Re: [PATCH] x86/srso: Correct the mitigation status when SMT is disabled

From: Josh Poimboeuf
Date: Wed Aug 16 2023 - 12:08:56 EST


On Wed, Aug 16, 2023 at 10:30:57AM +0200, Borislav Petkov wrote:
> On Tue, Aug 15, 2023 at 02:27:51PM -0700, Josh Poimboeuf wrote:
> > 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.

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");

> * 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.

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?

--
Josh