Skip to content

Commit 7290f3b

Browse files
npigginmpe
authored andcommitted
powerpc/64s/powernv: machine check dump SLB contents
Re-use the code introduced in pseries to save and dump the contents of the SLB in the case of an SLB involved machine check exception. This patch also avoids allocating the SLB save array on pseries radix. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0b66370 commit 7290f3b

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

arch/powerpc/kernel/mce.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,12 @@ void machine_check_print_event_info(struct machine_check_event *evt,
511511
subtype = evt->error_class < ARRAY_SIZE(mc_error_class) ?
512512
mc_error_class[evt->error_class] : "Unknown";
513513
printk("%sMCE: CPU%d: %s\n", level, evt->cpu, subtype);
514+
515+
#ifdef CONFIG_PPC_BOOK3S_64
516+
/* Display faulty slb contents for SLB errors. */
517+
if (evt->error_type == MCE_ERROR_TYPE_SLB)
518+
slb_dump_contents(local_paca->mce_faulty_slbs);
519+
#endif
514520
}
515521
EXPORT_SYMBOL_GPL(machine_check_print_event_info);
516522

arch/powerpc/kernel/mce_power.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ static int mce_handle_ierror(struct pt_regs *regs,
405405
/* attempt to correct the error */
406406
switch (table[i].error_type) {
407407
case MCE_ERROR_TYPE_SLB:
408+
if (local_paca->in_mce == 1)
409+
slb_save_contents(local_paca->mce_faulty_slbs);
408410
handled = mce_flush(MCE_FLUSH_SLB);
409411
break;
410412
case MCE_ERROR_TYPE_ERAT:
@@ -490,6 +492,8 @@ static int mce_handle_derror(struct pt_regs *regs,
490492
/* attempt to correct the error */
491493
switch (table[i].error_type) {
492494
case MCE_ERROR_TYPE_SLB:
495+
if (local_paca->in_mce == 1)
496+
slb_save_contents(local_paca->mce_faulty_slbs);
493497
if (mce_flush(MCE_FLUSH_SLB))
494498
handled = 1;
495499
break;

arch/powerpc/platforms/powernv/setup.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/bug.h>
2525
#include <linux/pci.h>
2626
#include <linux/cpufreq.h>
27+
#include <linux/memblock.h>
2728

2829
#include <asm/machdep.h>
2930
#include <asm/firmware.h>
@@ -166,6 +167,14 @@ static void __init pnv_init(void)
166167
else
167168
#endif
168169
add_preferred_console("hvc", 0, NULL);
170+
171+
if (!radix_enabled()) {
172+
int i;
173+
174+
/* Allocate per cpu area to save old slb contents during MCE */
175+
for_each_possible_cpu(i)
176+
paca_ptrs[i]->mce_faulty_slbs = memblock_alloc_node(mmu_slb_size, __alignof__(*paca_ptrs[i]->mce_faulty_slbs), cpu_to_node(i));
177+
}
169178
}
170179

171180
static void __init pnv_init_IRQ(void)

arch/powerpc/platforms/pseries/setup.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,19 @@ static void __init fwnmi_init(void)
142142
}
143143

144144
#ifdef CONFIG_PPC_BOOK3S_64
145-
/* Allocate per cpu slb area to save old slb contents during MCE */
146-
size = sizeof(struct slb_entry) * mmu_slb_size * nr_cpus;
147-
slb_ptr = memblock_alloc_try_nid_raw(size, sizeof(struct slb_entry),
148-
MEMBLOCK_LOW_LIMIT, ppc64_rma_size,
149-
NUMA_NO_NODE);
150-
if (!slb_ptr)
151-
panic("Failed to allocate %zu bytes below %pa for slb area\n",
152-
size, &ppc64_rma_size);
153-
154-
for_each_possible_cpu(i)
155-
paca_ptrs[i]->mce_faulty_slbs = slb_ptr + (mmu_slb_size * i);
145+
if (!radix_enabled()) {
146+
/* Allocate per cpu area to save old slb contents during MCE */
147+
size = sizeof(struct slb_entry) * mmu_slb_size * nr_cpus;
148+
slb_ptr = memblock_alloc_try_nid_raw(size,
149+
sizeof(struct slb_entry), MEMBLOCK_LOW_LIMIT,
150+
ppc64_rma_size, NUMA_NO_NODE);
151+
if (!slb_ptr)
152+
panic("Failed to allocate %zu bytes below %pa for slb area\n",
153+
size, &ppc64_rma_size);
154+
155+
for_each_possible_cpu(i)
156+
paca_ptrs[i]->mce_faulty_slbs = slb_ptr + (mmu_slb_size * i);
157+
}
156158
#endif
157159
}
158160

0 commit comments

Comments
 (0)