From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Cc: Anirudh Rayabharam <anrayabh@linux.microsoft.com>,
Sean Christopherson <seanjc@google.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 07/11] KVM: selftests: Switch to KVM_CAP_HYPERV_ENLIGHTENED_VMCS2
Date: Tue, 21 Jun 2022 17:58:26 +0200 [thread overview]
Message-ID: <20220621155830.60115-8-vkuznets@redhat.com> (raw)
In-Reply-To: <20220621155830.60115-1-vkuznets@redhat.com>
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(-)
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index cdaea2383543..3b5d25d6baae 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -348,6 +348,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)
{
diff --git a/tools/testing/selftests/kvm/include/x86_64/evmcs.h b/tools/testing/selftests/kvm/include/x86_64/evmcs.h
index 3c9260f8e116..b6d6c73f68dc 100644
--- a/tools/testing/selftests/kvm/include/x86_64/evmcs.h
+++ b/tools/testing/selftests/kvm/include/x86_64/evmcs.h
@@ -17,6 +17,7 @@
#define u64 uint64_t
#define EVMCS_VERSION 1
+#define EVMCS_REVISION 1
extern bool enable_evmcs;
diff --git a/tools/testing/selftests/kvm/lib/x86_64/vmx.c b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
index 381432741df4..1a0b9334f8d4 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/vmx.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
@@ -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)) &&
diff --git a/tools/testing/selftests/kvm/x86_64/evmcs_test.c b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
index 8dda527cc080..a546d1cad146 100644
--- a/tools/testing/selftests/kvm/x86_64/evmcs_test.c
+++ b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
@@ -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);
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
index cbd4a7d36189..f19859f1956e 100644
--- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
+++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
@@ -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;
}
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 b564b86dfc1d..b624a08a5574 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
@@ -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));
--
2.35.3
next prev parent reply other threads:[~2022-06-21 16:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 15:58 [PATCH 00/11] KVM: VMX: Support TscScaling and EnclsExitingBitmap whith eVMCS Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 01/11] KVM: x86: hyper-v: Expose access to debug MSRs in the partition privilege flags Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 02/11] x86/hyperv: Fix 'struct hv_enlightened_vmcs' definition Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 03/11] x86/hyperv: Update " Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 04/11] KVM: VMX: Define VMCS-to-EVMCS conversion for the new fields Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 05/11] KVM: nVMX: Support several new fields in eVMCSv1 Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 06/11] KVM: nVMX: Introduce KVM_CAP_HYPERV_ENLIGHTENED_VMCS2 Vitaly Kuznetsov
2022-06-21 15:58 ` Vitaly Kuznetsov [this message]
2022-06-21 15:58 ` [PATCH 08/11] KVM: VMX: Support TSC scaling with enlightened VMCS Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 09/11] KVM: selftests: Add ENCLS_EXITING_BITMAP{,HIGH} VMCS fields Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 10/11] KVM: selftests: Switch to updated eVMCSv1 definition Vitaly Kuznetsov
2022-06-21 15:58 ` [PATCH 11/11] KVM: selftests: Enable TSC scaling in evmcs selftest Vitaly Kuznetsov
2022-06-21 15:59 ` [PATCH QEMU EXAMPLE] i386: Support Enlightened VMCS revisions Vitaly Kuznetsov
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=20220621155830.60115-8-vkuznets@redhat.com \
--to=vkuznets@redhat.com \
--cc=anrayabh@linux.microsoft.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=wanpengli@tencent.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