2019-06-04 11:11:33 +03:00
/* SPDX-License-Identifier: GPL-2.0-only */
2014-03-21 13:19:17 +04:00
/ *
* linux/ a r c h / a r m 6 4 / c r y p t o / a e s - n e o n . S - A E S c i p h e r f o r A R M v8 N E O N
*
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
* Copyright ( C ) 2 0 1 3 - 2 0 1 7 L i n a r o L t d . < a r d . b i e s h e u v e l @linaro.org>
2014-03-21 13:19:17 +04:00
* /
# include < l i n u x / l i n k a g e . h >
2016-10-11 21:15:18 +03:00
# include < a s m / a s s e m b l e r . h >
2014-03-21 13:19:17 +04:00
2020-02-18 22:58:26 +03:00
# define A E S _ F U N C _ S T A R T ( f u n c ) S Y M _ F U N C _ S T A R T ( n e o n _ ## f u n c )
# define A E S _ F U N C _ E N D ( f u n c ) S Y M _ F U N C _ E N D ( n e o n _ ## f u n c )
2014-03-21 13:19:17 +04:00
2018-09-10 17:41:15 +03:00
xtsmask . r e q v7
crypto: arm64/aes-ce - implement 5 way interleave for ECB, CBC and CTR
This implements 5-way interleaving for ECB, CBC decryption and CTR,
resulting in a speedup of ~11% on Marvell ThunderX2, which has a
very deep pipeline and therefore a high issue latency for NEON
instructions operating on the same registers.
Note that XTS is left alone: implementing 5-way interleave there
would either involve spilling of the calculated tweaks to the
stack, or recalculating them after the encryption operation, and
doing either of those would most likely penalize low end cores.
For ECB, this is not a concern at all, given that we have plenty
of spare registers. For CTR and CBC decryption, we take advantage
of the fact that v16 is not used by the CE version of the code
(which is the only one targeted by the optimization), and so we
can reshuffle the code a bit and avoid having to spill to memory
(with the exception of one extra reload in the CBC routine)
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2019-06-24 20:38:31 +03:00
cbciv . r e q v7
vctr . r e q v4
2018-09-10 17:41:15 +03:00
.macro xts_ r e l o a d _ m a s k , t m p
xts_ l o a d _ m a s k \ t m p
.endm
2019-09-03 19:43:34 +03:00
/* special case for the neon-bs driver calling into this one for CTS */
.macro xts_ c t s _ s k i p _ t w , r e g , l b l
tbnz \ r e g , #1 , \ l b l
.endm
2014-03-21 13:19:17 +04:00
/* multiply by polynomial 'x' in GF(2^8) */
.macro mul_ b y _ x , o u t , i n , t e m p , c o n s t
sshr \ t e m p , \ i n , #7
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
shl \ o u t , \ i n , #1
2014-03-21 13:19:17 +04:00
and \ t e m p , \ t e m p , \ c o n s t
eor \ o u t , \ o u t , \ t e m p
.endm
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
/* multiply by polynomial 'x^2' in GF(2^8) */
.macro mul_ b y _ x2 , o u t , i n , t e m p , c o n s t
ushr \ t e m p , \ i n , #6
shl \ o u t , \ i n , #2
pmul \ t e m p , \ t e m p , \ c o n s t
eor \ o u t , \ o u t , \ t e m p
.endm
2014-03-21 13:19:17 +04:00
/* preload the entire Sbox */
.macro prepare, s b o x , s h i f t r o w s , t e m p
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
movi v12 . 1 6 b , #0x1b
2018-01-10 15:11:38 +03:00
ldr_ l q13 , \ s h i f t r o w s , \ t e m p
ldr_ l q14 , . L r o r32 b y 8 , \ t e m p
adr_ l \ t e m p , \ s b o x
2014-03-21 13:19:17 +04:00
ld1 { v16 . 1 6 b - v19 . 1 6 b } , [ \ t e m p ] , #64
ld1 { v20 . 1 6 b - v23 . 1 6 b } , [ \ t e m p ] , #64
ld1 { v24 . 1 6 b - v27 . 1 6 b } , [ \ t e m p ] , #64
ld1 { v28 . 1 6 b - v31 . 1 6 b } , [ \ t e m p ]
.endm
/* do preload for encryption */
.macro enc_ p r e p a r e , i g n o r e 0 , i g n o r e 1 , t e m p
2019-07-02 22:41:47 +03:00
prepare c r y p t o _ a e s _ s b o x , . L F o r w a r d _ S h i f t R o w s , \ t e m p
2014-03-21 13:19:17 +04:00
.endm
.macro enc_ s w i t c h _ k e y , i g n o r e 0 , i g n o r e 1 , t e m p
/* do nothing */
.endm
/* do preload for decryption */
.macro dec_ p r e p a r e , i g n o r e 0 , i g n o r e 1 , t e m p
2019-07-02 22:41:47 +03:00
prepare c r y p t o _ a e s _ i n v _ s b o x , . L R e v e r s e _ S h i f t R o w s , \ t e m p
2014-03-21 13:19:17 +04:00
.endm
/* apply SubBytes transformation using the the preloaded Sbox */
.macro sub_ b y t e s , i n
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v9 . 1 6 b , \ i n \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbl \ i n \ ( ) . 1 6 b , { v16 . 1 6 b - v19 . 1 6 b } , \ i n \ ( ) . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v10 . 1 6 b , v9 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n \ ( ) . 1 6 b , { v20 . 1 6 b - v23 . 1 6 b } , v9 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v11 . 1 6 b , v10 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n \ ( ) . 1 6 b , { v24 . 1 6 b - v27 . 1 6 b } , v10 . 1 6 b
tbx \ i n \ ( ) . 1 6 b , { v28 . 1 6 b - v31 . 1 6 b } , v11 . 1 6 b
.endm
/* apply MixColumns transformation */
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
.macro mix_ c o l u m n s , i n , e n c
.if \ enc = = 0
2014-03-21 13:19:17 +04:00
/* Inverse MixColumns: pre-multiply by { 5, 0, 4, 0 } */
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
mul_ b y _ x2 v8 . 1 6 b , \ i n \ ( ) . 1 6 b , v9 . 1 6 b , v12 . 1 6 b
eor \ i n \ ( ) . 1 6 b , \ i n \ ( ) . 1 6 b , v8 . 1 6 b
rev3 2 v8 . 8 h , v8 . 8 h
eor \ i n \ ( ) . 1 6 b , \ i n \ ( ) . 1 6 b , v8 . 1 6 b
.endif
mul_ b y _ x v9 . 1 6 b , \ i n \ ( ) . 1 6 b , v8 . 1 6 b , v12 . 1 6 b
rev3 2 v8 . 8 h , \ i n \ ( ) . 8 h
eor v8 . 1 6 b , v8 . 1 6 b , v9 . 1 6 b
eor \ i n \ ( ) . 1 6 b , \ i n \ ( ) . 1 6 b , v8 . 1 6 b
tbl \ i n \ ( ) . 1 6 b , { \ i n \ ( ) . 1 6 b } , v14 . 1 6 b
eor \ i n \ ( ) . 1 6 b , \ i n \ ( ) . 1 6 b , v8 . 1 6 b
2014-03-21 13:19:17 +04:00
.endm
.macro do_ b l o c k , e n c , i n , r o u n d s , r k , r k p , i
2016-10-11 21:15:18 +03:00
ld1 { v15 . 4 s } , [ \ r k ]
2014-03-21 13:19:17 +04:00
add \ r k p , \ r k , #16
mov \ i , \ r o u n d s
1111 : eor \ i n \ ( ) . 1 6 b , \ i n \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
movi v15 . 1 6 b , #0x40
2014-03-21 13:19:17 +04:00
tbl \ i n \ ( ) . 1 6 b , { \ i n \ ( ) . 1 6 b } , v13 . 1 6 b / * S h i f t R o w s * /
sub_ b y t e s \ i n
subs \ i , \ i , #1
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
ld1 { v15 . 4 s } , [ \ r k p ] , #16
2014-03-21 13:19:17 +04:00
beq 2 2 2 2 f
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
mix_ c o l u m n s \ i n , \ e n c
2014-03-21 13:19:17 +04:00
b 1 1 1 1 b
2222 : eor \ i n \ ( ) . 1 6 b , \ i n \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
.endm
.macro encrypt_ b l o c k , i n , r o u n d s , r k , r k p , i
do_ b l o c k 1 , \ i n , \ r o u n d s , \ r k , \ r k p , \ i
.endm
.macro decrypt_ b l o c k , i n , r o u n d s , r k , r k p , i
do_ b l o c k 0 , \ i n , \ r o u n d s , \ r k , \ r k p , \ i
.endm
/ *
* Interleaved v e r s i o n s : f u n c t i o n a l l y e q u i v a l e n t t o t h e
2019-06-24 20:38:30 +03:00
* ones a b o v e , b u t a p p l i e d t o A E S s t a t e s i n p a r a l l e l .
2014-03-21 13:19:17 +04:00
* /
.macro sub_ b y t e s _ 4 x , i n 0 , i n 1 , i n 2 , i n 3
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v8 . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbl \ i n 0 \ ( ) . 1 6 b , { v16 . 1 6 b - v19 . 1 6 b } , \ i n 0 \ ( ) . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v9 . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbl \ i n 1 \ ( ) . 1 6 b , { v16 . 1 6 b - v19 . 1 6 b } , \ i n 1 \ ( ) . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v10 . 1 6 b , \ i n 2 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbl \ i n 2 \ ( ) . 1 6 b , { v16 . 1 6 b - v19 . 1 6 b } , \ i n 2 \ ( ) . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v11 . 1 6 b , \ i n 3 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbl \ i n 3 \ ( ) . 1 6 b , { v16 . 1 6 b - v19 . 1 6 b } , \ i n 3 \ ( ) . 1 6 b
tbx \ i n 0 \ ( ) . 1 6 b , { v20 . 1 6 b - v23 . 1 6 b } , v8 . 1 6 b
tbx \ i n 1 \ ( ) . 1 6 b , { v20 . 1 6 b - v23 . 1 6 b } , v9 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v8 . 1 6 b , v8 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n 2 \ ( ) . 1 6 b , { v20 . 1 6 b - v23 . 1 6 b } , v10 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v9 . 1 6 b , v9 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n 3 \ ( ) . 1 6 b , { v20 . 1 6 b - v23 . 1 6 b } , v11 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v10 . 1 6 b , v10 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n 0 \ ( ) . 1 6 b , { v24 . 1 6 b - v27 . 1 6 b } , v8 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v11 . 1 6 b , v11 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n 1 \ ( ) . 1 6 b , { v24 . 1 6 b - v27 . 1 6 b } , v9 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v8 . 1 6 b , v8 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n 2 \ ( ) . 1 6 b , { v24 . 1 6 b - v27 . 1 6 b } , v10 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v9 . 1 6 b , v9 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n 3 \ ( ) . 1 6 b , { v24 . 1 6 b - v27 . 1 6 b } , v11 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v10 . 1 6 b , v10 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n 0 \ ( ) . 1 6 b , { v28 . 1 6 b - v31 . 1 6 b } , v8 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub v11 . 1 6 b , v11 . 1 6 b , v15 . 1 6 b
2014-03-21 13:19:17 +04:00
tbx \ i n 1 \ ( ) . 1 6 b , { v28 . 1 6 b - v31 . 1 6 b } , v9 . 1 6 b
tbx \ i n 2 \ ( ) . 1 6 b , { v28 . 1 6 b - v31 . 1 6 b } , v10 . 1 6 b
tbx \ i n 3 \ ( ) . 1 6 b , { v28 . 1 6 b - v31 . 1 6 b } , v11 . 1 6 b
.endm
.macro mul_ b y _ x _ 2 x , o u t 0 , o u t 1 , i n 0 , i n 1 , t m p0 , t m p1 , c o n s t
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sshr \ t m p0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , #7
shl \ o u t 0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , #1
sshr \ t m p1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , #7
2014-03-21 13:19:17 +04:00
and \ t m p0 \ ( ) . 1 6 b , \ t m p0 \ ( ) . 1 6 b , \ c o n s t \ ( ) . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
shl \ o u t 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , #1
2014-03-21 13:19:17 +04:00
and \ t m p1 \ ( ) . 1 6 b , \ t m p1 \ ( ) . 1 6 b , \ c o n s t \ ( ) . 1 6 b
eor \ o u t 0 \ ( ) . 1 6 b , \ o u t 0 \ ( ) . 1 6 b , \ t m p0 \ ( ) . 1 6 b
eor \ o u t 1 \ ( ) . 1 6 b , \ o u t 1 \ ( ) . 1 6 b , \ t m p1 \ ( ) . 1 6 b
.endm
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
.macro mul_ b y _ x2 _ 2 x , o u t 0 , o u t 1 , i n 0 , i n 1 , t m p0 , t m p1 , c o n s t
ushr \ t m p0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , #6
shl \ o u t 0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , #2
ushr \ t m p1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , #6
pmul \ t m p0 \ ( ) . 1 6 b , \ t m p0 \ ( ) . 1 6 b , \ c o n s t \ ( ) . 1 6 b
shl \ o u t 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , #2
pmul \ t m p1 \ ( ) . 1 6 b , \ t m p1 \ ( ) . 1 6 b , \ c o n s t \ ( ) . 1 6 b
eor \ o u t 0 \ ( ) . 1 6 b , \ o u t 0 \ ( ) . 1 6 b , \ t m p0 \ ( ) . 1 6 b
eor \ o u t 1 \ ( ) . 1 6 b , \ o u t 1 \ ( ) . 1 6 b , \ t m p1 \ ( ) . 1 6 b
2014-03-21 13:19:17 +04:00
.endm
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
.macro mix_ c o l u m n s _ 2 x , i n 0 , i n 1 , e n c
.if \ enc = = 0
/* Inverse MixColumns: pre-multiply by { 5, 0, 4, 0 } */
mul_ b y _ x2 _ 2 x v8 , v9 , \ i n 0 , \ i n 1 , v10 , v11 , v12
2014-03-21 13:19:17 +04:00
eor \ i n 0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v8 . 1 6 b
rev3 2 v8 . 8 h , v8 . 8 h
eor \ i n 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v9 . 1 6 b
rev3 2 v9 . 8 h , v9 . 8 h
eor \ i n 0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v8 . 1 6 b
eor \ i n 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v9 . 1 6 b
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
.endif
mul_ b y _ x _ 2 x v8 , v9 , \ i n 0 , \ i n 1 , v10 , v11 , v12
rev3 2 v10 . 8 h , \ i n 0 \ ( ) . 8 h
rev3 2 v11 . 8 h , \ i n 1 \ ( ) . 8 h
eor v10 . 1 6 b , v10 . 1 6 b , v8 . 1 6 b
eor v11 . 1 6 b , v11 . 1 6 b , v9 . 1 6 b
eor \ i n 0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v10 . 1 6 b
eor \ i n 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v11 . 1 6 b
tbl \ i n 0 \ ( ) . 1 6 b , { \ i n 0 \ ( ) . 1 6 b } , v14 . 1 6 b
tbl \ i n 1 \ ( ) . 1 6 b , { \ i n 1 \ ( ) . 1 6 b } , v14 . 1 6 b
eor \ i n 0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v10 . 1 6 b
eor \ i n 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v11 . 1 6 b
2014-03-21 13:19:17 +04:00
.endm
.macro do_ b l o c k _ 4 x , e n c , i n 0 , i n 1 , i n 2 , i n 3 , r o u n d s , r k , r k p , i
2016-10-11 21:15:18 +03:00
ld1 { v15 . 4 s } , [ \ r k ]
2014-03-21 13:19:17 +04:00
add \ r k p , \ r k , #16
mov \ i , \ r o u n d s
1111 : eor \ i n 0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
eor \ i n 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
eor \ i n 2 \ ( ) . 1 6 b , \ i n 2 \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
eor \ i n 3 \ ( ) . 1 6 b , \ i n 3 \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
movi v15 . 1 6 b , #0x40
2014-03-21 13:19:17 +04:00
tbl \ i n 0 \ ( ) . 1 6 b , { \ i n 0 \ ( ) . 1 6 b } , v13 . 1 6 b / * S h i f t R o w s * /
tbl \ i n 1 \ ( ) . 1 6 b , { \ i n 1 \ ( ) . 1 6 b } , v13 . 1 6 b / * S h i f t R o w s * /
tbl \ i n 2 \ ( ) . 1 6 b , { \ i n 2 \ ( ) . 1 6 b } , v13 . 1 6 b / * S h i f t R o w s * /
tbl \ i n 3 \ ( ) . 1 6 b , { \ i n 3 \ ( ) . 1 6 b } , v13 . 1 6 b / * S h i f t R o w s * /
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
sub_ b y t e s _ 4 x \ i n 0 , \ i n 1 , \ i n 2 , \ i n 3
2014-03-21 13:19:17 +04:00
subs \ i , \ i , #1
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
ld1 { v15 . 4 s } , [ \ r k p ] , #16
2014-03-21 13:19:17 +04:00
beq 2 2 2 2 f
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
mix_ c o l u m n s _ 2 x \ i n 0 , \ i n 1 , \ e n c
mix_ c o l u m n s _ 2 x \ i n 2 , \ i n 3 , \ e n c
2014-03-21 13:19:17 +04:00
b 1 1 1 1 b
2222 : eor \ i n 0 \ ( ) . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
eor \ i n 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
eor \ i n 2 \ ( ) . 1 6 b , \ i n 2 \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
eor \ i n 3 \ ( ) . 1 6 b , \ i n 3 \ ( ) . 1 6 b , v15 . 1 6 b / * ^ r o u n d k e y * /
.endm
.macro encrypt_ b l o c k 4 x , i n 0 , i n 1 , i n 2 , i n 3 , r o u n d s , r k , r k p , i
do_ b l o c k _ 4 x 1 , \ i n 0 , \ i n 1 , \ i n 2 , \ i n 3 , \ r o u n d s , \ r k , \ r k p , \ i
.endm
.macro decrypt_ b l o c k 4 x , i n 0 , i n 1 , i n 2 , i n 3 , r o u n d s , r k , r k p , i
do_ b l o c k _ 4 x 0 , \ i n 0 , \ i n 1 , \ i n 2 , \ i n 3 , \ r o u n d s , \ r k , \ r k p , \ i
.endm
# include " a e s - m o d e s . S "
2018-01-10 15:11:38 +03:00
.section " .rodata " , " a"
2019-07-02 22:41:47 +03:00
.align 4
crypto: arm64/aes-neon-blk - tweak performance for low end cores
The non-bitsliced AES implementation using the NEON is highly sensitive
to micro-architectural details, and, as it turns out, the Cortex-A53 on
the Raspberry Pi 3 is a core that can benefit from this code, given that
its scalar AES performance is abysmal (32.9 cycles per byte).
The new bitsliced AES code manages 19.8 cycles per byte on this core,
but can only operate on 8 blocks at a time, which is not supported by
all chaining modes. With a bit of tweaking, we can get the plain NEON
code to run at 22.0 cycles per byte, making it useful for sequential
modes like CBC encryption. (Like bitsliced NEON, the plain NEON
implementation does not use any lookup tables, which makes it easy on
the D-cache, and invulnerable to cache timing attacks)
So tweak the plain NEON AES code to use tbl instructions rather than
shl/sri pairs, and to avoid the need to reload permutation vectors or
other constants from memory in every round. Also, improve the decryption
performance by switching to 16x8 pmul instructions for the performing
the multiplications in GF(2^8).
To allow the ECB and CBC encrypt routines to be reused by the bitsliced
NEON code in a subsequent patch, export them from the module.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-29 02:25:38 +03:00
.LForward_ShiftRows :
.octa 0x0b06010c07020d08030e09040f0a0500
.LReverse_ShiftRows :
.octa 0x0306090c0f0205080b0e0104070a0d00
.Lror32by8 :
.octa 0x0c0f0e0d080b0a090407060500030201