Re: [PATCH v2] KVM: SVM: let alternatives handle the cases when RSB filling is required

From: Sean Christopherson
Date: Mon Jul 08 2024 - 14:59:59 EST


On Mon, Jul 01, 2024, David Kaplan wrote:
> > > > /*
> > > > * AMD's AutoIBRS is equivalent to Intel's eIBRS - use the
> > > > Intel feature
> > > > * flag and protect from vendor-specific bugs via the
> > > > whitelist.
> > > > *
> > > > * Don't use AutoIBRS when SNP is enabled because it degrades
> > > > host
> > > > * userspace indirect branch performance.
> > > > */
> > > > if ((x86_arch_cap_msr & ARCH_CAP_IBRS_ALL) ||
> > > > (cpu_has(c, X86_FEATURE_AUTOIBRS) &&
> > > > !cpu_feature_enabled(X86_FEATURE_SEV_SNP))) {
> > > > setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
> > > > if (!cpu_matches(cpu_vuln_whitelist, NO_EIBRS_PBRSB)
> > > > &&
> > > > !(x86_arch_cap_msr & ARCH_CAP_PBRSB_NO))
> > > > setup_force_cpu_bug(X86_BUG_EIBRS_PBRSB);
> > > > }
> > >
> > > Families 0FH through 12H don't have EIBRS or AutoIBRS, so there's no
> > > cpu_vuln_whitelist[] lookup. Hence, no need to set the NO_EIBRS_PBRSB
> > > bit, even if it is accurate.
> >
> > The commit that adds the RSB_VMEXIT_LITE feature flag does describe the
> > bug in a good amount of detail:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i
> > d=2b1299322016731d56807aa49254a5ea3080b6b3
> >
> > I've not seen any indication this is required for AMD CPUs.
> >
> > David, do you agree we don't need this?
> >
>
> It's not required, as AMD CPUs don't have the PBRSB issue with AutoIBRS.
> Although I think Sean was talking about being extra paranoid

Ya. I'm asking if there's a reason not to tack on X86_FEATURE_RSB_VMEXIT_LITE,
beyond it effectively being dead code. There's no runtime cost, and so assuming
it doesn't get spuriously enabled, I don't see a downside.

On the upside, if some SVM-capable CPU comes along that needs the lite version,
then fixing things for that CPU won't need a corresponding KVM change, just a
bugs/caps update.