2019-06-04 10:11:33 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2014-03-21 10:19:17 +01: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-28 23:25:38 +00: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 10:19:17 +01:00
* /
# include < l i n u x / l i n k a g e . h >
2016-10-11 19:15:18 +01:00
# include < a s m / a s s e m b l e r . h >
2014-03-21 10:19:17 +01:00
# define A E S _ E N T R Y ( f u n c ) E N T R Y ( n e o n _ ## f u n c )
# define A E S _ E N D P R O C ( f u n c ) E N D P R O C ( n e o n _ ## f u n c )
2018-09-10 16:41:15 +02:00
xtsmask . r e q v7
.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
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
shl \ o u t , \ i n , #1
2014-03-21 10:19:17 +01: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-28 23:25:38 +00: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 10:19:17 +01: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-28 23:25:38 +00:00
movi v12 . 1 6 b , #0x1b
2018-01-10 12:11:38 +00: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 10:19:17 +01: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
prepare . L F o r w a r d _ 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
.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
prepare . L R e v e r s e _ 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
.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-28 23:25:38 +00:00
sub v9 . 1 6 b , \ i n \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v10 . 1 6 b , v9 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v11 . 1 6 b , v10 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
.macro mix_ c o l u m n s , i n , e n c
.if \ enc = = 0
2014-03-21 10:19:17 +01: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-28 23:25:38 +00: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 10:19:17 +01: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 19:15:18 +01:00
ld1 { v15 . 4 s } , [ \ r k ]
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
movi v15 . 1 6 b , #0x40
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
ld1 { v15 . 4 s } , [ \ r k p ] , #16
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
mix_ c o l u m n s \ i n , \ e n c
2014-03-21 10:19:17 +01: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
* ones a b o v e , b u t a p p l i e d t o 2 o r 4 A E S s t a t e s i n p a r a l l e l .
* /
.macro sub_ b y t e s _ 2 x , i n 0 , i n 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-28 23:25:38 +00:00
sub v8 . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v9 . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v10 . 1 6 b , v8 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01:00
tbx \ i n 0 \ ( ) . 1 6 b , { v20 . 1 6 b - v23 . 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-28 23:25:38 +00:00
sub v11 . 1 6 b , v9 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01:00
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-28 23:25:38 +00:00
sub v8 . 1 6 b , v10 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01:00
tbx \ i n 0 \ ( ) . 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-28 23:25:38 +00:00
sub v9 . 1 6 b , v11 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01:00
tbx \ i n 1 \ ( ) . 1 6 b , { v24 . 1 6 b - v27 . 1 6 b } , v11 . 1 6 b
tbx \ i n 0 \ ( ) . 1 6 b , { v28 . 1 6 b - v31 . 1 6 b } , v8 . 1 6 b
tbx \ i n 1 \ ( ) . 1 6 b , { v28 . 1 6 b - v31 . 1 6 b } , v9 . 1 6 b
.endm
.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-28 23:25:38 +00:00
sub v8 . 1 6 b , \ i n 0 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v9 . 1 6 b , \ i n 1 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v10 . 1 6 b , \ i n 2 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v11 . 1 6 b , \ i n 3 \ ( ) . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v8 . 1 6 b , v8 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v9 . 1 6 b , v9 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v10 . 1 6 b , v10 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v11 . 1 6 b , v11 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v8 . 1 6 b , v8 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v9 . 1 6 b , v9 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v10 . 1 6 b , v10 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub v11 . 1 6 b , v11 . 1 6 b , v15 . 1 6 b
2014-03-21 10:19:17 +01: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-28 23:25:38 +00: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 10:19:17 +01: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-28 23:25:38 +00:00
shl \ o u t 1 \ ( ) . 1 6 b , \ i n 1 \ ( ) . 1 6 b , #1
2014-03-21 10:19:17 +01: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-28 23:25:38 +00: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 10:19:17 +01: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-28 23:25:38 +00: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 10:19:17 +01: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-28 23:25:38 +00: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 10:19:17 +01: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-28 23:25:38 +00:00
.macro do_ b l o c k _ 2 x , e n c , i n 0 , i n 1 , r o u n d s , r k , r k p , i
2016-10-11 19:15:18 +01:00
ld1 { v15 . 4 s } , [ \ r k ]
2014-03-21 10:19:17 +01: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 * /
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-28 23:25:38 +00:00
movi v15 . 1 6 b , #0x40
2014-03-21 10:19:17 +01: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 * /
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-28 23:25:38 +00:00
sub_ b y t e s _ 2 x \ i n 0 , \ i n 1
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
ld1 { v15 . 4 s } , [ \ r k p ] , #16
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
mix_ c o l u m n s _ 2 x \ i n 0 , \ i n 1 , \ e n c
2014-03-21 10:19:17 +01: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 * /
.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 19:15:18 +01:00
ld1 { v15 . 4 s } , [ \ r k ]
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
movi v15 . 1 6 b , #0x40
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
sub_ b y t e s _ 4 x \ i n 0 , \ i n 1 , \ i n 2 , \ i n 3
2014-03-21 10:19:17 +01: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-28 23:25:38 +00:00
ld1 { v15 . 4 s } , [ \ r k p ] , #16
2014-03-21 10:19:17 +01: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-28 23:25:38 +00: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 10:19:17 +01: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 2 x , i n 0 , i n 1 , r o u n d s , r k , r k p , i
do_ b l o c k _ 2 x 1 , \ i n 0 , \ i n 1 , \ r o u n d s , \ r k , \ r k p , \ i
.endm
.macro decrypt_ b l o c k 2 x , i n 0 , i n 1 , r o u n d s , r k , r k p , i
do_ b l o c k _ 2 x 0 , \ i n 0 , \ i n 1 , \ r o u n d s , \ r k , \ r k p , \ i
.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 12:11:38 +00:00
.section " .rodata " , " a"
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-28 23:25:38 +00:00
.align 6
2014-03-21 10:19:17 +01:00
.LForward_Sbox :
.byte 0 x6 3 , 0 x7 c , 0 x77 , 0 x7 b , 0 x f2 , 0 x6 b , 0 x6 f , 0 x c5
.byte 0 x3 0 , 0 x01 , 0 x67 , 0 x2 b , 0 x f e , 0 x d7 , 0 x a b , 0 x76
.byte 0 xca, 0 x82 , 0 x c9 , 0 x7 d , 0 x f a , 0 x59 , 0 x47 , 0 x f0
.byte 0 xad, 0 x d4 , 0 x a2 , 0 x a f , 0 x9 c , 0 x a4 , 0 x72 , 0 x c0
.byte 0 xb7 , 0 x f d , 0 x93 , 0 x26 , 0 x36 , 0 x3 f , 0 x f7 , 0 x c c
.byte 0 x3 4 , 0 x a5 , 0 x e 5 , 0 x f1 , 0 x71 , 0 x d8 , 0 x31 , 0 x15
.byte 0 x0 4 , 0 x c7 , 0 x23 , 0 x c3 , 0 x18 , 0 x96 , 0 x05 , 0 x9 a
.byte 0 x0 7 , 0 x12 , 0 x80 , 0 x e 2 , 0 x e b , 0 x27 , 0 x b2 , 0 x75
.byte 0 x0 9 , 0 x83 , 0 x2 c , 0 x1 a , 0 x1 b , 0 x6 e , 0 x5 a , 0 x a0
.byte 0 x5 2 , 0 x3 b , 0 x d6 , 0 x b3 , 0 x29 , 0 x e 3 , 0 x2 f , 0 x84
.byte 0 x5 3 , 0 x d1 , 0 x00 , 0 x e d , 0 x20 , 0 x f c , 0 x b1 , 0 x5 b
.byte 0 x6 a , 0 x c b , 0 x b e , 0 x39 , 0 x4 a , 0 x4 c , 0 x58 , 0 x c f
.byte 0 xd0 , 0 x e f , 0 x a a , 0 x f b , 0 x43 , 0 x4 d , 0 x33 , 0 x85
.byte 0 x4 5 , 0 x f9 , 0 x02 , 0 x7 f , 0 x50 , 0 x3 c , 0 x9 f , 0 x a8
.byte 0 x5 1 , 0 x a3 , 0 x40 , 0 x8 f , 0 x92 , 0 x9 d , 0 x38 , 0 x f5
.byte 0 xbc, 0 x b6 , 0 x d a , 0 x21 , 0 x10 , 0 x f f , 0 x f3 , 0 x d2
.byte 0 xcd, 0 x0 c , 0 x13 , 0 x e c , 0 x5 f , 0 x97 , 0 x44 , 0 x17
.byte 0 xc4 , 0 x a7 , 0 x7 e , 0 x3 d , 0 x64 , 0 x5 d , 0 x19 , 0 x73
.byte 0 x6 0 , 0 x81 , 0 x4 f , 0 x d c , 0 x22 , 0 x2 a , 0 x90 , 0 x88
.byte 0 x4 6 , 0 x e e , 0 x b8 , 0 x14 , 0 x d e , 0 x5 e , 0 x0 b , 0 x d b
.byte 0 xe0 , 0 x32 , 0 x3 a , 0 x0 a , 0 x49 , 0 x06 , 0 x24 , 0 x5 c
.byte 0 xc2 , 0 x d3 , 0 x a c , 0 x62 , 0 x91 , 0 x95 , 0 x e 4 , 0 x79
.byte 0 xe7 , 0 x c8 , 0 x37 , 0 x6 d , 0 x8 d , 0 x d5 , 0 x4 e , 0 x a9
.byte 0 x6 c , 0 x56 , 0 x f4 , 0 x e a , 0 x65 , 0 x7 a , 0 x a e , 0 x08
.byte 0 xba, 0 x78 , 0 x25 , 0 x2 e , 0 x1 c , 0 x a6 , 0 x b4 , 0 x c6
.byte 0 xe8 , 0 x d d , 0 x74 , 0 x1 f , 0 x4 b , 0 x b d , 0 x8 b , 0 x8 a
.byte 0 x7 0 , 0 x3 e , 0 x b5 , 0 x66 , 0 x48 , 0 x03 , 0 x f6 , 0 x0 e
.byte 0 x6 1 , 0 x35 , 0 x57 , 0 x b9 , 0 x86 , 0 x c1 , 0 x1 d , 0 x9 e
.byte 0 xe1 , 0 x f8 , 0 x98 , 0 x11 , 0 x69 , 0 x d9 , 0 x8 e , 0 x94
.byte 0 x9 b , 0 x1 e , 0 x87 , 0 x e 9 , 0 x c e , 0 x55 , 0 x28 , 0 x d f
.byte 0 x8 c , 0 x a1 , 0 x89 , 0 x0 d , 0 x b f , 0 x e 6 , 0 x42 , 0 x68
.byte 0 x4 1 , 0 x99 , 0 x2 d , 0 x0 f , 0 x b0 , 0 x54 , 0 x b b , 0 x16
.LReverse_Sbox :
.byte 0 x5 2 , 0 x09 , 0 x6 a , 0 x d5 , 0 x30 , 0 x36 , 0 x a5 , 0 x38
.byte 0 xbf, 0 x40 , 0 x a3 , 0 x9 e , 0 x81 , 0 x f3 , 0 x d7 , 0 x f b
.byte 0 x7 c , 0 x e 3 , 0 x39 , 0 x82 , 0 x9 b , 0 x2 f , 0 x f f , 0 x87
.byte 0 x3 4 , 0 x8 e , 0 x43 , 0 x44 , 0 x c4 , 0 x d e , 0 x e 9 , 0 x c b
.byte 0 x5 4 , 0 x7 b , 0 x94 , 0 x32 , 0 x a6 , 0 x c2 , 0 x23 , 0 x3 d
.byte 0 xee, 0 x4 c , 0 x95 , 0 x0 b , 0 x42 , 0 x f a , 0 x c3 , 0 x4 e
.byte 0 x0 8 , 0 x2 e , 0 x a1 , 0 x66 , 0 x28 , 0 x d9 , 0 x24 , 0 x b2
.byte 0 x7 6 , 0 x5 b , 0 x a2 , 0 x49 , 0 x6 d , 0 x8 b , 0 x d1 , 0 x25
.byte 0 x7 2 , 0 x f8 , 0 x f6 , 0 x64 , 0 x86 , 0 x68 , 0 x98 , 0 x16
.byte 0 xd4 , 0 x a4 , 0 x5 c , 0 x c c , 0 x5 d , 0 x65 , 0 x b6 , 0 x92
.byte 0 x6 c , 0 x70 , 0 x48 , 0 x50 , 0 x f d , 0 x e d , 0 x b9 , 0 x d a
.byte 0 x5 e , 0 x15 , 0 x46 , 0 x57 , 0 x a7 , 0 x8 d , 0 x9 d , 0 x84
.byte 0 x9 0 , 0 x d8 , 0 x a b , 0 x00 , 0 x8 c , 0 x b c , 0 x d3 , 0 x0 a
.byte 0 xf7 , 0 x e 4 , 0 x58 , 0 x05 , 0 x b8 , 0 x b3 , 0 x45 , 0 x06
.byte 0 xd0 , 0 x2 c , 0 x1 e , 0 x8 f , 0 x c a , 0 x3 f , 0 x0 f , 0 x02
.byte 0 xc1 , 0 x a f , 0 x b d , 0 x03 , 0 x01 , 0 x13 , 0 x8 a , 0 x6 b
.byte 0 x3 a , 0 x91 , 0 x11 , 0 x41 , 0 x4 f , 0 x67 , 0 x d c , 0 x e a
.byte 0 x9 7 , 0 x f2 , 0 x c f , 0 x c e , 0 x f0 , 0 x b4 , 0 x e 6 , 0 x73
.byte 0 x9 6 , 0 x a c , 0 x74 , 0 x22 , 0 x e 7 , 0 x a d , 0 x35 , 0 x85
.byte 0 xe2 , 0 x f9 , 0 x37 , 0 x e 8 , 0 x1 c , 0 x75 , 0 x d f , 0 x6 e
.byte 0 x4 7 , 0 x f1 , 0 x1 a , 0 x71 , 0 x1 d , 0 x29 , 0 x c5 , 0 x89
.byte 0 x6 f , 0 x b7 , 0 x62 , 0 x0 e , 0 x a a , 0 x18 , 0 x b e , 0 x1 b
.byte 0 xfc, 0 x56 , 0 x3 e , 0 x4 b , 0 x c6 , 0 x d2 , 0 x79 , 0 x20
.byte 0 x9 a , 0 x d b , 0 x c0 , 0 x f e , 0 x78 , 0 x c d , 0 x5 a , 0 x f4
.byte 0 x1 f , 0 x d d , 0 x a8 , 0 x33 , 0 x88 , 0 x07 , 0 x c7 , 0 x31
.byte 0 xb1 , 0 x12 , 0 x10 , 0 x59 , 0 x27 , 0 x80 , 0 x e c , 0 x5 f
.byte 0 x6 0 , 0 x51 , 0 x7 f , 0 x a9 , 0 x19 , 0 x b5 , 0 x4 a , 0 x0 d
.byte 0 x2 d , 0 x e 5 , 0 x7 a , 0 x9 f , 0 x93 , 0 x c9 , 0 x9 c , 0 x e f
.byte 0 xa0 , 0 x e 0 , 0 x3 b , 0 x4 d , 0 x a e , 0 x2 a , 0 x f5 , 0 x b0
.byte 0 xc8 , 0 x e b , 0 x b b , 0 x3 c , 0 x83 , 0 x53 , 0 x99 , 0 x61
.byte 0 x1 7 , 0 x2 b , 0 x04 , 0 x7 e , 0 x b a , 0 x77 , 0 x d6 , 0 x26
.byte 0 xe1 , 0 x69 , 0 x14 , 0 x63 , 0 x55 , 0 x21 , 0 x0 c , 0 x7 d
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-28 23:25:38 +00:00
.LForward_ShiftRows :
.octa 0x0b06010c07020d08030e09040f0a0500
.LReverse_ShiftRows :
.octa 0x0306090c0f0205080b0e0104070a0d00
.Lror32by8 :
.octa 0x0c0f0e0d080b0a090407060500030201