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

[PATCH 02/16] x86/shadow: fold/rename sh_unhook_*_mappings()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 22 Mar 2023 10:30:42 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=X+ld8GTQwB22a2rHLDTz7JUGbxwAP+yxpl3HqWacg5w=; b=mT7beBVdH237/nDwF/zBggZ+YYF/bmMJnFn/+0Ba/aIX5vGA5LKVlw7iShk1pjmMUUMTI0pm77v8fmS9zMck00zK1hkYNBuUnZDQlG+wkqZDpEVau81Ejp3JqHocbpdcG2O0P2Zp56WbUlopfcpw8+I4pKnTLR83MoUhSpLNwDRBKfYLHj33mst9MDmT7OBdGV8Eip/RZrupZcFJPDQaQW8c5H3ylI3Z+7MCm8qbP2MdwiHsKEvpWOJAaUWqBOEgoNm0ZFPUd4qzvs0pLnrBDLqRQRTgghbgnT/H9C4UrdKVANNhdv4tSQLeVVekm4s125kXwatl+e2giS4POBa+xg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lMEVpWZ5a17Me0naj91/hRGfJRC1CH74xRtZF4R8cwF4olCmeiOwKEL8Pa+BxRO7MpV/EZG4XuGkF7bU4FSw5shaNPSx9oZKinV29cdtIzpvPZmgijNVexBflTn00ndqcUo6UwxYW2OmsWwl5eEjRtG3xTztWBbsc1dHW5qN44hZ+y6Pg/dNLroAB/OvmhK2upGzKpdaJ/sMN6VO2nHfBalcL97VEYfZ0Uep6dxvYGYJ5Mr9BrxW+FAsKgNfrFsNXwGejnhPWtXgv63QoL6p4X4lRTZkTJNdHK2d5EJSFyu0E8VSWGul29XehgYd5i8PeK5XBt1e7fJwI+92/l2KzA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>
  • Delivery-date: Wed, 22 Mar 2023 09:30:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The "32b" and "pae" functions are identical at the source level (they
differ in what they get compiled to, due to differences in
SHADOW_FOREACH_L2E()), leaving aside a comment the PAE variant has and
the non-PAE one doesn't. Replace these infixes by the more usual l<N>
ones (and then also for the "64b" one for consistency; that'll also
allow for re-use once we support 5-level paging, if need be). The two
different instances are still distinguishable by their "level" suffix.

While fiddling with the names, convert the last parameter to boolean
as well.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
As long as the backing functions don't need to invoke each other, the
infixes could arguably also be dropped altogether. Every mode has
exactly one such function. (Thinking of it, unhooking at L4 is kind of
pointless for PV32, as the guest controlled root is L3. The only time
where we might want to unhook from L4 is when we clean up after the
guest. But even that's not strictly necessary as that would also be
taken care of by sh_detach_old_tables().)

--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -898,14 +898,14 @@ void shadow_unhook_mappings(struct domai
     {
 #ifdef CONFIG_HVM
     case SH_type_l2_32_shadow:
-        SHADOW_INTERNAL_NAME(sh_unhook_32b_mappings, 2)(d, smfn, user_only);
+        SHADOW_INTERNAL_NAME(sh_unhook_l2_mappings, 2)(d, smfn, user_only);
         break;
     case SH_type_l2_pae_shadow:
-        SHADOW_INTERNAL_NAME(sh_unhook_pae_mappings, 3)(d, smfn, user_only);
+        SHADOW_INTERNAL_NAME(sh_unhook_l2_mappings, 3)(d, smfn, user_only);
         break;
 #endif
     case SH_type_l4_64_shadow:
-        SHADOW_INTERNAL_NAME(sh_unhook_64b_mappings, 4)(d, smfn, user_only);
+        SHADOW_INTERNAL_NAME(sh_unhook_l4_mappings, 4)(d, smfn, user_only);
         break;
     default:
         printk(XENLOG_ERR "Bad top-level shadow type %08x\n", sp->u.sh.type);
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -1416,21 +1416,9 @@ void sh_destroy_l1_shadow(struct domain
  * This implementation is pretty crude and slow, but we hope that it won't
  * be called very often. */
 
-#if GUEST_PAGING_LEVELS == 2
+#if GUEST_PAGING_LEVELS < 4
 
-void sh_unhook_32b_mappings(struct domain *d, mfn_t sl2mfn, int user_only)
-{
-    shadow_l2e_t *sl2e;
-    SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, d, {
-        if ( !user_only || (sl2e->l2 & _PAGE_USER) )
-            shadow_set_l2e(d, sl2e, shadow_l2e_empty(), sl2mfn);
-    });
-}
-
-#elif GUEST_PAGING_LEVELS == 3
-
-void sh_unhook_pae_mappings(struct domain *d, mfn_t sl2mfn, int user_only)
-/* Walk a PAE l2 shadow, unhooking entries from all the subshadows */
+void sh_unhook_l2_mappings(struct domain *d, mfn_t sl2mfn, bool user_only)
 {
     shadow_l2e_t *sl2e;
     SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, d, {
@@ -1441,7 +1429,7 @@ void sh_unhook_pae_mappings(struct domai
 
 #elif GUEST_PAGING_LEVELS == 4
 
-void sh_unhook_64b_mappings(struct domain *d, mfn_t sl4mfn, int user_only)
+void sh_unhook_l4_mappings(struct domain *d, mfn_t sl4mfn, bool user_only)
 {
     shadow_l4e_t *sl4e;
     SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, 0, d, {
--- a/xen/arch/x86/mm/shadow/multi.h
+++ b/xen/arch/x86/mm/shadow/multi.h
@@ -50,14 +50,11 @@ SHADOW_INTERNAL_NAME(sh_destroy_l4_shado
     struct domain *d, mfn_t smfn);
 
 extern void
-SHADOW_INTERNAL_NAME(sh_unhook_32b_mappings, GUEST_LEVELS)
-    (struct domain *d, mfn_t sl2mfn, int user_only);
+SHADOW_INTERNAL_NAME(sh_unhook_l2_mappings, GUEST_LEVELS)
+    (struct domain *d, mfn_t sl2mfn, bool user_only);
 extern void
-SHADOW_INTERNAL_NAME(sh_unhook_pae_mappings, GUEST_LEVELS)
-    (struct domain *d, mfn_t sl3mfn, int user_only);
-extern void
-SHADOW_INTERNAL_NAME(sh_unhook_64b_mappings, GUEST_LEVELS)
-    (struct domain *d, mfn_t sl4mfn, int user_only);
+SHADOW_INTERNAL_NAME(sh_unhook_l4_mappings, GUEST_LEVELS)
+    (struct domain *d, mfn_t sl4mfn, bool user_only);
 
 int cf_check
 SHADOW_INTERNAL_NAME(sh_rm_write_access_from_l1, GUEST_LEVELS)
--- a/xen/arch/x86/mm/shadow/types.h
+++ b/xen/arch/x86/mm/shadow/types.h
@@ -232,9 +232,8 @@ static inline shadow_l4e_t shadow_l4e_fr
 #define sh_destroy_l3_shadow       INTERNAL_NAME(sh_destroy_l3_shadow)
 #define sh_destroy_l2_shadow       INTERNAL_NAME(sh_destroy_l2_shadow)
 #define sh_destroy_l1_shadow       INTERNAL_NAME(sh_destroy_l1_shadow)
-#define sh_unhook_32b_mappings     INTERNAL_NAME(sh_unhook_32b_mappings)
-#define sh_unhook_pae_mappings     INTERNAL_NAME(sh_unhook_pae_mappings)
-#define sh_unhook_64b_mappings     INTERNAL_NAME(sh_unhook_64b_mappings)
+#define sh_unhook_l2_mappings      INTERNAL_NAME(sh_unhook_l2_mappings)
+#define sh_unhook_l4_mappings      INTERNAL_NAME(sh_unhook_l4_mappings)
 #define sh_paging_mode             INTERNAL_NAME(sh_paging_mode)
 #define sh_audit_l1_table          INTERNAL_NAME(sh_audit_l1_table)
 #define sh_audit_fl1_table         INTERNAL_NAME(sh_audit_fl1_table)




 


Rackspace

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