summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c
diff options
context:
space:
mode:
authorjsing <>2025-08-14 15:11:01 +0000
committerjsing <>2025-08-14 15:11:01 +0000
commitd31d4089b9ae677123f49cc1b071b80207baf184 (patch)
tree7879c987565c0bfed998b5c1e2c33f9e02b9c966 /src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c
parent3d3d845569e98c5b0f11899e4958cca728c8b99a (diff)
downloadopenbsd-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@
Diffstat (limited to 'src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c')
-rw-r--r--src/lib/libcrypto/arch/amd64/crypto_cpu_caps.c6
1 files changed, 5 insertions, 1 deletions
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;