@@ -429,6 +429,7 @@
#define MSR_CORE_PERF_GLOBAL_STATUS 0x0000038e
#define MSR_CORE_PERF_GLOBAL_CTRL 0x0000038f
#define MSR_CORE_PERF_GLOBAL_OVF_CTRL 0x00000390
+#define MSR_CORE_PERF_GLOBAL_STATUS_SET 0x00000391
/* PERF_GLOBAL_OVF_CTRL bits */
#define MSR_CORE_PERF_GLOBAL_OVF_CTRL_LBR_FREEZE (1ULL << 58)
@@ -350,6 +350,14 @@ static void check_counter_overflow(void)
status = rdmsr(pmu.msr_global_status);
report(!(status & (1ull << idx)), "status clear-%d", i);
report(check_irq() == (i % 2), "irq-%d", i);
+ if (pmu.version >= 4) {
+ wrmsr(MSR_CORE_PERF_GLOBAL_STATUS_SET, 1ull << idx);
+ status = rdmsr(pmu.msr_global_status);
+ report(status & (1ull << idx), "status set-%d", i);
+ wrmsr(pmu.msr_global_status_clr, 1ull << idx);
+ status = rdmsr(pmu.msr_global_status);
+ report(!(status & (1ull << idx)), "status set clear-%d", i);
+ }
}
report_prefix_pop();
The IA32_PERF_GLOBAL_STATUS_SET MSR is introduced with arch PMU v4. It allows software to set individual bits in IA32_PERF_GLOBAL_STATUS MSR. This commit adds the test case for this MSR. When global status is cleared at counter overflow, guest write PERF_GLOBAL_STATUS_SET MSR to set the counter overflow bit, then check this counter's overflow bit in IA32_PERF_GLOABAL_STATUS MSR. Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> --- lib/x86/msr.h | 1 + x86/pmu.c | 8 ++++++++ 2 files changed, 9 insertions(+)