Skip to content

Commit

Permalink
Make dispatch tests use corruptible registers on aarch64. (#1118)
Browse files Browse the repository at this point in the history
Using registers x6 and x7 is risky because they can be used for input parameters.
Switching the dispatch tests to use x9 and x10 which are corruptible regitsters.
  • Loading branch information
nebeid authored Jul 28, 2023
1 parent 7bdae64 commit 0809c19
Show file tree
Hide file tree
Showing 23 changed files with 156 additions and 156 deletions.
24 changes: 12 additions & 12 deletions crypto/fipsmodule/aes/asm/aesv8-armx.pl
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@
$code.=<<___ if ($flavour =~ /64/);
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#3] // kFlag_aes_hw_set_encrypt_key
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#3] // kFlag_aes_hw_set_encrypt_key
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
AARCH64_VALID_CALL_TARGET
Expand Down Expand Up @@ -354,10 +354,10 @@ ()
$code.=<<___ if ($flavour =~ /64/);
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#1] // kFlag_aes_hw_encrypt
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#1] // kFlag_aes_hw_encrypt
#endif
___
$code.=<<___;
Expand Down Expand Up @@ -742,10 +742,10 @@ ()
$code.=<<___ if ($flavour =~ /64/);
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6] // kFlag_aes_hw_ctr32_encrypt_blocks
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9] // kFlag_aes_hw_ctr32_encrypt_blocks
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
AARCH64_VALID_CALL_TARGET
Expand Down
16 changes: 8 additions & 8 deletions crypto/fipsmodule/aes/asm/vpaes-armv8.pl
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@
vpaes_encrypt:
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#4] // kFlag_vpaes_encrypt
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#4] // kFlag_vpaes_encrypt
#endif
AARCH64_SIGN_LINK_REGISTER
stp x29,x30,[sp,#-16]!
Expand Down Expand Up @@ -1081,10 +1081,10 @@
vpaes_set_encrypt_key:
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#5] // kFlag_vpaes_set_encrypt_key
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#5] // kFlag_vpaes_set_encrypt_key
#endif
AARCH64_SIGN_LINK_REGISTER
stp x29,x30,[sp,#-16]!
Expand Down
8 changes: 4 additions & 4 deletions crypto/fipsmodule/modes/asm/aesv8-gcm-armv8-unroll8.pl
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@
aesv8_gcm_8x_enc_128:
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#7] // kFlag_aesv8_gcm_8x_enc_128
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#7] // kFlag_aesv8_gcm_8x_enc_128
#endif
AARCH64_VALID_CALL_TARGET
cbz x1, .L128_enc_ret
Expand Down
8 changes: 4 additions & 4 deletions crypto/fipsmodule/modes/asm/aesv8-gcm-armv8.pl
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@
aes_gcm_enc_kernel:
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#2] // kFlag_aes_gcm_enc_kernel
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#2] // kFlag_aes_gcm_enc_kernel
#endif
AARCH64_SIGN_LINK_REGISTER
stp x29, x30, [sp, #-128]!
Expand Down
16 changes: 8 additions & 8 deletions crypto/fipsmodule/sha/asm/sha512-armv8.pl
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@ sub BODY_00_xx {
.Lv8_entry:
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#6] // kFlag_sha256_hw
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#6] // kFlag_sha256_hw
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
stp x29,x30,[sp,#-16]!
Expand Down Expand Up @@ -457,10 +457,10 @@ sub BODY_00_xx {
.Lv8_entry:
#ifdef BORINGSSL_DISPATCH_TEST
.extern BORINGSSL_function_hit
adrp x6,:pg_hi21:BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#8] // kFlag_sha512_hw
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#8] // kFlag_sha512_hw
#endif
stp x29,x30,[sp,#-16]!
add x29,sp,#0
Expand Down
32 changes: 16 additions & 16 deletions generated-src/ios-aarch64/crypto/fipsmodule/aesv8-armx.S
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ _aes_hw_set_encrypt_key:
Lenc_key:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#3] // kFlag_aes_hw_set_encrypt_key
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#3] // kFlag_aes_hw_set_encrypt_key
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
AARCH64_VALID_CALL_TARGET
Expand Down Expand Up @@ -253,10 +253,10 @@ Ldec_key_abort:
_aes_hw_encrypt:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#1] // kFlag_aes_hw_encrypt
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#1] // kFlag_aes_hw_encrypt
#endif
AARCH64_VALID_CALL_TARGET
ldr w3,[x2,#240]
Expand Down Expand Up @@ -291,10 +291,10 @@ Loop_enc:
_aes_hw_decrypt:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#1] // kFlag_aes_hw_encrypt
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#1] // kFlag_aes_hw_encrypt
#endif
AARCH64_VALID_CALL_TARGET
ldr w3,[x2,#240]
Expand Down Expand Up @@ -622,10 +622,10 @@ Lcbc_abort:
_aes_hw_ctr32_encrypt_blocks:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6] // kFlag_aes_hw_ctr32_encrypt_blocks
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9] // kFlag_aes_hw_ctr32_encrypt_blocks
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
AARCH64_VALID_CALL_TARGET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
_aesv8_gcm_8x_enc_128:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#7] // kFlag_aesv8_gcm_8x_enc_128
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#7] // kFlag_aesv8_gcm_8x_enc_128
#endif
AARCH64_VALID_CALL_TARGET
cbz x1, L128_enc_ret
Expand Down
8 changes: 4 additions & 4 deletions generated-src/ios-aarch64/crypto/fipsmodule/aesv8-gcm-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
_aes_gcm_enc_kernel:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#2] // kFlag_aes_gcm_enc_kernel
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#2] // kFlag_aes_gcm_enc_kernel
#endif
AARCH64_SIGN_LINK_REGISTER
stp x29, x30, [sp, #-128]!
Expand Down
8 changes: 4 additions & 4 deletions generated-src/ios-aarch64/crypto/fipsmodule/sha256-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -1074,10 +1074,10 @@ sha256_block_armv8:
Lv8_entry:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#6] // kFlag_sha256_hw
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#6] // kFlag_sha256_hw
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
stp x29,x30,[sp,#-16]!
Expand Down
8 changes: 4 additions & 4 deletions generated-src/ios-aarch64/crypto/fipsmodule/sha512-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,10 @@ sha512_block_armv8:
Lv8_entry:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#8] // kFlag_sha512_hw
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#8] // kFlag_sha512_hw
#endif
stp x29,x30,[sp,#-16]!
add x29,sp,#0
Expand Down
16 changes: 8 additions & 8 deletions generated-src/ios-aarch64/crypto/fipsmodule/vpaes-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ Lenc_entry:
_vpaes_encrypt:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#4] // kFlag_vpaes_encrypt
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#4] // kFlag_vpaes_encrypt
#endif
AARCH64_SIGN_LINK_REGISTER
stp x29,x30,[sp,#-16]!
Expand Down Expand Up @@ -1028,10 +1028,10 @@ Lschedule_mangle_both:
_vpaes_set_encrypt_key:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,_BORINGSSL_function_hit@PAGE
add x6, x6, _BORINGSSL_function_hit@PAGEOFF
mov w7, #1
strb w7, [x6,#5] // kFlag_vpaes_set_encrypt_key
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#5] // kFlag_vpaes_set_encrypt_key
#endif
AARCH64_SIGN_LINK_REGISTER
stp x29,x30,[sp,#-16]!
Expand Down
32 changes: 16 additions & 16 deletions generated-src/linux-aarch64/crypto/fipsmodule/aesv8-armx.S
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ aes_hw_set_encrypt_key:
.Lenc_key:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#3] // kFlag_aes_hw_set_encrypt_key
adrp x9,BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#3] // kFlag_aes_hw_set_encrypt_key
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
AARCH64_VALID_CALL_TARGET
Expand Down Expand Up @@ -253,10 +253,10 @@ aes_hw_set_decrypt_key:
aes_hw_encrypt:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#1] // kFlag_aes_hw_encrypt
adrp x9,BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#1] // kFlag_aes_hw_encrypt
#endif
AARCH64_VALID_CALL_TARGET
ldr w3,[x2,#240]
Expand Down Expand Up @@ -291,10 +291,10 @@ aes_hw_encrypt:
aes_hw_decrypt:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#1] // kFlag_aes_hw_encrypt
adrp x9,BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#1] // kFlag_aes_hw_encrypt
#endif
AARCH64_VALID_CALL_TARGET
ldr w3,[x2,#240]
Expand Down Expand Up @@ -622,10 +622,10 @@ aes_hw_cbc_encrypt:
aes_hw_ctr32_encrypt_blocks:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6] // kFlag_aes_hw_ctr32_encrypt_blocks
adrp x9,BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9] // kFlag_aes_hw_ctr32_encrypt_blocks
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
AARCH64_VALID_CALL_TARGET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
aesv8_gcm_8x_enc_128:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#7] // kFlag_aesv8_gcm_8x_enc_128
adrp x9,BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#7] // kFlag_aesv8_gcm_8x_enc_128
#endif
AARCH64_VALID_CALL_TARGET
cbz x1, .L128_enc_ret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
aes_gcm_enc_kernel:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#2] // kFlag_aes_gcm_enc_kernel
adrp x9,BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#2] // kFlag_aes_gcm_enc_kernel
#endif
AARCH64_SIGN_LINK_REGISTER
stp x29, x30, [sp, #-128]!
Expand Down
8 changes: 4 additions & 4 deletions generated-src/linux-aarch64/crypto/fipsmodule/sha256-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -1074,10 +1074,10 @@ sha256_block_armv8:
.Lv8_entry:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#6] // kFlag_sha256_hw
adrp x9,BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#6] // kFlag_sha256_hw
#endif
// Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
stp x29,x30,[sp,#-16]!
Expand Down
Loading

0 comments on commit 0809c19

Please sign in to comment.