[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 1/9] memory: Initialize MemoryRegionOps for RAM memory re
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [RFC PATCH 1/9] memory: Initialize MemoryRegionOps for RAM memory regions |
Date: |
Tue, 18 Aug 2020 11:58:47 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
On 8/18/20 11:52 AM, P J P wrote:
> +-- On Mon, 17 Aug 2020, Philippe Mathieu-Daudé wrote --+
> | Fix by initializing the MemoryRegionOps to ram_device_mem_ops, this way the
> | memory accesses are properly dispatched using
> | memory_region_ram_device_read() / memory_region_ram_device_write().
> |
> | Fixes: 4a2e242bbb ("memory: Don't use memcpy for ram_device regions")
> | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> | ---
> | Since v1: Corrected description (PJP)
> | Cc: P J P <ppandit@redhat.com>
> | ---
> | softmmu/memory.c | 10 ++++++++++
> | 1 file changed, 10 insertions(+)
> |
> | diff --git a/softmmu/memory.c b/softmmu/memory.c
> | index 651705b7d1..8139da1a58 100644
> | --- a/softmmu/memory.c
> | +++ b/softmmu/memory.c
> | @@ -1517,6 +1517,8 @@ void
> memory_region_init_ram_shared_nomigrate(MemoryRegion *mr,
> | Error *err = NULL;
> | memory_region_init(mr, owner, name, size);
> | mr->ram = true;
> | + mr->ops = &ram_device_mem_ops;
> | + mr->opaque = mr;
> | mr->terminates = true;
>
>
> I wonder if 'mr->ops = &ram_device_mem_ops' could be done in
> memory_region_init() instead?
I don't think so, because to use &ram_device_mem_ops handlers use
mr->opaque and mr->ram_block, so alias/io/iommu/rom types would
directly crash accessing these NULL fields.
>
> Otherwise looks okay.
Thanks!
>
> Thank you.
> --
> Prasad J Pandit / Red Hat Product Security Team
> 8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
>
- [RFC PATCH 0/9] hw/misc: Add support for interleaved memory accesses, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 2/9] qtest: Add local qtest_mem_as() getter, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 3/9] qtest: Directly use global address_space_memory when no CPU available, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 4/9] hw/misc: Add interleaver device to make interleaved memory accesses, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 1/9] memory: Initialize MemoryRegionOps for RAM memory regions, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 5/9] hw/misc: Add MMIO test device, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 9/9] hw/misc/interleaver: Display subregions in 'info mtree', Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 6/9] hw/core/null-machine: Allow to use the MMIO 'test' device, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 7/9] tests/qtest: Add generic MMIO tests, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 8/9] memory: Allow memory region to display its subregions own descriptions, Philippe Mathieu-Daudé, 2020/08/17
- Re: [RFC PATCH 0/9] hw/misc: Add support for interleaved memory accesses, no-reply, 2020/08/17
- Re: [RFC PATCH 0/9] hw/misc: Add support for interleaved memory accesses, Philippe Mathieu-Daudé, 2020/08/22
- Re: [RFC PATCH 0/9] hw/misc: Add support for interleaved memory accesses, Philippe Mathieu-Daudé, 2020/08/22