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)
Sat, Dec 14, 9:41 PM
Unknown Object (File)
Thu, Nov 28, 2:43 AM
Unknown Object (File)
Nov 18 2024, 7:11 PM
Unknown Object (File)
Nov 18 2024, 5:26 PM
Unknown Object (File)
Sep 23 2024, 4:26 PM
Unknown Object (File)
Sep 19 2024, 4:50 AM
Unknown Object (File)
Sep 18 2024, 9:57 PM
Unknown Object (File)
Sep 18 2024, 2:25 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.