diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-09 13:00:15 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-09 13:00:15 -0400 |
| commit | 112cbae26d18e75098d95cc234cfa5059de8d479 (patch) | |
| tree | 8e96670829cbbe668330d364265dfcee511f6182 | |
| parent | 6395ad8559f3a8f4299c027175db00cde67849f7 (diff) | |
| parent | 877ccce7cbe8409256616f5e6bdedb08ce2e82db (diff) | |
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fix from Herbert Xu:
"This fixes a performance regression in arm64 NEON crypto as well as a
crash in x86 aegis/morus on unsupported CPUs"
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: x86/aegis,morus - Fix and simplify CPUID checks
crypto: arm64 - revert NEON yield for fast AEAD implementations
| -rw-r--r-- | arch/arm64/crypto/aes-ce-ccm-core.S | 150 | ||||
| -rw-r--r-- | arch/arm64/crypto/ghash-ce-core.S | 76 | ||||
| -rw-r--r-- | arch/x86/crypto/aegis128-aesni-glue.c | 12 | ||||
| -rw-r--r-- | arch/x86/crypto/aegis128l-aesni-glue.c | 12 | ||||
| -rw-r--r-- | arch/x86/crypto/aegis256-aesni-glue.c | 12 | ||||
| -rw-r--r-- | arch/x86/crypto/morus1280-avx2-glue.c | 10 | ||||
| -rw-r--r-- | arch/x86/crypto/morus1280-sse2-glue.c | 10 | ||||
| -rw-r--r-- | arch/x86/crypto/morus640-sse2-glue.c | 10 |
8 files changed, 101 insertions, 191 deletions
diff --git a/arch/arm64/crypto/aes-ce-ccm-core.S b/arch/arm64/crypto/aes-ce-ccm-core.S index 88f5aef7934c..e3a375c4cb83 100644 --- a/arch/arm64/crypto/aes-ce-ccm-core.S +++ b/arch/arm64/crypto/aes-ce-ccm-core.S | |||
| @@ -19,33 +19,24 @@ | |||
| 19 | * u32 *macp, u8 const rk[], u32 rounds); | 19 | * u32 *macp, u8 const rk[], u32 rounds); |
| 20 | */ | 20 | */ |
| 21 | ENTRY(ce_aes_ccm_auth_data) | 21 | ENTRY(ce_aes_ccm_auth_data) |
| 22 | frame_push 7 | 22 | ldr w8, [x3] /* leftover from prev round? */ |
| 23 | |||
| 24 | mov x19, x0 | ||
| 25 | mov x20, x1 | ||
| 26 | mov x21, x2 | ||
| 27 | mov x22, x3 | ||
| 28 | mov x23, x4 | ||
| 29 | mov x24, x5 | ||
| 30 | |||
| 31 | ldr w25, [x22] /* leftover from prev round? */ | ||
| 32 | ld1 {v0.16b}, [x0] /* load mac */ | 23 | ld1 {v0.16b}, [x0] /* load mac */ |
| 33 | cbz w25, 1f | 24 | cbz w8, 1f |
| 34 | sub w25, w25, #16 | 25 | sub w8, w8, #16 |
| 35 | eor v1.16b, v1.16b, v1.16b | 26 | eor v1.16b, v1.16b, v1.16b |
| 36 | 0: ldrb w7, [x20], #1 /* get 1 byte of input */ | 27 | 0: ldrb w7, [x1], #1 /* get 1 byte of input */ |
| 37 | subs w21, w21, #1 | 28 | subs w2, w2, #1 |
| 38 | add w25, w25, #1 | 29 | add w8, w8, #1 |
| 39 | ins v1.b[0], w7 | 30 | ins v1.b[0], w7 |
| 40 | ext v1.16b, v1.16b, v1.16b, #1 /* rotate in the input bytes */ | 31 | ext v1.16b, v1.16b, v1.16b, #1 /* rotate in the input bytes */ |
| 41 | beq 8f /* out of input? */ | 32 | beq 8f /* out of input? */ |
| 42 | cbnz w25, 0b | 33 | cbnz w8, 0b |
| 43 | eor v0.16b, v0.16b, v1.16b | 34 | eor v0.16b, v0.16b, v1.16b |
| 44 | 1: ld1 {v3.4s}, [x23] /* load first round key */ | 35 | 1: ld1 {v3.4s}, [x4] /* load first round key */ |
| 45 | prfm pldl1strm, [x20] | 36 | prfm pldl1strm, [x1] |
| 46 | cmp w24, #12 /* which key size? */ | 37 | cmp w5, #12 /* which key size? */ |
| 47 | add x6, x23, #16 | 38 | add x6, x4, #16 |
| 48 | sub w7, w24, #2 /* modified # of rounds */ | 39 | sub w7, w5, #2 /* modified # of rounds */ |
| 49 | bmi 2f | 40 | bmi 2f |
| 50 | bne 5f | 41 | bne 5f |
| 51 | mov v5.16b, v3.16b | 42 | mov v5.16b, v3.16b |
| @@ -64,43 +55,33 @@ ENTRY(ce_aes_ccm_auth_data) | |||
| 64 | ld1 {v5.4s}, [x6], #16 /* load next round key */ | 55 | ld1 {v5.4s}, [x6], #16 /* load next round key */ |
| 65 | bpl 3b | 56 | bpl 3b |
| 66 | aese v0.16b, v4.16b | 57 | aese v0.16b, v4.16b |
| 67 | subs w21, w21, #16 /* last data? */ | 58 | subs w2, w2, #16 /* last data? */ |
| 68 | eor v0.16b, v0.16b, v5.16b /* final round */ | 59 | eor v0.16b, v0.16b, v5.16b /* final round */ |
| 69 | bmi 6f | 60 | bmi 6f |
| 70 | ld1 {v1.16b}, [x20], #16 /* load next input block */ | 61 | ld1 {v1.16b}, [x1], #16 /* load next input block */ |
| 71 | eor v0.16b, v0.16b, v1.16b /* xor with mac */ | 62 | eor v0.16b, v0.16b, v1.16b /* xor with mac */ |
| 72 | beq 6f | 63 | bne 1b |
| 73 | 64 | 6: st1 {v0.16b}, [x0] /* store mac */ | |
| 74 | if_will_cond_yield_neon | ||
| 75 | st1 {v0.16b}, [x19] /* store mac */ | ||
| 76 | do_cond_yield_neon | ||
| 77 | ld1 {v0.16b}, [x19] /* reload mac */ | ||
| 78 | endif_yield_neon | ||
| 79 | |||
| 80 | b 1b | ||
| 81 | 6: st1 {v0.16b}, [x19] /* store mac */ | ||
| 82 | beq 10f | 65 | beq 10f |
| 83 | adds w21, w21, #16 | 66 | adds w2, w2, #16 |
| 84 | beq 10f | 67 | beq 10f |
| 85 | mov w25, w21 | 68 | mov w8, w2 |
| 86 | 7: ldrb w7, [x20], #1 | 69 | 7: ldrb w7, [x1], #1 |
| 87 | umov w6, v0.b[0] | 70 | umov w6, v0.b[0] |
| 88 | eor w6, w6, w7 | 71 | eor w6, w6, w7 |
| 89 | strb w6, [x19], #1 | 72 | strb w6, [x0], #1 |
| 90 | subs w21, w21, #1 | 73 | subs w2, w2, #1 |
| 91 | beq 10f | 74 | beq 10f |
| 92 | ext v0.16b, v0.16b, v0.16b, #1 /* rotate out the mac bytes */ | 75 | ext v0.16b, v0.16b, v0.16b, #1 /* rotate out the mac bytes */ |
| 93 | b 7b | 76 | b 7b |
| 94 | 8: mov w7, w25 | 77 | 8: mov w7, w8 |
| 95 | add w25, w25, #16 | 78 | add w8, w8, #16 |
| 96 | 9: ext v1.16b, v1.16b, v1.16b, #1 | 79 | 9: ext v1.16b, v1.16b, v1.16b, #1 |
| 97 | adds w7, w7, #1 | 80 | adds w7, w7, #1 |
| 98 | bne 9b | 81 | bne 9b |
| 99 | eor v0.16b, v0.16b, v1.16b | 82 | eor v0.16b, v0.16b, v1.16b |
| 100 | st1 {v0.16b}, [x19] | 83 | st1 {v0.16b}, [x0] |
| 101 | 10: str w25, [x22] | 84 | 10: str w8, [x3] |
| 102 | |||
| 103 | frame_pop | ||
| 104 | ret | 85 | ret |
| 105 | ENDPROC(ce_aes_ccm_auth_data) | 86 | ENDPROC(ce_aes_ccm_auth_data) |
| 106 | 87 | ||
| @@ -145,29 +126,19 @@ ENTRY(ce_aes_ccm_final) | |||
| 145 | ENDPROC(ce_aes_ccm_final) | 126 | ENDPROC(ce_aes_ccm_final) |
| 146 | 127 | ||
| 147 | .macro aes_ccm_do_crypt,enc | 128 | .macro aes_ccm_do_crypt,enc |
| 148 | frame_push 8 | 129 | ldr x8, [x6, #8] /* load lower ctr */ |
| 149 | 130 | ld1 {v0.16b}, [x5] /* load mac */ | |
| 150 | mov x19, x0 | 131 | CPU_LE( rev x8, x8 ) /* keep swabbed ctr in reg */ |
| 151 | mov x20, x1 | ||
| 152 | mov x21, x2 | ||
| 153 | mov x22, x3 | ||
| 154 | mov x23, x4 | ||
| 155 | mov x24, x5 | ||
| 156 | mov x25, x6 | ||
| 157 | |||
| 158 | ldr x26, [x25, #8] /* load lower ctr */ | ||
| 159 | ld1 {v0.16b}, [x24] /* load mac */ | ||
| 160 | CPU_LE( rev x26, x26 ) /* keep swabbed ctr in reg */ | ||
| 161 | 0: /* outer loop */ | 132 | 0: /* outer loop */ |
| 162 | ld1 {v1.8b}, [x25] /* load upper ctr */ | 133 | ld1 {v1.8b}, [x6] /* load upper ctr */ |
| 163 | prfm pldl1strm, [x20] | 134 | prfm pldl1strm, [x1] |
| 164 | add x26, x26, #1 | 135 | add x8, x8, #1 |
| 165 | rev x9, x26 | 136 | rev x9, x8 |
| 166 | cmp w23, #12 /* which key size? */ | 137 | cmp w4, #12 /* which key size? */ |
| 167 | sub w7, w23, #2 /* get modified # of rounds */ | 138 | sub w7, w4, #2 /* get modified # of rounds */ |
| 168 | ins v1.d[1], x9 /* no carry in lower ctr */ | 139 | ins v1.d[1], x9 /* no carry in lower ctr */ |
| 169 | ld1 {v3.4s}, [x22] /* load first round key */ | 140 | ld1 {v3.4s}, [x3] /* load first round key */ |
| 170 | add x10, x22, #16 | 141 | add x10, x3, #16 |
| 171 | bmi 1f | 142 | bmi 1f |
| 172 | bne 4f | 143 | bne 4f |
| 173 | mov v5.16b, v3.16b | 144 | mov v5.16b, v3.16b |
| @@ -194,9 +165,9 @@ CPU_LE( rev x26, x26 ) /* keep swabbed ctr in reg */ | |||
| 194 | bpl 2b | 165 | bpl 2b |
| 195 | aese v0.16b, v4.16b | 166 | aese v0.16b, v4.16b |
| 196 | aese v1.16b, v4.16b | 167 | aese v1.16b, v4.16b |
| 197 | subs w21, w21, #16 | 168 | subs w2, w2, #16 |
| 198 | bmi 7f /* partial block? */ | 169 | bmi 6f /* partial block? */ |
| 199 | ld1 {v2.16b}, [x20], #16 /* load next input block */ | 170 | ld1 {v2.16b}, [x1], #16 /* load next input block */ |
| 200 | .if \enc == 1 | 171 | .if \enc == 1 |
| 201 | eor v2.16b, v2.16b, v5.16b /* final round enc+mac */ | 172 | eor v2.16b, v2.16b, v5.16b /* final round enc+mac */ |
| 202 | eor v1.16b, v1.16b, v2.16b /* xor with crypted ctr */ | 173 | eor v1.16b, v1.16b, v2.16b /* xor with crypted ctr */ |
| @@ -205,29 +176,18 @@ CPU_LE( rev x26, x26 ) /* keep swabbed ctr in reg */ | |||
| 205 | eor v1.16b, v2.16b, v5.16b /* final round enc */ | 176 | eor v1.16b, v2.16b, v5.16b /* final round enc */ |
| 206 | .endif | 177 | .endif |
| 207 | eor v0.16b, v0.16b, v2.16b /* xor mac with pt ^ rk[last] */ | 178 | eor v0.16b, v0.16b, v2.16b /* xor mac with pt ^ rk[last] */ |
| 208 | st1 {v1.16b}, [x19], #16 /* write output block */ | 179 | st1 {v1.16b}, [x0], #16 /* write output block */ |
| 209 | beq 5f | 180 | bne 0b |
| 210 | 181 | CPU_LE( rev x8, x8 ) | |
| 211 | if_will_cond_yield_neon | 182 | st1 {v0.16b}, [x5] /* store mac */ |
| 212 | st1 {v0.16b}, [x24] /* st | ||
