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

[PATCH] x86/mm: PGC_page_table is used by shadow code only


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 29 Nov 2022 15:55:45 +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=E9e/K2ZxeIJXak06Lk356njAefBtPZNeUDKX9joG6ao=; b=fTdJ5dYRJeks4W+SiIXlAcQJHT0D72jyktfmjE+TJijZWsjsPiE9ny/tZo/vcbxBN07pXafu5rhiABDbimSp7+VBtMjg9qauF43iuaoUOClCQtmgnMCvQYM/FmvtxC/uDpRARAbEwYpx5xIhfYc0BqIayNrLbT55Qb+73S3AiF/r4RJ8dL5YDPCZt7gfujv2/R1vsUKhVCJZ4lSMX67qgwLwPfGtJVipnaFMhvv2yWb9QcTAkSjMnejbWThzLmdWGunuIadPzTqhNItpWITXD0QtZwgRLpH/af0xBCDkKTkfvWMow2rwtM6Ns6fYvOiUXyhjSMWoWUfhdXEyxJXrtQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KqTH/2VgeLFnirpIYIBQQG2ejIvxnwcmW0jTf1Jc1dqBMVmbXJPsznBxmHGhYlx5Q5UZnhZ59sdeN763+Hrn57Sy4ZbzB2+W8PWBIsCMRPgJzUES7XuzG1BOwCI3eJONMaP+yhX4X1O6STYqoY9HYqS95f9BYlND+2uGRCNeV6GAiXPEuwPu/UJru6BgnSgB6ljI/1GECYHNmy1T/BVcYTNQYwMfHGfeXfXX1E0mhuN93IpLEtEMk8aCS6BRSjYb+3NUwKDZT2zzsavX105lW4aiXydmnrTXTXmED1CTiXUlm+bacidgvzXkwPVbdrBmIP5tNiihNKt3wTNEXl29jQ==
  • 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>
  • Delivery-date: Tue, 29 Nov 2022 14:55:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

By defining the constant to zero when !SHADOW_PAGING we give compilers
the chance to eliminate a little more dead code elsewhere in the tree.
Plus, as a minor benefit, the general reference count can be one bit
wider. (To simplify things, have PGC_page_table change places with
PGC_extra.)

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
tboot.c's update_pagetable_mac() is suspicious: It effectively is a
no-op even prior to this change when !SHADOW_PAGING, which can't be
quite right. If (guest) page tables are relevant to include in the
verification, shouldn't this look for PGT_l<N>_page_table as well? How
to deal with HAP guests there is entirely unclear.

--- a/xen/arch/x86/include/asm/mm.h
+++ b/xen/arch/x86/include/asm/mm.h
@@ -70,9 +70,9 @@
  /* Page is Xen heap? */
 #define _PGC_xen_heap     PG_shift(2)
 #define PGC_xen_heap      PG_mask(1, 2)
- /* Set when is using a page as a page table */
-#define _PGC_page_table   PG_shift(3)
-#define PGC_page_table    PG_mask(1, 3)
+ /* Page is not reference counted */
+#define _PGC_extra        PG_shift(3)
+#define PGC_extra         PG_mask(1, 3)
  /* Page is broken? */
 #define _PGC_broken       PG_shift(4)
 #define PGC_broken        PG_mask(1, 4)
@@ -83,12 +83,20 @@
 #define PGC_state_offlined  PG_mask(2, 6)
 #define PGC_state_free      PG_mask(3, 6)
 #define page_state_is(pg, st) (((pg)->count_info&PGC_state) == PGC_state_##st)
-/* Page is not reference counted */
-#define _PGC_extra        PG_shift(7)
-#define PGC_extra         PG_mask(1, 7)
+#ifdef CONFIG_SHADOW_PAGING
+ /* Set when is using a page as a page table */
+#define _PGC_page_table   PG_shift(7)
+#define PGC_page_table    PG_mask(1, 7)
+#else
+#define PGC_page_table    0
+#endif
 
 /* Count of references to this frame. */
+#if PGC_page_table
 #define PGC_count_width   PG_shift(7)
+#else
+#define PGC_count_width   PG_shift(6)
+#endif
 #define PGC_count_mask    ((1UL<<PGC_count_width)-1)
 
 /*



 


Rackspace

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