Skip to content

Commit 602bd70

Browse files
suryasaimadhuKAGA-KOKO
authored andcommitted
x86/dumpstack: Save first regs set for the executive summary
Save the regs set when __die() is onvoked for the first time and print it in oops_end(). Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Andy Lutomirski <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 7cccf07 commit 602bd70

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

arch/x86/kernel/dumpstack.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ int panic_on_unrecovered_nmi;
2828
int panic_on_io_nmi;
2929
static int die_counter;
3030

31+
static struct pt_regs exec_summary_regs;
32+
3133
bool in_task_stack(unsigned long *stack, struct task_struct *task,
3234
struct stack_info *info)
3335
{
@@ -321,6 +323,9 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
321323
raw_local_irq_restore(flags);
322324
oops_exit();
323325

326+
/* Executive summary in case the oops scrolled away */
327+
__show_regs(&exec_summary_regs, true);
328+
324329
if (!signr)
325330
return;
326331
if (in_interrupt())
@@ -339,10 +344,10 @@ NOKPROBE_SYMBOL(oops_end);
339344

340345
int __die(const char *str, struct pt_regs *regs, long err)
341346
{
342-
#ifdef CONFIG_X86_32
343-
unsigned short ss;
344-
unsigned long sp;
345-
#endif
347+
/* Save the regs of the first oops for the executive summary later. */
348+
if (!die_counter)
349+
exec_summary_regs = *regs;
350+
346351
printk(KERN_DEFAULT
347352
"%s: %04lx [#%d]%s%s%s%s%s\n", str, err & 0xffff, ++die_counter,
348353
IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
@@ -352,26 +357,13 @@ int __die(const char *str, struct pt_regs *regs, long err)
352357
IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION) ?
353358
(boot_cpu_has(X86_FEATURE_PTI) ? " PTI" : " NOPTI") : "");
354359

360+
show_regs(regs);
361+
print_modules();
362+
355363
if (notify_die(DIE_OOPS, str, regs, err,
356364
current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
357365
return 1;
358366

359-
print_modules();
360-
show_regs(regs);
361-
#ifdef CONFIG_X86_32
362-
if (user_mode(regs)) {
363-
sp = regs->sp;
364-
ss = regs->ss;
365-
} else {
366-
sp = kernel_stack_pointer(regs);
367-
savesegment(ss, ss);
368-
}
369-
printk(KERN_EMERG "EIP: %pS SS:ESP: %04x:%08lx\n",
370-
(void *)regs->ip, ss, sp);
371-
#else
372-
/* Executive summary in case the oops scrolled away */
373-
printk(KERN_ALERT "RIP: %pS RSP: %016lx\n", (void *)regs->ip, regs->sp);
374-
#endif
375367
return 0;
376368
}
377369
NOKPROBE_SYMBOL(__die);

0 commit comments

Comments
 (0)