]> xenbits.xensource.com Git - xen.git/commitdiff
libxenctrl: Fix lock_pages()/unlock_pages() region-size calculation.
authorKeir Fraser <keir@xensource.com>
Mon, 1 Oct 2007 12:18:19 +0000 (13:18 +0100)
committerKeir Fraser <keir@xensource.com>
Mon, 1 Oct 2007 12:18:19 +0000 (13:18 +0100)
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
tools/libxc/xc_private.c

index 18a18f4c658af0306d49a8719da0228f45854cc9..03d7904d61545c5f55e351fe23b278a34d4dd39e 100644 (file)
@@ -130,7 +130,8 @@ int lock_pages(void *addr, size_t len)
       int e = 0;
 #ifndef __sun__
       void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
-      size_t llen = (len + PAGE_SIZE - 1) & PAGE_MASK;
+      size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
+                     PAGE_SIZE - 1) & PAGE_MASK;
       e = mlock(laddr, llen);
 #endif
       return e;
@@ -140,7 +141,8 @@ void unlock_pages(void *addr, size_t len)
 {
 #ifndef __sun__
     void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
-    size_t llen = (len + PAGE_SIZE - 1) & PAGE_MASK;
+    size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
+                   PAGE_SIZE - 1) & PAGE_MASK;
     safe_munlock(laddr, llen);
 #endif
 }