powerpc: Fix kernel crash in show_instructions() w/DEBUG_VIRTUAL
With CONFIG_DEBUG_VIRTUAL=y, we can hit a BUG() if we take a hard
lockup watchdog interrupt when in OPAL mode.
This happens in show_instructions() if the kernel takes the watchdog
NMI IPI, or any other interrupt, with MSR_IR == 0. show_instructions()
updates the variable pc in the loop and the second iteration will
result in BUG().
We hit the BUG_ON due the below check in __va()
#define __va(x)
({
VIRTUAL_BUG_ON((unsigned long)(x) >= PAGE_OFFSET);
(void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET);
})
Fix it by moving the check out of the loop. Also update nip so that
the nip == pc check still matches.
Fixes: 4dd7554a64
("powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
[mpe: Use IS_ENABLED(), massage change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200524093822.423487-1-aneesh.kumar@linux.ibm.com
This commit is contained in:
parent
b3a9e3b962
commit
a6e2c226c3
|
@ -1252,29 +1252,31 @@ struct task_struct *__switch_to(struct task_struct *prev,
|
||||||
static void show_instructions(struct pt_regs *regs)
|
static void show_instructions(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
unsigned long nip = regs->nip;
|
||||||
unsigned long pc = regs->nip - (NR_INSN_TO_PRINT * 3 / 4 * sizeof(int));
|
unsigned long pc = regs->nip - (NR_INSN_TO_PRINT * 3 / 4 * sizeof(int));
|
||||||
|
|
||||||
printk("Instruction dump:");
|
printk("Instruction dump:");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we were executing with the MMU off for instructions, adjust pc
|
||||||
|
* rather than printing XXXXXXXX.
|
||||||
|
*/
|
||||||
|
if (!IS_ENABLED(CONFIG_BOOKE) && !(regs->msr & MSR_IR)) {
|
||||||
|
pc = (unsigned long)phys_to_virt(pc);
|
||||||
|
nip = (unsigned long)phys_to_virt(regs->nip);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < NR_INSN_TO_PRINT; i++) {
|
for (i = 0; i < NR_INSN_TO_PRINT; i++) {
|
||||||
int instr;
|
int instr;
|
||||||
|
|
||||||
if (!(i % 8))
|
if (!(i % 8))
|
||||||
pr_cont("\n");
|
pr_cont("\n");
|
||||||
|
|
||||||
#if !defined(CONFIG_BOOKE)
|
|
||||||
/* If executing with the IMMU off, adjust pc rather
|
|
||||||
* than print XXXXXXXX.
|
|
||||||
*/
|
|
||||||
if (!(regs->msr & MSR_IR))
|
|
||||||
pc = (unsigned long)phys_to_virt(pc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!__kernel_text_address(pc) ||
|
if (!__kernel_text_address(pc) ||
|
||||||
probe_kernel_address((const void *)pc, instr)) {
|
probe_kernel_address((const void *)pc, instr)) {
|
||||||
pr_cont("XXXXXXXX ");
|
pr_cont("XXXXXXXX ");
|
||||||
} else {
|
} else {
|
||||||
if (regs->nip == pc)
|
if (nip == pc)
|
||||||
pr_cont("<%08x> ", instr);
|
pr_cont("<%08x> ", instr);
|
||||||
else
|
else
|
||||||
pr_cont("%08x ", instr);
|
pr_cont("%08x ", instr);
|
||||||
|
|
Loading…
Reference in New Issue