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

Detect when AVX is disabled via OSXSAVE #1182

Merged
merged 3 commits into from
Jan 23, 2025
Merged

Detect when AVX is disabled via OSXSAVE #1182

merged 3 commits into from
Jan 23, 2025

Conversation

graebm
Copy link
Contributor

@graebm graebm commented Jan 23, 2025

Issue #:
internal V1647663988

SEV-SNP enabled EC2 instances crash when using AWS CLI to upload with checksum algorithm CRC64NVME. AWS CLI v2 uses aws-c-common under the hood to do CRC64NVME.

Investigation:
aws-c-common has checks for AVX support, using CPUID. But apparently, just because CPUID reports that it can do AVX, doesn't necessarily mean it's enabled by the OS. On SEV-SNP enabled instances, AVX is not allowed.

GCC had the same bug until 7.4: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85100

Stackoverflow question: https://stackoverflow.com/questions/72522885/are-the-xgetbv-and-cpuid-checks-sufficient-to-guarantee-avx2-support

Description of changes:

  • Do further checks before deciding that AVX can be used.
  • Move all Intel feature detection into 1 function.
    • This is simpler, it's how we're doing feature detection on some other architectures.
    • Add checks to find the max value that CPUID accepts. We weren't doing this before.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@graebm graebm merged commit f6622ac into main Jan 23, 2025
56 checks passed
@graebm graebm deleted the bugfix-avx-xsave branch January 23, 2025 23:56
graebm added a commit to awslabs/aws-crt-python that referenced this pull request Jan 24, 2025
…SXSAVE

Fix comes from:
awslabs/aws-c-common#1182

Updated submodules:
```
aws-c-auth         v0.8.0 -> v0.8.1
aws-c-common       v0.10.6 -> v0.10.7
aws-c-s3           v0.7.7 -> v0.7.9
aws-c-sdkutils     v0.2.1 -> v0.2.2
aws-lc             v1.41.1 -> v1.43.0
s2n                v1.5.10 -> v1.5.11
```
graebm added a commit that referenced this pull request Jan 24, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
**Issue:**
There were some bugs in the previous PR: #1182

**Description of changes:**
* Fix bug where high and low bits of XGETBV were reversed
* Add back AVX2 feature detection (accidentally omitted from previous PR)
* VPCLMULQDQ also depends on AVX being usable
graebm added a commit that referenced this pull request Jan 31, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
**Issue:**
I accidentally committed broken CPU-feature-detection code in #1182 (fixed the next day by #1184)

This kind of accident slipped through because I was in a rush, and we don't have unit tests to double-check this particular code. Unit tests for feature detection are hard because these features vary wildly machine to machine.

**Description of changes:**
Add an integration test that checks CPU-feature-detection against linux's easy-to-parse `/proc/cpuinfo`.

This test is skipped on platforms like Windows and Apple where there's no simple way to query CPU features
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.

None yet

2 participants