]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf/x86/intel: Improve validation and configuration of ACR masks
authorDapeng Mi <dapeng1.mi@linux.intel.com>
Thu, 30 Apr 2026 00:25:54 +0000 (08:25 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 5 May 2026 10:47:21 +0000 (12:47 +0200)
commit5ad732a56be46aabf158c16aa0c095291727aaef
tree056033ce48fb816c75b5ba00896b62d4abe515ba
parentc69df06e4e26e50611190ce04eab92c5cc261b61
perf/x86/intel: Improve validation and configuration of ACR masks

Currently there are several issues on the user space ACR mask validation
and configuration.
- The validation for user space ACR mask (attr.config2) is incomplete,
  e.g., the ACR mask could include the index which belongs to another
  ACR events group, but it's not validated.
- An early return on an invalid ACR mask caused all subsequent ACR groups
  to be skipped.
- The stale hardware ACR mask (hw.config1) is not cleared before setting
  new hardware ACR mask.

The following changes address all of the above issues.
- Figure out the event index group of an ACR group. Any bits in the
  user-space mask not present in the index group are now dropped.
- Instead of an early return on invalid bits, drop only the invalid
  portions and continue iterating through all ACR events to ensure full
  configuration.
- Explicitly clear the stale hardware ACR mask for each event prior to
  writing the new configuration.

Besides, a non-leader event member of ACR group could be disabled in
theory. This could cause bit-shifting errors in the acr_mask of remaining
group members. But since ACR sampling requires all events to be active,
this should not be a big concern in real use case. Add a "FIXME" comment
to notice this risk.

Fixes: ec980e4facef ("perf/x86/intel: Support auto counter reload")
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260430002558.712334-2-dapeng1.mi@linux.intel.com
arch/x86/events/intel/core.c