All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: selftest: Move XFD CPUID checking out of __vm_xsave_require_permission()
@ 2022-11-25  2:38 Wang, Lei
  2022-11-28 17:03 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Wang, Lei @ 2022-11-25  2:38 UTC (permalink / raw)
  To: kvm; +Cc: pbonzini, seanjc, yang.zhong

kvm_cpu_has(X86_FEATURE_XFD) will call kvm_get_supported_cpuid() which will
cache the cpuid information when it is firstly called. Move this line out
of __vm_xsave_require_permission() and check it afterwards so that the
CPUID change will not be veiled by the cached CPUID information.

Signed-off-by: Wang, Lei <lei4.wang@intel.com>
---
 tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 --
 tools/testing/selftests/kvm/x86_64/amx_test.c      | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
index 39c4409ef56a..5686eacd4700 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
@@ -616,8 +616,6 @@ void __vm_xsave_require_permission(int bit, const char *name)
 		.addr = (unsigned long) &bitmask
 	};
 
-	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XFD));
-
 	kvm_fd = open_kvm_dev_path_or_exit();
 	rc = __kvm_ioctl(kvm_fd, KVM_GET_DEVICE_ATTR, &attr);
 	close(kvm_fd);
diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
index dadcbad10a1d..1e3457ff304b 100644
--- a/tools/testing/selftests/kvm/x86_64/amx_test.c
+++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
@@ -312,6 +312,7 @@ int main(int argc, char *argv[])
 	/* 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));
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-29  1:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25  2:38 [PATCH] KVM: selftest: Move XFD CPUID checking out of __vm_xsave_require_permission() Wang, Lei
2022-11-28 17:03 ` Sean Christopherson
2022-11-29  1:01   ` Wang, Lei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.