KVM: VMX: Don't rely _only_ on CPUID to enforce XCR0 restrictions for ECREATE
authorSean Christopherson <seanjc@google.com>
Wed, 3 May 2023 16:08:36 +0000 (09:08 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 21 May 2023 08:05:51 +0000 (04:05 -0400)
commitad45413d22e6a224f8530b6fcc9ac01c8ced7fd6
tree000e181725c801bf46bc8f0a135b00c4c86235e3
parentafb2acb2e3a32e4d56f7fbd819769b98ed1b7520
KVM: VMX: Don't rely _only_ on CPUID to enforce XCR0 restrictions for ECREATE

Explicitly check the vCPU's supported XCR0 when determining whether or not
the XFRM for ECREATE is valid.  Checking CPUID works because KVM updates
guest CPUID.0x12.1 to restrict the leaf to a subset of the guest's allowed
XCR0, but that is rather subtle and KVM should not modify guest CPUID
except for modeling true runtime behavior (allowed XFRM is most definitely
not "runtime" behavior).

Reviewed-by: Kai Huang <kai.huang@intel.com>
Tested-by: Kai Huang <kai.huang@intel.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20230503160838.3412617-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/sgx.c