diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-24 14:05:18 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-24 14:05:18 -0400 |
| commit | b48a97be8e6c2afdba2f3b61fd88c3c7743fbd73 (patch) | |
| tree | c5b9258be43d7f4e2ec1d91e4b83820562fbaebb | |
| parent | 04012e3076943f17c8cfc77a196701c8f0b8964f (diff) | |
| parent | e70308ec0e4bff344fcfdf160de40e1150552c5f (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu:
"This push fixes a memory corruption issue in caam, as well as
reverting the new optimised crct10dif implementation as it breaks boot
on initrd systems.
Hopefully crct10dif will be reinstated once the supporting code is
added so that it doesn't break boot"
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
Revert "crypto: crct10dif - Wrap crc_t10dif function all to use crypto transform framework"
crypto: caam - Fixed the memory out of bound overwrite issue
| -rw-r--r-- | arch/x86/crypto/Makefile | 2 | ||||
| -rw-r--r-- | arch/x86/crypto/crct10dif-pcl-asm_64.S | 643 | ||||
| -rw-r--r-- | arch/x86/crypto/crct10dif-pclmul_glue.c | 151 | ||||
| -rw-r--r-- | crypto/Kconfig | 19 | ||||
| -rw-r--r-- | crypto/Makefile | 1 | ||||
| -rw-r--r-- | crypto/crct10dif.c | 178 | ||||
| -rw-r--r-- | crypto/tcrypt.c | 8 | ||||
| -rw-r--r-- | crypto/testmgr.c | 10 | ||||
| -rw-r--r-- | crypto/testmgr.h | 33 | ||||
| -rw-r--r-- | drivers/crypto/caam/caamhash.c | 2 | ||||
| -rw-r--r-- | include/linux/crc-t10dif.h | 4 | ||||
| -rw-r--r-- | lib/Kconfig | 2 | ||||
| -rw-r--r-- | lib/crc-t10dif.c | 73 |
13 files changed, 44 insertions, 1082 deletions
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile index 7d6ba9db1be9..6c63c358a7e6 100644 --- a/arch/x86/crypto/Makefile +++ b/arch/x86/crypto/Makefile | |||
| @@ -27,7 +27,6 @@ obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o | |||
| 27 | obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o | 27 | obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o |
| 28 | obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o | 28 | obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o |
| 29 | obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o | 29 | obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o |
| 30 | obj-$(CONFIG_CRYPTO_CRCT10DIF_PCLMUL) += crct10dif-pclmul.o | ||
| 31 | 30 | ||
| 32 | # These modules require assembler to support AVX. | 31 | # These modules require assembler to support AVX. |
| 33 | ifeq ($(avx_supported),yes) | 32 | ifeq ($(avx_supported),yes) |
| @@ -82,4 +81,3 @@ crc32c-intel-$(CONFIG_64BIT) += crc32c-pcl-intel-asm_64.o | |||
| 82 | crc32-pclmul-y := crc32-pclmul_asm.o crc32-pclmul_glue.o | 81 | crc32-pclmul-y := crc32-pclmul_asm.o crc32-pclmul_glue.o |
| 83 | sha256-ssse3-y := sha256-ssse3-asm.o sha256-avx-asm.o sha256-avx2-asm.o sha256_ssse3_glue.o | 82 | sha256-ssse3-y := sha256-ssse3-asm.o sha256-avx-asm.o sha256-avx2-asm.o sha256_ssse3_glue.o |
| 84 | sha512-ssse3-y := sha512-ssse3-asm.o sha512-avx-asm.o sha512-avx2-asm.o sha512_ssse3_glue.o | 83 | sha512-ssse3-y := sha512-ssse3-asm.o sha512-avx-asm.o sha512-avx2-asm.o sha512_ssse3_glue.o |
| 85 | crct10dif-pclmul-y := crct10dif-pcl-asm_64.o crct10dif-pclmul_glue.o | ||
diff --git a/arch/x86/crypto/crct10dif-pcl-asm_64.S b/arch/x86/crypto/crct10dif-pcl-asm_64.S deleted file mode 100644 index 35e97569d05f..000000000000 --- a/arch/x86/crypto/crct10dif-pcl-asm_64.S +++ /dev/null | |||
| @@ -1,643 +0,0 @@ | |||
| 1 | ######################################################################## | ||
| 2 | # Implement fast CRC-T10DIF computation with SSE and PCLMULQDQ instructions | ||
| 3 | # | ||
| 4 | # Copyright (c) 2013, Intel Corporation | ||
| 5 | # | ||
| 6 | # Authors: | ||
| 7 | # Erdinc Ozturk <erdinc.ozturk@intel.com> | ||
| 8 | # Vinodh Gopal <vinodh.gopal@intel.com> | ||
| 9 | # James Guilford <james.guilford@intel.com> | ||
| 10 | # Tim Chen <tim.c.chen@linux.intel.com> | ||
| 11 | # | ||
| 12 | # This software is available to you under a choice of one of two | ||
| 13 | # licenses. You may choose to be licensed under the terms of the GNU | ||
| 14 | # General Public License (GPL) Version 2, available from the file | ||
| 15 | # COPYING in the main directory of this source tree, or the | ||
| 16 | # OpenIB.org BSD license below: | ||
| 17 | # | ||
| 18 | # Redistribution and use in source and binary forms, with or without | ||
| 19 | # modification, are permitted provided that the following conditions are | ||
| 20 | # met: | ||
| 21 | # | ||
| 22 | # * Redistributions of source code must retain the above copyright | ||
| 23 | # notice, this list of conditions and the following disclaimer. | ||
| 24 | # | ||
| 25 | # * Redistributions in binary form must reproduce the above copyright | ||
| 26 | # notice, this list of conditions and the following disclaimer in the | ||
| 27 | # documentation and/or other materials provided with the | ||
| 28 | # distribution. | ||
| 29 | # | ||
| 30 | # * Neither the name of the Intel Corporation nor the names of its | ||
| 31 | # contributors may be used to endorse or promote products derived from | ||
| 32 | # this software without specific prior written permission. | ||
| 33 | # | ||
| 34 | # | ||
| 35 | # THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY | ||
| 36 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 37 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 38 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR | ||
| 39 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| 40 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| 41 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| 42 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 43 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 44 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| 45 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 46 | ######################################################################## | ||
| 47 | # Function API: | ||
| 48 | # UINT16 crc_t10dif_pcl( | ||
| 49 | # UINT16 init_crc, //initial CRC value, 16 bits | ||
| 50 | # const unsigned char *buf, //buffer pointer to calculate CRC on | ||
| 51 | # UINT64 len //buffer length in bytes (64-bit data) | ||
| 52 | # ); | ||
| 53 | # | ||
| 54 | # Reference paper titled "Fast CRC Computation for Generic | ||
| 55 | # Polynomials Using PCLMULQDQ Instruction" | ||
| 56 | # URL: http://www.intel.com/content/dam/www/public/us/en/documents | ||
| 57 | # /white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf | ||
| 58 | # | ||
| 59 | # | ||
| 60 | |||
| 61 | #include <linux/linkage.h> | ||
| 62 | |||
| 63 | .text | ||
| 64 | |||
| 65 | #define arg1 %rdi | ||
| 66 | #define arg2 %rsi | ||
| 67 | #define arg3 %rdx | ||
| 68 | |||
| 69 | #define arg1_low32 %edi | ||
| 70 | |||
| 71 | ENTRY(crc_t10dif_pcl) | ||
| 72 | .align 16 | ||
| 73 | |||
| 74 | # adjust the 16-bit initial_crc value, scale it to 32 bits | ||
| 75 | shl $16, arg1_low32 | ||
| 76 | |||
| 77 | # Allocate Stack Space | ||
| 78 | mov %rsp, %rcx | ||
| 79 | sub $16*2, %rsp | ||
| 80 | # align stack to 16 byte boundary | ||
| 81 | and $~(0x10 - 1), %rsp | ||
| 82 | |||
| 83 | # check if smaller than 256 | ||
| 84 | cmp $256, arg3 | ||
| 85 | |||
| 86 | # for sizes less than 128, we can't fold 64B at a time... | ||
| 87 | jl _less_than_128 | ||
| 88 | |||
| 89 | |||
| 90 | # load the initial crc value | ||
| 91 | movd arg1_low32, %xmm10 # initial crc | ||
| 92 | |||
| 93 | # crc value does not need to be byte-reflected, but it needs | ||
| 94 | # to be moved to the high part of the register. | ||
| 95 | # because data will be byte-reflected and will align with | ||
| 96 | # initial crc at correct place. | ||
| 97 | pslldq $12, %xmm10 | ||
| 98 | |||
| 99 | movdqa SHUF_MASK(%rip), %xmm11 | ||
| 100 | # receive the initial 64B data, xor the initial crc value | ||
| 101 | movdqu 16*0(arg2), %xmm0 | ||
| 102 | movdqu 16*1(arg2), %xmm1 | ||
| 103 | movdqu 16*2(arg2), %xmm2 | ||
| 104 | movdqu 16*3(arg2), %xmm3 | ||
| 105 | movdqu 16*4(arg2), %xmm4 | ||
| 106 | movdqu 16*5(arg2), %xmm5 | ||
| 107 | movdqu 16*6(arg2), %xmm6 | ||
| 108 | movdqu 16*7(arg2), %xmm7 | ||
| 109 | |||
| 110 | pshufb %xmm11, %xmm0 | ||
| 111 | # XOR the initial_crc value | ||
| 112 | pxor %xmm10, %xmm0 | ||
| 113 | pshufb %xmm11, %xmm1 | ||
| 114 | pshufb %xmm11, %xmm2 | ||
| 115 | pshufb %xmm11, %xmm3 | ||
| 116 | pshufb %xmm11, %xmm4 | ||
| 117 | pshufb %xmm11, %xmm5 | ||
| 118 | pshufb %xmm11, %xmm6 | ||
| 119 | pshufb %xmm11, %xmm7 | ||
| 120 | |||
| 121 | movdqa rk3(%rip), %xmm10 #xmm10 has rk3 and rk4 | ||
| 122 | #imm value of pclmulqdq instruction | ||
| 123 | #will determine which constant to use | ||
| 124 | |||
| 125 | ################################################################# | ||
| 126 | # we subtract 256 instead of 128 to save one instruction from the loop | ||
| 127 | sub $256, arg3 | ||
| 128 | |||
| 129 | # at this section of the code, there is 64*x+y (0<=y<64) bytes of | ||
| 130 | # buffer. The _fold_64_B_loop will fold 64B at a time | ||
| 131 | # until we have 64+y Bytes of buffer | ||
| 132 | |||
| 133 | |||
| 134 | # fold 64B at a time. This section of the code folds 4 xmm | ||
| 135 | # registers in parallel | ||
| 136 | _fold_64_B_loop: | ||
| 137 | |||
| 138 | # update the buffer pointer | ||
| 139 | add $128, arg2 # buf += 64# | ||
| 140 | |||
| 141 | movdqu 16*0(arg2), %xmm9 | ||
| 142 | movdqu 16*1(arg2), %xmm12 | ||
| 143 | pshufb %xmm11, %xmm9 | ||
| 144 | pshufb %xmm11, %xmm12 | ||
| 145 | movdqa %xmm0, %xmm8 | ||
| 146 | movdqa %xmm1, %xmm13 | ||
| 147 | pclmulqdq $0x0 , %xmm10, %xmm0 | ||
| 148 | pclmulqdq $0x11, %xmm10, %xmm8 | ||
