Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/head: Add unwind hint annotations

Jiri Slaby reported an ORC issue when unwinding from an idle task. The
stack was:

ffffffff811083c2 do_idle+0x142/0x1e0
ffffffff8110861d cpu_startup_entry+0x5d/0x60
ffffffff82715f58 start_kernel+0x3ff/0x407
ffffffff827153e8 x86_64_start_kernel+0x14e/0x15d
ffffffff810001bf secondary_startup_64+0x9f/0xa0

The ORC unwinder errored out at secondary_startup_64 because the head
code isn't annotated yet so there wasn't a corresponding ORC entry.

Fix that and any other head-related unwinding issues by adding unwind
hints to the head code.

Reported-by: Jiri Slaby <jslaby@suse.cz>
Tested-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.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/78ef000a2f68f545d6eef44ee912edceaad82ccf.1505764066.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Josh Poimboeuf and committed by
Ingo Molnar
2704fbb6 abbe1cac

+12 -3
-1
arch/x86/kernel/Makefile
··· 26 26 KASAN_SANITIZE_dumpstack_$(BITS).o := n 27 27 KASAN_SANITIZE_stacktrace.o := n 28 28 29 - OBJECT_FILES_NON_STANDARD_head_$(BITS).o := y 30 29 OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o := y 31 30 OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o := y 32 31 OBJECT_FILES_NON_STANDARD_test_nx.o := y
+12 -2
arch/x86/kernel/head_64.S
··· 49 49 .code64 50 50 .globl startup_64 51 51 startup_64: 52 + UNWIND_HINT_EMPTY 52 53 /* 53 54 * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 0, 54 55 * and someone has loaded an identity mapped page table ··· 89 88 addq $(early_top_pgt - __START_KERNEL_map), %rax 90 89 jmp 1f 91 90 ENTRY(secondary_startup_64) 91 + UNWIND_HINT_EMPTY 92 92 /* 93 93 * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 0, 94 94 * and someone has loaded a mapped page table. ··· 134 132 movq $1f, %rax 135 133 jmp *%rax 136 134 1: 135 + UNWIND_HINT_EMPTY 137 136 138 137 /* Check if nx is implemented */ 139 138 movl $0x80000001, %eax ··· 249 246 */ 250 247 ENTRY(start_cpu0) 251 248 movq initial_stack(%rip), %rsp 249 + UNWIND_HINT_EMPTY 252 250 jmp .Ljump_to_C_code 253 251 ENDPROC(start_cpu0) 254 252 #endif ··· 274 270 i = 0 275 271 .rept NUM_EXCEPTION_VECTORS 276 272 .ifeq (EXCEPTION_ERRCODE_MASK >> i) & 1 277 - pushq $0 # Dummy error code, to make stack frame uniform 273 + UNWIND_HINT_IRET_REGS 274 + pushq $0 # Dummy error code, to make stack frame uniform 275 + .else 276 + UNWIND_HINT_IRET_REGS offset=8 278 277 .endif 279 278 pushq $i # 72(%rsp) Vector number 280 279 jmp early_idt_handler_common 280 + UNWIND_HINT_IRET_REGS 281 281 i = i + 1 282 282 .fill early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE - ., 1, 0xcc 283 283 .endr 284 + UNWIND_HINT_IRET_REGS offset=16 284 285 END(early_idt_handler_array) 285 286 286 287 early_idt_handler_common: ··· 314 305 pushq %r13 /* pt_regs->r13 */ 315 306 pushq %r14 /* pt_regs->r14 */ 316 307 pushq %r15 /* pt_regs->r15 */ 308 + UNWIND_HINT_REGS 317 309 318 310 cmpq $14,%rsi /* Page fault? */ 319 311 jnz 10f ··· 437 427 EXPORT_SYMBOL(phys_base) 438 428 439 429 #include "../../x86/xen/xen-head.S" 440 - 430 + 441 431 __PAGE_ALIGNED_BSS 442 432 NEXT_PAGE(empty_zero_page) 443 433 .skip PAGE_SIZE