Skip to content

Commit b8ce25d

Browse files
dkaplan2bp3tk0v
authored andcommitted
x86/bugs: Add AUTO mitigations for mds/taa/mmio/rfds
Add AUTO mitigations for mds/taa/mmio/rfds to create consistent vulnerability handling. These AUTO mitigations will be turned into the appropriate default mitigations in the <vuln>_select_mitigation() functions. Later, these will be used with the new attack vector controls to help select appropriate mitigations. Signed-off-by: David Kaplan <david.kaplan@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20250108202515.385902-4-david.kaplan@amd.com
1 parent 2c93762 commit b8ce25d

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

arch/x86/include/asm/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ extern enum l1tf_mitigations l1tf_mitigation;
757757

758758
enum mds_mitigations {
759759
MDS_MITIGATION_OFF,
760+
MDS_MITIGATION_AUTO,
760761
MDS_MITIGATION_FULL,
761762
MDS_MITIGATION_VMWERV,
762763
};

arch/x86/kernel/cpu/bugs.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static void x86_amd_ssb_disable(void)
238238

239239
/* Default mitigation for MDS-affected CPUs */
240240
static enum mds_mitigations mds_mitigation __ro_after_init =
241-
IS_ENABLED(CONFIG_MITIGATION_MDS) ? MDS_MITIGATION_FULL : MDS_MITIGATION_OFF;
241+
IS_ENABLED(CONFIG_MITIGATION_MDS) ? MDS_MITIGATION_AUTO : MDS_MITIGATION_OFF;
242242
static bool mds_nosmt __ro_after_init = false;
243243

244244
static const char * const mds_strings[] = {
@@ -249,34 +249,37 @@ static const char * const mds_strings[] = {
249249

250250
enum taa_mitigations {
251251
TAA_MITIGATION_OFF,
252+
TAA_MITIGATION_AUTO,
252253
TAA_MITIGATION_UCODE_NEEDED,
253254
TAA_MITIGATION_VERW,
254255
TAA_MITIGATION_TSX_DISABLED,
255256
};
256257

257258
/* Default mitigation for TAA-affected CPUs */
258259
static enum taa_mitigations taa_mitigation __ro_after_init =
259-
IS_ENABLED(CONFIG_MITIGATION_TAA) ? TAA_MITIGATION_VERW : TAA_MITIGATION_OFF;
260+
IS_ENABLED(CONFIG_MITIGATION_TAA) ? TAA_MITIGATION_AUTO : TAA_MITIGATION_OFF;
260261

261262
enum mmio_mitigations {
262263
MMIO_MITIGATION_OFF,
264+
MMIO_MITIGATION_AUTO,
263265
MMIO_MITIGATION_UCODE_NEEDED,
264266
MMIO_MITIGATION_VERW,
265267
};
266268

267269
/* Default mitigation for Processor MMIO Stale Data vulnerabilities */
268270
static enum mmio_mitigations mmio_mitigation __ro_after_init =
269-
IS_ENABLED(CONFIG_MITIGATION_MMIO_STALE_DATA) ? MMIO_MITIGATION_VERW : MMIO_MITIGATION_OFF;
271+
IS_ENABLED(CONFIG_MITIGATION_MMIO_STALE_DATA) ? MMIO_MITIGATION_AUTO : MMIO_MITIGATION_OFF;
270272

271273
enum rfds_mitigations {
272274
RFDS_MITIGATION_OFF,
275+
RFDS_MITIGATION_AUTO,
273276
RFDS_MITIGATION_VERW,
274277
RFDS_MITIGATION_UCODE_NEEDED,
275278
};
276279

277280
/* Default mitigation for Register File Data Sampling */
278281
static enum rfds_mitigations rfds_mitigation __ro_after_init =
279-
IS_ENABLED(CONFIG_MITIGATION_RFDS) ? RFDS_MITIGATION_VERW : RFDS_MITIGATION_OFF;
282+
IS_ENABLED(CONFIG_MITIGATION_RFDS) ? RFDS_MITIGATION_AUTO : RFDS_MITIGATION_OFF;
280283

281284
static void __init mds_select_mitigation(void)
282285
{
@@ -285,6 +288,9 @@ static void __init mds_select_mitigation(void)
285288
return;
286289
}
287290

291+
if (mds_mitigation == MDS_MITIGATION_AUTO)
292+
mds_mitigation = MDS_MITIGATION_FULL;
293+
288294
if (mds_mitigation == MDS_MITIGATION_FULL) {
289295
if (!boot_cpu_has(X86_FEATURE_MD_CLEAR))
290296
mds_mitigation = MDS_MITIGATION_VMWERV;
@@ -514,6 +520,9 @@ static void __init rfds_select_mitigation(void)
514520
if (rfds_mitigation == RFDS_MITIGATION_OFF)
515521
return;
516522

523+
if (rfds_mitigation == RFDS_MITIGATION_AUTO)
524+
rfds_mitigation = RFDS_MITIGATION_VERW;
525+
517526
if (x86_arch_cap_msr & ARCH_CAP_RFDS_CLEAR)
518527
setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
519528
else
@@ -1979,6 +1988,7 @@ void cpu_bugs_smt_update(void)
19791988

19801989
switch (mds_mitigation) {
19811990
case MDS_MITIGATION_FULL:
1991+
case MDS_MITIGATION_AUTO:
19821992
case MDS_MITIGATION_VMWERV:
19831993
if (sched_smt_active() && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
19841994
pr_warn_once(MDS_MSG_SMT);
@@ -1990,6 +2000,7 @@ void cpu_bugs_smt_update(void)
19902000

19912001
switch (taa_mitigation) {
19922002
case TAA_MITIGATION_VERW:
2003+
case TAA_MITIGATION_AUTO:
19932004
case TAA_MITIGATION_UCODE_NEEDED:
19942005
if (sched_smt_active())
19952006
pr_warn_once(TAA_MSG_SMT);
@@ -2001,6 +2012,7 @@ void cpu_bugs_smt_update(void)
20012012

20022013
switch (mmio_mitigation) {
20032014
case MMIO_MITIGATION_VERW:
2015+
case MMIO_MITIGATION_AUTO:
20042016
case MMIO_MITIGATION_UCODE_NEEDED:
20052017
if (sched_smt_active())
20062018
pr_warn_once(MMIO_MSG_SMT);

0 commit comments

Comments
 (0)