Skip to content

Commit

Permalink
Make dispatch tests use corruptible registers on aarch64. (aws#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 and Bill Yang committed Jul 31, 2023
1 parent dd4356a commit 9973451
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 124 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 @@ -98,10 +98,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 @@ -351,10 +351,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 @@ -739,10 +739,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 @@ -263,10 +263,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 @@ -1078,10 +1078,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
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 @@ -361,10 +361,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 @@ -454,10 +454,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,#2] // kFlag_sha512_hw
adrp x9,:pg_hi21:BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#2] // 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
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,#2] // kFlag_sha512_hw
adrp x9,_BORINGSSL_function_hit@PAGE
add x9, x9, _BORINGSSL_function_hit@PAGEOFF
mov w10, #1
strb w10, [x9,#2] // 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 @@ -35,10 +35,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 @@ -254,10 +254,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 @@ -292,10 +292,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 @@ -623,10 +623,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
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 @@ -1075,10 +1075,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
8 changes: 4 additions & 4 deletions generated-src/linux-aarch64/crypto/fipsmodule/sha512-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,10 @@ sha512_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,#2] // kFlag_sha512_hw
adrp x9,BORINGSSL_function_hit
add x9, x9, :lo12:BORINGSSL_function_hit
mov w10, #1
strb w10, [x9,#2] // kFlag_sha512_hw
#endif
stp x29,x30,[sp,#-16]!
add x29,sp,#0
Expand Down
16 changes: 8 additions & 8 deletions generated-src/linux-aarch64/crypto/fipsmodule/vpaes-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ _vpaes_encrypt_core:
vpaes_encrypt:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#4] // kFlag_vpaes_encrypt
adrp x9,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 @@ -1029,10 +1029,10 @@ _vpaes_schedule_mangle:
vpaes_set_encrypt_key:
#ifdef BORINGSSL_DISPATCH_TEST

adrp x6,BORINGSSL_function_hit
add x6, x6, :lo12:BORINGSSL_function_hit
mov w7, #1
strb w7, [x6,#5] // kFlag_vpaes_set_encrypt_key
adrp x9,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
Loading

0 comments on commit 9973451

Please sign in to comment.