* [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1)
@ 2025-10-28 18:12 Philippe Mathieu-Daudé
2025-10-28 18:12 ` [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors Philippe Mathieu-Daudé
` (24 more replies)
0 siblings, 25 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé
- Use sysbus_mmio_get_region() instead of SysBusDevice::mmio[].memory
- Use memory_region_name() instead of MemoryRegion::name
- Use memory_region_size() instead of int128_get64(MemoryRegion::size)
- Add memory_region_get_address()
- Use memory_region_get_address() instead of MemoryRegion::addr
- Remove SysBusDevice::mmio[].addr
- Simplify SysBusDevice::mmio[]
Philippe Mathieu-Daudé (25):
hw/i386/microvm: Use proper SysBus accessors
hw/i386/ioapic: Use proper SysBus accessors
hw/timer/hpet: Use proper SysBus accessors
hw/acpi/cxl: Use proper SysBus accessors
hw/ppc/e500: Use proper SysBus accessors
hw/pci-bridge: Use proper SysBus accessors
hw/sysbus: Use memory_region_name()
hw/nvme/ctrl: Use memory_region_size()
hw/s390x: Use memory_region_size()
system/memory: Have memory_region_size() take a const argument
system/memory: Introduce memory_region_get_address()
migration/ram: Use memory_region_get_address()
hw/acpi: Use memory_region_get_address()
hw/fdt: Use memory_region_get_address()
hw/nvme: Use memory_region_get_address()
hw/s390x: Use memory_region_get_address()
hw/timer/hpet: Use memory_region_get_address()
hw/watchdog/aspeed: Use memory_region_get_address()
hw/pci-bridge: Use memory_region_get_address()
system/ioport: Use memory_region_get_address()
hw/sysbus: Use memory_region_get_address()
hw/sysbus: Hoist MemoryRegion in sysbus_mmio_map_common()
hw/sysbus: Remove sysbus_mmio_map_common() @may_overlap argument
hw/sysbus: Use memory_region_is_mapped() to check for mapped region
hw/sysbus: Simplify SysBusDevice::mmio
include/hw/sysbus.h | 5 +--
include/system/memory.h | 9 ++++-
hw/acpi/cxl.c | 10 +++--
hw/core/sysbus.c | 57 ++++++++++++-----------------
hw/i386/acpi-build.c | 8 ++--
hw/i386/kvm/ioapic.c | 3 +-
hw/i386/microvm-dt.c | 6 ++-
hw/loongarch/virt-acpi-build.c | 4 +-
hw/loongarch/virt-fdt-build.c | 4 +-
hw/nvme/ctrl.c | 15 +++++---
hw/pci-bridge/pci_expander_bridge.c | 6 ++-
hw/ppc/e500.c | 2 +-
hw/s390x/s390-pci-inst.c | 23 ++++++++----
hw/timer/hpet.c | 4 +-
hw/watchdog/wdt_aspeed.c | 2 +-
migration/ram.c | 11 +++---
system/ioport.c | 21 +++++++----
system/memory.c | 7 +++-
18 files changed, 113 insertions(+), 84 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 71+ messages in thread
* [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 5:54 ` Thomas Huth
2025-10-30 6:58 ` Zhao Liu
2025-10-28 18:12 ` [PATCH v3 02/25] hw/i386/ioapic: " Philippe Mathieu-Daudé
` (23 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Michael S. Tsirkin, Marcel Apfelbaum,
Paolo Bonzini, Richard Henderson, Eduardo Habkost
SysBusDevice::mmio[] is private data of SysBusDevice, use
sysbus_mmio_get_region() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i386/microvm-dt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/i386/microvm-dt.c b/hw/i386/microvm-dt.c
index cb27dfd732e..d7f49bc1b5f 100644
--- a/hw/i386/microvm-dt.c
+++ b/hw/i386/microvm-dt.c
@@ -71,7 +71,8 @@ static void dt_add_virtio(MicrovmMachineState *mms, VirtIOMMIOProxy *mmio)
return;
}
- hwaddr base = dev->mmio[0].addr;
+ MemoryRegion *mr = sysbus_mmio_get_region(dev, 0);
+ hwaddr base = mr->addr;
hwaddr size = 512;
unsigned index = (base - VIRTIO_MMIO_BASE) / size;
uint32_t irq = mms->virtio_irq_base + index;
@@ -150,7 +151,8 @@ static void dt_add_pcie(MicrovmMachineState *mms)
static void dt_add_ioapic(MicrovmMachineState *mms, SysBusDevice *dev)
{
- hwaddr base = dev->mmio[0].addr;
+ MemoryRegion *mr = sysbus_mmio_get_region(dev, 0);
+ hwaddr base = mr->addr;
char *nodename;
uint32_t ph;
int index;
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 02/25] hw/i386/ioapic: Use proper SysBus accessors
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
2025-10-28 18:12 ` [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-30 6:58 ` Zhao Liu
2025-10-30 7:03 ` Zhao Liu
2025-10-28 18:12 ` [PATCH v3 03/25] hw/timer/hpet: " Philippe Mathieu-Daudé
` (22 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Michael S. Tsirkin, Marcel Apfelbaum,
Paolo Bonzini, Richard Henderson, Eduardo Habkost
SysBusDevice::mmio[] is private data of SysBusDevice, use
sysbus_mmio_get_region() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i386/kvm/ioapic.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c
index 693ee978a12..0519432edbe 100644
--- a/hw/i386/kvm/ioapic.c
+++ b/hw/i386/kvm/ioapic.c
@@ -80,6 +80,7 @@ static void kvm_ioapic_put(IOAPICCommonState *s)
{
struct kvm_irqchip chip;
struct kvm_ioapic_state *kioapic;
+ MemoryRegion *mr = sysbus_mmio_get_region(s->busdev, 0);
int ret, i;
chip.chip_id = KVM_IRQCHIP_IOAPIC;
@@ -87,7 +88,7 @@ static void kvm_ioapic_put(IOAPICCommonState *s)
kioapic->id = s->id;
kioapic->ioregsel = s->ioregsel;
- kioapic->base_address = s->busdev.mmio[0].addr;
+ kioapic->base_address = mr->addr;
kioapic->irr = s->irr;
for (i = 0; i < IOAPIC_NUM_PINS; i++) {
kioapic->redirtbl[i].bits = s->ioredtbl[i];
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 03/25] hw/timer/hpet: Use proper SysBus accessors
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
2025-10-28 18:12 ` [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors Philippe Mathieu-Daudé
2025-10-28 18:12 ` [PATCH v3 02/25] hw/i386/ioapic: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-30 6:57 ` Zhao Liu
2025-10-28 18:12 ` [PATCH v3 04/25] hw/acpi/cxl: " Philippe Mathieu-Daudé
` (21 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Michael S. Tsirkin, Paolo Bonzini
SysBusDevice::mmio[] is private data of SysBusDevice, use
sysbus_mmio_get_region() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/timer/hpet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 1acba4fa9db..c1b96d0a89f 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -654,7 +654,7 @@ static const MemoryRegionOps hpet_ram_ops = {
static void hpet_reset(DeviceState *d)
{
HPETState *s = HPET(d);
- SysBusDevice *sbd = SYS_BUS_DEVICE(d);
+ MemoryRegion *mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(d), 0);
int i;
for (i = 0; i < s->num_timers; i++) {
@@ -677,7 +677,7 @@ static void hpet_reset(DeviceState *d)
s->hpet_offset = 0ULL;
s->config = 0ULL;
hpet_fw_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability;
- hpet_fw_cfg.hpet[s->hpet_id].address = sbd->mmio[0].addr;
+ hpet_fw_cfg.hpet[s->hpet_id].address = mr->addr;
/* to document that the RTC lowers its output on reset as well */
s->rtc_irq_level = 0;
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 04/25] hw/acpi/cxl: Use proper SysBus accessors
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 03/25] hw/timer/hpet: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 7:56 ` Richard Henderson
2025-10-29 11:05 ` Jonathan Cameron via
2025-10-28 18:12 ` [PATCH v3 05/25] hw/ppc/e500: " Philippe Mathieu-Daudé
` (20 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Michael S. Tsirkin, Igor Mammedov,
Ani Sinha
SysBusDevice::mmio[] is private data of SysBusDevice, use
sysbus_mmio_get_region() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/acpi/cxl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c
index 75d5b30bb8b..77c99dfb184 100644
--- a/hw/acpi/cxl.c
+++ b/hw/acpi/cxl.c
@@ -104,7 +104,7 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
{
PXBDev *pxb = PXB_DEV(cxl);
SysBusDevice *sbd = SYS_BUS_DEVICE(cxl->cxl_host_bridge);
- struct MemoryRegion *mr = sbd->mmio[0].memory;
+ MemoryRegion *mr = sysbus_mmio_get_region(sbd, 0);
/* Type */
build_append_int_noprefix(table_data, 0, 1);
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 05/25] hw/ppc/e500: Use proper SysBus accessors
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 04/25] hw/acpi/cxl: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 7:56 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 06/25] hw/pci-bridge: " Philippe Mathieu-Daudé
` (19 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Bernhard Beschow
SysBusDevice::mmio[] is private data of SysBusDevice, use
sysbus_mmio_get_region() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/ppc/e500.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 8842f7f6b88..fe1aeffe676 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -887,7 +887,7 @@ static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms,
s = SYS_BUS_DEVICE(dev);
memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET,
- s->mmio[0].memory);
+ sysbus_mmio_get_region(s, 0));
return dev;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 06/25] hw/pci-bridge: Use proper SysBus accessors
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 05/25] hw/ppc/e500: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-28 19:28 ` BALATON Zoltan
2025-10-28 18:12 ` [PATCH v3 07/25] hw/sysbus: Use memory_region_name() Philippe Mathieu-Daudé
` (18 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, BALATON Zoltan, Michael S. Tsirkin,
Marcel Apfelbaum
SysBusDevice::mmio[] is private data of SysBusDevice, use
sysbus_mmio_get_region() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
---
hw/pci-bridge/pci_expander_bridge.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index 1bcceddbc4d..aa55749954a 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -157,9 +157,11 @@ static char *pxb_host_ofw_unit_address(const SysBusDevice *dev)
main_host = PCI_HOST_BRIDGE(pxb_dev_base->parent_bus->parent);
main_host_sbd = SYS_BUS_DEVICE(main_host);
- if (main_host_sbd->num_mmio > 0) {
+ if (sysbus_has_mmio(main_host_sbd, 0)) {
+ MemoryRegion *mr = sysbus_mmio_get_region(main_host_sbd, 0);
+
return g_strdup_printf(HWADDR_FMT_plx ",%x",
- main_host_sbd->mmio[0].addr, position + 1);
+ mr->addr, position + 1);
}
if (main_host_sbd->num_pio > 0) {
return g_strdup_printf("i%04x,%x",
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 07/25] hw/sysbus: Use memory_region_name()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 06/25] hw/pci-bridge: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 7:57 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 08/25] hw/nvme/ctrl: Use memory_region_size() Philippe Mathieu-Daudé
` (17 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
MemoryRegion::name is private data of MemoryRegion. Use the
proper memory_region_name() accessor, which might return a
different name.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/core/sysbus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index ae447c1196a..d33be6b2b52 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -154,7 +154,7 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr)
int sysbus_mmio_map_name(SysBusDevice *dev, const char *name, hwaddr addr)
{
for (int i = 0; i < dev->num_mmio; i++) {
- if (!strcmp(dev->mmio[i].memory->name, name)) {
+ if (!strcmp(memory_region_name(dev->mmio[i].memory), name)) {
sysbus_mmio_map(dev, i, addr);
return i;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 08/25] hw/nvme/ctrl: Use memory_region_size()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 07/25] hw/sysbus: Use memory_region_name() Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 7:58 ` Richard Henderson
2025-10-30 7:59 ` Klaus Jensen
2025-10-28 18:12 ` [PATCH v3 09/25] hw/s390x: " Philippe Mathieu-Daudé
` (16 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Keith Busch, Klaus Jensen,
Jesper Devantier
MemoryRegion::size is private data of MemoryRegion,
use the proper memory_region_size() getter to get it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/nvme/ctrl.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index cd81f739975..9505f291f62 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -514,14 +514,16 @@ static bool nvme_update_ruh(NvmeCtrl *n, NvmeNamespace *ns, uint16_t pid)
static bool nvme_addr_is_cmb(NvmeCtrl *n, hwaddr addr)
{
+ MemoryRegion *mr;
hwaddr hi, lo;
if (!n->cmb.cmse) {
return false;
}
+ mr = &n->cmb.mem;
lo = n->params.legacy_cmb ? n->cmb.mem.addr : n->cmb.cba;
- hi = lo + int128_get64(n->cmb.mem.size);
+ hi = lo + memory_region_size(mr);
return addr >= lo && addr < hi;
}
@@ -540,7 +542,7 @@ static bool nvme_addr_is_pmr(NvmeCtrl *n, hwaddr addr)
return false;
}
- hi = n->pmr.cba + int128_get64(n->pmr.dev->mr.size);
+ hi = n->pmr.cba + memory_region_size(&n->pmr.dev->mr);
return addr >= n->pmr.cba && addr < hi;
}
@@ -563,7 +565,7 @@ static inline bool nvme_addr_is_iomem(NvmeCtrl *n, hwaddr addr)
* in BAR0 as well, then this must be changed.
*/
lo = n->bar0.addr;
- hi = lo + int128_get64(n->bar0.size);
+ hi = lo + memory_region_size(&n->bar0);
return addr >= lo && addr < hi;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 09/25] hw/s390x: Use memory_region_size()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 08/25] hw/nvme/ctrl: Use memory_region_size() Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 5:42 ` Thomas Huth
` (2 more replies)
2025-10-28 18:12 ` [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument Philippe Mathieu-Daudé
` (15 subsequent siblings)
24 siblings, 3 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Matthew Rosato, Eric Farman,
Halil Pasic, Christian Borntraeger, Thomas Huth,
Richard Henderson, David Hildenbrand, Ilya Leoshkevich
MemoryRegion::size is private data of MemoryRegion,
use the proper memory_region_size() getter to get it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/s390x/s390-pci-inst.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index a3bb5aa2216..5841dfc4fec 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -396,7 +396,7 @@ static MemoryRegion *s390_get_subregion(MemoryRegion *mr, uint64_t offset,
uint64_t subregion_size;
QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) {
- subregion_size = int128_get64(subregion->size);
+ subregion_size = memory_region_size(subregion);
if ((offset >= subregion->addr) &&
(offset + len) <= (subregion->addr + subregion_size)) {
mr = subregion;
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 09/25] hw/s390x: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
` (3 more replies)
2025-10-28 18:12 ` [PATCH v3 11/25] system/memory: Introduce memory_region_get_address() Philippe Mathieu-Daudé
` (14 subsequent siblings)
24 siblings, 4 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini, Peter Xu,
David Hildenbrand
Since the @mr argument is not modified, it can be const.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/memory.h | 2 +-
system/memory.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/system/memory.h b/include/system/memory.h
index 3bd5ffa5e0d..45de6946812 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -1776,7 +1776,7 @@ Object *memory_region_owner(MemoryRegion *mr);
*
* @mr: the memory region being queried.
*/
-uint64_t memory_region_size(MemoryRegion *mr);
+uint64_t memory_region_size(const MemoryRegion *mr);
/**
* memory_region_is_ram: check whether a memory region is random access
diff --git a/system/memory.c b/system/memory.c
index 8b84661ae36..d1c060b2b50 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1870,7 +1870,7 @@ void memory_region_unref(MemoryRegion *mr)
}
}
-uint64_t memory_region_size(MemoryRegion *mr)
+uint64_t memory_region_size(const MemoryRegion *mr)
{
if (int128_eq(mr->size, int128_2_64())) {
return UINT64_MAX;
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 11/25] system/memory: Introduce memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
` (3 more replies)
2025-10-28 18:12 ` [PATCH v3 12/25] migration/ram: Use memory_region_get_address() Philippe Mathieu-Daudé
` (13 subsequent siblings)
24 siblings, 4 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Peter Maydell, Paolo Bonzini,
Peter Xu, David Hildenbrand
MemoryRegion::addr is private data of MemoryRegion.
Introduce memory_region_get_address() to get it,
similar to memory_region_set_address() to set it.
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/memory.h | 7 +++++++
system/memory.c | 5 +++++
2 files changed, 12 insertions(+)
diff --git a/include/system/memory.h b/include/system/memory.h
index 45de6946812..d2a5850a360 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -2481,6 +2481,13 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled);
*/
void memory_region_set_address(MemoryRegion *mr, hwaddr addr);
+/**
+ * memory_region_get_address: Get the base address of a memory region
+ *
+ * @mr: the region to be queried
+ */
+hwaddr memory_region_get_address(const MemoryRegion *mr);
+
/*
* memory_region_set_size: dynamically update the size of a region.
*
diff --git a/system/memory.c b/system/memory.c
index d1c060b2b50..f48b586122d 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -2777,6 +2777,11 @@ void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
}
}
+hwaddr memory_region_get_address(const MemoryRegion *mr)
+{
+ return mr->addr;
+}
+
void memory_region_set_alias_offset(MemoryRegion *mr, hwaddr offset)
{
assert(mr->alias);
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 12/25] migration/ram: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 11/25] system/memory: Introduce memory_region_get_address() Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
2025-10-29 8:28 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 13/25] hw/acpi: " Philippe Mathieu-Daudé
` (12 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Peter Xu, Fabiano Rosas
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
migration/ram.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 5eef2efc781..3330c102977 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -3144,7 +3144,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque, Error **errp)
qemu_put_be64(f, block->page_size);
}
if (migrate_ignore_shared()) {
- qemu_put_be64(f, block->mr->addr);
+ qemu_put_be64(f, memory_region_get_address(block->mr));
}
if (migrate_mapped_ram()) {
@@ -4190,11 +4190,12 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length)
}
if (migrate_ignore_shared()) {
hwaddr addr = qemu_get_be64(f);
- if (migrate_ram_is_ignored(block) &&
- block->mr->addr != addr) {
+ hwaddr block_addr = memory_region_get_address(block->mr);
+
+ if (migrate_ram_is_ignored(block) && block_addr != addr) {
error_report("Mismatched GPAs for block %s "
- "%" PRId64 "!= %" PRId64, block->idstr,
- (uint64_t)addr, (uint64_t)block->mr->addr);
+ "0x" HWADDR_FMT_plx "!= 0x" HWADDR_FMT_plx,
+ block->idstr, addr, block_addr);
return -EINVAL;
}
}
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 13/25] hw/acpi: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 12/25] migration/ram: Use memory_region_get_address() Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:41 ` Richard Henderson
2025-10-29 11:06 ` Jonathan Cameron via
2025-10-28 18:12 ` [PATCH v3 14/25] hw/fdt: " Philippe Mathieu-Daudé
` (11 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Michael S. Tsirkin, Igor Mammedov,
Ani Sinha, Marcel Apfelbaum, Paolo Bonzini, Richard Henderson,
Eduardo Habkost, Song Gao, Bibo Mao, Jiaxun Yang
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/acpi/cxl.c | 8 ++++++--
hw/i386/acpi-build.c | 8 +++++---
hw/loongarch/virt-acpi-build.c | 4 ++--
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c
index 77c99dfb184..92c032851cc 100644
--- a/hw/acpi/cxl.c
+++ b/hw/acpi/cxl.c
@@ -105,6 +105,7 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
PXBDev *pxb = PXB_DEV(cxl);
SysBusDevice *sbd = SYS_BUS_DEVICE(cxl->cxl_host_bridge);
MemoryRegion *mr = sysbus_mmio_get_region(sbd, 0);
+ hwaddr container_base_addr = memory_region_get_address(mr->container);
/* Type */
build_append_int_noprefix(table_data, 0, 1);
@@ -125,7 +126,9 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
build_append_int_noprefix(table_data, 0, 4);
/* Base - subregion within a container that is in PA space */
- build_append_int_noprefix(table_data, mr->container->addr + mr->addr, 8);
+ build_append_int_noprefix(table_data,
+ container_base_addr
+ + memory_region_get_address(mr), 8);
/* Length */
build_append_int_noprefix(table_data, memory_region_size(mr), 8);
@@ -154,7 +157,8 @@ static void cedt_build_cfmws(CXLFixedWindow *fw, Aml *cedt)
build_append_int_noprefix(table_data, 0, 4);
/* Base HPA */
- build_append_int_noprefix(table_data, fw->mr.addr, 8);
+ build_append_int_noprefix(table_data,
+ memory_region_get_address(&fw->mr), 8);
/* Window Size */
build_append_int_noprefix(table_data, fw->size, 8);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 9446a9f862c..201fdbb39f0 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1039,7 +1039,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
/* Handle the ranges for the PXB expanders */
if (pci_bus_is_cxl(bus)) {
MemoryRegion *mr = &pcms->cxl_devices_state.host_mr;
- uint64_t base = mr->addr;
+ hwaddr base = memory_region_get_address(mr);
cxl_present = true;
crs_range_insert(crs_range_set.mem_ranges, base,
@@ -1822,7 +1822,8 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id,
/* Capability offset */
build_append_int_noprefix(table_data, s->pci->capab_offset, 2);
/* IOMMU base address */
- build_append_int_noprefix(table_data, s->mr_mmio.addr, 8);
+ build_append_int_noprefix(table_data,
+ memory_region_get_address(&s->mr_mmio), 8);
/* PCI Segment Group */
build_append_int_noprefix(table_data, 0, 2);
/* IOMMU info */
@@ -1857,7 +1858,8 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id,
/* Capability offset */
build_append_int_noprefix(table_data, s->pci->capab_offset, 2);
/* IOMMU base address */
- build_append_int_noprefix(table_data, s->mr_mmio.addr, 8);
+ build_append_int_noprefix(table_data,
+ memory_region_get_address(&s->mr_mmio), 8);
/* PCI Segment Group */
build_append_int_noprefix(table_data, 0, 2);
/* IOMMU info */
diff --git a/hw/loongarch/virt-acpi-build.c b/hw/loongarch/virt-acpi-build.c
index 3694c9827f0..101d083ae6a 100644
--- a/hw/loongarch/virt-acpi-build.c
+++ b/hw/loongarch/virt-acpi-build.c
@@ -409,11 +409,11 @@ static void build_flash_aml(Aml *scope, LoongArchVirtMachineState *lvms)
hwaddr flash1_size;
flash_mem = pflash_cfi01_get_memory(lvms->flash[0]);
- flash0_base = flash_mem->addr;
+ flash0_base = memory_region_get_address(flash_mem);
flash0_size = memory_region_size(flash_mem);
flash_mem = pflash_cfi01_get_memory(lvms->flash[1]);
- flash1_base = flash_mem->addr;
+ flash1_base = memory_region_get_address(flash_mem);
flash1_size = memory_region_size(flash_mem);
dev = aml_device("FLS0");
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 14/25] hw/fdt: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 13/25] hw/acpi: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:41 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 15/25] hw/nvme: " Philippe Mathieu-Daudé
` (10 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Michael S. Tsirkin, Marcel Apfelbaum,
Paolo Bonzini, Richard Henderson, Eduardo Habkost, Song Gao,
Bibo Mao, Jiaxun Yang
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i386/microvm-dt.c | 4 ++--
hw/loongarch/virt-fdt-build.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/i386/microvm-dt.c b/hw/i386/microvm-dt.c
index d7f49bc1b5f..5b64f5b7f30 100644
--- a/hw/i386/microvm-dt.c
+++ b/hw/i386/microvm-dt.c
@@ -72,7 +72,7 @@ static void dt_add_virtio(MicrovmMachineState *mms, VirtIOMMIOProxy *mmio)
}
MemoryRegion *mr = sysbus_mmio_get_region(dev, 0);
- hwaddr base = mr->addr;
+ hwaddr base = memory_region_get_address(mr);
hwaddr size = 512;
unsigned index = (base - VIRTIO_MMIO_BASE) / size;
uint32_t irq = mms->virtio_irq_base + index;
@@ -152,7 +152,7 @@ static void dt_add_pcie(MicrovmMachineState *mms)
static void dt_add_ioapic(MicrovmMachineState *mms, SysBusDevice *dev)
{
MemoryRegion *mr = sysbus_mmio_get_region(dev, 0);
- hwaddr base = mr->addr;
+ hwaddr base = memory_region_get_address(mr);
char *nodename;
uint32_t ph;
int index;
diff --git a/hw/loongarch/virt-fdt-build.c b/hw/loongarch/virt-fdt-build.c
index 1f0ba01f711..54524e5aca9 100644
--- a/hw/loongarch/virt-fdt-build.c
+++ b/hw/loongarch/virt-fdt-build.c
@@ -195,11 +195,11 @@ static void fdt_add_flash_node(LoongArchVirtMachineState *lvms)
hwaddr flash1_size;
flash_mem = pflash_cfi01_get_memory(lvms->flash[0]);
- flash0_base = flash_mem->addr;
+ flash0_base = memory_region_get_address(flash_mem);
flash0_size = memory_region_size(flash_mem);
flash_mem = pflash_cfi01_get_memory(lvms->flash[1]);
- flash1_base = flash_mem->addr;
+ flash1_base = memory_region_get_address(flash_mem);
flash1_size = memory_region_size(flash_mem);
nodename = g_strdup_printf("/flash@%" PRIx64, flash0_base);
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 15/25] hw/nvme: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 14/25] hw/fdt: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:42 ` Richard Henderson
2025-10-30 7:58 ` Klaus Jensen
2025-10-28 18:12 ` [PATCH v3 16/25] hw/s390x: " Philippe Mathieu-Daudé
` (9 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Keith Busch, Klaus Jensen,
Jesper Devantier
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/nvme/ctrl.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 9505f291f62..65cc1c8ee52 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -522,7 +522,7 @@ static bool nvme_addr_is_cmb(NvmeCtrl *n, hwaddr addr)
}
mr = &n->cmb.mem;
- lo = n->params.legacy_cmb ? n->cmb.mem.addr : n->cmb.cba;
+ lo = n->params.legacy_cmb ? memory_region_get_address(mr) : n->cmb.cba;
hi = lo + memory_region_size(mr);
return addr >= lo && addr < hi;
@@ -530,7 +530,8 @@ static bool nvme_addr_is_cmb(NvmeCtrl *n, hwaddr addr)
static inline void *nvme_addr_to_cmb(NvmeCtrl *n, hwaddr addr)
{
- hwaddr base = n->params.legacy_cmb ? n->cmb.mem.addr : n->cmb.cba;
+ hwaddr base = n->params.legacy_cmb ? memory_region_get_address(&n->cmb.mem)
+ : n->cmb.cba;
return &n->cmb.buf[addr - base];
}
@@ -564,7 +565,7 @@ static inline bool nvme_addr_is_iomem(NvmeCtrl *n, hwaddr addr)
* that if the device model is ever changed to allow the CMB to be located
* in BAR0 as well, then this must be changed.
*/
- lo = n->bar0.addr;
+ lo = memory_region_get_address(&n->bar0);
hi = lo + memory_region_size(&n->bar0);
return addr >= lo && addr < hi;
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 16/25] hw/s390x: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 15/25] hw/nvme: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 5:55 ` Thomas Huth
2025-10-29 8:28 ` David Hildenbrand
2025-10-28 18:12 ` [PATCH v3 17/25] hw/timer/hpet: " Philippe Mathieu-Daudé
` (8 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Matthew Rosato, Eric Farman,
Halil Pasic, Christian Borntraeger, Thomas Huth,
Richard Henderson, David Hildenbrand, Ilya Leoshkevich
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/s390x/s390-pci-inst.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 5841dfc4fec..d4adf782ca1 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -394,11 +394,14 @@ static MemoryRegion *s390_get_subregion(MemoryRegion *mr, uint64_t offset,
{
MemoryRegion *subregion;
uint64_t subregion_size;
+ hwaddr subregion_addr;
QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) {
subregion_size = memory_region_size(subregion);
- if ((offset >= subregion->addr) &&
- (offset + len) <= (subregion->addr + subregion_size)) {
+ subregion_addr = memory_region_get_address(subregion);
+
+ if ((offset >= subregion_addr) &&
+ (offset + len) <= (subregion_addr + subregion_size)) {
mr = subregion;
break;
}
@@ -410,11 +413,12 @@ static MemTxResult zpci_read_bar(S390PCIBusDevice *pbdev, uint8_t pcias,
uint64_t offset, uint64_t *data, uint8_t len)
{
MemoryRegion *mr;
+ hwaddr subregion_base_addr;
mr = pbdev->pdev->io_regions[pcias].memory;
mr = s390_get_subregion(mr, offset, len);
- offset -= mr->addr;
- return memory_region_dispatch_read(mr, offset, data,
+ subregion_base_addr = memory_region_get_address(mr);
+ return memory_region_dispatch_read(mr, offset - subregion_base_addr, data,
size_memop(len) | MO_BE,
MEMTXATTRS_UNSPECIFIED);
}
@@ -510,11 +514,12 @@ static MemTxResult zpci_write_bar(S390PCIBusDevice *pbdev, uint8_t pcias,
uint64_t offset, uint64_t data, uint8_t len)
{
MemoryRegion *mr;
+ hwaddr subregion_base_addr;
mr = pbdev->pdev->io_regions[pcias].memory;
mr = s390_get_subregion(mr, offset, len);
- offset -= mr->addr;
- return memory_region_dispatch_write(mr, offset, data,
+ subregion_base_addr = memory_region_get_address(mr);
+ return memory_region_dispatch_write(mr, offset - subregion_base_addr, data,
size_memop(len) | MO_BE,
MEMTXATTRS_UNSPECIFIED);
}
@@ -832,6 +837,7 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
S390PCIBusDevice *pbdev;
MemoryRegion *mr;
MemTxResult result;
+ hwaddr subregion_base_addr;
uint64_t offset;
int i;
uint32_t fh;
@@ -900,7 +906,8 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
mr = pbdev->pdev->io_regions[pcias].memory;
mr = s390_get_subregion(mr, offset, len);
- offset -= mr->addr;
+ subregion_base_addr = memory_region_get_address(mr);
+ offset -= subregion_base_addr;
for (i = 0; i < len; i += 8) {
if (!memory_region_access_valid(mr, offset + i, 8, true,
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 17/25] hw/timer/hpet: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 16/25] hw/s390x: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:46 ` Richard Henderson
2025-10-30 6:52 ` Zhao Liu
2025-10-28 18:12 ` [PATCH v3 18/25] hw/watchdog/aspeed: " Philippe Mathieu-Daudé
` (7 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Michael S. Tsirkin, Paolo Bonzini
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/timer/hpet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index c1b96d0a89f..e2cd0c9cccb 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -677,7 +677,7 @@ static void hpet_reset(DeviceState *d)
s->hpet_offset = 0ULL;
s->config = 0ULL;
hpet_fw_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability;
- hpet_fw_cfg.hpet[s->hpet_id].address = mr->addr;
+ hpet_fw_cfg.hpet[s->hpet_id].address = memory_region_get_address(mr);
/* to document that the RTC lowers its output on reset as well */
s->rtc_irq_level = 0;
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 18/25] hw/watchdog/aspeed: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 17/25] hw/timer/hpet: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:46 ` Richard Henderson
2025-10-29 17:13 ` Cédric Le Goater
2025-10-28 18:12 ` [PATCH v3 19/25] hw/pci-bridge: " Philippe Mathieu-Daudé
` (6 subsequent siblings)
24 siblings, 2 replies; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Cédric Le Goater, Peter Maydell,
Steven Lee, Troy Lee, Jamin Lin, Andrew Jeffery, Joel Stanley
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/watchdog/wdt_aspeed.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
index 30226435efc..f842d8e973a 100644
--- a/hw/watchdog/wdt_aspeed.c
+++ b/hw/watchdog/wdt_aspeed.c
@@ -274,7 +274,7 @@ static void aspeed_wdt_timer_expired(void *dev)
}
qemu_log_mask(CPU_LOG_RESET, "Watchdog timer %" HWADDR_PRIx " expired.\n",
- s->iomem.addr);
+ memory_region_get_address(&s->iomem));
watchdog_perform_action();
timer_del(s->timer);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 19/25] hw/pci-bridge: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 18/25] hw/watchdog/aspeed: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:48 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 20/25] system/ioport: " Philippe Mathieu-Daudé
` (5 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Michael S. Tsirkin, Marcel Apfelbaum
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/pci-bridge/pci_expander_bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index aa55749954a..0cb94fca9c0 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -161,7 +161,7 @@ static char *pxb_host_ofw_unit_address(const SysBusDevice *dev)
MemoryRegion *mr = sysbus_mmio_get_region(main_host_sbd, 0);
return g_strdup_printf(HWADDR_FMT_plx ",%x",
- mr->addr, position + 1);
+ memory_region_get_address(mr), position + 1);
}
if (main_host_sbd->num_pio > 0) {
return g_strdup_printf("i%04x,%x",
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 20/25] system/ioport: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 19/25] hw/pci-bridge: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:49 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 21/25] hw/sysbus: " Philippe Mathieu-Daudé
` (4 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini, Peter Xu,
David Hildenbrand
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
system/ioport.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/system/ioport.c b/system/ioport.c
index 4f96e9119fc..9bb8df5e757 100644
--- a/system/ioport.c
+++ b/system/ioport.c
@@ -177,17 +177,19 @@ static uint64_t portio_read(void *opaque, hwaddr addr, unsigned size)
{
MemoryRegionPortioList *mrpio = opaque;
const MemoryRegionPortio *mrp = find_portio(mrpio, addr, size, false);
+ hwaddr pio_base_addr = memory_region_get_address(&mrpio->mr);
uint64_t data;
data = ((uint64_t)1 << (size * 8)) - 1;
if (mrp) {
- data = mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr);
+ data = mrp->read(mrpio->portio_opaque, pio_base_addr + addr);
} else if (size == 2) {
mrp = find_portio(mrpio, addr, 1, false);
if (mrp) {
- data = mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr);
+ data = mrp->read(mrpio->portio_opaque, pio_base_addr + addr);
if (addr + 1 < mrp->offset + mrp->len) {
- data |= mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr + 1) << 8;
+ data |= mrp->read(mrpio->portio_opaque,
+ pio_base_addr + addr + 1) << 8;
} else {
data |= 0xff00;
}
@@ -201,15 +203,17 @@ static void portio_write(void *opaque, hwaddr addr, uint64_t data,
{
MemoryRegionPortioList *mrpio = opaque;
const MemoryRegionPortio *mrp = find_portio(mrpio, addr, size, true);
+ hwaddr pio_base_addr = memory_region_get_address(&mrpio->mr);
if (mrp) {
- mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr, data);
+ mrp->write(mrpio->portio_opaque, pio_base_addr + addr, data);
} else if (size == 2) {
mrp = find_portio(mrpio, addr, 1, true);
if (mrp) {
- mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr, data & 0xff);
+ mrp->write(mrpio->portio_opaque, pio_base_addr + addr, data & 0xff);
if (addr + 1 < mrp->offset + mrp->len) {
- mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr + 1, data >> 8);
+ mrp->write(mrpio->portio_opaque,
+ pio_base_addr + addr + 1, data >> 8);
}
}
}
@@ -335,12 +339,15 @@ void portio_list_set_enabled(PortioList *piolist, bool enabled)
void portio_list_set_address(PortioList *piolist, uint32_t addr)
{
MemoryRegionPortioList *mrpio;
+ hwaddr pio_base_addr;
unsigned i, j;
for (i = 0; i < piolist->nr; ++i) {
mrpio = container_of(piolist->regions[i], MemoryRegionPortioList, mr);
+ pio_base_addr = memory_region_get_address(&mrpio->mr);
+
memory_region_set_address(&mrpio->mr,
- mrpio->mr.addr - piolist->addr + addr);
+ pio_base_addr - piolist->addr + addr);
for (j = 0; mrpio->ports[j].size; ++j) {
mrpio->ports[j].offset += addr - piolist->addr;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 21/25] hw/sysbus: Use memory_region_get_address()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 20/25] system/ioport: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:52 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 22/25] hw/sysbus: Hoist MemoryRegion in sysbus_mmio_map_common() Philippe Mathieu-Daudé
` (3 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
MemoryRegion::addr is private data of MemoryRegion, use
memory_region_get_address() to access it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/sysbus.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index d33be6b2b52..414b3f806d1 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -257,13 +257,14 @@ bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp)
static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
{
SysBusDevice *s = SYS_BUS_DEVICE(dev);
- hwaddr size;
- int i;
- for (i = 0; i < s->num_mmio; i++) {
- size = memory_region_size(s->mmio[i].memory);
- monitor_printf(mon, "%*smmio " HWADDR_FMT_plx "/" HWADDR_FMT_plx "\n",
- indent, "", s->mmio[i].addr, size);
+ for (int i = 0; i < s->num_mmio; i++) {
+ MemoryRegion *mr = sysbus_mmio_get_region(s, i);
+ hwaddr addr = memory_region_get_address(mr);
+ uint64_t size = memory_region_size(mr);
+
+ monitor_printf(mon, "%*smmio " HWADDR_FMT_plx "/%016" PRIx64 "\n",
+ indent, "", addr, size);
}
}
@@ -282,8 +283,10 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev)
}
}
if (s->num_mmio) {
+ MemoryRegion *mr = sysbus_mmio_get_region(s, 0);
+
return g_strdup_printf("%s@" HWADDR_FMT_plx, qdev_fw_name(dev),
- s->mmio[0].addr);
+ memory_region_get_address(mr));
}
if (s->num_pio) {
return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]);
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 22/25] hw/sysbus: Hoist MemoryRegion in sysbus_mmio_map_common()
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 21/25] hw/sysbus: " Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:52 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 23/25] hw/sysbus: Remove sysbus_mmio_map_common() @may_overlap argument Philippe Mathieu-Daudé
` (2 subsequent siblings)
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
In order to make the next commit easier to review,
use the local @mr variable in sysbus_mmio_map_common().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/sysbus.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 414b3f806d1..dca6e67a92d 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -122,7 +122,10 @@ bool sysbus_has_mmio(const SysBusDevice *dev, unsigned int n)
static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
bool may_overlap, int priority)
{
+ MemoryRegion *mr;
+
assert(n >= 0 && n < dev->num_mmio);
+ mr = dev->mmio[n].memory;
if (dev->mmio[n].addr == addr) {
/* ??? region already mapped here. */
@@ -130,13 +133,13 @@ static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
}
if (dev->mmio[n].addr != (hwaddr)-1) {
/* Unregister previous mapping. */
- memory_region_del_subregion(get_system_memory(), dev->mmio[n].memory);
+ memory_region_del_subregion(get_system_memory(), mr);
}
dev->mmio[n].addr = addr;
if (may_overlap) {
memory_region_add_subregion_overlap(get_system_memory(),
addr,
- dev->mmio[n].memory,
+ mr,
priority);
}
else {
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 23/25] hw/sysbus: Remove sysbus_mmio_map_common() @may_overlap argument
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 22/25] hw/sysbus: Hoist MemoryRegion in sysbus_mmio_map_common() Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:53 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 24/25] hw/sysbus: Use memory_region_is_mapped() to check for mapped region Philippe Mathieu-Daudé
2025-10-28 18:12 ` [PATCH v3 25/25] hw/sysbus: Simplify SysBusDevice::mmio Philippe Mathieu-Daudé
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
memory_region_add_subregion_overlap(priority=0) is
identical to memory_region_add_subregion(). Just use
the former to simplify.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/sysbus.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index dca6e67a92d..e6acf8dba3b 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -120,7 +120,7 @@ bool sysbus_has_mmio(const SysBusDevice *dev, unsigned int n)
}
static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
- bool may_overlap, int priority)
+ int priority)
{
MemoryRegion *mr;
@@ -136,22 +136,13 @@ static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
memory_region_del_subregion(get_system_memory(), mr);
}
dev->mmio[n].addr = addr;
- if (may_overlap) {
- memory_region_add_subregion_overlap(get_system_memory(),
- addr,
- mr,
- priority);
- }
- else {
- memory_region_add_subregion(get_system_memory(),
- addr,
- dev->mmio[n].memory);
- }
+ memory_region_add_subregion_overlap(get_system_memory(),
+ addr, mr, priority);
}
void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr)
{
- sysbus_mmio_map_common(dev, n, addr, false, 0);
+ sysbus_mmio_map_common(dev, n, addr, 0);
}
int sysbus_mmio_map_name(SysBusDevice *dev, const char *name, hwaddr addr)
@@ -168,7 +159,7 @@ int sysbus_mmio_map_name(SysBusDevice *dev, const char *name, hwaddr addr)
void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr,
int priority)
{
- sysbus_mmio_map_common(dev, n, addr, true, priority);
+ sysbus_mmio_map_common(dev, n, addr, priority);
}
/* Request an IRQ source. The actual IRQ object may be populated later. */
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 24/25] hw/sysbus: Use memory_region_is_mapped() to check for mapped region
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 23/25] hw/sysbus: Remove sysbus_mmio_map_common() @may_overlap argument Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:54 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 25/25] hw/sysbus: Simplify SysBusDevice::mmio Philippe Mathieu-Daudé
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
Check the region is mapped in the global system memory
with memory_region_is_mapped().
SysBusDevice::mmio[].addr is left unused, remove it.
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
RFC: Are we sysbus-mapping containers?
system/memory.c:2835:bool memory_region_is_mapped(MemoryRegion *mr)
system/memory.c-2836-{
system/memory.c-2837- return !!mr->container || mr->mapped_via_alias;
system/memory.c-2838-}
---
include/hw/sysbus.h | 1 -
hw/core/sysbus.c | 8 +-------
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index 69eb62e29c8..b2a2ea507ea 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -60,7 +60,6 @@ struct SysBusDevice {
int num_mmio;
struct {
- hwaddr addr;
MemoryRegion *memory;
} mmio[QDEV_MAX_MMIO];
int num_pio;
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index e6acf8dba3b..b3060e02484 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -127,15 +127,10 @@ static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
assert(n >= 0 && n < dev->num_mmio);
mr = dev->mmio[n].memory;
- if (dev->mmio[n].addr == addr) {
- /* ??? region already mapped here. */
- return;
- }
- if (dev->mmio[n].addr != (hwaddr)-1) {
+ if (memory_region_is_mapped(mr)) {
/* Unregister previous mapping. */
memory_region_del_subregion(get_system_memory(), mr);
}
- dev->mmio[n].addr = addr;
memory_region_add_subregion_overlap(get_system_memory(),
addr, mr, priority);
}
@@ -180,7 +175,6 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory)
assert(dev->num_mmio < QDEV_MAX_MMIO);
n = dev->num_mmio++;
- dev->mmio[n].addr = -1;
dev->mmio[n].memory = memory;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* [PATCH v3 25/25] hw/sysbus: Simplify SysBusDevice::mmio
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
` (23 preceding siblings ...)
2025-10-28 18:12 ` [PATCH v3 24/25] hw/sysbus: Use memory_region_is_mapped() to check for mapped region Philippe Mathieu-Daudé
@ 2025-10-28 18:12 ` Philippe Mathieu-Daudé
2025-10-29 8:55 ` Richard Henderson
24 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x,
Philippe Mathieu-Daudé, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost
Directly access the MemoryRegion array, removing
the need for the embedded structure.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/sysbus.h | 4 +---
hw/core/sysbus.c | 8 ++++----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index b2a2ea507ea..2cee5bcd44f 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -59,9 +59,7 @@ struct SysBusDevice {
/*< public >*/
int num_mmio;
- struct {
- MemoryRegion *memory;
- } mmio[QDEV_MAX_MMIO];
+ MemoryRegion *mmio[QDEV_MAX_MMIO];
int num_pio;
uint32_t pio[QDEV_MAX_PIO];
};
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index b3060e02484..188a6ab055e 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -125,7 +125,7 @@ static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
MemoryRegion *mr;
assert(n >= 0 && n < dev->num_mmio);
- mr = dev->mmio[n].memory;
+ mr = dev->mmio[n];
if (memory_region_is_mapped(mr)) {
/* Unregister previous mapping. */
@@ -143,7 +143,7 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr)
int sysbus_mmio_map_name(SysBusDevice *dev, const char *name, hwaddr addr)
{
for (int i = 0; i < dev->num_mmio; i++) {
- if (!strcmp(memory_region_name(dev->mmio[i].memory), name)) {
+ if (!strcmp(memory_region_name(dev->mmio[i]), name)) {
sysbus_mmio_map(dev, i, addr);
return i;
}
@@ -175,13 +175,13 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory)
assert(dev->num_mmio < QDEV_MAX_MMIO);
n = dev->num_mmio++;
- dev->mmio[n].memory = memory;
+ dev->mmio[n] = memory;
}
MemoryRegion *sysbus_mmio_get_region(const SysBusDevice *dev, int n)
{
assert(n >= 0 && n < QDEV_MAX_MMIO);
- return dev->mmio[n].memory;
+ return dev->mmio[n];
}
void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
--
2.51.0
^ permalink raw reply related [flat|nested] 71+ messages in thread
* Re: [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
2025-10-28 18:12 ` [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument Philippe Mathieu-Daudé
@ 2025-10-28 18:41 ` Peter Xu
2025-10-29 5:48 ` Thomas Huth
` (2 subsequent siblings)
3 siblings, 0 replies; 71+ messages in thread
From: Peter Xu @ 2025-10-28 18:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Paolo Bonzini,
David Hildenbrand
On Tue, Oct 28, 2025 at 07:12:44PM +0100, Philippe Mathieu-Daudé wrote:
> Since the @mr argument is not modified, it can be const.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 11/25] system/memory: Introduce memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 11/25] system/memory: Introduce memory_region_get_address() Philippe Mathieu-Daudé
@ 2025-10-28 18:41 ` Peter Xu
2025-10-29 5:52 ` Thomas Huth
` (2 subsequent siblings)
3 siblings, 0 replies; 71+ messages in thread
From: Peter Xu @ 2025-10-28 18:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Peter Maydell,
Paolo Bonzini, David Hildenbrand
On Tue, Oct 28, 2025 at 07:12:45PM +0100, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion.
> Introduce memory_region_get_address() to get it,
> similar to memory_region_set_address() to set it.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 12/25] migration/ram: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 12/25] migration/ram: Use memory_region_get_address() Philippe Mathieu-Daudé
@ 2025-10-28 18:41 ` Peter Xu
2025-10-29 8:28 ` Richard Henderson
1 sibling, 0 replies; 71+ messages in thread
From: Peter Xu @ 2025-10-28 18:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Fabiano Rosas
On Tue, Oct 28, 2025 at 07:12:46PM +0100, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 06/25] hw/pci-bridge: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 06/25] hw/pci-bridge: " Philippe Mathieu-Daudé
@ 2025-10-28 19:28 ` BALATON Zoltan
0 siblings, 0 replies; 71+ messages in thread
From: BALATON Zoltan @ 2025-10-28 19:28 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Marcel Apfelbaum
[-- Attachment #1: Type: text/plain, Size: 1325 bytes --]
On Tue, 28 Oct 2025, Philippe Mathieu-Daudé wrote:
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
I haven't reviewed this patch but the e500 one.
Regards,
BALATON Zoltan
> ---
> hw/pci-bridge/pci_expander_bridge.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
> index 1bcceddbc4d..aa55749954a 100644
> --- a/hw/pci-bridge/pci_expander_bridge.c
> +++ b/hw/pci-bridge/pci_expander_bridge.c
> @@ -157,9 +157,11 @@ static char *pxb_host_ofw_unit_address(const SysBusDevice *dev)
> main_host = PCI_HOST_BRIDGE(pxb_dev_base->parent_bus->parent);
> main_host_sbd = SYS_BUS_DEVICE(main_host);
>
> - if (main_host_sbd->num_mmio > 0) {
> + if (sysbus_has_mmio(main_host_sbd, 0)) {
> + MemoryRegion *mr = sysbus_mmio_get_region(main_host_sbd, 0);
> +
> return g_strdup_printf(HWADDR_FMT_plx ",%x",
> - main_host_sbd->mmio[0].addr, position + 1);
> + mr->addr, position + 1);
> }
> if (main_host_sbd->num_pio > 0) {
> return g_strdup_printf("i%04x,%x",
>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 09/25] hw/s390x: Use memory_region_size()
2025-10-28 18:12 ` [PATCH v3 09/25] hw/s390x: " Philippe Mathieu-Daudé
@ 2025-10-29 5:42 ` Thomas Huth
2025-10-29 7:59 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
2 siblings, 0 replies; 71+ messages in thread
From: Thomas Huth @ 2025-10-29 5:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Matthew Rosato,
Eric Farman, Halil Pasic, Christian Borntraeger,
Richard Henderson, David Hildenbrand, Ilya Leoshkevich
On 28/10/2025 19.12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::size is private data of MemoryRegion,
> use the proper memory_region_size() getter to get it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/s390x/s390-pci-inst.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
> index a3bb5aa2216..5841dfc4fec 100644
> --- a/hw/s390x/s390-pci-inst.c
> +++ b/hw/s390x/s390-pci-inst.c
> @@ -396,7 +396,7 @@ static MemoryRegion *s390_get_subregion(MemoryRegion *mr, uint64_t offset,
> uint64_t subregion_size;
>
> QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) {
> - subregion_size = int128_get64(subregion->size);
> + subregion_size = memory_region_size(subregion);
> if ((offset >= subregion->addr) &&
> (offset + len) <= (subregion->addr + subregion_size)) {
> mr = subregion;
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
2025-10-28 18:12 ` [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
@ 2025-10-29 5:48 ` Thomas Huth
2025-10-29 8:00 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
3 siblings, 0 replies; 71+ messages in thread
From: Thomas Huth @ 2025-10-29 5:48 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Paolo Bonzini,
Peter Xu, David Hildenbrand
On 28/10/2025 19.12, Philippe Mathieu-Daudé wrote:
> Since the @mr argument is not modified, it can be const.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/memory.h | 2 +-
> system/memory.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/system/memory.h b/include/system/memory.h
> index 3bd5ffa5e0d..45de6946812 100644
> --- a/include/system/memory.h
> +++ b/include/system/memory.h
> @@ -1776,7 +1776,7 @@ Object *memory_region_owner(MemoryRegion *mr);
> *
> * @mr: the memory region being queried.
> */
> -uint64_t memory_region_size(MemoryRegion *mr);
> +uint64_t memory_region_size(const MemoryRegion *mr);
>
> /**
> * memory_region_is_ram: check whether a memory region is random access
> diff --git a/system/memory.c b/system/memory.c
> index 8b84661ae36..d1c060b2b50 100644
> --- a/system/memory.c
> +++ b/system/memory.c
> @@ -1870,7 +1870,7 @@ void memory_region_unref(MemoryRegion *mr)
> }
> }
>
> -uint64_t memory_region_size(MemoryRegion *mr)
> +uint64_t memory_region_size(const MemoryRegion *mr)
> {
> if (int128_eq(mr->size, int128_2_64())) {
> return UINT64_MAX;
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 11/25] system/memory: Introduce memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 11/25] system/memory: Introduce memory_region_get_address() Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
@ 2025-10-29 5:52 ` Thomas Huth
2025-10-29 8:21 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
3 siblings, 0 replies; 71+ messages in thread
From: Thomas Huth @ 2025-10-29 5:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Peter Maydell,
Paolo Bonzini, Peter Xu, David Hildenbrand
On 28/10/2025 19.12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion.
> Introduce memory_region_get_address() to get it,
> similar to memory_region_set_address() to set it.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/memory.h | 7 +++++++
> system/memory.c | 5 +++++
> 2 files changed, 12 insertions(+)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors Philippe Mathieu-Daudé
@ 2025-10-29 5:54 ` Thomas Huth
2025-10-30 6:58 ` Zhao Liu
1 sibling, 0 replies; 71+ messages in thread
From: Thomas Huth @ 2025-10-29 5:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Marcel Apfelbaum, Paolo Bonzini, Richard Henderson,
Eduardo Habkost
On 28/10/2025 19.12, Philippe Mathieu-Daudé wrote:
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/i386/microvm-dt.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/i386/microvm-dt.c b/hw/i386/microvm-dt.c
> index cb27dfd732e..d7f49bc1b5f 100644
> --- a/hw/i386/microvm-dt.c
> +++ b/hw/i386/microvm-dt.c
> @@ -71,7 +71,8 @@ static void dt_add_virtio(MicrovmMachineState *mms, VirtIOMMIOProxy *mmio)
> return;
> }
>
> - hwaddr base = dev->mmio[0].addr;
> + MemoryRegion *mr = sysbus_mmio_get_region(dev, 0);
> + hwaddr base = mr->addr;
> hwaddr size = 512;
> unsigned index = (base - VIRTIO_MMIO_BASE) / size;
> uint32_t irq = mms->virtio_irq_base + index;
> @@ -150,7 +151,8 @@ static void dt_add_pcie(MicrovmMachineState *mms)
>
> static void dt_add_ioapic(MicrovmMachineState *mms, SysBusDevice *dev)
> {
> - hwaddr base = dev->mmio[0].addr;
> + MemoryRegion *mr = sysbus_mmio_get_region(dev, 0);
> + hwaddr base = mr->addr;
> char *nodename;
> uint32_t ph;
> int index;
Wouldn't it make sense to move patch 11 before this patch, and then to use
memory_region_get_address() here directly?
Thomas
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 16/25] hw/s390x: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 16/25] hw/s390x: " Philippe Mathieu-Daudé
@ 2025-10-29 5:55 ` Thomas Huth
2025-10-29 8:28 ` David Hildenbrand
1 sibling, 0 replies; 71+ messages in thread
From: Thomas Huth @ 2025-10-29 5:55 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Matthew Rosato,
Eric Farman, Halil Pasic, Christian Borntraeger,
Richard Henderson, David Hildenbrand, Ilya Leoshkevich
On 28/10/2025 19.12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/s390x/s390-pci-inst.c | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
> index 5841dfc4fec..d4adf782ca1 100644
> --- a/hw/s390x/s390-pci-inst.c
> +++ b/hw/s390x/s390-pci-inst.c
> @@ -394,11 +394,14 @@ static MemoryRegion *s390_get_subregion(MemoryRegion *mr, uint64_t offset,
> {
> MemoryRegion *subregion;
> uint64_t subregion_size;
> + hwaddr subregion_addr;
>
> QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) {
> subregion_size = memory_region_size(subregion);
> - if ((offset >= subregion->addr) &&
> - (offset + len) <= (subregion->addr + subregion_size)) {
> + subregion_addr = memory_region_get_address(subregion);
> +
> + if ((offset >= subregion_addr) &&
> + (offset + len) <= (subregion_addr + subregion_size)) {
While you're at it, you could also drop the superfluous parentheses here.
Anyway:
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 04/25] hw/acpi/cxl: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 04/25] hw/acpi/cxl: " Philippe Mathieu-Daudé
@ 2025-10-29 7:56 ` Richard Henderson
2025-10-29 11:05 ` Jonathan Cameron via
1 sibling, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 7:56 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/acpi/cxl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 05/25] hw/ppc/e500: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 05/25] hw/ppc/e500: " Philippe Mathieu-Daudé
@ 2025-10-29 7:56 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 7:56 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/ppc/e500.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 07/25] hw/sysbus: Use memory_region_name()
2025-10-28 18:12 ` [PATCH v3 07/25] hw/sysbus: Use memory_region_name() Philippe Mathieu-Daudé
@ 2025-10-29 7:57 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 7:57 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::name is private data of MemoryRegion. Use the
> proper memory_region_name() accessor, which might return a
> different name.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> Reviewed-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
> hw/core/sysbus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 08/25] hw/nvme/ctrl: Use memory_region_size()
2025-10-28 18:12 ` [PATCH v3 08/25] hw/nvme/ctrl: Use memory_region_size() Philippe Mathieu-Daudé
@ 2025-10-29 7:58 ` Richard Henderson
2025-10-30 7:59 ` Klaus Jensen
1 sibling, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 7:58 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::size is private data of MemoryRegion,
> use the proper memory_region_size() getter to get it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/nvme/ctrl.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 09/25] hw/s390x: Use memory_region_size()
2025-10-28 18:12 ` [PATCH v3 09/25] hw/s390x: " Philippe Mathieu-Daudé
2025-10-29 5:42 ` Thomas Huth
@ 2025-10-29 7:59 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
2 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 7:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::size is private data of MemoryRegion,
> use the proper memory_region_size() getter to get it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/s390x/s390-pci-inst.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
2025-10-28 18:12 ` [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
2025-10-29 5:48 ` Thomas Huth
@ 2025-10-29 8:00 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
3 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:00 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> Since the @mr argument is not modified, it can be const.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> include/system/memory.h | 2 +-
> system/memory.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 11/25] system/memory: Introduce memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 11/25] system/memory: Introduce memory_region_get_address() Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
2025-10-29 5:52 ` Thomas Huth
@ 2025-10-29 8:21 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
3 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:21 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion.
> Introduce memory_region_get_address() to get it,
> similar to memory_region_set_address() to set it.
>
> Suggested-by: Peter Maydell<peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> include/system/memory.h | 7 +++++++
> system/memory.c | 5 +++++
> 2 files changed, 12 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
I agree with Thomas that this should come first, and no new uses of mr->addr should be
added in the first couple of patches.
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 09/25] hw/s390x: Use memory_region_size()
2025-10-28 18:12 ` [PATCH v3 09/25] hw/s390x: " Philippe Mathieu-Daudé
2025-10-29 5:42 ` Thomas Huth
2025-10-29 7:59 ` Richard Henderson
@ 2025-10-29 8:26 ` David Hildenbrand
2 siblings, 0 replies; 71+ messages in thread
From: David Hildenbrand @ 2025-10-29 8:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Matthew Rosato,
Eric Farman, Halil Pasic, Christian Borntraeger, Thomas Huth,
Richard Henderson, Ilya Leoshkevich
On 28.10.25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::size is private data of MemoryRegion,
> use the proper memory_region_size() getter to get it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/s390x/s390-pci-inst.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
> index a3bb5aa2216..5841dfc4fec 100644
> --- a/hw/s390x/s390-pci-inst.c
> +++ b/hw/s390x/s390-pci-inst.c
> @@ -396,7 +396,7 @@ static MemoryRegion *s390_get_subregion(MemoryRegion *mr, uint64_t offset,
> uint64_t subregion_size;
>
> QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) {
> - subregion_size = int128_get64(subregion->size);
> + subregion_size = memory_region_size(subregion);
> if ((offset >= subregion->addr) &&
> (offset + len) <= (subregion->addr + subregion_size)) {
> mr = subregion;
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
2025-10-28 18:12 ` [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-10-29 8:00 ` Richard Henderson
@ 2025-10-29 8:26 ` David Hildenbrand
3 siblings, 0 replies; 71+ messages in thread
From: David Hildenbrand @ 2025-10-29 8:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Paolo Bonzini,
Peter Xu
On 28.10.25 19:12, Philippe Mathieu-Daudé wrote:
> Since the @mr argument is not modified, it can be const.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 11/25] system/memory: Introduce memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 11/25] system/memory: Introduce memory_region_get_address() Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-10-29 8:21 ` Richard Henderson
@ 2025-10-29 8:26 ` David Hildenbrand
3 siblings, 0 replies; 71+ messages in thread
From: David Hildenbrand @ 2025-10-29 8:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Peter Maydell,
Paolo Bonzini, Peter Xu
On 28.10.25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion.
> Introduce memory_region_get_address() to get it,
> similar to memory_region_set_address() to set it.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 12/25] migration/ram: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 12/25] migration/ram: Use memory_region_get_address() Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
@ 2025-10-29 8:28 ` Richard Henderson
1 sibling, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:28 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> migration/ram.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 16/25] hw/s390x: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 16/25] hw/s390x: " Philippe Mathieu-Daudé
2025-10-29 5:55 ` Thomas Huth
@ 2025-10-29 8:28 ` David Hildenbrand
2025-10-29 13:18 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 71+ messages in thread
From: David Hildenbrand @ 2025-10-29 8:28 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Matthew Rosato,
Eric Farman, Halil Pasic, Christian Borntraeger, Thomas Huth,
Richard Henderson, Ilya Leoshkevich
> @@ -510,11 +514,12 @@ static MemTxResult zpci_write_bar(S390PCIBusDevice *pbdev, uint8_t pcias,
> uint64_t offset, uint64_t data, uint8_t len)
> {
> MemoryRegion *mr;
> + hwaddr subregion_base_addr;
>
> mr = pbdev->pdev->io_regions[pcias].memory;
> mr = s390_get_subregion(mr, offset, len);
> - offset -= mr->addr;
> - return memory_region_dispatch_write(mr, offset, data,
> + subregion_base_addr = memory_region_get_address(mr);
Any partixular reason for the temp variable?
> + return memory_region_dispatch_write(mr, offset - subregion_base_addr, data,
> size_memop(len) | MO_BE,
> MEMTXATTRS_UNSPECIFIED);
> }
> @@ -832,6 +837,7 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
> S390PCIBusDevice *pbdev;
> MemoryRegion *mr;
> MemTxResult result;
> + hwaddr subregion_base_addr;
> uint64_t offset;
> int i;
> uint32_t fh;
> @@ -900,7 +906,8 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
>
> mr = pbdev->pdev->io_regions[pcias].memory;
> mr = s390_get_subregion(mr, offset, len);
> - offset -= mr->addr;
> + subregion_base_addr = memory_region_get_address(mr);
Dito
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 13/25] hw/acpi: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 13/25] hw/acpi: " Philippe Mathieu-Daudé
@ 2025-10-29 8:41 ` Richard Henderson
2025-10-29 11:06 ` Jonathan Cameron via
1 sibling, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> +++ b/hw/acpi/cxl.c
> @@ -105,6 +105,7 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
> PXBDev *pxb = PXB_DEV(cxl);
> SysBusDevice *sbd = SYS_BUS_DEVICE(cxl->cxl_host_bridge);
> MemoryRegion *mr = sysbus_mmio_get_region(sbd, 0);
> + hwaddr container_base_addr = memory_region_get_address(mr->container);
>
> /* Type */
> build_append_int_noprefix(table_data, 0, 1);
> @@ -125,7 +126,9 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
> build_append_int_noprefix(table_data, 0, 4);
>
> /* Base - subregion within a container that is in PA space */
> - build_append_int_noprefix(table_data, mr->container->addr + mr->addr, 8);
> + build_append_int_noprefix(table_data,
> + container_base_addr
> + + memory_region_get_address(mr), 8);
Why the single-use variable, instead of expanding here, like what you're replacing?
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 14/25] hw/fdt: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 14/25] hw/fdt: " Philippe Mathieu-Daudé
@ 2025-10-29 8:41 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/i386/microvm-dt.c | 4 ++--
> hw/loongarch/virt-fdt-build.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 15/25] hw/nvme: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 15/25] hw/nvme: " Philippe Mathieu-Daudé
@ 2025-10-29 8:42 ` Richard Henderson
2025-10-30 7:58 ` Klaus Jensen
1 sibling, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:42 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/nvme/ctrl.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 17/25] hw/timer/hpet: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 17/25] hw/timer/hpet: " Philippe Mathieu-Daudé
@ 2025-10-29 8:46 ` Richard Henderson
2025-10-30 6:52 ` Zhao Liu
1 sibling, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:46 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/timer/hpet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 18/25] hw/watchdog/aspeed: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 18/25] hw/watchdog/aspeed: " Philippe Mathieu-Daudé
@ 2025-10-29 8:46 ` Richard Henderson
2025-10-29 17:13 ` Cédric Le Goater
1 sibling, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:46 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/watchdog/wdt_aspeed.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 19/25] hw/pci-bridge: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 19/25] hw/pci-bridge: " Philippe Mathieu-Daudé
@ 2025-10-29 8:48 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:48 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/pci-bridge/pci_expander_bridge.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 20/25] system/ioport: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 20/25] system/ioport: " Philippe Mathieu-Daudé
@ 2025-10-29 8:49 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:49 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> system/ioport.c | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 21/25] hw/sysbus: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 21/25] hw/sysbus: " Philippe Mathieu-Daudé
@ 2025-10-29 8:52 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:52 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/core/sysbus.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
The patch description is incomplete for these changes, but the changes themselves are good.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index d33be6b2b52..414b3f806d1 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -257,13 +257,14 @@ bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp)
> static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
> {
> SysBusDevice *s = SYS_BUS_DEVICE(dev);
> - hwaddr size;
> - int i;
>
> - for (i = 0; i < s->num_mmio; i++) {
> - size = memory_region_size(s->mmio[i].memory);
> - monitor_printf(mon, "%*smmio " HWADDR_FMT_plx "/" HWADDR_FMT_plx "\n",
> - indent, "", s->mmio[i].addr, size);
> + for (int i = 0; i < s->num_mmio; i++) {
> + MemoryRegion *mr = sysbus_mmio_get_region(s, i);
> + hwaddr addr = memory_region_get_address(mr);
> + uint64_t size = memory_region_size(mr);
> +
> + monitor_printf(mon, "%*smmio " HWADDR_FMT_plx "/%016" PRIx64 "\n",
> + indent, "", addr, size);
> }
> }
>
> @@ -282,8 +283,10 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev)
> }
> }
> if (s->num_mmio) {
> + MemoryRegion *mr = sysbus_mmio_get_region(s, 0);
> +
> return g_strdup_printf("%s@" HWADDR_FMT_plx, qdev_fw_name(dev),
> - s->mmio[0].addr);
> + memory_region_get_address(mr));
> }
> if (s->num_pio) {
> return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]);
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 22/25] hw/sysbus: Hoist MemoryRegion in sysbus_mmio_map_common()
2025-10-28 18:12 ` [PATCH v3 22/25] hw/sysbus: Hoist MemoryRegion in sysbus_mmio_map_common() Philippe Mathieu-Daudé
@ 2025-10-29 8:52 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:52 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> In order to make the next commit easier to review,
> use the local @mr variable in sysbus_mmio_map_common().
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/core/sysbus.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 23/25] hw/sysbus: Remove sysbus_mmio_map_common() @may_overlap argument
2025-10-28 18:12 ` [PATCH v3 23/25] hw/sysbus: Remove sysbus_mmio_map_common() @may_overlap argument Philippe Mathieu-Daudé
@ 2025-10-29 8:53 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:53 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> memory_region_add_subregion_overlap(priority=0) is
> identical to memory_region_add_subregion(). Just use
> the former to simplify.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/core/sysbus.c | 19 +++++--------------
> 1 file changed, 5 insertions(+), 14 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 24/25] hw/sysbus: Use memory_region_is_mapped() to check for mapped region
2025-10-28 18:12 ` [PATCH v3 24/25] hw/sysbus: Use memory_region_is_mapped() to check for mapped region Philippe Mathieu-Daudé
@ 2025-10-29 8:54 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:54 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> Check the region is mapped in the global system memory
> with memory_region_is_mapped().
>
> SysBusDevice::mmio[].addr is left unused, remove it.
>
> Suggested-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 25/25] hw/sysbus: Simplify SysBusDevice::mmio
2025-10-28 18:12 ` [PATCH v3 25/25] hw/sysbus: Simplify SysBusDevice::mmio Philippe Mathieu-Daudé
@ 2025-10-29 8:55 ` Richard Henderson
0 siblings, 0 replies; 71+ messages in thread
From: Richard Henderson @ 2025-10-29 8:55 UTC (permalink / raw)
To: qemu-devel
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> Directly access the MemoryRegion array, removing
> the need for the embedded structure.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> include/hw/sysbus.h | 4 +---
> hw/core/sysbus.c | 8 ++++----
> 2 files changed, 5 insertions(+), 7 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 04/25] hw/acpi/cxl: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 04/25] hw/acpi/cxl: " Philippe Mathieu-Daudé
2025-10-29 7:56 ` Richard Henderson
@ 2025-10-29 11:05 ` Jonathan Cameron via
1 sibling, 0 replies; 71+ messages in thread
From: Jonathan Cameron via @ 2025-10-29 11:05 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Igor Mammedov, Ani Sinha
On Tue, 28 Oct 2025 19:12:38 +0100
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Thanks,
> ---
> hw/acpi/cxl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c
> index 75d5b30bb8b..77c99dfb184 100644
> --- a/hw/acpi/cxl.c
> +++ b/hw/acpi/cxl.c
> @@ -104,7 +104,7 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
> {
> PXBDev *pxb = PXB_DEV(cxl);
> SysBusDevice *sbd = SYS_BUS_DEVICE(cxl->cxl_host_bridge);
> - struct MemoryRegion *mr = sbd->mmio[0].memory;
> + MemoryRegion *mr = sysbus_mmio_get_region(sbd, 0);
>
> /* Type */
> build_append_int_noprefix(table_data, 0, 1);
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 13/25] hw/acpi: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 13/25] hw/acpi: " Philippe Mathieu-Daudé
2025-10-29 8:41 ` Richard Henderson
@ 2025-10-29 11:06 ` Jonathan Cameron via
1 sibling, 0 replies; 71+ messages in thread
From: Jonathan Cameron via @ 2025-10-29 11:06 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Igor Mammedov, Ani Sinha, Marcel Apfelbaum, Paolo Bonzini,
Richard Henderson, Eduardo Habkost, Song Gao, Bibo Mao,
Jiaxun Yang
On Tue, 28 Oct 2025 19:12:47 +0100
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/acpi/cxl.c | 8 ++++++--
Acked-by: Jonathan Cameron <jonathan.cameron@huawei.com> #for CXL
> hw/i386/acpi-build.c | 8 +++++---
> hw/loongarch/virt-acpi-build.c | 4 ++--
> 3 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c
> index 77c99dfb184..92c032851cc 100644
> --- a/hw/acpi/cxl.c
> +++ b/hw/acpi/cxl.c
> @@ -105,6 +105,7 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
> PXBDev *pxb = PXB_DEV(cxl);
> SysBusDevice *sbd = SYS_BUS_DEVICE(cxl->cxl_host_bridge);
> MemoryRegion *mr = sysbus_mmio_get_region(sbd, 0);
> + hwaddr container_base_addr = memory_region_get_address(mr->container);
>
> /* Type */
> build_append_int_noprefix(table_data, 0, 1);
> @@ -125,7 +126,9 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
> build_append_int_noprefix(table_data, 0, 4);
>
> /* Base - subregion within a container that is in PA space */
> - build_append_int_noprefix(table_data, mr->container->addr + mr->addr, 8);
> + build_append_int_noprefix(table_data,
> + container_base_addr
> + + memory_region_get_address(mr), 8);
>
> /* Length */
> build_append_int_noprefix(table_data, memory_region_size(mr), 8);
> @@ -154,7 +157,8 @@ static void cedt_build_cfmws(CXLFixedWindow *fw, Aml *cedt)
> build_append_int_noprefix(table_data, 0, 4);
>
> /* Base HPA */
> - build_append_int_noprefix(table_data, fw->mr.addr, 8);
> + build_append_int_noprefix(table_data,
> + memory_region_get_address(&fw->mr), 8);
>
> /* Window Size */
> build_append_int_noprefix(table_data, fw->size, 8);
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 16/25] hw/s390x: Use memory_region_get_address()
2025-10-29 8:28 ` David Hildenbrand
@ 2025-10-29 13:18 ` Philippe Mathieu-Daudé
2025-10-29 13:23 ` David Hildenbrand
0 siblings, 1 reply; 71+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-29 13:18 UTC (permalink / raw)
To: David Hildenbrand, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Matthew Rosato,
Eric Farman, Halil Pasic, Christian Borntraeger, Thomas Huth,
Richard Henderson, Ilya Leoshkevich
On 29/10/25 09:28, David Hildenbrand wrote:
>
>> @@ -510,11 +514,12 @@ static MemTxResult
>> zpci_write_bar(S390PCIBusDevice *pbdev, uint8_t pcias,
>> uint64_t offset, uint64_t data,
>> uint8_t len)
>> {
>> MemoryRegion *mr;
>> + hwaddr subregion_base_addr;
>> mr = pbdev->pdev->io_regions[pcias].memory;
>> mr = s390_get_subregion(mr, offset, len);
>> - offset -= mr->addr;
>> - return memory_region_dispatch_write(mr, offset, data,
>> + subregion_base_addr = memory_region_get_address(mr);
>
> Any partixular reason for the temp variable?
To fit the 72-80 chars per line limit. Since various people
asked the same, I'll just replace in place, ignoring the
checkpatch.pl warnings.
>
>> + return memory_region_dispatch_write(mr, offset -
>> subregion_base_addr, data,
>> size_memop(len) | MO_BE,
>> MEMTXATTRS_UNSPECIFIED);
>> }
>> @@ -832,6 +837,7 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1,
>> uint8_t r3, uint64_t gaddr,
>> S390PCIBusDevice *pbdev;
>> MemoryRegion *mr;
>> MemTxResult result;
>> + hwaddr subregion_base_addr;
>> uint64_t offset;
>> int i;
>> uint32_t fh;
>> @@ -900,7 +906,8 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1,
>> uint8_t r3, uint64_t gaddr,
>> mr = pbdev->pdev->io_regions[pcias].memory;
>> mr = s390_get_subregion(mr, offset, len);
>> - offset -= mr->addr;
>> + subregion_base_addr = memory_region_get_address(mr);
>
> Dito
>
>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 16/25] hw/s390x: Use memory_region_get_address()
2025-10-29 13:18 ` Philippe Mathieu-Daudé
@ 2025-10-29 13:23 ` David Hildenbrand
0 siblings, 0 replies; 71+ messages in thread
From: David Hildenbrand @ 2025-10-29 13:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Matthew Rosato,
Eric Farman, Halil Pasic, Christian Borntraeger, Thomas Huth,
Richard Henderson, Ilya Leoshkevich
On 29.10.25 14:18, Philippe Mathieu-Daudé wrote:
> On 29/10/25 09:28, David Hildenbrand wrote:
>>
>>> @@ -510,11 +514,12 @@ static MemTxResult
>>> zpci_write_bar(S390PCIBusDevice *pbdev, uint8_t pcias,
>>> uint64_t offset, uint64_t data,
>>> uint8_t len)
>>> {
>>> MemoryRegion *mr;
>>> + hwaddr subregion_base_addr;
>>> mr = pbdev->pdev->io_regions[pcias].memory;
>>> mr = s390_get_subregion(mr, offset, len);
>>> - offset -= mr->addr;
>>> - return memory_region_dispatch_write(mr, offset, data,
>>> + subregion_base_addr = memory_region_get_address(mr);
>>
>> Any partixular reason for the temp variable?
>
> To fit the 72-80 chars per line limit. Since various people
> asked the same, I'll just replace in place, ignoring the
> checkpatch.pl warnings.
I was wondering about a simple
offset -= memory_region_get_address(mr);
by minimizing changes to surrounding code.
Anyhow, I was just wondering about that.
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 18/25] hw/watchdog/aspeed: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 18/25] hw/watchdog/aspeed: " Philippe Mathieu-Daudé
2025-10-29 8:46 ` Richard Henderson
@ 2025-10-29 17:13 ` Cédric Le Goater
1 sibling, 0 replies; 71+ messages in thread
From: Cédric Le Goater @ 2025-10-29 17:13 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Peter Maydell,
Steven Lee, Troy Lee, Jamin Lin, Andrew Jeffery, Joel Stanley
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/watchdog/wdt_aspeed.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
> index 30226435efc..f842d8e973a 100644
> --- a/hw/watchdog/wdt_aspeed.c
> +++ b/hw/watchdog/wdt_aspeed.c
> @@ -274,7 +274,7 @@ static void aspeed_wdt_timer_expired(void *dev)
> }
>
> qemu_log_mask(CPU_LOG_RESET, "Watchdog timer %" HWADDR_PRIx " expired.\n",
> - s->iomem.addr);
> + memory_region_get_address(&s->iomem));
> watchdog_perform_action();
> timer_del(s->timer);
> }
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 17/25] hw/timer/hpet: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 17/25] hw/timer/hpet: " Philippe Mathieu-Daudé
2025-10-29 8:46 ` Richard Henderson
@ 2025-10-30 6:52 ` Zhao Liu
1 sibling, 0 replies; 71+ messages in thread
From: Zhao Liu @ 2025-10-30 6:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Paolo Bonzini
On Tue, Oct 28, 2025 at 07:12:51PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Tue, 28 Oct 2025 19:12:51 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v3 17/25] hw/timer/hpet: Use memory_region_get_address()
> X-Mailer: git-send-email 2.51.0
>
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/timer/hpet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 03/25] hw/timer/hpet: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 03/25] hw/timer/hpet: " Philippe Mathieu-Daudé
@ 2025-10-30 6:57 ` Zhao Liu
0 siblings, 0 replies; 71+ messages in thread
From: Zhao Liu @ 2025-10-30 6:57 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Paolo Bonzini
On Tue, Oct 28, 2025 at 07:12:37PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Tue, 28 Oct 2025 19:12:37 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v3 03/25] hw/timer/hpet: Use proper SysBus accessors
> X-Mailer: git-send-email 2.51.0
>
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/timer/hpet.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
> index 1acba4fa9db..c1b96d0a89f 100644
> --- a/hw/timer/hpet.c
> +++ b/hw/timer/hpet.c
> @@ -654,7 +654,7 @@ static const MemoryRegionOps hpet_ram_ops = {
> static void hpet_reset(DeviceState *d)
> {
> HPETState *s = HPET(d);
> - SysBusDevice *sbd = SYS_BUS_DEVICE(d);
> + MemoryRegion *mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(d), 0);
> int i;
>
> for (i = 0; i < s->num_timers; i++) {
> @@ -677,7 +677,7 @@ static void hpet_reset(DeviceState *d)
> s->hpet_offset = 0ULL;
> s->config = 0ULL;
> hpet_fw_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability;
> - hpet_fw_cfg.hpet[s->hpet_id].address = sbd->mmio[0].addr;
> + hpet_fw_cfg.hpet[s->hpet_id].address = mr->addr;
Rust's sysbus has a method "mmio_addr". Maybe Rust side should also
split it into two methods similar to `sysbus_mmio_get_region` and
`memory_region_get_address`, to align with the C interfaces.
For this patch,
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> /* to document that the RTC lowers its output on reset as well */
> s->rtc_irq_level = 0;
> --
> 2.51.0
>
>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 02/25] hw/i386/ioapic: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 02/25] hw/i386/ioapic: " Philippe Mathieu-Daudé
@ 2025-10-30 6:58 ` Zhao Liu
2025-10-30 7:03 ` Zhao Liu
1 sibling, 0 replies; 71+ messages in thread
From: Zhao Liu @ 2025-10-30 6:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Marcel Apfelbaum, Paolo Bonzini, Richard Henderson,
Eduardo Habkost
On Tue, Oct 28, 2025 at 07:12:36PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Tue, 28 Oct 2025 19:12:36 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v3 02/25] hw/i386/ioapic: Use proper SysBus accessors
> X-Mailer: git-send-email 2.51.0
>
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/i386/kvm/ioapic.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors Philippe Mathieu-Daudé
2025-10-29 5:54 ` Thomas Huth
@ 2025-10-30 6:58 ` Zhao Liu
1 sibling, 0 replies; 71+ messages in thread
From: Zhao Liu @ 2025-10-30 6:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Marcel Apfelbaum, Paolo Bonzini, Richard Henderson,
Eduardo Habkost
On Tue, Oct 28, 2025 at 07:12:35PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Tue, 28 Oct 2025 19:12:35 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors
> X-Mailer: git-send-email 2.51.0
>
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/i386/microvm-dt.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 02/25] hw/i386/ioapic: Use proper SysBus accessors
2025-10-28 18:12 ` [PATCH v3 02/25] hw/i386/ioapic: " Philippe Mathieu-Daudé
2025-10-30 6:58 ` Zhao Liu
@ 2025-10-30 7:03 ` Zhao Liu
1 sibling, 0 replies; 71+ messages in thread
From: Zhao Liu @ 2025-10-30 7:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Michael S. Tsirkin,
Marcel Apfelbaum, Paolo Bonzini, Richard Henderson,
Eduardo Habkost
On Tue, Oct 28, 2025 at 07:12:36PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Tue, 28 Oct 2025 19:12:36 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v3 02/25] hw/i386/ioapic: Use proper SysBus accessors
> X-Mailer: git-send-email 2.51.0
>
> SysBusDevice::mmio[] is private data of SysBusDevice, use
> sysbus_mmio_get_region() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/i386/kvm/ioapic.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
BTW, it seems ioapic & microvm could also use memory_region_get_address(mr)
as the follow up cleanup, just like hpet did.
Regards,
Zhao
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 15/25] hw/nvme: Use memory_region_get_address()
2025-10-28 18:12 ` [PATCH v3 15/25] hw/nvme: " Philippe Mathieu-Daudé
2025-10-29 8:42 ` Richard Henderson
@ 2025-10-30 7:58 ` Klaus Jensen
1 sibling, 0 replies; 71+ messages in thread
From: Klaus Jensen @ 2025-10-30 7:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Keith Busch,
Jesper Devantier
[-- Attachment #1: Type: text/plain, Size: 271 bytes --]
On Oct 28 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::addr is private data of MemoryRegion, use
> memory_region_get_address() to access it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v3 08/25] hw/nvme/ctrl: Use memory_region_size()
2025-10-28 18:12 ` [PATCH v3 08/25] hw/nvme/ctrl: Use memory_region_size() Philippe Mathieu-Daudé
2025-10-29 7:58 ` Richard Henderson
@ 2025-10-30 7:59 ` Klaus Jensen
1 sibling, 0 replies; 71+ messages in thread
From: Klaus Jensen @ 2025-10-30 7:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Mark Cave-Ayland, qemu-ppc, qemu-riscv, qemu-block,
Marc-André Lureau, qemu-arm, qemu-s390x, Keith Busch,
Jesper Devantier
[-- Attachment #1: Type: text/plain, Size: 279 bytes --]
On Oct 28 19:12, Philippe Mathieu-Daudé wrote:
> MemoryRegion::size is private data of MemoryRegion,
> use the proper memory_region_size() getter to get it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 71+ messages in thread
end of thread, other threads:[~2025-10-30 8:00 UTC | newest]
Thread overview: 71+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28 18:12 [PATCH v3 00/25] hw/sysbus: Spring cleanups (part 1) Philippe Mathieu-Daudé
2025-10-28 18:12 ` [PATCH v3 01/25] hw/i386/microvm: Use proper SysBus accessors Philippe Mathieu-Daudé
2025-10-29 5:54 ` Thomas Huth
2025-10-30 6:58 ` Zhao Liu
2025-10-28 18:12 ` [PATCH v3 02/25] hw/i386/ioapic: " Philippe Mathieu-Daudé
2025-10-30 6:58 ` Zhao Liu
2025-10-30 7:03 ` Zhao Liu
2025-10-28 18:12 ` [PATCH v3 03/25] hw/timer/hpet: " Philippe Mathieu-Daudé
2025-10-30 6:57 ` Zhao Liu
2025-10-28 18:12 ` [PATCH v3 04/25] hw/acpi/cxl: " Philippe Mathieu-Daudé
2025-10-29 7:56 ` Richard Henderson
2025-10-29 11:05 ` Jonathan Cameron via
2025-10-28 18:12 ` [PATCH v3 05/25] hw/ppc/e500: " Philippe Mathieu-Daudé
2025-10-29 7:56 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 06/25] hw/pci-bridge: " Philippe Mathieu-Daudé
2025-10-28 19:28 ` BALATON Zoltan
2025-10-28 18:12 ` [PATCH v3 07/25] hw/sysbus: Use memory_region_name() Philippe Mathieu-Daudé
2025-10-29 7:57 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 08/25] hw/nvme/ctrl: Use memory_region_size() Philippe Mathieu-Daudé
2025-10-29 7:58 ` Richard Henderson
2025-10-30 7:59 ` Klaus Jensen
2025-10-28 18:12 ` [PATCH v3 09/25] hw/s390x: " Philippe Mathieu-Daudé
2025-10-29 5:42 ` Thomas Huth
2025-10-29 7:59 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
2025-10-28 18:12 ` [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
2025-10-29 5:48 ` Thomas Huth
2025-10-29 8:00 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
2025-10-28 18:12 ` [PATCH v3 11/25] system/memory: Introduce memory_region_get_address() Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
2025-10-29 5:52 ` Thomas Huth
2025-10-29 8:21 ` Richard Henderson
2025-10-29 8:26 ` David Hildenbrand
2025-10-28 18:12 ` [PATCH v3 12/25] migration/ram: Use memory_region_get_address() Philippe Mathieu-Daudé
2025-10-28 18:41 ` Peter Xu
2025-10-29 8:28 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 13/25] hw/acpi: " Philippe Mathieu-Daudé
2025-10-29 8:41 ` Richard Henderson
2025-10-29 11:06 ` Jonathan Cameron via
2025-10-28 18:12 ` [PATCH v3 14/25] hw/fdt: " Philippe Mathieu-Daudé
2025-10-29 8:41 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 15/25] hw/nvme: " Philippe Mathieu-Daudé
2025-10-29 8:42 ` Richard Henderson
2025-10-30 7:58 ` Klaus Jensen
2025-10-28 18:12 ` [PATCH v3 16/25] hw/s390x: " Philippe Mathieu-Daudé
2025-10-29 5:55 ` Thomas Huth
2025-10-29 8:28 ` David Hildenbrand
2025-10-29 13:18 ` Philippe Mathieu-Daudé
2025-10-29 13:23 ` David Hildenbrand
2025-10-28 18:12 ` [PATCH v3 17/25] hw/timer/hpet: " Philippe Mathieu-Daudé
2025-10-29 8:46 ` Richard Henderson
2025-10-30 6:52 ` Zhao Liu
2025-10-28 18:12 ` [PATCH v3 18/25] hw/watchdog/aspeed: " Philippe Mathieu-Daudé
2025-10-29 8:46 ` Richard Henderson
2025-10-29 17:13 ` Cédric Le Goater
2025-10-28 18:12 ` [PATCH v3 19/25] hw/pci-bridge: " Philippe Mathieu-Daudé
2025-10-29 8:48 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 20/25] system/ioport: " Philippe Mathieu-Daudé
2025-10-29 8:49 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 21/25] hw/sysbus: " Philippe Mathieu-Daudé
2025-10-29 8:52 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 22/25] hw/sysbus: Hoist MemoryRegion in sysbus_mmio_map_common() Philippe Mathieu-Daudé
2025-10-29 8:52 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 23/25] hw/sysbus: Remove sysbus_mmio_map_common() @may_overlap argument Philippe Mathieu-Daudé
2025-10-29 8:53 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 24/25] hw/sysbus: Use memory_region_is_mapped() to check for mapped region Philippe Mathieu-Daudé
2025-10-29 8:54 ` Richard Henderson
2025-10-28 18:12 ` [PATCH v3 25/25] hw/sysbus: Simplify SysBusDevice::mmio Philippe Mathieu-Daudé
2025-10-29 8:55 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).