Repository navigation
Handle CPUID subleaves more precisely when using Bhyve defaults - #915
Merged
Merged
Conversation
We would report a few CPUID leaves as not having subleaves at all. Guests that try to interrogate CPUID leaves according to the APM then could end up very confused since later "subleaves" would just be repetitions of the single first leaf we queried from the host. For leaves F, 10, and 8000_0020, I've chosen to hide the otherwise-unsupported-anyway PQM and PQE features from PQoS. If a guest tried to use the PQM/PQE features as-advertised, it should get a #GP anyway. Presumably #GP from a "supported" feature may not be gracefully handled. For 8000_0026, I'm less committed to returning zeroes, but it seems like the least-unreasonable thing to present. I noticed this from `cpuid` in a Linux guest printing thousands of bogus 0x8000_0020 leaves on dogfood. That's PQoS feature information, and the APM happens to mention that the appropriate way to query this is to check individual bits in a bit field (implicitly that there are no more than 32 subleaves on that function). In that case it was technically a `cpuid` bug that resulted in it trying all the other 2^32-32 leaves, but we should be better here. 0x8000_0026 is more likely to matter, but it isn't present on Zen 3 parts.
pfmooney
reviewed
Jul 2, 2025
| let data = query(leaf, 0)?; | ||
| let mut data = query(leaf, 0)?; | ||
|
|
||
| // Leaf 7 EBX bits 12 and 15 indicate PQM and PQE support on AMD |
Contributor
There was a problem hiding this comment.
style nit: I think it would be nice to use the h suffix consistently, even for numbers (7, F) which do not require it for disambiguation.
Member
Author
There was a problem hiding this comment.
fair enough. it turns out we use 0x prefixes for leaves elsewhere in Propolis anyway, so i've switched to those along the way.
| // > returned hierarchy level type (CPUID | ||
| // > Fn8000_0026_ECX[LevelType]) is equal to zero | ||
| // | ||
| // but if the sole leaf has a non-zero ECX[LevelType], it will |
Contributor
There was a problem hiding this comment.
nit: With this not starting a new sentence, it almost reads like part of the comment was chopped off.
hawkw
reviewed
Jul 2, 2025
hawkw
left a comment
Member
There was a problem hiding this comment.
No concerns from me beyond Patrick's comment suggestions.
| )?; | ||
| } | ||
| } | ||
| // Leaf F describes Platform QoS Monitoring ("PQM"). |
Member
There was a problem hiding this comment.
thank you for spelling out the acronym <3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We would report a few CPUID leaves as not having subleaves at all. Guests that try to interrogate CPUID leaves according to the APM then could end up very confused since later "subleaves" would just be repetitions of the single first leaf we queried from the host.
For leaves F, 10, and 8000_0020, I've chosen to hide the otherwise-unsupported-anyway PQM and PQE features from PQoS. If a guest tried to use the PQM/PQE features as-advertised, it should get a #GP anyway. Presumably #GP from a "supported" feature may not be gracefully handled. For 8000_0026, I'm less committed to returning zeroes, but it seems like the least-unreasonable thing to present.
I noticed this from
cpuidin a Linux guest printing thousands of bogus 0x8000_0020 leaves on dogfood. That's PQoS feature information, and the APM happens to mention that the appropriate way to query this is to check individual bits in a bit field (implicitly that there are no more than 32 subleaves on that function). In that case it was technically acpuidbug that resulted in it trying all the other 2^32-32 leaves, but we should be better here.0x8000_0026 is more likely to matter, but it isn't present on Zen 3 parts.
(while in the product this will be avoided by using the CPUID definitions from RFD 314, this would still crop up when hacking on Propolis locally and it's annoying for "use the host defaults" to result in bogus leaves)