mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 21:02:19 +00:00
Improve x86 debuggability: print registers with the same log level as the backtrace.
Signed-off-by: Ingo Molnar <mingo@kernel.org> -----BEGIN PGP SIGNATURE----- iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAl8oSVwRHG1pbmdvQGtl cm5lbC5vcmcACgkQEnMQ0APhK1iVgA//dJgCrIXMtv30UCHH6i4pWqUB9uPAoqk4 tK3A6L2+D+1nSbREe3DW/8Lz5val3KjfZmDkwZzdtT6W9B3lv7fNE8dU/2yA18Ov DPAAf+s+A/rQlNOi+PNQ9tm4zRitHQzdth2p9CeR+Ty5WcaPZ+sTjlSZH4me6a2h M4bK8pemseifO7DLlB+ZehrsFF1dcxqgKeZGXY4bpL7w3iunfc8+SNhVa3QX2Yay i1XqCHXaAL7LEpmxyTtH0NYrMoEO2z6qpJ4r93I41ku4lHBXjyY+6siJYHX4cmRr RoUbPNlI6BWODS+O0RRYnwlWwkqzC6kahHWjsq8kq6n3QXDXHh8oqqw+qV5BCtSL q6CBCAjjYOCH+fMKp22U23kKG+YpTtbtFEewGhMvto5Czis4UdLcuGjuLSmhSrYC Lc78DE6V2xNb5bb769oVHSk99ztb/6JhJk3jvIpCAY4Trl52m4RZBTNAGjlSekyQ A1EA7siA7W6Ccs0S0XXXVJ8Uzx/UzwzLFfPGZJPCWV/G/+CH4Gq+7dkKh6TKZ+pu Cc8yFxs2eBRr6a8GZtmlCN4ydLBkrOzwgWRaLO1CcZC/mgUJhWKoQYuhuuN/Fcnv q208MaVOXzV4mAHlqjqTccmFVeB5rL4/+s+7vADj0CBi8xFLkiIySmBrVyy+01Q6 UfhzuNsJBUk= =zyiS -----END PGP SIGNATURE----- Merge tag 'x86-core-2020-08-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull x86 debug fixlets from Ingo Molnar: "Improve x86 debuggability: print registers with the same log level as the backtrace" * tag 'x86-core-2020-08-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/dumpstack: Show registers dump with trace's log level x86/dumpstack: Add log_lvl to __show_regs() x86/dumpstack: Add log_lvl to show_iret_regs()
This commit is contained in:
commit
4ee4810315
@ -36,8 +36,9 @@ extern void die(const char *, struct pt_regs *,long);
|
||||
void die_addr(const char *str, struct pt_regs *regs, long err, long gp_addr);
|
||||
extern int __must_check __die(const char *, struct pt_regs *, long);
|
||||
extern void show_stack_regs(struct pt_regs *regs);
|
||||
extern void __show_regs(struct pt_regs *regs, enum show_regs_mode);
|
||||
extern void show_iret_regs(struct pt_regs *regs);
|
||||
extern void __show_regs(struct pt_regs *regs, enum show_regs_mode,
|
||||
const char *log_lvl);
|
||||
extern void show_iret_regs(struct pt_regs *regs, const char *log_lvl);
|
||||
extern unsigned long oops_begin(void);
|
||||
extern void oops_end(unsigned long, struct pt_regs *, int signr);
|
||||
|
||||
|
@ -133,15 +133,15 @@ void show_ip(struct pt_regs *regs, const char *loglvl)
|
||||
show_opcodes(regs, loglvl);
|
||||
}
|
||||
|
||||
void show_iret_regs(struct pt_regs *regs)
|
||||
void show_iret_regs(struct pt_regs *regs, const char *log_lvl)
|
||||
{
|
||||
show_ip(regs, KERN_DEFAULT);
|
||||
printk(KERN_DEFAULT "RSP: %04x:%016lx EFLAGS: %08lx", (int)regs->ss,
|
||||
show_ip(regs, log_lvl);
|
||||
printk("%sRSP: %04x:%016lx EFLAGS: %08lx", log_lvl, (int)regs->ss,
|
||||
regs->sp, regs->flags);
|
||||
}
|
||||
|
||||
static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs,
|
||||
bool partial)
|
||||
bool partial, const char *log_lvl)
|
||||
{
|
||||
/*
|
||||
* These on_stack() checks aren't strictly necessary: the unwind code
|
||||
@ -153,7 +153,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs,
|
||||
* they can be printed in the right context.
|
||||
*/
|
||||
if (!partial && on_stack(info, regs, sizeof(*regs))) {
|
||||
__show_regs(regs, SHOW_REGS_SHORT);
|
||||
__show_regs(regs, SHOW_REGS_SHORT, log_lvl);
|
||||
|
||||
} else if (partial && on_stack(info, (void *)regs + IRET_FRAME_OFFSET,
|
||||
IRET_FRAME_SIZE)) {
|
||||
@ -162,7 +162,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs,
|
||||
* full pt_regs might not have been saved yet. In that case
|
||||
* just print the iret frame.
|
||||
*/
|
||||
show_iret_regs(regs);
|
||||
show_iret_regs(regs, log_lvl);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
|
||||
printk("%s <%s>\n", log_lvl, stack_name);
|
||||
|
||||
if (regs)
|
||||
show_regs_if_on_stack(&stack_info, regs, partial);
|
||||
show_regs_if_on_stack(&stack_info, regs, partial, log_lvl);
|
||||
|
||||
/*
|
||||
* Scan the stack, printing any text addresses we find. At the
|
||||
@ -278,7 +278,7 @@ next:
|
||||
/* if the frame has entry regs, print them */
|
||||
regs = unwind_get_entry_regs(&state, &partial);
|
||||
if (regs)
|
||||
show_regs_if_on_stack(&stack_info, regs, partial);
|
||||
show_regs_if_on_stack(&stack_info, regs, partial, log_lvl);
|
||||
}
|
||||
|
||||
if (stack_name)
|
||||
@ -352,7 +352,7 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
|
||||
oops_exit();
|
||||
|
||||
/* Executive summary in case the oops scrolled away */
|
||||
__show_regs(&exec_summary_regs, SHOW_REGS_ALL);
|
||||
__show_regs(&exec_summary_regs, SHOW_REGS_ALL, KERN_DEFAULT);
|
||||
|
||||
if (!signr)
|
||||
return;
|
||||
@ -444,9 +444,12 @@ void die_addr(const char *str, struct pt_regs *regs, long err, long gp_addr)
|
||||
|
||||
void show_regs(struct pt_regs *regs)
|
||||
{
|
||||
enum show_regs_mode print_kernel_regs;
|
||||
|
||||
show_regs_print_info(KERN_DEFAULT);
|
||||
|
||||
__show_regs(regs, user_mode(regs) ? SHOW_REGS_USER : SHOW_REGS_ALL);
|
||||
print_kernel_regs = user_mode(regs) ? SHOW_REGS_USER : SHOW_REGS_ALL;
|
||||
__show_regs(regs, print_kernel_regs, KERN_DEFAULT);
|
||||
|
||||
/*
|
||||
* When in-kernel, we also print out the stack at the time of the fault..
|
||||
|
@ -56,7 +56,8 @@
|
||||
|
||||
#include "process.h"
|
||||
|
||||
void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
|
||||
void __show_regs(struct pt_regs *regs, enum show_regs_mode mode,
|
||||
const char *log_lvl)
|
||||
{
|
||||
unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
|
||||
unsigned long d0, d1, d2, d3, d6, d7;
|
||||
@ -67,14 +68,14 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
|
||||
else
|
||||
savesegment(gs, gs);
|
||||
|
||||
show_ip(regs, KERN_DEFAULT);
|
||||
show_ip(regs, log_lvl);
|
||||
|
||||
printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
|
||||
regs->ax, regs->bx, regs->cx, regs->dx);
|
||||
printk(KERN_DEFAULT "ESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n",
|
||||
regs->si, regs->di, regs->bp, regs->sp);
|
||||
printk(KERN_DEFAULT "DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x EFLAGS: %08lx\n",
|
||||
(u16)regs->ds, (u16)regs->es, (u16)regs->fs, gs, regs->ss, regs->flags);
|
||||
printk("%sEAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
|
||||
log_lvl, regs->ax, regs->bx, regs->cx, regs->dx);
|
||||
printk("%sESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n",
|
||||
log_lvl, regs->si, regs->di, regs->bp, regs->sp);
|
||||
printk("%sDS: %04x ES: %04x FS: %04x GS: %04x SS: %04x EFLAGS: %08lx\n",
|
||||
log_lvl, (u16)regs->ds, (u16)regs->es, (u16)regs->fs, gs, regs->ss, regs->flags);
|
||||
|
||||
if (mode != SHOW_REGS_ALL)
|
||||
return;
|
||||
@ -83,8 +84,8 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
|
||||
cr2 = read_cr2();
|
||||
cr3 = __read_cr3();
|
||||
cr4 = __read_cr4();
|
||||
printk(KERN_DEFAULT "CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n",
|
||||
cr0, cr2, cr3, cr4);
|
||||
printk("%sCR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n",
|
||||
log_lvl, cr0, cr2, cr3, cr4);
|
||||
|
||||
get_debugreg(d0, 0);
|
||||
get_debugreg(d1, 1);
|
||||
@ -98,10 +99,10 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
|
||||
(d6 == DR6_RESERVED) && (d7 == 0x400))
|
||||
return;
|
||||
|
||||
printk(KERN_DEFAULT "DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n",
|
||||
d0, d1, d2, d3);
|
||||
printk(KERN_DEFAULT "DR6: %08lx DR7: %08lx\n",
|
||||
d6, d7);
|
||||
printk("%sDR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n",
|
||||
log_lvl, d0, d1, d2, d3);
|
||||
printk("%sDR6: %08lx DR7: %08lx\n",
|
||||
log_lvl, d6, d7);
|
||||
}
|
||||
|
||||
void release_thread(struct task_struct *dead_task)
|
||||
|
@ -62,30 +62,31 @@
|
||||
#include "process.h"
|
||||
|
||||
/* Prints also some state that isn't saved in the pt_regs */
|
||||
void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
|
||||
void __show_regs(struct pt_regs *regs, enum show_regs_mode mode,
|
||||
const char *log_lvl)
|
||||
{
|
||||
unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs;
|
||||
unsigned long d0, d1, d2, d3, d6, d7;
|
||||
unsigned int fsindex, gsindex;
|
||||
unsigned int ds, es;
|
||||
|
||||
show_iret_regs(regs);
|
||||
show_iret_regs(regs, log_lvl);
|
||||
|
||||
if (regs->orig_ax != -1)
|
||||
pr_cont(" ORIG_RAX: %016lx\n", regs->orig_ax);
|
||||
else
|
||||
pr_cont("\n");
|
||||
|
||||
printk(KERN_DEFAULT "RAX: %016lx RBX: %016lx RCX: %016lx\n",
|
||||
regs->ax, regs->bx, regs->cx);
|
||||
printk(KERN_DEFAULT "RDX: %016lx RSI: %016lx RDI: %016lx\n",
|
||||
regs->dx, regs->si, regs->di);
|
||||
printk(KERN_DEFAULT "RBP: %016lx R08: %016lx R09: %016lx\n",
|
||||
regs->bp, regs->r8, regs->r9);
|
||||
printk(KERN_DEFAULT "R10: %016lx R11: %016lx R12: %016lx\n",
|
||||
regs->r10, regs->r11, regs->r12);
|
||||
printk(KERN_DEFAULT "R13: %016lx R14: %016lx R15: %016lx\n",
|
||||
regs->r13, regs->r14, regs->r15);
|
||||
printk("%sRAX: %016lx RBX: %016lx RCX: %016lx\n",
|
||||
log_lvl, regs->ax, regs->bx, regs->cx);
|
||||
printk("%sRDX: %016lx RSI: %016lx RDI: %016lx\n",
|
||||
log_lvl, regs->dx, regs->si, regs->di);
|
||||
printk("%sRBP: %016lx R08: %016lx R09: %016lx\n",
|
||||
log_lvl, regs->bp, regs->r8, regs->r9);
|
||||
printk("%sR10: %016lx R11: %016lx R12: %016lx\n",
|
||||
log_lvl, regs->r10, regs->r11, regs->r12);
|
||||
printk("%sR13: %016lx R14: %016lx R15: %016lx\n",
|
||||
log_lvl, regs->r13, regs->r14, regs->r15);
|
||||
|
||||
if (mode == SHOW_REGS_SHORT)
|
||||
return;
|
||||
@ -93,8 +94,8 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
|
||||
if (mode == SHOW_REGS_USER) {
|
||||
rdmsrl(MSR_FS_BASE, fs);
|
||||
rdmsrl(MSR_KERNEL_GS_BASE, shadowgs);
|
||||
printk(KERN_DEFAULT "FS: %016lx GS: %016lx\n",
|
||||
fs, shadowgs);
|
||||
printk("%sFS: %016lx GS: %016lx\n",
|
||||
log_lvl, fs, shadowgs);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -112,12 +113,12 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
|
||||
cr3 = __read_cr3();
|
||||
cr4 = __read_cr4();
|
||||
|
||||
printk(KERN_DEFAULT "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n",
|
||||
fs, fsindex, gs, gsindex, shadowgs);
|
||||
printk(KERN_DEFAULT "CS: %04lx DS: %04x ES: %04x CR0: %016lx\n", regs->cs, ds,
|
||||
es, cr0);
|
||||
printk(KERN_DEFAULT "CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3,
|
||||
cr4);
|
||||
printk("%sFS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n",
|
||||
log_lvl, fs, fsindex, gs, gsindex, shadowgs);
|
||||
printk("%sCS: %04lx DS: %04x ES: %04x CR0: %016lx\n",
|
||||
log_lvl, regs->cs, ds, es, cr0);
|
||||
printk("%sCR2: %016lx CR3: %016lx CR4: %016lx\n",
|
||||
log_lvl, cr2, cr3, cr4);
|
||||
|
||||
get_debugreg(d0, 0);
|
||||
get_debugreg(d1, 1);
|
||||
@ -129,14 +130,14 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
|
||||
/* Only print out debug registers if they are in their non-default state. */
|
||||
if (!((d0 == 0) && (d1 == 0) && (d2 == 0) && (d3 == 0) &&
|
||||
(d6 == DR6_RESERVED) && (d7 == 0x400))) {
|
||||
printk(KERN_DEFAULT "DR0: %016lx DR1: %016lx DR2: %016lx\n",
|
||||
d0, d1, d2);
|
||||
printk(KERN_DEFAULT "DR3: %016lx DR6: %016lx DR7: %016lx\n",
|
||||
d3, d6, d7);
|
||||
printk("%sDR0: %016lx DR1: %016lx DR2: %016lx\n",
|
||||
log_lvl, d0, d1, d2);
|
||||
printk("%sDR3: %016lx DR6: %016lx DR7: %016lx\n",
|
||||
log_lvl, d3, d6, d7);
|
||||
}
|
||||
|
||||
if (boot_cpu_has(X86_FEATURE_OSPKE))
|
||||
printk(KERN_DEFAULT "PKRU: %08x\n", read_pkru());
|
||||
printk("%sPKRU: %08x\n", log_lvl, read_pkru());
|
||||
}
|
||||
|
||||
void release_thread(struct task_struct *dead_task)
|
||||
|
Loading…
Reference in New Issue
Block a user