From f64e3d4931a8fdca53b83a62cdd2a439cd17143a Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Sun, 18 Feb 2018 18:09:49 -0500 Subject: [PATCH] exec: add wrapper for host pointer access host pointer accesses force pointer math, let's add a wrapper to make them safer. Backports relevant parts of commit 1240be24357ee292f8d05aa2abfdba75dd0ca25d from qemu --- qemu/exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu/exec.c b/qemu/exec.c index df73c57c..62348345 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -1282,7 +1282,7 @@ void *qemu_get_ram_block_host_ptr(struct uc_struct *uc, ram_addr_t addr) { RAMBlock *block = qemu_get_ram_block(uc, addr); - return block->host; + return ramblock_ptr(block, 0); } /* Return a host pointer to ram allocated with qemu_ram_alloc. @@ -1297,7 +1297,7 @@ void *qemu_get_ram_ptr(struct uc_struct *uc, ram_addr_t addr) { RAMBlock *block = qemu_get_ram_block(uc, addr); - return block->host + (addr - block->offset); + return ramblock_ptr(block, addr - block->offset); } /* Return a host pointer to guest's ram. Similar to qemu_get_ram_ptr