diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-08-14 12:02:41 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-08-15 09:16:02 +0200 |
commit | 65efa61dc0d536d5f0602c33ee805a57cc07e9dc (patch) | |
tree | 6794e51c0a6fa5da3fecb33f9642b7a08b2c05a1 /tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | |
parent | selftests: kvm: do not try running the VM in vmx_set_nested_state_test (diff) | |
download | linux-dev-65efa61dc0d536d5f0602c33ee805a57cc07e9dc.tar.xz linux-dev-65efa61dc0d536d5f0602c33ee805a57cc07e9dc.zip |
selftests: kvm: provide common function to enable eVMCS
There are two tests already enabling eVMCS and a third is coming.
Add a function that enables the capability and tests the result.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c')
-rw-r--r-- | tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c index f72b3043db0e..ee59831fbc98 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c @@ -18,6 +18,7 @@ #include "test_util.h" #include "kvm_util.h" #include "processor.h" +#include "vmx.h" #define VCPU_ID 0 @@ -106,12 +107,7 @@ int main(int argc, char *argv[]) { struct kvm_vm *vm; int rv; - uint16_t evmcs_ver; struct kvm_cpuid2 *hv_cpuid_entries; - struct kvm_enable_cap enable_evmcs_cap = { - .cap = KVM_CAP_HYPERV_ENLIGHTENED_VMCS, - .args[0] = (unsigned long)&evmcs_ver - }; /* Tell stdout not to buffer its content */ setbuf(stdout, NULL); @@ -136,14 +132,14 @@ int main(int argc, char *argv[]) free(hv_cpuid_entries); - rv = _vcpu_ioctl(vm, VCPU_ID, KVM_ENABLE_CAP, &enable_evmcs_cap); - - if (rv) { + if (!kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) { fprintf(stderr, "Enlightened VMCS is unsupported, skip related test\n"); goto vm_free; } + vcpu_enable_evmcs(vm, VCPU_ID); + hv_cpuid_entries = kvm_get_supported_hv_cpuid(vm); if (!hv_cpuid_entries) return 1; |