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

s_has_vpclmulqdq() is not checking correct bit to detect VPCLMULQDQ #1084

Closed
pbadari opened this issue Jan 25, 2024 · 5 comments · May be fixed by awslabs/aws-checksums#72
Closed

s_has_vpclmulqdq() is not checking correct bit to detect VPCLMULQDQ #1084

pbadari opened this issue Jan 25, 2024 · 5 comments · May be fixed by awslabs/aws-checksums#72
Assignees
Labels
bug This issue is a bug. needs-review This issue or pull request needs review from a core team member. p2 This is a standard priority issue

Comments

@pbadari
Copy link
Contributor

pbadari commented Jan 25, 2024

Describe the bug

s_has_vpclmulqdq() is not checking the correct bit to detect VPCLMULQDQ.
According to the documentation it is bit 10. (code is checking bit 20).

Input Output
EAX=07H, ECX=0 ECX[bit 10] VPCLMULQDQ
EAX=07H, ECX=0 EBX[bit 16] AVX512F
EAX=07H, ECX=0 EBX[bit 31] AVX512VL

https://en.wikichip.org/wiki/x86/vpclmulqdq

Expected Behavior

s_has_vpclmulqdq() should return TRUE if the CPU supports it.

Current Behavior

s_has_vpclmulqdq() returns FALSE incorrectly.

Reproduction Steps

call s_has_vpclmulqdq() on any modern IA system.

Possible Solution

diff --git a/source/arch/intel/cpuid.c b/source/arch/intel/cpuid.c
index 44fdff0..465fccd 100644
--- a/source/arch/intel/cpuid.c
+++ b/source/arch/intel/cpuid.c
@@ -116,8 +116,8 @@ static bool s_has_bmi2(void) {
 static bool s_has_vpclmulqdq(void) {
     uint32_t abcd[4];
     /* Check VPCLMULQDQ:
-     * CPUID.(EAX=07H, ECX=0H):ECX.VPCLMULQDQ[bit 20]==1 */
-    uint32_t vpclmulqdq_mask = (1 << 20);
+     * CPUID.(EAX=07H, ECX=0H):ECX.VPCLMULQDQ[bit 10]==1 */
+    uint32_t vpclmulqdq_mask = (1 << 10);
     aws_run_cpuid(7, 0, abcd);
     if ((abcd[2] & vpclmulqdq_mask) != vpclmulqdq_mask) {
         return false;

Additional Information/Context

No response

aws-c-common version used

latest mainline branch

Compiler and version used

gcc version 11.4.1 20231218

Operating System and version

CentOS9

@pbadari pbadari added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 25, 2024
@jmklix jmklix self-assigned this Feb 5, 2024
@jmklix jmklix added p2 This is a standard priority issue needs-review This issue or pull request needs review from a core team member. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 5, 2024
@jmklix jmklix linked a pull request Feb 5, 2024 that will close this issue
@jmklix
Copy link
Member

jmklix commented Feb 5, 2024

Thanks for finding this. We are reviewing the suggested changes.

@jmklix
Copy link
Member

jmklix commented Feb 22, 2024

This PR should include the fix: awslabs/aws-checksums#72

@pbadari
Copy link
Contributor Author

pbadari commented Mar 11, 2024

This PR should include the fix: awslabs/aws-checksums#72

Please note that, this PR includes the fix needed for [awslabs/aws-checksums#72]

@pbadari
Copy link
Contributor Author

pbadari commented Apr 16, 2024

Can you please review and push the fix as its needed for working on AVX512 changes for aws-checksums project?

@pbadari
Copy link
Contributor Author

pbadari commented May 2, 2024

closing the issue as s_has_vpclmulqdq() has been fixed through some other merge.

@pbadari pbadari closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-review This issue or pull request needs review from a core team member. p2 This is a standard priority issue
Projects
None yet
2 participants