lib/crypto: arm64: Assume a little-endian kernel
Subsystems (2)
Eric Biggers
maintainerPATCH 1/1 lib/crypto: arm64: Assume a little-endian kernel
Since support for big-endian arm64 kernels was removed, the CPU_LE() macro now unconditionally emits the code it is passed, and the CPU_BE() macro now unconditionally discards the code it is passed.
Simplify the assembly code in lib/crypto/arm64/ accordingly.
---
This patch is targeting libcrypto-next
lib/crypto/arm64/aes-cipher-core.S | 10 ------- lib/crypto/arm64/chacha-neon-core.S | 16 ----------- lib/crypto/arm64/ghash-neon-core.S | 2 +- lib/crypto/arm64/sha1-ce-core.S | 8 +++--- lib/crypto/arm64/sha256-ce.S | 41 +++++++++++++---------------- lib/crypto/arm64/sha512-ce-core.S | 16 +++++------ lib/crypto/arm64/sm3-ce-core.S | 8 +++--- 7 files changed, 36 insertions(+), 65 deletions(-)
lib/crypto/arm64/aes-cipher-core.S +0 -10
@@ -85,15 +85,10 @@ ldp w4, w5, [in] ldp w6, w7, [in, #8] ldp w8, w9, [rk], #16 ldp w10, w11, [rk, #-8] -CPU_BE( rev w4, w4 ) -CPU_BE( rev w5, w5 ) -CPU_BE( rev w6, w6 ) -CPU_BE( rev w7, w7 ) - eor w4, w4, w8 eor w5, w5, w9 eor w6, w6, w10 eor w7, w7, w11
@@ -110,15 +105,10 @@ CPU_BE( rev w7, w7 ) 2: \round w4, w5, w6, w7, w8, w9, w10, w11 b 0b 3: adr_l tt, \ltab \round w4, w5, w6, w7, w8, w9, w10, w11, \bsz, b -CPU_BE( rev w4, w4 ) -CPU_BE( rev w5, w5 ) -CPU_BE( rev w6, w6 ) -CPU_BE( rev w7, w7 ) - stp w4, w5, [out] stp w6, w7, [out, #8] ret .endm
lib/crypto/arm64/chacha-neon-core.S +0 -16
@@ -529,14 +529,10 @@ SYM_FUNC_START(chacha_4block_xor_neon) add a0, a0, w6 add a1, a1, w7 add v3.4s, v3.4s, v19.4s add a2, a2, w8 add a3, a3, w9 -CPU_BE( rev a0, a0 ) -CPU_BE( rev a1, a1 ) -CPU_BE( rev a2, a2 ) -CPU_BE( rev a3, a3 ) ld4r {v24.4s-v27.4s}, [x0], #16 ld4r {v28.4s-v31.4s}, [x0] // x4[0-3] += s1[0]
@@ -553,14 +549,10 @@ CPU_BE( rev a3, a3 ) add a4, a4, w6 add a5, a5, w7 add v7.4s, v7.4s, v23.4s add a6, a6, w8 add a7, a7, w9 -CPU_BE( rev a4, a4 ) -CPU_BE( rev a5, a5 ) -CPU_BE( rev a6, a6 ) -CPU_BE( rev a7, a7 ) // x8[0-3] += s2[0] // x9[0-3] += s2[1] // x10[0-3] += s2[2] // x11[0-3] += s2[3]
@@ -574,14 +566,10 @@ CPU_BE( rev a7, a7 ) add a8, a8, w6 add a9, a9, w7 add v11.4s, v11.4s, v27.4s add a10, a10, w8 add a11, a11, w9 -CPU_BE( rev a8, a8 ) -CPU_BE( rev a9, a9 ) -CPU_BE( rev a10, a10 ) -CPU_BE( rev a11, a11 ) // x12[0-3] += s3[0] // x13[0-3] += s3[1] // x14[0-3] += s3[2] // x15[0-3] += s3[3]
@@ -595,14 +583,10 @@ CPU_BE( rev a11, a11 ) add a12, a12, w6 add a13, a13, w7 add v15.4s, v15.4s, v31.4s add a14, a14, w8 add a15, a15, w9 -CPU_BE( rev a12, a12 ) -CPU_BE( rev a13, a13 ) -CPU_BE( rev a14, a14 ) -CPU_BE( rev a15, a15 ) // interleave 32-bit words in state n, n+1 ldp w6, w7, [x2], #64 zip1 v16.4s, v0.4s, v1.4s ldp w8, w9, [x2, #-56]
lib/crypto/arm64/ghash-neon-core.S +1 -1
@@ -190,11 +190,11 @@ SYM_FUNC_START(pmull_ghash_update_p8) 0: ld1 {T1.2d}, [x2], #16 sub x0, x0, #1 /* multiply XL by SHASH in GF(2^128) */ -CPU_LE( rev64 T1.16b, T1.16b ) + rev64 T1.16b, T1.16b ext T2.16b, XL.16b, XL.16b, #8 ext IN1.16b, T1.16b, T1.16b, #8 eor T1.16b, T1.16b, T2.16b eor XL.16b, XL.16b, IN1.16b
lib/crypto/arm64/sha1-ce-core.S +4 -4
@@ -78,14 +78,14 @@ SYM_FUNC_START(__sha1_ce_transform) /* load input */ 0: ld1 {v8.4s-v11.4s}, [x1], #64 sub x2, x2, #1 -CPU_LE( rev32 v8.16b, v8.16b ) -CPU_LE( rev32 v9.16b, v9.16b ) -CPU_LE( rev32 v10.16b, v10.16b ) -CPU_LE( rev32 v11.16b, v11.16b ) + rev32 v8.16b, v8.16b + rev32 v9.16b, v9.16b + rev32 v10.16b, v10.16b + rev32 v11.16b, v11.16b add t0.4s, v8.4s, k0.4s mov dg0v.16b, dgav.16b add_update c, ev, k0, 8, 9, 10, 11, dgb
lib/crypto/arm64/sha256-ce.S +19 -22
88 lines not on this page · raw message
lib/crypto/arm64/sha512-ce-core.S +8 -8
@@ -108,18 +108,18 @@ SYM_FUNC_START(__sha512_ce_transform) /* load input */ 0: ld1 {v12.2d-v15.2d}, [x1], #64 ld1 {v16.2d-v19.2d}, [x1], #64 sub x2, x2, #1 -CPU_LE( rev64 v12.16b, v12.16b ) -CPU_LE( rev64 v13.16b, v13.16b ) -CPU_LE( rev64 v14.16b, v14.16b ) -CPU_LE( rev64 v15.16b, v15.16b ) -CPU_LE( rev64 v16.16b, v16.16b ) -CPU_LE( rev64 v17.16b, v17.16b ) -CPU_LE( rev64 v18.16b, v18.16b ) -CPU_LE( rev64 v19.16b, v19.16b ) + rev64 v12.16b, v12.16b + rev64 v13.16b, v13.16b + rev64 v14.16b, v14.16b + rev64 v15.16b, v15.16b + rev64 v16.16b, v16.16b + rev64 v17.16b, v17.16b + rev64 v18.16b, v18.16b + rev64 v19.16b, v19.16b mov x4, x3 // rc pointer mov v0.16b, v8.16b mov v1.16b, v9.16b
lib/crypto/arm64/sm3-ce-core.S +4 -4
@@ -89,14 +89,14 @@ SYM_FUNC_START(sm3_ce_transform) sub x2, x2, #1 mov v15.16b, v8.16b mov v16.16b, v9.16b -CPU_LE( rev32 v0.16b, v0.16b ) -CPU_LE( rev32 v1.16b, v1.16b ) -CPU_LE( rev32 v2.16b, v2.16b ) -CPU_LE( rev32 v3.16b, v3.16b ) + rev32 v0.16b, v0.16b + rev32 v1.16b, v1.16b + rev32 v2.16b, v2.16b + rev32 v3.16b, v3.16b ext v11.16b, v13.16b, v13.16b, #4 qround a, v0, v1, v2, v3, v4 qround a, v1, v2, v3, v4, v0
base-commit: d2a68aba8505ce88b39c34ecb3b707c776af79d4
Signature · 1 line
2.53.0
Quoted 11 lines · Eric Biggers
Since support for big-endian arm64 kernels was removed, the
CPU_LE()macro now unconditionally emits the code it is passed, and theCPU_BE()macro now unconditionally discards the code it is passed.Simplify the assembly code in
lib/crypto/arm64/accordingly.Signed-off-by Eric Biggers <[email protected]>---
This patch is targeting libcrypto-next
Quoted 9 lines
lib/crypto/arm64/aes-cipher-core.S | 10 ------- lib/crypto/arm64/chacha-neon-core.S | 16 ----------- lib/crypto/arm64/ghash-neon-core.S | 2 +- lib/crypto/arm64/sha1-ce-core.S | 8 +++--- lib/crypto/arm64/sha256-ce.S | 41 +++++++++++++---------------- lib/crypto/arm64/sha512-ce-core.S | 16 +++++------ lib/crypto/arm64/sm3-ce-core.S | 8 +++--- 7 files changed, 36 insertions(+), 65 deletions(-)
Quoted 8 lines · Eric Biggers
Since support for big-endian arm64 kernels was removed, the
CPU_LE()macro now unconditionally emits the code it is passed, and theCPU_BE()macro now unconditionally discards the code it is passed.Simplify the assembly code in
lib/crypto/arm64/accordingly.Signed-off-by Eric Biggers <[email protected]>---
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next
- Eric