x86/srso: Disable the mitigation on unaffected configurations
Subsystems (2)
Borislav Petkov
maintainerPATCH 1/1 x86/srso: Disable the mitigation on unaffected configurations
From: "Borislav Petkov (AMD)" <[email protected]>
Skip the srso cmd line parsing which is not needed on Zen1/2 with SMT disabled and with the proper microcode applied (latter should be the case anyway) as those are not affected.
--- arch/x86/kernel/cpu/bugs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +6 -1
@@ -2418,8 +2418,10 @@ static void __init srso_select_mitigation(void)* IBPB microcode has been applied. */ if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) + (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO ); + goto pred_cmd; + } }if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {
@@ -2696,6 +2698,9 @@ static ssize_t retbleed_show_state(char *buf)static ssize_t srso_show_state (char *buf) { +if (boot_cpu_has (X86_FEATURE_SRSO_NO )) +return sysfs_emit (buf,"Not affected\n" ); +return sysfs_emit (buf,"%s%s\n" , srso_strings[srso_mitigation], (cpu_has_ibpb_brtype_microcode () ?"" :", no microcode" ));
Signature · 1 line
2.42.0.rc0.25.ga82fb66fed25
Quoted 17 lines · Borislav Petkov
From: "Borislav Petkov (AMD)" <[email protected]>
Skip the srso cmd line parsing which is not needed on Zen1/2 with SMT disabled and with the proper microcode applied (latter should be the case anyway) as those are not affected.
Fixes 5a15d8348881 ("x86/srso: Tie SBPB bit setting to microcode patch detection")Signed-off-by Borislav Petkov (AMD) <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/bugs.c +0
-0
arch/x86/kernel/cpu/bugs.c static void __init srso_select_mitigation(void) · line 2423
Quoted 7 lines
arch/x86/kernel/cpu/bugs.c +2
-1@@ -2418,8 +2418,10 @@ static void __init srso_select_mitigation(void)* IBPB microcode has been applied. */ if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) + (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO ); + goto pred_cmd;
Actually can't you simply return, given that zen1/2 never have the SBPB flag set? Only zen3/4 with the updated microcode?
Quoted 14 lines
arch/x86/kernel/cpu/bugs.c +4
-0+ } }if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {@@ -2696,6 +2698,9 @@ static ssize_t retbleed_show_state(char *buf)static ssize_t srso_show_state (char *buf) { +if (boot_cpu_has (X86_FEATURE_SRSO_NO )) +return sysfs_emit (buf,"Not affected\n" ); +return sysfs_emit (buf,"%s%s\n" , srso_strings[srso_mitigation], (cpu_has_ibpb_brtype_microcode () ?"" :", no microcode" ));
Josh Poimboeuf
maintainerQuoted 15 lines · Nikolay Borisov
Quoted 12 lines · Borislav Petkov
From: "Borislav Petkov (AMD)" <[email protected]>
Skip the srso cmd line parsing which is not needed on Zen1/2 with SMT disabled and with the proper microcode applied (latter should be the case anyway) as those are not affected.
Fixes 5a15d8348881 ("x86/srso: Tie SBPB bit setting to microcode patch detection")Signed-off-by Borislav Petkov (AMD) <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Quoted 15 lines
arch/x86/kernel/cpu/bugs.c static void __init srso_select_mitigation(void) · line 2423
Quoted 12 lines
arch/x86/kernel/cpu/bugs.c +2
-1@@ -2418,8 +2418,10 @@ static void __init srso_select_mitigation(void)* IBPB microcode has been applied. */ if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) + (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO ); + goto pred_cmd;Actually can't you simply return, given that zen1/2 never have the SBPB flag set? Only zen3/4 with the updated microcode?
Tangentially, the 'cpu_smt_control == CPU_SMT_DISABLED' check is wrong, as SMT could still get enabled at runtime and SRSO would be exposed.
Also is there a reason to re-use the hardware SRSO_NO bit rather than clear the bug bit? That seems cleaner, then you wouldn't need this hack:
Quoted 3 lines
Quoted 3 lines
arch/x86/kernel/cpu/bugs.c +3
-0+if (boot_cpu_has (X86_FEATURE_SRSO_NO )) +return sysfs_emit (buf,"Not affected\n" ); +
Signature · 1 line
Josh
Borislav Petkov
maintainerQuoted 2 lines · Josh Poimboeuf
Tangentially, the '
cpu_smt_control==CPU_SMT_DISABLED' check is wrong, as SMT could still get enabled at runtime and SRSO would be exposed.
Well, even if it gets exposed, I don't think we can safely enable the mitigation at runtime as alternatives have run already.
I guess I could use CPU_SMT_FORCE_DISABLED here.
Quoted 1 line
Also is there a reason to re-use the hardware
SRSO_NObit
Not a hardware bit - this is set by software - it is only allocated in the CPUID leaf for easier interaction with guests.
Quoted 1 line
rather than clear the bug bit?
We don't clear the X86_BUGs. Ever. The logic is that if the CPU matches an affected CPU, that flag remains to show that it is potentially affected.
/sys/devices/system/cpu/vulnerabilities/ tells you what the actual state is.
Quoted 1 line
That seems cleaner, then you wouldn't need this hack:
Not a hack. This is just like the other "not affected" feature flags.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteJosh Poimboeuf
maintainerQuoted 6 lines · Borislav Petkov
Quoted 2 lines · Josh Poimboeuf
Tangentially, the '
cpu_smt_control==CPU_SMT_DISABLED' check is wrong, as SMT could still get enabled at runtime and SRSO would be exposed.Well, even if it gets exposed, I don't think we can safely enable the mitigation at runtime as alternatives have run already.
Right, I wasn't suggesting to enable the mitigation at runtime. Rather, enable the mitigation at boot time, if SMT is even possible. That's what we've done for other mitigations. Better safe than sorry.
Quoted 1 line
I guess I could use
CPU_SMT_FORCE_DISABLEDhere.
cpu_smt_possible() already does that.
Quoted 4 lines
Quoted 1 line
Also is there a reason to re-use the hardware
SRSO_NObitNot a hardware bit - this is set by software - it is only allocated in the CPUID leaf for easier interaction with guests.
2. ENUMERATION OF NEW CAPABILITIES
AMD is defining three new CPUID bits to assist with the enumeration of capabilities related to SRSO:
CPUID Fn8000_0021_EAX[29] (SRSO_NO) – If this bit is 1, it indicates the CPU is not subject to the SRSO vulnerability.
CPUID Fn8000_0021_EAX[28] (IBPB_BRTYPE) – If this bit is 1, it indicates that MSR 49h (PRED_CMD) bit 0 (IBPB) flushes all branch type predictions from the CPU branch predictor.
CPUID Fn8000_0021_EAX[27] (SBPB)
Quoted 5 lines
Quoted 1 line
rather than clear the bug bit?
We don't clear the
X86_BUGs. Ever. The logic is that if the CPU matches an affected CPU, that flag remains to show that it is potentially affected.
Hm, ok. I thought that was the point of the vulnerabilities file.
Quoted 2 lines
/sys/devices/system/cpu/vulnerabilities/tells you what the actual state is.
Since technically the CPU is affected, I'm thinking it should say "Mitigation: SMT disabled" or such, instead of "Not affected".
Quoted 3 lines
Quoted 1 line
That seems cleaner, then you wouldn't need this hack:
Not a hack. This is just like the other "not affected" feature flags.
Hm? You mean the *_NO ones that determine whether the BUG bits get set in the first place? How do they print "Not affected"?
Signature · 1 line
Josh
Borislav Petkov
maintainerQuoted 1 line · Josh Poimboeuf
cpu_smt_possible()already does that.
Ok.
Quoted 1 line
2. ENUMERATION OF NEW CAPABILITIES
Yes, exactly. On the next page: "Hypervisor software should synthesize... " I got confused initially too.
Quoted 2 lines
Since technically the CPU is affected, I'm thinking it should say "Mitigation: SMT disabled" or such, instead of "Not affected".
Lemme see how ugly it becomes tomorrow.
Quoted 2 lines
Hm? You mean the
*_NOones that determine whether the BUG bits get set in the first place? How do they print "Not affected"?
If SMT is disabled on those configurations, it is not affected. But ok, "SMT disabled".
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerPATCH 1/1 x86/srso: Correct the mitigation status when SMT is disabled
Quoted 1 line · Borislav Petkov
Lemme see how ugly it becomes tomorrow.
Not too bad, considering bugs.c's ugliness.
From: "Borislav Petkov (AMD)" <[email protected]>
Date: Tue, 15 Aug 2023 11:53:13 +0200
Subject: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Specify how is SRSO mitigated when SMT is disabled. Also, correct the SMT check for that.
--- arch/x86/kernel/cpu/bugs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +7 -4
@@ -2417,8 +2417,7 @@ static void __init srso_select_mitigation(void)* Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. */ -if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) { +if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; }
@@ -2698,8 +2697,12 @@ static ssize_t retbleed_show_state(char *buf)static ssize_t srso_show_state (char *buf) { -if (boot_cpu_has (X86_FEATURE_SRSO_NO )) -return sysfs_emit (buf,"Not affected\n" ); +if (boot_cpu_has (X86_FEATURE_SRSO_NO )) { +if (sched_smt_active ()) +return sysfs_emit (buf,"Not affected\n" ); +else +return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); + } return sysfs_emit(buf, "%s%s\n", srso_strings[srso_mitigation],
Signature · 7 lines
2.42.0.rc0.25.ga82fb66fed25
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteJosh Poimboeuf
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Quoted 14 lines · Borislav Petkov
arch/x86/kernel/cpu/bugs.c +1
-2@@ -2417,8 +2417,7 @@ static void __init srso_select_mitigation(void)* Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. */ -if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) { +if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; }@@ -2698,8 +2697,12 @@ static ssize_t retbleed_show_state(char *buf)
arch/x86/kernel/cpu/bugs.c static ssize_t retbleed_show_state(char *buf) · line 2705
Quoted 10 lines
arch/x86/kernel/cpu/bugs.c +6
-2static ssize_t srso_show_state (char *buf) { -if (boot_cpu_has (X86_FEATURE_SRSO_NO )) -return sysfs_emit (buf,"Not affected\n" ); +if (boot_cpu_has (X86_FEATURE_SRSO_NO )) { +if (sched_smt_active ()) +return sysfs_emit (buf,"Not affected\n" ); +else +return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); + }
AFAICT, nowhere in the spec does it say the SRSO_NO bit won't get set by future (fixed) HW. In fact I'd expect it will, similar to other *_NO flags.
Regardless, here SRSO_NO seems to mean two different things: "reported safe by host (or HW)" and "not reported safe on Zen1/2 with SMT not possible".
Also, in this code, the SRSO_NO+SMT combo doesn't seem logically possible, as srso_show_state() only gets called if X86_BUG_SRSO is set, which only happens if SRSO_NO is not set by the HW/host in the first place. So here, if boot_cpu_has(X86_FEATURE_SRSO_NO), it means SRSO_NO was manually set by srso_select_mitigation(), and SMT can't possibly be enabled.
Instead of piggybacking on SRSO_NO, which is confusing, why not just add a new mitigation type, like:
arch/x86/kernel/cpu/bugs.c +5 -10
@@ -2343,6 +2343,7 @@ early_param("l1tf", l1tf_cmdline);enum srso_mitigation {SRSO_MITIGATION_NONE ,SRSO_MITIGATION_MICROCODE , +SRSO_MITIGATION_SMT ,SRSO_MITIGATION_SAFE_RET ,SRSO_MITIGATION_IBPB ,SRSO_MITIGATION_IBPB_ON_VMEXIT ,
@@ -2359,6 +2360,7 @@ enum srso_mitigation_cmd {static const char *const srso_strings[] = { [SRSO_MITIGATION_NONE ] ="Vulnerable" , [SRSO_MITIGATION_MICROCODE ] ="Mitigation: microcode" , + [SRSO_MITIGATION_SMT ] ="Mitigation: SMT disabled" , [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: safe RET" , [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only"
@@ -2407,19 +2409,15 @@ static void __init srso_select_mitigation(void)pr_warn ("IBPB-extending microcode not applied!\n" );pr_warn (SRSO_NOTICE ); }else { -/* -* Enable the synthetic (even if in a real CPUID leaf) -* flags for guests. -*/ +/* Enable the synthetic flag, as HW doesn't set it. */ setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE );/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. */ -if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) { -setup_force_cpu_cap (X86_FEATURE_SRSO_NO ); +if ((boot_cpu_data.x86 <0x19 ) && !cpu_smt_possible ()) { + srso_mitigation =SRSO_MITIGATION_SMT ;return ; } }
@@ -2698,9 +2696,6 @@ static ssize_t retbleed_show_state(char *buf)static ssize_t srso_show_state (char *buf) { -if (boot_cpu_has (X86_FEATURE_SRSO_NO )) -return sysfs_emit (buf,"Not affected\n" ); -return sysfs_emit (buf,"%s%s\n" , srso_strings[srso_mitigation], (cpu_has_ibpb_brtype_microcode () ?"" :", no microcode" ));
Borislav Petkov
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Quoted 3 lines · Josh Poimboeuf
AFAICT, nowhere in the spec does it say the
SRSO_NObit won't get set by future (fixed) HW. In fact I'd expect it will, similar to other*_NOflags.
I'm pretty sure it won't.
SRSO_NO is synthesized by the hypervisor *software*. Nothing else.
It is there so that you don't check microcode version in the guest which is nearly impossible anyway.
Quoted 3 lines
Regardless, here
SRSO_NOseems to mean two different things: "reported safe by host (or HW)" and "not reported safe on Zen1/2 with SMT not possible".
Huh?
Quoted 6 lines
Also, in this code, the SRSO_NO+SMT combo doesn't seem logically possible, as
srso_show_state()only gets called ifX86_BUG_SRSOis set, which only happens ifSRSO_NOis not set by the HW/host in the first place. So here, ifboot_cpu_has(X86_FEATURE_SRSO_NO), it meansSRSO_NOwas manually set bysrso_select_mitigation(), and SMT can't possibly be enabled.
Have you considered the case where Linux would set SRSO_NO when booting on future hardware, which is fixed?
There SRSO_NO and SMT will very much be possible.
Quoted 2 lines
Instead of piggybacking on
SRSO_NO, which is confusing, why not just add a new mitigation type, like:
I had a separate mitigation defintion but then realized I don't need it because, well, it is not really a mitigation - it is a case where the machine is not affected.
For example, I have a Zen2 laptop here with SMT disabled in the hardware which is also not affected.
And also, the rest of the SMT disabled cases in bugs.c do check sched_smt_active() too, without having a separate mitigation.
That's why.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteJosh Poimboeuf
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Quoted 8 lines · Borislav Petkov
Quoted 3 lines · Josh Poimboeuf
AFAICT, nowhere in the spec does it say the
SRSO_NObit won't get set by future (fixed) HW. In fact I'd expect it will, similar to other*_NOflags.I'm pretty sure it won't.
SRSO_NOis synthesized by the hypervisor *software*. Nothing else.
Citation needed.
Quoted 8 lines
It is there so that you don't check microcode version in the guest which is nearly impossible anyway.
Quoted 3 lines
Regardless, here
SRSO_NOseems to mean two different things: "reported safe by host (or HW)" and "not reported safe on Zen1/2 with SMT not possible".Huh?
Can you clarify what doesn't make sense?
Quoted 11 lines
Quoted 6 lines
Also, in this code, the SRSO_NO+SMT combo doesn't seem logically possible, as
srso_show_state()only gets called ifX86_BUG_SRSOis set, which only happens ifSRSO_NOis not set by the HW/host in the first place. So here, ifboot_cpu_has(X86_FEATURE_SRSO_NO), it meansSRSO_NOwas manually set bysrso_select_mitigation(), and SMT can't possibly be enabled.Have you considered the case where Linux would set
SRSO_NOwhen booting on future hardware, which is fixed?There
SRSO_NOand SMT will very much be possible.
How is that relevant to my comment? The bug bit still wouldn't get set and srso_show_state() still wouldn't be called.
Signature · 1 line
Josh
Borislav Petkov
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Quoted 2 lines · Josh Poimboeuf
How is that relevant to my comment? The bug bit still wouldn't get set and
srso_show_state()still wouldn't be called.
Lemme explain how I see this working - it might help us get on the right track. And for comparison you can look at X86_FEATURE_BTC_NO too.
* Something has set X86_FEATURE_SRSO_NO - hw or sw doesn't matter
- because the machine is not affected. X86_BUG_SRSO doesn't get set and the mitigation detection is skipped. All good.
* Nothing has set X86_FEATURE_SRSO_NO, mitigation detection runs and find that the kernel runs on a Zen1/2 with SMT disabled - we set X86_FEATURE_SRSO_NO.
* Now X86_FEATURE_SRSO_NO is passed in by KVM to the guest and the above dance repeats.
Now you.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteJosh Poimboeuf
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Quoted 10 lines · Borislav Petkov
Quoted 2 lines · Josh Poimboeuf
How is that relevant to my comment? The bug bit still wouldn't get set and
srso_show_state()still wouldn't be called.Lemme explain how I see this working - it might help us get on the right track. And for comparison you can look at
X86_FEATURE_BTC_NOtoo.* Something has set
X86_FEATURE_SRSO_NO- hw or sw doesn't matter
- because the machine is not affected.X86_BUG_SRSOdoesn't get set and the mitigation detection is skipped. All good.
In this case srso_show_state() is never called, so the following code can't run:
+ if (boot_cpu_has(X86_FEATURE_SRSO_NO)) {
+ if (sched_smt_active())
+ return sysfs_emit(buf, "Not affected\n");
Quoted 3 lines
* Nothing has set
X86_FEATURE_SRSO_NO, mitigation detection runs and find that the kernel runs on a Zen1/2 with SMT disabled - we setX86_FEATURE_SRSO_NO.
In this case SMT is disabled, so the following code still can't run:
+ if (boot_cpu_has(X86_FEATURE_SRSO_NO)) {
+ if (sched_smt_active())
+ return sysfs_emit(buf, "Not affected\n");
So the above code never runs.
See?
Signature · 1 line
Josh
Borislav Petkov
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Review
Quoted 6 lines · Josh Poimboeuf
In this case
srso_show_state()is never called, so the following code can't run:(quoted diff) +3
-0+ if (boot_cpu_has(X86_FEATURE_SRSO_NO)) { + if (sched_smt_active()) + return sysfs_emit(buf, "Not affected\n");
Ofc it can. If something has set X86_FEATURE_SRSO_NO early, before the bug bits detection happens, then you get:
$ cat /sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow Not affected
Review
Quoted 5 lines
In this case SMT is disabled, so the following code still can't run:
(quoted diff) +3
-0+ if (boot_cpu_has(X86_FEATURE_SRSO_NO)) { + if (sched_smt_active()) + return sysfs_emit(buf, "Not affected\n");
Yes, it runs in the above case where on some future hw which might have SRSO fixed, we'll set SRSO_NO.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteJosh Poimboeuf
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Quoted 11 lines · Borislav Petkov
Review
Quoted 6 lines · Josh Poimboeuf
In this case
srso_show_state()is never called, so the following code can't run:(quoted diff) +3
-0+ if (boot_cpu_has(X86_FEATURE_SRSO_NO)) { + if (sched_smt_active()) + return sysfs_emit(buf, "Not affected\n");Ofc it can. If something has set
X86_FEATURE_SRSO_NOearly, before the bug bits detection happens, then you get:
Quoted 2 lines
$ cat /sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow Not affected
No, if the bug bit isn't set then that comes from cpu_show_common():
static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr,
char *buf, unsigned int bug)
{
if (!boot_cpu_has_bug(bug))
return sysfs_emit(buf, "Not affected\n");Signature · 1 line
Josh
Borislav Petkov
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Quoted 7 lines · Josh Poimboeuf
No, if the bug bit isn't set then that comes from
cpu_show_common():static
ssize_tcpu_show_common(struct device *dev, structdevice_attribute*attr,
char *buf, unsigned int bug){ if (!boot_cpu_has_bug(bug)) return sysfs_emit(buf, "Not affected\n");
Bah, there was that thing too.
Ok, I'll zap the sched_smt_active() branch in srso_show_state() then.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
From: "Borislav Petkov (AMD)" <[email protected]>
Date: Tue, 15 Aug 2023 11:53:13 +0200
Subject: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Specify how is SRSO mitigated when SMT is disabled. Also, correct the SMT check for that.
--- arch/x86/kernel/cpu/bugs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +2 -3
@@ -2428,8 +2428,7 @@ static void __init srso_select_mitigation(void)* Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. */ -if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) { +if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; }
@@ -2714,7 +2713,7 @@ static ssize_t retbleed_show_state(char *buf)static ssize_t srso_show_state (char *buf) {if (boot_cpu_has (X86_FEATURE_SRSO_NO )) -return sysfs_emit (buf,"Not affected\n" ); +return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); return sysfs_emit(buf, "%s%s\n", srso_strings[srso_mitigation],
Signature · 7 lines
2.42.0.rc0.25.ga82fb66fed25
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled
Quoted 11 lines · Borislav Petkov
From: "Borislav Petkov (AMD)" <[email protected]>
Date: Tue, 15 Aug 2023 11:53:13 +0200
Subject: [PATCH] x86/srso: Correct the mitigation status when SMT is disabledSpecify how is SRSO mitigated when SMT is disabled. Also, correct the SMT check for that.
Fixes e9fbc47b818b ("x86/srso: Disable the mitigation on unaffected configurations")Suggested-by Josh Poimboeuf <[email protected]>Signed-off-by Borislav Petkov (AMD) <[email protected]>
Signature · 1 line
Josh
[tip: x86/urgent] x86/srso: Correct the mitigation status when SMT is disabled
In reply to Josh PoimboeufThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 6405b72e8d17bd1875a56ae52d23ec3cd51b9d66 Gitweb: https://git.kernel.org/tip/6405b72e8d17bd1875a56ae52d23ec3cd51b9d66 Author: Borislav Petkov (AMD) <[email protected]> AuthorDate: Tue, 15 Aug 2023 11:53:13 +02:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 18 Aug 2023 12:43:10 +02:00
x86/srso: Correct the mitigation status when SMT is disabled
Specify how is SRSO mitigated when SMT is disabled. Also, correct the SMT check for that.
--- arch/x86/kernel/cpu/bugs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +2 -3
@@ -2428,8 +2428,7 @@ static void __init srso_select_mitigation(void)* Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. */ -if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) { +if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; }
@@ -2714,7 +2713,7 @@ static ssize_t retbleed_show_state(char *buf)static ssize_t srso_show_state (char *buf) {if (boot_cpu_has (X86_FEATURE_SRSO_NO )) -return sysfs_emit (buf,"Not affected\n" ); +return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); return sysfs_emit(buf, "%s%s\n", srso_strings[srso_mitigation],
The following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: e9fbc47b818b964ddff5df5b2d5c0f5f32f4a147 Gitweb: https://git.kernel.org/tip/e9fbc47b818b964ddff5df5b2d5c0f5f32f4a147 Author: Borislav Petkov (AMD) <[email protected]> AuthorDate: Sun, 13 Aug 2023 12:39:34 +02:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Mon, 14 Aug 2023 11:28:51 +02:00
x86/srso: Disable the mitigation on unaffected configurations
Skip the srso cmd line parsing which is not needed on Zen1/2 with SMT disabled and with the proper microcode applied (latter should be the case anyway) as those are not affected.
--- arch/x86/kernel/cpu/bugs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +6 -1
@@ -2418,8 +2418,10 @@ static void __init srso_select_mitigation(void)* IBPB microcode has been applied. */ if ((boot_cpu_data.x86 <0x19 ) && - (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) + (!cpu_smt_possible () || (cpu_smt_control ==CPU_SMT_DISABLED ))) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO ); +return ; + } }if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {
@@ -2696,6 +2698,9 @@ static ssize_t retbleed_show_state(char *buf)static ssize_t srso_show_state (char *buf) { +if (boot_cpu_has (X86_FEATURE_SRSO_NO )) +return sysfs_emit (buf,"Not affected\n" ); +return sysfs_emit (buf,"%s%s\n" , srso_strings[srso_mitigation], (cpu_has_ibpb_brtype_microcode () ?"" :", no microcode" ));