From 51c2291e14f00bfd95d8a9dc0d44092254510a60 Mon Sep 17 00:00:00 2001 From: Razvan Cojocaru Date: Mon, 15 Feb 2016 14:13:31 +0100 Subject: [PATCH] vm_event: remove xc_mem_access_enable_emulate() and friends xc_mem_access_enable_emulate() and xc_mem_access_disable_emulate() are currently no-ops, that is all they do is set a flag that nobody else checks. The user can already set the EMULATE flags in the vm_event response if emulation is desired, and having an extra check above that is not inherently safer, but it does complicate (currenly unnecessarily) the API. This patch removes these functions and the corresponding hypervisor code. Signed-off-by: Razvan Cojocaru Acked-by: Tamas K Lengyel Acked-by: Jan Beulich Acked-by: Stefano Stabellini Acked-by: Wei Liu --- tools/libxc/include/xenctrl.h | 11 ----------- tools/libxc/xc_mem_access.c | 24 ------------------------ xen/common/mem_access.c | 8 -------- xen/include/asm-arm/p2m.h | 14 -------------- xen/include/asm-x86/domain.h | 1 - xen/include/asm-x86/p2m.h | 24 ------------------------ xen/include/public/memory.h | 9 +++++++-- 7 files changed, 7 insertions(+), 84 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 1a5f4ec940..42eafa4a44 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2101,17 +2101,6 @@ int xc_set_mem_access(xc_interface *xch, domid_t domain_id, int xc_get_mem_access(xc_interface *xch, domid_t domain_id, uint64_t pfn, xenmem_access_t *access); -/* - * Instructions causing a mem_access violation can be emulated by Xen - * to progress the execution without having to relax the mem_access - * permissions. - * This feature has to be first enabled, then in the vm_event - * response to a mem_access event it can be indicated if the instruction - * should be emulated. - */ -int xc_mem_access_enable_emulate(xc_interface *xch, domid_t domain_id); -int xc_mem_access_disable_emulate(xc_interface *xch, domid_t domain_id); - /*** * Monitor control operations. * diff --git a/tools/libxc/xc_mem_access.c b/tools/libxc/xc_mem_access.c index 3634c398b7..eee088cc67 100644 --- a/tools/libxc/xc_mem_access.c +++ b/tools/libxc/xc_mem_access.c @@ -62,30 +62,6 @@ int xc_get_mem_access(xc_interface *xch, return rc; } -int xc_mem_access_enable_emulate(xc_interface *xch, - domid_t domain_id) -{ - xen_mem_access_op_t mao = - { - .op = XENMEM_access_op_enable_emulate, - .domid = domain_id, - }; - - return do_memory_op(xch, XENMEM_access_op, &mao, sizeof(mao)); -} - -int xc_mem_access_disable_emulate(xc_interface *xch, - domid_t domain_id) -{ - xen_mem_access_op_t mao = - { - .op = XENMEM_access_op_disable_emulate, - .domid = domain_id, - }; - - return do_memory_op(xch, XENMEM_access_op, &mao, sizeof(mao)); -} - /* * Local variables: * mode: C diff --git a/xen/common/mem_access.c b/xen/common/mem_access.c index 92ebeada4b..b4033f017e 100644 --- a/xen/common/mem_access.c +++ b/xen/common/mem_access.c @@ -98,14 +98,6 @@ int mem_access_memop(unsigned long cmd, break; } - case XENMEM_access_op_enable_emulate: - rc = p2m_mem_access_enable_emulate(d); - break; - - case XENMEM_access_op_disable_emulate: - rc = p2m_mem_access_disable_emulate(d); - break; - default: rc = -ENOSYS; break; diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 4c62725f3d..433952ab04 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -88,20 +88,6 @@ typedef enum { p2m_max_real_type, /* Types after this won't be store in the p2m */ } p2m_type_t; -static inline -int p2m_mem_access_enable_emulate(struct domain *d) -{ - /* Not supported on ARM */ - return -ENOSYS; -} - -static inline -int p2m_mem_access_disable_emulate(struct domain *d) -{ - /* Not supported on ARM */ - return -ENOSYS; -} - static inline void p2m_mem_access_emulate_check(struct vcpu *v, const vm_event_response_t *rsp) diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 4072e273ae..4fad6380c2 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -390,7 +390,6 @@ struct arch_domain } monitor; /* Mem_access emulation control */ - bool_t mem_access_emulate_enabled; bool_t mem_access_emulate_each_rep; /* Emulated devices enabled bitmap. */ diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index ca0480e699..5392eb05a2 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -648,30 +648,6 @@ bool_t p2m_mem_access_check(paddr_t gpa, unsigned long gla, struct npfec npfec, vm_event_request_t **req_ptr); -/* - * Emulating a memory access requires custom handling. These non-atomic - * functions should be called under domctl lock. - */ -static inline -int p2m_mem_access_enable_emulate(struct domain *d) -{ - if ( d->arch.mem_access_emulate_enabled ) - return -EEXIST; - - d->arch.mem_access_emulate_enabled = 1; - return 0; -} - -static inline -int p2m_mem_access_disable_emulate(struct domain *d) -{ - if ( !d->arch.mem_access_emulate_enabled ) - return -EEXIST; - - d->arch.mem_access_emulate_enabled = 0; - return 0; -} - /* Check for emulation and mark vcpu for skipping one instruction * upon rescheduling if required. */ void p2m_mem_access_emulate_check(struct vcpu *v, diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 4df38d6b24..f69e92f906 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -390,8 +390,13 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_paging_op_t); #define XENMEM_access_op 21 #define XENMEM_access_op_set_access 0 #define XENMEM_access_op_get_access 1 -#define XENMEM_access_op_enable_emulate 2 -#define XENMEM_access_op_disable_emulate 3 +/* + * XENMEM_access_op_enable_emulate and XENMEM_access_op_disable_emulate are + * currently unused, but since they have been in use please do not reuse them. + * + * #define XENMEM_access_op_enable_emulate 2 + * #define XENMEM_access_op_disable_emulate 3 + */ typedef enum { XENMEM_access_n, -- 2.39.5