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 - m o d e s . S - c h a i n i n g m o d e w r a p p e r s f o r A E S
*
2017-02-03 14:49:37 +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
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n .
* /
/* included by aes-ce.S and aes-neon.S */
.text
.align 4
aes_encrypt_block4x :
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
encrypt_ b l o c k 4 x v0 , v1 , v2 , v3 , w3 , x2 , x8 , w7
2014-03-21 10:19:17 +01:00
ret
ENDPROC( a e s _ e n c r y p t _ b l o c k 4 x )
aes_decrypt_block4x :
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
decrypt_ b l o c k 4 x v0 , v1 , v2 , v3 , w3 , x2 , x8 , w7
2014-03-21 10:19:17 +01:00
ret
ENDPROC( a e s _ d e c r y p t _ b l o c k 4 x )
/ *
* aes_ e c b _ e n c r y p t ( u 8 o u t [ ] , u 8 c o n s t i n [ ] , u 8 c o n s t r k [ ] , i n t r o u n d s ,
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
* int b l o c k s )
2014-03-21 10:19:17 +01:00
* aes_ e c b _ d e c r y p t ( u 8 o u t [ ] , u 8 c o n s t i n [ ] , u 8 c o n s t r k [ ] , i n t r o u n d s ,
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
* int b l o c k s )
2014-03-21 10:19:17 +01:00
* /
AES_ E N T R Y ( a e s _ e c b _ e n c r y p t )
2018-03-10 15:21:51 +00:00
stp x29 , x30 , [ s p , #- 16 ] !
mov x29 , s p
2014-03-21 10:19:17 +01:00
enc_ p r e p a r e w3 , x2 , x5
.LecbencloopNx :
2018-03-10 15:21:51 +00:00
subs w4 , w4 , #4
2014-03-21 10:19:17 +01:00
bmi . L e c b e n c1 x
ld1 { v0 . 1 6 b - v3 . 1 6 b } , [ x1 ] , #64 / * g e t 4 p t b l o c k s * /
2018-03-10 15:21:51 +00:00
bl a e s _ e n c r y p t _ b l o c k 4 x
2014-03-21 10:19:17 +01:00
st1 { v0 . 1 6 b - v3 . 1 6 b } , [ x0 ] , #64
b . L e c b e n c l o o p N x
.Lecbenc1x :
2018-03-10 15:21:51 +00:00
adds w4 , w4 , #4
2014-03-21 10:19:17 +01:00
beq . L e c b e n c o u t
.Lecbencloop :
ld1 { v0 . 1 6 b } , [ x1 ] , #16 / * g e t n e x t p t b l o c k * /
encrypt_ b l o c k v0 , w3 , x2 , x5 , w6
st1 { v0 . 1 6 b } , [ x0 ] , #16
subs w4 , w4 , #1
bne . L e c b e n c l o o p
.Lecbencout :
2018-03-10 15:21:51 +00:00
ldp x29 , x30 , [ s p ] , #16
2014-03-21 10:19:17 +01:00
ret
AES_ E N D P R O C ( a e s _ e c b _ e n c r y p t )
AES_ E N T R Y ( a e s _ e c b _ d e c r y p t )
2018-03-10 15:21:51 +00:00
stp x29 , x30 , [ s p , #- 16 ] !
mov x29 , s p
2014-03-21 10:19:17 +01:00
dec_ p r e p a r e w3 , x2 , x5
.LecbdecloopNx :
2018-03-10 15:21:51 +00:00
subs w4 , w4 , #4
2014-03-21 10:19:17 +01:00
bmi . L e c b d e c1 x
ld1 { v0 . 1 6 b - v3 . 1 6 b } , [ x1 ] , #64 / * g e t 4 c t b l o c k s * /
2018-03-10 15:21:51 +00:00
bl a e s _ d e c r y p t _ b l o c k 4 x
2014-03-21 10:19:17 +01:00
st1 { v0 . 1 6 b - v3 . 1 6 b } , [ x0 ] , #64
b . L e c b d e c l o o p N x
.Lecbdec1x :
2018-03-10 15:21:51 +00:00
adds w4 , w4 , #4
2014-03-21 10:19:17 +01:00
beq . L e c b d e c o u t
.Lecbdecloop :
ld1 { v0 . 1 6 b } , [ x1 ] , #16 / * g e t n e x t c t b l o c k * /
decrypt_ b l o c k v0 , w3 , x2 , x5 , w6
st1 { v0 . 1 6 b } , [ x0 ] , #16
subs w4 , w4 , #1
bne . L e c b d e c l o o p
.Lecbdecout :
2018-03-10 15:21:51 +00:00
ldp x29 , x30 , [ s p ] , #16
2014-03-21 10:19:17 +01:00
ret
AES_ E N D P R O C ( a e s _ e c b _ d e c r y p t )
/ *
* aes_ c b c _ e n c r y p t ( u 8 o u t [ ] , u 8 c o n s t i n [ ] , u 8 c o n s t r k [ ] , i n t r o u n d s ,
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
* int b l o c k s , u 8 i v [ ] )
2014-03-21 10:19:17 +01:00
* aes_ c b c _ d e c r y p t ( u 8 o u t [ ] , u 8 c o n s t i n [ ] , u 8 c o n s t r k [ ] , i n t r o u n d s ,
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
* int b l o c k s , u 8 i v [ ] )
2014-03-21 10:19:17 +01:00
* /
AES_ E N T R Y ( a e s _ c b c _ e n c r y p t )
2018-03-10 15:21:52 +00:00
ld1 { v4 . 1 6 b } , [ x5 ] / * g e t i v * /
2017-01-17 13:46:29 +00:00
enc_ p r e p a r e w3 , x2 , x6
2014-03-21 10:19:17 +01:00
2018-03-10 15:21:52 +00:00
.Lcbcencloop4x :
subs w4 , w4 , #4
bmi . L c b c e n c1 x
ld1 { v0 . 1 6 b - v3 . 1 6 b } , [ x1 ] , #64 / * g e t 4 p t b l o c k s * /
eor v0 . 1 6 b , v0 . 1 6 b , v4 . 1 6 b / * . . a n d x o r w i t h i v * /
2017-01-17 13:46:29 +00:00
encrypt_ b l o c k v0 , w3 , x2 , x6 , w7
2018-03-10 15:21:52 +00:00
eor v1 . 1 6 b , v1 . 1 6 b , v0 . 1 6 b
encrypt_ b l o c k v1 , w3 , x2 , x6 , w7
eor v2 . 1 6 b , v2 . 1 6 b , v1 . 1 6 b
encrypt_ b l o c k v2 , w3 , x2 , x6 , w7
eor v3 . 1 6 b , v3 . 1 6 b , v2 . 1 6 b
encrypt_ b l o c k v3 , w3 , x2 , x6 , w7
st1 { v0 . 1 6 b - v3 . 1 6 b } , [ x0 ] , #64
mov v4 . 1 6 b , v3 . 1 6 b
b . L c b c e n c l o o p4 x
.Lcbcenc1x :
adds w4 , w4 , #4
beq . L c b c e n c o u t
.Lcbcencloop :
ld1 { v0 . 1 6 b } , [ x1 ] , #16 / * g e t n e x t p t b l o c k * /
eor v4 . 1 6 b , v4 . 1 6 b , v0 . 1 6 b / * . . a n d x o r w i t h i v * /
encrypt_ b l o c k v4 , w3 , x2 , x6 , w7
st1 { v4 . 1 6 b } , [ x0 ] , #16
2014-03-21 10:19:17 +01:00
subs w4 , w4 , #1
bne . L c b c e n c l o o p
2018-03-10 15:21:52 +00:00
.Lcbcencout :
st1 { v4 . 1 6 b } , [ x5 ] / * r e t u r n i v * /
2014-03-21 10:19:17 +01:00
ret
AES_ E N D P R O C ( a e s _ c b c _ e n c r y p t )
AES_ E N T R Y ( a e s _ c b c _ d e c r y p t )
2018-03-10 15:21:51 +00:00
stp x29 , x30 , [ s p , #- 16 ] !
mov x29 , s p
2014-03-21 10:19:17 +01:00
ld1 { v7 . 1 6 b } , [ x5 ] / * g e t i v * /
2017-01-17 13:46:29 +00:00
dec_ p r e p a r e w3 , x2 , x6
2014-03-21 10:19:17 +01:00
.LcbcdecloopNx :
2018-03-10 15:21:51 +00:00
subs w4 , w4 , #4
2014-03-21 10:19:17 +01:00
bmi . L c b c d e c1 x
ld1 { v0 . 1 6 b - v3 . 1 6 b } , [ x1 ] , #64 / * g e t 4 c t b l o c k s * /
mov v4 . 1 6 b , v0 . 1 6 b
mov v5 . 1 6 b , v1 . 1 6 b
mov v6 . 1 6 b , v2 . 1 6 b
2018-03-10 15:21:51 +00:00
bl a e s _ d e c r y p t _ b l o c k 4 x
2014-03-21 10:19:17 +01:00
sub x1 , x1 , #16
eor v0 . 1 6 b , v0 . 1 6 b , v7 . 1 6 b
eor v1 . 1 6 b , v1 . 1 6 b , v4 . 1 6 b
ld1 { v7 . 1 6 b } , [ x1 ] , #16 / * r e l o a d 1 c t b l o c k * /
eor v2 . 1 6 b , v2 . 1 6 b , v5 . 1 6 b
eor v3 . 1 6 b , v3 . 1 6 b , v6 . 1 6 b
st1 { v0 . 1 6 b - v3 . 1 6 b } , [ x0 ] , #64
b . L c b c d e c l o o p N x
.Lcbcdec1x :
2018-03-10 15:21:51 +00:00
adds w4 , w4 , #4
2014-03-21 10:19:17 +01:00
beq . L c b c d e c o u t
.Lcbcdecloop :
ld1 { v1 . 1 6 b } , [ x1 ] , #16 / * g e t n e x t c t b l o c k * /
mov v0 . 1 6 b , v1 . 1 6 b / * . . . a n d c o p y t o v0 * /
2017-01-17 13:46:29 +00:00
decrypt_ b l o c k v0 , w3 , x2 , x6 , w7
2014-03-21 10:19:17 +01:00
eor v0 . 1 6 b , v0 . 1 6 b , v7 . 1 6 b / * x o r w i t h i v = > p t * /
mov v7 . 1 6 b , v1 . 1 6 b / * c t i s n e x t i v * /
st1 { v0 . 1 6 b } , [ x0 ] , #16
subs w4 , w4 , #1
bne . L c b c d e c l o o p
.Lcbcdecout :
2017-01-17 13:46:29 +00:00
st1 { v7 . 1 6 b } , [ x5 ] / * r e t u r n i v * /
2018-03-10 15:21:51 +00:00
ldp x29 , x30 , [ s p ] , #16
2014-03-21 10:19:17 +01:00
ret
AES_ E N D P R O C ( a e s _ c b c _ d e c r y p t )
/ *
* aes_ c t r _ e n c r y p t ( u 8 o u t [ ] , u 8 c o n s t i n [ ] , u 8 c o n s t r k [ ] , i n t r o u n d s ,
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
* int b l o c k s , u 8 c t r [ ] )
2014-03-21 10:19:17 +01:00
* /
AES_ E N T R Y ( a e s _ c t r _ e n c r y p t )
2018-03-10 15:21:51 +00:00
stp x29 , x30 , [ s p , #- 16 ] !
mov x29 , s p
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
2014-03-21 10:19:17 +01:00
enc_ p r e p a r e w3 , x2 , x6
ld1 { v4 . 1 6 b } , [ x5 ]
2017-01-17 13:46:29 +00:00
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
umov x6 , v4 . d [ 1 ] / * k e e p s w a b b e d c t r i n r e g * /
rev x6 , x6
cmn w6 , w4 / * 3 2 b i t o v e r f l o w ? * /
2014-03-21 10:19:17 +01:00
bcs . L c t r l o o p
.LctrloopNx :
2018-03-10 15:21:51 +00:00
subs w4 , w4 , #4
2014-03-21 10:19:17 +01:00
bmi . L c t r1 x
ldr q8 , =0x30000000200000001 / * a d d e n d s 1 ,2 ,3 [ ,0 ] * /
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
dup v7 . 4 s , w6
2014-03-21 10:19:17 +01:00
mov v0 . 1 6 b , v4 . 1 6 b
add v7 . 4 s , v7 . 4 s , v8 . 4 s
mov v1 . 1 6 b , v4 . 1 6 b
rev3 2 v8 . 1 6 b , v7 . 1 6 b
mov v2 . 1 6 b , v4 . 1 6 b
mov v3 . 1 6 b , v4 . 1 6 b
mov v1 . s [ 3 ] , v8 . s [ 0 ]
mov v2 . s [ 3 ] , v8 . s [ 1 ]
mov v3 . s [ 3 ] , v8 . s [ 2 ]
ld1 { v5 . 1 6 b - v7 . 1 6 b } , [ x1 ] , #48 / * g e t 3 i n p u t b l o c k s * /
2018-03-10 15:21:51 +00:00
bl a e s _ e n c r y p t _ b l o c k 4 x
2014-03-21 10:19:17 +01:00
eor v0 . 1 6 b , v5 . 1 6 b , v0 . 1 6 b
ld1 { v5 . 1 6 b } , [ x1 ] , #16 / * g e t 1 i n p u t b l o c k * /
eor v1 . 1 6 b , v6 . 1 6 b , v1 . 1 6 b
eor v2 . 1 6 b , v7 . 1 6 b , v2 . 1 6 b
eor v3 . 1 6 b , v5 . 1 6 b , v3 . 1 6 b
st1 { v0 . 1 6 b - v3 . 1 6 b } , [ x0 ] , #64
2018-03-10 15:21:51 +00:00
add x6 , x6 , #4
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
rev x7 , x6
2014-03-21 10:19:17 +01:00
ins v4 . d [ 1 ] , x7
2017-01-17 13:46:29 +00:00
cbz w4 , . L c t r o u t
2014-03-21 10:19:17 +01:00
b . L c t r l o o p N x
.Lctr1x :
2018-03-10 15:21:51 +00:00
adds w4 , w4 , #4
2014-03-21 10:19:17 +01:00
beq . L c t r o u t
.Lctrloop :
mov v0 . 1 6 b , v4 . 1 6 b
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
encrypt_ b l o c k v0 , w3 , x2 , x8 , w7
2017-01-17 13:46:29 +00:00
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
adds x6 , x6 , #1 / * i n c r e m e n t B E c t r * /
rev x7 , x6
2017-01-17 13:46:29 +00:00
ins v4 . d [ 1 ] , x7
bcs . L c t r c a r r y / * o v e r f l o w ? * /
.Lctrcarrydone :
2014-03-21 10:19:17 +01:00
subs w4 , w4 , #1
2017-01-28 23:25:34 +00:00
bmi . L c t r t a i l b l o c k / * b l o c k s < 0 m e a n s t a i l b l o c k * /
2014-03-21 10:19:17 +01:00
ld1 { v3 . 1 6 b } , [ x1 ] , #16
eor v3 . 1 6 b , v0 . 1 6 b , v3 . 1 6 b
st1 { v3 . 1 6 b } , [ x0 ] , #16
2017-01-17 13:46:29 +00:00
bne . L c t r l o o p
.Lctrout :
st1 { v4 . 1 6 b } , [ x5 ] / * r e t u r n n e x t C T R v a l u e * /
2018-03-10 15:21:51 +00:00
ldp x29 , x30 , [ s p ] , #16
2017-01-17 13:46:29 +00:00
ret
2017-01-28 23:25:34 +00:00
.Lctrtailblock :
st1 { v0 . 1 6 b } , [ x0 ]
2018-03-10 15:21:51 +00:00
ldp x29 , x30 , [ s p ] , #16
2014-03-21 10:19:17 +01:00
ret
2017-01-17 13:46:29 +00:00
.Lctrcarry :
umov x7 , v4 . d [ 0 ] / * l o a d u p p e r w o r d o f c t r * /
rev x7 , x7 / * . . . t o h a n d l e t h e c a r r y * /
add x7 , x7 , #1
rev x7 , x7
ins v4 . d [ 0 ] , x7
b . L c t r c a r r y d o n e
2014-03-21 10:19:17 +01:00
AES_ E N D P R O C ( a e s _ c t r _ e n c r y p t )
.ltorg
/ *
* aes_ x t s _ d e c r y p t ( u 8 o u t [ ] , u 8 c o n s t i n [ ] , u 8 c o n s t r k 1 [ ] , i n t r o u n d s ,
* int b l o c k s , u 8 c o n s t r k 2 [ ] , u 8 i v [ ] , i n t f i r s t )
* aes_ x t s _ d e c r y p t ( u 8 o u t [ ] , u 8 c o n s t i n [ ] , u 8 c o n s t r k 1 [ ] , i n t r o u n d s ,
* int b l o c k s , u 8 c o n s t r k 2 [ ] , u 8 i v [ ] , i n t f i r s t )
* /
.macro next_ t w e a k , o u t , i n , c o n s t , t m p
sshr \ t m p \ ( ) . 2 d , \ i n \ ( ) . 2 d , #63
and \ t m p \ ( ) . 1 6 b , \ t m p \ ( ) . 1 6 b , \ c o n s t \ ( ) . 1 6 b
add \ o u t \ ( ) . 2 d , \ i n \ ( ) . 2 d , \ i n \ ( ) . 2 d
ext \ t m p \ ( ) . 1 6 b , \ t m p \ ( ) . 1 6 b , \ t m p \ ( ) . 1 6 b , #8
eor \ o u t \ ( ) . 1 6 b , \ o u t \ ( ) . 1 6 b , \ t m p \ ( ) . 1 6 b
.endm
.Lxts_mul_x :
2016-10-11 19:15:19 +01:00
CPU_ L E ( . q u a d 1 , 0 x87 )
CPU_ B E ( . q u a d 0 x87 , 1 )
2014-03-21 10:19:17 +01:00
AES_ E N T R Y ( a e s _ x t s _ e n c r y p t )
2018-03-10 15:21:51 +00:00
stp x29 , x30 , [ s p , #- 16 ] !
mov x29 , s p
2014-03-21 10:19:17 +01:00
ld1 { v4 . 1 6 b } , [ x6 ]
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
cbz w7 , . L x t s e n c n o t f i r s t
enc_ p r e p a r e w3 , x5 , x8
encrypt_ b l o c k v4 , w3 , x5 , x8 , w7 / * f i r s t t w e a k * /
enc_ s w i t c h _ k e y w3 , x2 , x8
2014-03-21 10:19:17 +01:00
ldr q7 , . L x t s _ m u l _ x
b . L x t s e n c N x
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
.Lxtsencnotfirst :
enc_ p r e p a r e w3 , x2 , x8
2014-03-21 10:19:17 +01:00
.LxtsencloopNx :
ldr q7 , . L x t s _ m u l _ x
next_ t w e a k v4 , v4 , v7 , v8
.LxtsencNx :
2018-03-10 15:21:51 +00:00
subs w4 , w4 , #4
2014-03-21 10:19:17 +01:00
bmi . L x t s e n c1 x
ld1 { v0 . 1 6 b - v3 . 1 6 b } , [ x1 ] , #64 / * g e t 4 p t b l o c k s * /
next_ t w e a k v5 , v4 , v7 , v8
eor v0 . 1 6 b , v0 . 1 6 b , v4 . 1 6 b
next_ t w e a k v6 , v5 , v7 , v8
eor v1 . 1 6 b , v1 . 1 6 b , v5 . 1 6 b
eor v2 . 1 6 b , v2 . 1 6 b , v6 . 1 6 b
next_ t w e a k v7 , v6 , v7 , v8
eor v3 . 1 6 b , v3 . 1 6 b , v7 . 1 6 b
2018-03-10 15:21:51 +00:00
bl a e s _ e n c r y p t _ b l o c k 4 x
2014-03-21 10:19:17 +01:00
eor v3 . 1 6 b , v3 . 1 6 b , v7 . 1 6 b
eor v0 . 1 6 b , v0 . 1 6 b , v4 . 1 6 b
eor v1 . 1 6 b , v1 . 1 6 b , v5 . 1 6 b
eor v2 . 1 6 b , v2 . 1 6 b , v6 . 1 6 b
st1 { v0 . 1 6 b - v3 . 1 6 b } , [ x0 ] , #64
mov v4 . 1 6 b , v7 . 1 6 b
cbz w4 , . L x t s e n c o u t
b . L x t s e n c l o o p N x
.Lxtsenc1x :
2018-03-10 15:21:51 +00:00
adds w4 , w4 , #4
2014-03-21 10:19:17 +01:00
beq . L x t s e n c o u t
.Lxtsencloop :
ld1 { v1 . 1 6 b } , [ x1 ] , #16
eor v0 . 1 6 b , v1 . 1 6 b , v4 . 1 6 b
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
encrypt_ b l o c k v0 , w3 , x2 , x8 , w7
2014-03-21 10:19:17 +01:00
eor v0 . 1 6 b , v0 . 1 6 b , v4 . 1 6 b
st1 { v0 . 1 6 b } , [ x0 ] , #16
subs w4 , w4 , #1
beq . L x t s e n c o u t
next_ t w e a k v4 , v4 , v7 , v8
b . L x t s e n c l o o p
.Lxtsencout :
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
st1 { v4 . 1 6 b } , [ x6 ]
2018-03-10 15:21:51 +00:00
ldp x29 , x30 , [ s p ] , #16
2014-03-21 10:19:17 +01:00
ret
AES_ E N D P R O C ( a e s _ x t s _ e n c r y p t )
AES_ E N T R Y ( a e s _ x t s _ d e c r y p t )
2018-03-10 15:21:51 +00:00
stp x29 , x30 , [ s p , #- 16 ] !
mov x29 , s p
2014-03-21 10:19:17 +01:00
ld1 { v4 . 1 6 b } , [ x6 ]
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
cbz w7 , . L x t s d e c n o t f i r s t
enc_ p r e p a r e w3 , x5 , x8
encrypt_ b l o c k v4 , w3 , x5 , x8 , w7 / * f i r s t t w e a k * /
dec_ p r e p a r e w3 , x2 , x8
2014-03-21 10:19:17 +01:00
ldr q7 , . L x t s _ m u l _ x
b . L x t s d e c N x
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
.Lxtsdecnotfirst :
dec_ p r e p a r e w3 , x2 , x8
2014-03-21 10:19:17 +01:00
.LxtsdecloopNx :
ldr q7 , . L x t s _ m u l _ x
next_ t w e a k v4 , v4 , v7 , v8
.LxtsdecNx :
2018-03-10 15:21:51 +00:00
subs w4 , w4 , #4
2014-03-21 10:19:17 +01:00
bmi . L x t s d e c1 x
ld1 { v0 . 1 6 b - v3 . 1 6 b } , [ x1 ] , #64 / * g e t 4 c t b l o c k s * /
next_ t w e a k v5 , v4 , v7 , v8
eor v0 . 1 6 b , v0 . 1 6 b , v4 . 1 6 b
next_ t w e a k v6 , v5 , v7 , v8
eor v1 . 1 6 b , v1 . 1 6 b , v5 . 1 6 b
eor v2 . 1 6 b , v2 . 1 6 b , v6 . 1 6 b
next_ t w e a k v7 , v6 , v7 , v8
eor v3 . 1 6 b , v3 . 1 6 b , v7 . 1 6 b
2018-03-10 15:21:51 +00:00
bl a e s _ d e c r y p t _ b l o c k 4 x
2014-03-21 10:19:17 +01:00
eor v3 . 1 6 b , v3 . 1 6 b , v7 . 1 6 b
eor v0 . 1 6 b , v0 . 1 6 b , v4 . 1 6 b
eor v1 . 1 6 b , v1 . 1 6 b , v5 . 1 6 b
eor v2 . 1 6 b , v2 . 1 6 b , v6 . 1 6 b
st1 { v0 . 1 6 b - v3 . 1 6 b } , [ x0 ] , #64
mov v4 . 1 6 b , v7 . 1 6 b
cbz w4 , . L x t s d e c o u t
b . L x t s d e c l o o p N x
.Lxtsdec1x :
2018-03-10 15:21:51 +00:00
adds w4 , w4 , #4
2014-03-21 10:19:17 +01:00
beq . L x t s d e c o u t
.Lxtsdecloop :
ld1 { v1 . 1 6 b } , [ x1 ] , #16
eor v0 . 1 6 b , v1 . 1 6 b , v4 . 1 6 b
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
decrypt_ b l o c k v0 , w3 , x2 , x8 , w7
2014-03-21 10:19:17 +01:00
eor v0 . 1 6 b , v0 . 1 6 b , v4 . 1 6 b
st1 { v0 . 1 6 b } , [ x0 ] , #16
subs w4 , w4 , #1
beq . L x t s d e c o u t
next_ t w e a k v4 , v4 , v7 , v8
b . L x t s d e c l o o p
.Lxtsdecout :
crypto: arm64/aes-blk - move kernel mode neon en/disable into loop
When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.
Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.
So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)
Note that this requires some reshuffling of the registers in the asm
code, because the XTS routines can no longer rely on the registers to
retain their contents between invocations.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-10 15:21:48 +00:00
st1 { v4 . 1 6 b } , [ x6 ]
2018-03-10 15:21:51 +00:00
ldp x29 , x30 , [ s p ] , #16
2014-03-21 10:19:17 +01:00
ret
AES_ E N D P R O C ( a e s _ x t s _ d e c r y p t )
2017-02-03 14:49:37 +00:00
/ *
* aes_ m a c _ u p d a t e ( u 8 c o n s t i n [ ] , u 3 2 c o n s t r k [ ] , i n t r o u n d s ,
* int b l o c k s , u 8 d g [ ] , i n t e n c _ b e f o r e , i n t e n c _ a f t e r )
* /
AES_ E N T R Y ( a e s _ m a c _ u p d a t e )
ld1 { v0 . 1 6 b } , [ x4 ] / * g e t d g * /
enc_ p r e p a r e w2 , x1 , x7
2018-03-10 15:21:53 +00:00
cbz w5 , . L m a c l o o p4 x
2017-02-03 14:49:37 +00:00
2018-03-10 15:21:53 +00:00
encrypt_ b l o c k v0 , w2 , x1 , x7 , w8
.Lmacloop4x :
subs w3 , w3 , #4
bmi . L m a c1 x
ld1 { v1 . 1 6 b - v4 . 1 6 b } , [ x0 ] , #64 / * g e t n e x t p t b l o c k * /
eor v0 . 1 6 b , v0 . 1 6 b , v1 . 1 6 b / * . . a n d x o r w i t h d g * /
encrypt_ b l o c k v0 , w2 , x1 , x7 , w8
eor v0 . 1 6 b , v0 . 1 6 b , v2 . 1 6 b
encrypt_ b l o c k v0 , w2 , x1 , x7 , w8
eor v0 . 1 6 b , v0 . 1 6 b , v3 . 1 6 b
encrypt_ b l o c k v0 , w2 , x1 , x7 , w8
eor v0 . 1 6 b , v0 . 1 6 b , v4 . 1 6 b
cmp w3 , w z r
csinv x5 , x6 , x z r , e q
cbz w5 , . L m a c o u t
encrypt_ b l o c k v0 , w2 , x1 , x7 , w8
b . L m a c l o o p4 x
.Lmac1x :
add w3 , w3 , #4
2017-02-03 14:49:37 +00:00
.Lmacloop :
cbz w3 , . L m a c o u t
ld1 { v1 . 1 6 b } , [ x0 ] , #16 / * g e t n e x t p t b l o c k * /
eor v0 . 1 6 b , v0 . 1 6 b , v1 . 1 6 b / * . . a n d x o r w i t h d g * /
subs w3 , w3 , #1
csinv x5 , x6 , x z r , e q
cbz w5 , . L m a c o u t
encrypt_ b l o c k v0 , w2 , x1 , x7 , w8
b . L m a c l o o p
.Lmacout :
st1 { v0 . 1 6 b } , [ x4 ] / * r e t u r n d g * /
ret
AES_ E N D P R O C ( a e s _ m a c _ u p d a t e )