[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V5 03/12] xen/mem_paging: Convert mem_event_op to mem_paging_op
The only use-case of the mem_event_op structure had been in mem_paging, thus renaming the structure mem_paging_op and relocating its associated functions clarifies its actual usage. Signed-off-by: Tamas K Lengyel <tamas.lengyel@xxxxxxxxxxxx> Acked-by: Tim Deegan <tim@xxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> --- v5: Style fixes v4: Style fixes v3: Style fixes --- tools/libxc/xc_mem_event.c | 16 ---------------- tools/libxc/xc_mem_paging.c | 26 ++++++++++++++++++-------- tools/libxc/xc_private.h | 3 --- xen/arch/x86/mm/mem_paging.c | 32 +++++++++++++------------------- xen/arch/x86/x86_64/compat/mm.c | 10 ++++++---- xen/arch/x86/x86_64/mm.c | 8 ++++---- xen/common/mem_event.c | 4 ++-- xen/include/asm-x86/mem_paging.h | 2 +- xen/include/public/memory.h | 9 ++++----- 9 files changed, 48 insertions(+), 62 deletions(-) diff --git a/tools/libxc/xc_mem_event.c b/tools/libxc/xc_mem_event.c index ee25cdd..487fcee 100644 --- a/tools/libxc/xc_mem_event.c +++ b/tools/libxc/xc_mem_event.c @@ -40,22 +40,6 @@ int xc_mem_event_control(xc_interface *xch, domid_t domain_id, unsigned int op, return rc; } -int xc_mem_event_memop(xc_interface *xch, domid_t domain_id, - unsigned int op, unsigned int mode, - uint32_t gfn, void *buffer) -{ - xen_mem_event_op_t meo; - - memset(&meo, 0, sizeof(meo)); - - meo.op = op; - meo.domain = domain_id; - meo.gfn = gfn; - meo.buffer = (unsigned long) buffer; - - return do_memory_op(xch, mode, &meo, sizeof(meo)); -} - void *xc_mem_event_enable(xc_interface *xch, domid_t domain_id, int param, uint32_t *port, int enable_introspection) { diff --git a/tools/libxc/xc_mem_paging.c b/tools/libxc/xc_mem_paging.c index 5194423..049aff4 100644 --- a/tools/libxc/xc_mem_paging.c +++ b/tools/libxc/xc_mem_paging.c @@ -23,6 +23,20 @@ #include "xc_private.h" +static int xc_mem_paging_memop(xc_interface *xch, domid_t domain_id, + unsigned int op, uint32_t gfn, void *buffer) +{ + xen_mem_paging_op_t mpo; + + memset(&mpo, 0, sizeof(mpo)); + + mpo.op = op; + mpo.domain = domain_id; + mpo.gfn = gfn; + mpo.buffer = (unsigned long) buffer; + + return do_memory_op(xch, XENMEM_paging_op, &mpo, sizeof(mpo)); +} int xc_mem_paging_enable(xc_interface *xch, domid_t domain_id, uint32_t *port) @@ -49,25 +63,22 @@ int xc_mem_paging_disable(xc_interface *xch, domid_t domain_id) int xc_mem_paging_nominate(xc_interface *xch, domid_t domain_id, unsigned long gfn) { - return xc_mem_event_memop(xch, domain_id, + return xc_mem_paging_memop(xch, domain_id, XENMEM_paging_op_nominate, - XENMEM_paging_op, gfn, NULL); } int xc_mem_paging_evict(xc_interface *xch, domid_t domain_id, unsigned long gfn) { - return xc_mem_event_memop(xch, domain_id, + return xc_mem_paging_memop(xch, domain_id, XENMEM_paging_op_evict, - XENMEM_paging_op, gfn, NULL); } int xc_mem_paging_prep(xc_interface *xch, domid_t domain_id, unsigned long gfn) { - return xc_mem_event_memop(xch, domain_id, + return xc_mem_paging_memop(xch, domain_id, XENMEM_paging_op_prep, - XENMEM_paging_op, gfn, NULL); } @@ -87,9 +98,8 @@ int xc_mem_paging_load(xc_interface *xch, domid_t domain_id, if ( mlock(buffer, XC_PAGE_SIZE) ) return -1; - rc = xc_mem_event_memop(xch, domain_id, + rc = xc_mem_paging_memop(xch, domain_id, XENMEM_paging_op_prep, - XENMEM_paging_op, gfn, buffer); old_errno = errno; diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index bc021b8..f1f601c 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -425,9 +425,6 @@ int xc_ffs64(uint64_t x); */ int xc_mem_event_control(xc_interface *xch, domid_t domain_id, unsigned int op, unsigned int mode, uint32_t *port); -int xc_mem_event_memop(xc_interface *xch, domid_t domain_id, - unsigned int op, unsigned int mode, - uint32_t gfn, void *buffer); /* * Enables mem_event and returns the mapped ring page indicated by param. * param can be HVM_PARAM_PAGING/ACCESS/SHARING_RING_PFN diff --git a/xen/arch/x86/mm/mem_paging.c b/xen/arch/x86/mm/mem_paging.c index 65f6a3d..87a7b72 100644 --- a/xen/arch/x86/mm/mem_paging.c +++ b/xen/arch/x86/mm/mem_paging.c @@ -25,38 +25,32 @@ #include <xen/mem_event.h> -int mem_paging_memop(struct domain *d, xen_mem_event_op_t *mec) +int mem_paging_memop(struct domain *d, xen_mem_paging_op_t *mpo) { + int rc = -ENODEV; if ( unlikely(!d->mem_event->paging.ring_page) ) - return -ENODEV; + return rc; - switch( mec->op ) + switch( mpo->op ) { case XENMEM_paging_op_nominate: - { - unsigned long gfn = mec->gfn; - return p2m_mem_paging_nominate(d, gfn); - } - break; + rc = p2m_mem_paging_nominate(d, mpo->gfn); + break; case XENMEM_paging_op_evict: - { - unsigned long gfn = mec->gfn; - return p2m_mem_paging_evict(d, gfn); - } - break; + rc = p2m_mem_paging_evict(d, mpo->gfn); + break; case XENMEM_paging_op_prep: - { - unsigned long gfn = mec->gfn; - return p2m_mem_paging_prep(d, gfn, mec->buffer); - } - break; + rc = p2m_mem_paging_prep(d, mpo->gfn, mpo->buffer); + break; default: - return -ENOSYS; + rc = -ENOSYS; break; } + + return rc; } diff --git a/xen/arch/x86/x86_64/compat/mm.c b/xen/arch/x86/x86_64/compat/mm.c index f90f611..96cec31 100644 --- a/xen/arch/x86/x86_64/compat/mm.c +++ b/xen/arch/x86/x86_64/compat/mm.c @@ -188,11 +188,12 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case XENMEM_paging_op: { - xen_mem_event_op_t meo; - if ( copy_from_guest(&meo, arg, 1) ) + xen_mem_paging_op_t mpo; + + if ( copy_from_guest(&mpo, arg, 1) ) return -EFAULT; - rc = do_mem_event_op(cmd, meo.domain, &meo); - if ( !rc && __copy_to_guest(arg, &meo, 1) ) + rc = do_mem_event_op(cmd, mpo.domain, &mpo); + if ( !rc && __copy_to_guest(arg, &mpo, 1) ) return -EFAULT; break; } @@ -200,6 +201,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case XENMEM_sharing_op: { xen_mem_sharing_op_t mso; + if ( copy_from_guest(&mso, arg, 1) ) return -EFAULT; if ( mso.op == XENMEM_sharing_op_audit ) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index d631aee..2fa1f67 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -985,11 +985,11 @@ long subarch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case XENMEM_paging_op: { - xen_mem_event_op_t meo; - if ( copy_from_guest(&meo, arg, 1) ) + xen_mem_paging_op_t mpo; + if ( copy_from_guest(&mpo, arg, 1) ) return -EFAULT; - rc = do_mem_event_op(cmd, meo.domain, &meo); - if ( !rc && __copy_to_guest(arg, &meo, 1) ) + rc = do_mem_event_op(cmd, mpo.domain, &mpo); + if ( !rc && __copy_to_guest(arg, &mpo, 1) ) return -EFAULT; break; } diff --git a/xen/common/mem_event.c b/xen/common/mem_event.c index b96d9fb..ae60c10 100644 --- a/xen/common/mem_event.c +++ b/xen/common/mem_event.c @@ -475,12 +475,12 @@ int do_mem_event_op(int op, uint32_t domain, void *arg) { #ifdef HAS_MEM_PAGING case XENMEM_paging_op: - ret = mem_paging_memop(d, (xen_mem_event_op_t *) arg); + ret = mem_paging_memop(d, arg); break; #endif #ifdef HAS_MEM_SHARING case XENMEM_sharing_op: - ret = mem_sharing_memop(d, (xen_mem_sharing_op_t *) arg); + ret = mem_sharing_memop(d, arg); break; #endif default: diff --git a/xen/include/asm-x86/mem_paging.h b/xen/include/asm-x86/mem_paging.h index 6b7a1fe..92ed2fa 100644 --- a/xen/include/asm-x86/mem_paging.h +++ b/xen/include/asm-x86/mem_paging.h @@ -21,7 +21,7 @@ */ -int mem_paging_memop(struct domain *d, xen_mem_event_op_t *meo); +int mem_paging_memop(struct domain *d, xen_mem_paging_op_t *meo); /* diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 2ef1728..9c41f5d 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -372,10 +372,9 @@ typedef struct xen_pod_target xen_pod_target_t; #define XENMEM_paging_op_evict 1 #define XENMEM_paging_op_prep 2 -struct xen_mem_event_op { - uint8_t op; /* XENMEM_*_op_* */ +struct xen_mem_paging_op { + uint8_t op; /* XENMEM_paging_op_* */ domid_t domain; - /* PAGING_PREP IN: buffer to immediately fill page in */ uint64_aligned_t buffer; @@ -383,8 +382,8 @@ struct xen_mem_event_op { uint32_t gfn; /* IN: gfn of page being operated on */ uint32_t _pad; }; -typedef struct xen_mem_event_op xen_mem_event_op_t; -DEFINE_XEN_GUEST_HANDLE(xen_mem_event_op_t); +typedef struct xen_mem_paging_op xen_mem_paging_op_t; +DEFINE_XEN_GUEST_HANDLE(xen_mem_paging_op_t); #define XENMEM_access_op 21 #define XENMEM_access_op_resume 0 -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |