head 1.11; access; symbols netbsd-11-0-RELEASE:1.7 netbsd-11-0-RC7:1.7 netbsd-11-0-RC6:1.7 netbsd-11-0-RC5:1.7 netbsd-11-0-RC4:1.7 netbsd-11-0-RC3:1.7 netbsd-11-0-RC2:1.7 netbsd-11-0-RC1:1.7 perseant-exfatfs-base-20250801:1.7 netbsd-11:1.7.0.4 netbsd-11-base:1.7 netbsd-10-1-RELEASE:1.6 perseant-exfatfs-base-20240630:1.7 perseant-exfatfs:1.7.0.2 perseant-exfatfs-base:1.7 netbsd-10-0-RELEASE:1.6 netbsd-10-0-RC6:1.6 netbsd-10-0-RC5:1.6 netbsd-10-0-RC4:1.6 netbsd-10-0-RC3:1.6 netbsd-10-0-RC2:1.6 netbsd-10-0-RC1:1.6 netbsd-10:1.6.0.6 netbsd-10-base:1.6 cjep_sun2x-base1:1.6 cjep_sun2x:1.6.0.4 cjep_sun2x-base:1.6 cjep_staticlib_x-base1:1.6 cjep_staticlib_x:1.6.0.2 cjep_staticlib_x-base:1.6; locks; strict; comment @# @; 1.11 date 2025.11.24.16.28.51; author nia; state Exp; branches; next 1.10; commitid WOieiTJXnjM8ePjG; 1.10 date 2025.11.23.22.48.27; author riastradh; state Exp; branches; next 1.9; commitid DyNWn8bpWikomJjG; 1.9 date 2025.11.23.22.44.14; author riastradh; state Exp; branches; next 1.8; commitid sK7Zpd26tf3XkJjG; 1.8 date 2025.11.22.22.32.39; author riastradh; state Exp; branches; next 1.7; commitid oq1ie9hpKwiYiBjG; 1.7 date 2023.08.08.06.27.32; author mrg; state Exp; branches; next 1.6; commitid fXtLeeKhU4aARWzE; 1.6 date 2020.09.08.17.35.27; author jakllsch; state Exp; branches; next 1.5; commitid OV3IOQDxsoBWJgnC; 1.5 date 2020.08.17.16.26.02; author riastradh; state Exp; branches; next 1.4; commitid mhTGtcH1evXm5rkC; 1.4 date 2020.08.16.15.52.14; author martin; state Exp; branches; next 1.3; commitid 8tzJlBDJ67rEVikC; 1.3 date 2020.07.25.22.33.04; author riastradh; state Exp; branches; next 1.2; commitid EhLNwxAgajQhRvhC; 1.2 date 2020.07.01.09.58.29; author riastradh; state Exp; branches; next 1.1; commitid d9HFrUDJEwOfsmeC; 1.1 date 2020.06.30.20.32.11; author riastradh; state Exp; branches; next ; commitid FIYM0QmP24NsZheC; desc @@ 1.11 log @Needs the same compiler bug workaround as the kernel. @ text @# $NetBSD: Makefile,v 1.10 2025/11/23 22:48:27 riastradh Exp $ .include TESTSDIR= ${TESTSBASE}/sys/crypto/aes TESTS_C= t_aes AFLAGS+= -D_LOCORE .PATH: ${NETBSDSRCDIR}/sys/crypto/aes CPPFLAGS+= -I${NETBSDSRCDIR}/sys SRCS.t_aes+= t_aes.c SRCS.t_aes+= aes_bear.c SRCS.t_aes+= aes_ct.c SRCS.t_aes+= aes_ct_dec.c SRCS.t_aes+= aes_ct_enc.c SRCS.t_aes+= aes_bear64.c SRCS.t_aes+= aes_ct64.c SRCS.t_aes+= aes_ct64_dec.c SRCS.t_aes+= aes_ct64_enc.c SRCS.t_aes+= aes_keysched.c SRCS.t_aes+= aes_selftest.c .if !empty(MACHINE_ARCH:Mearmv7*) || !empty(MACHINE_ARCH:Maarch64*) .PATH: ${NETBSDSRCDIR}/sys/crypto/aes/arch/arm CPPFLAGS+= -I${NETBSDSRCDIR}/sys/crypto/aes/arch/arm .if !empty(MACHINE_ARCH:Maarch64*) # XXX no AESE/AESD in 32-bit mode yet SRCS.t_aes+= aes_armv8.c SRCS.t_aes+= aes_armv8_64.S .endif CLANG_NO_NONPORTABLE_VECTOR_INITIALIZATION= ${${ACTIVE_CC} == "clang":? -Wno-nonportable-vector-initialization :} SRCS.t_aes+= aes_neon.c COPTS.aes_neon.c+=${CLANG_NO_NONPORTABLE_VECTOR_INITIALIZATION} SRCS.t_aes+= aes_neon_impl.c SRCS.t_aes+= aes_neon_subr.c COPTS.aes_neon_subr.c+=${CLANG_NO_NONPORTABLE_VECTOR_INITIALIZATION} .if !empty(MACHINE_ARCH:Mearmv7*) SRCS.t_aes+= aes_neon_32.S .endif .if !empty(MACHINE_ARCH:Mearmv7*) && empty(MACHINE_ARCH:Mearmv7hf*) COPTS.aes_neon.c+= -mfloat-abi=softfp -mfpu=neon COPTS.aes_neon_subr.c+= -mfloat-abi=softfp -mfpu=neon AOPTS.aes_neon_32.S+= -D__SOFTFP__ .endif .endif # earmv7/aarch64 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" .PATH: ${NETBSDSRCDIR}/sys/crypto/aes/arch/x86 CPPFLAGS+= -I${NETBSDSRCDIR}/sys/crypto/aes/arch/x86 .if ${MACHINE_ARCH} == "x86_64" # XXX no AES-NI in 32-bit mode yet SRCS.t_aes+= aes_ni.c SRCS.t_aes+= aes_ni_64.S .endif SRCS.t_aes+= aes_sse2_4x32.c SRCS.t_aes+= aes_sse2_4x32_dec.c SRCS.t_aes+= aes_sse2_4x32_enc.c SRCS.t_aes+= aes_sse2_4x32_impl.c SRCS.t_aes+= aes_sse2_4x32_subr.c COPTS.aes_sse2_4x32.c+= -msse -msse2 COPTS.aes_sse2_4x32_dec.c+= -msse -msse2 COPTS.aes_sse2_4x32_enc.c+= -msse -msse2 COPTS.aes_sse2_4x32_subr.c+= -msse -msse2 SRCS.t_aes+= aes_ssse3.c SRCS.t_aes+= aes_ssse3_impl.c SRCS.t_aes+= aes_ssse3_subr.c COPTS.aes_ssse3.c+= -msse -msse2 -msse3 -mssse3 COPTS.aes_ssse3_subr.c+= -msse -msse2 -msse3 -mssse3 SRCS.t_aes+= aes_via.c .endif # x86 WARNS= 5 # Many of these are probably GCC bugs, see # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110878 COPTS.aes_armv8.c+= ${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW} COPTS.aes_bear.c+= ${CC_WNO_STRINGOP_OVERFLOW} ${CC_WNO_ARRAY_BOUNDS} COPTS.aes_bear64.c+= ${CC_WNO_STRINGOP_OVERFLOW} ${CC_WNO_ARRAY_BOUNDS} \ ${CC_WNO_STRINGOP_OVERREAD} COPTS.aes_neon_subr.c+= ${CC_WNO_ARRAY_BOUNDS} COPTS.aes_ni.c+= ${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW} COPTS.aes_sse2_4x32_subr.c+= ${CC_WNO_ARRAY_BOUNDS} COPTS.aes_ssse3_subr.c+=${CC_WNO_ARRAY_BOUNDS} COPTS.aes_via.c+= ${CC_WNO_ARRAY_BOUNDS} .include @ 1.10 log @aes(9): Rewrite x86 SSE2 implementation. This computes eight AES_k instances simultaneously, using the bitsliced 32-bit aes_ct logic which computes two blocks at a time in uint32_t arithmetic, vectorized four ways. Previously, the SSE2 code was a very naive adaptation of aes_ct64, which computes four blocks at a time in uint64_t arithmetic, without any 2x vectorization -- I did it at the time because: (a) it was easier to get working, (b) it only affects really old hardware with neither AES-NI nor SSSE3 which are both much much faster. But it was bugging me that this was a kind of dumb use of SSE2. Substantially reduces stack usage (from ~1200 bytes to ~800 bytes) and should approximately double throughput for CBC decryption and for XTS encryption/decryption. I also tried a 2x64 version but cursory performance measurements didn't reveal much benefit over 4x32. (If anyone is interested in doing more serious performance measurements, on ancient hardware for which it might matter, I also have the 2x64 code around.) Prompted by: PR kern/59774: bearssl 32-bit AES is too slow, want 64-bit optimized version in kernel @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.9 2025/11/23 22:44:14 riastradh Exp $ d94 2 a95 1 COPTS.aes_bear64.c+= ${CC_WNO_STRINGOP_OVERFLOW} ${CC_WNO_ARRAY_BOUNDS} @ 1.9 log @aes(9): New 64-bit bitsliced implementation. Derived from BearSSL's aes_ct64 code. Compared to the aes_ct code, on machines with native 64-bit integer arithmetic, aes_ct64 should have approximately: - the same throughput for: . CBC encryption, . CCM encryption/decryption, and . CBC-MAC; - double the throughput for: . CBC decryption, . XTS encryption/decryption. (aes_ct computes AES on two blocks at a time; aes_ct64 computes it on four blocks at a time, with roughly the same number of instructions. CBC encryption and CBC-MAC are inherently sequential; CCM, being a combination of CTR and CBC-MAC, can only really be parallelized two ways, so having four ways available doesn't help; and CBC decryption and XTS admit parallelism limited only by the size of the inputs.) Enable with `options AES_BEAR64'. Should be a reasonable default on all platforms with 64-bit integer registers. Caveat: uses about 1200 bytes of stack space. (Could approximately halve that, like the BearSSL aes_ct code, at some speed cost which I haven't measured -- by moving the br_aes_ct64_skey_expand logic into add_round_key in aes_ct64_{enc,dec}.c.) PR kern/59774: bearssl 32-bit AES is too slow, want 64-bit optimized version in kernel @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.8 2025/11/22 22:32:39 riastradh Exp $ d68 9 a76 9 SRCS.t_aes+= aes_sse2.c SRCS.t_aes+= aes_sse2_dec.c SRCS.t_aes+= aes_sse2_enc.c SRCS.t_aes+= aes_sse2_impl.c SRCS.t_aes+= aes_sse2_subr.c COPTS.aes_sse2.c+= -msse -msse2 COPTS.aes_sse2_dec.c+= -msse -msse2 COPTS.aes_sse2_enc.c+= -msse -msse2 COPTS.aes_sse2_subr.c+= -msse -msse2 d98 1 a98 1 COPTS.aes_sse2_subr.c+= ${CC_WNO_ARRAY_BOUNDS} @ 1.8 log @aes(9): New aes_keysched_enc/dec. These implement the standard key schedule. They are named independently of any particular AES implementation, so that: (a) we can swap between the BearSSL aes_ct and aes_ct64 code without changing all the callers who don't care which one they get, and (b) we could push it into the aes_impl abstraction if we wanted. This eliminates all br_aes_* references outside aes_bear.c, aes_ct*.c, and the new aes_keysched.c wrappers. Preparation for: PR kern/59774: bearssl 32-bit AES is too slow, want 64-bit optimized version in kernel @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.7 2023/08/08 06:27:32 mrg Exp $ d20 6 d94 1 @ 1.7 log @introduce new GCC 12 warning disables and use them in a few places this introduces 4 new warning disable flags: CC_WNO_MISSING_TEMPLATE_KEYWORD CC_WNO_REGISTER CC_WNO_STRINGOP_OVERREAD CC_WNO_ARRAY_BOUNDS and documents them in README.warnings. of these, the string op and array bounds are both problematic (real bugs) and also spurious (not real bugs), and the other 2 are mostly temporary for older 3rd party code. add some new uses of CC_WNO_STRINGOP_OVERFLOW. fix m68k build for gallium and GCC 12. @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.6 2020/09/08 17:35:27 jakllsch Exp $ d20 1 @ 1.6 log @Acknowledge clang warning for NEON cipher code on aarch64eb We've already made the nonportable vector initializations portable; the code works on aarch64eb. @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.5 2020/08/17 16:26:02 riastradh Exp $ d83 11 @ 1.5 log @Make the AES and ChaCha NEON tests work in softfloat userland. (`Softfloat' here refers to the ABI, which of course may be running on a CPU with NEON.) @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.4 2020/08/16 15:52:14 martin Exp $ d32 2 d35 1 d38 1 @ 1.4 log @Restrict the NEON code to v7hf - the softfloat toolchain does not like it (nor is it likely to work if there is no FPU present). @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.3 2020/07/25 22:33:04 riastradh Exp $ d22 1 a22 1 .if !empty(MACHINE_ARCH:Mearmv7hf*) || !empty(MACHINE_ARCH:Maarch64*) d35 1 a35 1 .if !empty(MACHINE_ARCH:Mearmv7hf*) d39 6 @ 1.3 log @Implement AES-CCM with ARMv8.5-AES. @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.2 2020/07/01 09:58:29 riastradh Exp $ d22 1 a22 1 .if !empty(MACHINE_ARCH:Mearmv7*) || !empty(MACHINE_ARCH:Maarch64*) d35 1 a35 1 .if !empty(MACHINE_ARCH:Mearmv7*) @ 1.2 log @Pass the requisite -msse options for i386. @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.1 2020/06/30 20:32:11 riastradh Exp $ d9 2 @ 1.1 log @New test sys/crypto/aes/t_aes. Runs aes_selftest on all kernel AES implementations supported on the current hardware, not just the preferred one. @ text @d1 1 a1 1 # $NetBSD$ d54 4 d62 2 a63 1 COPTS.aes_ssse3.c+= -msse3 -mssse3 @