* [PATCH 0/3] selftests: kvm: improvements to VMX support check
@ 2019-10-08 19:43 Vitaly Kuznetsov
2019-10-08 19:43 ` [PATCH 1/3] selftests: kvm: vmx_set_nested_state_test: don't check for VMX support twice Vitaly Kuznetsov
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Vitaly Kuznetsov @ 2019-10-08 19:43 UTC (permalink / raw)
To: kvm; +Cc: linux-kernel, Paolo Bonzini, Sean Christopherson, Jim Mattson
vmx_dirty_log_test fails on AMD and this is no surprise as it is VMX
specific. Consolidate checks from other VMX tests into a library routine
and add a check to skip the test when !VMX.
Vitaly Kuznetsov (3):
selftests: kvm: vmx_set_nested_state_test: don't check for VMX support
twice
selftests: kvm: consolidate VMX support checks
selftests: kvm: vmx_dirty_log_test: skip the test when VMX is not
supported
tools/testing/selftests/kvm/include/x86_64/vmx.h | 2 ++
tools/testing/selftests/kvm/lib/x86_64/vmx.c | 10 ++++++++++
.../kvm/x86_64/vmx_close_while_nested_test.c | 6 +-----
.../selftests/kvm/x86_64/vmx_dirty_log_test.c | 2 ++
.../kvm/x86_64/vmx_set_nested_state_test.c | 13 ++-----------
.../selftests/kvm/x86_64/vmx_tsc_adjust_test.c | 6 +-----
6 files changed, 18 insertions(+), 21 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 1/3] selftests: kvm: vmx_set_nested_state_test: don't check for VMX support twice 2019-10-08 19:43 [PATCH 0/3] selftests: kvm: improvements to VMX support check Vitaly Kuznetsov @ 2019-10-08 19:43 ` Vitaly Kuznetsov 2019-10-08 19:43 ` [PATCH 2/3] selftests: kvm: consolidate VMX support checks Vitaly Kuznetsov ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: Vitaly Kuznetsov @ 2019-10-08 19:43 UTC (permalink / raw) To: kvm; +Cc: linux-kernel, Paolo Bonzini, Sean Christopherson, Jim Mattson vmx_set_nested_state_test() checks if VMX is supported twice: in the very beginning (and skips the whole test if it's not) and before doing test_vmx_nested_state(). One should be enough. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- .../selftests/kvm/x86_64/vmx_set_nested_state_test.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c b/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c index 853e370e8a39..a6d85614ae4d 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c @@ -271,12 +271,7 @@ int main(int argc, char *argv[]) state.flags = KVM_STATE_NESTED_RUN_PENDING; test_nested_state_expect_einval(vm, &state); - /* - * TODO: When SVM support is added for KVM_SET_NESTED_STATE - * add tests here to support it like VMX. - */ - if (entry->ecx & CPUID_VMX) - test_vmx_nested_state(vm); + test_vmx_nested_state(vm); kvm_vm_free(vm); return 0; -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] selftests: kvm: consolidate VMX support checks 2019-10-08 19:43 [PATCH 0/3] selftests: kvm: improvements to VMX support check Vitaly Kuznetsov 2019-10-08 19:43 ` [PATCH 1/3] selftests: kvm: vmx_set_nested_state_test: don't check for VMX support twice Vitaly Kuznetsov @ 2019-10-08 19:43 ` Vitaly Kuznetsov 2019-10-08 19:43 ` [PATCH 3/3] selftests: kvm: vmx_dirty_log_test: skip the test when VMX is not supported Vitaly Kuznetsov 2019-10-09 8:07 ` [PATCH 0/3] selftests: kvm: improvements to VMX support check Paolo Bonzini 3 siblings, 0 replies; 5+ messages in thread From: Vitaly Kuznetsov @ 2019-10-08 19:43 UTC (permalink / raw) To: kvm; +Cc: linux-kernel, Paolo Bonzini, Sean Christopherson, Jim Mattson vmx_* tests require VMX and three of them implement the same check. Move it to vmx library. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- tools/testing/selftests/kvm/include/x86_64/vmx.h | 2 ++ tools/testing/selftests/kvm/lib/x86_64/vmx.c | 10 ++++++++++ .../selftests/kvm/x86_64/vmx_close_while_nested_test.c | 6 +----- .../selftests/kvm/x86_64/vmx_set_nested_state_test.c | 6 +----- .../testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c | 6 +----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/kvm/include/x86_64/vmx.h b/tools/testing/selftests/kvm/include/x86_64/vmx.h index 6ae5a47fe067..f52e0ba84fed 100644 --- a/tools/testing/selftests/kvm/include/x86_64/vmx.h +++ b/tools/testing/selftests/kvm/include/x86_64/vmx.h @@ -580,6 +580,8 @@ bool prepare_for_vmx_operation(struct vmx_pages *vmx); void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip, void *guest_rsp); bool load_vmcs(struct vmx_pages *vmx); +void nested_vmx_check_supported(void); + void nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm, uint64_t nested_paddr, uint64_t paddr, uint32_t eptp_memslot); void nested_map(struct vmx_pages *vmx, struct kvm_vm *vm, diff --git a/tools/testing/selftests/kvm/lib/x86_64/vmx.c b/tools/testing/selftests/kvm/lib/x86_64/vmx.c index fab8f6b0bf52..f6ec97b7eaef 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/vmx.c +++ b/tools/testing/selftests/kvm/lib/x86_64/vmx.c @@ -376,6 +376,16 @@ void prepare_vmcs(struct vmx_pages *vmx, void *guest_rip, void *guest_rsp) init_vmcs_guest_state(guest_rip, guest_rsp); } +void nested_vmx_check_supported(void) +{ + struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); + + if (!(entry->ecx & CPUID_VMX)) { + fprintf(stderr, "nested VMX not enabled, skipping test\n"); + exit(KSFT_SKIP); + } +} + void nested_pg_map(struct vmx_pages *vmx, struct kvm_vm *vm, uint64_t nested_paddr, uint64_t paddr, uint32_t eptp_memslot) { diff --git a/tools/testing/selftests/kvm/x86_64/vmx_close_while_nested_test.c b/tools/testing/selftests/kvm/x86_64/vmx_close_while_nested_test.c index 3b0ffe01dacd..5dfb53546a26 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_close_while_nested_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_close_while_nested_test.c @@ -53,12 +53,8 @@ static void l1_guest_code(struct vmx_pages *vmx_pages) int main(int argc, char *argv[]) { vm_vaddr_t vmx_pages_gva; - struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); - if (!(entry->ecx & CPUID_VMX)) { - fprintf(stderr, "nested VMX not enabled, skipping test\n"); - exit(KSFT_SKIP); - } + nested_vmx_check_supported(); vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code); vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); diff --git a/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c b/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c index a6d85614ae4d..9ef7fab39d48 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c @@ -224,7 +224,6 @@ int main(int argc, char *argv[]) { struct kvm_vm *vm; struct kvm_nested_state state; - struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); have_evmcs = kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS); @@ -237,10 +236,7 @@ int main(int argc, char *argv[]) * AMD currently does not implement set_nested_state, so for now we * just early out. */ - if (!(entry->ecx & CPUID_VMX)) { - fprintf(stderr, "nested VMX not enabled, skipping test\n"); - exit(KSFT_SKIP); - } + nested_vmx_check_supported(); vm = vm_create_default(VCPU_ID, 0, 0); diff --git a/tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c b/tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c index f36c10eba71e..5590fd2bcf87 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c @@ -128,12 +128,8 @@ static void report(int64_t val) int main(int argc, char *argv[]) { vm_vaddr_t vmx_pages_gva; - struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); - if (!(entry->ecx & CPUID_VMX)) { - fprintf(stderr, "nested VMX not enabled, skipping test\n"); - exit(KSFT_SKIP); - } + nested_vmx_check_supported(); vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code); vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] selftests: kvm: vmx_dirty_log_test: skip the test when VMX is not supported 2019-10-08 19:43 [PATCH 0/3] selftests: kvm: improvements to VMX support check Vitaly Kuznetsov 2019-10-08 19:43 ` [PATCH 1/3] selftests: kvm: vmx_set_nested_state_test: don't check for VMX support twice Vitaly Kuznetsov 2019-10-08 19:43 ` [PATCH 2/3] selftests: kvm: consolidate VMX support checks Vitaly Kuznetsov @ 2019-10-08 19:43 ` Vitaly Kuznetsov 2019-10-09 8:07 ` [PATCH 0/3] selftests: kvm: improvements to VMX support check Paolo Bonzini 3 siblings, 0 replies; 5+ messages in thread From: Vitaly Kuznetsov @ 2019-10-08 19:43 UTC (permalink / raw) To: kvm; +Cc: linux-kernel, Paolo Bonzini, Sean Christopherson, Jim Mattson vmx_dirty_log_test fails on AMD and this is no surprise as it is VMX specific. Bail early when nested VMX is unsupported. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c b/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c index 0bca1cfe2c1e..a223a6401258 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c @@ -78,6 +78,8 @@ int main(int argc, char *argv[]) struct ucall uc; bool done = false; + nested_vmx_check_supported(); + /* Create VM */ vm = vm_create_default(VCPU_ID, 0, l1_guest_code); vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] selftests: kvm: improvements to VMX support check 2019-10-08 19:43 [PATCH 0/3] selftests: kvm: improvements to VMX support check Vitaly Kuznetsov ` (2 preceding siblings ...) 2019-10-08 19:43 ` [PATCH 3/3] selftests: kvm: vmx_dirty_log_test: skip the test when VMX is not supported Vitaly Kuznetsov @ 2019-10-09 8:07 ` Paolo Bonzini 3 siblings, 0 replies; 5+ messages in thread From: Paolo Bonzini @ 2019-10-09 8:07 UTC (permalink / raw) To: Vitaly Kuznetsov, kvm; +Cc: linux-kernel, Sean Christopherson, Jim Mattson On 08/10/19 21:43, Vitaly Kuznetsov wrote: > vmx_dirty_log_test fails on AMD and this is no surprise as it is VMX > specific. Consolidate checks from other VMX tests into a library routine > and add a check to skip the test when !VMX. > > Vitaly Kuznetsov (3): > selftests: kvm: vmx_set_nested_state_test: don't check for VMX support > twice > selftests: kvm: consolidate VMX support checks > selftests: kvm: vmx_dirty_log_test: skip the test when VMX is not > supported > > tools/testing/selftests/kvm/include/x86_64/vmx.h | 2 ++ > tools/testing/selftests/kvm/lib/x86_64/vmx.c | 10 ++++++++++ > .../kvm/x86_64/vmx_close_while_nested_test.c | 6 +----- > .../selftests/kvm/x86_64/vmx_dirty_log_test.c | 2 ++ > .../kvm/x86_64/vmx_set_nested_state_test.c | 13 ++----------- > .../selftests/kvm/x86_64/vmx_tsc_adjust_test.c | 6 +----- > 6 files changed, 18 insertions(+), 21 deletions(-) > Queued, thanks. Paolo ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-10-09 8:07 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-10-08 19:43 [PATCH 0/3] selftests: kvm: improvements to VMX support check Vitaly Kuznetsov 2019-10-08 19:43 ` [PATCH 1/3] selftests: kvm: vmx_set_nested_state_test: don't check for VMX support twice Vitaly Kuznetsov 2019-10-08 19:43 ` [PATCH 2/3] selftests: kvm: consolidate VMX support checks Vitaly Kuznetsov 2019-10-08 19:43 ` [PATCH 3/3] selftests: kvm: vmx_dirty_log_test: skip the test when VMX is not supported Vitaly Kuznetsov 2019-10-09 8:07 ` [PATCH 0/3] selftests: kvm: improvements to VMX support check Paolo Bonzini
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox