Aarch64 asm: Have software fallback and CPU id checks#10754
Conversation
|
efe891c to
030ceff
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10754
Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
030ceff to
d92491c
Compare
|
Jenkins: retest this please Checkout failed - agent went down |
| #define CPUID_AARCH64_FEAT_SHA3 ((word64)1 << 32) | ||
| #define CPUID_AARCH64_FEAT_SM3 ((word64)1 << 36) | ||
| #define CPUID_AARCH64_FEAT_SM4 ((word64)1 << 40) | ||
| #define CPUID_AARCH64_FEAT_ASMID ((word64)0xf << 20) |
|
|
||
| /* Dispatch each Poly1305 operation to the NEON assembly or the C | ||
| * implementation, choosing at runtime when both are available. */ | ||
| void poly1305_blocks_aarch64(Poly1305* ctx, const unsigned char* m, size_t bytes) |
| #endif | ||
| } | ||
|
|
||
| void poly1305_block_aarch64(Poly1305* ctx, const unsigned char* m) |
| poly1305_arm32_blocks_16(ctx, m, bytes, 1); | ||
| return 0; | ||
| /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */ | ||
| ctx->r[0] = (U8TO32(key + 0) ) & 0x3ffffff; |
There was a problem hiding this comment.
Could/should these also use the POLY1305_CTX_ remap macros?
There was a problem hiding this comment.
Not used with the ARM64 fallback and don't want to have C fallback if it can be helped. That is, want to add assembly implementations that use base instructions only as well.
cpuid.h — added CPUID_ASIMD flag + IS_AARCH64_ASIMD() macro (NEON detection). cpuid.c — added NEON/ASIMD detection fixed FreeBSD/OpenBSD to use HWCAP_* sha256.c — runtime dispatch SHA256-crypto → NEON → software sha512.c — replaced the #error with the same crypto → NEON → software dispatch. chacha.c: add AArch64 runtime fallback to C. poly1305.c: add AArch64 runtime fallback to C. Fixes test_tls.c: don't memcpy into buffer if length is too long. sha256.c: even if data is not NULL, return immediately when length is 0.
d92491c to
6315f95
Compare
|
Jenkins: retest this please makedist check timed out. |
Description
cpuid.h — added CPUID_ASIMD flag + IS_AARCH64_ASIMD() macro (NEON detection).
cpuid.c — added NEON/ASIMD detection fixed FreeBSD/OpenBSD to use HWCAP_*
sha256.c — runtime dispatch SHA256-crypto → NEON → software
sha512.c — replaced the #error with the same crypto → NEON → software dispatch.
chacha.c: add AArch64 runtime fallback to C.
poly1305.c: add AArch64 runtime fallback to C.
Fixes
test_tls.c: don't memcpy into buffer if length is too long.
sha256.c: even if data is not NULL, return immediately when length is 0.
Testing
Regression tested Aarch64 platforms.