debuggers.hg

changeset 22290:86cf01f3d737

libxc: flask: use (un)lock pages rather than open coding m(un)lock.

Allows us to do away with safe_unlock and merge into unlock_pages.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Ian Campbell <ian.campbell@citrix.com>
date Mon Oct 18 16:43:15 2010 +0100 (2010-10-18)
parents fc2242ac90e1
children 490b7420deba
files tools/libxc/xc_flask.c tools/libxc/xc_private.c tools/libxc/xc_private.h
line diff
     1.1 --- a/tools/libxc/xc_flask.c	Mon Oct 18 11:31:47 2010 +0100
     1.2 +++ b/tools/libxc/xc_flask.c	Mon Oct 18 16:43:15 2010 +0100
     1.3 @@ -44,7 +44,7 @@ int xc_flask_op(xc_interface *xch, flask
     1.4      hypercall.op     = __HYPERVISOR_xsm_op;
     1.5      hypercall.arg[0] = (unsigned long)op;
     1.6  
     1.7 -    if ( mlock(op, sizeof(*op)) != 0 )
     1.8 +    if ( lock_pages(op, sizeof(*op)) != 0 )
     1.9      {
    1.10          PERROR("Could not lock memory for Xen hypercall");
    1.11          goto out;
    1.12 @@ -56,7 +56,7 @@ int xc_flask_op(xc_interface *xch, flask
    1.13              fprintf(stderr, "XSM operation failed!\n");
    1.14      }
    1.15  
    1.16 -    safe_munlock(op, sizeof(*op));
    1.17 +    unlock_pages(op, sizeof(*op));
    1.18  
    1.19   out:
    1.20      return ret;
     2.1 --- a/tools/libxc/xc_private.c	Mon Oct 18 11:31:47 2010 +0100
     2.2 +++ b/tools/libxc/xc_private.c	Mon Oct 18 16:43:15 2010 +0100
     2.3 @@ -218,7 +218,9 @@ void unlock_pages(void *addr, size_t len
     2.4      void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
     2.5      size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
     2.6                     PAGE_SIZE - 1) & PAGE_MASK;
     2.7 -    safe_munlock(laddr, llen);
     2.8 +    int saved_errno = errno;
     2.9 +    (void)munlock(laddr, llen);
    2.10 +    errno = saved_errno;
    2.11  }
    2.12  
    2.13  static pthread_key_t hcall_buf_pkey;
     3.1 --- a/tools/libxc/xc_private.h	Mon Oct 18 11:31:47 2010 +0100
     3.2 +++ b/tools/libxc/xc_private.h	Mon Oct 18 16:43:15 2010 +0100
     3.3 @@ -106,13 +106,6 @@ void unlock_pages(void *addr, size_t len
     3.4  int hcall_buf_prep(void **addr, size_t len);
     3.5  void hcall_buf_release(void **addr, size_t len);
     3.6  
     3.7 -static inline void safe_munlock(const void *addr, size_t len)
     3.8 -{
     3.9 -    int saved_errno = errno;
    3.10 -    (void)munlock(addr, len);
    3.11 -    errno = saved_errno;
    3.12 -}
    3.13 -
    3.14  int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall);
    3.15  
    3.16  static inline int do_xen_version(xc_interface *xch, int cmd, void *dest)