Skip to content

Commit 553d165

Browse files
committed
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent cd5f3d2 commit 553d165

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/testing/selftests/kvm/x86_64/amx_test.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,21 @@ int main(int argc, char *argv[])
249249
u32 amx_offset;
250250
int stage, ret;
251251

252+
/*
253+
* Note, all off-by-default features must be enabled before anything
254+
* caches KVM_GET_SUPPORTED_CPUID, e.g. before using kvm_cpu_has().
255+
*/
252256
vm_xsave_require_permission(XSTATE_XTILE_DATA_BIT);
253257

254-
/* Create VM */
255-
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
256-
257258
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XFD));
258259
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XSAVE));
259260
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_AMX_TILE));
260261
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILECFG));
261262
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILEDATA));
262263

264+
/* Create VM */
265+
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
266+
263267
TEST_ASSERT(kvm_cpu_has_p(X86_PROPERTY_XSTATE_MAX_SIZE),
264268
"KVM should enumerate max XSAVE size when XSAVE is supported");
265269
xsave_restore_size = kvm_cpu_property(X86_PROPERTY_XSTATE_MAX_SIZE);

0 commit comments

Comments
 (0)