Patchwork Fix bsd-user qemu_vmalloc() host page protection code

login
register
mail settings
Submitter Juergen Lock
Date March 25, 2010, 9:11 p.m.
Message ID <20100325211117.GA52537@triton8.kn-bremen.de>
Download mbox | patch
Permalink /patch/48604/
State New
Headers show

Comments

Juergen Lock - March 25, 2010, 9:11 p.m.
Just do the same as linux-user does.

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>

Patch

--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -77,16 +77,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_ANON, -1, 0);
 
-    addr = (unsigned long)p;
-    if (addr == (target_ulong) addr) {
+    if (h2g_valid(p)) {
         /* Allocated region overlaps guest address space.
            This may recurse.  */
+        abi_ulong addr = h2g(p);
         page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
                        PAGE_RESERVED);
     }