git: 469727f0637b - main - hwpmc: probe the RAPL unit MSR instead of faulting on it
Alexander Leidinger <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.cvs.src |
|---|---|
| Message-ID | <6a8aab36.409d5.73d116bc__14697.3964687035$1787472730$gmane$org@gitrepo.freebsd.org> |
The branch main has been updated by netchild: URL: https://cgit.FreeBSD.org/src/commit/?id=469727f0637beec05e0478c1391e3df1e684e53c commit 469727f0637beec05e0478c1391e3df1e684e53c Author: Alexander Leidinger <[email protected]> AuthorDate: 2026-08-21 22:29:05 +0000 Commit: Alexander Leidinger <[email protected]> CommitDate: 2026-08-23 08:09:20 +0000 hwpmc: probe the RAPL unit MSR instead of faulting on it The RAPL probe read MSR_RAPL_POWER_UNIT with a bare rdmsr(). RAPL is not enumerated by CPUID on either vendor and the register is absent on older Intel and AMD parts and under a hypervisor that does not emulate it, so the read raises #GP and loading hwpmc panics the machine. Read it with rdmsr_safe() and return ENXIO when it is not there, as this function already does for the energy MSRs. Both callers already drop the class when the probe fails. Fixes: a99d04f39dab ("hwpmc: add RAPL energy-counter class (AMD + Intel)") Assisted-by: Claude Code (Opus 5) --- sys/dev/hwpmc/hwpmc_rapl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/hwpmc/hwpmc_rapl.c b/sys/dev/hwpmc/hwpmc_rapl.c index b4a105a86dbb..4ca76bc12403 100644 --- a/sys/dev/hwpmc/hwpmc_rapl.c +++ b/sys/dev/hwpmc/hwpmc_rapl.c @@ -532,7 +532,8 @@ pmc_rapl_initialize(struct pmc_mdep *md, int maxcpu, int classindex) } /* Decode the energy unit. */ - unit_val = rdmsr(unit_msr); + if (rdmsr_safe(unit_msr, &unit_val) != 0) + return (ENXIO); esu = (unit_val >> 8) & 0x1f; dram_unit = rapl_intel_fixed_dram_unit() ? 16 : esu;