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é <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20251002084203.63899-3-philmd@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2025-09-29 14:36:19 +02:00
parent 7d4c9d2cb8
commit 839976e9da
2 changed files with 21 additions and 9 deletions

View file

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

View file

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