Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: arm64/sm4 - simplify sm4_ce_expand_key() of CE implementation

Use a 128-bit swap mask and tbl instruction to simplify the implementation
for generating SM4 rkey_dec.

Also fixed the issue of not being wrapped by kernel_neon_begin/end() when
using the sm4_ce_expand_key() function.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Tianjia Zhang and committed by
Herbert Xu
cb9ba02b ce41fefd

+24 -24
+22 -24
arch/arm64/crypto/sm4-ce-core.S
··· 65 65 sm4ekey v6.4s, v5.4s, v30.4s; 66 66 sm4ekey v7.4s, v6.4s, v31.4s; 67 67 68 + adr_l x5, .Lbswap128_mask 69 + ld1 {v24.16b}, [x5] 70 + 68 71 st1 {v0.16b-v3.16b}, [x1], #64; 69 72 st1 {v4.16b-v7.16b}, [x1]; 70 - rev64 v7.4s, v7.4s; 71 - rev64 v6.4s, v6.4s; 72 - rev64 v5.4s, v5.4s; 73 - rev64 v4.4s, v4.4s; 74 - rev64 v3.4s, v3.4s; 75 - rev64 v2.4s, v2.4s; 76 - rev64 v1.4s, v1.4s; 77 - rev64 v0.4s, v0.4s; 78 - ext v7.16b, v7.16b, v7.16b, #8; 79 - ext v6.16b, v6.16b, v6.16b, #8; 80 - ext v5.16b, v5.16b, v5.16b, #8; 81 - ext v4.16b, v4.16b, v4.16b, #8; 82 - ext v3.16b, v3.16b, v3.16b, #8; 83 - ext v2.16b, v2.16b, v2.16b, #8; 84 - ext v1.16b, v1.16b, v1.16b, #8; 85 - ext v0.16b, v0.16b, v0.16b, #8; 86 - st1 {v7.16b}, [x2], #16; 87 - st1 {v6.16b}, [x2], #16; 88 - st1 {v5.16b}, [x2], #16; 89 - st1 {v4.16b}, [x2], #16; 90 - st1 {v3.16b}, [x2], #16; 91 - st1 {v2.16b}, [x2], #16; 92 - st1 {v1.16b}, [x2], #16; 93 - st1 {v0.16b}, [x2]; 73 + 74 + tbl v16.16b, {v7.16b}, v24.16b 75 + tbl v17.16b, {v6.16b}, v24.16b 76 + tbl v18.16b, {v5.16b}, v24.16b 77 + tbl v19.16b, {v4.16b}, v24.16b 78 + tbl v20.16b, {v3.16b}, v24.16b 79 + tbl v21.16b, {v2.16b}, v24.16b 80 + tbl v22.16b, {v1.16b}, v24.16b 81 + tbl v23.16b, {v0.16b}, v24.16b 82 + 83 + st1 {v16.16b-v19.16b}, [x2], #64 84 + st1 {v20.16b-v23.16b}, [x2] 94 85 95 86 ret; 96 87 SYM_FUNC_END(sm4_ce_expand_key) ··· 569 578 570 579 ret 571 580 SYM_FUNC_END(sm4_ce_ctr_enc) 581 + 582 + 583 + .section ".rodata", "a" 584 + .align 4 585 + .Lbswap128_mask: 586 + .byte 0x0c, 0x0d, 0x0e, 0x0f, 0x08, 0x09, 0x0a, 0x0b 587 + .byte 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03
+2
arch/arm64/crypto/sm4-ce-glue.c
··· 44 44 if (key_len != SM4_KEY_SIZE) 45 45 return -EINVAL; 46 46 47 + kernel_neon_begin(); 47 48 sm4_ce_expand_key(key, ctx->rkey_enc, ctx->rkey_dec, 48 49 crypto_sm4_fk, crypto_sm4_ck); 50 + kernel_neon_end(); 49 51 return 0; 50 52 } 51 53