WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 02 of 24] libxc: flask: use (un)lock pages rather tha

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 02 of 24] libxc: flask: use (un)lock pages rather than open coding m(un)lock
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 06 Sep 2010 14:38:22 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 06 Sep 2010 06:42:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1283780300@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1283779690 -3600
# Node ID 89333e9d1d90fba9e5a493ae4f541a956a04e3c0
# Parent  f3b0732b41af4dd3218e59dae6e0a005c323774f
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@xxxxxxxxxx>

diff -r f3b0732b41af -r 89333e9d1d90 tools/libxc/xc_flask.c
--- a/tools/libxc/xc_flask.c    Mon Sep 06 14:07:06 2010 +0100
+++ b/tools/libxc/xc_flask.c    Mon Sep 06 14:28:10 2010 +0100
@@ -44,7 +44,7 @@ int xc_flask_op(xc_interface *xch, flask
     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
             fprintf(stderr, "XSM operation failed!\n");
     }
 
-    safe_munlock(op, sizeof(*op));
+    unlock_pages(op, sizeof(*op));
 
  out:
     return ret;
diff -r f3b0732b41af -r 89333e9d1d90 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Mon Sep 06 14:07:06 2010 +0100
+++ b/tools/libxc/xc_private.c  Mon Sep 06 14:28:10 2010 +0100
@@ -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;
diff -r f3b0732b41af -r 89333e9d1d90 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h  Mon Sep 06 14:07:06 2010 +0100
+++ b/tools/libxc/xc_private.h  Mon Sep 06 14:28:10 2010 +0100
@@ -105,13 +105,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);
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel