acrn-kernel/arch/x86/events/amd
Breno Leitao 183e0f9da6 perf/x86/amd: Do not WARN() on every IRQ
[ Upstream commit 599522d9d2 ]

Zen 4 systems running buggy microcode can hit a WARN_ON() in the PMI
handler, as shown below, several times while perf runs. A simple
`perf top` run is enough to render the system unusable:

  WARNING: CPU: 18 PID: 20608 at arch/x86/events/amd/core.c:944 amd_pmu_v2_handle_irq+0x1be/0x2b0

This happens because the Performance Counter Global Status Register
(PerfCntGlobalStatus) has one or more bits set which are considered
reserved according to the "AMD64 Architecture Programmer’s Manual,
Volume 2: System Programming, 24593":

  https://www.amd.com/system/files/TechDocs/24593.pdf

To make this less intrusive, warn just once if any reserved bit is set
and prompt the user to update the microcode. Also sanitize the value to
what the code is handling, so that the overflow events continue to be
handled for the number of counters that are known to be sane.

Going forward, the following microcode patch levels are recommended
for Zen 4 processors in order to avoid such issues with reserved bits:

  Family=0x19 Model=0x11 Stepping=0x01: Patch=0x0a10113e
  Family=0x19 Model=0x11 Stepping=0x02: Patch=0x0a10123e
  Family=0x19 Model=0xa0 Stepping=0x01: Patch=0x0aa00116
  Family=0x19 Model=0xa0 Stepping=0x02: Patch=0x0aa00212

Commit f2eb058afc57 ("linux-firmware: Update AMD cpu microcode") from
the linux-firmware tree has binaries that meet the minimum required
patch levels.

  [ sandipan: - add message to prompt users to update microcode
              - rework commit message and call out required microcode levels ]

Fixes: 7685665c39 ("perf/x86/amd/core: Add PerfMonV2 overflow handling")
Reported-by: Jirka Hladky <jhladky@redhat.com>
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Sandipan Das <sandipan.das@amd.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/all/3540f985652f41041e54ee82aa53e7dbd55739ae.1694696888.git.sandipan.das@amd.com/
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-10-10 22:00:41 +02:00
..
Makefile perf/x86/amd/lbr: Detect LbrExtV2 support 2022-08-27 00:05:43 +02:00
brs.c perf/x86/amd/brs: Move feature-specific functions 2022-08-27 00:05:41 +02:00
core.c perf/x86/amd: Do not WARN() on every IRQ 2023-10-10 22:00:41 +02:00
ibs.c perf/ibs: Fix interface via core pmu events 2023-07-19 16:21:02 +02:00
iommu.c x86/events/amd/iommu: Remove redundant assignment to variable shift 2021-12-28 21:30:05 +01:00
iommu.h IOMMU Updates for Linux v5.13 2021-05-01 09:33:00 -07:00
lbr.c perf/x86/amd/lbr: Adjust LBR regardless of filtering 2022-09-29 12:20:57 +02:00
power.c perf/x86/amd/power: Assign pmu.module 2021-08-26 09:12:57 +02:00
uncore.c perf/x86/amd/uncore: Fix memory leak for events array 2022-11-09 12:38:01 +01:00