OSDN Git Service

perf/x86: Fix out of bound MSR access
authorPeter Zijlstra <peterz@infradead.org>
Thu, 29 Jul 2021 09:14:57 +0000 (11:14 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 4 Aug 2021 13:16:33 +0000 (15:16 +0200)
commitf4b4b45652578357031fbbef7f7a1b04f6fa2dc3
tree962fc386974a3c2b13c1f0664ad24f3f9f7fc0aa
parentb068fc04de10fff8974f6ef32b861ad134d94ba4
perf/x86: Fix out of bound MSR access

On Wed, Jul 28, 2021 at 12:49:43PM -0400, Vince Weaver wrote:
> [32694.087403] unchecked MSR access error: WRMSR to 0x318 (tried to write 0x0000000000000000) at rIP: 0xffffffff8106f854 (native_write_msr+0x4/0x20)
> [32694.101374] Call Trace:
> [32694.103974]  perf_clear_dirty_counters+0x86/0x100

The problem being that it doesn't filter out all fake counters, in
specific the above (erroneously) tries to use FIXED_BTS. Limit the
fixed counters indexes to the hardware supplied number.

Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Vince Weaver <vincent.weaver@maine.edu>
Tested-by: Like Xu <likexu@tencent.com>
Link: https://lkml.kernel.org/r/YQJxka3dxgdIdebG@hirez.programming.kicks-ass.net
arch/x86/events/core.c