From: Philippe Mathieu-Daudé Date: Mon, 29 Sep 2025 12:36:19 +0000 (+0200) Subject: system/memory: Factor address_space_is_io() out X-Git-Tag: v10.2.0-rc1~73^2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=839976e9da4b577aca284847b7e965332f2ca687;p=thirdparty%2Fqemu.git system/memory: Factor address_space_is_io() out Factor address_space_is_io() out of cpu_physical_memory_is_io(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson Message-Id: <20251002084203.63899-3-philmd@linaro.org> --- diff --git a/include/system/memory.h b/include/system/memory.h index 08daf0fc59..f222743b6f 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -3047,6 +3047,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 34216fa538..5574c424f0 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3356,6 +3356,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, @@ -3752,15 +3763,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)