2017-10-29 01:48:53 -04:00
|
|
|
diff --git a/drivers/staging/android/fiq_debugger/fiq_debugger.c b/drivers/staging/android/fiq_debugger/fiq_debugger.c
|
2017-10-29 22:14:37 -04:00
|
|
|
index 1d73362..ceb45bc9e 100644
|
2017-10-29 01:48:53 -04:00
|
|
|
--- a/drivers/staging/android/fiq_debugger/fiq_debugger.c
|
|
|
|
+++ b/drivers/staging/android/fiq_debugger/fiq_debugger.c
|
|
|
|
@@ -30,6 +30,7 @@
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
+#include <linux/sysrq.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/tty_flip.h>
|
2017-10-29 22:14:37 -04:00
|
|
|
@@ -395,7 +396,7 @@
|
2017-10-29 01:48:53 -04:00
|
|
|
cmd += 6;
|
|
|
|
while (*cmd == ' ')
|
|
|
|
cmd++;
|
|
|
|
- if (cmd != '\0')
|
|
|
|
+ if ((cmd != '\0') && sysrq_on())
|
|
|
|
kernel_restart(cmd);
|
|
|
|
else
|
|
|
|
kernel_restart(NULL);
|
2017-10-29 22:14:37 -04:00
|
|
|
@@ -425,30 +426,39 @@
|
2017-10-29 01:48:53 -04:00
|
|
|
static void fiq_debugger_help(struct fiq_debugger_state *state)
|
|
|
|
{
|
|
|
|
fiq_debugger_printf(&state->output,
|
|
|
|
- "FIQ Debugger commands:\n"
|
|
|
|
- " pc PC status\n"
|
|
|
|
- " regs Register dump\n"
|
|
|
|
- " allregs Extended Register dump\n"
|
2017-10-29 22:14:37 -04:00
|
|
|
- " bt Stack trace\n");
|
2017-10-29 01:48:53 -04:00
|
|
|
+ "FIQ Debugger commands:\n");
|
|
|
|
+ if (sysrq_on()) {
|
|
|
|
+ fiq_debugger_printf(&state->output,
|
|
|
|
+ " pc PC status\n"
|
|
|
|
+ " regs Register dump\n"
|
|
|
|
+ " allregs Extended Register dump\n"
|
|
|
|
+ " bt Stack trace\n");
|
|
|
|
+ fiq_debugger_printf(&state->output,
|
|
|
|
+ " reboot [<c>] Reboot with command <c>\n"
|
|
|
|
+ " reset [<c>] Hard reset with command <c>\n"
|
|
|
|
+ " irqs Interrupt status\n"
|
|
|
|
+ " kmsg Kernel log\n"
|
|
|
|
+ " version Kernel version\n");
|
|
|
|
+ fiq_debugger_printf(&state->output,
|
|
|
|
+ " cpu Current CPU\n"
|
|
|
|
+ " cpu <number> Switch to CPU<number>\n"
|
|
|
|
+ " sysrq sysrq options\n"
|
|
|
|
+ " sysrq <param> Execute sysrq with <param>\n");
|
|
|
|
+ } else {
|
|
|
|
+ fiq_debugger_printf(&state->output,
|
|
|
|
+ " reboot Reboot\n"
|
|
|
|
+ " reset Hard reset\n"
|
|
|
|
+ " irqs Interrupt status\n");
|
|
|
|
+ }
|
|
|
|
fiq_debugger_printf(&state->output,
|
2017-10-29 22:14:37 -04:00
|
|
|
- " reboot [<c>] Reboot with command <c>\n"
|
|
|
|
- " reset [<c>] Hard reset with command <c>\n"
|
|
|
|
- " irqs Interupt status\n"
|
|
|
|
- " kmsg Kernel log\n"
|
|
|
|
- " version Kernel version\n");
|
|
|
|
- fiq_debugger_printf(&state->output,
|
|
|
|
- " sleep Allow sleep while in FIQ\n"
|
|
|
|
- " nosleep Disable sleep while in FIQ\n"
|
|
|
|
- " console Switch terminal to console\n"
|
|
|
|
- " cpu Current CPU\n"
|
|
|
|
- " cpu <number> Switch to CPU<number>\n");
|
|
|
|
- fiq_debugger_printf(&state->output,
|
2017-10-29 01:48:53 -04:00
|
|
|
- " ps Process list\n"
|
|
|
|
- " sysrq sysrq options\n"
|
|
|
|
- " sysrq <param> Execute sysrq with <param>\n");
|
|
|
|
+ " sleep Allow sleep while in FIQ\n"
|
|
|
|
+ " nosleep Disable sleep while in FIQ\n"
|
|
|
|
+ " console Switch terminal to console\n"
|
|
|
|
+ " ps Process list\n");
|
|
|
|
#ifdef CONFIG_KGDB
|
|
|
|
- fiq_debugger_printf(&state->output,
|
|
|
|
- " kgdb Enter kernel debugger\n");
|
|
|
|
+ if (fiq_kgdb_enable) {
|
|
|
|
+ fiq_debugger_printf(&state->output,
|
|
|
|
+ " kgdb Enter kernel debugger\n");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-10-29 22:14:37 -04:00
|
|
|
@@ -480,18 +490,23 @@
|
2017-10-29 01:48:53 -04:00
|
|
|
if (!strcmp(cmd, "help") || !strcmp(cmd, "?")) {
|
|
|
|
fiq_debugger_help(state);
|
|
|
|
} else if (!strcmp(cmd, "pc")) {
|
|
|
|
- fiq_debugger_dump_pc(&state->output, regs);
|
|
|
|
+ if (sysrq_on())
|
|
|
|
+ fiq_debugger_dump_pc(&state->output, regs);
|
|
|
|
} else if (!strcmp(cmd, "regs")) {
|
|
|
|
- fiq_debugger_dump_regs(&state->output, regs);
|
|
|
|
+ if (sysrq_on())
|
|
|
|
+ fiq_debugger_dump_regs(&state->output, regs);
|
|
|
|
} else if (!strcmp(cmd, "allregs")) {
|
|
|
|
- fiq_debugger_dump_allregs(&state->output, regs);
|
|
|
|
+ if (sysrq_on())
|
|
|
|
+ fiq_debugger_dump_allregs(&state->output, regs);
|
|
|
|
} else if (!strcmp(cmd, "bt")) {
|
|
|
|
- fiq_debugger_dump_stacktrace(&state->output, regs, 100, svc_sp);
|
|
|
|
+ if (sysrq_on())
|
|
|
|
+ fiq_debugger_dump_stacktrace(&state->output, regs,
|
|
|
|
+ 100, svc_sp);
|
|
|
|
} else if (!strncmp(cmd, "reset", 5)) {
|
|
|
|
cmd += 5;
|
|
|
|
while (*cmd == ' ')
|
|
|
|
cmd++;
|
|
|
|
- if (*cmd) {
|
|
|
|
+ if (*cmd && sysrq_on()) {
|
|
|
|
char tmp_cmd[32];
|
|
|
|
strlcpy(tmp_cmd, cmd, sizeof(tmp_cmd));
|
|
|
|
machine_restart(tmp_cmd);
|
2017-10-29 22:14:37 -04:00
|
|
|
@@ -501,9 +516,12 @@
|
2017-10-29 01:48:53 -04:00
|
|
|
} else if (!strcmp(cmd, "irqs")) {
|
|
|
|
fiq_debugger_dump_irqs(state);
|
|
|
|
} else if (!strcmp(cmd, "kmsg")) {
|
|
|
|
- fiq_debugger_dump_kernel_log(state);
|
|
|
|
+ if (sysrq_on())
|
|
|
|
+ fiq_debugger_dump_kernel_log(state);
|
|
|
|
} else if (!strcmp(cmd, "version")) {
|
|
|
|
- fiq_debugger_printf(&state->output, "%s\n", linux_banner);
|
|
|
|
+ if (sysrq_on())
|
|
|
|
+ fiq_debugger_printf(&state->output, "%s\n",
|
|
|
|
+ linux_banner);
|
|
|
|
} else if (!strcmp(cmd, "sleep")) {
|
|
|
|
state->no_sleep = false;
|
|
|
|
fiq_debugger_printf(&state->output, "enabling sleep\n");
|
2017-10-29 22:14:37 -04:00
|
|
|
@@ -515,14 +533,17 @@
|
2017-10-29 01:48:53 -04:00
|
|
|
fiq_debugger_uart_flush(state);
|
|
|
|
state->console_enable = true;
|
|
|
|
} else if (!strcmp(cmd, "cpu")) {
|
|
|
|
- fiq_debugger_printf(&state->output, "cpu %d\n", state->current_cpu);
|
|
|
|
- } else if (!strncmp(cmd, "cpu ", 4)) {
|
|
|
|
+ if (sysrq_on())
|
|
|
|
+ fiq_debugger_printf(&state->output, "cpu %d\n",
|
|
|
|
+ state->current_cpu);
|
|
|
|
+ } else if (!strncmp(cmd, "cpu ", 4) && sysrq_on()) {
|
|
|
|
unsigned long cpu = 0;
|
|
|
|
if (strict_strtoul(cmd + 4, 10, &cpu) == 0)
|
|
|
|
fiq_debugger_switch_cpu(state, cpu);
|
|
|
|
else
|
|
|
|
fiq_debugger_printf(&state->output, "invalid cpu\n");
|
|
|
|
- fiq_debugger_printf(&state->output, "cpu %d\n", state->current_cpu);
|
|
|
|
+ fiq_debugger_printf(&state->output, "cpu %d\n",
|
|
|
|
+ state->current_cpu);
|
|
|
|
} else {
|
|
|
|
if (state->debug_busy) {
|
|
|
|
fiq_debugger_printf(&state->output,
|
|
|
|
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
|
|
|
|
index b51c154..08c9406 100644
|
|
|
|
--- a/drivers/tty/sysrq.c
|
|
|
|
+++ b/drivers/tty/sysrq.c
|
2017-10-29 22:14:37 -04:00
|
|
|
@@ -55,10 +55,11 @@
|
2017-10-29 01:48:53 -04:00
|
|
|
unsigned short platform_sysrq_reset_seq[] __weak = { KEY_RESERVED };
|
|
|
|
int sysrq_reset_downtime_ms __weak;
|
|
|
|
|
|
|
|
-static bool sysrq_on(void)
|
|
|
|
+bool sysrq_on(void)
|
|
|
|
{
|
|
|
|
return sysrq_enabled || sysrq_always_enabled;
|
|
|
|
}
|
|
|
|
+EXPORT_SYMBOL(sysrq_on);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A value of 1 means 'all', other nonzero values are an op mask:
|
|
|
|
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
|
|
|
|
index 7faf933..5a0bd93 100644
|
|
|
|
--- a/include/linux/sysrq.h
|
|
|
|
+++ b/include/linux/sysrq.h
|
2017-10-29 22:14:37 -04:00
|
|
|
@@ -45,6 +45,7 @@
|
2017-10-29 01:48:53 -04:00
|
|
|
* are available -- else NULL's).
|
|
|
|
*/
|
|
|
|
|
|
|
|
+bool sysrq_on(void);
|
|
|
|
void handle_sysrq(int key);
|
|
|
|
void __handle_sysrq(int key, bool check_mask);
|
|
|
|
int register_sysrq_key(int key, struct sysrq_key_op *op);
|