-
Notifications
You must be signed in to change notification settings - Fork 130
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: add XGETBV checks #793
Comments
The link in the first comment is dead but the document has been archived fortunately. We're hitting a crash in Firefox because of this, see bug 1838108. The full detection sequence for AVX from the Intel manual is the following:
From what I can tell what the crate is missing at the moment is step 2. |
It seems like we can use Something like this? (after detecting XGETBV is enabled) let xcr0 = unsafe { core::arch::x86_64::_xgetbv(0) };
// XMM state and YMM state are enabled by OS
(xcr0 & 6) == 6 |
Yes, that would do the trick. |
What about target features dependent on XMM and ZMM registers? |
@newpavlov I guess that'd be all of the AVX-512 instructions? (and wouldn't it be XMM, YMM, and ZMM?) |
I mean, shouldn't we technically check OS support for XMM registers when we use SSE instructions? Same for ZMM registers which are indeed used by AVX-512 instructions. After a cursory search I couldn't find information about them. |
That seems like the safest option, although I'm curious what the Intel manual says |
I /believe/ you only need to check OSXSAVE for VEX-prefixed instructions. |
According to the Intel manual, when detecting features like AVX and AVX2 we should first check availability of the XGETBV instruction and then check that OS supports XMM and YMM registers.
The text was updated successfully, but these errors were encountered: