public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Yang Weijiang <weijiang.yang@intel.com>
To: pbonzini@redhat.com
Cc: kvm@vger.kernel.org, Yang Weijiang <weijiang.yang@intel.com>
Subject: [kvm-unit-tests PATCH 2/3] x86: Skip running test when pmu is disabled
Date: Thu,  9 Jun 2022 04:39:15 -0400	[thread overview]
Message-ID: <20220609083916.36658-3-weijiang.yang@intel.com> (raw)
In-Reply-To: <20220609083916.36658-1-weijiang.yang@intel.com>

Read MSR_IA32_PERF_CAPABILITIES triggers #GP when pmu is disabled
by enable_pmu=0 in KVM. Let's check whether pmu is available before
issue msr reading to avoid the #GP.

Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
 x86/pmu_lbr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/x86/pmu_lbr.c b/x86/pmu_lbr.c
index 688634d..835a7bb 100644
--- a/x86/pmu_lbr.c
+++ b/x86/pmu_lbr.c
@@ -74,13 +74,15 @@ int main(int ac, char **av)
 		return 0;
 	}
 
-	perf_cap = rdmsr(MSR_IA32_PERF_CAPABILITIES);
 	eax.full = id.a;
 
 	if (!eax.split.version_id) {
 		printf("No pmu is detected!\n");
 		return report_summary();
 	}
+
+	perf_cap = rdmsr(MSR_IA32_PERF_CAPABILITIES);
+
 	if (!(perf_cap & PMU_CAP_LBR_FMT)) {
 		printf("No LBR is detected!\n");
 		return report_summary();
-- 
2.31.1


  parent reply	other threads:[~2022-06-09  8:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09  8:39 [kvm-unit-tests PATCH 0/3] Fix up test failures induced by !enable_pmu Yang Weijiang
2022-06-09  8:39 ` [kvm-unit-tests PATCH 1/3] x86: Remove perf enable bit from default config Yang Weijiang
2022-06-09  8:39 ` Yang Weijiang [this message]
2022-06-09 23:57   ` [kvm-unit-tests PATCH 2/3] x86: Skip running test when pmu is disabled Like Xu
2022-06-10  1:40     ` Yang, Weijiang
2022-06-09  8:39 ` [kvm-unit-tests PATCH 3/3] x86: Skip perf related tests " Yang Weijiang
2022-06-10  0:14   ` Like Xu
2022-06-10  1:47     ` Yang, Weijiang
2022-06-10  2:24       ` Jim Mattson
2022-06-10  2:48         ` Like Xu
2022-06-10  4:16           ` Jim Mattson
2022-06-10  4:22             ` Jim Mattson
2022-06-10  4:56               ` Like Xu
2022-06-10  6:03                 ` Yang, Weijiang
2022-06-10  0:02 ` [kvm-unit-tests PATCH 0/3] Fix up test failures induced by !enable_pmu Like Xu
2022-06-10  6:29   ` 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=20220609083916.36658-3-weijiang.yang@intel.com \
    --to=weijiang.yang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.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