diff options
author | Vitaly Kuznetsov <vkuznets@redhat.com> | 2019-09-16 18:22:58 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-09-24 13:37:31 +0200 |
commit | e738772e29214019f506372dd1162723b7a4d507 (patch) | |
tree | c6f4c9053d1b947985530f9779f49e7e2308dad1 /tools | |
parent | b2d8b167e15bb5ec2691d1119c025630a247f649 (diff) | |
download | linux-stable-e738772e29214019f506372dd1162723b7a4d507.tar.gz linux-stable-e738772e29214019f506372dd1162723b7a4d507.tar.bz2 linux-stable-e738772e29214019f506372dd1162723b7a4d507.zip |
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')
-rw-r--r-- | tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 27 |
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) { } +static int smt_possible(void) +{ + char buf[16]; + FILE *f; + bool res = 1; + + f = fopen("/sys/devices/system/cpu/smt/control", "r"); + if (f) { + if (fread(buf, sizeof(*buf), sizeof(buf), f) > 0) { + if (!strncmp(buf, "forceoff", 8) || + !strncmp(buf, "notsupported", 12)) + res = 0; + } + fclose(f); + } + + return res; +} + static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries, int evmcs_enabled) { @@ -59,6 +78,14 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries, TEST_ASSERT(!entry->padding[0] && !entry->padding[1] && !entry->padding[2], "padding should be zero"); + if (entry->function == 0x40000004) { + int nononarchcs = !!(entry->eax & (1UL << 18)); + + TEST_ASSERT(nononarchcs == !smt_possible(), + "NoNonArchitecturalCoreSharing bit" + " doesn't reflect SMT setting"); + } + /* * If needed for debug: * fprintf(stdout, |