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 <rcojoc...@bitdefender.com>
---
 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   |  2 --
 7 files changed, 84 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 1a5f4ec..42eafa4 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 3634c39..eee088c 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 159c036..0fb6699 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 4c62725..433952a 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -89,20 +89,6 @@ typedef enum {
 } 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 4072e27..4fad638 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 fa46dd9..2a90491 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -647,30 +647,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 4df38d6..baa8ce1 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -390,8 +390,6 @@ 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
 
 typedef enum {
     XENMEM_access_n,
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to