libxc: flask: use (un)lock pages rather than open coding m(un)lock.
authorIan Campbell <ian.campbell@citrix.com>
Mon, 18 Oct 2010 15:43:15 +0000 (16:43 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 18 Oct 2010 15:43:15 +0000 (16:43 +0100)
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>
tools/libxc/xc_flask.c
tools/libxc/xc_private.c
tools/libxc/xc_private.h

index d9d4204f4e316a2ae1684fa653efeb3a158dcd62..e97f9b09e924473db75b35ab1c4c2cbaac4a9719 100644 (file)
@@ -44,7 +44,7 @@ int xc_flask_op(xc_interface *xch, flask_op_t *op)
     hypercall.op     = __HYPERVISOR_xsm_op;
     hypercall.arg[0] = (unsigned long)op;
 
-    if ( mlock(op, sizeof(*op)) != 0 )
+    if ( lock_pages(op, sizeof(*op)) != 0 )
     {
         PERROR("Could not lock memory for Xen hypercall");
         goto out;
@@ -56,7 +56,7 @@ int xc_flask_op(xc_interface *xch, flask_op_t *op)
             fprintf(stderr, "XSM operation failed!\n");
     }
 
-    safe_munlock(op, sizeof(*op));
+    unlock_pages(op, sizeof(*op));
 
  out:
     return ret;
index e6952a1a527ac9d9b5225e36ba207ed57dad6eea..a1822edc69702cc84e6f58618aed0ffab7aa1fb0 100644 (file)
@@ -218,7 +218,9 @@ void unlock_pages(void *addr, size_t len)
     void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
     size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
                    PAGE_SIZE - 1) & PAGE_MASK;
-    safe_munlock(laddr, llen);
+    int saved_errno = errno;
+    (void)munlock(laddr, llen);
+    errno = saved_errno;
 }
 
 static pthread_key_t hcall_buf_pkey;
index bec3871e19ca4c8b8b4cb18cfba11b63fef4444b..88f3a72909b0616c5492126d85a1092d57329c34 100644 (file)
@@ -106,13 +106,6 @@ void unlock_pages(void *addr, size_t len);
 int hcall_buf_prep(void **addr, size_t len);
 void hcall_buf_release(void **addr, size_t len);
 
-static inline void safe_munlock(const void *addr, size_t len)
-{
-    int saved_errno = errno;
-    (void)munlock(addr, len);
-    errno = saved_errno;
-}
-
 int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall);
 
 static inline int do_xen_version(xc_interface *xch, int cmd, void *dest)