perf/x86/lbr: Reset LBR_SELECT during vlbr reset
authorWanpeng Li <wanpengli@tencent.com>
Fri, 5 Nov 2021 07:20:51 +0000 (00:20 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 11 Nov 2021 12:09:34 +0000 (13:09 +0100)
lbr_select in kvm guest has residual data even if kvm guest is poweroff.
We can get residual data in the next boot. Because lbr_select is not
reset during kvm vlbr release. Let's reset LBR_SELECT during vlbr reset.

Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1636096851-36623-1-git-send-email-wanpengli@tencent.com
arch/x86/events/intel/lbr.c

index 6b72e9b55c69cfebd0d3f2ccae93df46f727e17d..8043213b75a52f7082551da414cc25b765c2f3eb 100644 (file)
@@ -265,6 +265,8 @@ void intel_pmu_lbr_reset(void)
 
        cpuc->last_task_ctx = NULL;
        cpuc->last_log_id = 0;
+       if (!static_cpu_has(X86_FEATURE_ARCH_LBR) && cpuc->lbr_select)
+               wrmsrl(MSR_LBR_SELECT, 0);
 }
 
 /*