]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
restore p2m_access_t enum order to allow bitmask semantics
authorMalcolm Crossley <malcolm.crossley@citrix.com>
Tue, 15 Mar 2016 11:17:52 +0000 (12:17 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 15 Mar 2016 11:17:52 +0000 (12:17 +0100)
Nested hap code assumed implict bitmask semantics of the p2m_access_t
enum prior to C/S 4c63692d7c38c5ac414fe97f8ef37b66e05abe5c

The change to the enum ordering broke this assumption and caused functional
problems for the nested hap code. As it may be error prone to audit and find
all other p2m_access users assuming bitmask semantics, instead restore the
previous enum order and make it explict that bitmask semantics are to be
preserved for the read, write and execute access types.

Signed-off-by: Malcolm Crossley <malcolm.crossley@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm/hap/nested_hap.c
xen/include/xen/p2m-common.h

index 0dbae13ef7fa83c50c3cc19df0986bf5cac4510b..9cee5a05ee236e5420b4a85be4255303bba75bd3 100644 (file)
@@ -263,7 +263,7 @@ nestedhvm_hap_nested_page_fault(struct vcpu *v, paddr_t *L2_gpa,
 
     switch ( p2ma_10 )
     {
-    case p2m_access_rwx ... p2m_access_n:
+    case p2m_access_n ... p2m_access_rwx:
         break;
     case p2m_access_rx2rw:
         p2ma_10 = p2m_access_rx;
index 8b704595ce1ee25b8683edc9d36ac964dc6ec243..6374a5b0867f490638635d6a7a52e860d176eb28 100644 (file)
  * 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. */
+    /* Code uses bottom three bits with bitmask semantics */
+    p2m_access_n     = 0, /* No access allowed. */
+    p2m_access_r     = 1 << 0,
+    p2m_access_w     = 1 << 1,
+    p2m_access_x     = 1 << 2,
+    p2m_access_rw    = p2m_access_r | p2m_access_w,
+    p2m_access_rx    = p2m_access_r | p2m_access_x,
+    p2m_access_wx    = p2m_access_w | p2m_access_x,
+    p2m_access_rwx   = p2m_access_r | p2m_access_w | p2m_access_x,
 
     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, *