[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230615164417.3588162-2-leitao@debian.org>
Date: Thu, 15 Jun 2023 09:44:12 -0700
From: Breno Leitao <leitao@...ian.org>
To: pawan.kumar.gupta@...ux.intel.com, jpoimboe@...nel.org,
peterz@...radead.org, tglx@...utronix.de, bp@...en8.de,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>
Cc: leit@...com, linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] x86/bugs: Create an option to disable MDS
There is no way to disable MDS mitigation today at compilation time. MDS
is enabled even if CONFIG_SPECULATION_MITIGATIONS is unset.
Create a new KCONFIG option that allow MDS mitigations to be disabled in
compilation time.
Signed-off-by: Breno Leitao <leitao@...ian.org>
---
arch/x86/Kconfig | 11 +++++++++++
arch/x86/kernel/cpu/bugs.c | 9 ++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 53bab123a8ee..d25132b2d54f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2649,6 +2649,17 @@ config SLS
against straight line speculation. The kernel image might be slightly
larger.
+config MITIGATE_MDS
+ bool "Mitigate Microarchitectural Data Sampling (MDS) hardware bug"
+ depends on CPU_SUP_INTEL && X86_64
+ default y
+ help
+ Enable mitigation for Microarchitectural Data Sampling (MDS). MDS is
+ a hardware vulnerability which allows unprivileged speculative access
+ to data which is available in various CPU internal buffer. Deeper
+ technical information is available in the MDS specific x86 architecture
+ section: Documentation/arch/x86/mds.rst.
+
endif
config ARCH_HAS_ADD_PAGES
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 182af64387d0..50f12829dce9 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -269,6 +269,7 @@ static void x86_amd_ssb_disable(void)
/* Default mitigation for MDS-affected CPUs */
static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_FULL;
static bool mds_nosmt __ro_after_init = false;
+#define MDS_WARN_MSG "WARNING: Microarchitectural Data Sampling (MDS) speculative mitigation disabled!\n"
static const char * const mds_strings[] = {
[MDS_MITIGATION_OFF] = "Vulnerable",
@@ -278,11 +279,17 @@ static const char * const mds_strings[] = {
static void __init mds_select_mitigation(void)
{
- if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) {
+ if (!boot_cpu_has_bug(X86_BUG_MDS)) {
mds_mitigation = MDS_MITIGATION_OFF;
return;
}
+ if (cpu_mitigations_off() || !IS_ENABLED(CONFIG_MITIGATE_MDS)) {
+ mds_mitigation = MDS_MITIGATION_OFF;
+ pr_err(MDS_WARN_MSG);
+ return;
+ }
+
if (mds_mitigation == MDS_MITIGATION_FULL) {
if (!boot_cpu_has(X86_FEATURE_MD_CLEAR))
mds_mitigation = MDS_MITIGATION_VMWERV;
--
2.34.1
Powered by blists - more mailing lists