Re: [PATCH v9 03/22] KVM: VMX: Disable FRED if FRED consistency checks fail
From: Sean Christopherson
Date: Wed Mar 04 2026 - 19:25:51 EST
On Sun, Oct 26, 2025, Xin Li (Intel) wrote:
> diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h
> index 6bd67c40ca3b..651507627ef3 100644
> --- a/arch/x86/kvm/vmx/capabilities.h
> +++ b/arch/x86/kvm/vmx/capabilities.h
> @@ -405,6 +405,16 @@ static inline bool vmx_pebs_supported(void)
> return boot_cpu_has(X86_FEATURE_PEBS) && kvm_pmu_cap.pebs_ept;
> }
>
> +static inline bool cpu_has_vmx_fred(void)
> +{
> + /*
> + * setup_vmcs_config() guarantees FRED VM-entry/exit controls
> + * are either all set or none. So, no need to check FRED VM-exit
> + * controls.
> + */
Eh, omit the comment, there are at least six other control pairs that use this
logic.
> + return (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_FRED);
Unnecessary parentheses.
> +}
> +
> static inline bool cpu_has_notify_vmexit(void)
> {
> return vmcs_config.cpu_based_2nd_exec_ctrl &
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index be48ba2d70e1..fcfa99160018 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -8020,6 +8020,9 @@ static __init void vmx_set_cpu_caps(void)
> kvm_cpu_cap_check_and_set(X86_FEATURE_DTES64);
> }
>
> + if (!cpu_has_vmx_fred())
> + kvm_cpu_cap_clear(X86_FEATURE_FRED);
> +
> if (!enable_pmu)
> kvm_cpu_cap_clear(X86_FEATURE_PDCM);
> kvm_caps.supported_perf_cap = vmx_get_perf_capabilities();
> --
> 2.51.0
>