Page MenuHomeFreeBSD

hwpmc_amd: check extended CPUID bits
Changes PlannedPublic

Authored by mhorne on Aug 1 2023, 4:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 7:34 AM
Unknown Object (File)
Fri, Apr 26, 7:33 AM
Unknown Object (File)
Thu, Apr 25, 11:43 PM
Unknown Object (File)
Dec 23 2023, 2:53 PM
Unknown Object (File)
Dec 21 2023, 7:29 AM
Unknown Object (File)
Dec 20 2023, 5:52 AM
Unknown Object (File)
Dec 11 2023, 2:24 AM
Unknown Object (File)
Nov 24 2023, 3:38 PM
Subscribers

Details

Reviewers
jkoshy
gnn
Group Reviewers
pmc
Summary

There are three types of performance counters defined by the spec, with
three CPUID bits allocated to indicate support. Add detection of this to
the initialization routine.

Support for the "Core" performance counters is required, and if this is
not detected then the class will not attach. Let the other two types of
counters become optional.

This fixes an issue where use of hwpmc in bhyve could easily trigger
panics, as all MSR reads and writes were intercepted to be a no-op.
vmm(4) clears the relevant bits from CPUID, so now this behaves as
expected.

PR: 268943

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 52935
Build 49826: arc lint + arc unit

Event Timeline

mhorne requested review of this revision.Aug 1 2023, 4:24 PM
sys/dev/hwpmc/hwpmc_amd.c
394

IIRC, case ranges are a GNU and Clang extension. I'm not sure if they are allowed by the current style(9).

sys/dev/hwpmc/hwpmc_amd.c
394

I recently questioned this too in another review. There is a large enough precedent for the use of this extension within the src tree.

This revision is now accepted and ready to land.Aug 9 2023, 5:09 AM

I want to have this fixed soon, but need to look a little deeper. It is difficult to determine exactly when these CPUID bits were added to the spec, and what CPUs are affected.