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-changelog

[Xen-changelog] [xen-3.2-testing] x86 libxc: Fix mlock sizes in libxc ar

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.2-testing] x86 libxc: Fix mlock sizes in libxc around vcpu context hypercalls
From: "Xen patchbot-3.2-testing" <patchbot-3.2-testing@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 09 Apr 2008 09:10:58 -0700
Delivery-date: Wed, 09 Apr 2008 09:11:49 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1207755946 -3600
# Node ID f00c9c09759cac3316c91a62df064f8dea50151b
# Parent  f3bb67460388ceb6f198f4f0b6ebe449c2122a4e
x86 libxc: Fix mlock sizes in libxc around vcpu context hypercalls
backing off to the old behaviour if we fail.

Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
xen-unstable changeset:   17423:c99dee5e44d68d6a0a5251da86e70cf842160dd0
xen-unstable date:        Wed Apr 09 16:24:46 2008 +0100
---
 tools/libxc/xc_domain.c |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diff -r f3bb67460388 -r f00c9c09759c tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Wed Apr 09 16:45:21 2008 +0100
+++ b/tools/libxc/xc_domain.c   Wed Apr 09 16:45:46 2008 +0100
@@ -7,6 +7,7 @@
  */
 
 #include "xc_private.h"
+#include "xg_save_restore.h"
 #include <xen/memory.h>
 #include <xen/hvm/hvm_op.h>
 
@@ -301,18 +302,27 @@ int xc_vcpu_getcontext(int xc_handle,
 {
     int rc;
     DECLARE_DOMCTL;
+    size_t sz = sizeof(vcpu_guest_context_either_t);
 
     domctl.cmd = XEN_DOMCTL_getvcpucontext;
     domctl.domain = (domid_t)domid;
     domctl.u.vcpucontext.vcpu   = (uint16_t)vcpu;
     set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
 
-    if ( (rc = lock_pages(ctxt, sizeof(*ctxt))) != 0 )
-        return rc;
+    /*
+     * We may be asked to lock either a 32-bit or a 64-bit context. Lock the
+     * larger of the two if possible, otherwise fall back to native size.
+     */
+    if ( (rc = lock_pages(ctxt, sz)) != 0 )
+    {
+        sz = sizeof(*ctxt);
+        if ( (rc = lock_pages(ctxt, sz)) != 0 )
+            return rc;
+    }
 
     rc = do_domctl(xc_handle, &domctl);
 
-    unlock_pages(ctxt, sizeof(*ctxt));
+    unlock_pages(ctxt, sz);
 
     return rc;
 }
@@ -635,19 +645,28 @@ int xc_vcpu_setcontext(int xc_handle,
 {
     DECLARE_DOMCTL;
     int rc;
+    size_t sz = sizeof(vcpu_guest_context_either_t);
 
     domctl.cmd = XEN_DOMCTL_setvcpucontext;
     domctl.domain = domid;
     domctl.u.vcpucontext.vcpu = vcpu;
     set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
 
-    if ( (ctxt != NULL) && ((rc = lock_pages(ctxt, sizeof(*ctxt))) != 0) )
-        return rc;
+    /*
+     * We may be asked to lock either a 32-bit or a 64-bit context. Lock the
+     * larger of the two if possible, otherwise fall back to native size.
+     */
+    if ( (ctxt != NULL) && (rc = lock_pages(ctxt, sz)) != 0 )
+    {
+        sz = sizeof(*ctxt);
+        if ( (rc = lock_pages(ctxt, sz)) != 0 )
+            return rc;
+    }
 
     rc = do_domctl(xc_handle, &domctl);
 
     if ( ctxt != NULL )
-        unlock_pages(ctxt, sizeof(*ctxt));
+        unlock_pages(ctxt, sz);
 
     return rc;
 }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.2-testing] x86 libxc: Fix mlock sizes in libxc around vcpu context hypercalls, Xen patchbot-3.2-testing <=