[PATCH v4 0/9] perf/amd/ibs: Fix sample period computations

Ravi Bangoria posted 9 patches 11 months ago
arch/x86/events/amd/ibs.c                  |  92 +-
arch/x86/include/asm/perf_event.h          |   1 +
tools/perf/arch/x86/include/arch-tests.h   |   1 +
tools/perf/arch/x86/tests/Build            |   1 +
tools/perf/arch/x86/tests/amd-ibs-period.c | 951 +++++++++++++++++++++
tools/perf/arch/x86/tests/arch-tests.c     |   2 +
6 files changed, 1024 insertions(+), 24 deletions(-)
create mode 100644 tools/perf/arch/x86/tests/amd-ibs-period.c
[PATCH v4 0/9] perf/amd/ibs: Fix sample period computations
Posted by Ravi Bangoria 11 months ago
IBS Fetch and IBS Op PMUs have constraints on supported sample period
values. The IBS hw behavior could be undefined if they are not followed.
Currently, IBS driver does not honor them correctly and thus a malicious
event could cause issues to the system. Fortunately, the IBS hw is very
resilient so far and IBS PMUs are restricted to root only, so the attack
vector is minimal. In any case, these are genuine bugs and must be fixed.

Patches are prepared on tip/perf/core (b709eb872e19) with 4cd67bac9d4e
("perf test: Introduce DEFINE_SUITE_EXCLUSIVE().") cherry-picked from
perf-tools-next/perf-tools-next.

v3: https://lore.kernel.org/r/20241210093449.1662-1-ravi.bangoria@amd.com
v3->v4:
  - No need to add pmu->adjust_period() callback. Adjust sample_period
    within IBS driver itself.
  - Fix perf IBS period test when sampling freq is more than
    perf_event_max_sample_rate.
  - Add unit test with sample_period beyond IBS PMU supported max period.
  - Fix i386 perf tool build failure.
  - Patch to introduce DEFINE_SUITE_EXCLUSIVE() is already picked up by
    Arnaldo and is in the perf-tools-next/perf-tools-next. So remove it
    from the series.

Ravi Bangoria (9):
  perf/amd/ibs: Remove IBS_{FETCH|OP}_CONFIG_MASK macros
  perf/amd/ibs: Remove pointless sample period check
  perf/amd/ibs: Fix ->config to sample period calculation for OP PMU
  perf/amd/ibs: Fix perf_ibs_op.cnt_mask for CurCnt
  perf/amd/ibs: Don't allow freq mode event creation through ->config
    interface
  perf/amd/ibs: Add PMU specific minimum period
  perf/amd/ibs: Add ->check_period() callback
  perf/amd/ibs: Ceil sample_period to min_period
  perf test amd ibs: Add sample period unit test

 arch/x86/events/amd/ibs.c                  |  92 +-
 arch/x86/include/asm/perf_event.h          |   1 +
 tools/perf/arch/x86/include/arch-tests.h   |   1 +
 tools/perf/arch/x86/tests/Build            |   1 +
 tools/perf/arch/x86/tests/amd-ibs-period.c | 951 +++++++++++++++++++++
 tools/perf/arch/x86/tests/arch-tests.c     |   2 +
 6 files changed, 1024 insertions(+), 24 deletions(-)
 create mode 100644 tools/perf/arch/x86/tests/amd-ibs-period.c

-- 
2.43.0