summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2019-09-16 12:22:58 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2019-09-24 07:37:31 -0400
commite738772e29214019f506372dd1162723b7a4d507 (patch)
treec6f4c9053d1b947985530f9779f49e7e2308dad1 /tools/testing/selftests
parentb2d8b167e15bb5ec2691d1119c025630a247f649 (diff)
KVM: selftests: hyperv_cpuid: add check for NoNonArchitecturalCoreSharing bit
The bit is supposed to be '1' when SMT is not supported or forcefully disabled and '0' otherwise. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r--tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
index ee59831fbc98..443a2b54645b 100644
--- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
+++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
@@ -26,6 +26,25 @@ static void guest_code(void)
26{ 26{
27} 27}
28 28
29static int smt_possible(void)
30{
31 char buf[16];
32 FILE *f;
33 bool res = 1;
34
35 f = fopen("/sys/devices/system/cpu/smt/control", "r");
36 if (f) {
37 if (fread(buf, sizeof(*buf), sizeof(buf), f) > 0) {
38 if (!strncmp(buf, "forceoff", 8) ||
39 !strncmp(buf, "notsupported", 12))
40 res = 0;
41 }
42 fclose(f);
43 }
44
45 return res;
46}
47
29static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries, 48static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,
30 int evmcs_enabled) 49 int evmcs_enabled)
31{ 50{
@@ -59,6 +78,14 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,
59 TEST_ASSERT(!entry->padding[0] && !entry->padding[1] && 78 TEST_ASSERT(!entry->padding[0] && !entry->padding[1] &&
60 !entry->padding[2], "padding should be zero"); 79 !entry->padding[2], "padding should be zero");
61 80
81 if (entry->function == 0x40000004) {
82 int nononarchcs = !!(entry->eax & (1UL << 18));
83
84 TEST_ASSERT(nononarchcs == !smt_possible(),
85 "NoNonArchitecturalCoreSharing bit"
86 " doesn't reflect SMT setting");
87 }
88
62 /* 89 /*
63 * If needed for debug: 90 * If needed for debug:
64 * fprintf(stdout, 91 * fprintf(stdout,