Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpufeatures: check OS register support #919

Merged
merged 5 commits into from
Jun 15, 2023
Merged

cpufeatures: check OS register support #919

merged 5 commits into from
Jun 15, 2023

Conversation

newpavlov
Copy link
Member

@newpavlov newpavlov commented Jun 15, 2023

cpufeatures/src/x86.rs Outdated Show resolved Hide resolved
@tarcieri
Copy link
Member

It looks like you're using XGETBV without first checking CPUID to determine if it's available.

I was reading about some virtualized environments that didn't implement it yesterday (although I forget specifically which ones, maybe I can dig up a link)

@newpavlov
Copy link
Member Author

I check it on line 76. Bit 26 of ECX register is responsible for availability of XSAVE, XRSTOR, XSETBV, XGETBV instructions.

@newpavlov
Copy link
Member Author

According to this page, there are 3 bits relevant to AVX-512:

  • 5 opmask AVX-512 enabled and XSAVE support for opmask registers k0-k7
  • 6 ZMM_Hi256 AVX-512 enabled and XSAVE support for upper halves of lower ZMM registers
  • 7 Hi16_ZMM AVX-512 enabled and XSAVE support for upper ZMM registers

Honestly, I have no idea when we should check what. For now to be safe I will check all bits. We may change it in future according to user reports.

@newpavlov newpavlov merged commit 95219ac into master Jun 15, 2023
99 checks passed
@newpavlov newpavlov deleted the xgetbv branch June 15, 2023 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cpufeatures: add XGETBV checks
2 participants