Commit 36e635cb authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 stackdump update from Ingo Molnar:
 "A number of stackdump enhancements"

* 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/dumpstack: Add show_stack_regs() and use it
  printk: Make the printk*once() variants return a value
  x86/dumpstack: Honor supplied @regs arg
parents c265cc5c 81c2949f
...@@ -26,6 +26,7 @@ extern void die(const char *, struct pt_regs *,long); ...@@ -26,6 +26,7 @@ extern void die(const char *, struct pt_regs *,long);
extern int __must_check __die(const char *, struct pt_regs *, long); extern int __must_check __die(const char *, struct pt_regs *, long);
extern void show_trace(struct task_struct *t, struct pt_regs *regs, extern void show_trace(struct task_struct *t, struct pt_regs *regs,
unsigned long *sp, unsigned long bp); unsigned long *sp, unsigned long bp);
extern void show_stack_regs(struct pt_regs *regs);
extern void __show_regs(struct pt_regs *regs, int all); extern void __show_regs(struct pt_regs *regs, int all);
extern unsigned long oops_begin(void); extern unsigned long oops_begin(void);
extern void oops_end(unsigned long, struct pt_regs *, int signr); extern void oops_end(unsigned long, struct pt_regs *, int signr);
......
...@@ -205,6 +205,11 @@ void show_stack(struct task_struct *task, unsigned long *sp) ...@@ -205,6 +205,11 @@ void show_stack(struct task_struct *task, unsigned long *sp)
show_stack_log_lvl(task, NULL, sp, bp, ""); show_stack_log_lvl(task, NULL, sp, bp, "");
} }
void show_stack_regs(struct pt_regs *regs)
{
show_stack_log_lvl(current, regs, (unsigned long *)regs->sp, regs->bp, "");
}
static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED; static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
static int die_owner = -1; static int die_owner = -1;
static unsigned int die_nest_count; static unsigned int die_nest_count;
......
...@@ -96,7 +96,9 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, ...@@ -96,7 +96,9 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
int i; int i;
if (sp == NULL) { if (sp == NULL) {
if (task) if (regs)
sp = (unsigned long *)regs->sp;
else if (task)
sp = (unsigned long *)task->thread.sp; sp = (unsigned long *)task->thread.sp;
else else
sp = (unsigned long *)&sp; sp = (unsigned long *)&sp;
......
...@@ -264,7 +264,9 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, ...@@ -264,7 +264,9 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
* back trace for this cpu: * back trace for this cpu:
*/ */
if (sp == NULL) { if (sp == NULL) {
if (task) if (regs)
sp = (unsigned long *)regs->sp;
else if (task)
sp = (unsigned long *)task->thread.sp; sp = (unsigned long *)task->thread.sp;
else else
sp = (unsigned long *)&sp; sp = (unsigned long *)&sp;
......
#include <linux/module.h> #include <linux/module.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/traps.h> #include <asm/traps.h>
#include <asm/kdebug.h>
typedef bool (*ex_handler_t)(const struct exception_table_entry *, typedef bool (*ex_handler_t)(const struct exception_table_entry *,
struct pt_regs *, int); struct pt_regs *, int);
...@@ -46,8 +47,9 @@ EXPORT_SYMBOL(ex_handler_ext); ...@@ -46,8 +47,9 @@ EXPORT_SYMBOL(ex_handler_ext);
bool ex_handler_rdmsr_unsafe(const struct exception_table_entry *fixup, bool ex_handler_rdmsr_unsafe(const struct exception_table_entry *fixup,
struct pt_regs *regs, int trapnr) struct pt_regs *regs, int trapnr)
{ {
WARN_ONCE(1, "unchecked MSR access error: RDMSR from 0x%x\n", if (pr_warn_once("unchecked MSR access error: RDMSR from 0x%x at rIP: 0x%lx (%pF)\n",
(unsigned int)regs->cx); (unsigned int)regs->cx, regs->ip, (void *)regs->ip))
show_stack_regs(regs);
/* Pretend that the read succeeded and returned 0. */ /* Pretend that the read succeeded and returned 0. */
regs->ip = ex_fixup_addr(fixup); regs->ip = ex_fixup_addr(fixup);
...@@ -60,9 +62,10 @@ EXPORT_SYMBOL(ex_handler_rdmsr_unsafe); ...@@ -60,9 +62,10 @@ EXPORT_SYMBOL(ex_handler_rdmsr_unsafe);
bool ex_handler_wrmsr_unsafe(const struct exception_table_entry *fixup, bool ex_handler_wrmsr_unsafe(const struct exception_table_entry *fixup,
struct pt_regs *regs, int trapnr) struct pt_regs *regs, int trapnr)
{ {
WARN_ONCE(1, "unchecked MSR access error: WRMSR to 0x%x (tried to write 0x%08x%08x)\n", if (pr_warn_once("unchecked MSR access error: WRMSR to 0x%x (tried to write 0x%08x%08x) at rIP: 0x%lx (%pF)\n",
(unsigned int)regs->cx, (unsigned int)regs->cx, (unsigned int)regs->dx,
(unsigned int)regs->dx, (unsigned int)regs->ax); (unsigned int)regs->ax, regs->ip, (void *)regs->ip))
show_stack_regs(regs);
/* Pretend that the write succeeded. */ /* Pretend that the write succeeded. */
regs->ip = ex_fixup_addr(fixup); regs->ip = ex_fixup_addr(fixup);
......
...@@ -108,11 +108,14 @@ struct va_format { ...@@ -108,11 +108,14 @@ struct va_format {
* Dummy printk for disabled debugging statements to use whilst maintaining * Dummy printk for disabled debugging statements to use whilst maintaining
* gcc's format checking. * gcc's format checking.
*/ */
#define no_printk(fmt, ...) \ #define no_printk(fmt, ...) \
do { \ ({ \
if (0) \ do { \
printk(fmt, ##__VA_ARGS__); \ if (0) \
} while (0) printk(fmt, ##__VA_ARGS__); \
} while (0); \
0; \
})
#ifdef CONFIG_EARLY_PRINTK #ifdef CONFIG_EARLY_PRINTK
extern asmlinkage __printf(1, 2) extern asmlinkage __printf(1, 2)
...@@ -309,20 +312,24 @@ extern asmlinkage void dump_stack(void) __cold; ...@@ -309,20 +312,24 @@ extern asmlinkage void dump_stack(void) __cold;
#define printk_once(fmt, ...) \ #define printk_once(fmt, ...) \
({ \ ({ \
static bool __print_once __read_mostly; \ static bool __print_once __read_mostly; \
bool __ret_print_once = !__print_once; \
\ \
if (!__print_once) { \ if (!__print_once) { \
__print_once = true; \ __print_once = true; \
printk(fmt, ##__VA_ARGS__); \ printk(fmt, ##__VA_ARGS__); \
} \ } \
unlikely(__ret_print_once); \
}) })
#define printk_deferred_once(fmt, ...) \ #define printk_deferred_once(fmt, ...) \
({ \ ({ \
static bool __print_once __read_mostly; \ static bool __print_once __read_mostly; \
bool __ret_print_once = !__print_once; \
\ \
if (!__print_once) { \ if (!__print_once) { \
__print_once = true; \ __print_once = true; \
printk_deferred(fmt, ##__VA_ARGS__); \ printk_deferred(fmt, ##__VA_ARGS__); \
} \ } \
unlikely(__ret_print_once); \
}) })
#else #else
#define printk_once(fmt, ...) \ #define printk_once(fmt, ...) \
......
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