[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 1 of 5] xenpaging: extend xc_mem_paging_enable() to handle interface version


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Tue, 06 Dec 2011 18:07:02 +0100
  • Delivery-date: Tue, 06 Dec 2011 17:09:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1323189139 -3600
# Node ID b733498b351a8650b2d952aa56725f63d49c1889
# Parent  a4d7c27ec1f190ecbb9a909609f6ef0eca250c00
xenpaging: extend xc_mem_paging_enable() to handle interface version

Since upcoming patches will change the way how paging internally works,
add a new interface to xc_mem_paging_enable() to make sure the pager is
not out-of-date. This is similar to XEN_DOMCTL_INTERFACE_VERSION in
do_domctl() where the tools have to match the running hypervisor.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

diff -r a4d7c27ec1f1 -r b733498b351a tools/libxc/xc_mem_paging.c
--- a/tools/libxc/xc_mem_paging.c
+++ b/tools/libxc/xc_mem_paging.c
@@ -25,12 +25,13 @@
 
 
 int xc_mem_paging_enable(xc_interface *xch, domid_t domain_id,
+                        unsigned long interface_age,
                         void *shared_page, void *ring_page)
 {
     return xc_mem_event_control(xch, domain_id,
                                 XEN_DOMCTL_MEM_EVENT_OP_PAGING_ENABLE,
                                 XEN_DOMCTL_MEM_EVENT_OP_PAGING,
-                                shared_page, ring_page, INVALID_MFN);
+                                shared_page, ring_page, interface_age);
 }
 
 int xc_mem_paging_disable(xc_interface *xch, domid_t domain_id)
diff -r a4d7c27ec1f1 -r b733498b351a tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -1859,6 +1859,7 @@ int xc_mem_event_control(xc_interface *x
                           void *ring_page, unsigned long gfn);
 
 int xc_mem_paging_enable(xc_interface *xch, domid_t domain_id,
+                        unsigned long interface_age,
                         void *shared_page, void *ring_page);
 int xc_mem_paging_disable(xc_interface *xch, domid_t domain_id);
 int xc_mem_paging_nominate(xc_interface *xch, domid_t domain_id,
diff -r a4d7c27ec1f1 -r b733498b351a tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -366,6 +366,7 @@ static xenpaging_t *xenpaging_init(int a
     
     /* Initialise Xen */
     rc = xc_mem_paging_enable(xch, paging->mem_event.domain_id,
+                             MEM_EVENT_PAGING_AGE,
                              paging->mem_event.shared_page,
                              paging->mem_event.ring_page);
     if ( rc != 0 )
@@ -380,6 +381,9 @@ static xenpaging_t *xenpaging_init(int a
             case EXDEV:
                 ERROR("xenpaging not supported in a PoD guest");
                 break;
+            case ENOEXEC:
+                ERROR("xenpaging version mismatch");
+                break;
             default:
                 PERROR("Error initialising shared page");
                 break;
diff -r a4d7c27ec1f1 -r b733498b351a xen/arch/x86/mm/mem_event.c
--- a/xen/arch/x86/mm/mem_event.c
+++ b/xen/arch/x86/mm/mem_event.c
@@ -287,6 +287,15 @@ int mem_event_domctl(struct domain *d, x
             if ( p2m->pod.entry_count )
                 break;
 
+            rc = -ENOEXEC;
+            /* Reject old pager */
+            if ( mec->gfn != MEM_EVENT_PAGING_AGE )
+           {
+                gdprintk(XENLOG_INFO, "Expected paging age %lx, got %lx\n",
+                         MEM_EVENT_PAGING_AGE, mec->gfn);
+                break;
+           }
+
             rc = mem_event_enable(d, mec, med);
         }
         break;
diff -r a4d7c27ec1f1 -r b733498b351a xen/include/public/mem_event.h
--- a/xen/include/public/mem_event.h
+++ b/xen/include/public/mem_event.h
@@ -49,6 +49,8 @@
 #define MEM_EVENT_REASON_INT3        5    /* int3 was hit: gla/gfn are RIP */
 #define MEM_EVENT_REASON_SINGLESTEP  6    /* single step was invoked: gla/gfn 
are RIP */
 
+#define MEM_EVENT_PAGING_AGE         1UL  /* Number distinguish the mem_paging 
<-> pager interface */
+
 typedef struct mem_event_shared_page {
     uint32_t port;
 } mem_event_shared_page_t;

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.