Fix objtool: missing int3 after ret warning

Resolve straight-line speculation warnings reported by objtool
for x86_64 assembly on Linux when CONFIG_SLS is set.  See the
following LWN article for the complete details.

https://lwn.net/Articles/877845/

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13528
Closes #13575
This commit is contained in:
Brian Behlendorf 2022-06-20 23:36:21 +00:00
parent 8aceded193
commit 43569ee374
12 changed files with 44 additions and 32 deletions

View File

@ -208,7 +208,7 @@ _key_expansion_256a_local:
pxor %xmm1, %xmm0 pxor %xmm1, %xmm0
movups %xmm0, (%rcx) movups %xmm0, (%rcx)
add $0x10, %rcx add $0x10, %rcx
ret RET
nop nop
SET_SIZE(_key_expansion_128) SET_SIZE(_key_expansion_128)
SET_SIZE(_key_expansion_256a) SET_SIZE(_key_expansion_256a)
@ -236,7 +236,7 @@ _key_expansion_192a_local:
shufps $0b01001110, %xmm2, %xmm1 shufps $0b01001110, %xmm2, %xmm1
movups %xmm1, 0x10(%rcx) movups %xmm1, 0x10(%rcx)
add $0x20, %rcx add $0x20, %rcx
ret RET
SET_SIZE(_key_expansion_192a) SET_SIZE(_key_expansion_192a)
@ -257,7 +257,7 @@ _key_expansion_192b_local:
movups %xmm0, (%rcx) movups %xmm0, (%rcx)
add $0x10, %rcx add $0x10, %rcx
ret RET
SET_SIZE(_key_expansion_192b) SET_SIZE(_key_expansion_192b)
@ -271,7 +271,7 @@ _key_expansion_256b_local:
pxor %xmm1, %xmm2 pxor %xmm1, %xmm2
movups %xmm2, (%rcx) movups %xmm2, (%rcx)
add $0x10, %rcx add $0x10, %rcx
ret RET
SET_SIZE(_key_expansion_256b) SET_SIZE(_key_expansion_256b)
@ -376,7 +376,7 @@ rijndael_key_setup_enc_intel_local:
mov $14, %rax // return # rounds = 14 mov $14, %rax // return # rounds = 14
#endif #endif
FRAME_END FRAME_END
ret RET
.align 4 .align 4
.Lenc_key192: .Lenc_key192:
@ -413,7 +413,7 @@ rijndael_key_setup_enc_intel_local:
mov $12, %rax // return # rounds = 12 mov $12, %rax // return # rounds = 12
#endif #endif
FRAME_END FRAME_END
ret RET
.align 4 .align 4
.Lenc_key128: .Lenc_key128:
@ -453,13 +453,13 @@ rijndael_key_setup_enc_intel_local:
mov $10, %rax // return # rounds = 10 mov $10, %rax // return # rounds = 10
#endif #endif
FRAME_END FRAME_END
ret RET
.Lenc_key_invalid_param: .Lenc_key_invalid_param:
#ifdef OPENSSL_INTERFACE #ifdef OPENSSL_INTERFACE
mov $-1, %rax // user key or AES key pointer is NULL mov $-1, %rax // user key or AES key pointer is NULL
FRAME_END FRAME_END
ret RET
#else #else
/* FALLTHROUGH */ /* FALLTHROUGH */
#endif /* OPENSSL_INTERFACE */ #endif /* OPENSSL_INTERFACE */
@ -471,7 +471,7 @@ rijndael_key_setup_enc_intel_local:
xor %rax, %rax // a key pointer is NULL or invalid keysize xor %rax, %rax // a key pointer is NULL or invalid keysize
#endif /* OPENSSL_INTERFACE */ #endif /* OPENSSL_INTERFACE */
FRAME_END FRAME_END
ret RET
SET_SIZE(rijndael_key_setup_enc_intel) SET_SIZE(rijndael_key_setup_enc_intel)
@ -548,7 +548,7 @@ FRAME_BEGIN
// OpenSolaris: rax = # rounds (10, 12, or 14) or 0 for error // OpenSolaris: rax = # rounds (10, 12, or 14) or 0 for error
// OpenSSL: rax = 0 for OK, or non-zero for error // OpenSSL: rax = 0 for OK, or non-zero for error
FRAME_END FRAME_END
ret RET
SET_SIZE(rijndael_key_setup_dec_intel) SET_SIZE(rijndael_key_setup_dec_intel)
@ -655,7 +655,7 @@ ENTRY_NP(aes_encrypt_intel)
aesenclast %KEY, %STATE // last round aesenclast %KEY, %STATE // last round
movups %STATE, (%OUTP) // output movups %STATE, (%OUTP) // output
ret RET
SET_SIZE(aes_encrypt_intel) SET_SIZE(aes_encrypt_intel)
@ -738,7 +738,7 @@ ENTRY_NP(aes_decrypt_intel)
aesdeclast %KEY, %STATE // last round aesdeclast %KEY, %STATE // last round
movups %STATE, (%OUTP) // output movups %STATE, (%OUTP) // output
ret RET
SET_SIZE(aes_decrypt_intel) SET_SIZE(aes_decrypt_intel)
#endif /* lint || __lint */ #endif /* lint || __lint */

View File

@ -785,7 +785,7 @@ ENTRY_NP(aes_encrypt_amd64)
mov 2*8(%rsp), %rbp mov 2*8(%rsp), %rbp
mov 3*8(%rsp), %r12 mov 3*8(%rsp), %r12
add $[4*8], %rsp add $[4*8], %rsp
ret RET
SET_SIZE(aes_encrypt_amd64) SET_SIZE(aes_encrypt_amd64)
@ -896,7 +896,7 @@ ENTRY_NP(aes_decrypt_amd64)
mov 2*8(%rsp), %rbp mov 2*8(%rsp), %rbp
mov 3*8(%rsp), %r12 mov 3*8(%rsp), %r12
add $[4*8], %rsp add $[4*8], %rsp
ret RET
SET_SIZE(aes_decrypt_amd64) SET_SIZE(aes_decrypt_amd64)
#endif /* lint || __lint */ #endif /* lint || __lint */

View File

@ -1334,7 +1334,7 @@ zfs_blake3_hash_many_avx2:
pop r13 pop r13
pop r14 pop r14
pop r15 pop r15
ret RET
.p2align 5 .p2align 5
3: 3:
mov rbx, qword ptr [rbp+0x50] mov rbx, qword ptr [rbp+0x50]

View File

@ -1116,7 +1116,7 @@ zfs_blake3_hash_many_avx512:
pop r13 pop r13
pop r14 pop r14
pop r15 pop r15
ret RET
.p2align 6 .p2align 6
3: 3:
test esi, 0x8 test esi, 0x8
@ -2487,7 +2487,7 @@ zfs_blake3_compress_in_place_avx512:
vpxor xmm1, xmm1, xmm3 vpxor xmm1, xmm1, xmm3
vmovdqu xmmword ptr [rdi], xmm0 vmovdqu xmmword ptr [rdi], xmm0
vmovdqu xmmword ptr [rdi+0x10], xmm1 vmovdqu xmmword ptr [rdi+0x10], xmm1
ret RET
.p2align 6 .p2align 6
zfs_blake3_compress_xof_avx512: zfs_blake3_compress_xof_avx512:
@ -2573,7 +2573,7 @@ zfs_blake3_compress_xof_avx512:
vmovdqu xmmword ptr [r9+0x10], xmm1 vmovdqu xmmword ptr [r9+0x10], xmm1
vmovdqu xmmword ptr [r9+0x20], xmm2 vmovdqu xmmword ptr [r9+0x20], xmm2
vmovdqu xmmword ptr [r9+0x30], xmm3 vmovdqu xmmword ptr [r9+0x30], xmm3
ret RET
.size zfs_blake3_hash_many_avx512, . - zfs_blake3_hash_many_avx512 .size zfs_blake3_hash_many_avx512, . - zfs_blake3_hash_many_avx512
.size zfs_blake3_compress_in_place_avx512, . - zfs_blake3_compress_in_place_avx512 .size zfs_blake3_compress_in_place_avx512, . - zfs_blake3_compress_in_place_avx512

View File

@ -1671,7 +1671,7 @@ zfs_blake3_hash_many_sse2:
pop r13 pop r13
pop r14 pop r14
pop r15 pop r15
ret RET
.p2align 5 .p2align 5
3: 3:
test esi, 0x2 test esi, 0x2
@ -2157,7 +2157,7 @@ zfs_blake3_compress_in_place_sse2:
pxor xmm1, xmm3 pxor xmm1, xmm3
movups xmmword ptr [rdi], xmm0 movups xmmword ptr [rdi], xmm0
movups xmmword ptr [rdi+0x10], xmm1 movups xmmword ptr [rdi+0x10], xmm1
ret RET
.p2align 6 .p2align 6
zfs_blake3_compress_xof_sse2: zfs_blake3_compress_xof_sse2:
@ -2276,7 +2276,7 @@ zfs_blake3_compress_xof_sse2:
movups xmmword ptr [r9+0x10], xmm1 movups xmmword ptr [r9+0x10], xmm1
movups xmmword ptr [r9+0x20], xmm2 movups xmmword ptr [r9+0x20], xmm2
movups xmmword ptr [r9+0x30], xmm3 movups xmmword ptr [r9+0x30], xmm3
ret RET
.size zfs_blake3_hash_many_sse2, . - zfs_blake3_hash_many_sse2 .size zfs_blake3_hash_many_sse2, . - zfs_blake3_hash_many_sse2
.size zfs_blake3_compress_in_place_sse2, . - zfs_blake3_compress_in_place_sse2 .size zfs_blake3_compress_in_place_sse2, . - zfs_blake3_compress_in_place_sse2

View File

@ -1475,7 +1475,7 @@ zfs_blake3_hash_many_sse41:
pop r13 pop r13
pop r14 pop r14
pop r15 pop r15
ret RET
.p2align 5 .p2align 5
3: 3:
test esi, 0x2 test esi, 0x2
@ -1908,7 +1908,7 @@ zfs_blake3_compress_in_place_sse41:
pxor xmm1, xmm3 pxor xmm1, xmm3
movups xmmword ptr [rdi], xmm0 movups xmmword ptr [rdi], xmm0
movups xmmword ptr [rdi+0x10], xmm1 movups xmmword ptr [rdi+0x10], xmm1
ret RET
.p2align 6 .p2align 6
zfs_blake3_compress_xof_sse41: zfs_blake3_compress_xof_sse41:
_CET_ENDBR _CET_ENDBR
@ -2015,7 +2015,7 @@ zfs_blake3_compress_xof_sse41:
movups xmmword ptr [r9+0x10], xmm1 movups xmmword ptr [r9+0x10], xmm1
movups xmmword ptr [r9+0x20], xmm2 movups xmmword ptr [r9+0x20], xmm2
movups xmmword ptr [r9+0x30], xmm3 movups xmmword ptr [r9+0x30], xmm3
ret RET
.size zfs_blake3_hash_many_sse41, . - zfs_blake3_hash_many_sse41 .size zfs_blake3_hash_many_sse41, . - zfs_blake3_hash_many_sse41
.size zfs_blake3_compress_in_place_sse41, . - zfs_blake3_compress_in_place_sse41 .size zfs_blake3_compress_in_place_sse41, . - zfs_blake3_compress_in_place_sse41

View File

@ -1201,7 +1201,7 @@ aesni_gcm_encrypt:
.align 32 .align 32
clear_fpu_regs_avx: clear_fpu_regs_avx:
vzeroall vzeroall
ret RET
.size clear_fpu_regs_avx,.-clear_fpu_regs_avx .size clear_fpu_regs_avx,.-clear_fpu_regs_avx
/* /*
@ -1219,7 +1219,7 @@ gcm_xor_avx:
movdqu (%rsi), %xmm1 movdqu (%rsi), %xmm1
pxor %xmm1, %xmm0 pxor %xmm1, %xmm0
movdqu %xmm0, (%rsi) movdqu %xmm0, (%rsi)
ret RET
.size gcm_xor_avx,.-gcm_xor_avx .size gcm_xor_avx,.-gcm_xor_avx
/* /*
@ -1236,7 +1236,7 @@ atomic_toggle_boolean_nv:
jz 1f jz 1f
movl $1, %eax movl $1, %eax
1: 1:
ret RET
.size atomic_toggle_boolean_nv,.-atomic_toggle_boolean_nv .size atomic_toggle_boolean_nv,.-atomic_toggle_boolean_nv
.align 64 .align 64

View File

@ -244,7 +244,7 @@ ENTRY_NP(gcm_mul_pclmulqdq)
// //
// Return // Return
// //
ret RET
SET_SIZE(gcm_mul_pclmulqdq) SET_SIZE(gcm_mul_pclmulqdq)
#endif /* lint || __lint */ #endif /* lint || __lint */

View File

@ -2058,7 +2058,7 @@ ENTRY_NP(SHA256TransformBlocks)
.cfi_adjust_cfa_offset -8 .cfi_adjust_cfa_offset -8
.cfi_restore %rbx .cfi_restore %rbx
ret RET
.cfi_endproc .cfi_endproc
SET_SIZE(SHA256TransformBlocks) SET_SIZE(SHA256TransformBlocks)

View File

@ -2059,7 +2059,7 @@ ENTRY_NP(SHA512TransformBlocks)
.cfi_adjust_cfa_offset -8 .cfi_adjust_cfa_offset -8
.cfi_restore %rbx .cfi_restore %rbx
ret RET
.cfi_endproc .cfi_endproc
SET_SIZE(SHA512TransformBlocks) SET_SIZE(SHA512TransformBlocks)

View File

@ -30,6 +30,12 @@
#include <sys/stack.h> #include <sys/stack.h>
#include <sys/trap.h> #include <sys/trap.h>
#if defined(__linux__) && defined(CONFIG_SLS)
#define RET ret; int3
#else
#define RET ret
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -35,6 +35,12 @@ x:
.size x, [.-x] .size x, [.-x]
#if defined(__linux__) && defined(CONFIG_SLS)
#define RET ret; int3
#else
#define RET ret
#endif
/* /*
* Setjmp and longjmp implement non-local gotos using state vectors * Setjmp and longjmp implement non-local gotos using state vectors
* type label_t. * type label_t.
@ -52,7 +58,7 @@ x:
movq 0(%rsp), %rdx /* return address */ movq 0(%rsp), %rdx /* return address */
movq %rdx, 56(%rdi) /* rip */ movq %rdx, 56(%rdi) /* rip */
xorl %eax, %eax /* return 0 */ xorl %eax, %eax /* return 0 */
ret RET
SET_SIZE(setjmp) SET_SIZE(setjmp)
ENTRY(longjmp) ENTRY(longjmp)
@ -67,7 +73,7 @@ x:
movq %rdx, 0(%rsp) movq %rdx, 0(%rsp)
xorl %eax, %eax xorl %eax, %eax
incl %eax /* return 1 */ incl %eax /* return 1 */
ret RET
SET_SIZE(longjmp) SET_SIZE(longjmp)
#ifdef __ELF__ #ifdef __ELF__