qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw()
@ 2025-09-30  4:13 Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 01/17] docs/devel/loads-stores: Stop mentioning cpu_physical_memory_write_rom() Philippe Mathieu-Daudé
                   ` (16 more replies)
  0 siblings, 17 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Since v1:
- Removed extra 'len' arg in address_space_is_io (rth)

---

The cpu_physical_memory API is legacy (see commit b7ecba0f6f6):

  ``cpu_physical_memory_*``
  ~~~~~~~~~~~~~~~~~~~~~~~~~

  These are convenience functions which are identical to
  ``address_space_*`` but operate specifically on the system address space,
  always pass a ``MEMTXATTRS_UNSPECIFIED`` set of memory attributes and
  ignore whether the memory transaction succeeded or failed.
  For new code they are better avoided:
  ...

This series removes:
  - cpu_physical_memory_is_io()
  - cpu_physical_memory_rw()
and start converting some
  - cpu_physical_memory_map()
  - cpu_physical_memory_unmap()
calls.

Based-on: <20250922192940.2908002-1-richard.henderson@linaro.org>
          "system/memory: Split address_space_write_rom_internal"

Philippe Mathieu-Daudé (17):
  docs/devel/loads-stores: Stop mentioning
    cpu_physical_memory_write_rom()
  system/memory: Better describe @plen argument of flatview_translate()
  system/memory: Factor address_space_is_io() out
  target/i386/arch_memory_mapping: Use address_space_memory_is_io()
  hw/s390x/sclp: Use address_space_memory_is_io() in sclp_service_call()
  system/physmem: Remove cpu_physical_memory_is_io()
  system/physmem: Pass address space argument to
    cpu_flush_icache_range()
  hw/s390x/sclp: Replace [cpu_physical_memory -> address_space]_r/w()
  target/s390x/mmu: Replace [cpu_physical_memory -> address_space]_rw()
  target/i386/whpx: Replace legacy cpu_physical_memory_rw() call
  target/i386/kvm: Replace legacy cpu_physical_memory_rw() call
  target/i386/nvmm: Inline cpu_physical_memory_rw() in nvmm_mem_callback
  hw/xen/hvm: Inline cpu_physical_memory_rw() in rw_phys_req_item()
  system/physmem: Un-inline cpu_physical_memory_read/write()
  system/physmem: Inline cpu_physical_memory_rw() and remove it
  hw/virtio/vhost: Replace legacy cpu_physical_memory_*map() calls
  hw/virtio/virtio: Replace legacy cpu_physical_memory_map() call

 docs/devel/loads-stores.rst            |  6 ++--
 scripts/coccinelle/exec_rw_const.cocci | 22 ------------
 include/exec/cpu-common.h              | 18 ++--------
 include/system/memory.h                | 16 +++++++--
 hw/core/loader.c                       |  2 +-
 hw/s390x/sclp.c                        | 14 +++++---
 hw/virtio/vhost.c                      |  6 ++--
 hw/virtio/virtio.c                     | 10 +++---
 hw/xen/xen-hvm-common.c                |  8 +++--
 system/physmem.c                       | 48 ++++++++++++++------------
 target/i386/arch_memory_mapping.c      | 10 +++---
 target/i386/kvm/xen-emu.c              |  4 ++-
 target/i386/nvmm/nvmm-all.c            |  5 ++-
 target/i386/whpx/whpx-all.c            |  7 ++--
 target/s390x/mmu_helper.c              |  6 ++--
 15 files changed, 89 insertions(+), 93 deletions(-)

-- 
2.51.0



^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 01/17] docs/devel/loads-stores: Stop mentioning cpu_physical_memory_write_rom()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 02/17] system/memory: Better describe @plen argument of flatview_translate() Philippe Mathieu-Daudé
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Update the documentation after commit 3c8133f9737 ("Rename
cpu_physical_memory_write_rom() to address_space_write_rom()").

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 docs/devel/loads-stores.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
index 9471bac8599..f9b565da57a 100644
--- a/docs/devel/loads-stores.rst
+++ b/docs/devel/loads-stores.rst
@@ -474,7 +474,7 @@ This function is intended for use by the GDB stub and similar code.
 It takes a virtual address, converts it to a physical address via
 an MMU lookup using the current settings of the specified CPU,
 and then performs the access (using ``address_space_rw`` for
-reads or ``cpu_physical_memory_write_rom`` for writes).
+reads or ``address_space_write_rom`` for writes).
 This means that if the access is a write to a ROM then this
 function will modify the contents (whereas a normal guest CPU access
 would ignore the write attempt).
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 02/17] system/memory: Better describe @plen argument of flatview_translate()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 01/17] docs/devel/loads-stores: Stop mentioning cpu_physical_memory_write_rom() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:51   ` Thomas Huth
  2025-09-30  4:13 ` [PATCH v2 03/17] system/memory: Factor address_space_is_io() out Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

flatview_translate()'s @plen argument is output-only and can be NULL.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/system/memory.h | 5 +++--
 system/physmem.c        | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/system/memory.h b/include/system/memory.h
index aa85fc27a10..3e5bf3ef05e 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -2992,13 +2992,14 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
  * @addr: address within that address space
  * @xlat: pointer to address within the returned memory region section's
  * #MemoryRegion.
- * @len: pointer to length
+ * @plen_out: pointer to valid read/write length of the translated address.
+ *            It can be @NULL when we don't care about it.
  * @is_write: indicates the transfer direction
  * @attrs: memory attributes
  */
 MemoryRegion *flatview_translate(FlatView *fv,
                                  hwaddr addr, hwaddr *xlat,
-                                 hwaddr *len, bool is_write,
+                                 hwaddr *plen_out, bool is_write,
                                  MemTxAttrs attrs);
 
 static inline MemoryRegion *address_space_translate(AddressSpace *as,
diff --git a/system/physmem.c b/system/physmem.c
index 8a8be3a80e2..2d1697fce4c 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -566,7 +566,7 @@ iotlb_fail:
 
 /* Called from RCU critical section */
 MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
-                                 hwaddr *plen, bool is_write,
+                                 hwaddr *plen_out, bool is_write,
                                  MemTxAttrs attrs)
 {
     MemoryRegion *mr;
@@ -574,13 +574,13 @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
     AddressSpace *as = NULL;
 
     /* This can be MMIO, so setup MMIO bit. */
-    section = flatview_do_translate(fv, addr, xlat, plen, NULL,
+    section = flatview_do_translate(fv, addr, xlat, plen_out, NULL,
                                     is_write, true, &as, attrs);
     mr = section.mr;
 
     if (xen_enabled() && memory_access_is_direct(mr, is_write, attrs)) {
         hwaddr page = ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr;
-        *plen = MIN(page, *plen);
+        *plen_out = MIN(page, *plen_out);
     }
 
     return mr;
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 03/17] system/memory: Factor address_space_is_io() out
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 01/17] docs/devel/loads-stores: Stop mentioning cpu_physical_memory_write_rom() Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 02/17] system/memory: Better describe @plen argument of flatview_translate() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  5:00   ` Thomas Huth
  2025-09-30  4:13 ` [PATCH v2 04/17] target/i386/arch_memory_mapping: Use address_space_memory_is_io() Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Factor address_space_is_io() out of cpu_physical_memory_is_io().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/system/memory.h |  9 +++++++++
 system/physmem.c        | 21 ++++++++++++---------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/include/system/memory.h b/include/system/memory.h
index 3e5bf3ef05e..546c643961d 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -3030,6 +3030,15 @@ static inline MemoryRegion *address_space_translate(AddressSpace *as,
 bool address_space_access_valid(AddressSpace *as, hwaddr addr, hwaddr len,
                                 bool is_write, MemTxAttrs attrs);
 
+/**
+ * address_space_is_io: check whether an guest physical addresses
+ *                      whithin an address space is I/O memory.
+ *
+ * @as: #AddressSpace to be accessed
+ * @addr: address within that address space
+ */
+bool address_space_is_io(AddressSpace *as, hwaddr addr);
+
 /* address_space_map: map a physical memory region into a host virtual address
  *
  * May map a subset of the requested range, given by and returned in @plen.
diff --git a/system/physmem.c b/system/physmem.c
index 2d1697fce4c..be8e66dfe02 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3358,6 +3358,17 @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr,
     return flatview_access_valid(fv, addr, len, is_write, attrs);
 }
 
+bool address_space_is_io(AddressSpace *as, hwaddr addr)
+{
+    MemoryRegion *mr;
+
+    RCU_READ_LOCK_GUARD();
+    mr = address_space_translate(as, addr, &addr, NULL, false,
+                                 MEMTXATTRS_UNSPECIFIED);
+
+    return !(memory_region_is_ram(mr) || memory_region_is_romd(mr));
+}
+
 static hwaddr
 flatview_extend_translation(FlatView *fv, hwaddr addr,
                             hwaddr target_len,
@@ -3754,15 +3765,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
 
 bool cpu_physical_memory_is_io(hwaddr phys_addr)
 {
-    MemoryRegion*mr;
-    hwaddr l = 1;
-
-    RCU_READ_LOCK_GUARD();
-    mr = address_space_translate(&address_space_memory,
-                                 phys_addr, &phys_addr, &l, false,
-                                 MEMTXATTRS_UNSPECIFIED);
-
-    return !(memory_region_is_ram(mr) || memory_region_is_romd(mr));
+    return address_space_is_io(&address_space_memory, phys_addr);
 }
 
 int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque)
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 04/17] target/i386/arch_memory_mapping: Use address_space_memory_is_io()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 03/17] system/memory: Factor address_space_is_io() out Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 05/17] hw/s390x/sclp: Use address_space_memory_is_io() in sclp_service_call() Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Since all functions have an address space argument, it is
trivial to replace cpu_physical_memory_is_io() by
address_space_memory_is_io().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/i386/arch_memory_mapping.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/target/i386/arch_memory_mapping.c b/target/i386/arch_memory_mapping.c
index a2398c21732..560f4689abc 100644
--- a/target/i386/arch_memory_mapping.c
+++ b/target/i386/arch_memory_mapping.c
@@ -35,7 +35,7 @@ static void walk_pte(MemoryMappingList *list, AddressSpace *as,
         }
 
         start_paddr = (pte & ~0xfff) & ~(0x1ULL << 63);
-        if (cpu_physical_memory_is_io(start_paddr)) {
+        if (address_space_is_io(as, start_paddr)) {
             /* I/O region */
             continue;
         }
@@ -65,7 +65,7 @@ static void walk_pte2(MemoryMappingList *list, AddressSpace *as,
         }
 
         start_paddr = pte & ~0xfff;
-        if (cpu_physical_memory_is_io(start_paddr)) {
+        if (address_space_is_io(as, start_paddr)) {
             /* I/O region */
             continue;
         }
@@ -100,7 +100,7 @@ static void walk_pde(MemoryMappingList *list, AddressSpace *as,
         if (pde & PG_PSE_MASK) {
             /* 2 MB page */
             start_paddr = (pde & ~0x1fffff) & ~(0x1ULL << 63);
-            if (cpu_physical_memory_is_io(start_paddr)) {
+            if (address_space_is_io(as, start_paddr)) {
                 /* I/O region */
                 continue;
             }
@@ -142,7 +142,7 @@ static void walk_pde2(MemoryMappingList *list, AddressSpace *as,
              */
             high_paddr = ((hwaddr)(pde & 0x1fe000) << 19);
             start_paddr = (pde & ~0x3fffff) | high_paddr;
-            if (cpu_physical_memory_is_io(start_paddr)) {
+            if (address_space_is_io(as, start_paddr)) {
                 /* I/O region */
                 continue;
             }
@@ -203,7 +203,7 @@ static void walk_pdpe(MemoryMappingList *list, AddressSpace *as,
         if (pdpe & PG_PSE_MASK) {
             /* 1 GB page */
             start_paddr = (pdpe & ~0x3fffffff) & ~(0x1ULL << 63);
-            if (cpu_physical_memory_is_io(start_paddr)) {
+            if (address_space_is_io(as, start_paddr)) {
                 /* I/O region */
                 continue;
             }
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 05/17] hw/s390x/sclp: Use address_space_memory_is_io() in sclp_service_call()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 04/17] target/i386/arch_memory_mapping: Use address_space_memory_is_io() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:43   ` Thomas Huth
  2025-09-30  4:13 ` [PATCH v2 06/17] system/physmem: Remove cpu_physical_memory_is_io() Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

When cpu_address_space_init() isn't called during vCPU creation,
its single address space is the global &address_space_memory.

As s390x boards don't call cpu_address_space_init(),
cpu_get_address_space(CPU(cpu), 0) returns &address_space_memory.

We can then replace cpu_physical_memory_is_io() by the semantically
equivalent address_space_memory_is_io() call.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/s390x/sclp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 9718564fa42..f507b36cd91 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -16,6 +16,7 @@
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/boards.h"
+#include "system/memory.h"
 #include "hw/s390x/sclp.h"
 #include "hw/s390x/event-facility.h"
 #include "hw/s390x/s390-pci-bus.h"
@@ -301,6 +302,7 @@ int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code)
     CPUS390XState *env = &cpu->env;
     SCLPDevice *sclp = get_sclp_device();
     SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
+    AddressSpace *as = cpu_get_address_space(CPU(cpu), 0);
     SCCBHeader header;
     g_autofree SCCB *work_sccb = NULL;
 
@@ -308,7 +310,7 @@ int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code)
     if (env->psw.mask & PSW_MASK_PSTATE) {
         return -PGM_PRIVILEGED;
     }
-    if (cpu_physical_memory_is_io(sccb)) {
+    if (address_space_is_io(as, sccb)) {
         return -PGM_ADDRESSING;
     }
     if ((sccb & ~0x1fffUL) == 0 || (sccb & ~0x1fffUL) == env->psa
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 06/17] system/physmem: Remove cpu_physical_memory_is_io()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 05/17] hw/s390x/sclp: Use address_space_memory_is_io() in sclp_service_call() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 07/17] system/physmem: Pass address space argument to cpu_flush_icache_range() Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

There are no more uses of the legacy cpu_physical_memory_is_io()
method. Remove it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu-common.h | 2 --
 system/physmem.c          | 5 -----
 2 files changed, 7 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index e413d8b3079..a73463a7038 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -149,8 +149,6 @@ void *cpu_physical_memory_map(hwaddr addr,
 void cpu_physical_memory_unmap(void *buffer, hwaddr len,
                                bool is_write, hwaddr access_len);
 
-bool cpu_physical_memory_is_io(hwaddr phys_addr);
-
 /* Coalesced MMIO regions are areas where write operations can be reordered.
  * This usually implies that write operations are side-effect free.  This allows
  * batching which can make a major impact on performance when using
diff --git a/system/physmem.c b/system/physmem.c
index be8e66dfe02..573e5bb1adc 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3763,11 +3763,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
     return 0;
 }
 
-bool cpu_physical_memory_is_io(hwaddr phys_addr)
-{
-    return address_space_is_io(&address_space_memory, phys_addr);
-}
-
 int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque)
 {
     RAMBlock *block;
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 07/17] system/physmem: Pass address space argument to cpu_flush_icache_range()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 06/17] system/physmem: Remove cpu_physical_memory_is_io() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:15   ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 08/17] hw/s390x/sclp: Replace [cpu_physical_memory -> address_space]_r/w() Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  16 siblings, 1 reply; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Rename cpu_flush_icache_range() as address_space_flush_icache_range(),
passing an address space by argument. The single caller, rom_reset(),
already operates on an address space. Use it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/cpu-common.h | 2 --
 include/system/memory.h   | 2 ++
 hw/core/loader.c          | 2 +-
 system/physmem.c          | 5 ++---
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index a73463a7038..6c7d84aacb4 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -156,8 +156,6 @@ void cpu_physical_memory_unmap(void *buffer, hwaddr len,
  */
 void qemu_flush_coalesced_mmio_buffer(void);
 
-void cpu_flush_icache_range(hwaddr start, hwaddr len);
-
 typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque);
 
 int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
diff --git a/include/system/memory.h b/include/system/memory.h
index 546c643961d..dfea90c4d6b 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -2977,6 +2977,8 @@ void address_space_cache_invalidate(MemoryRegionCache *cache,
  */
 void address_space_cache_destroy(MemoryRegionCache *cache);
 
+void address_space_flush_icache_range(AddressSpace *as, hwaddr addr, hwaddr len);
+
 /* address_space_get_iotlb_entry: translate an address into an IOTLB
  * entry. Should be called from an RCU critical section.
  */
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 524af6f14a0..477661a0255 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -1242,7 +1242,7 @@ static void rom_reset(void *unused)
          * that the instruction cache for that new region is clear, so that the
          * CPU definitely fetches its instructions from the just written data.
          */
-        cpu_flush_icache_range(rom->addr, rom->datasize);
+        address_space_flush_icache_range(rom->as, rom->addr, rom->datasize);
 
         trace_loader_write_rom(rom->name, rom->addr, rom->datasize, rom->isrom);
     }
diff --git a/system/physmem.c b/system/physmem.c
index 573e5bb1adc..70b02675b93 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3214,7 +3214,7 @@ MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr,
     return MEMTX_OK;
 }
 
-void cpu_flush_icache_range(hwaddr addr, hwaddr len)
+void address_space_flush_icache_range(AddressSpace *as, hwaddr addr, hwaddr len)
 {
     /*
      * This function should do the same thing as an icache flush that was
@@ -3229,8 +3229,7 @@ void cpu_flush_icache_range(hwaddr addr, hwaddr len)
     RCU_READ_LOCK_GUARD();
     while (len > 0) {
         hwaddr addr1, l = len;
-        MemoryRegion *mr = address_space_translate(&address_space_memory,
-                                                   addr, &addr1, &l, true,
+        MemoryRegion *mr = address_space_translate(as, addr, &addr1, &l, true,
                                                    MEMTXATTRS_UNSPECIFIED);
 
         if (!memory_region_supports_direct_access(mr)) {
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 08/17] hw/s390x/sclp: Replace [cpu_physical_memory -> address_space]_r/w()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 07/17] system/physmem: Pass address space argument to cpu_flush_icache_range() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:47   ` Thomas Huth
  2025-09-30  4:13 ` [PATCH v2 09/17] target/s390x/mmu: Replace [cpu_physical_memory -> address_space]_rw() Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

cpu_physical_memory_read() and cpu_physical_memory_write() are
legacy (see commit b7ecba0f6f6), replace by address_space_read()
and address_space_write().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/s390x/sclp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index f507b36cd91..152c773d1b4 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -319,7 +319,8 @@ int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code)
     }
 
     /* the header contains the actual length of the sccb */
-    cpu_physical_memory_read(sccb, &header, sizeof(SCCBHeader));
+    address_space_read(as, sccb, MEMTXATTRS_UNSPECIFIED,
+                       &header, sizeof(SCCBHeader));
 
     /* Valid sccb sizes */
     if (be16_to_cpu(header.length) < sizeof(SCCBHeader)) {
@@ -332,7 +333,8 @@ int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code)
      * the host has checked the values
      */
     work_sccb = g_malloc0(be16_to_cpu(header.length));
-    cpu_physical_memory_read(sccb, work_sccb, be16_to_cpu(header.length));
+    address_space_read(as, sccb, MEMTXATTRS_UNSPECIFIED,
+                       work_sccb, be16_to_cpu(header.length));
 
     if (!sclp_command_code_valid(code)) {
         work_sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND);
@@ -346,8 +348,8 @@ int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code)
 
     sclp_c->execute(sclp, work_sccb, code);
 out_write:
-    cpu_physical_memory_write(sccb, work_sccb,
-                              be16_to_cpu(work_sccb->h.length));
+    address_space_write(as, sccb, MEMTXATTRS_UNSPECIFIED,
+                        work_sccb, be16_to_cpu(header.length));
 
     sclp_c->service_interrupt(sclp, sccb);
 
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 09/17] target/s390x/mmu: Replace [cpu_physical_memory -> address_space]_rw()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 08/17] hw/s390x/sclp: Replace [cpu_physical_memory -> address_space]_r/w() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:42   ` Thomas Huth
  2025-09-30  4:13 ` [PATCH v2 10/17] target/i386/whpx: Replace legacy cpu_physical_memory_rw() call Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

When cpu_address_space_init() isn't called during vCPU creation,
its single address space is the global &address_space_memory.

As s390x boards don't call cpu_address_space_init(),
cpu_get_address_space(CPU(cpu), 0) returns &address_space_memory.

We can then replace cpu_physical_memory_rw() by the semantically
equivalent address_space_rw() call.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/s390x/mmu_helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
index 00946e9c0fe..4e2f31dc763 100644
--- a/target/s390x/mmu_helper.c
+++ b/target/s390x/mmu_helper.c
@@ -23,6 +23,7 @@
 #include "kvm/kvm_s390x.h"
 #include "system/kvm.h"
 #include "system/tcg.h"
+#include "system/memory.h"
 #include "exec/page-protection.h"
 #include "exec/target_page.h"
 #include "hw/hw.h"
@@ -522,6 +523,7 @@ int s390_cpu_pv_mem_rw(S390CPU *cpu, unsigned int offset, void *hostbuf,
 int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
                          int len, bool is_write)
 {
+    AddressSpace *as = cpu_get_address_space(CPU(cpu), 0);
     int currlen, nr_pages, i;
     target_ulong *pages;
     uint64_t tec;
@@ -545,8 +547,8 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
         /* Copy data by stepping through the area page by page */
         for (i = 0; i < nr_pages; i++) {
             currlen = MIN(len, TARGET_PAGE_SIZE - (laddr % TARGET_PAGE_SIZE));
-            cpu_physical_memory_rw(pages[i] | (laddr & ~TARGET_PAGE_MASK),
-                                   hostbuf, currlen, is_write);
+            address_space_rw(as, pages[i] | (laddr & ~TARGET_PAGE_MASK),
+                             MEMTXATTRS_UNSPECIFIED, hostbuf, currlen, is_write);
             laddr += currlen;
             hostbuf += currlen;
             len -= currlen;
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 10/17] target/i386/whpx: Replace legacy cpu_physical_memory_rw() call
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 09/17] target/s390x/mmu: Replace [cpu_physical_memory -> address_space]_rw() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 11/17] target/i386/kvm: " Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Get the vCPU address space and convert the legacy
cpu_physical_memory_rw() by address_space_rw().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/i386/whpx/whpx-all.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 2a85168ed51..82ba177c4a5 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -788,8 +788,11 @@ static HRESULT CALLBACK whpx_emu_mmio_callback(
     void *ctx,
     WHV_EMULATOR_MEMORY_ACCESS_INFO *ma)
 {
-    cpu_physical_memory_rw(ma->GpaAddress, ma->Data, ma->AccessSize,
-                           ma->Direction);
+    CPUState *cpu = (CPUState *)ctx;
+    AddressSpace *as = cpu_addressspace(cs, MEMTXATTRS_UNSPECIFIED);
+
+    address_space_rw(as, ma->GpaAddress, MEMTXATTRS_UNSPECIFIED,
+                     ma->Data, ma->AccessSize, ma->Direction);
     return S_OK;
 }
 
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 11/17] target/i386/kvm: Replace legacy cpu_physical_memory_rw() call
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 10/17] target/i386/whpx: Replace legacy cpu_physical_memory_rw() call Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 12/17] target/i386/nvmm: Inline cpu_physical_memory_rw() in nvmm_mem_callback Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Get the vCPU address space and convert the legacy
cpu_physical_memory_rw() by address_space_rw().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/i386/kvm/xen-emu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index 284c5ef6f68..52de0198343 100644
--- a/target/i386/kvm/xen-emu.c
+++ b/target/i386/kvm/xen-emu.c
@@ -21,6 +21,7 @@
 #include "system/address-spaces.h"
 #include "xen-emu.h"
 #include "trace.h"
+#include "system/memory.h"
 #include "system/runstate.h"
 
 #include "hw/pci/msi.h"
@@ -75,6 +76,7 @@ static bool kvm_gva_to_gpa(CPUState *cs, uint64_t gva, uint64_t *gpa,
 static int kvm_gva_rw(CPUState *cs, uint64_t gva, void *_buf, size_t sz,
                       bool is_write)
 {
+    AddressSpace *as = cpu_addressspace(cs, MEMTXATTRS_UNSPECIFIED);
     uint8_t *buf = (uint8_t *)_buf;
     uint64_t gpa;
     size_t len;
@@ -87,7 +89,7 @@ static int kvm_gva_rw(CPUState *cs, uint64_t gva, void *_buf, size_t sz,
             len = sz;
         }
 
-        cpu_physical_memory_rw(gpa, buf, len, is_write);
+        address_space_rw(as, gpa, MEMTXATTRS_UNSPECIFIED, buf, len, is_write);
 
         buf += len;
         sz -= len;
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 12/17] target/i386/nvmm: Inline cpu_physical_memory_rw() in nvmm_mem_callback
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 11/17] target/i386/kvm: " Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 13/17] hw/xen/hvm: Inline cpu_physical_memory_rw() in rw_phys_req_item() Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/i386/nvmm/nvmm-all.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index ed424251673..2e442baf4b7 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -15,6 +15,7 @@
 #include "accel/accel-ops.h"
 #include "system/nvmm.h"
 #include "system/cpus.h"
+#include "system/memory.h"
 #include "system/runstate.h"
 #include "qemu/main-loop.h"
 #include "qemu/error-report.h"
@@ -516,7 +517,9 @@ nvmm_io_callback(struct nvmm_io *io)
 static void
 nvmm_mem_callback(struct nvmm_mem *mem)
 {
-    cpu_physical_memory_rw(mem->gpa, mem->data, mem->size, mem->write);
+    /* TODO: Get CPUState via mem->vcpu? */
+    address_space_rw(&address_space_memory, mem->gpa, MEMTXATTRS_UNSPECIFIED,
+                     mem->data, mem->size, mem->write);
 
     /* Needed, otherwise infinite loop. */
     current_cpu->vcpu_dirty = false;
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 13/17] hw/xen/hvm: Inline cpu_physical_memory_rw() in rw_phys_req_item()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 12/17] target/i386/nvmm: Inline cpu_physical_memory_rw() in nvmm_mem_callback Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write() Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

cpu_physical_memory_rw() is legacy, replace by address_space_rw().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/xen/xen-hvm-common.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c
index 78e0bc8f644..52e2cce397a 100644
--- a/hw/xen/xen-hvm-common.c
+++ b/hw/xen/xen-hvm-common.c
@@ -12,6 +12,7 @@
 #include "hw/xen/xen-bus.h"
 #include "hw/boards.h"
 #include "hw/xen/arch_hvm.h"
+#include "system/memory.h"
 #include "system/runstate.h"
 #include "system/system.h"
 #include "system/xen.h"
@@ -279,8 +280,8 @@ static void do_outp(uint32_t addr,
  * memory, as part of the implementation of an ioreq.
  *
  * Equivalent to
- *   cpu_physical_memory_rw(addr + (req->df ? -1 : +1) * req->size * i,
- *                          val, req->size, 0/1)
+ *   address_space_rw(as, addr + (req->df ? -1 : +1) * req->size * i,
+ *                    attrs, val, req->size, 0/1)
  * except without the integer overflow problems.
  */
 static void rw_phys_req_item(hwaddr addr,
@@ -295,7 +296,8 @@ static void rw_phys_req_item(hwaddr addr,
     } else {
         addr += offset;
     }
-    cpu_physical_memory_rw(addr, val, req->size, rw);
+    address_space_rw(&address_space_memory, addr, MEMTXATTRS_UNSPECIFIED,
+                     val, req->size, rw);
 }
 
 static inline void read_phys_req_item(hwaddr addr,
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write()
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 13/17] hw/xen/hvm: Inline cpu_physical_memory_rw() in rw_phys_req_item() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  5:02   ` Thomas Huth
  2025-09-30  4:13 ` [PATCH v2 15/17] system/physmem: Inline cpu_physical_memory_rw() and remove it Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Un-inline cpu_physical_memory_read() and cpu_physical_memory_write().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/cpu-common.h | 12 ++----------
 system/physmem.c          | 10 ++++++++++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 6c7d84aacb4..6e8cb530f6e 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -133,16 +133,8 @@ void cpu_address_space_destroy(CPUState *cpu, int asidx);
 
 void cpu_physical_memory_rw(hwaddr addr, void *buf,
                             hwaddr len, bool is_write);
-static inline void cpu_physical_memory_read(hwaddr addr,
-                                            void *buf, hwaddr len)
-{
-    cpu_physical_memory_rw(addr, buf, len, false);
-}
-static inline void cpu_physical_memory_write(hwaddr addr,
-                                             const void *buf, hwaddr len)
-{
-    cpu_physical_memory_rw(addr, (void *)buf, len, true);
-}
+void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len);
+void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len);
 void *cpu_physical_memory_map(hwaddr addr,
                               hwaddr *plen,
                               bool is_write);
diff --git a/system/physmem.c b/system/physmem.c
index 70b02675b93..6d6bc449376 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3188,6 +3188,16 @@ void cpu_physical_memory_rw(hwaddr addr, void *buf,
                      buf, len, is_write);
 }
 
+void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len)
+{
+    cpu_physical_memory_rw(addr, buf, len, false);
+}
+
+void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len)
+{
+    cpu_physical_memory_rw(addr, (void *)buf, len, true);
+}
+
 /* used for ROM loading : can write in RAM and ROM */
 MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr,
                                     MemTxAttrs attrs,
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 15/17] system/physmem: Inline cpu_physical_memory_rw() and remove it
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write() Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 16/17] hw/virtio/vhost: Replace legacy cpu_physical_memory_*map() calls Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 17/17] hw/virtio/virtio: Replace legacy cpu_physical_memory_map() call Philippe Mathieu-Daudé
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

After inlining the legacy cpu_physical_memory_rw() in the 2 functions
using it (cpu_physical_memory_read and cpu_physical_memory_write), we
removed all its use: remove it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 docs/devel/loads-stores.rst            |  4 +---
 scripts/coccinelle/exec_rw_const.cocci | 22 ----------------------
 include/exec/cpu-common.h              |  2 --
 system/physmem.c                       | 13 ++++---------
 4 files changed, 5 insertions(+), 36 deletions(-)

diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
index f9b565da57a..c906c6509ee 100644
--- a/docs/devel/loads-stores.rst
+++ b/docs/devel/loads-stores.rst
@@ -460,10 +460,8 @@ For new code they are better avoided:
 
 ``cpu_physical_memory_write``
 
-``cpu_physical_memory_rw``
-
 Regexes for git grep:
- - ``\<cpu_physical_memory_\(read\|write\|rw\)\>``
+ - ``\<cpu_physical_memory_\(read\|write\)\>``
 
 ``cpu_memory_rw_debug``
 ~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/scripts/coccinelle/exec_rw_const.cocci b/scripts/coccinelle/exec_rw_const.cocci
index 1a202969519..4c02c94e04e 100644
--- a/scripts/coccinelle/exec_rw_const.cocci
+++ b/scripts/coccinelle/exec_rw_const.cocci
@@ -21,13 +21,6 @@ expression E1, E2, E3, E4, E5;
 + address_space_rw(E1, E2, E3, E4, E5, true)
 |
 
-- cpu_physical_memory_rw(E1, E2, E3, 0)
-+ cpu_physical_memory_rw(E1, E2, E3, false)
-|
-- cpu_physical_memory_rw(E1, E2, E3, 1)
-+ cpu_physical_memory_rw(E1, E2, E3, true)
-|
-
 - cpu_physical_memory_map(E1, E2, 0)
 + cpu_physical_memory_map(E1, E2, false)
 |
@@ -62,18 +55,6 @@ symbol true, false;
 + address_space_write(E1, E2, E3, E4, E5)
 )
 
-// Avoid uses of cpu_physical_memory_rw() with a constant is_write argument.
-@@
-expression E1, E2, E3;
-@@
-(
-- cpu_physical_memory_rw(E1, E2, E3, false)
-+ cpu_physical_memory_read(E1, E2, E3)
-|
-- cpu_physical_memory_rw(E1, E2, E3, true)
-+ cpu_physical_memory_write(E1, E2, E3)
-)
-
 // Remove useless cast
 @@
 expression E1, E2, E3, E4, E5, E6;
@@ -93,9 +74,6 @@ type T;
 + address_space_write_rom(E1, E2, E3, E4, E5)
 |
 
-- cpu_physical_memory_rw(E1, (T *)(E2), E3, E4)
-+ cpu_physical_memory_rw(E1, E2, E3, E4)
-|
 - cpu_physical_memory_read(E1, (T *)(E2), E3)
 + cpu_physical_memory_read(E1, E2, E3)
 |
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 6e8cb530f6e..910e1c2afb9 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -131,8 +131,6 @@ void cpu_address_space_init(CPUState *cpu, int asidx,
  */
 void cpu_address_space_destroy(CPUState *cpu, int asidx);
 
-void cpu_physical_memory_rw(hwaddr addr, void *buf,
-                            hwaddr len, bool is_write);
 void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len);
 void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len);
 void *cpu_physical_memory_map(hwaddr addr,
diff --git a/system/physmem.c b/system/physmem.c
index 6d6bc449376..a654b2af2a3 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3181,21 +3181,16 @@ MemTxResult address_space_set(AddressSpace *as, hwaddr addr,
     return error;
 }
 
-void cpu_physical_memory_rw(hwaddr addr, void *buf,
-                            hwaddr len, bool is_write)
-{
-    address_space_rw(&address_space_memory, addr, MEMTXATTRS_UNSPECIFIED,
-                     buf, len, is_write);
-}
-
 void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len)
 {
-    cpu_physical_memory_rw(addr, buf, len, false);
+    address_space_read(&address_space_memory, addr,
+                       MEMTXATTRS_UNSPECIFIED, buf, len);
 }
 
 void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len)
 {
-    cpu_physical_memory_rw(addr, (void *)buf, len, true);
+    address_space_write(&address_space_memory, addr,
+                        MEMTXATTRS_UNSPECIFIED, buf, len);
 }
 
 /* used for ROM loading : can write in RAM and ROM */
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 16/17] hw/virtio/vhost: Replace legacy cpu_physical_memory_*map() calls
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 15/17] system/physmem: Inline cpu_physical_memory_rw() and remove it Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  2025-09-30  7:38   ` Philippe Mathieu-Daudé
  2025-09-30  4:13 ` [PATCH v2 17/17] hw/virtio/virtio: Replace legacy cpu_physical_memory_map() call Philippe Mathieu-Daudé
  16 siblings, 1 reply; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Use VirtIODevice::dma_as address space to convert the legacy
cpu_physical_memory_[un]map() calls to address_space_[un]map().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/virtio/vhost.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6557c58d12a..890d2bac585 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -27,6 +27,7 @@
 #include "migration/blocker.h"
 #include "migration/qemu-file-types.h"
 #include "system/dma.h"
+#include "system/memory.h"
 #include "trace.h"
 
 /* enabled until disconnected backend stabilizes */
@@ -455,7 +456,8 @@ static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
                               hwaddr *plen, bool is_write)
 {
     if (!vhost_dev_has_iommu(dev)) {
-        return cpu_physical_memory_map(addr, plen, is_write);
+        return address_space_map(vdev->dma_as, addr, plen, is_write,
+                                 MEMTXATTRS_UNSPECIFIED);
     } else {
         return (void *)(uintptr_t)addr;
     }
@@ -466,7 +468,7 @@ static void vhost_memory_unmap(struct vhost_dev *dev, void *buffer,
                                hwaddr access_len)
 {
     if (!vhost_dev_has_iommu(dev)) {
-        cpu_physical_memory_unmap(buffer, len, is_write, access_len);
+        address_space_unmap(vdev->dma_as, buffer, len, is_write, access_len);
     }
 }
 
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 17/17] hw/virtio/virtio: Replace legacy cpu_physical_memory_map() call
  2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
                   ` (15 preceding siblings ...)
  2025-09-30  4:13 ` [PATCH v2 16/17] hw/virtio/vhost: Replace legacy cpu_physical_memory_*map() calls Philippe Mathieu-Daudé
@ 2025-09-30  4:13 ` Philippe Mathieu-Daudé
  16 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:13 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Philippe Mathieu-Daudé, Jason Herne, Stefano Stabellini,
	Stefano Garzarella, xen-devel, Paolo Bonzini, Ilya Leoshkevich,
	Anthony PERARD, Paul Durrant, Eric Farman, Marcelo Tosatti,
	Halil Pasic, Matthew Rosato, Reinoud Zandijk, Zhao Liu,
	David Woodhouse, Christian Borntraeger, Sunil Muthuswamy, kvm,
	Michael S. Tsirkin, Peter Xu, Thomas Huth, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

Propagate VirtIODevice::dma_as to virtqueue_undo_map_desc()
in order to replace the legacy cpu_physical_memory_unmap()
call by address_space_unmap().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/virtio/virtio.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 9a81ad912e0..1ed3aa6abab 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -31,6 +31,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/virtio/virtio-access.h"
 #include "system/dma.h"
+#include "system/memory.h"
 #include "system/runstate.h"
 #include "virtio-qmp.h"
 
@@ -1622,7 +1623,8 @@ out:
  * virtqueue_unmap_sg() can't be used).  Assumes buffers weren't written to
  * yet.
  */
-static void virtqueue_undo_map_desc(unsigned int out_num, unsigned int in_num,
+static void virtqueue_undo_map_desc(AddressSpace *as,
+                                    unsigned int out_num, unsigned int in_num,
                                     struct iovec *iov)
 {
     unsigned int i;
@@ -1630,7 +1632,7 @@ static void virtqueue_undo_map_desc(unsigned int out_num, unsigned int in_num,
     for (i = 0; i < out_num + in_num; i++) {
         int is_write = i >= out_num;
 
-        cpu_physical_memory_unmap(iov->iov_base, iov->iov_len, is_write, 0);
+        address_space_unmap(as, iov->iov_base, iov->iov_len, is_write, 0);
         iov++;
     }
 }
@@ -1832,7 +1834,7 @@ done:
     return elem;
 
 err_undo_map:
-    virtqueue_undo_map_desc(out_num, in_num, iov);
+    virtqueue_undo_map_desc(vdev->dma_as, out_num, in_num, iov);
     goto done;
 }
 
@@ -1982,7 +1984,7 @@ done:
     return elem;
 
 err_undo_map:
-    virtqueue_undo_map_desc(out_num, in_num, iov);
+    virtqueue_undo_map_desc(vdev->dma_as, out_num, in_num, iov);
     goto done;
 }
 
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 07/17] system/physmem: Pass address space argument to cpu_flush_icache_range()
  2025-09-30  4:13 ` [PATCH v2 07/17] system/physmem: Pass address space argument to cpu_flush_icache_range() Philippe Mathieu-Daudé
@ 2025-09-30  4:15   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  4:15 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, Thomas Huth,
	qemu-s390x, Edgar E. Iglesias, Richard Henderson,
	David Hildenbrand

On 30/9/25 06:13, Philippe Mathieu-Daudé wrote:
> Rename cpu_flush_icache_range() as address_space_flush_icache_range(),
> passing an address space by argument. The single caller, rom_reset(),
> already operates on an address space. Use it.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

> ---
>   include/exec/cpu-common.h | 2 --
>   include/system/memory.h   | 2 ++
>   hw/core/loader.c          | 2 +-
>   system/physmem.c          | 5 ++---
>   4 files changed, 5 insertions(+), 6 deletions(-)



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 09/17] target/s390x/mmu: Replace [cpu_physical_memory -> address_space]_rw()
  2025-09-30  4:13 ` [PATCH v2 09/17] target/s390x/mmu: Replace [cpu_physical_memory -> address_space]_rw() Philippe Mathieu-Daudé
@ 2025-09-30  4:42   ` Thomas Huth
  0 siblings, 0 replies; 29+ messages in thread
From: Thomas Huth @ 2025-09-30  4:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
> When cpu_address_space_init() isn't called during vCPU creation,
> its single address space is the global &address_space_memory.
> 
> As s390x boards don't call cpu_address_space_init(),
> cpu_get_address_space(CPU(cpu), 0) returns &address_space_memory.
> 
> We can then replace cpu_physical_memory_rw() by the semantically
> equivalent address_space_rw() call.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 05/17] hw/s390x/sclp: Use address_space_memory_is_io() in sclp_service_call()
  2025-09-30  4:13 ` [PATCH v2 05/17] hw/s390x/sclp: Use address_space_memory_is_io() in sclp_service_call() Philippe Mathieu-Daudé
@ 2025-09-30  4:43   ` Thomas Huth
  0 siblings, 0 replies; 29+ messages in thread
From: Thomas Huth @ 2025-09-30  4:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
> When cpu_address_space_init() isn't called during vCPU creation,
> its single address space is the global &address_space_memory.
> 
> As s390x boards don't call cpu_address_space_init(),
> cpu_get_address_space(CPU(cpu), 0) returns &address_space_memory.
> 
> We can then replace cpu_physical_memory_is_io() by the semantically
> equivalent address_space_memory_is_io() call.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 08/17] hw/s390x/sclp: Replace [cpu_physical_memory -> address_space]_r/w()
  2025-09-30  4:13 ` [PATCH v2 08/17] hw/s390x/sclp: Replace [cpu_physical_memory -> address_space]_r/w() Philippe Mathieu-Daudé
@ 2025-09-30  4:47   ` Thomas Huth
  0 siblings, 0 replies; 29+ messages in thread
From: Thomas Huth @ 2025-09-30  4:47 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
> cpu_physical_memory_read() and cpu_physical_memory_write() are
> legacy (see commit b7ecba0f6f6), replace by address_space_read()
> and address_space_write().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 02/17] system/memory: Better describe @plen argument of flatview_translate()
  2025-09-30  4:13 ` [PATCH v2 02/17] system/memory: Better describe @plen argument of flatview_translate() Philippe Mathieu-Daudé
@ 2025-09-30  4:51   ` Thomas Huth
  0 siblings, 0 replies; 29+ messages in thread
From: Thomas Huth @ 2025-09-30  4:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
> flatview_translate()'s @plen argument is output-only and can be NULL.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/system/memory.h | 5 +++--
>   system/physmem.c        | 6 +++---
>   2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/include/system/memory.h b/include/system/memory.h
> index aa85fc27a10..3e5bf3ef05e 100644
> --- a/include/system/memory.h
> +++ b/include/system/memory.h
> @@ -2992,13 +2992,14 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
>    * @addr: address within that address space
>    * @xlat: pointer to address within the returned memory region section's
>    * #MemoryRegion.
> - * @len: pointer to length
> + * @plen_out: pointer to valid read/write length of the translated address.
> + *            It can be @NULL when we don't care about it.
>    * @is_write: indicates the transfer direction
>    * @attrs: memory attributes
>    */
>   MemoryRegion *flatview_translate(FlatView *fv,
>                                    hwaddr addr, hwaddr *xlat,
> -                                 hwaddr *len, bool is_write,
> +                                 hwaddr *plen_out, bool is_write,
>                                    MemTxAttrs attrs);
>   
>   static inline MemoryRegion *address_space_translate(AddressSpace *as,
> diff --git a/system/physmem.c b/system/physmem.c
> index 8a8be3a80e2..2d1697fce4c 100644
> --- a/system/physmem.c
> +++ b/system/physmem.c
> @@ -566,7 +566,7 @@ iotlb_fail:
>   
>   /* Called from RCU critical section */
>   MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
> -                                 hwaddr *plen, bool is_write,
> +                                 hwaddr *plen_out, bool is_write,
>                                    MemTxAttrs attrs)
>   {
>       MemoryRegion *mr;
> @@ -574,13 +574,13 @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
>       AddressSpace *as = NULL;
>   
>       /* This can be MMIO, so setup MMIO bit. */
> -    section = flatview_do_translate(fv, addr, xlat, plen, NULL,
> +    section = flatview_do_translate(fv, addr, xlat, plen_out, NULL,
>                                       is_write, true, &as, attrs);
>       mr = section.mr;
>   
>       if (xen_enabled() && memory_access_is_direct(mr, is_write, attrs)) {
>           hwaddr page = ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr;
> -        *plen = MIN(page, *plen);
> +        *plen_out = MIN(page, *plen_out);

There is no check for a NULL pointer here, so plen_out must *not* be NULL?
Or did I miss something?

  Thomas


>       }
>   
>       return mr;



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 03/17] system/memory: Factor address_space_is_io() out
  2025-09-30  4:13 ` [PATCH v2 03/17] system/memory: Factor address_space_is_io() out Philippe Mathieu-Daudé
@ 2025-09-30  5:00   ` Thomas Huth
  0 siblings, 0 replies; 29+ messages in thread
From: Thomas Huth @ 2025-09-30  5:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
> Factor address_space_is_io() out of cpu_physical_memory_is_io().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write()
  2025-09-30  4:13 ` [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write() Philippe Mathieu-Daudé
@ 2025-09-30  5:02   ` Thomas Huth
  2025-09-30  7:23     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 29+ messages in thread
From: Thomas Huth @ 2025-09-30  5:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
> Un-inline cpu_physical_memory_read() and cpu_physical_memory_write().

What's the reasoning for this patch?

  Thomas

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/exec/cpu-common.h | 12 ++----------
>   system/physmem.c          | 10 ++++++++++
>   2 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index 6c7d84aacb4..6e8cb530f6e 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -133,16 +133,8 @@ void cpu_address_space_destroy(CPUState *cpu, int asidx);
>   
>   void cpu_physical_memory_rw(hwaddr addr, void *buf,
>                               hwaddr len, bool is_write);
> -static inline void cpu_physical_memory_read(hwaddr addr,
> -                                            void *buf, hwaddr len)
> -{
> -    cpu_physical_memory_rw(addr, buf, len, false);
> -}
> -static inline void cpu_physical_memory_write(hwaddr addr,
> -                                             const void *buf, hwaddr len)
> -{
> -    cpu_physical_memory_rw(addr, (void *)buf, len, true);
> -}
> +void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len);
> +void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len);
>   void *cpu_physical_memory_map(hwaddr addr,
>                                 hwaddr *plen,
>                                 bool is_write);
> diff --git a/system/physmem.c b/system/physmem.c
> index 70b02675b93..6d6bc449376 100644
> --- a/system/physmem.c
> +++ b/system/physmem.c
> @@ -3188,6 +3188,16 @@ void cpu_physical_memory_rw(hwaddr addr, void *buf,
>                        buf, len, is_write);
>   }
>   
> +void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len)
> +{
> +    cpu_physical_memory_rw(addr, buf, len, false);
> +}
> +
> +void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len)
> +{
> +    cpu_physical_memory_rw(addr, (void *)buf, len, true);
> +}
> +
>   /* used for ROM loading : can write in RAM and ROM */
>   MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr,
>                                       MemTxAttrs attrs,



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write()
  2025-09-30  5:02   ` Thomas Huth
@ 2025-09-30  7:23     ` Philippe Mathieu-Daudé
  2025-09-30  7:25       ` Philippe Mathieu-Daudé
  2025-09-30  7:40       ` Thomas Huth
  0 siblings, 2 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  7:23 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/9/25 07:02, Thomas Huth wrote:
> On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
>> Un-inline cpu_physical_memory_read() and cpu_physical_memory_write().
> 
> What's the reasoning for this patch?

Remove cpu_physical_memory_rw() in the next patch without having
to inline the address_space_read/address_space_write() calls in
"exec/cpu-common.h".

Maybe better squashing both together?

> 
>   Thomas
> 
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/exec/cpu-common.h | 12 ++----------
>>   system/physmem.c          | 10 ++++++++++
>>   2 files changed, 12 insertions(+), 10 deletions(-)
>>
>> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
>> index 6c7d84aacb4..6e8cb530f6e 100644
>> --- a/include/exec/cpu-common.h
>> +++ b/include/exec/cpu-common.h
>> @@ -133,16 +133,8 @@ void cpu_address_space_destroy(CPUState *cpu, int 
>> asidx);
>>   void cpu_physical_memory_rw(hwaddr addr, void *buf,
>>                               hwaddr len, bool is_write);
>> -static inline void cpu_physical_memory_read(hwaddr addr,
>> -                                            void *buf, hwaddr len)
>> -{
>> -    cpu_physical_memory_rw(addr, buf, len, false);
>> -}
>> -static inline void cpu_physical_memory_write(hwaddr addr,
>> -                                             const void *buf, hwaddr 
>> len)
>> -{
>> -    cpu_physical_memory_rw(addr, (void *)buf, len, true);
>> -}
>> +void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len);
>> +void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr 
>> len);
>>   void *cpu_physical_memory_map(hwaddr addr,
>>                                 hwaddr *plen,
>>                                 bool is_write);
>> diff --git a/system/physmem.c b/system/physmem.c
>> index 70b02675b93..6d6bc449376 100644
>> --- a/system/physmem.c
>> +++ b/system/physmem.c
>> @@ -3188,6 +3188,16 @@ void cpu_physical_memory_rw(hwaddr addr, void 
>> *buf,
>>                        buf, len, is_write);
>>   }
>> +void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len)
>> +{
>> +    cpu_physical_memory_rw(addr, buf, len, false);
>> +}
>> +
>> +void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len)
>> +{
>> +    cpu_physical_memory_rw(addr, (void *)buf, len, true);
>> +}
>> +
>>   /* used for ROM loading : can write in RAM and ROM */
>>   MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr,
>>                                       MemTxAttrs attrs,
> 



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write()
  2025-09-30  7:23     ` Philippe Mathieu-Daudé
@ 2025-09-30  7:25       ` Philippe Mathieu-Daudé
  2025-09-30  7:40       ` Thomas Huth
  1 sibling, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  7:25 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/9/25 09:23, Philippe Mathieu-Daudé wrote:
> On 30/9/25 07:02, Thomas Huth wrote:
>> On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
>>> Un-inline cpu_physical_memory_read() and cpu_physical_memory_write().
>>
>> What's the reasoning for this patch?
> 
> Remove cpu_physical_memory_rw() in the next patch without having
> to inline the address_space_read/address_space_write() calls in
> "exec/cpu-common.h".
> 
> Maybe better squashing both together?

That would be:

-- >8 --
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 6c7d84aacb4..910e1c2afb9 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -131,18 +131,8 @@ void cpu_address_space_init(CPUState *cpu, int asidx,
   */
  void cpu_address_space_destroy(CPUState *cpu, int asidx);

-void cpu_physical_memory_rw(hwaddr addr, void *buf,
-                            hwaddr len, bool is_write);
-static inline void cpu_physical_memory_read(hwaddr addr,
-                                            void *buf, hwaddr len)
-{
-    cpu_physical_memory_rw(addr, buf, len, false);
-}
-static inline void cpu_physical_memory_write(hwaddr addr,
-                                             const void *buf, hwaddr len)
-{
-    cpu_physical_memory_rw(addr, (void *)buf, len, true);
-}
+void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len);
+void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len);
  void *cpu_physical_memory_map(hwaddr addr,
                                hwaddr *plen,
                                bool is_write);
diff --git a/system/physmem.c b/system/physmem.c
index 70b02675b93..a654b2af2a3 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3181,11 +3181,16 @@ MemTxResult address_space_set(AddressSpace *as, 
hwaddr addr,
      return error;
  }

-void cpu_physical_memory_rw(hwaddr addr, void *buf,
-                            hwaddr len, bool is_write)
+void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len)
  {
-    address_space_rw(&address_space_memory, addr, MEMTXATTRS_UNSPECIFIED,
-                     buf, len, is_write);
+    address_space_read(&address_space_memory, addr,
+                       MEMTXATTRS_UNSPECIFIED, buf, len);
+}
+
+void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len)
+{
+    address_space_write(&address_space_memory, addr,
+                        MEMTXATTRS_UNSPECIFIED, buf, len);
  }

  /* used for ROM loading : can write in RAM and ROM */
---


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 16/17] hw/virtio/vhost: Replace legacy cpu_physical_memory_*map() calls
  2025-09-30  4:13 ` [PATCH v2 16/17] hw/virtio/vhost: Replace legacy cpu_physical_memory_*map() calls Philippe Mathieu-Daudé
@ 2025-09-30  7:38   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30  7:38 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, Thomas Huth,
	qemu-s390x, Edgar E. Iglesias, Richard Henderson,
	David Hildenbrand

On 30/9/25 06:13, Philippe Mathieu-Daudé wrote:
> Use VirtIODevice::dma_as address space to convert the legacy
> cpu_physical_memory_[un]map() calls to address_space_[un]map().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/virtio/vhost.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 6557c58d12a..890d2bac585 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -27,6 +27,7 @@
>   #include "migration/blocker.h"
>   #include "migration/qemu-file-types.h"
>   #include "system/dma.h"
> +#include "system/memory.h"
>   #include "trace.h"
>   
>   /* enabled until disconnected backend stabilizes */
> @@ -455,7 +456,8 @@ static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
>                                 hwaddr *plen, bool is_write)
>   {
>       if (!vhost_dev_has_iommu(dev)) {
> -        return cpu_physical_memory_map(addr, plen, is_write);
> +        return address_space_map(vdev->dma_as, addr, plen, is_write,
> +                                 MEMTXATTRS_UNSPECIFIED);
>       } else {
>           return (void *)(uintptr_t)addr;
>       }
> @@ -466,7 +468,7 @@ static void vhost_memory_unmap(struct vhost_dev *dev, void *buffer,
>                                  hwaddr access_len)
>   {
>       if (!vhost_dev_has_iommu(dev)) {
> -        cpu_physical_memory_unmap(buffer, len, is_write, access_len);
> +        address_space_unmap(vdev->dma_as, buffer, len, is_write, access_len);
>       }
>   }
>   

Forgot to squash:

-- >8 --
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 890d2bac585..acd359bdb3f 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -456,7 +456,7 @@ static void *vhost_memory_map(struct vhost_dev *dev, 
hwaddr addr,
                                hwaddr *plen, bool is_write)
  {
      if (!vhost_dev_has_iommu(dev)) {
-        return address_space_map(vdev->dma_as, addr, plen, is_write,
+        return address_space_map(dev->vdev->dma_as, addr, plen, is_write,
                                   MEMTXATTRS_UNSPECIFIED);
      } else {
          return (void *)(uintptr_t)addr;
(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? y
@@ -468,7 +468,8 @@ static void vhost_memory_unmap(struct vhost_dev 
*dev, void *buffer,
                                 hwaddr access_len)
  {
      if (!vhost_dev_has_iommu(dev)) {
-        address_space_unmap(vdev->dma_as, buffer, len, is_write, 
access_len);
+        address_space_unmap(dev->vdev->dma_as, buffer, len, is_write,
+                            access_len);
      }
  }

---


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write()
  2025-09-30  7:23     ` Philippe Mathieu-Daudé
  2025-09-30  7:25       ` Philippe Mathieu-Daudé
@ 2025-09-30  7:40       ` Thomas Huth
  1 sibling, 0 replies; 29+ messages in thread
From: Thomas Huth @ 2025-09-30  7:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Peter Maydell
  Cc: Jason Herne, Stefano Stabellini, Stefano Garzarella, xen-devel,
	Paolo Bonzini, Ilya Leoshkevich, Anthony PERARD, Paul Durrant,
	Eric Farman, Marcelo Tosatti, Halil Pasic, Matthew Rosato,
	Reinoud Zandijk, Zhao Liu, David Woodhouse, Christian Borntraeger,
	Sunil Muthuswamy, kvm, Michael S. Tsirkin, Peter Xu, qemu-s390x,
	Edgar E. Iglesias, Richard Henderson, David Hildenbrand

On 30/09/2025 09.23, Philippe Mathieu-Daudé wrote:
> On 30/9/25 07:02, Thomas Huth wrote:
>> On 30/09/2025 06.13, Philippe Mathieu-Daudé wrote:
>>> Un-inline cpu_physical_memory_read() and cpu_physical_memory_write().
>>
>> What's the reasoning for this patch?
> 
> Remove cpu_physical_memory_rw() in the next patch without having
> to inline the address_space_read/address_space_write() calls in
> "exec/cpu-common.h".
> 
> Maybe better squashing both together?

Either squash them, or provide a proper patch description here, but just 
repeating the patch title as description without giving a reasoning is just 
confusing for the reviewers.

  Thomas



^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2025-09-30  7:41 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-30  4:13 [PATCH v2 00/17] system/physmem: Remove cpu_physical_memory _is_io() and _rw() Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 01/17] docs/devel/loads-stores: Stop mentioning cpu_physical_memory_write_rom() Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 02/17] system/memory: Better describe @plen argument of flatview_translate() Philippe Mathieu-Daudé
2025-09-30  4:51   ` Thomas Huth
2025-09-30  4:13 ` [PATCH v2 03/17] system/memory: Factor address_space_is_io() out Philippe Mathieu-Daudé
2025-09-30  5:00   ` Thomas Huth
2025-09-30  4:13 ` [PATCH v2 04/17] target/i386/arch_memory_mapping: Use address_space_memory_is_io() Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 05/17] hw/s390x/sclp: Use address_space_memory_is_io() in sclp_service_call() Philippe Mathieu-Daudé
2025-09-30  4:43   ` Thomas Huth
2025-09-30  4:13 ` [PATCH v2 06/17] system/physmem: Remove cpu_physical_memory_is_io() Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 07/17] system/physmem: Pass address space argument to cpu_flush_icache_range() Philippe Mathieu-Daudé
2025-09-30  4:15   ` Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 08/17] hw/s390x/sclp: Replace [cpu_physical_memory -> address_space]_r/w() Philippe Mathieu-Daudé
2025-09-30  4:47   ` Thomas Huth
2025-09-30  4:13 ` [PATCH v2 09/17] target/s390x/mmu: Replace [cpu_physical_memory -> address_space]_rw() Philippe Mathieu-Daudé
2025-09-30  4:42   ` Thomas Huth
2025-09-30  4:13 ` [PATCH v2 10/17] target/i386/whpx: Replace legacy cpu_physical_memory_rw() call Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 11/17] target/i386/kvm: " Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 12/17] target/i386/nvmm: Inline cpu_physical_memory_rw() in nvmm_mem_callback Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 13/17] hw/xen/hvm: Inline cpu_physical_memory_rw() in rw_phys_req_item() Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 14/17] system/physmem: Un-inline cpu_physical_memory_read/write() Philippe Mathieu-Daudé
2025-09-30  5:02   ` Thomas Huth
2025-09-30  7:23     ` Philippe Mathieu-Daudé
2025-09-30  7:25       ` Philippe Mathieu-Daudé
2025-09-30  7:40       ` Thomas Huth
2025-09-30  4:13 ` [PATCH v2 15/17] system/physmem: Inline cpu_physical_memory_rw() and remove it Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 16/17] hw/virtio/vhost: Replace legacy cpu_physical_memory_*map() calls Philippe Mathieu-Daudé
2025-09-30  7:38   ` Philippe Mathieu-Daudé
2025-09-30  4:13 ` [PATCH v2 17/17] hw/virtio/virtio: Replace legacy cpu_physical_memory_map() call Philippe Mathieu-Daudé

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).