summaryrefslogtreecommitdiffstats
path: root/linux-user
diff options
context:
space:
mode:
authorRichard Henderson2010-03-10 23:38:59 +0100
committerPaul Brook2010-03-12 17:29:07 +0100
commit7bc7b099dfa38a856b1bc892c0f9f3d6fe28e170 (patch)
tree89f87316997247b2db97b323971101ddec19f557 /linux-user
parentUse TARGET_VIRT_ADDR_SPACE_BITS in h2g_valid. (diff)
downloadqemu-7bc7b099dfa38a856b1bc892c0f9f3d6fe28e170.tar.gz
qemu-7bc7b099dfa38a856b1bc892c0f9f3d6fe28e170.tar.xz
qemu-7bc7b099dfa38a856b1bc892c0f9f3d6fe28e170.zip
linux-user: Use h2g_valid in qemu_vmalloc.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/mmap.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 25fc0b2959..65fdc33c26 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -80,16 +80,15 @@ void mmap_unlock(void)
void *qemu_vmalloc(size_t size)
{
void *p;
- unsigned long addr;
+
mmap_lock();
/* Use map and mark the pages as used. */
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- addr = (unsigned long)p;
- if (addr == (target_ulong) addr) {
- /* Allocated region overlaps guest address space.
- This may recurse. */
+ if (h2g_valid(p)) {
+ /* Allocated region overlaps guest address space. This may recurse. */
+ unsigned long addr = h2g(p);
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
PAGE_RESERVED);
}