Commit 3818c29a authored by Douglas Anderson's avatar Douglas Anderson Committed by Greg Kroah-Hartman

kdb: Don't back trace on a cpu that didn't round up

[ Upstream commit 162bc7f5 ]

If you have a CPU that fails to round up and then run 'btc' you'll end
up crashing in kdb becaue we dereferenced NULL.  Let's add a check.
It's wise to also set the task to NULL when leaving the debugger so
that if we fail to round up on a later entry into the debugger we
won't backtrace a stale task.
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Acked-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 6a7c0215
...@@ -535,6 +535,8 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, ...@@ -535,6 +535,8 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs,
arch_kgdb_ops.correct_hw_break(); arch_kgdb_ops.correct_hw_break();
if (trace_on) if (trace_on)
tracing_on(); tracing_on();
kgdb_info[cpu].debuggerinfo = NULL;
kgdb_info[cpu].task = NULL;
kgdb_info[cpu].exception_state &= kgdb_info[cpu].exception_state &=
~(DCPU_WANT_MASTER | DCPU_IS_SLAVE); ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE);
kgdb_info[cpu].enter_kgdb--; kgdb_info[cpu].enter_kgdb--;
...@@ -667,6 +669,8 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, ...@@ -667,6 +669,8 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs,
if (trace_on) if (trace_on)
tracing_on(); tracing_on();
kgdb_info[cpu].debuggerinfo = NULL;
kgdb_info[cpu].task = NULL;
kgdb_info[cpu].exception_state &= kgdb_info[cpu].exception_state &=
~(DCPU_WANT_MASTER | DCPU_IS_SLAVE); ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE);
kgdb_info[cpu].enter_kgdb--; kgdb_info[cpu].enter_kgdb--;
......
...@@ -186,7 +186,16 @@ kdb_bt(int argc, const char **argv) ...@@ -186,7 +186,16 @@ kdb_bt(int argc, const char **argv)
kdb_printf("btc: cpu status: "); kdb_printf("btc: cpu status: ");
kdb_parse("cpu\n"); kdb_parse("cpu\n");
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu)); void *kdb_tsk = KDB_TSK(cpu);
/* If a CPU failed to round up we could be here */
if (!kdb_tsk) {
kdb_printf("WARNING: no task for cpu %ld\n",
cpu);
continue;
}
sprintf(buf, "btt 0x%px\n", kdb_tsk);
kdb_parse(buf); kdb_parse(buf);
touch_nmi_watchdog(); touch_nmi_watchdog();
} }
......
...@@ -118,13 +118,6 @@ int kdb_stub(struct kgdb_state *ks) ...@@ -118,13 +118,6 @@ int kdb_stub(struct kgdb_state *ks)
kdb_bp_remove(); kdb_bp_remove();
KDB_STATE_CLEAR(DOING_SS); KDB_STATE_CLEAR(DOING_SS);
KDB_STATE_SET(PAGER); KDB_STATE_SET(PAGER);
/* zero out any offline cpu data */
for_each_present_cpu(i) {
if (!cpu_online(i)) {
kgdb_info[i].debuggerinfo = NULL;
kgdb_info[i].task = NULL;
}
}
if (ks->err_code == DIE_OOPS || reason == KDB_REASON_OOPS) { if (ks->err_code == DIE_OOPS || reason == KDB_REASON_OOPS) {
ks->pass_exception = 1; ks->pass_exception = 1;
KDB_FLAG_SET(CATASTROPHIC); KDB_FLAG_SET(CATASTROPHIC);
......
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