aboutsummaryrefslogtreecommitdiff
path: root/include/exec
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2025-02-10 09:46:42 +0100
committerPeter Xu <peterx@redhat.com>2025-02-12 10:13:27 -0500
commit52012209e1802e67aa186459e3e965f669e553df (patch)
tree64ca92456ae8ff84553eed963bf92d579fafc5c4 /include/exec
parentf051a9c4dc70cd1b6eafa61aec8f3b9344e02e85 (diff)
downloadqemu-52012209e1802e67aa186459e3e965f669e553df.zip
qemu-52012209e1802e67aa186459e3e965f669e553df.tar.gz
qemu-52012209e1802e67aa186459e3e965f669e553df.tar.bz2
physmem: factor out memory_region_is_ram_device() check in memory_access_is_direct()
As documented in commit 4a2e242bbb306 ("memory: Don't use memcpy for ram_device regions"), we disallow direct access to RAM DEVICE regions. Let's make this clearer to prepare for further changes. Note that romd regions will never be RAM DEVICE at the same time. Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Link: https://lore.kernel.org/r/20250210084648.33798-2-david@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to 'include/exec')
-rw-r--r--include/exec/memory.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 9f73b59..5cd7574 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2997,12 +2997,19 @@ bool prepare_mmio_access(MemoryRegion *mr);
static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)
{
+ /*
+ * RAM DEVICE regions can be accessed directly using memcpy, but it might
+ * be MMIO and access using mempy can be wrong (e.g., using instructions not
+ * intended for MMIO access). So we treat this as IO.
+ */
+ if (memory_region_is_ram_device(mr)) {
+ return false;
+ }
if (is_write) {
return memory_region_is_ram(mr) && !mr->readonly &&
- !mr->rom_device && !memory_region_is_ram_device(mr);
+ !mr->rom_device;
} else {
- return (memory_region_is_ram(mr) && !memory_region_is_ram_device(mr)) ||
- memory_region_is_romd(mr);
+ return memory_region_is_ram(mr) || memory_region_is_romd(mr);
}
}