All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb+git@google.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCH] x86/boot: Avoid global attribute in early memory mappings
Date: Wed, 15 May 2024 11:32:34 +0200	[thread overview]
Message-ID: <20240515093233.3698988-2-ardb+git@google.com> (raw)

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


                 reply	other threads:[~2024-05-15  9:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240515093233.3698988-2-ardb+git@google.com \
    --to=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.