Commit 6081f9c7 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Paolo Bonzini

KVM: selftests: Adapt hyperv_cpuid test to the newly introduced Enlightened MSR-Bitmap

CPUID 0x40000000.EAX is now always present as it has Enlightened
MSR-Bitmap feature bit set. Adapt the test accordingly. Opportunistically
add a check for the supported eVMCS version range.
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20220203104620.277031-2-vkuznets@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 66c03a92
...@@ -49,16 +49,13 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries, ...@@ -49,16 +49,13 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,
bool evmcs_expected) bool evmcs_expected)
{ {
int i; int i;
int nent = 9; int nent_expected = 10;
u32 test_val; u32 test_val;
if (evmcs_expected) TEST_ASSERT(hv_cpuid_entries->nent == nent_expected,
nent += 1; /* 0x4000000A */
TEST_ASSERT(hv_cpuid_entries->nent == nent,
"KVM_GET_SUPPORTED_HV_CPUID should return %d entries" "KVM_GET_SUPPORTED_HV_CPUID should return %d entries"
" with evmcs=%d (returned %d)", " (returned %d)",
nent, evmcs_expected, hv_cpuid_entries->nent); nent_expected, hv_cpuid_entries->nent);
for (i = 0; i < hv_cpuid_entries->nent; i++) { for (i = 0; i < hv_cpuid_entries->nent; i++) {
struct kvm_cpuid_entry2 *entry = &hv_cpuid_entries->entries[i]; struct kvm_cpuid_entry2 *entry = &hv_cpuid_entries->entries[i];
...@@ -68,9 +65,6 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries, ...@@ -68,9 +65,6 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,
"function %x is our of supported range", "function %x is our of supported range",
entry->function); entry->function);
TEST_ASSERT(evmcs_expected || (entry->function != 0x4000000A),
"0x4000000A leaf should not be reported");
TEST_ASSERT(entry->index == 0, TEST_ASSERT(entry->index == 0,
".index field should be zero"); ".index field should be zero");
...@@ -97,8 +91,20 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries, ...@@ -97,8 +91,20 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,
"NoNonArchitecturalCoreSharing bit" "NoNonArchitecturalCoreSharing bit"
" doesn't reflect SMT setting"); " doesn't reflect SMT setting");
break; break;
} case 0x4000000A:
TEST_ASSERT(entry->eax & (1UL << 19),
"Enlightened MSR-Bitmap should always be supported"
" 0x40000000.EAX: %x", entry->eax);
if (evmcs_expected)
TEST_ASSERT((entry->eax & 0xffff) == 0x101,
"Supported Enlightened VMCS version range is supposed to be 1:1"
" 0x40000000.EAX: %x", entry->eax);
break;
default:
break;
}
/* /*
* If needed for debug: * If needed for debug:
* fprintf(stdout, * fprintf(stdout,
...@@ -107,7 +113,6 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries, ...@@ -107,7 +113,6 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,
* entry->edx); * entry->edx);
*/ */
} }
} }
void test_hv_cpuid_e2big(struct kvm_vm *vm, bool system) void test_hv_cpuid_e2big(struct kvm_vm *vm, bool system)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment