diff options
author | tb <> | 2024-02-24 15:30:14 +0000 |
---|---|---|
committer | tb <> | 2024-02-24 15:30:14 +0000 |
commit | c10c5b524e3121f42c9239d737dd7f975638f378 (patch) | |
tree | 162dfb371639bf1514d472f64e2a4d1279851907 /src/lib/libcrypto/bn | |
parent | 1f31ec76cd83a26559f7a7ee2623bce8b503473d (diff) | |
download | openbsd-c10c5b524e3121f42c9239d737dd7f975638f378.tar.gz openbsd-c10c5b524e3121f42c9239d737dd7f975638f378.tar.bz2 openbsd-c10c5b524e3121f42c9239d737dd7f975638f378.zip |
Replace uses of endbr64 with _CET_ENDBR from cet.h
cet.h is needed for other platforms to emit the relevant .gnu.properties
sections that are necessary for them to enable IBT. It also avoids issues
with older toolchains on macOS that explode on encountering endbr64.
based on a diff by kettenis
ok beck kettenis
Diffstat (limited to 'src/lib/libcrypto/bn')
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_add.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_mul.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bignum_sub.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/word_clz.S | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/asm/modexp512-x86_64.pl | 10 | ||||
-rwxr-xr-x | src/lib/libcrypto/bn/asm/x86_64-mont.pl | 6 | ||||
-rwxr-xr-x | src/lib/libcrypto/bn/asm/x86_64-mont5.pl | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/s2n_bignum_internal.h | 6 |
15 files changed, 30 insertions, 24 deletions
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_add.S b/src/lib/libcrypto/bn/arch/amd64/bignum_add.S index 06298ca69e..5fe4aae7a1 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_add.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_add.S | |||
@@ -49,7 +49,7 @@ | |||
49 | 49 | ||
50 | 50 | ||
51 | S2N_BN_SYMBOL(bignum_add): | 51 | S2N_BN_SYMBOL(bignum_add): |
52 | endbr64 | 52 | _CET_ENDBR |
53 | 53 | ||
54 | #if WINDOWS_ABI | 54 | #if WINDOWS_ABI |
55 | push rdi | 55 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S b/src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S index 5ad712749f..25ba17bce2 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_cmadd.S | |||
@@ -54,7 +54,7 @@ | |||
54 | 54 | ||
55 | 55 | ||
56 | S2N_BN_SYMBOL(bignum_cmadd): | 56 | S2N_BN_SYMBOL(bignum_cmadd): |
57 | endbr64 | 57 | _CET_ENDBR |
58 | 58 | ||
59 | #if WINDOWS_ABI | 59 | #if WINDOWS_ABI |
60 | push rdi | 60 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S b/src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S index 9199c8f48b..12f785d63a 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_cmul.S | |||
@@ -51,7 +51,7 @@ | |||
51 | 51 | ||
52 | 52 | ||
53 | S2N_BN_SYMBOL(bignum_cmul): | 53 | S2N_BN_SYMBOL(bignum_cmul): |
54 | endbr64 | 54 | _CET_ENDBR |
55 | 55 | ||
56 | #if WINDOWS_ABI | 56 | #if WINDOWS_ABI |
57 | push rdi | 57 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul.S index 2d7ed19091..a3552679a2 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_mul.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul.S | |||
@@ -59,7 +59,7 @@ | |||
59 | 59 | ||
60 | 60 | ||
61 | S2N_BN_SYMBOL(bignum_mul): | 61 | S2N_BN_SYMBOL(bignum_mul): |
62 | endbr64 | 62 | _CET_ENDBR |
63 | 63 | ||
64 | #if WINDOWS_ABI | 64 | #if WINDOWS_ABI |
65 | push rdi | 65 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S index f02b09b288..70ff69e372 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_4_8_alt.S | |||
@@ -72,7 +72,7 @@ | |||
72 | adc h, rdx | 72 | adc h, rdx |
73 | 73 | ||
74 | S2N_BN_SYMBOL(bignum_mul_4_8_alt): | 74 | S2N_BN_SYMBOL(bignum_mul_4_8_alt): |
75 | endbr64 | 75 | _CET_ENDBR |
76 | 76 | ||
77 | #if WINDOWS_ABI | 77 | #if WINDOWS_ABI |
78 | push rdi | 78 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S index 97be83e1f7..066403b074 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_mul_8_16_alt.S | |||
@@ -72,7 +72,7 @@ | |||
72 | adc h, rdx | 72 | adc h, rdx |
73 | 73 | ||
74 | S2N_BN_SYMBOL(bignum_mul_8_16_alt): | 74 | S2N_BN_SYMBOL(bignum_mul_8_16_alt): |
75 | endbr64 | 75 | _CET_ENDBR |
76 | 76 | ||
77 | #if WINDOWS_ABI | 77 | #if WINDOWS_ABI |
78 | push rdi | 78 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S index c4a0cabf35..54e3f59442 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr.S | |||
@@ -62,7 +62,7 @@ | |||
62 | #define llshort ebp | 62 | #define llshort ebp |
63 | 63 | ||
64 | S2N_BN_SYMBOL(bignum_sqr): | 64 | S2N_BN_SYMBOL(bignum_sqr): |
65 | endbr64 | 65 | _CET_ENDBR |
66 | 66 | ||
67 | #if WINDOWS_ABI | 67 | #if WINDOWS_ABI |
68 | push rdi | 68 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S index b228414dce..7c534ae907 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_4_8_alt.S | |||
@@ -71,7 +71,7 @@ | |||
71 | adc c, 0 | 71 | adc c, 0 |
72 | 72 | ||
73 | S2N_BN_SYMBOL(bignum_sqr_4_8_alt): | 73 | S2N_BN_SYMBOL(bignum_sqr_4_8_alt): |
74 | endbr64 | 74 | _CET_ENDBR |
75 | 75 | ||
76 | #if WINDOWS_ABI | 76 | #if WINDOWS_ABI |
77 | push rdi | 77 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S index 04efeec7e2..ac0b6f96c2 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sqr_8_16_alt.S | |||
@@ -103,7 +103,7 @@ | |||
103 | adc c, 0 | 103 | adc c, 0 |
104 | 104 | ||
105 | S2N_BN_SYMBOL(bignum_sqr_8_16_alt): | 105 | S2N_BN_SYMBOL(bignum_sqr_8_16_alt): |
106 | endbr64 | 106 | _CET_ENDBR |
107 | 107 | ||
108 | #if WINDOWS_ABI | 108 | #if WINDOWS_ABI |
109 | push rdi | 109 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bignum_sub.S b/src/lib/libcrypto/bn/arch/amd64/bignum_sub.S index 11a9bd7edd..3ff8a30510 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bignum_sub.S +++ b/src/lib/libcrypto/bn/arch/amd64/bignum_sub.S | |||
@@ -49,7 +49,7 @@ | |||
49 | 49 | ||
50 | 50 | ||
51 | S2N_BN_SYMBOL(bignum_sub): | 51 | S2N_BN_SYMBOL(bignum_sub): |
52 | endbr64 | 52 | _CET_ENDBR |
53 | 53 | ||
54 | #if WINDOWS_ABI | 54 | #if WINDOWS_ABI |
55 | push rdi | 55 | push rdi |
diff --git a/src/lib/libcrypto/bn/arch/amd64/word_clz.S b/src/lib/libcrypto/bn/arch/amd64/word_clz.S index 464a9d90fc..3926fcd4b0 100644 --- a/src/lib/libcrypto/bn/arch/amd64/word_clz.S +++ b/src/lib/libcrypto/bn/arch/amd64/word_clz.S | |||
@@ -30,7 +30,7 @@ | |||
30 | .text | 30 | .text |
31 | 31 | ||
32 | S2N_BN_SYMBOL(word_clz): | 32 | S2N_BN_SYMBOL(word_clz): |
33 | endbr64 | 33 | _CET_ENDBR |
34 | 34 | ||
35 | #if WINDOWS_ABI | 35 | #if WINDOWS_ABI |
36 | push rdi | 36 | push rdi |
diff --git a/src/lib/libcrypto/bn/asm/modexp512-x86_64.pl b/src/lib/libcrypto/bn/asm/modexp512-x86_64.pl index af78fff541..8645d5adcc 100644 --- a/src/lib/libcrypto/bn/asm/modexp512-x86_64.pl +++ b/src/lib/libcrypto/bn/asm/modexp512-x86_64.pl | |||
@@ -347,7 +347,7 @@ $code.=<<___; | |||
347 | .type MULADD_128x512,\@abi-omnipotent | 347 | .type MULADD_128x512,\@abi-omnipotent |
348 | .align 16 | 348 | .align 16 |
349 | MULADD_128x512: | 349 | MULADD_128x512: |
350 | endbr64 | 350 | _CET_ENDBR |
351 | ___ | 351 | ___ |
352 | &MULSTEP_512([map("%r$_",(8..15))], "(+8*0)(%rcx)", "%rsi", "%rbp", "%rbx"); | 352 | &MULSTEP_512([map("%r$_",(8..15))], "(+8*0)(%rcx)", "%rsi", "%rbp", "%rbx"); |
353 | $code.=<<___; | 353 | $code.=<<___; |
@@ -415,7 +415,7 @@ $code.=<<___; | |||
415 | .type mont_reduce,\@abi-omnipotent | 415 | .type mont_reduce,\@abi-omnipotent |
416 | .align 16 | 416 | .align 16 |
417 | mont_reduce: | 417 | mont_reduce: |
418 | endbr64 | 418 | _CET_ENDBR |
419 | ___ | 419 | ___ |
420 | 420 | ||
421 | my $STACK_DEPTH = 8; | 421 | my $STACK_DEPTH = 8; |
@@ -678,7 +678,7 @@ $code.=<<___; | |||
678 | .type mont_mul_a3b,\@abi-omnipotent | 678 | .type mont_mul_a3b,\@abi-omnipotent |
679 | .align 16 | 679 | .align 16 |
680 | mont_mul_a3b: | 680 | mont_mul_a3b: |
681 | endbr64 | 681 | _CET_ENDBR |
682 | # | 682 | # |
683 | # multiply tmp = src1 * src2 | 683 | # multiply tmp = src1 * src2 |
684 | # For multiply: dst = rcx, src1 = rdi, src2 = rsi | 684 | # For multiply: dst = rcx, src1 = rdi, src2 = rsi |
@@ -1080,7 +1080,7 @@ $code.=<<___; | |||
1080 | .type sqr_reduce,\@abi-omnipotent | 1080 | .type sqr_reduce,\@abi-omnipotent |
1081 | .align 16 | 1081 | .align 16 |
1082 | sqr_reduce: | 1082 | sqr_reduce: |
1083 | endbr64 | 1083 | _CET_ENDBR |
1084 | mov (+$pResult_offset+8)(%rsp), %rcx | 1084 | mov (+$pResult_offset+8)(%rsp), %rcx |
1085 | ___ | 1085 | ___ |
1086 | &SQR_512("%rsp+$tmp16_offset+8", "%rcx", [map("%r$_",(10..15,8..9))], "%rbx", "%rbp", "%rsi", "%rdi"); | 1086 | &SQR_512("%rsp+$tmp16_offset+8", "%rcx", [map("%r$_",(10..15,8..9))], "%rbx", "%rbp", "%rsi", "%rdi"); |
@@ -1110,7 +1110,7 @@ $code.=<<___; | |||
1110 | .globl mod_exp_512 | 1110 | .globl mod_exp_512 |
1111 | .type mod_exp_512,\@function,4 | 1111 | .type mod_exp_512,\@function,4 |
1112 | mod_exp_512: | 1112 | mod_exp_512: |
1113 | endbr64 | 1113 | _CET_ENDBR |
1114 | push %rbp | 1114 | push %rbp |
1115 | push %rbx | 1115 | push %rbx |
1116 | push %r12 | 1116 | push %r12 |
diff --git a/src/lib/libcrypto/bn/asm/x86_64-mont.pl b/src/lib/libcrypto/bn/asm/x86_64-mont.pl index 6f5ab331e2..30cfab4fce 100755 --- a/src/lib/libcrypto/bn/asm/x86_64-mont.pl +++ b/src/lib/libcrypto/bn/asm/x86_64-mont.pl | |||
@@ -63,7 +63,7 @@ $code=<<___; | |||
63 | .type bn_mul_mont,\@function,6 | 63 | .type bn_mul_mont,\@function,6 |
64 | .align 16 | 64 | .align 16 |
65 | bn_mul_mont: | 65 | bn_mul_mont: |
66 | endbr64 | 66 | _CET_ENDBR |
67 | test \$3,${num}d | 67 | test \$3,${num}d |
68 | jnz .Lmul_enter | 68 | jnz .Lmul_enter |
69 | cmp \$8,${num}d | 69 | cmp \$8,${num}d |
@@ -279,7 +279,7 @@ $code.=<<___; | |||
279 | .align 16 | 279 | .align 16 |
280 | bn_mul4x_mont: | 280 | bn_mul4x_mont: |
281 | .Lmul4x_enter: | 281 | .Lmul4x_enter: |
282 | endbr64 | 282 | _CET_ENDBR |
283 | push %rbx | 283 | push %rbx |
284 | push %rbp | 284 | push %rbp |
285 | push %r12 | 285 | push %r12 |
@@ -707,7 +707,7 @@ $code.=<<___; | |||
707 | .align 16 | 707 | .align 16 |
708 | bn_sqr4x_mont: | 708 | bn_sqr4x_mont: |
709 | .Lsqr4x_enter: | 709 | .Lsqr4x_enter: |
710 | endbr64 | 710 | _CET_ENDBR |
711 | push %rbx | 711 | push %rbx |
712 | push %rbp | 712 | push %rbp |
713 | push %r12 | 713 | push %r12 |
diff --git a/src/lib/libcrypto/bn/asm/x86_64-mont5.pl b/src/lib/libcrypto/bn/asm/x86_64-mont5.pl index 3b3325a6cc..38751ec5de 100755 --- a/src/lib/libcrypto/bn/asm/x86_64-mont5.pl +++ b/src/lib/libcrypto/bn/asm/x86_64-mont5.pl | |||
@@ -57,7 +57,7 @@ $code=<<___; | |||
57 | .type bn_mul_mont_gather5,\@function,6 | 57 | .type bn_mul_mont_gather5,\@function,6 |
58 | .align 64 | 58 | .align 64 |
59 | bn_mul_mont_gather5: | 59 | bn_mul_mont_gather5: |
60 | endbr64 | 60 | _CET_ENDBR |
61 | test \$3,${num}d | 61 | test \$3,${num}d |
62 | jnz .Lmul_enter | 62 | jnz .Lmul_enter |
63 | cmp \$8,${num}d | 63 | cmp \$8,${num}d |
@@ -388,7 +388,7 @@ $code.=<<___; | |||
388 | .type bn_mul4x_mont_gather5,\@function,6 | 388 | .type bn_mul4x_mont_gather5,\@function,6 |
389 | .align 16 | 389 | .align 16 |
390 | bn_mul4x_mont_gather5: | 390 | bn_mul4x_mont_gather5: |
391 | endbr64 | 391 | _CET_ENDBR |
392 | .Lmul4x_enter: | 392 | .Lmul4x_enter: |
393 | mov ${num}d,${num}d | 393 | mov ${num}d,${num}d |
394 | movd `($win64?56:8)`(%rsp),%xmm5 # load 7th argument | 394 | movd `($win64?56:8)`(%rsp),%xmm5 # load 7th argument |
@@ -927,7 +927,7 @@ $code.=<<___; | |||
927 | .type bn_scatter5,\@abi-omnipotent | 927 | .type bn_scatter5,\@abi-omnipotent |
928 | .align 16 | 928 | .align 16 |
929 | bn_scatter5: | 929 | bn_scatter5: |
930 | endbr64 | 930 | _CET_ENDBR |
931 | cmp \$0, $num | 931 | cmp \$0, $num |
932 | jz .Lscatter_epilogue | 932 | jz .Lscatter_epilogue |
933 | lea ($tbl,$idx,8),$tbl | 933 | lea ($tbl,$idx,8),$tbl |
@@ -946,7 +946,7 @@ bn_scatter5: | |||
946 | .type bn_gather5,\@abi-omnipotent | 946 | .type bn_gather5,\@abi-omnipotent |
947 | .align 16 | 947 | .align 16 |
948 | bn_gather5: | 948 | bn_gather5: |
949 | endbr64 | 949 | _CET_ENDBR |
950 | .LSEH_begin_bn_gather5: # Win64 thing, but harmless in other cases | 950 | .LSEH_begin_bn_gather5: # Win64 thing, but harmless in other cases |
951 | # I can't trust assembler to use specific encoding:-( | 951 | # I can't trust assembler to use specific encoding:-( |
952 | .byte 0x4c,0x8d,0x14,0x24 # lea (%rsp),%r10 | 952 | .byte 0x4c,0x8d,0x14,0x24 # lea (%rsp),%r10 |
@@ -1057,7 +1057,7 @@ $code.=<<___; | |||
1057 | .type mul_handler,\@abi-omnipotent | 1057 | .type mul_handler,\@abi-omnipotent |
1058 | .align 16 | 1058 | .align 16 |
1059 | mul_handler: | 1059 | mul_handler: |
1060 | endbr64 | 1060 | _CET_ENDBR |
1061 | push %rsi | 1061 | push %rsi |
1062 | push %rdi | 1062 | push %rdi |
1063 | push %rbx | 1063 | push %rbx |
diff --git a/src/lib/libcrypto/bn/s2n_bignum_internal.h b/src/lib/libcrypto/bn/s2n_bignum_internal.h index f413688338..b82db7d019 100644 --- a/src/lib/libcrypto/bn/s2n_bignum_internal.h +++ b/src/lib/libcrypto/bn/s2n_bignum_internal.h | |||
@@ -18,6 +18,12 @@ | |||
18 | # define S2N_BN_SYMBOL(name) name | 18 | # define S2N_BN_SYMBOL(name) name |
19 | #endif | 19 | #endif |
20 | 20 | ||
21 | #ifdef __CET__ | ||
22 | # include <cet.h> | ||
23 | #else | ||
24 | # define _CET_ENDBR | ||
25 | #endif | ||
26 | |||
21 | #define S2N_BN_SYM_VISIBILITY_DIRECTIVE(name) .globl S2N_BN_SYMBOL(name) | 27 | #define S2N_BN_SYM_VISIBILITY_DIRECTIVE(name) .globl S2N_BN_SYMBOL(name) |
22 | #ifdef S2N_BN_HIDE_SYMBOLS | 28 | #ifdef S2N_BN_HIDE_SYMBOLS |
23 | # ifdef __APPLE__ | 29 | # ifdef __APPLE__ |