All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/boot: Avoid global attribute in early memory mappings
@ 2024-05-15  9:32 Ard Biesheuvel
  0 siblings, 0 replies; only message in thread
From: Ard Biesheuvel @ 2024-05-15  9:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: x86, Ard Biesheuvel

From: Ard Biesheuvel <ardb@kernel.org>

The decompressor uses the __PAGE_KERNEL_LARGE_EXEC template to create
page table entries, and this includes the 'G' global bit. Global
mappings are a performance optimization that requires more elaborate TLB
maintenance, which the decompressor does not implement, and so global
mappings are disabled entirely, by clearing CR4.PGE in the startup code.

Since global mappings are not used, it is better to avoid setting the
bit altogether, so clear it from the 'flag' variable used to populate
page table entries.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/x86/boot/compressed/ident_map_64.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c
index dfb9c2deb77c..e24fedf1e36b 100644
--- a/arch/x86/boot/compressed/ident_map_64.c
+++ b/arch/x86/boot/compressed/ident_map_64.c
@@ -121,6 +121,12 @@ void initialize_identity_maps(void *rmode)
 	mapping_info.page_flag = __PAGE_KERNEL_LARGE_EXEC | sme_me_mask;
 	mapping_info.kernpg_flag = _KERNPG_TABLE;
 
+	/*
+	 * Entries with the G bit require more elaborate TLB maintenance,
+	 * so avoid them for these early mappings.
+	 */
+	mapping_info.page_flag &= ~_PAGE_GLOBAL;
+
 	/*
 	 * It should be impossible for this not to already be true,
 	 * but since calling this a second time would rewind the other
-- 
2.45.0.rc1.225.g2a3ae87e7f-goog


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-15  9:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-15  9:32 [PATCH] x86/boot: Avoid global attribute in early memory mappings Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.