Skip to content

Commit 18eee7b

Browse files
Lei Wangsean-jc
authored andcommitted
KVM: selftests: Move XFD CPUID checking out of __vm_xsave_require_permission()
Move the kvm_cpu_has() check on X86_FEATURE_XFD out of the helper to enable off-by-default XSAVE-managed features and into the one test that currenty requires XFD (XFeature Disable) support. kvm_cpu_has() uses kvm_get_supported_cpuid() and thus caches KVM_GET_SUPPORTED_CPUID, and so using kvm_cpu_has() before ARCH_REQ_XCOMP_GUEST_PERM effectively results in the test caching stale values, e.g. subsequent checks on AMX_TILE will get false negatives. Although off-by-default features are nonsensical without XFD, checking for XFD virtualization prior to enabling such features isn't strictly required. Signed-off-by: Lei Wang <[email protected]> Fixes: 7fbb653 ("KVM: selftests: Check KVM's supported CPUID, not host CPUID, for XFD") Link: https://lore.kernel.org/r/[email protected] [sean: add Fixes, reword changelog] Signed-off-by: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8fcee04 commit 18eee7b

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

tools/testing/selftests/kvm/lib/x86_64/processor.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,6 @@ void __vm_xsave_require_permission(int bit, const char *name)
563563
.addr = (unsigned long) &bitmask
564564
};
565565

566-
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XFD));
567-
568566
kvm_fd = open_kvm_dev_path_or_exit();
569567
rc = __kvm_ioctl(kvm_fd, KVM_GET_DEVICE_ATTR, &attr);
570568
close(kvm_fd);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ int main(int argc, char *argv[])
254254
/* Create VM */
255255
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
256256

257+
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XFD));
257258
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XSAVE));
258259
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_AMX_TILE));
259260
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILECFG));

0 commit comments

Comments
 (0)