Re: [RFC][PATCH 11/17] x86/cpu: Remove all SRSO interface nonsense

From: Peter Zijlstra
Date: Wed Aug 09 2023 - 09:36:38 EST


On Wed, Aug 09, 2023 at 02:10:42PM +0100, Andrew.Cooper3@xxxxxxxxxx wrote:
> On 09/08/2023 8:12 am, Peter Zijlstra wrote:
> > Now that retbleed can do all that the srso knob did, and without the
> > dubious interactions with retbleed selections, remove it.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> > ---
> > arch/x86/kernel/cpu/bugs.c | 188 ++-------------------------------------------
> > drivers/base/cpu.c | 8 -
> > include/linux/cpu.h | 2
> > 3 files changed, 10 insertions(+), 188 deletions(-)
>
> Not all of this can go, because ...
>
> > --- a/arch/x86/kernel/cpu/bugs.c
> > +++ b/arch/x86/kernel/cpu/bugs.c
> > ...
> > -static void __init srso_select_mitigation(void)
> > -{
> > - bool has_microcode;
> > -
> > - if (!boot_cpu_has_bug(X86_BUG_SRSO) || cpu_mitigations_off())
> > - goto pred_cmd;
> > -
> > - /*
> > - * The first check is for the kernel running as a guest in order
> > - * for guests to verify whether IBPB is a viable mitigation.
> > - */
> > - has_microcode = boot_cpu_has(X86_FEATURE_IBPB_BRTYPE) || cpu_has_ibpb_brtype_microcode();
> > - if (!has_microcode) {
> > - 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.
> > - */
> > - setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE);
> > - setup_force_cpu_cap(X86_FEATURE_SBPB);
>
> ... these (minus the virt bug caused by probing for microcode behaviour
> even when virtualised, and the enumeration bug caused by ignoring
> synthesis if host mitigations are off) are necessary for KVM.
>
> https://www.amd.com/content/dam/amd/en/documents/corporate/cr/speculative-return-stack-overflow-whitepaper.pdf
>
> and here's one I prepared earlier
> https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=2280b0ee2aed6e0fd4af3fa31bf99bc04d038bfe
>
> but these bits need to get into guests for the guests to be able to
> figure out what to do.

Patch 6 adds these feature bits to retbleed_select_mitigation().