]> git.itanic.dy.fi Git - linux-stable/commitdiff
KVM: selftests: Make Hyper-V tests explicitly require KVM Hyper-V support
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 5 Dec 2023 10:36:23 +0000 (11:36 +0100)
committerSean Christopherson <seanjc@google.com>
Thu, 7 Dec 2023 17:34:36 +0000 (09:34 -0800)
In preparation for conditional Hyper-V emulation enablement in KVM, make
Hyper-V specific tests skip gracefully instead of failing when KVM support
for emulating Hyper-V is not there.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Tested-by: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://lore.kernel.org/r/20231205103630.1391318-10-vkuznets@redhat.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86_64/hyperv_clock.c
tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c
tools/testing/selftests/kvm/x86_64/hyperv_features.c
tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c

index f25749eaa6a84bb16f0405fdf8847ace33ce04ce..f5e1e98f04f9ef0a00f3d80ba8a0bd94f90feffd 100644 (file)
@@ -211,6 +211,8 @@ int main(void)
        vm_vaddr_t tsc_page_gva;
        int stage;
 
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_TIME));
+
        vm = vm_create_with_one_vcpu(&vcpu, guest_main);
 
        vcpu_set_hv_cpuid(vcpu);
index 7bde0c4dfdbd18b769a2580c68c2e789a7a692a6..4c7257ecd2a68ce6fec6c9b93f8ae83afc6e7867 100644 (file)
@@ -240,11 +240,12 @@ int main(int argc, char *argv[])
        struct ucall uc;
        int stage;
 
-       vm = vm_create_with_one_vcpu(&vcpu, guest_code);
-
        TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
        TEST_REQUIRE(kvm_has_cap(KVM_CAP_NESTED_STATE));
        TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS));
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_DIRECT_TLBFLUSH));
+
+       vm = vm_create_with_one_vcpu(&vcpu, guest_code);
 
        hcall_page = vm_vaddr_alloc_pages(vm, 1);
        memset(addr_gva2hva(vm, hcall_page), 0x0,  getpagesize());
index e036db1f32b9b33d99e0cbb55b349b87dbcdb6ef..949e08e98f31585a41f5d5ccd5bfb0bab3de0de9 100644 (file)
@@ -43,6 +43,8 @@ int main(void)
        uint64_t *outval;
        struct ucall uc;
 
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_CPUID));
+
        /* Verify if extended hypercalls are supported */
        if (!kvm_cpuid_has(kvm_get_supported_hv_cpuid(),
                           HV_ENABLE_EXTENDED_HYPERCALLS)) {
index 9f28aa276c4e23608f22cb97c2fd5f4a84084988..387c605a30772b3160fd98c10ff6e6f4d7e69a90 100644 (file)
@@ -690,6 +690,8 @@ static void guest_test_hcalls_access(void)
 
 int main(void)
 {
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_ENFORCE_CPUID));
+
        pr_info("Testing access to Hyper-V specific MSRs\n");
        guest_test_msrs_access();
 
index 6feb5ddb031dac66aeabe18b7733f8639f29af63..65e5f4c05068a8fff78caf386f76ef107ac407f2 100644 (file)
@@ -248,6 +248,8 @@ int main(int argc, char *argv[])
        int stage = 1, r;
        struct ucall uc;
 
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_SEND_IPI));
+
        vm = vm_create_with_one_vcpu(&vcpu[0], sender_guest_code);
 
        /* Hypercall input/output */
index 6c127856209065f5345ff2590383e532891467fe..c9b18707edc03113db996d127342b4b6bfade843 100644 (file)
@@ -158,6 +158,7 @@ int main(int argc, char *argv[])
        int stage;
 
        TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_DIRECT_TLBFLUSH));
 
        /* Create VM */
        vm = vm_create_with_one_vcpu(&vcpu, guest_code);
index 4758b6ef5618e387d3a838908e78d2e51af79fa7..c4443f71f8dd01f6aafde337c618d414c61c1ce3 100644 (file)
@@ -590,6 +590,8 @@ int main(int argc, char *argv[])
        struct ucall uc;
        int stage = 1, r, i;
 
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_TLBFLUSH));
+
        vm = vm_create_with_one_vcpu(&vcpu[0], sender_guest_code);
 
        /* Test data page */