[RFC PATCH 22/34] x86/bugs: Add attack vector controls for taa

From: David Kaplan
Date: Thu Sep 12 2024 - 15:15:10 EST


Use attack vector controls to determine if taa mitigation is required.

Signed-off-by: David Kaplan <david.kaplan@xxxxxxx>
---
arch/x86/kernel/cpu/bugs.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index a5fbd7cc9e25..f042c5595463 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -513,11 +513,17 @@ static void __init taa_select_mitigation(void)
if (taa_mitigation == TAA_MITIGATION_OFF)
return;

- /* This handles the AUTO case. */
- if (boot_cpu_has(X86_FEATURE_MD_CLEAR))
- taa_mitigation = TAA_MITIGATION_VERW;
- else
- taa_mitigation = TAA_MITIGATION_UCODE_NEEDED;
+ if (taa_mitigation == TAA_MITIGATION_AUTO) {
+ if (should_mitigate_vuln(TAA)) {
+ if (boot_cpu_has(X86_FEATURE_MD_CLEAR))
+ taa_mitigation = TAA_MITIGATION_VERW;
+ else
+ taa_mitigation = TAA_MITIGATION_UCODE_NEEDED;
+ } else {
+ taa_mitigation = TAA_MITIGATION_OFF;
+ return;
+ }
+ }

/*
* VERW doesn't clear the CPU buffers when MD_CLEAR=1 and MDS_NO=1.
@@ -560,7 +566,8 @@ static void __init taa_apply_mitigation(void)
*/
setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);

- if (taa_nosmt || cpu_mitigations_auto_nosmt())
+ if (taa_nosmt || cpu_mitigations_auto_nosmt() ||
+ cpu_mitigate_attack_vector(CPU_MITIGATE_CROSS_THREAD))
cpu_smt_disable(false);
}

--
2.34.1