aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Hankland <ehankland@google.com>2020-02-03 17:25:04 -0800
committerPaolo Bonzini <pbonzini@redhat.com>2020-02-05 16:47:17 +0100
commitddade902bc4c4473cadbd38a584e8cc9d3f18d55 (patch)
tree8f250754ec17bbd52c5bf09d1b590ae06ef124dd
parent97b5f9553a48a15296462dc4c6170200b0dd70b8 (diff)
downloadkvm-unit-tests-ddade902bc4c4473cadbd38a584e8cc9d3f18d55.tar.gz
x86: pmu: Test WRMSR on a running counter
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> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--x86/pmu.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/x86/pmu.c b/x86/pmu.c
index a4e483b..c8096b8 100644
--- a/x86/pmu.c
+++ b/x86/pmu.c
@@ -420,6 +420,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(evt.count < gp_events[1].min, "running counter wrmsr");
+}
+
int main(int ac, char **av)
{
struct cpuid id = cpuid(10);
@@ -454,6 +469,7 @@ int main(int ac, char **av)
check_counters_many();
check_counter_overflow();
check_gp_counter_cmask();
+ check_running_counter_wrmsr();
return report_summary();
}