ia64/xen-unstable

changeset 16027:69a74ac976cb

libxenctrl: Fix lock_pages()/unlock_pages() region-size calculation.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Keir Fraser <keir@xensource.com>
date Mon Oct 01 13:18:19 2007 +0100 (2007-10-01)
parents b3814860d170
children 9eff4c97053b
files tools/libxc/xc_private.c
line diff
     1.1 --- a/tools/libxc/xc_private.c	Mon Oct 01 09:32:25 2007 +0100
     1.2 +++ b/tools/libxc/xc_private.c	Mon Oct 01 13:18:19 2007 +0100
     1.3 @@ -130,7 +130,8 @@ int lock_pages(void *addr, size_t len)
     1.4        int e = 0;
     1.5  #ifndef __sun__
     1.6        void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
     1.7 -      size_t llen = (len + PAGE_SIZE - 1) & PAGE_MASK;
     1.8 +      size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
     1.9 +                     PAGE_SIZE - 1) & PAGE_MASK;
    1.10        e = mlock(laddr, llen);
    1.11  #endif
    1.12        return e;
    1.13 @@ -140,7 +141,8 @@ void unlock_pages(void *addr, size_t len
    1.14  {
    1.15  #ifndef __sun__
    1.16      void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
    1.17 -    size_t llen = (len + PAGE_SIZE - 1) & PAGE_MASK;
    1.18 +    size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
    1.19 +                   PAGE_SIZE - 1) & PAGE_MASK;
    1.20      safe_munlock(laddr, llen);
    1.21  #endif
    1.22  }