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
This commit is contained in:
Amit Shah 2018-02-18 18:09:49 -05:00 committed by Lioncash
parent 0696e7fe19
commit f64e3d4931
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

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