Skip to content

Commit 1c3e5d3

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86/entry: Make entry_64_compat.S objtool clean
Currently entry_64_compat is exempt from objtool, but with vmlinux mode there is no hiding it. Make the following changes to make it pass: - change entry_SYSENTER_compat to STT_NOTYPE; it's not a function and doesn't have function type stack setup. - mark all STT_NOTYPE symbols with UNWIND_HINT_EMPTY; so we do validate them and don't treat them as unreachable. - don't abuse RSP as a temp register, this confuses objtool mightily as it (rightfully) thinks we're doing unspeakable things to the stack. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent a7ef9ba commit 1c3e5d3

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

arch/x86/entry/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) -fstack-protector -fstack-protector-
1111
CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) -fstack-protector -fstack-protector-strong
1212
CFLAGS_REMOVE_syscall_64.o = $(CC_FLAGS_FTRACE) -fstack-protector -fstack-protector-strong
1313

14-
OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y
15-
1614
CFLAGS_syscall_64.o += $(call cc-option,-Wno-override-init,)
1715
CFLAGS_syscall_32.o += $(call cc-option,-Wno-override-init,)
1816
obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o

arch/x86/entry/entry_64_compat.S

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@
4646
* ebp user stack
4747
* 0(%ebp) arg6
4848
*/
49-
SYM_FUNC_START(entry_SYSENTER_compat)
49+
SYM_CODE_START(entry_SYSENTER_compat)
50+
UNWIND_HINT_EMPTY
5051
/* Interrupts are off on entry. */
5152
SWAPGS
5253

53-
/* We are about to clobber %rsp anyway, clobbering here is OK */
54-
SWITCH_TO_KERNEL_CR3 scratch_reg=%rsp
54+
pushq %rax
55+
SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
56+
popq %rax
5557

5658
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
5759

@@ -104,6 +106,9 @@ SYM_FUNC_START(entry_SYSENTER_compat)
104106
xorl %r14d, %r14d /* nospec r14 */
105107
pushq $0 /* pt_regs->r15 = 0 */
106108
xorl %r15d, %r15d /* nospec r15 */
109+
110+
UNWIND_HINT_REGS
111+
107112
cld
108113

109114
/*
@@ -141,7 +146,7 @@ SYM_FUNC_START(entry_SYSENTER_compat)
141146
popfq
142147
jmp .Lsysenter_flags_fixed
143148
SYM_INNER_LABEL(__end_entry_SYSENTER_compat, SYM_L_GLOBAL)
144-
SYM_FUNC_END(entry_SYSENTER_compat)
149+
SYM_CODE_END(entry_SYSENTER_compat)
145150

146151
/*
147152
* 32-bit SYSCALL entry.
@@ -191,6 +196,7 @@ SYM_FUNC_END(entry_SYSENTER_compat)
191196
* 0(%esp) arg6
192197
*/
193198
SYM_CODE_START(entry_SYSCALL_compat)
199+
UNWIND_HINT_EMPTY
194200
/* Interrupts are off on entry. */
195201
swapgs
196202

@@ -241,6 +247,8 @@ SYM_INNER_LABEL(entry_SYSCALL_compat_after_hwframe, SYM_L_GLOBAL)
241247
pushq $0 /* pt_regs->r15 = 0 */
242248
xorl %r15d, %r15d /* nospec r15 */
243249

250+
UNWIND_HINT_REGS
251+
244252
movq %rsp, %rdi
245253
call do_fast_syscall_32
246254
/* XEN PV guests always use IRET path */
@@ -328,6 +336,7 @@ SYM_CODE_END(entry_SYSCALL_compat)
328336
* ebp arg6
329337
*/
330338
SYM_CODE_START(entry_INT80_compat)
339+
UNWIND_HINT_EMPTY
331340
/*
332341
* Interrupts are off on entry.
333342
*/
@@ -349,8 +358,11 @@ SYM_CODE_START(entry_INT80_compat)
349358

350359
/* Need to switch before accessing the thread stack. */
351360
SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi
361+
352362
/* In the Xen PV case we already run on the thread stack. */
353-
ALTERNATIVE "movq %rsp, %rdi", "jmp .Lint80_keep_stack", X86_FEATURE_XENPV
363+
ALTERNATIVE "", "jmp .Lint80_keep_stack", X86_FEATURE_XENPV
364+
365+
movq %rsp, %rdi
354366
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
355367

356368
pushq 6*8(%rdi) /* regs->ss */
@@ -389,6 +401,9 @@ SYM_CODE_START(entry_INT80_compat)
389401
xorl %r14d, %r14d /* nospec r14 */
390402
pushq %r15 /* pt_regs->r15 */
391403
xorl %r15d, %r15d /* nospec r15 */
404+
405+
UNWIND_HINT_REGS
406+
392407
cld
393408

394409
movq %rsp, %rdi

0 commit comments

Comments
 (0)