Skip to content

Commit 1fb1436

Browse files
jpoimboeIngo Molnar
authored andcommitted
x86/entry/64: Fix unwind hints in kernel exit path
In swapgs_restore_regs_and_return_to_usermode, after the stack is switched to the trampoline stack, the existing UNWIND_HINT_REGS hint is no longer valid, which can result in the following ORC unwinder warning: WARNING: can't dereference registers at 000000003aeb0cdd for ip swapgs_restore_regs_and_return_to_usermode+0x93/0xa0 For full correctness, we could try to add complicated unwind hints so the unwinder could continue to find the registers, but when when it's this close to kernel exit, unwind hints aren't really needed anymore and it's fine to just use an empty hint which tells the unwinder to stop. For consistency, also move the UNWIND_HINT_EMPTY in entry_SYSCALL_64_after_hwframe to a similar location. Fixes: 3e3b929 ("x86/entry/64: Return to userspace from the trampoline stack") Reported-by: Vince Weaver <[email protected]> Reported-by: Dave Jones <[email protected]> Reported-by: Dr. David Alan Gilbert <[email protected]> Reported-by: Joe Mario <[email protected]> Reported-by: Jann Horn <[email protected]> Reported-by: Linus Torvalds <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/60ea8f562987ed2d9ace2977502fe481c0d7c9a0.1587808742.git.jpoimboe@redhat.com
1 parent 06a9750 commit 1fb1436

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/entry/entry_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ SYM_INNER_LABEL(entry_SYSCALL_64_after_hwframe, SYM_L_GLOBAL)
249249
*/
250250
syscall_return_via_sysret:
251251
/* rcx and r11 are already restored (see code above) */
252-
UNWIND_HINT_EMPTY
253252
POP_REGS pop_rdi=0 skip_r11rcx=1
254253

255254
/*
@@ -258,6 +257,7 @@ syscall_return_via_sysret:
258257
*/
259258
movq %rsp, %rdi
260259
movq PER_CPU_VAR(cpu_tss_rw + TSS_sp0), %rsp
260+
UNWIND_HINT_EMPTY
261261

262262
pushq RSP-RDI(%rdi) /* RSP */
263263
pushq (%rdi) /* RDI */
@@ -637,6 +637,7 @@ SYM_INNER_LABEL(swapgs_restore_regs_and_return_to_usermode, SYM_L_GLOBAL)
637637
*/
638638
movq %rsp, %rdi
639639
movq PER_CPU_VAR(cpu_tss_rw + TSS_sp0), %rsp
640+
UNWIND_HINT_EMPTY
640641

641642
/* Copy the IRET frame to the trampoline stack. */
642643
pushq 6*8(%rdi) /* SS */

0 commit comments

Comments
 (0)