]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/s390/kernel/dumpstack.c
2 * Stack dumping functions
4 * Copyright IBM Corp. 1999, 2013
7 #include <linux/kallsyms.h>
8 #include <linux/hardirq.h>
9 #include <linux/kprobes.h>
10 #include <linux/utsname.h>
11 #include <linux/export.h>
12 #include <linux/kdebug.h>
13 #include <linux/ptrace.h>
14 #include <linux/module.h>
15 #include <linux/sched.h>
16 #include <asm/processor.h>
17 #include <asm/debug.h>
22 * For show_trace we have tree different stack to consider:
23 * - the panic stack which is used if the kernel stack has overflown
24 * - the asynchronous interrupt stack (cpu related)
25 * - the synchronous kernel stack (process related)
26 * The stack trace can start at any of the three stack and can potentially
27 * touch all of them. The order is: panic stack, async stack, sync stack.
30 __show_trace(unsigned long sp
, unsigned long low
, unsigned long high
)
32 struct stack_frame
*sf
;
37 sp
= sp
& PSW_ADDR_INSN
;
38 if (sp
< low
|| sp
> high
- sizeof(*sf
))
40 sf
= (struct stack_frame
*) sp
;
41 addr
= sf
->gprs
[8] & PSW_ADDR_INSN
;
42 printk("([<%016lx>] %pSR)\n", addr
, (void *)addr
);
43 /* Follow the backchain. */
46 sp
= sf
->back_chain
& PSW_ADDR_INSN
;
49 if (sp
<= low
|| sp
> high
- sizeof(*sf
))
51 sf
= (struct stack_frame
*) sp
;
52 addr
= sf
->gprs
[8] & PSW_ADDR_INSN
;
53 printk(" [<%016lx>] %pSR\n", addr
, (void *)addr
);
55 /* Zero backchain detected, check for interrupt frame. */
56 sp
= (unsigned long) (sf
+ 1);
57 if (sp
<= low
|| sp
> high
- sizeof(*regs
))
59 regs
= (struct pt_regs
*) sp
;
60 addr
= regs
->psw
.addr
& PSW_ADDR_INSN
;
61 printk(" [<%016lx>] %pSR\n", addr
, (void *)addr
);
67 static void show_trace(struct task_struct
*task
, unsigned long *stack
)
69 const unsigned long frame_size
=
70 STACK_FRAME_OVERHEAD
+ sizeof(struct pt_regs
);
71 register unsigned long __r15
asm ("15");
74 sp
= (unsigned long) stack
;
76 sp
= task
? task
->thread
.ksp
: __r15
;
77 printk("Call Trace:\n");
78 #ifdef CONFIG_CHECK_STACK
80 S390_lowcore
.panic_stack
+ frame_size
- 4096,
81 S390_lowcore
.panic_stack
+ frame_size
);
84 S390_lowcore
.async_stack
+ frame_size
- ASYNC_SIZE
,
85 S390_lowcore
.async_stack
+ frame_size
);
87 __show_trace(sp
, (unsigned long) task_stack_page(task
),
88 (unsigned long) task_stack_page(task
) + THREAD_SIZE
);
90 __show_trace(sp
, S390_lowcore
.thread_info
,
91 S390_lowcore
.thread_info
+ THREAD_SIZE
);
94 debug_show_held_locks(task
);
97 void show_stack(struct task_struct
*task
, unsigned long *sp
)
99 register unsigned long *__r15
asm ("15");
100 unsigned long *stack
;
104 stack
= task
? (unsigned long *) task
->thread
.ksp
: __r15
;
108 for (i
= 0; i
< 20; i
++) {
109 if (((addr_t
) stack
& (THREAD_SIZE
-1)) == 0)
111 if ((i
* sizeof(long) % 32) == 0)
112 printk("%s ", i
== 0 ? "" : "\n");
113 printk("%016lx ", *stack
++);
116 show_trace(task
, sp
);
119 static void show_last_breaking_event(struct pt_regs
*regs
)
121 printk("Last Breaking-Event-Address:\n");
122 printk(" [<%016lx>] %pSR\n", regs
->args
[0], (void *)regs
->args
[0]);
125 static inline int mask_bits(struct pt_regs
*regs
, unsigned long bits
)
127 return (regs
->psw
.mask
& bits
) / ((~bits
+ 1) & bits
);
130 void show_registers(struct pt_regs
*regs
)
134 mode
= user_mode(regs
) ? "User" : "Krnl";
135 printk("%s PSW : %p %p", mode
, (void *)regs
->psw
.mask
, (void *)regs
->psw
.addr
);
136 if (!user_mode(regs
))
137 printk(" (%pSR)", (void *)regs
->psw
.addr
);
139 printk(" R:%x T:%x IO:%x EX:%x Key:%x M:%x W:%x "
140 "P:%x AS:%x CC:%x PM:%x", mask_bits(regs
, PSW_MASK_PER
),
141 mask_bits(regs
, PSW_MASK_DAT
), mask_bits(regs
, PSW_MASK_IO
),
142 mask_bits(regs
, PSW_MASK_EXT
), mask_bits(regs
, PSW_MASK_KEY
),
143 mask_bits(regs
, PSW_MASK_MCHECK
), mask_bits(regs
, PSW_MASK_WAIT
),
144 mask_bits(regs
, PSW_MASK_PSTATE
), mask_bits(regs
, PSW_MASK_ASC
),
145 mask_bits(regs
, PSW_MASK_CC
), mask_bits(regs
, PSW_MASK_PM
));
146 printk(" EA:%x", mask_bits(regs
, PSW_MASK_EA
| PSW_MASK_BA
));
147 printk("\n%s GPRS: %016lx %016lx %016lx %016lx\n", mode
,
148 regs
->gprs
[0], regs
->gprs
[1], regs
->gprs
[2], regs
->gprs
[3]);
149 printk(" %016lx %016lx %016lx %016lx\n",
150 regs
->gprs
[4], regs
->gprs
[5], regs
->gprs
[6], regs
->gprs
[7]);
151 printk(" %016lx %016lx %016lx %016lx\n",
152 regs
->gprs
[8], regs
->gprs
[9], regs
->gprs
[10], regs
->gprs
[11]);
153 printk(" %016lx %016lx %016lx %016lx\n",
154 regs
->gprs
[12], regs
->gprs
[13], regs
->gprs
[14], regs
->gprs
[15]);
158 void show_regs(struct pt_regs
*regs
)
160 show_regs_print_info(KERN_DEFAULT
);
161 show_registers(regs
);
162 /* Show stack backtrace if pt_regs is from kernel mode */
163 if (!user_mode(regs
))
164 show_trace(NULL
, (unsigned long *) regs
->gprs
[15]);
165 show_last_breaking_event(regs
);
168 static DEFINE_SPINLOCK(die_lock
);
170 void die(struct pt_regs
*regs
, const char *str
)
172 static int die_counter
;
178 spin_lock_irq(&die_lock
);
180 printk("%s: %04x ilc:%d [#%d] ", str
, regs
->int_code
& 0xffff,
181 regs
->int_code
>> 17, ++die_counter
);
182 #ifdef CONFIG_PREEMPT
188 #ifdef CONFIG_DEBUG_PAGEALLOC
189 printk("DEBUG_PAGEALLOC");
192 notify_die(DIE_OOPS
, str
, regs
, 0, regs
->int_code
& 0xffff, SIGSEGV
);
196 add_taint(TAINT_DIE
, LOCKDEP_NOW_UNRELIABLE
);
197 spin_unlock_irq(&die_lock
);
199 panic("Fatal exception in interrupt");
201 panic("Fatal exception: panic_on_oops");