Commit 427284b2 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Yang Yingliang
Browse files

x86/entry: Make entry_64_compat.S objtool clean



mainline inclusion
from mainline-v5.8-rc1
commit 1c3e5d3f
category: feature
bugzilla: 175666
CVE: NA

---------------------------

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: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarAlexandre Chartre <alexandre.chartre@oracle.com>
Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/20200505134341.272248024@linutronix.de


Signed-off-by: default avatarWang ShaoBo <bobo.shaobowang@huawei.com>
Conflicts:
	arch/x86/entry/entry_64_compat.S
[wangshaobo: change ENDPROC to END, avoid objtool skipping STT_FUNC type check]
Reviewed-by: default avatarCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 89f74ab3
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -3,8 +3,6 @@
# Makefile for the x86 low level entry code
#

OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y

CFLAGS_syscall_64.o		+= $(call cc-option,-Wno-override-init,)
CFLAGS_syscall_32.o		+= $(call cc-option,-Wno-override-init,)
obj-y				:= entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o
+15 −2
Original line number Diff line number Diff line
@@ -47,11 +47,14 @@
 * 0(%ebp) arg6
 */
ENTRY(entry_SYSENTER_compat)
	UNWIND_HINT_EMPTY
	/* Interrupts are off on entry. */
	SWAPGS

	/* We are about to clobber %rsp anyway, clobbering here is OK */
	SWITCH_TO_KERNEL_CR3 scratch_reg=%rsp
	pushq	%rax
	SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
	popq	%rax

	movq	PER_CPU_VAR(cpu_current_top_of_stack), %rsp

@@ -104,6 +107,9 @@ ENTRY(entry_SYSENTER_compat)
	xorl	%r14d, %r14d		/* nospec   r14 */
	pushq   $0			/* pt_regs->r15 = 0 */
	xorl	%r15d, %r15d		/* nospec   r15 */

	UNWIND_HINT_REGS

	cld

	/*
@@ -147,7 +153,7 @@ ENTRY(entry_SYSENTER_compat)
	popfq
	jmp	.Lsysenter_flags_fixed
GLOBAL(__end_entry_SYSENTER_compat)
ENDPROC(entry_SYSENTER_compat)
END(entry_SYSENTER_compat)

/*
 * 32-bit SYSCALL entry.
@@ -197,6 +203,7 @@ ENDPROC(entry_SYSENTER_compat)
 * 0(%esp) arg6
 */
ENTRY(entry_SYSCALL_compat)
	UNWIND_HINT_EMPTY
	/* Interrupts are off on entry. */
	swapgs

@@ -247,6 +254,8 @@ GLOBAL(entry_SYSCALL_compat_after_hwframe)
	pushq   $0			/* pt_regs->r15 = 0 */
	xorl	%r15d, %r15d		/* nospec   r15 */

	UNWIND_HINT_REGS

	/*
	 * User mode is traced as though IRQs are on, and SYSENTER
	 * turned them off.
@@ -335,6 +344,7 @@ END(entry_SYSCALL_compat)
 * ebp  arg6
 */
ENTRY(entry_INT80_compat)
	UNWIND_HINT_EMPTY
	/*
	 * Interrupts are off on entry.
	 */
@@ -396,6 +406,9 @@ ENTRY(entry_INT80_compat)
	xorl	%r14d, %r14d		/* nospec   r14 */
	pushq   %r15                    /* pt_regs->r15 */
	xorl	%r15d, %r15d		/* nospec   r15 */

	UNWIND_HINT_REGS

	cld

	/*