[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230816080737.zmqfdrlifedjqmw6@yy-desk-7060>
Date: Wed, 16 Aug 2023 16:07:38 +0800
From: Yuan Yao <yuan.yao@...ux.intel.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Zeng Guang <guang.zeng@...el.com>,
Yuan Yao <yuan.yao@...el.com>
Subject: Re: [PATCH v3 04/15] KVM: VMX: Check KVM CPU caps, not just VMX MSR
support, for XSAVE enabling
On Tue, Aug 15, 2023 at 01:36:42PM -0700, Sean Christopherson wrote:
> Check KVM CPU capabilities instead of raw VMX support for XSAVES when
> determining whether or not XSAVER can/should be exposed to the guest.
> Practically speaking, it's nonsensical/impossible for a CPU to support
> "enable XSAVES" without XSAVES being supported natively. The real
> motivation for checking kvm_cpu_cap_has() is to allow using the governed
> feature's standard check-and-set logic.
>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
Reviewed-by: Yuan Yao <yuan.yao@...el.com>
> ---
> arch/x86/kvm/vmx/vmx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 1bf85bd53416..78f292b7e2c5 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -7745,7 +7745,7 @@ static void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
> * to the guest. XSAVES depends on CR4.OSXSAVE, and CR4.OSXSAVE can be
> * set if and only if XSAVE is supported.
> */
> - vcpu->arch.xsaves_enabled = cpu_has_vmx_xsaves() &&
> + vcpu->arch.xsaves_enabled = kvm_cpu_cap_has(X86_FEATURE_XSAVES) &&
> boot_cpu_has(X86_FEATURE_XSAVE) &&
> guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
> guest_cpuid_has(vcpu, X86_FEATURE_XSAVES);
> --
> 2.41.0.694.ge786442a9b-goog
>
Powered by blists - more mailing lists