linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] x86: Use CPUID 0x8000001f to confirm SME availability
@ 2022-02-11  5:36 Mario Limonciello
  2022-02-11  5:36 ` [PATCH 2/2] x86/cpu: clear SME/SEV/SEV_ES features when not in use Mario Limonciello
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Mario Limonciello @ 2022-02-11  5:36 UTC (permalink / raw)
  To: Borislav Petkov, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)
  Cc: Kees Cook, Thomas Lendacky, hughsient, Martin Fernandez,
	linux-kernel, Mario Limonciello

An upcoming change will disable the X86 SME feature flag when the
kernel hasn't activated SME.  Avoid relying upon that when determining
whether to call `native_wbinvd` by directly calling the CPUID that
indicates it.

Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 arch/x86/kernel/process.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 81d8ef036637..e131d71b3cae 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -765,8 +765,11 @@ void stop_this_cpu(void *dummy)
 	 * without the encryption bit, they don't race each other when flushed
 	 * and potentially end up with the wrong entry being committed to
 	 * memory.
+	 *
+	 * Test the CPUID bit directly because the machine might've cleared
+	 * X86_FEATURE_SME due to cmdline options.
 	 */
-	if (boot_cpu_has(X86_FEATURE_SME))
+	if (cpuid_eax(0x8000001f) & BIT(0))
 		native_wbinvd();
 	for (;;) {
 		/*
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-02-11 21:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11  5:36 [PATCH 1/2] x86: Use CPUID 0x8000001f to confirm SME availability Mario Limonciello
2022-02-11  5:36 ` [PATCH 2/2] x86/cpu: clear SME/SEV/SEV_ES features when not in use Mario Limonciello
2022-02-11  8:31   ` Borislav Petkov
2022-02-11 19:43     ` Limonciello, Mario
2022-02-11 14:46   ` Tom Lendacky
2022-02-11 19:54     ` Limonciello, Mario
2022-02-11 20:42       ` Tom Lendacky
2022-02-11  8:28 ` [PATCH 1/2] x86: Use CPUID 0x8000001f to confirm SME availability Borislav Petkov
2022-02-11 14:55 ` Tom Lendacky
2022-02-11 19:51   ` Limonciello, Mario
2022-02-11 21:09     ` Tom Lendacky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).