aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/sysrq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/sysrq.c')
-rw-r--r--drivers/char/sysrq.c63
1 files changed, 25 insertions, 38 deletions
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 6b4d4d1e343d..5f49280779fb 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -35,14 +35,15 @@
35#include <linux/vt_kern.h> 35#include <linux/vt_kern.h>
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37#include <linux/kexec.h> 37#include <linux/kexec.h>
38#include <linux/irq.h>
38 39
39#include <asm/ptrace.h> 40#include <asm/ptrace.h>
41#include <asm/irq_regs.h>
40 42
41/* Whether we react on sysrq keys or just ignore them */ 43/* Whether we react on sysrq keys or just ignore them */
42int sysrq_enabled = 1; 44int sysrq_enabled = 1;
43 45
44static void sysrq_handle_loglevel(int key, struct pt_regs *pt_regs, 46static void sysrq_handle_loglevel(int key, struct tty_struct *tty)
45 struct tty_struct *tty)
46{ 47{
47 int i; 48 int i;
48 i = key - '0'; 49 i = key - '0';
@@ -58,8 +59,7 @@ static struct sysrq_key_op sysrq_loglevel_op = {
58}; 59};
59 60
60#ifdef CONFIG_VT 61#ifdef CONFIG_VT
61static void sysrq_handle_SAK(int key, struct pt_regs *pt_regs, 62static void sysrq_handle_SAK(int key, struct tty_struct *tty)
62 struct tty_struct *tty)
63{ 63{
64 if (tty) 64 if (tty)
65 do_SAK(tty); 65 do_SAK(tty);
@@ -76,8 +76,7 @@ static struct sysrq_key_op sysrq_SAK_op = {
76#endif 76#endif
77 77
78#ifdef CONFIG_VT 78#ifdef CONFIG_VT
79static void sysrq_handle_unraw(int key, struct pt_regs *pt_regs, 79static void sysrq_handle_unraw(int key, struct tty_struct *tty)
80 struct tty_struct *tty)
81{ 80{
82 struct kbd_struct *kbd = &kbd_table[fg_console]; 81 struct kbd_struct *kbd = &kbd_table[fg_console];
83 82
@@ -95,10 +94,9 @@ static struct sysrq_key_op sysrq_unraw_op = {
95#endif /* CONFIG_VT */ 94#endif /* CONFIG_VT */
96 95
97#ifdef CONFIG_KEXEC 96#ifdef CONFIG_KEXEC
98static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs, 97static void sysrq_handle_crashdump(int key, struct tty_struct *tty)
99 struct tty_struct *tty)
100{ 98{
101 crash_kexec(pt_regs); 99 crash_kexec(get_irq_regs());
102} 100}
103static struct sysrq_key_op sysrq_crashdump_op = { 101static struct sysrq_key_op sysrq_crashdump_op = {
104 .handler = sysrq_handle_crashdump, 102 .handler = sysrq_handle_crashdump,
@@ -110,8 +108,7 @@ static struct sysrq_key_op sysrq_crashdump_op = {
110#define sysrq_crashdump_op (*(struct sysrq_key_op *)0) 108#define sysrq_crashdump_op (*(struct sysrq_key_op *)0)
111#endif 109#endif
112 110
113static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, 111static void sysrq_handle_reboot(int key, struct tty_struct *tty)
114 struct tty_struct *tty)
115{ 112{
116 lockdep_off(); 113 lockdep_off();
117 local_irq_enable(); 114 local_irq_enable();
@@ -124,8 +121,7 @@ static struct sysrq_key_op sysrq_reboot_op = {
124 .enable_mask = SYSRQ_ENABLE_BOOT, 121 .enable_mask = SYSRQ_ENABLE_BOOT,
125}; 122};
126 123
127static void sysrq_handle_sync(int key, struct pt_regs *pt_regs, 124static void sysrq_handle_sync(int key, struct tty_struct *tty)
128 struct tty_struct *tty)
129{ 125{
130 emergency_sync(); 126 emergency_sync();
131} 127}
@@ -136,8 +132,7 @@ static struct sysrq_key_op sysrq_sync_op = {
136 .enable_mask = SYSRQ_ENABLE_SYNC, 132 .enable_mask = SYSRQ_ENABLE_SYNC,
137}; 133};
138 134
139static void sysrq_handle_mountro(int key, struct pt_regs *pt_regs, 135static void sysrq_handle_mountro(int key, struct tty_struct *tty)
140 struct tty_struct *tty)
141{ 136{
142 emergency_remount(); 137 emergency_remount();
143} 138}
@@ -149,8 +144,7 @@ static struct sysrq_key_op sysrq_mountro_op = {
149}; 144};
150 145
151#ifdef CONFIG_LOCKDEP 146#ifdef CONFIG_LOCKDEP
152static void sysrq_handle_showlocks(int key, struct pt_regs *pt_regs, 147static void sysrq_handle_showlocks(int key, struct tty_struct *tty)
153 struct tty_struct *tty)
154{ 148{
155 debug_show_all_locks(); 149 debug_show_all_locks();
156} 150}
@@ -164,11 +158,11 @@ static struct sysrq_key_op sysrq_showlocks_op = {
164#define sysrq_showlocks_op (*(struct sysrq_key_op *)0) 158#define sysrq_showlocks_op (*(struct sysrq_key_op *)0)
165#endif 159#endif
166 160
167static void sysrq_handle_showregs(int key, struct pt_regs *pt_regs, 161static void sysrq_handle_showregs(int key, struct tty_struct *tty)
168 struct tty_struct *tty)
169{ 162{
170 if (pt_regs) 163 struct pt_regs *regs = get_irq_regs();
171 show_regs(pt_regs); 164 if (regs)
165 show_regs(regs);
172} 166}
173static struct sysrq_key_op sysrq_showregs_op = { 167static struct sysrq_key_op sysrq_showregs_op = {
174 .handler = sysrq_handle_showregs, 168 .handler = sysrq_handle_showregs,
@@ -177,8 +171,7 @@ static struct sysrq_key_op sysrq_showregs_op = {
177 .enable_mask = SYSRQ_ENABLE_DUMP, 171 .enable_mask = SYSRQ_ENABLE_DUMP,
178}; 172};
179 173
180static void sysrq_handle_showstate(int key, struct pt_regs *pt_regs, 174static void sysrq_handle_showstate(int key, struct tty_struct *tty)
181 struct tty_struct *tty)
182{ 175{
183 show_state(); 176 show_state();
184} 177}
@@ -189,8 +182,7 @@ static struct sysrq_key_op sysrq_showstate_op = {
189 .enable_mask = SYSRQ_ENABLE_DUMP, 182 .enable_mask = SYSRQ_ENABLE_DUMP,
190}; 183};
191 184
192static void sysrq_handle_showmem(int key, struct pt_regs *pt_regs, 185static void sysrq_handle_showmem(int key, struct tty_struct *tty)
193 struct tty_struct *tty)
194{ 186{
195 show_mem(); 187 show_mem();
196} 188}
@@ -215,8 +207,7 @@ static void send_sig_all(int sig)
215 } 207 }
216} 208}
217 209
218static void sysrq_handle_term(int key, struct pt_regs *pt_regs, 210static void sysrq_handle_term(int key, struct tty_struct *tty)
219 struct tty_struct *tty)
220{ 211{
221 send_sig_all(SIGTERM); 212 send_sig_all(SIGTERM);
222 console_loglevel = 8; 213 console_loglevel = 8;
@@ -236,8 +227,7 @@ static void moom_callback(void *ignored)
236 227
237static DECLARE_WORK(moom_work, moom_callback, NULL); 228static DECLARE_WORK(moom_work, moom_callback, NULL);
238 229
239static void sysrq_handle_moom(int key, struct pt_regs *pt_regs, 230static void sysrq_handle_moom(int key, struct tty_struct *tty)
240 struct tty_struct *tty)
241{ 231{
242 schedule_work(&moom_work); 232 schedule_work(&moom_work);
243} 233}
@@ -247,8 +237,7 @@ static struct sysrq_key_op sysrq_moom_op = {
247 .action_msg = "Manual OOM execution", 237 .action_msg = "Manual OOM execution",
248}; 238};
249 239
250static void sysrq_handle_kill(int key, struct pt_regs *pt_regs, 240static void sysrq_handle_kill(int key, struct tty_struct *tty)
251 struct tty_struct *tty)
252{ 241{
253 send_sig_all(SIGKILL); 242 send_sig_all(SIGKILL);
254 console_loglevel = 8; 243 console_loglevel = 8;
@@ -260,8 +249,7 @@ static struct sysrq_key_op sysrq_kill_op = {
260 .enable_mask = SYSRQ_ENABLE_SIGNAL, 249 .enable_mask = SYSRQ_ENABLE_SIGNAL,
261}; 250};
262 251
263static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs, 252static void sysrq_handle_unrt(int key, struct tty_struct *tty)
264 struct tty_struct *tty)
265{ 253{
266 normalize_rt_tasks(); 254 normalize_rt_tasks();
267} 255}
@@ -361,8 +349,7 @@ static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
361 * This is the non-locking version of handle_sysrq. It must/can only be called 349 * This is the non-locking version of handle_sysrq. It must/can only be called
362 * by sysrq key handlers, as they are inside of the lock 350 * by sysrq key handlers, as they are inside of the lock
363 */ 351 */
364void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, 352void __handle_sysrq(int key, struct tty_struct *tty, int check_mask)
365 int check_mask)
366{ 353{
367 struct sysrq_key_op *op_p; 354 struct sysrq_key_op *op_p;
368 int orig_log_level; 355 int orig_log_level;
@@ -384,7 +371,7 @@ void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty,
384 (sysrq_enabled & op_p->enable_mask)) { 371 (sysrq_enabled & op_p->enable_mask)) {
385 printk("%s\n", op_p->action_msg); 372 printk("%s\n", op_p->action_msg);
386 console_loglevel = orig_log_level; 373 console_loglevel = orig_log_level;
387 op_p->handler(key, pt_regs, tty); 374 op_p->handler(key, tty);
388 } else { 375 } else {
389 printk("This sysrq operation is disabled.\n"); 376 printk("This sysrq operation is disabled.\n");
390 } 377 }
@@ -413,11 +400,11 @@ void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty,
413 * This function is called by the keyboard handler when SysRq is pressed 400 * This function is called by the keyboard handler when SysRq is pressed
414 * and any other keycode arrives. 401 * and any other keycode arrives.
415 */ 402 */
416void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) 403void handle_sysrq(int key, struct tty_struct *tty)
417{ 404{
418 if (!sysrq_enabled) 405 if (!sysrq_enabled)
419 return; 406 return;
420 __handle_sysrq(key, pt_regs, tty, 1); 407 __handle_sysrq(key, tty, 1);
421} 408}
422EXPORT_SYMBOL(handle_sysrq); 409EXPORT_SYMBOL(handle_sysrq);
423 410