From: Maxim Levitsky <mlevitsk@redhat.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>,
kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/14] KVM: selftests: Make all Hyper-V tests explicitly dependent on Hyper-V emulation support in KVM
Date: Tue, 07 Nov 2023 20:23:32 +0200 [thread overview]
Message-ID: <5aea3131a1166e30e12f9a5ef490327607219193.camel@redhat.com> (raw)
In-Reply-To: <20231025152406.1879274-9-vkuznets@redhat.com>
On Wed, 2023-10-25 at 17:24 +0200, Vitaly Kuznetsov wrote:
> In preparation for conditional Hyper-V emulation enablement in KVM, make
> Hyper-V specific tests check skip gracefully instead of failing when the
> support is not there.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
> tools/testing/selftests/kvm/x86_64/hyperv_clock.c | 2 ++
> tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c | 5 +++--
> .../selftests/kvm/x86_64/hyperv_extended_hypercalls.c | 2 ++
> tools/testing/selftests/kvm/x86_64/hyperv_features.c | 2 ++
> tools/testing/selftests/kvm/x86_64/hyperv_ipi.c | 2 ++
> tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c | 1 +
> tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c | 2 ++
> 7 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_clock.c b/tools/testing/selftests/kvm/x86_64/hyperv_clock.c
> index f25749eaa6a8..f5e1e98f04f9 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_clock.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_clock.c
> @@ -211,6 +211,8 @@ int main(void)
> vm_vaddr_t tsc_page_gva;
> int stage;
>
> + TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_TIME));
> +
Makes sense.
> vm = vm_create_with_one_vcpu(&vcpu, guest_main);
>
> vcpu_set_hv_cpuid(vcpu);
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c b/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
> index 7bde0c4dfdbd..4c7257ecd2a6 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
> @@ -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));
The test indeed uses the direct TLB flush.
It might be a good idea in the future to rename the test to hyperv_nested_vmx or something like
that because it tests more than just the evmcs.
It's not urgent though.
> +
> + 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());
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c b/tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c
> index e036db1f32b9..949e08e98f31 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c
> @@ -43,6 +43,8 @@ int main(void)
> uint64_t *outval;
> struct ucall uc;
>
> + TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_CPUID));
Yep, the test uses KVM_GET_SUPPORTED_HV_CPUID.
> +
> /* Verify if extended hypercalls are supported */
> if (!kvm_cpuid_has(kvm_get_supported_hv_cpuid(),
> HV_ENABLE_EXTENDED_HYPERCALLS)) {
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_features.c b/tools/testing/selftests/kvm/x86_64/hyperv_features.c
> index 9f28aa276c4e..387c605a3077 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_features.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_features.c
> @@ -690,6 +690,8 @@ static void guest_test_hcalls_access(void)
>
> int main(void)
> {
> + TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_ENFORCE_CPUID));
> +
Correct.
> pr_info("Testing access to Hyper-V specific MSRs\n");
> guest_test_msrs_access();
>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c b/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
> index 6feb5ddb031d..65e5f4c05068 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
> @@ -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));
Correct.
> +
> vm = vm_create_with_one_vcpu(&vcpu[0], sender_guest_code);
>
> /* Hypercall input/output */
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
> index 6c1278562090..c9b18707edc0 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
> @@ -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));
Maybe also rename the test in the future to hyperv_nested_svm or something like that,
for the same reason.
>
> /* Create VM */
> vm = vm_create_with_one_vcpu(&vcpu, guest_code);
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c b/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
> index 4758b6ef5618..c4443f71f8dd 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
> @@ -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));
Also makes sense.
> +
> vm = vm_create_with_one_vcpu(&vcpu[0], sender_guest_code);
>
> /* Test data page */
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Best regards,
Maxim Levitsky
next prev parent reply other threads:[~2023-11-07 18:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 15:23 [PATCH 00/14] KVM: x86: Make Hyper-V emulation optional Vitaly Kuznetsov
2023-10-25 15:23 ` [PATCH 01/14] KVM: x86: xen: Remove unneeded xen context from struct kvm_arch when !CONFIG_KVM_XEN Vitaly Kuznetsov
2023-10-25 15:23 ` [PATCH 02/14] KVM: x86: hyper-v: Move Hyper-V partition assist page out of Hyper-V emulation context Vitaly Kuznetsov
2023-11-07 18:21 ` Maxim Levitsky
2023-10-25 15:23 ` [PATCH 03/14] KVM: VMX: Split off vmx_onhyperv.{ch} from hyperv.{ch} Vitaly Kuznetsov
2023-10-25 15:23 ` [PATCH 04/14] KVM: x86: hyper-v: Introduce kvm_hv_synic_auto_eoi_set() Vitaly Kuznetsov
2023-10-25 15:23 ` [PATCH 05/14] KVM: x86: hyper-v: Introduce kvm_hv_synic_has_vector() Vitaly Kuznetsov
2023-10-25 15:23 ` [PATCH 06/14] KVM: VMX: Split off hyperv_evmcs.{ch} Vitaly Kuznetsov
2023-10-25 15:23 ` [PATCH 07/14] KVM: x86: hyper-v: Introduce kvm_hv_nested_transtion_tlb_flush() helper Vitaly Kuznetsov
2023-11-07 18:21 ` Maxim Levitsky
2023-10-25 15:24 ` [PATCH 08/14] KVM: selftests: Make all Hyper-V tests explicitly dependent on Hyper-V emulation support in KVM Vitaly Kuznetsov
2023-11-07 18:23 ` Maxim Levitsky [this message]
2023-10-25 15:24 ` [PATCH 09/14] KVM: selftests: Fix vmxon_pa == vmcs12_pa == -1ull vmx_set_nested_state_test for !eVMCS case Vitaly Kuznetsov
2023-11-07 18:23 ` Maxim Levitsky
2023-10-25 15:24 ` [PATCH 10/14] KVM: x86: Make Hyper-V emulation optional Vitaly Kuznetsov
2023-11-07 18:25 ` Maxim Levitsky
2023-11-13 13:51 ` Vitaly Kuznetsov
2023-11-30 1:31 ` Sean Christopherson
2023-11-30 15:11 ` Vitaly Kuznetsov
2023-11-30 18:28 ` Sean Christopherson
2023-11-30 1:38 ` Sean Christopherson
2023-10-25 15:24 ` [PATCH 11/14] KVM: nVMX: hyper-v: Introduce nested_vmx_evmptr12() and nested_vmx_is_evmptr12_valid() helpers Vitaly Kuznetsov
2023-11-07 18:26 ` Maxim Levitsky
2023-11-30 1:24 ` Sean Christopherson
2023-11-30 19:13 ` Sean Christopherson
2023-10-25 15:24 ` [PATCH 12/14] KVM: nVMX: hyper-v: Introduce nested_vmx_evmcs() accessor Vitaly Kuznetsov
2023-10-25 15:24 ` [PATCH 13/14] KVM: nVMX: hyper-v: Hide more stuff under CONFIG_KVM_HYPERV Vitaly Kuznetsov
2023-10-25 15:24 ` [PATCH 14/14] KVM: nSVM: hyper-v: Hide more stuff under CONFIG_KVM_HYPERV/CONFIG_HYPERV Vitaly Kuznetsov
2023-11-30 1:42 ` [PATCH 00/14] KVM: x86: Make Hyper-V emulation optional Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5aea3131a1166e30e12f9a5ef490327607219193.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®