KVM: VMX: Recompute "XSAVES enabled" only after CPUID update
authorSean Christopherson <seanjc@google.com>
Tue, 15 Aug 2023 20:36:41 +0000 (13:36 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 17 Aug 2023 18:38:28 +0000 (11:38 -0700)
commit1143c0b85c07fc45daf1c33b26ba9320becd6748
tree83cfedf3d1b87a5c7e199cc01a2524bb61131a9f
parentccf31d6e6cc53e50cc42845061174082fd229c79
KVM: VMX: Recompute "XSAVES enabled" only after CPUID update

Recompute whether or not XSAVES is enabled for the guest only if the
guest's CPUID model changes instead of redoing the computation every time
KVM generates vmcs01's secondary execution controls.  The boot_cpu_has()
and cpu_has_vmx_xsaves() checks should never change after KVM is loaded,
and if they do the kernel/KVM is hosed.

Opportunistically add a comment explaining _why_ XSAVES is effectively
exposed to the guest if and only if XSAVE is also exposed to the guest.

Practically speaking, no functional change intended (KVM will do fewer
computations, but should still see the same xsaves_enabled value whenever
KVM looks at it).

Reviewed-by: Yuan Yao <yuan.yao@intel.com>
Link: https://lore.kernel.org/r/20230815203653.519297-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/vmx.c