x86/shadow: don't open-code SHF_* shorthands
authorJan Beulich <jbeulich@suse.com>
Mon, 12 Apr 2021 10:32:18 +0000 (12:32 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 12 Apr 2021 10:32:18 +0000 (12:32 +0200)
Use SHF_L1_ANY, SHF_32, SHF_PAE, as well as SHF_64, and introduce
SHF_FL1_ANY.

Note that in shadow_audit_tables() this has the effect of no longer
(I assume mistakenly, or else I don't see why the respective callback
table entry isn't NULL) excluding SHF_L2H_64.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/shadow/common.c
xen/arch/x86/mm/shadow/private.h

index c64de3b789117975803f4228850b71fd0f77fb64..bcc3d6c3aed34c927280c0dfc1d9080da73fa8a6 100644 (file)
@@ -1834,14 +1834,7 @@ int sh_remove_write_access(struct domain *d, mfn_t gmfn,
         NULL  /* unused  */
     };
 
-    static const unsigned int callback_mask =
-          SHF_L1_32
-        | SHF_FL1_32
-        | SHF_L1_PAE
-        | SHF_FL1_PAE
-        | SHF_L1_64
-        | SHF_FL1_64
-        ;
+    static const unsigned int callback_mask = SHF_L1_ANY | SHF_FL1_ANY;
     struct page_info *pg = mfn_to_page(gmfn);
 #if SHADOW_OPTIMIZATIONS & SHOPT_WRITABLE_HEURISTIC
     struct vcpu *curr = current;
@@ -2065,14 +2058,7 @@ int sh_remove_all_mappings(struct domain *d, mfn_t gmfn, gfn_t gfn)
         NULL  /* unused  */
     };
 
-    static const unsigned int callback_mask =
-          SHF_L1_32
-        | SHF_FL1_32
-        | SHF_L1_PAE
-        | SHF_FL1_PAE
-        | SHF_L1_64
-        | SHF_FL1_64
-        ;
+    static const unsigned int callback_mask = SHF_L1_ANY | SHF_FL1_ANY;
 
     perfc_incr(shadow_mappings);
     if ( sh_check_page_has_no_refs(page) )
@@ -3424,11 +3410,9 @@ void shadow_audit_tables(struct vcpu *v)
         /* Audit only the current mode's tables */
         switch ( v->arch.paging.mode->guest_levels )
         {
-        case 2: mask = (SHF_L1_32|SHF_FL1_32|SHF_L2_32); break;
-        case 3: mask = (SHF_L1_PAE|SHF_FL1_PAE|SHF_L2_PAE
-                        |SHF_L2H_PAE); break;
-        case 4: mask = (SHF_L1_64|SHF_FL1_64|SHF_L2_64
-                        |SHF_L3_64|SHF_L4_64); break;
+        case 2: mask = SHF_32; break;
+        case 3: mask = SHF_PAE; break;
+        case 4: mask = SHF_64; break;
         default: BUG();
         }
     }
index 911db46e739988ca69291fa89bb528b0267fea1e..e2c352f8785a39834176a4f7eb93ee95f6d4b260 100644 (file)
@@ -269,6 +269,7 @@ static inline void sh_terminate_list(struct page_list_head *tmp_list)
 #define SHF_64  (SHF_L1_64|SHF_FL1_64|SHF_L2_64|SHF_L2H_64|SHF_L3_64|SHF_L4_64)
 
 #define SHF_L1_ANY  (SHF_L1_32|SHF_L1_PAE|SHF_L1_64)
+#define SHF_FL1_ANY (SHF_FL1_32|SHF_FL1_PAE|SHF_FL1_64)
 
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
 /* Marks a guest L1 page table which is shadowed but not write-protected.