Message ID | 20220609083916.36658-3-weijiang.yang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix up test failures induced by !enable_pmu | expand |
On 9/6/2022 4:39 pm, Yang Weijiang wrote:
> + perf_cap = rdmsr(MSR_IA32_PERF_CAPABILITIES);
Nit, check the PDCM bit before accessing this MSR.
On 6/10/2022 7:57 AM, Like Xu wrote: > On 9/6/2022 4:39 pm, Yang Weijiang wrote: >> + perf_cap = rdmsr(MSR_IA32_PERF_CAPABILITIES); > > Nit, check the PDCM bit before accessing this MSR. Thanks, I'll add the check.
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();
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(-)