Skip to content

Commit 03b2cd7

Browse files
committed
Merge tag 'objtool-core-2021-04-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool updates from Ingo Molnar: - Standardize the crypto asm code so that it looks like compiler- generated code to objtool - so that it can understand it. This enables unwinding from crypto asm code - and also fixes the last known remaining objtool warnings for LTO and more. - x86 decoder fixes: clean up and fix the decoder, and also extend it a bit - Misc fixes and cleanups * tag 'objtool-core-2021-04-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (24 commits) x86/crypto: Enable objtool in crypto code x86/crypto/sha512-ssse3: Standardize stack alignment prologue x86/crypto/sha512-avx2: Standardize stack alignment prologue x86/crypto/sha512-avx: Standardize stack alignment prologue x86/crypto/sha256-avx2: Standardize stack alignment prologue x86/crypto/sha1_avx2: Standardize stack alignment prologue x86/crypto/sha_ni: Standardize stack alignment prologue x86/crypto/crc32c-pcl-intel: Standardize jump table x86/crypto/camellia-aesni-avx2: Unconditionally allocate stack buffer x86/crypto/aesni-intel_avx: Standardize stack alignment prologue x86/crypto/aesni-intel_avx: Fix register usage comments x86/crypto/aesni-intel_avx: Remove unused macros objtool: Support asm jump tables objtool: Parse options from OBJTOOL_ARGS objtool: Collate parse_options() users objtool: Add --backup objtool,x86: More ModRM sugar objtool,x86: Rewrite ADD/SUB/AND objtool,x86: Support %riz encodings objtool,x86: Simplify register decode ...
2 parents 0ff0edb + 7d3d10e commit 03b2cd7

18 files changed

Lines changed: 384 additions & 276 deletions

arch/x86/crypto/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#
33
# x86 crypto algorithms
44

5-
OBJECT_FILES_NON_STANDARD := y
6-
75
obj-$(CONFIG_CRYPTO_TWOFISH_586) += twofish-i586.o
86
twofish-i586-y := twofish-i586-asm_32.o twofish_glue.o
97
obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o

arch/x86/crypto/aesni-intel_avx-x86_64.S

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ HashKey_8_k = 16*21 # store XOR of HashKey^8 <<1 mod poly here (for Karatsu
212212
#define arg4 %rcx
213213
#define arg5 %r8
214214
#define arg6 %r9
215-
#define arg7 STACK_OFFSET+8*1(%r14)
216-
#define arg8 STACK_OFFSET+8*2(%r14)
217-
#define arg9 STACK_OFFSET+8*3(%r14)
218-
#define arg10 STACK_OFFSET+8*4(%r14)
219215
#define keysize 2*15*16(arg1)
220216

221217
i = 0
@@ -237,9 +233,6 @@ define_reg j %j
237233
.noaltmacro
238234
.endm
239235

240-
# need to push 4 registers into stack to maintain
241-
STACK_OFFSET = 8*4
242-
243236
TMP1 = 16*0 # Temporary storage for AAD
244237
TMP2 = 16*1 # Temporary storage for AES State 2 (State 1 is stored in an XMM register)
245238
TMP3 = 16*2 # Temporary storage for AES State 3
@@ -256,25 +249,22 @@ VARIABLE_OFFSET = 16*8
256249
################################
257250

258251
.macro FUNC_SAVE
259-
#the number of pushes must equal STACK_OFFSET
260252
push %r12
261253
push %r13
262-
push %r14
263254
push %r15
264255

265-
mov %rsp, %r14
266-
267-
256+
push %rbp
257+
mov %rsp, %rbp
268258

269259
sub $VARIABLE_OFFSET, %rsp
270260
and $~63, %rsp # align rsp to 64 bytes
271261
.endm
272262

273263
.macro FUNC_RESTORE
274-
mov %r14, %rsp
264+
mov %rbp, %rsp
265+
pop %rbp
275266

276267
pop %r15
277-
pop %r14
278268
pop %r13
279269
pop %r12
280270
.endm
@@ -294,7 +284,7 @@ VARIABLE_OFFSET = 16*8
294284

295285
# combined for GCM encrypt and decrypt functions
296286
# clobbering all xmm registers
297-
# clobbering r10, r11, r12, r13, r14, r15
287+
# clobbering r10, r11, r12, r13, r15, rax
298288
.macro GCM_ENC_DEC INITIAL_BLOCKS GHASH_8_ENCRYPT_8_PARALLEL GHASH_LAST_8 GHASH_MUL ENC_DEC REP
299289
vmovdqu AadHash(arg2), %xmm8
300290
vmovdqu HashKey(arg2), %xmm13 # xmm13 = HashKey
@@ -996,7 +986,7 @@ _partial_block_done_\@:
996986
## num_initial_blocks = b mod 4#
997987
## encrypt the initial num_initial_blocks blocks and apply ghash on the ciphertext
998988
## r10, r11, r12, rax are clobbered
999-
## arg1, arg3, arg4, r14 are used as a pointer only, not modified
989+
## arg1, arg2, arg3, arg4 are used as pointers only, not modified
1000990

1001991
.macro INITIAL_BLOCKS_AVX REP num_initial_blocks T1 T2 T3 T4 T5 CTR XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 T6 T_key ENC_DEC
1002992
i = (8-\num_initial_blocks)
@@ -1231,7 +1221,7 @@ _initial_blocks_done\@:
12311221

12321222
# encrypt 8 blocks at a time
12331223
# ghash the 8 previously encrypted ciphertext blocks
1234-
# arg1, arg3, arg4 are used as pointers only, not modified
1224+
# arg1, arg2, arg3, arg4 are used as pointers only, not modified
12351225
# r11 is the data offset value
12361226
.macro GHASH_8_ENCRYPT_8_PARALLEL_AVX REP T1 T2 T3 T4 T5 T6 CTR XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 T7 loop_idx ENC_DEC
12371227

@@ -1944,7 +1934,7 @@ SYM_FUNC_END(aesni_gcm_finalize_avx_gen2)
19441934
## num_initial_blocks = b mod 4#
19451935
## encrypt the initial num_initial_blocks blocks and apply ghash on the ciphertext
19461936
## r10, r11, r12, rax are clobbered
1947-
## arg1, arg3, arg4, r14 are used as a pointer only, not modified
1937+
## arg1, arg2, arg3, arg4 are used as pointers only, not modified
19481938

19491939
.macro INITIAL_BLOCKS_AVX2 REP num_initial_blocks T1 T2 T3 T4 T5 CTR XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 T6 T_key ENC_DEC VER
19501940
i = (8-\num_initial_blocks)
@@ -2186,7 +2176,7 @@ _initial_blocks_done\@:
21862176

21872177
# encrypt 8 blocks at a time
21882178
# ghash the 8 previously encrypted ciphertext blocks
2189-
# arg1, arg3, arg4 are used as pointers only, not modified
2179+
# arg1, arg2, arg3, arg4 are used as pointers only, not modified
21902180
# r11 is the data offset value
21912181
.macro GHASH_8_ENCRYPT_8_PARALLEL_AVX2 REP T1 T2 T3 T4 T5 T6 CTR XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 T7 loop_idx ENC_DEC
21922182

arch/x86/crypto/camellia-aesni-avx2-asm_64.S

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ SYM_FUNC_START(camellia_cbc_dec_32way)
990990
* %rdx: src (32 blocks)
991991
*/
992992
FRAME_BEGIN
993+
subq $(16 * 32), %rsp;
993994

994995
vzeroupper;
995996

@@ -1002,7 +1003,6 @@ SYM_FUNC_START(camellia_cbc_dec_32way)
10021003
%ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
10031004
%ymm15, %rdx, (key_table)(CTX, %r8, 8));
10041005

1005-
movq %rsp, %r10;
10061006
cmpq %rsi, %rdx;
10071007
je .Lcbc_dec_use_stack;
10081008

@@ -1015,7 +1015,6 @@ SYM_FUNC_START(camellia_cbc_dec_32way)
10151015
* dst still in-use (because dst == src), so use stack for temporary
10161016
* storage.
10171017
*/
1018-
subq $(16 * 32), %rsp;
10191018
movq %rsp, %rax;
10201019

10211020
.Lcbc_dec_continue:
@@ -1025,7 +1024,6 @@ SYM_FUNC_START(camellia_cbc_dec_32way)
10251024
vpxor %ymm7, %ymm7, %ymm7;
10261025
vinserti128 $1, (%rdx), %ymm7, %ymm7;
10271026
vpxor (%rax), %ymm7, %ymm7;
1028-
movq %r10, %rsp;
10291027
vpxor (0 * 32 + 16)(%rdx), %ymm6, %ymm6;
10301028
vpxor (1 * 32 + 16)(%rdx), %ymm5, %ymm5;
10311029
vpxor (2 * 32 + 16)(%rdx), %ymm4, %ymm4;
@@ -1047,6 +1045,7 @@ SYM_FUNC_START(camellia_cbc_dec_32way)
10471045

10481046
vzeroupper;
10491047

1048+
addq $(16 * 32), %rsp;
10501049
FRAME_END
10511050
ret;
10521051
SYM_FUNC_END(camellia_cbc_dec_32way)

arch/x86/crypto/crc32c-pcl-intel-asm_64.S

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
.endm
5454

5555
.macro JMPTBL_ENTRY i
56-
.word crc_\i - crc_array
56+
.quad crc_\i
5757
.endm
5858

5959
.macro JNC_LESS_THAN j
@@ -168,10 +168,7 @@ continue_block:
168168
xor crc2, crc2
169169

170170
## branch into array
171-
lea jump_table(%rip), %bufp
172-
movzwq (%bufp, %rax, 2), len
173-
lea crc_array(%rip), %bufp
174-
lea (%bufp, len, 1), %bufp
171+
mov jump_table(,%rax,8), %bufp
175172
JMP_NOSPEC bufp
176173

177174
################################################################

arch/x86/crypto/sha1_avx2_x86_64_asm.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,9 @@ _loop3:
645645
RESERVE_STACK = (W_SIZE*4 + 8+24)
646646

647647
/* Align stack */
648-
mov %rsp, %rbx
648+
push %rbp
649+
mov %rsp, %rbp
649650
and $~(0x20-1), %rsp
650-
push %rbx
651651
sub $RESERVE_STACK, %rsp
652652

653653
avx2_zeroupper
@@ -665,8 +665,8 @@ _loop3:
665665

666666
avx2_zeroupper
667667

668-
add $RESERVE_STACK, %rsp
669-
pop %rsp
668+
mov %rbp, %rsp
669+
pop %rbp
670670

671671
pop %r15
672672
pop %r14

arch/x86/crypto/sha1_ni_asm.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
#define DATA_PTR %rsi /* 2nd arg */
6060
#define NUM_BLKS %rdx /* 3rd arg */
6161

62-
#define RSPSAVE %rax
63-
6462
/* gcc conversion */
6563
#define FRAME_SIZE 32 /* space for 2x16 bytes */
6664

@@ -96,7 +94,8 @@
9694
.text
9795
.align 32
9896
SYM_FUNC_START(sha1_ni_transform)
99-
mov %rsp, RSPSAVE
97+
push %rbp
98+
mov %rsp, %rbp
10099
sub $FRAME_SIZE, %rsp
101100
and $~0xF, %rsp
102101

@@ -288,7 +287,8 @@ SYM_FUNC_START(sha1_ni_transform)
288287
pextrd $3, E0, 1*16(DIGEST_PTR)
289288

290289
.Ldone_hash:
291-
mov RSPSAVE, %rsp
290+
mov %rbp, %rsp
291+
pop %rbp
292292

293293
ret
294294
SYM_FUNC_END(sha1_ni_transform)

arch/x86/crypto/sha256-avx2-asm.S

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,13 @@ _XMM_SAVE_SIZE = 0
117117
_INP_END_SIZE = 8
118118
_INP_SIZE = 8
119119
_CTX_SIZE = 8
120-
_RSP_SIZE = 8
121120

122121
_XFER = 0
123122
_XMM_SAVE = _XFER + _XFER_SIZE
124123
_INP_END = _XMM_SAVE + _XMM_SAVE_SIZE
125124
_INP = _INP_END + _INP_END_SIZE
126125
_CTX = _INP + _INP_SIZE
127-
_RSP = _CTX + _CTX_SIZE
128-
STACK_SIZE = _RSP + _RSP_SIZE
126+
STACK_SIZE = _CTX + _CTX_SIZE
129127

130128
# rotate_Xs
131129
# Rotate values of symbols X0...X3
@@ -533,11 +531,11 @@ SYM_FUNC_START(sha256_transform_rorx)
533531
pushq %r14
534532
pushq %r15
535533

536-
mov %rsp, %rax
534+
push %rbp
535+
mov %rsp, %rbp
536+
537537
subq $STACK_SIZE, %rsp
538538
and $-32, %rsp # align rsp to 32 byte boundary
539-
mov %rax, _RSP(%rsp)
540-
541539

542540
shl $6, NUM_BLKS # convert to bytes
543541
jz done_hash
@@ -704,7 +702,8 @@ only_one_block:
704702

705703
done_hash:
706704

707-
mov _RSP(%rsp), %rsp
705+
mov %rbp, %rsp
706+
pop %rbp
708707

709708
popq %r15
710709
popq %r14

arch/x86/crypto/sha512-avx-asm.S

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,10 @@ tmp0 = %rax
7676
W_SIZE = 80*8
7777
# W[t] + K[t] | W[t+1] + K[t+1]
7878
WK_SIZE = 2*8
79-
RSPSAVE_SIZE = 1*8
80-
GPRSAVE_SIZE = 5*8
8179

8280
frame_W = 0
8381
frame_WK = frame_W + W_SIZE
84-
frame_RSPSAVE = frame_WK + WK_SIZE
85-
frame_GPRSAVE = frame_RSPSAVE + RSPSAVE_SIZE
86-
frame_size = frame_GPRSAVE + GPRSAVE_SIZE
82+
frame_size = frame_WK + WK_SIZE
8783

8884
# Useful QWORD "arrays" for simpler memory references
8985
# MSG, DIGEST, K_t, W_t are arrays
@@ -281,18 +277,18 @@ SYM_FUNC_START(sha512_transform_avx)
281277
test msglen, msglen
282278
je nowork
283279

280+
# Save GPRs
281+
push %rbx
282+
push %r12
283+
push %r13
284+
push %r14
285+
push %r15
286+
284287
# Allocate Stack Space
285-
mov %rsp, %rax
288+
push %rbp
289+
mov %rsp, %rbp
286290
sub $frame_size, %rsp
287291
and $~(0x20 - 1), %rsp
288-
mov %rax, frame_RSPSAVE(%rsp)
289-
290-
# Save GPRs
291-
mov %rbx, frame_GPRSAVE(%rsp)
292-
mov %r12, frame_GPRSAVE +8*1(%rsp)
293-
mov %r13, frame_GPRSAVE +8*2(%rsp)
294-
mov %r14, frame_GPRSAVE +8*3(%rsp)
295-
mov %r15, frame_GPRSAVE +8*4(%rsp)
296292

297293
updateblock:
298294

@@ -353,15 +349,16 @@ updateblock:
353349
dec msglen
354350
jnz updateblock
355351

356-
# Restore GPRs
357-
mov frame_GPRSAVE(%rsp), %rbx
358-
mov frame_GPRSAVE +8*1(%rsp), %r12
359-
mov frame_GPRSAVE +8*2(%rsp), %r13
360-
mov frame_GPRSAVE +8*3(%rsp), %r14
361-
mov frame_GPRSAVE +8*4(%rsp), %r15
362-
363352
# Restore Stack Pointer
364-
mov frame_RSPSAVE(%rsp), %rsp
353+
mov %rbp, %rsp
354+
pop %rbp
355+
356+
# Restore GPRs
357+
pop %r15
358+
pop %r14
359+
pop %r13
360+
pop %r12
361+
pop %rbx
365362

366363
nowork:
367364
ret

0 commit comments

Comments
 (0)