]> xenbits.xensource.com Git - xen.git/commitdiff
relocate p2m_access_t into common and swap the order
authorTamas K Lengyel <tklengyel@sec.in.tum.de>
Fri, 26 Sep 2014 14:24:02 +0000 (16:24 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 26 Sep 2014 14:24:02 +0000 (16:24 +0200)
We swap the order of the enum of types n ... rwx, as to have rwx at 0, which is
the default setting when mem_access is not in use. This has performance benefits for
non-memaccess paths, as now comparison is to 0 when checking if memaccess is in use,
which is often faster.

We fix one location in nested_hap where the order of the enum made a difference.

Signed-off-by: Tamas K Lengyel <tklengyel@sec.in.tum.de>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/hap/nested_hap.c
xen/include/asm-x86/p2m.h
xen/include/xen/p2m-common.h

index a4bb8358599572cebc46d2360ff593d73c368f0a..9c1ec11b5d89168058faa06b4e93e99db530748f 100644 (file)
@@ -264,7 +264,7 @@ nestedhvm_hap_nested_page_fault(struct vcpu *v, paddr_t *L2_gpa,
 
     switch ( p2ma_10 )
     {
-    case p2m_access_n ... p2m_access_rwx:
+    case p2m_access_rwx ... p2m_access_n:
         break;
     case p2m_access_rx2rw:
         p2ma_10 = p2m_access_rx;
index 453aeefb9d7f851e93b8457551d0ef7605799213..42c04b203a6bdd973002c1df6f9b3caca26ae2b2 100644 (file)
@@ -74,34 +74,6 @@ typedef enum {
     p2m_map_foreign  = 14,        /* ram pages from foreign domain */
 } p2m_type_t;
 
-/*
- * Additional access types, which are used to further restrict
- * the permissions given my the p2m_type_t memory type.  Violations
- * caused by p2m_access_t restrictions are sent to the mem_event
- * interface.
- *
- * The access permissions are soft state: when any ambigious change of page
- * type or use occurs, or when pages are flushed, swapped, or at any other
- * convenient type, the access permissions can get reset to the p2m_domain
- * default.
- */
-typedef enum {
-    p2m_access_n     = 0, /* No access permissions allowed */
-    p2m_access_r     = 1,
-    p2m_access_w     = 2, 
-    p2m_access_rw    = 3,
-    p2m_access_x     = 4, 
-    p2m_access_rx    = 5,
-    p2m_access_wx    = 6, 
-    p2m_access_rwx   = 7,
-    p2m_access_rx2rw = 8, /* Special: page goes from RX to RW on write */
-    p2m_access_n2rwx = 9, /* Special: page goes from N to RWX on access, *
-                           * generates an event but does not pause the
-                           * vcpu */
-
-    /* NOTE: Assumed to be only 4 bits right now */
-} p2m_access_t;
-
 /* Modifiers to the query */
 typedef unsigned int p2m_query_t;
 #define P2M_ALLOC    (1u<<0)   /* Populate PoD and paged-out entries */
index 9f1b7711a520384eacc635fb0483165e48deaac4..29f362807f4a7b57d230fedf993164573e0dead9 100644 (file)
@@ -1,6 +1,37 @@
 #ifndef _XEN_P2M_COMMON_H
 #define _XEN_P2M_COMMON_H
 
+#include <public/mem_event.h>
+
+/*
+ * Additional access types, which are used to further restrict
+ * the permissions given my the p2m_type_t memory type.  Violations
+ * caused by p2m_access_t restrictions are sent to the mem_event
+ * interface.
+ *
+ * The access permissions are soft state: when any ambiguous change of page
+ * type or use occurs, or when pages are flushed, swapped, or at any other
+ * convenient type, the access permissions can get reset to the p2m_domain
+ * default.
+ */
+typedef enum {
+    p2m_access_rwx   = 0, /* The default access type when not used. */
+    p2m_access_wx    = 1,
+    p2m_access_rx    = 2,
+    p2m_access_x     = 3,
+    p2m_access_rw    = 4,
+    p2m_access_w     = 5,
+    p2m_access_r     = 6,
+    p2m_access_n     = 7, /* No access allowed. */
+
+    p2m_access_rx2rw = 8, /* Special: page goes from RX to RW on write */
+    p2m_access_n2rwx = 9, /* Special: page goes from N to RWX on access, *
+                           * generates an event but does not pause the
+                           * vcpu */
+
+    /* NOTE: Assumed to be only 4 bits right now on x86. */
+} p2m_access_t;
+
 /* Map MMIO regions in the p2m: start_gfn and nr describe the range in
  *  * the guest physical address space to map, starting from the machine
  *   * frame number mfn. */