From: Yang Weijiang <weijiang.yang@intel.com>
To: pbonzini@redhat.com, seanjc@google.com
Cc: kvm@vger.kernel.org, Yang Weijiang <weijiang.yang@intel.com>
Subject: [PATCH v3 2/3] x86: Skip perf related tests when platform cannot support
Date: Fri, 24 Jun 2022 05:08:27 -0400 [thread overview]
Message-ID: <20220624090828.62191-3-weijiang.yang@intel.com> (raw)
In-Reply-To: <20220624090828.62191-1-weijiang.yang@intel.com>
Add helpers to check whether MSR_CORE_PERF_GLOBAL_CTRL and rdpmc
are supported in KVM. When pmu is disabled with enable_pmu=0,
reading MSR_CORE_PERF_GLOBAL_CTRL or executing rdpmc leads to #GP,
so skip related tests in this case to avoid test failure.
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
lib/x86/processor.h | 10 ++++++++++
x86/vmx_tests.c | 18 ++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index 9a0dad6..70b9193 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -690,4 +690,14 @@ static inline bool cpuid_osxsave(void)
return cpuid(1).c & (1 << (X86_FEATURE_OSXSAVE % 32));
}
+static inline u8 pmu_version(void)
+{
+ return cpuid(10).a & 0xff;
+}
+
+static inline bool has_perf_global_ctrl(void)
+{
+ return pmu_version() > 1;
+}
+
#endif
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 4d581e7..3cf0776 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -944,6 +944,14 @@ static void insn_intercept_main(void)
continue;
}
+ if (insn_table[cur_insn].flag == CPU_RDPMC) {
+ if (!!pmu_version()) {
+ printf("\tFeature required for %s is not supported.\n",
+ insn_table[cur_insn].name);
+ continue;
+ }
+ }
+
if (insn_table[cur_insn].disabled) {
printf("\tFeature required for %s is not supported.\n",
insn_table[cur_insn].name);
@@ -7490,6 +7498,11 @@ static void test_perf_global_ctrl(u32 nr, const char *name, u32 ctrl_nr,
static void test_load_host_perf_global_ctrl(void)
{
+ if (!has_perf_global_ctrl()) {
+ report_skip("test_load_host_perf_global_ctrl");
+ return;
+ }
+
if (!(ctrl_exit_rev.clr & EXI_LOAD_PERF)) {
printf("\"load IA32_PERF_GLOBAL_CTRL\" exit control not supported\n");
return;
@@ -7502,6 +7515,11 @@ static void test_load_host_perf_global_ctrl(void)
static void test_load_guest_perf_global_ctrl(void)
{
+ if (!has_perf_global_ctrl()) {
+ report_skip("test_load_guest_perf_global_ctrl");
+ return;
+ }
+
if (!(ctrl_enter_rev.clr & ENT_LOAD_PERF)) {
printf("\"load IA32_PERF_GLOBAL_CTRL\" entry control not supported\n");
return;
--
2.27.0
next prev parent reply other threads:[~2022-06-24 9:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-24 9:08 [kvm-unit-tests PATCH v3 0/3] Fix up test failures due to recent KVM changes Yang Weijiang
2022-06-24 9:08 ` [PATCH v3 1/3] x86: Don't overwrite bits 11 and 12 of MSR_IA32_MISC_ENABLE Yang Weijiang
2022-06-24 9:08 ` Yang Weijiang [this message]
2022-06-24 22:08 ` [PATCH v3 2/3] x86: Skip perf related tests when platform cannot support Sean Christopherson
2022-06-25 6:34 ` Yang, Weijiang
2022-06-24 9:08 ` [PATCH v3 3/3] x86: Check platform vPMU capabilities before run lbr tests Yang Weijiang
2022-06-24 22:23 ` Sean Christopherson
2022-06-25 6:38 ` Yang, Weijiang
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=20220624090828.62191-3-weijiang.yang@intel.com \
--to=weijiang.yang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.