Re: [PATCH 04/23] KVM: x86: Add IBPB_BRTYPE support
From: Sean Christopherson
Date: Fri Aug 25 2023 - 14:17:18 EST
On Fri, Aug 25, 2023, Josh Poimboeuf wrote:
> Add support for the IBPB_BRTYPE CPUID flag, which indicates that IBPB
> includes branch type prediction flushing.
Please add:
Note, like SRSO_NO, advertise support for IBPB_BRTYPE even if it's not
enumerated by in the raw CPUID, i.e. bypass the cpuid_count() in
__kvm_cpu_cap_mask(). Some CPUs that gained support via a uCode patch
don't report IBPB_BRTYPE via CPUID (the kernel forces the flag).
Opportunistically use kvm_cpu_cap_check_and_set() for SRSS_NO instead
of manually querying host support (cpu_feature_enabled() and
boot_cpu_has() yield the same end result in this case).
Feel free to take this through tip if this is urgent enough to go into 6.6,
otherwise I'll grab it for 6.7.
Acked-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> ---
> arch/x86/kvm/cpuid.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index d3432687c9e6..c65f3ff1c79d 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -729,8 +729,8 @@ void kvm_set_cpu_caps(void)
> F(NULL_SEL_CLR_BASE) | F(AUTOIBRS) | 0 /* PrefetchCtlMsr */
> );
>
> - if (cpu_feature_enabled(X86_FEATURE_SRSO_NO))
> - kvm_cpu_cap_set(X86_FEATURE_SRSO_NO);
> + kvm_cpu_cap_check_and_set(X86_FEATURE_IBPB_BRTYPE);
> + kvm_cpu_cap_check_and_set(X86_FEATURE_SRSO_NO);
>
> kvm_cpu_cap_init_kvm_defined(CPUID_8000_0022_EAX,
> F(PERFMON_V2)
> --
> 2.41.0
>