@@ -406,6 +406,14 @@ static inline void vcpu_enable_cap(struct kvm_vcpu *vcpu, uint32_t cap,
vcpu_ioctl(vcpu, KVM_ENABLE_CAP, &enable_cap);
}
+static inline void vcpu_enable_cap2(struct kvm_vcpu *vcpu, uint32_t cap,
+ uint64_t arg0, uint64_t arg1)
+{
+ struct kvm_enable_cap enable_cap = { .cap = cap, .args = { arg0, arg1 } };
+
+ vcpu_ioctl(vcpu, KVM_ENABLE_CAP, &enable_cap);
+}
+
static inline void vcpu_guest_debug_set(struct kvm_vcpu *vcpu,
struct kvm_guest_debug *debug)
{
@@ -17,6 +17,7 @@
#define u64 uint64_t
#define EVMCS_VERSION 1
+#define EVMCS_REVISION 1
extern bool enable_evmcs;
@@ -42,12 +42,13 @@ struct eptPageTablePointer {
uint64_t address:40;
uint64_t reserved_63_52:12;
};
+
int vcpu_enable_evmcs(struct kvm_vcpu *vcpu)
{
uint16_t evmcs_ver;
- vcpu_enable_cap(vcpu, KVM_CAP_HYPERV_ENLIGHTENED_VMCS,
- (unsigned long)&evmcs_ver);
+ vcpu_enable_cap2(vcpu, KVM_CAP_HYPERV_ENLIGHTENED_VMCS2,
+ EVMCS_REVISION, (unsigned long)&evmcs_ver);
/* KVM should return supported EVMCS version range */
TEST_ASSERT(((evmcs_ver >> 8) >= (evmcs_ver & 0xff)) &&
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
TEST_REQUIRE(nested_vmx_supported());
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_ENLIGHTENED_VMCS2));
vcpu_set_hv_cpuid(vcpu);
vcpu_enable_evmcs(vcpu);
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
free(hv_cpuid_entries);
if (!nested_vmx_supported() ||
- !kvm_has_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) {
+ !kvm_has_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS2)) {
print_skip("Enlightened VMCS is unsupported");
goto do_sys;
}
@@ -265,7 +265,7 @@ int main(int argc, char *argv[])
struct kvm_nested_state state;
struct kvm_vcpu *vcpu;
- have_evmcs = kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS);
+ have_evmcs = kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS2);
TEST_REQUIRE(kvm_has_cap(KVM_CAP_NESTED_STATE));
KVM_CAP_HYPERV_ENLIGHTENED_VMCS was obsoleted by KVM_CAP_HYPERV_ENLIGHTENED_VMCS2, use it in selftests. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- tools/testing/selftests/kvm/include/kvm_util_base.h | 8 ++++++++ tools/testing/selftests/kvm/include/x86_64/evmcs.h | 1 + tools/testing/selftests/kvm/lib/x86_64/vmx.c | 5 +++-- tools/testing/selftests/kvm/x86_64/evmcs_test.c | 2 +- tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 2 +- .../selftests/kvm/x86_64/vmx_set_nested_state_test.c | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-)