diff options
author | jsing <> | 2025-08-14 15:11:01 +0000 |
---|---|---|
committer | jsing <> | 2025-08-14 15:11:01 +0000 |
commit | d31d4089b9ae677123f49cc1b071b80207baf184 (patch) | |
tree | 7879c987565c0bfed998b5c1e2c33f9e02b9c966 | |
parent | 3d3d845569e98c5b0f11899e4958cca728c8b99a (diff) | |
download | openbsd-d31d4089b9ae677123f49cc1b071b80207baf184.tar.gz openbsd-d31d4089b9ae677123f49cc1b071b80207baf184.tar.bz2 openbsd-d31d4089b9ae677123f49cc1b071b80207baf184.zip |
Add CPU feature detection for ADX on amd64.
Add detection of Multi-Precision Add-Carry Instruction Extensions on amd64.
s2n-bignum provides a number of fast multiplication routines that can
leverage these instructions.
ok tb@
-rw-r--r-- | src/lib/libcrypto/arch/amd64/crypto_arch.h | 9 | ||||
-rw-r--r-- | src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/libcrypto/arch/amd64/crypto_arch.h b/src/lib/libcrypto/arch/amd64/crypto_arch.h index e869fbba35..a8f64cf235 100644 --- a/src/lib/libcrypto/arch/amd64/crypto_arch.h +++ b/src/lib/libcrypto/arch/amd64/crypto_arch.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: crypto_arch.h,v 1.13 2025/07/22 09:18:02 jsing Exp $ */ | 1 | /* $OpenBSD: crypto_arch.h,v 1.14 2025/08/14 15:11:01 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -26,9 +26,10 @@ | |||
26 | extern uint64_t crypto_cpu_caps_amd64; | 26 | extern uint64_t crypto_cpu_caps_amd64; |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | #define CRYPTO_CPU_CAPS_AMD64_AES (1ULL << 0) | 29 | #define CRYPTO_CPU_CAPS_AMD64_ADX (1ULL << 0) |
30 | #define CRYPTO_CPU_CAPS_AMD64_CLMUL (1ULL << 1) | 30 | #define CRYPTO_CPU_CAPS_AMD64_AES (1ULL << 1) |
31 | #define CRYPTO_CPU_CAPS_AMD64_SHA (1ULL << 2) | 31 | #define CRYPTO_CPU_CAPS_AMD64_CLMUL (1ULL << 2) |
32 | #define CRYPTO_CPU_CAPS_AMD64_SHA (1ULL << 3) | ||
32 | 33 | ||
33 | #ifndef OPENSSL_NO_ASM | 34 | #ifndef OPENSSL_NO_ASM |
34 | 35 | ||
diff --git a/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c b/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c index 0bc440d34f..51a2da4616 100644 --- a/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c +++ b/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: crypto_cpu_caps.c,v 1.7 2025/07/22 09:18:02 jsing Exp $ */ | 1 | /* $OpenBSD: crypto_cpu_caps.c,v 1.8 2025/08/14 15:11:01 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -119,6 +119,10 @@ crypto_cpu_caps_init(void) | |||
119 | if (max_cpuid >= 7) { | 119 | if (max_cpuid >= 7) { |
120 | cpuid(7, NULL, &ebx, NULL, NULL); | 120 | cpuid(7, NULL, &ebx, NULL, NULL); |
121 | 121 | ||
122 | /* Intel ADX feature bit - ebx[19]. */ | ||
123 | if (((ebx >> 19) & 1) != 0) | ||
124 | crypto_cpu_caps_amd64 |= CRYPTO_CPU_CAPS_AMD64_ADX; | ||
125 | |||
122 | /* Intel SHA extensions feature bit - ebx[29]. */ | 126 | /* Intel SHA extensions feature bit - ebx[29]. */ |
123 | if (((ebx >> 29) & 1) != 0) | 127 | if (((ebx >> 29) & 1) != 0) |
124 | crypto_cpu_caps_amd64 |= CRYPTO_CPU_CAPS_AMD64_SHA; | 128 | crypto_cpu_caps_amd64 |= CRYPTO_CPU_CAPS_AMD64_SHA; |