aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar E. Iglesias <edgar.iglesias@amd.com>2024-07-02 00:44:20 +0200
committerEdgar E. Iglesias <edgar.iglesias@amd.com>2024-07-12 00:17:36 +0200
commit596ccccdbfa124adb42be8c2faf0c74f4849c7a6 (patch)
treed182e5b664108f8aab4c0251e011be9f7d34501d
parentd01a6fffa9e5e605cde216733948f97beb01bdb1 (diff)
downloadqemu-596ccccdbfa124adb42be8c2faf0c74f4849c7a6.zip
qemu-596ccccdbfa124adb42be8c2faf0c74f4849c7a6.tar.gz
qemu-596ccccdbfa124adb42be8c2faf0c74f4849c7a6.tar.bz2
physmem: Bail out qemu_ram_block_from_host() for invalid ram addrs
Bail out in qemu_ram_block_from_host() when xen_ram_addr_from_mapcache() does not find an existing mapping. Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
-rw-r--r--system/physmem.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/system/physmem.c b/system/physmem.c
index 14aa025..2154432 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -2277,6 +2277,10 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
ram_addr_t ram_addr;
RCU_READ_LOCK_GUARD();
ram_addr = xen_ram_addr_from_mapcache(ptr);
+ if (ram_addr == RAM_ADDR_INVALID) {
+ return NULL;
+ }
+
block = qemu_get_ram_block(ram_addr);
if (block) {
*offset = ram_addr - block->offset;