[RFC PATCH 21/34] x86/bugs: Add attack vector controls for mds

David Kaplan posted 34 patches 2 months, 2 weeks ago
There is a newer version of this series
[RFC PATCH 21/34] x86/bugs: Add attack vector controls for mds
Posted by David Kaplan 2 months, 2 weeks ago
Use attack vector controls to determine if mds mitigation is required.

If cross-thread attack mitigations are required, disable SMT.

Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
 arch/x86/kernel/cpu/bugs.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index a50c7cf2975d..a5fbd7cc9e25 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -414,8 +414,12 @@ static void __init mds_select_mitigation(void)
 		return;
 	}
 
-	if (mds_mitigation == MDS_MITIGATION_AUTO)
-		mds_mitigation = MDS_MITIGATION_FULL;
+	if (mds_mitigation == MDS_MITIGATION_AUTO) {
+		if (should_mitigate_vuln(MDS))
+			mds_mitigation = MDS_MITIGATION_FULL;
+		else
+			mds_mitigation = MDS_MITIGATION_OFF;
+	}
 
 	if (mds_mitigation == MDS_MITIGATION_FULL) {
 		if (!boot_cpu_has(X86_FEATURE_MD_CLEAR))
@@ -446,7 +450,8 @@ static void __init mds_apply_mitigation(void)
 	if (mds_mitigation == MDS_MITIGATION_FULL) {
 		setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
 		if (!boot_cpu_has(X86_BUG_MSBDS_ONLY) &&
-		    (mds_nosmt || cpu_mitigations_auto_nosmt()))
+		    (mds_nosmt || cpu_mitigations_auto_nosmt() ||
+		     cpu_mitigate_attack_vector(CPU_MITIGATE_CROSS_THREAD)))
 			cpu_smt_disable(false);
 	}
 }
-- 
2.34.1
Re: [RFC PATCH 21/34] x86/bugs: Add attack vector controls for mds
Posted by Manwaring, Derek 2 months ago
On 2024-09-12 14:08-0500 David Kaplan wrote:
> @@ -446,7 +450,8 @@ static void __init mds_apply_mitigation(void)
>      if (mds_mitigation == MDS_MITIGATION_FULL) {
>          setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
>          if (!boot_cpu_has(X86_BUG_MSBDS_ONLY) &&
> -            (mds_nosmt || cpu_mitigations_auto_nosmt()))
> +            (mds_nosmt || cpu_mitigations_auto_nosmt() ||
> +             cpu_mitigate_attack_vector(CPU_MITIGATE_CROSS_THREAD)))
>              cpu_smt_disable(false);
>      }
>  }

Maybe I'm missing something here - if you care about user/user, why
would you not care about cross-thread? It seems to me SMT should be
turned off for all of the vectors.

Derek