From: "tip-bot2 for Borislav Petkov (AMD)" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>,
Srikanth Aithal <sraithal@amd.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/alternatives] x86/alternatives: Catch late X86_FEATURE modifiers
Date: Thu, 04 Apr 2024 09:11:17 -0000 [thread overview]
Message-ID: <171222187750.10875.4089921606500177665.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240327154317.29909-3-bp@alien8.de>
The following commit has been merged into the x86/alternatives branch of tip:
Commit-ID: 97784e52f18fe6e0d6516ded8ecd3cec722ce9cc
Gitweb: https://git.kernel.org/tip/97784e52f18fe6e0d6516ded8ecd3cec722ce9cc
Author: Borislav Petkov (AMD) <bp@alien8.de>
AuthorDate: Wed, 27 Mar 2024 16:43:14 +01:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Wed, 03 Apr 2024 20:03:24 +02:00
x86/alternatives: Catch late X86_FEATURE modifiers
After alternatives have been patched, changes to the X86_FEATURE flags
won't take effect and could potentially even be wrong.
Warn about it.
This is something which has been long overdue.
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Srikanth Aithal <sraithal@amd.com>
Link: https://lore.kernel.org/r/20240327154317.29909-3-bp@alien8.de
---
arch/x86/include/asm/cpufeature.h | 8 ++++++--
arch/x86/kernel/cpu/cpuid-deps.c | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 7103ba1..e5d8880 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -148,8 +148,12 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
extern void setup_clear_cpu_cap(unsigned int bit);
extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
-#define setup_force_cpu_cap(bit) do { \
- set_cpu_cap(&boot_cpu_data, bit); \
+#define setup_force_cpu_cap(bit) do { \
+ \
+ if (!boot_cpu_has(bit)) \
+ WARN_ON(alternatives_patched); \
+ \
+ set_cpu_cap(&boot_cpu_data, bit); \
set_bit(bit, (unsigned long *)cpu_caps_set); \
} while (0)
diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index b717420..5dd427c 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -114,6 +114,9 @@ static void do_clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int feature)
if (WARN_ON(feature >= MAX_FEATURE_BITS))
return;
+ if (boot_cpu_has(feature))
+ WARN_ON(alternatives_patched);
+
clear_feature(c, feature);
/* Collect all features to disable, handling dependencies */
next prev parent reply other threads:[~2024-04-04 9:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-27 15:43 [PATCH 0/5] x86/sev: Fix SNP host late disable Borislav Petkov
2024-03-27 15:43 ` [PATCH 1/5] x86/alternatives: Remove a superfluous newline in _static_cpu_has() Borislav Petkov
2024-04-04 9:11 ` [tip: x86/alternatives] " tip-bot2 for Borislav Petkov (AMD)
2024-04-04 10:16 ` tip-bot2 for Borislav Petkov (AMD)
2024-04-09 17:11 ` [tip: x86/asm] " tip-bot2 for Borislav Petkov (AMD)
2024-03-27 15:43 ` [PATCH 2/5] x86/alternatives: Catch late X86_FEATURE modifiers Borislav Petkov
2024-03-27 15:57 ` Nikolay Borisov
2024-04-03 17:59 ` Borislav Petkov
2024-04-04 9:11 ` tip-bot2 for Borislav Petkov (AMD) [this message]
2024-04-04 10:16 ` [tip: x86/alternatives] " tip-bot2 for Borislav Petkov (AMD)
2024-04-09 17:11 ` tip-bot2 for Borislav Petkov (AMD)
2024-03-27 15:43 ` [PATCH 3/5] x86/kvm/Kconfig: Have KVM_AMD_SEV select ARCH_HAS_CC_PLATFORM Borislav Petkov
2024-03-29 14:42 ` Tom Lendacky
2024-04-04 9:11 ` [tip: x86/urgent] " tip-bot2 for Borislav Petkov (AMD)
2024-03-27 15:43 ` [PATCH 4/5] x86/cc: Add cc_platform_set/_clear() helpers Borislav Petkov
2024-03-29 14:46 ` Tom Lendacky
2024-04-04 9:11 ` [tip: x86/urgent] " tip-bot2 for Borislav Petkov (AMD)
2024-03-27 15:43 ` [PATCH 5/5] x86/CPU/AMD: Track SNP host status with cc_platform_*() Borislav Petkov
2024-03-28 11:51 ` Jeremi Piotrowski
2024-03-28 13:41 ` Borislav Petkov
2024-03-28 14:24 ` Jeremi Piotrowski
2024-03-28 15:39 ` Borislav Petkov
2024-04-04 17:07 ` Jeremi Piotrowski
2024-04-24 18:46 ` Borislav Petkov
2024-03-29 14:52 ` Tom Lendacky
2024-04-04 9:11 ` [tip: x86/urgent] " tip-bot2 for Borislav Petkov (AMD)
2024-04-03 4:15 ` [PATCH 0/5] x86/sev: Fix SNP host late disable Aithal, Srikanth
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=171222187750.10875.4089921606500177665.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=sraithal@amd.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®