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

[Xen-devel] [PATCH for-4.5 v9 RESEND 06/19] xen: Relocate mem_event_op domctl and access_op memop into common.



Signed-off-by: Tamas K Lengyel <tklengyel@xxxxxxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v9: Rename abstracted function to p2m_setup_introspection.
v8: Move the new enable_msr_exit_interception test into the p2m layer.
v6: Grouping style fix of #includes in common/memory.c.
v5: Move memop compat into common as well.
    Position domctl in switch relative to the domctl #.
v4: Don't remove memop handling from x86_64/compat and style fixes.
---
 xen/arch/x86/domctl.c           |    8 --------
 xen/arch/x86/mm/p2m.c           |    9 +++++++++
 xen/arch/x86/x86_64/compat/mm.c |    4 ----
 xen/arch/x86/x86_64/mm.c        |    4 ----
 xen/common/compat/memory.c      |    5 +++++
 xen/common/domctl.c             |    7 +++++++
 xen/common/mem_event.c          |   10 ++++------
 xen/common/memory.c             |    9 +++++++--
 xen/include/asm-arm/p2m.h       |    6 ++++++
 xen/include/asm-x86/p2m.h       |    3 +++
 10 files changed, 41 insertions(+), 24 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 8731e7f..ec77555 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1131,14 +1131,6 @@ long arch_do_domctl(
     }
     break;
 
-    case XEN_DOMCTL_mem_event_op:
-    {
-        ret = mem_event_domctl(d, &domctl->u.mem_event_op,
-                              guest_handle_cast(u_domctl, void));
-        copyback = 1;
-    }
-    break;
-
     case XEN_DOMCTL_mem_sharing_op:
     {
         ret = mem_sharing_domctl(d, &domctl->u.mem_sharing_op);
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 4822517..efa49dd 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1435,6 +1435,15 @@ void p2m_mem_event_emulate_check(struct vcpu *v, const 
mem_event_response_t *rsp
     }
 }
 
+void p2m_setup_introspection(struct domain *d)
+{
+    if ( hvm_funcs.enable_msr_exit_interception )
+    {
+        d->arch.hvm_domain.introspection_enabled = 1;
+        hvm_funcs.enable_msr_exit_interception(d);
+    }
+}
+
 bool_t p2m_mem_access_check(paddr_t gpa, unsigned long gla,
                             struct npfec npfec,
                             mem_event_request_t **req_ptr)
diff --git a/xen/arch/x86/x86_64/compat/mm.c b/xen/arch/x86/x86_64/compat/mm.c
index c079702..54f25b7 100644
--- a/xen/arch/x86/x86_64/compat/mm.c
+++ b/xen/arch/x86/x86_64/compat/mm.c
@@ -198,10 +198,6 @@ int compat_arch_memory_op(unsigned long cmd, 
XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
-    case XENMEM_access_op:
-        rc = mem_access_memop(cmd, guest_handle_cast(arg, 
xen_mem_access_op_t));
-        break;
-
     case XENMEM_sharing_op:
     {
         xen_mem_sharing_op_t mso;
diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
index cce1406..8e5a1a1 100644
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -995,10 +995,6 @@ long subarch_memory_op(unsigned long cmd, 
XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
-    case XENMEM_access_op:
-        rc = mem_access_memop(cmd, guest_handle_cast(arg, 
xen_mem_access_op_t));
-        break;
-
     case XENMEM_sharing_op:
     {
         xen_mem_sharing_op_t mso;
diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c
index 25dc016..43d02bc 100644
--- a/xen/common/compat/memory.c
+++ b/xen/common/compat/memory.c
@@ -4,6 +4,7 @@
 #include <xen/guest_access.h>
 #include <xen/sched.h>
 #include <xen/event.h>
+#include <xen/mem_access.h>
 #include <asm/current.h>
 #include <compat/memory.h>
 
@@ -381,6 +382,10 @@ int compat_memory_op(unsigned int cmd, 
XEN_GUEST_HANDLE_PARAM(void) compat)
             break;
         }
 
+        case XENMEM_access_op:
+            rc = mem_access_memop(cmd, guest_handle_cast(compat, 
xen_mem_access_op_t));
+            break;
+
         case XENMEM_add_to_physmap_batch:
             start_extent = end_extent;
             break;
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 329e535..fd8dd44 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -24,6 +24,7 @@
 #include <xen/bitmap.h>
 #include <xen/paging.h>
 #include <xen/hypercall.h>
+#include <xen/mem_event.h>
 #include <asm/current.h>
 #include <asm/irq.h>
 #include <asm/page.h>
@@ -1111,6 +1112,12 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
u_domctl)
     }
     break;
 
+    case XEN_DOMCTL_mem_event_op:
+        ret = mem_event_domctl(d, &op->u.mem_event_op,
+                               guest_handle_cast(u_domctl, void));
+        copyback = 1;
+        break;
+
     case XEN_DOMCTL_disable_migrate:
     {
         d->disable_migrate = op->u.disable_migrate.disable;
diff --git a/xen/common/mem_event.c b/xen/common/mem_event.c
index 9f1a1b0..4338826 100644
--- a/xen/common/mem_event.c
+++ b/xen/common/mem_event.c
@@ -623,12 +623,10 @@ int mem_event_domctl(struct domain *d, 
xen_domctl_mem_event_op_t *mec,
                                     HVM_PARAM_ACCESS_RING_PFN,
                                     mem_access_notification);
 
-            if ( mec->op != XEN_DOMCTL_MEM_EVENT_OP_ACCESS_ENABLE &&
-                 rc == 0 && hvm_funcs.enable_msr_exit_interception )
-            {
-                d->arch.hvm_domain.introspection_enabled = 1;
-                hvm_funcs.enable_msr_exit_interception(d);
-            }
+            if ( mec->op == XEN_DOMCTL_MEM_EVENT_OP_ACCESS_ENABLE_INTROSPECTION
+                 && !rc )
+                p2m_setup_introspection(d);
+
         }
         break;
 
diff --git a/xen/common/memory.c b/xen/common/memory.c
index bad50cb..cc36e39 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -21,13 +21,14 @@
 #include <xen/errno.h>
 #include <xen/tmem.h>
 #include <xen/tmem_xen.h>
+#include <xen/numa.h>
+#include <xen/mem_access.h>
+#include <xen/trace.h>
 #include <asm/current.h>
 #include <asm/hardirq.h>
 #include <asm/p2m.h>
-#include <xen/numa.h>
 #include <public/memory.h>
 #include <xsm/xsm.h>
-#include <xen/trace.h>
 
 struct memop_args {
     /* INPUT */
@@ -939,6 +940,10 @@ long do_memory_op(unsigned long cmd, 
XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+    case XENMEM_access_op:
+        rc = mem_access_memop(cmd, guest_handle_cast(arg, 
xen_mem_access_op_t));
+        break;
+
     case XENMEM_claim_pages:
         if ( copy_from_guest(&reservation, arg, 1) )
             return -EFAULT;
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 4d5570a..10bf111 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -77,6 +77,12 @@ void p2m_mem_event_emulate_check(struct vcpu *v,
     /* Not supported on ARM. */
 };
 
+static inline
+void p2m_setup_introspection(struct domain *d)
+{
+    /* No special setup on ARM. */
+}
+
 #define p2m_is_foreign(_t)  ((_t) == p2m_map_foreign)
 #define p2m_is_ram(_t)      ((_t) == p2m_ram_rw || (_t) == p2m_ram_ro)
 
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 1de493e..a0e1704 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -589,6 +589,9 @@ int p2m_get_mem_access(struct domain *d, unsigned long pfn,
 void p2m_mem_event_emulate_check(struct vcpu *v,
                                  const mem_event_response_t *rsp);
 
+/* Enable arch specific introspection options (such as MSR interception). */
+void p2m_setup_introspection(struct domain *d);
+
 /* 
  * Internal functions, only called by other p2m code
  */
-- 
1.7.10.4


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


 


Rackspace

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