[PATCH v1 2/2] crypto: mediatek - add DT bindings documentation
Add DT bindings documentation for the crypto driver Signed-off-by: Ryder Lee--- .../devicetree/bindings/crypto/mediatek-crypto.txt | 32 ++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt diff --git a/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt b/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt new file mode 100644 index 000..8b1db08 --- /dev/null +++ b/Documentation/devicetree/bindings/crypto/mediatek-crypto.txt @@ -0,0 +1,32 @@ +MediaTek cryptographic accelerators + +Required properties: +- compatible: Should be "mediatek,mt7623-crypto" +- reg: Address and length of the register set for the device +- interrupts: Should contain the five crypto engines interrupts in numeric + order. These are global system and four descriptor rings. +- clocks: the clock used by the core +- clock-names: the names of the clock listed in the clocks property. These are + "ethif", "cryp" +- power-domains: Must contain a reference to the PM domain. + + +Optional properties: +- interrupt-parent: Should be the phandle for the interrupt controller + that services interrupts for this device + + +Example: + crypto: crypto@1b24 { + compatible = "mediatek,mt7623-crypto"; + reg = <0 0x1b24 0 0x2>; + interrupts = , +, +, +, +; + clocks = < CLK_TOP_ETHIF_SEL>, +< CLK_ETHSYS_CRYPTO>; + clock-names = "ethif","cryp"; + power-domains = < MT2701_POWER_DOMAIN_ETH>; + }; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 0/2] Add MediaTek crypto acclelrator driver
Hello, This adds support for the MediaTek hardware accelerator on mt7623 SoC. This driver currently implement: - SHA1 and SHA2 family(HMAC) hash alogrithms. - AES block cipher in CBC/ECB mode with 128/196/256 bits keys. Changes since v1: - remove EXPORT_SYMBOL - remove unused PRNG setting - sort headers in alphabetical order - add a definition for IRQ unmber - replace ambiguous definition - add more annotation and function comment - add COMPILE_TEST in Kconfig Ryder Lee (2): Add crypto driver support for some MediaTek chips crypto: mediatek - add DT bindings documentation .../devicetree/bindings/crypto/mediatek-crypto.txt | 32 + drivers/crypto/Kconfig | 17 + drivers/crypto/Makefile|1 + drivers/crypto/mediatek/Makefile |2 + drivers/crypto/mediatek/mtk-aes.c | 763 +++ drivers/crypto/mediatek/mtk-platform.c | 580 drivers/crypto/mediatek/mtk-platform.h | 235 drivers/crypto/mediatek/mtk-regs.h | 194 +++ drivers/crypto/mediatek/mtk-sha.c | 1423 9 files changed, 3247 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt create mode 100644 drivers/crypto/mediatek/Makefile create mode 100644 drivers/crypto/mediatek/mtk-aes.c create mode 100644 drivers/crypto/mediatek/mtk-platform.c create mode 100644 drivers/crypto/mediatek/mtk-platform.h create mode 100644 drivers/crypto/mediatek/mtk-regs.h create mode 100644 drivers/crypto/mediatek/mtk-sha.c -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 1/2] Add crypto driver support for some MediaTek chips
This adds support for the MediaTek hardware accelerator on mt7623/mt2701/mt8521p SoC. This driver currently implement: - SHA1 and SHA2 family(HMAC) hash alogrithms. - AES block cipher in CBC/ECB mode with 128/196/256 bits keys. Signed-off-by: Ryder Lee--- drivers/crypto/Kconfig | 17 + drivers/crypto/Makefile|1 + drivers/crypto/mediatek/Makefile |2 + drivers/crypto/mediatek/mtk-aes.c | 763 + drivers/crypto/mediatek/mtk-platform.c | 580 + drivers/crypto/mediatek/mtk-platform.h | 235 ++ drivers/crypto/mediatek/mtk-regs.h | 194 + drivers/crypto/mediatek/mtk-sha.c | 1423 8 files changed, 3215 insertions(+) create mode 100644 drivers/crypto/mediatek/Makefile create mode 100644 drivers/crypto/mediatek/mtk-aes.c create mode 100644 drivers/crypto/mediatek/mtk-platform.c create mode 100644 drivers/crypto/mediatek/mtk-platform.h create mode 100644 drivers/crypto/mediatek/mtk-regs.h create mode 100644 drivers/crypto/mediatek/mtk-sha.c diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 4d2b81f..ad0a00b 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig @@ -553,6 +553,23 @@ config CRYPTO_DEV_ROCKCHIP This driver interfaces with the hardware crypto accelerator. Supporting cbc/ecb chainmode, and aes/des/des3_ede cipher mode. +config CRYPTO_DEV_MEDIATEK + tristate "MediaTek's Cryptographic Engine driver" + depends on ARM && (ARCH_MEDIATEK || COMPILE_TEST) + select NEON + select KERNEL_MODE_NEON + select ARM_CRYPTO + select CRYPTO_AES + select CRYPTO_BLKCIPHER + select CRYPTO_SHA1_ARM_NEON + select CRYPTO_SHA256_ARM + select CRYPTO_SHA512_ARM + select CRYPTO_HMAC + help + This driver allows you to utilize the hardware crypto accelerator + which can be found on the MT7623 MT2701, MT8521p, etc + Select this if you want to use it for AES/SHA1/SHA2 algorithms. + source "drivers/crypto/chelsio/Kconfig" endif # CRYPTO_HW diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index ad7250f..272b51a 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_CRYPTO_DEV_IMGTEC_HASH) += img-hash.o obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o obj-$(CONFIG_CRYPTO_DEV_MV_CESA) += mv_cesa.o obj-$(CONFIG_CRYPTO_DEV_MARVELL_CESA) += marvell/ +obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mediatek/ obj-$(CONFIG_CRYPTO_DEV_MXS_DCP) += mxs-dcp.o obj-$(CONFIG_CRYPTO_DEV_NIAGARA2) += n2_crypto.o n2_crypto-y := n2_core.o n2_asm.o diff --git a/drivers/crypto/mediatek/Makefile b/drivers/crypto/mediatek/Makefile new file mode 100644 index 000..187be79 --- /dev/null +++ b/drivers/crypto/mediatek/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mtk-crypto.o +mtk-crypto-objs:= mtk-platform.o mtk-aes.o mtk-sha.o diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c new file mode 100644 index 000..0208981 --- /dev/null +++ b/drivers/crypto/mediatek/mtk-aes.c @@ -0,0 +1,763 @@ +/* + * Cryptographic API. + * + * Support for MediaTek AES hardware accelerator. + * + * Copyright (c) 2016 MediaTek Inc. + * Author: Ryder Lee + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Some ideas are from atmel-aes.c drivers. + */ + +#include +#include +#include +#include +#include +#include "mtk-platform.h" +#include "mtk-regs.h" + +#define AES_QUEUE_LENGTH 512 +#define AES_BUFFER_ORDER 2 +#define AES_BUFFER_SIZE((PAGE_SIZE << AES_BUFFER_ORDER) \ + & ~(AES_BLOCK_SIZE - 1)) + +/* AES command token */ +#define AES_CT_SIZE_ECB2 +#define AES_CT_SIZE_CBC3 +#define AES_CT_CTRL_HDR0x0022 +#define AES_COMMAND0 0x0500 +#define AES_COMMAND1 0x2d06 +#define AES_COMMAND2 0xe4a63806 + +/* AES transform information */ +#define AES_TFM_ECB(0x0 << 0) +#define AES_TFM_CBC(0x1 << 0) +#define AES_TFM_DECRYPT(0x5 << 0) +#define AES_TFM_ENCRYPT(0x4 << 0) +#define AES_TFM_SIZE(x)((x) << 8) +#define AES_TFM_128BITS(0xb << 16) +#define AES_TFM_192BITS(0xd << 16) +#define AES_TFM_256BITS(0xf << 16) +#define AES_TFM_FULL_IV(0xf << 5) + +/* AES flags */ +#define AES_FLAGS_MODE_MSK GENMASK(2, 0) +#define AES_FLAGS_ECB BIT(0) +#define AES_FLAGS_CBC BIT(1) +#define AES_FLAGS_ENCRYPT BIT(2) +#define AES_FLAGS_BUSY BIT(3) + +/** + * AES command token(CT) is a set of hardware
Re: [PATCH] crypto: rsa - fix a potential race condition in build
On Fri, Dec 02, 2016 at 03:41:04PM -0800, Yang Shi wrote: > When building kernel with RSA enabled with multithreaded, the below > compile failure might be caught: > > | /buildarea/kernel-source/crypto/rsa_helper.c:18:28: fatal error: > rsapubkey-asn1.h: No such file or directory > | #include "rsapubkey-asn1.h" > | ^ > | compilation terminated. > | CC crypto/rsa-pkcs1pad.o > | CC crypto/algboss.o > | CC crypto/testmgr.o > | make[3]: *** [/buildarea/kernel-source/scripts/Makefile.build:289: > crypto/rsa_helper.o] Error 1 > | make[3]: *** Waiting for unfinished jobs > | make[2]: *** [/buildarea/kernel-source/Makefile:969: crypto] Error 2 > | make[1]: *** [Makefile:150: sub-make] Error 2 > | make: *** [Makefile:24: __sub-make] Error 2 > > The header file is not generated before rsa_helper is compiled, so > adding dependency to avoid such issue. > > Signed-off-by: Yang ShiThis should already be fixed in the latest crypto tree. Could you please double-check? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Crypto Fixes for 4.9
Hi Linus: This push fixes the following issues: - Intermittent build failure in RSA. - Memory corruption in chelsio crypto driver. - Regression in DRBG due to vmalloced stack. Please pull from git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git linus David Michael (1): crypto: rsa - Add Makefile dependencies to fix parallel builds Harsh Jain (1): crypto: chcr - Fix memory corruption Stephan Mueller (1): crypto: drbg - prevent invalid SG mappings crypto/Makefile|1 + crypto/drbg.c | 29 - drivers/crypto/chelsio/chcr_algo.h |3 ++- include/crypto/drbg.h |2 ++ 4 files changed, 29 insertions(+), 6 deletions(-) Thanks, -- Email: Herbert XuHome Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v5 1/1] crypto: add virtio-crypto driver
I don't think the root cause of those warnings are introduced by virtio-crypto driver. What's your opinion? Sam and David? Thanks, -Gonglei > -Original Message- > From: kbuild test robot [mailto:l...@intel.com] > Sent: Sunday, December 04, 2016 10:40 AM > Subject: Re: [PATCH v5 1/1] crypto: add virtio-crypto driver > > Hi Gonglei, > > [auto build test ERROR on cryptodev/master] > [also build test ERROR on v4.9-rc7 next-20161202] > [if your patch is applied to the wrong git tree, please drop us a note to help > improve the system] > > url: > https://github.com/0day-ci/linux/commits/Gonglei/crypto-add-virtio-crypto-dri > ver/20161202-190424 > base: > https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git > master > config: sparc64-allyesconfig (attached as .config) > compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 > reproduce: > wget > https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cr > oss -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # save the attached .config to linux build tree > make.cross ARCH=sparc64 > > All errors (new ones prefixed by >>): > >In file included from arch/sparc/include/asm/topology.h:4:0, > from include/linux/topology.h:35, > from include/linux/gfp.h:8, > from include/linux/kmod.h:22, > from include/linux/module.h:13, > from drivers/crypto/virtio/virtio_crypto_mgr.c:21: >drivers/crypto/virtio/virtio_crypto_common.h: In function > 'virtio_crypto_get_current_node': > >> arch/sparc/include/asm/topology_64.h:44:44: error: implicit declaration of > function 'cpu_data' [-Werror=implicit-function-declaration] > #define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id) >^ >drivers/crypto/virtio/virtio_crypto_common.h:116:9: note: in expansion of > macro 'topology_physical_package_id' > return topology_physical_package_id(smp_processor_id()); > ^~~~ > >> arch/sparc/include/asm/topology_64.h:44:57: error: request for member > 'proc_id' in something not a structure or union > #define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id) > ^ >drivers/crypto/virtio/virtio_crypto_common.h:116:9: note: in expansion of > macro 'topology_physical_package_id' > return topology_physical_package_id(smp_processor_id()); > ^~~~ >cc1: some warnings being treated as errors > > vim +/cpu_data +44 arch/sparc/include/asm/topology_64.h > > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 28 > 9d079337 arch/sparc/include/asm/topology_64.h David Miller > 2009-01-11 29 #define cpumask_of_pcibus(bus)\ > 9d079337 arch/sparc/include/asm/topology_64.h David Miller > 2009-01-11 30(pcibus_to_node(bus) == -1 ? \ > e9b37512 arch/sparc/include/asm/topology_64.h Rusty Russell > 2009-03-16 31 cpu_all_mask : \ > 9d079337 arch/sparc/include/asm/topology_64.h David Miller > 2009-01-11 32 cpumask_of_node(pcibus_to_node(bus))) > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 33 > 52708d69 arch/sparc/include/asm/topology_64.h Nitin Gupta > 2015-11-02 34 int __node_distance(int, int); > 52708d69 arch/sparc/include/asm/topology_64.h Nitin Gupta > 2015-11-02 35 #define node_distance(a, b) __node_distance(a, b) > 52708d69 arch/sparc/include/asm/topology_64.h Nitin Gupta > 2015-11-02 36 > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 37 #else /* CONFIG_NUMA */ > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 38 > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 39 #include > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 40 > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 41 #endif /* !(CONFIG_NUMA) */ > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 42 > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 43 #ifdef CONFIG_SMP > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 @44 #define topology_physical_package_id(cpu) > (cpu_data(cpu).proc_id) > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 45 #define topology_core_id(cpu) > (cpu_data(cpu).core_id) > acc455cf arch/sparc/include/asm/topology_64.h chris hyser > 2015-04-22 46 #define topology_core_cpumask(cpu) > (_core_sib_map[cpu]) > 06931e62 arch/sparc/include/asm/topology_64.h Bartosz Golaszewski > 2015-05-26 47 #define topology_sibling_cpumask(cpu) > (_cpu(cpu_sibling_map, cpu)) > f5e706ad include/asm-sparc/topology_64.h Sam Ravnborg > 2008-07-17 48 #endif /* CONFIG_SMP */ > f5e706ad
[PATCH v2 6/6] crypto: arm/crc32 - accelerated support based on x86 SSE implementation
This is a combination of the the Intel algorithm implemented using SSE and PCLMULQDQ instructions from arch/x86/crypto/crc32-pclmul_asm.S, and the new CRC32 extensions introduced for both 32-bit and 64-bit ARM in version 8 of the architecture. Two versions of the above combo are provided, one for CRC32 and one for CRC32C. The PMULL/NEON algorithm is faster, but operates on blocks of at least 64 bytes, and on multiples of 16 bytes only. For the remaining input, or for all input on systems that lack the PMULL 64x64->128 instructions, the CRC32 instructions will be used. Signed-off-by: Ard Biesheuvel--- arch/arm/crypto/Kconfig | 5 + arch/arm/crypto/Makefile| 2 + arch/arm/crypto/crc32-ce-core.S | 306 arch/arm/crypto/crc32-ce-glue.c | 195 + 4 files changed, 508 insertions(+) diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index fce801fa52a1..de7bb20815bf 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -125,4 +125,9 @@ config CRYPTO_CRCT10DIF_ARM_CE depends on KERNEL_MODE_NEON && CRC_T10DIF select CRYPTO_HASH +config CRYPTO_CRC32_ARM_CE + tristate "CRC32(C) digest algorithm using CRC and/or PMULL instructions" + depends on KERNEL_MODE_NEON && CRC32 + select CRYPTO_HASH + endif diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile index fc77265014b7..b578a1820ab1 100644 --- a/arch/arm/crypto/Makefile +++ b/arch/arm/crypto/Makefile @@ -14,6 +14,7 @@ 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 +ce-obj-$(CONFIG_CRYPTO_CRC32_ARM_CE) += crc32-arm-ce.o ifneq ($(ce-obj-y)$(ce-obj-m),) ifeq ($(call as-instr,.fpu crypto-neon-fp-armv8,y,n),y) @@ -38,6 +39,7 @@ 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 quiet_cmd_perl = PERL$@ cmd_perl = $(PERL) $(<) > $(@) diff --git a/arch/arm/crypto/crc32-ce-core.S b/arch/arm/crypto/crc32-ce-core.S new file mode 100644 index ..70e0c8042880 --- /dev/null +++ b/arch/arm/crypto/crc32-ce-core.S @@ -0,0 +1,306 @@ +/* + * Accelerated CRC32(C) using ARM CRC, NEON and Crypto Extensions instructions + * + * Copyright (C) 2016 Linaro Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see http://www.gnu.org/licenses + * + * Please visit http://www.xyratex.com/contact if you need additional + * information or have any questions. + * + * GPL HEADER END + */ + +/* + * Copyright 2012 Xyratex Technology Limited + * + * Using hardware provided PCLMULQDQ instruction to accelerate the CRC32 + * calculation. + * CRC32 polynomial:0x04c11db7(BE)/0xEDB88320(LE) + * PCLMULQDQ is a new instruction in Intel SSE4.2, the reference can be found + * at: + * http://www.intel.com/products/processor/manuals/ + * Intel(R) 64 and IA-32 Architectures Software Developer's Manual + * Volume 2B: Instruction Set Reference, N-Z + * + * Authors: Gregory Prestas + * Alexander Boyko + */ + +#include +#include + + .text + .align 6 + .arch armv8-a + .arch_extension crc + .fpucrypto-neon-fp-armv8 + +.Lcrc32_constants: + /* +* [x4*128+32 mod P(x) << 32)]' << 1 = 0x154442bd4 +* #define CONSTANT_R1 0x154442bd4LL +* +* [(x4*128-32 mod P(x) << 32)]' << 1 = 0x1c6e41596 +* #define CONSTANT_R2 0x1c6e41596LL +*/ + .quad 0x000154442bd4 + .quad 0x0001c6e41596 + + /* +* [(x128+32 mod P(x) << 32)]' << 1 = 0x1751997d0 +* #define CONSTANT_R3 0x1751997d0LL +* +*
[PATCH v2 5/6] crypto: arm64/crc32 - accelerated support based on x86 SSE implementation
This is a combination of the the Intel algorithm implemented using SSE and PCLMULQDQ instructions from arch/x86/crypto/crc32-pclmul_asm.S, and the new CRC32 extensions introduced for both 32-bit and 64-bit ARM in version 8 of the architecture. Two versions of the above combo are provided, one for CRC32 and one for CRC32C. The PMULL/NEON algorithm is faster, but operates on blocks of at least 64 bytes, and on multiples of 16 bytes only. For the remaining input, or for all input on systems that lack the PMULL 64x64->128 instructions, the CRC32 instructions will be used. Signed-off-by: Ard Biesheuvel--- arch/arm64/crypto/Kconfig | 6 + arch/arm64/crypto/Makefile| 3 + arch/arm64/crypto/crc32-ce-core.S | 266 arch/arm64/crypto/crc32-ce-glue.c | 188 ++ 4 files changed, 463 insertions(+) diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index d773c0659202..21835deb1ab9 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -28,6 +28,11 @@ config CRYPTO_CRCT10DIF_ARM64_CE depends on KERNEL_MODE_NEON && CRC_T10DIF select CRYPTO_HASH +config CRYPTO_CRC32_ARM64_CE + tristate "CRC32 and CRC32C digest algorithms using PMULL instructions" + depends on KERNEL_MODE_NEON && CRC32 + select CRYPTO_HASH + config CRYPTO_AES_ARM64_CE tristate "AES core cipher using ARMv8 Crypto Extensions" depends on ARM64 && KERNEL_MODE_NEON @@ -58,4 +63,5 @@ config CRYPTO_CRC32_ARM64 tristate "CRC32 and CRC32C using optional ARMv8 instructions" depends on ARM64 select CRYPTO_HASH + endif diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile index 36fd3eb4201b..144387805a46 100644 --- a/arch/arm64/crypto/Makefile +++ b/arch/arm64/crypto/Makefile @@ -20,6 +20,9 @@ ghash-ce-y := ghash-ce-glue.o ghash-ce-core.o obj-$(CONFIG_CRYPTO_CRCT10DIF_ARM64_CE) += crct10dif-ce.o crct10dif-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o +obj-$(CONFIG_CRYPTO_CRC32_ARM64_CE) += crc32-ce.o +crc32-ce-y:= crc32-ce-core.o crc32-ce-glue.o + obj-$(CONFIG_CRYPTO_AES_ARM64_CE) += aes-ce-cipher.o CFLAGS_aes-ce-cipher.o += -march=armv8-a+crypto diff --git a/arch/arm64/crypto/crc32-ce-core.S b/arch/arm64/crypto/crc32-ce-core.S new file mode 100644 index ..18f5a8442276 --- /dev/null +++ b/arch/arm64/crypto/crc32-ce-core.S @@ -0,0 +1,266 @@ +/* + * Accelerated CRC32(C) using arm64 CRC, NEON and Crypto Extensions instructions + * + * Copyright (C) 2016 Linaro Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see http://www.gnu.org/licenses + * + * Please visit http://www.xyratex.com/contact if you need additional + * information or have any questions. + * + * GPL HEADER END + */ + +/* + * Copyright 2012 Xyratex Technology Limited + * + * Using hardware provided PCLMULQDQ instruction to accelerate the CRC32 + * calculation. + * CRC32 polynomial:0x04c11db7(BE)/0xEDB88320(LE) + * PCLMULQDQ is a new instruction in Intel SSE4.2, the reference can be found + * at: + * http://www.intel.com/products/processor/manuals/ + * Intel(R) 64 and IA-32 Architectures Software Developer's Manual + * Volume 2B: Instruction Set Reference, N-Z + * + * Authors: Gregory Prestas + * Alexander Boyko + */ + +#include +#include + + .text + .align 6 + .cpugeneric+crypto+crc + +.Lcrc32_constants: + /* +* [x4*128+32 mod P(x) << 32)]' << 1 = 0x154442bd4 +* #define CONSTANT_R1 0x154442bd4LL +* +* [(x4*128-32 mod P(x) << 32)]' << 1 = 0x1c6e41596 +* #define CONSTANT_R2 0x1c6e41596LL +*/ + .octa 0x0001c6e41596000154442bd4 + + /* +* [(x128+32 mod P(x) << 32)]' << 1 = 0x1751997d0 +* #define CONSTANT_R3 0x1751997d0LL +* +* [(x128-32 mod P(x) << 32)]' << 1 = 0x0ccaa009e +* #define CONSTANT_R4 0x0ccaa009eLL +
[PATCH v2 2/6] crypto: testmgr - add/enhance test cases for CRC-T10DIF
The existing test cases only exercise a small slice of the various possible code paths through the x86 SSE/PCLMULQDQ implementation, and the upcoming ports of it for arm64. So add one that exceeds 256 bytes in size, and convert another to a chunked test. Signed-off-by: Ard Biesheuvel--- crypto/testmgr.h | 70 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/crypto/testmgr.h b/crypto/testmgr.h index e64a4ef9d8ca..b7cd41b25a2a 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -1334,36 +1334,50 @@ static struct hash_testvec rmd320_tv_template[] = { } }; -#define CRCT10DIF_TEST_VECTORS 3 +#define CRCT10DIF_TEST_VECTORS ARRAY_SIZE(crct10dif_tv_template) static struct hash_testvec crct10dif_tv_template[] = { { - .plaintext = "abc", - .psize = 3, -#ifdef __LITTLE_ENDIAN - .digest = "\x3b\x44", -#else - .digest = "\x44\x3b", -#endif - }, { - .plaintext = "1234567890123456789012345678901234567890" -"123456789012345678901234567890123456789", - .psize = 79, -#ifdef __LITTLE_ENDIAN - .digest = "\x70\x4b", -#else - .digest = "\x4b\x70", -#endif - }, { - .plaintext = - "abcd", - .psize = 56, -#ifdef __LITTLE_ENDIAN - .digest = "\xe3\x9c", -#else - .digest = "\x9c\xe3", -#endif - .np = 2, - .tap= { 28, 28 } + .plaintext = "abc", + .psize = 3, + .digest = (u8 *)(u16 []){ 0x443b }, + }, { + .plaintext = "1234567890123456789012345678901234567890" + "123456789012345678901234567890123456789", + .psize = 79, + .digest = (u8 *)(u16 []){ 0x4b70 }, + .np = 2, + .tap= { 63, 16 }, + }, { + .plaintext = "abc" + "d", + .psize = 56, + .digest = (u8 *)(u16 []){ 0x9ce3 }, + .np = 8, + .tap= { 1, 2, 28, 7, 6, 5, 4, 3 }, + }, { + .plaintext = "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "123456789012345678901234567890123456789", + .psize = 319, + .digest = (u8 *)(u16 []){ 0x44c6 }, + }, { + .plaintext = "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "123456789012345678901234567890123456789", + .psize = 319, + .digest = (u8 *)(u16 []){ 0x44c6 }, + .np = 4, + .tap= { 1, 255, 57, 6 }, } }; -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/6] crypto: arm64/crct10dif - port x86 SSE implementation to arm64
This is a transliteration of the Intel algorithm implemented using SSE and PCLMULQDQ instructions that resides in the file arch/x86/crypto/crct10dif-pcl-asm_64.S, but simplified to only operate on multiples of 16 bytes. The residual data is handled by the generic C implementation. Signed-off-by: Ard Biesheuvel--- arch/arm64/crypto/Kconfig | 5 + arch/arm64/crypto/Makefile| 3 + arch/arm64/crypto/crct10dif-ce-core.S | 317 arch/arm64/crypto/crct10dif-ce-glue.c | 91 ++ 4 files changed, 416 insertions(+) diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 2cf32e9887e1..d773c0659202 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -23,6 +23,11 @@ config CRYPTO_GHASH_ARM64_CE depends on ARM64 && KERNEL_MODE_NEON select CRYPTO_HASH +config CRYPTO_CRCT10DIF_ARM64_CE + tristate "CRCT10DIF digest algorithm using PMULL instructions" + depends on KERNEL_MODE_NEON && CRC_T10DIF + select CRYPTO_HASH + config CRYPTO_AES_ARM64_CE tristate "AES core cipher using ARMv8 Crypto Extensions" depends on ARM64 && KERNEL_MODE_NEON diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile index abb79b3cfcfe..36fd3eb4201b 100644 --- a/arch/arm64/crypto/Makefile +++ b/arch/arm64/crypto/Makefile @@ -17,6 +17,9 @@ sha2-ce-y := sha2-ce-glue.o sha2-ce-core.o obj-$(CONFIG_CRYPTO_GHASH_ARM64_CE) += ghash-ce.o ghash-ce-y := ghash-ce-glue.o ghash-ce-core.o +obj-$(CONFIG_CRYPTO_CRCT10DIF_ARM64_CE) += crct10dif-ce.o +crct10dif-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o + obj-$(CONFIG_CRYPTO_AES_ARM64_CE) += aes-ce-cipher.o CFLAGS_aes-ce-cipher.o += -march=armv8-a+crypto diff --git a/arch/arm64/crypto/crct10dif-ce-core.S b/arch/arm64/crypto/crct10dif-ce-core.S new file mode 100644 index ..641685effebd --- /dev/null +++ b/arch/arm64/crypto/crct10dif-ce-core.S @@ -0,0 +1,317 @@ +// +// Accelerated CRC-T10DIF using arm64 NEON and Crypto Extensions instructions +// +// Copyright (C) 2016 Linaro Ltd +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// + +// +// Implement fast CRC-T10DIF computation with SSE and PCLMULQDQ instructions +// +// Copyright (c) 2013, Intel Corporation +// +// Authors: +// Erdinc Ozturk +// Vinodh Gopal +// James Guilford +// Tim Chen +// +// This software is available to you under a choice of one of two +// licenses. You may choose to be licensed under the terms of the GNU +// General Public License (GPL) Version 2, available from the file +// COPYING in the main directory of this source tree, or the +// OpenIB.org BSD license below: +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// +// * Neither the name of the Intel Corporation nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// +// THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Function API: +// UINT16 crc_t10dif_pcl( +// UINT16 init_crc, //initial CRC value, 16 bits +// const unsigned char *buf, //buffer pointer to calculate CRC on +// UINT64 len //buffer length in bytes (64-bit data) +// ); +// +// Reference paper titled "Fast CRC Computation for Generic +// Polynomials Using PCLMULQDQ Instruction" +// URL: http://www.intel.com/content/dam/www/public/us/en/documents +//
[PATCH v2 4/6] crypto: arm/crct10dif - port x86 SSE implementation to ARM
This is a transliteration of the Intel algorithm implemented using SSE and PCLMULQDQ instructions that resides in the file arch/x86/crypto/crct10dif-pcl-asm_64.S, but simplified to only operate on multiples of 16 bytes. The residual data is handled by the generic C implementation. Signed-off-by: Ard Biesheuvel--- arch/arm/crypto/Kconfig | 5 + arch/arm/crypto/Makefile| 2 + arch/arm/crypto/crct10dif-ce-core.S | 349 arch/arm/crypto/crct10dif-ce-glue.c | 95 ++ 4 files changed, 451 insertions(+) diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index 27ed1b1cd1d7..fce801fa52a1 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -120,4 +120,9 @@ config CRYPTO_GHASH_ARM_CE that uses the 64x64 to 128 bit polynomial multiplication (vmull.p64) that is part of the ARMv8 Crypto Extensions +config CRYPTO_CRCT10DIF_ARM_CE + tristate "CRCT10DIF digest algorithm using PMULL instructions" + depends on KERNEL_MODE_NEON && CRC_T10DIF + select CRYPTO_HASH + endif diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile index fc5150702b64..fc77265014b7 100644 --- a/arch/arm/crypto/Makefile +++ b/arch/arm/crypto/Makefile @@ -13,6 +13,7 @@ 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 ifneq ($(ce-obj-y)$(ce-obj-m),) ifeq ($(call as-instr,.fpu crypto-neon-fp-armv8,y,n),y) @@ -36,6 +37,7 @@ 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 quiet_cmd_perl = PERL$@ cmd_perl = $(PERL) $(<) > $(@) diff --git a/arch/arm/crypto/crct10dif-ce-core.S b/arch/arm/crypto/crct10dif-ce-core.S new file mode 100644 index ..ae2adb54e905 --- /dev/null +++ b/arch/arm/crypto/crct10dif-ce-core.S @@ -0,0 +1,349 @@ +// +// Accelerated CRC-T10DIF using ARM NEON and Crypto Extensions instructions +// +// Copyright (C) 2016 Linaro Ltd +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// + +// +// Implement fast CRC-T10DIF computation with SSE and PCLMULQDQ instructions +// +// Copyright (c) 2013, Intel Corporation +// +// Authors: +// Erdinc Ozturk +// Vinodh Gopal +// James Guilford +// Tim Chen +// +// This software is available to you under a choice of one of two +// licenses. You may choose to be licensed under the terms of the GNU +// General Public License (GPL) Version 2, available from the file +// COPYING in the main directory of this source tree, or the +// OpenIB.org BSD license below: +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the +// distribution. +// +// * Neither the name of the Intel Corporation nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// +// THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Function API: +// UINT16 crc_t10dif_pcl( +// UINT16 init_crc, //initial CRC value, 16 bits +// const unsigned char *buf, //buffer pointer to calculate CRC on +// UINT64 len
[PATCH v2 1/6] crypto: testmgr - avoid overlap in chunked tests
The IDXn offsets are chosen such that tap values (which may go up to 255) end up overlapping in the xbuf allocation. In particular, IDX1 and IDX3 are too close together, so update IDX3 to avoid this issue. Signed-off-by: Ard Biesheuvel--- crypto/testmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index ded50b67c757..670893bcf361 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -63,7 +63,7 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask) */ #define IDX1 32 #define IDX2 32400 -#define IDX3 1 +#define IDX3 511 #define IDX4 8193 #define IDX5 2 #define IDX6 17101 -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/6] crypto: ARM/arm64 CRC-T10DIF/CRC32/CRC32C roundup
This v2 combines the CRC-T10DIF and CRC32 implementations for both ARM and arm64 that I sent out a couple of weeks ago, and adds support to the latter for CRC32C. Ard Biesheuvel (6): crypto: testmgr - avoid overlap in chunked tests crypto: testmgr - add/enhance test cases for CRC-T10DIF crypto: arm64/crct10dif - port x86 SSE implementation to arm64 crypto: arm/crct10dif - port x86 SSE implementation to ARM crypto: arm64/crc32 - accelerated support based on x86 SSE implementation crypto: arm/crc32 - accelerated support based on x86 SSE implementation arch/arm/crypto/Kconfig | 10 + arch/arm/crypto/Makefile | 4 + arch/arm/crypto/crc32-ce-core.S | 306 + arch/arm/crypto/crc32-ce-glue.c | 195 +++ arch/arm/crypto/crct10dif-ce-core.S | 349 arch/arm/crypto/crct10dif-ce-glue.c | 95 ++ arch/arm64/crypto/Kconfig | 11 + arch/arm64/crypto/Makefile| 6 + arch/arm64/crypto/crc32-ce-core.S | 266 +++ arch/arm64/crypto/crc32-ce-glue.c | 188 +++ arch/arm64/crypto/crct10dif-ce-core.S | 317 ++ arch/arm64/crypto/crct10dif-ce-glue.c | 91 + crypto/testmgr.c | 2 +- crypto/testmgr.h | 70 ++-- 14 files changed, 1881 insertions(+), 29 deletions(-) create mode 100644 arch/arm/crypto/crc32-ce-core.S create mode 100644 arch/arm/crypto/crc32-ce-glue.c create mode 100644 arch/arm/crypto/crct10dif-ce-core.S create mode 100644 arch/arm/crypto/crct10dif-ce-glue.c create mode 100644 arch/arm64/crypto/crc32-ce-core.S create mode 100644 arch/arm64/crypto/crc32-ce-glue.c create mode 100644 arch/arm64/crypto/crct10dif-ce-core.S create mode 100644 arch/arm64/crypto/crct10dif-ce-glue.c -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html