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

20240522-sha256-avx1-IS_INTEL_SHA #7572

Merged
merged 1 commit into from
May 23, 2024

Conversation

douzzer
Copy link
Contributor

@douzzer douzzer commented May 22, 2024

wolfcrypt/src/sha256.c: in WC_NO_INTERNAL_FUNCTION_POINTERS code path (linuxkm), fix oversight whereby Transform_Sha256_AVX1_Sha() was used on targets with false IS_INTEL_SHA(intel_flags). the former SHA256_AVX1 method id is now split into SHA256_AVX1_SHA and SHA256_AVX1_NOSHA, with corresponding fixes in Sha256_SetTransform(), inline_XTRANSFORM() and inline_XTRANSFORM_LEN().

tested with wolfssl-multi-test.sh ... linuxkm-all-cryptonly-intelasm-LKCAPI-insmod-mainline-fallback-fuzzing linuxkm-defaults-all-intelasm

@douzzer
Copy link
Contributor Author

douzzer commented May 22, 2024

note, these are the implementations that use the SHA hardware instructions:

$ awk 'BEGIN{printed=0;}/^\.type[      ]+[^,]+,@function/{curfunc=$0;printed=0;next}/^[        ]*sha/{if (! printed){print curfunc; printed=1}}' < wolfcrypt/src/sha256_asm.S 
.type   Transform_Sha256_SSE2_Sha,@function
.type   Transform_Sha256_SSE2_Sha_Len,@function
.type   Transform_Sha256_AVX1_Sha,@function
.type   Transform_Sha256_AVX1_Sha_Len,@function

The WC_NO_INTERNAL_FUNCTION_POINTERS version of Sha256_SetTransform() already had the SSE2 implementation correctly dependent on IS_INTEL_SHA(intel_flags). With this patch, the AVX1+SHA implementation is also correctly dependent.

Note, WC_NO_INTERNAL_FUNCTION_POINTERS is currently only used by the linuxkm build, by way of the WC_C_DYNAMIC_FALLBACK flag.

Copy link
Contributor

@bandi13 bandi13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really a fix. Transform_Sha256_AVX1 is eliminated from ever being called.

(this comment refers to an earlier and indeed wrong version of the patch.)

@bandi13 bandi13 assigned douzzer and unassigned wolfSSL-Bot and bandi13 May 22, 2024
… (linuxkm), fix oversight whereby Transform_Sha256_AVX1_Sha() was used on targets with false IS_INTEL_SHA(intel_flags). the former SHA256_AVX1 method id is now split into SHA256_AVX1_SHA and SHA256_AVX1_NOSHA, with corresponding fixes in Sha256_SetTransform(), inline_XTRANSFORM() and inline_XTRANSFORM_LEN().
@douzzer douzzer force-pushed the 20240522-sha256-avx1-IS_INTEL_SHA branch from b988f23 to 110f4ec Compare May 22, 2024 20:40
@douzzer
Copy link
Contributor Author

douzzer commented May 22, 2024

retest this please

@douzzer douzzer removed their assignment May 23, 2024
@SparkiDev SparkiDev self-assigned this May 23, 2024
@SparkiDev SparkiDev merged commit 023f604 into wolfSSL:master May 23, 2024
105 checks passed
jefferyq2 pushed a commit to jefferyq2/wolfssl that referenced this pull request Jun 9, 2024
…INTEL_SHA

20240522-sha256-avx1-IS_INTEL_SHA
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.

4 participants