# HG changeset patch # 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 Index: xen-4.1.2-testing/tools/libxc/xc_mem_paging.c =================================================================== --- xen-4.1.2-testing.orig/tools/libxc/xc_mem_paging.c +++ xen-4.1.2-testing/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) Index: xen-4.1.2-testing/tools/libxc/xenctrl.h =================================================================== --- xen-4.1.2-testing.orig/tools/libxc/xenctrl.h +++ xen-4.1.2-testing/tools/libxc/xenctrl.h @@ -1736,6 +1736,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, Index: xen-4.1.2-testing/tools/xenpaging/xenpaging.c =================================================================== --- xen-4.1.2-testing.orig/tools/xenpaging/xenpaging.c +++ xen-4.1.2-testing/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 ) Index: xen-4.1.2-testing/xen/arch/x86/mm/mem_event.c =================================================================== --- xen-4.1.2-testing.orig/xen/arch/x86/mm/mem_event.c +++ xen-4.1.2-testing/xen/arch/x86/mm/mem_event.c @@ -274,6 +274,15 @@ int mem_event_domctl(struct domain *d, x if ( p2m->pod.entry_count ) break; + rc = -ENOEXEC; + /* Disallow paging in a PoD guest */ + 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; Index: xen-4.1.2-testing/xen/include/public/mem_event.h =================================================================== --- xen-4.1.2-testing.orig/xen/include/public/mem_event.h +++ xen-4.1.2-testing/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;