Commit 26c4ef9c authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Ingo Molnar

x86/entry/64: Split the IRET-to-user and IRET-to-kernel paths

These code paths will diverge soon.
Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/dccf8c7b3750199b4b30383c812d4e2931811509.1509609304.git.luto@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 9da78ba6
...@@ -321,7 +321,7 @@ syscall_return_via_sysret: ...@@ -321,7 +321,7 @@ syscall_return_via_sysret:
opportunistic_sysret_failed: opportunistic_sysret_failed:
SWAPGS SWAPGS
jmp restore_regs_and_iret jmp restore_regs_and_return_to_usermode
END(entry_SYSCALL_64) END(entry_SYSCALL_64)
ENTRY(stub_ptregs_64) ENTRY(stub_ptregs_64)
...@@ -423,7 +423,7 @@ ENTRY(ret_from_fork) ...@@ -423,7 +423,7 @@ ENTRY(ret_from_fork)
call syscall_return_slowpath /* returns with IRQs disabled */ call syscall_return_slowpath /* returns with IRQs disabled */
TRACE_IRQS_ON /* user mode is traced as IRQS on */ TRACE_IRQS_ON /* user mode is traced as IRQS on */
SWAPGS SWAPGS
jmp restore_regs_and_iret jmp restore_regs_and_return_to_usermode
1: 1:
/* kernel thread */ /* kernel thread */
...@@ -612,7 +612,20 @@ GLOBAL(retint_user) ...@@ -612,7 +612,20 @@ GLOBAL(retint_user)
call prepare_exit_to_usermode call prepare_exit_to_usermode
TRACE_IRQS_IRETQ TRACE_IRQS_IRETQ
SWAPGS SWAPGS
jmp restore_regs_and_iret
GLOBAL(restore_regs_and_return_to_usermode)
#ifdef CONFIG_DEBUG_ENTRY
/* Assert that pt_regs indicates user mode. */
testl $3, CS(%rsp)
jnz 1f
ud2
1:
#endif
RESTORE_EXTRA_REGS
RESTORE_C_REGS
REMOVE_PT_GPREGS_FROM_STACK 8
INTERRUPT_RETURN
/* Returning to kernel space */ /* Returning to kernel space */
retint_kernel: retint_kernel:
...@@ -632,11 +645,14 @@ retint_kernel: ...@@ -632,11 +645,14 @@ retint_kernel:
*/ */
TRACE_IRQS_IRETQ TRACE_IRQS_IRETQ
/* GLOBAL(restore_regs_and_return_to_kernel)
* At this label, code paths which return to kernel and to user, #ifdef CONFIG_DEBUG_ENTRY
* which come from interrupts/exception and from syscalls, merge. /* Assert that pt_regs indicates kernel mode. */
*/ testl $3, CS(%rsp)
GLOBAL(restore_regs_and_iret) jz 1f
ud2
1:
#endif
RESTORE_EXTRA_REGS RESTORE_EXTRA_REGS
RESTORE_C_REGS RESTORE_C_REGS
REMOVE_PT_GPREGS_FROM_STACK 8 REMOVE_PT_GPREGS_FROM_STACK 8
...@@ -1327,7 +1343,7 @@ ENTRY(nmi) ...@@ -1327,7 +1343,7 @@ ENTRY(nmi)
* work, because we don't want to enable interrupts. * work, because we don't want to enable interrupts.
*/ */
SWAPGS SWAPGS
jmp restore_regs_and_iret jmp restore_regs_and_return_to_usermode
.Lnmi_from_kernel: .Lnmi_from_kernel:
/* /*
......
...@@ -337,7 +337,7 @@ ENTRY(entry_INT80_compat) ...@@ -337,7 +337,7 @@ ENTRY(entry_INT80_compat)
/* Go back to user mode. */ /* Go back to user mode. */
TRACE_IRQS_ON TRACE_IRQS_ON
SWAPGS SWAPGS
jmp restore_regs_and_iret jmp restore_regs_and_return_to_usermode
END(entry_INT80_compat) END(entry_INT80_compat)
ENTRY(stub32_clone) ENTRY(stub32_clone)
......
...@@ -326,7 +326,7 @@ early_idt_handler_common: ...@@ -326,7 +326,7 @@ early_idt_handler_common:
20: 20:
decl early_recursion_flag(%rip) decl early_recursion_flag(%rip)
jmp restore_regs_and_iret jmp restore_regs_and_return_to_kernel
END(early_idt_handler_common) END(early_idt_handler_common)
__INITDATA __INITDATA
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment