This ports the SUPERCOP implementation for usage in kernel space. In addition to the usual header, macro, and style changes required for kernel space, it makes a few small changes to the code: - The stack alignment is relaxed to 16 bytes. - Superfluous mov statements have been removed. - ldr for constants has been replaced with movw. - ldreq has been replaced with moveq. - The str epilogue has been made more idiomatic. - SIMD registers are not pushed and popped at the beginning and end. - The prologue and epilogue have been made idiomatic. - A hole has been removed from the stack, saving 32 bytes. - We write-back the base register whenever possible for vld1.8. - Some multiplications have been reordered for better A7 performance. There are more opportunities for cleanup, since this code is from qhasm, which doesn't always do the most opportune thing. But even prior to extensive hand optimizations, this code delivers significant performance improvements (given in get_cycles() per call): ----------- ------------- | generic C | this commit | ------------ ----------- ------------- | Cortex-A7 | 49136 | 22395 | ------------ ----------- ------------- | Cortex-A17 | 17326 | 4983 | ------------ ----------- ------------- Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> [ardb: - move to arch/arm/crypto - wire into lib/crypto framework - implement crypto API KPP hooks ] Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit d8f1308a025fc7e00414194ed742d5f05a21e13c) Bug: 152722841 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: Ifb910f18c3f9fedafc4e424a3a3d7de030eaa78b
84 lines
3.1 KiB
Makefile
84 lines
3.1 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Arch-specific CryptoAPI modules.
|
|
#
|
|
|
|
obj-$(CONFIG_CRYPTO_AES_ARM) += aes-arm.o
|
|
obj-$(CONFIG_CRYPTO_AES_ARM_BS) += aes-arm-bs.o
|
|
obj-$(CONFIG_CRYPTO_SHA1_ARM) += sha1-arm.o
|
|
obj-$(CONFIG_CRYPTO_SHA1_ARM_NEON) += sha1-arm-neon.o
|
|
obj-$(CONFIG_CRYPTO_SHA256_ARM) += sha256-arm.o
|
|
obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o
|
|
obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha-neon.o
|
|
obj-$(CONFIG_CRYPTO_POLY1305_ARM) += poly1305-arm.o
|
|
obj-$(CONFIG_CRYPTO_NHPOLY1305_NEON) += nhpoly1305-neon.o
|
|
obj-$(CONFIG_CRYPTO_CURVE25519_NEON) += curve25519-neon.o
|
|
|
|
ce-obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o
|
|
ce-obj-$(CONFIG_CRYPTO_SHA1_ARM_CE) += sha1-arm-ce.o
|
|
ce-obj-$(CONFIG_CRYPTO_SHA2_ARM_CE) += sha2-arm-ce.o
|
|
ce-obj-$(CONFIG_CRYPTO_GHASH_ARM_CE) += ghash-arm-ce.o
|
|
ce-obj-$(CONFIG_CRYPTO_CRCT10DIF_ARM_CE) += crct10dif-arm-ce.o
|
|
crc-obj-$(CONFIG_CRYPTO_CRC32_ARM_CE) += crc32-arm-ce.o
|
|
|
|
ifneq ($(crc-obj-y)$(crc-obj-m),)
|
|
ifeq ($(call as-instr,.arch armv8-a\n.arch_extension crc,y,n),y)
|
|
ce-obj-y += $(crc-obj-y)
|
|
ce-obj-m += $(crc-obj-m)
|
|
else
|
|
$(warning These CRC Extensions modules need binutils 2.23 or higher)
|
|
$(warning $(crc-obj-y) $(crc-obj-m))
|
|
endif
|
|
endif
|
|
|
|
ifneq ($(ce-obj-y)$(ce-obj-m),)
|
|
ifeq ($(call as-instr,.fpu crypto-neon-fp-armv8,y,n),y)
|
|
obj-y += $(ce-obj-y)
|
|
obj-m += $(ce-obj-m)
|
|
else
|
|
$(warning These ARMv8 Crypto Extensions modules need binutils 2.23 or higher)
|
|
$(warning $(ce-obj-y) $(ce-obj-m))
|
|
endif
|
|
endif
|
|
|
|
aes-arm-y := aes-cipher-core.o aes-cipher-glue.o
|
|
aes-arm-bs-y := aes-neonbs-core.o aes-neonbs-glue.o
|
|
sha1-arm-y := sha1-armv4-large.o sha1_glue.o
|
|
sha1-arm-neon-y := sha1-armv7-neon.o sha1_neon_glue.o
|
|
sha256-arm-neon-$(CONFIG_KERNEL_MODE_NEON) := sha256_neon_glue.o
|
|
sha256-arm-y := sha256-core.o sha256_glue.o $(sha256-arm-neon-y)
|
|
sha512-arm-neon-$(CONFIG_KERNEL_MODE_NEON) := sha512-neon-glue.o
|
|
sha512-arm-y := sha512-core.o sha512-glue.o $(sha512-arm-neon-y)
|
|
sha1-arm-ce-y := sha1-ce-core.o sha1-ce-glue.o
|
|
sha2-arm-ce-y := sha2-ce-core.o sha2-ce-glue.o
|
|
aes-arm-ce-y := aes-ce-core.o aes-ce-glue.o
|
|
ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o
|
|
crct10dif-arm-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o
|
|
crc32-arm-ce-y:= crc32-ce-core.o crc32-ce-glue.o
|
|
chacha-neon-y := chacha-scalar-core.o chacha-glue.o
|
|
chacha-neon-$(CONFIG_KERNEL_MODE_NEON) += chacha-neon-core.o
|
|
poly1305-arm-y := poly1305-core.o poly1305-glue.o
|
|
nhpoly1305-neon-y := nh-neon-core.o nhpoly1305-neon-glue.o
|
|
curve25519-neon-y := curve25519-core.o curve25519-glue.o
|
|
|
|
ifdef REGENERATE_ARM_CRYPTO
|
|
quiet_cmd_perl = PERL $@
|
|
cmd_perl = $(PERL) $(<) > $(@)
|
|
|
|
$(src)/poly1305-core.S_shipped: $(src)/poly1305-armv4.pl
|
|
$(call cmd,perl)
|
|
|
|
$(src)/sha256-core.S_shipped: $(src)/sha256-armv4.pl
|
|
$(call cmd,perl)
|
|
|
|
$(src)/sha512-core.S_shipped: $(src)/sha512-armv4.pl
|
|
$(call cmd,perl)
|
|
endif
|
|
|
|
targets += poly1305-core.S sha256-core.S sha512-core.S
|
|
|
|
# massage the perlasm code a bit so we only get the NEON routine if we need it
|
|
poly1305-aflags-$(CONFIG_CPU_V7) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=5
|
|
poly1305-aflags-$(CONFIG_KERNEL_MODE_NEON) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=7
|
|
AFLAGS_poly1305-core.o += $(poly1305-aflags-y)
|