KVM: selftests: Do kvm_cpu_has() checks before creating VM+vCPU
Move the AMX test's kvm_cpu_has() checks before creating the VM+vCPU, there are no dependencies between the two operations. Opportunistically add a comment to call out that enabling off-by-default XSAVE-managed features must be done before KVM_GET_SUPPORTED_CPUID is cached. Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20221128225735.3291648-5-seanjc@google.com
This commit is contained in:
parent
cd5f3d2100
commit
553d1652b8
@ -249,17 +249,21 @@ int main(int argc, char *argv[])
|
||||
u32 amx_offset;
|
||||
int stage, ret;
|
||||
|
||||
/*
|
||||
* Note, all off-by-default features must be enabled before anything
|
||||
* caches KVM_GET_SUPPORTED_CPUID, e.g. before using kvm_cpu_has().
|
||||
*/
|
||||
vm_xsave_require_permission(XSTATE_XTILE_DATA_BIT);
|
||||
|
||||
/* Create VM */
|
||||
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
|
||||
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XFD));
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XSAVE));
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_AMX_TILE));
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILECFG));
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILEDATA));
|
||||
|
||||
/* Create VM */
|
||||
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
|
||||
|
||||
TEST_ASSERT(kvm_cpu_has_p(X86_PROPERTY_XSTATE_MAX_SIZE),
|
||||
"KVM should enumerate max XSAVE size when XSAVE is supported");
|
||||
xsave_restore_size = kvm_cpu_property(X86_PROPERTY_XSTATE_MAX_SIZE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user