public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Hankland <ehankland@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Jim Mattson <jmattson@google.com>,
	Peter Shier <pshier@google.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	Eric Hankland <ehankland@google.com>
Subject: [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter
Date: Mon,  3 Feb 2020 17:25:04 -0800	[thread overview]
Message-ID: <20200204012504.9590-1-ehankland@google.com> (raw)

Ensure that the value of the counter was successfully set to 0 after
writing it while the counter was running.

Signed-off-by: Eric Hankland <ehankland@google.com>
---
 x86/pmu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/x86/pmu.c b/x86/pmu.c
index cb8c9e3..8a77993 100644
--- a/x86/pmu.c
+++ b/x86/pmu.c
@@ -419,6 +419,21 @@ static void check_rdpmc(void)
 	report_prefix_pop();
 }
 
+static void check_running_counter_wrmsr(void)
+{
+	pmu_counter_t evt = {
+		.ctr = MSR_IA32_PERFCTR0,
+		.config = EVNTSEL_OS | EVNTSEL_USR | gp_events[1].unit_sel,
+		.count = 0,
+	};
+
+	start_event(&evt);
+	loop();
+	wrmsr(MSR_IA32_PERFCTR0, 0);
+	stop_event(&evt);
+	report("running counter wrmsr", evt.count < gp_events[1].min);
+}
+
 int main(int ac, char **av)
 {
 	struct cpuid id = cpuid(10);
@@ -453,6 +468,7 @@ int main(int ac, char **av)
 	check_counters_many();
 	check_counter_overflow();
 	check_gp_counter_cmask();
+	check_running_counter_wrmsr();
 
 	return report_summary();
 }


             reply	other threads:[~2020-02-04  1:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04  1:25 Eric Hankland [this message]
2020-02-05 11:45 ` [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter Vitaly Kuznetsov
2020-02-05 14:56 ` Paolo Bonzini

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=20200204012504.9590-1-ehankland@google.com \
    --to=ehankland@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=pshier@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox