Commit 729b0f71 authored by Mahesh Salgaonkar's avatar Mahesh Salgaonkar Committed by Benjamin Herrenschmidt

powerpc/book3s: Introduce exclusive emergency stack for machine check exception.

This patch introduces exclusive emergency stack for machine check exception.
We use emergency stack to handle machine check exception so that we can save
MCE information (srr1, srr0, dar and dsisr) before turning on ME bit and be
ready for re-entrancy. This helps us to prevent clobbering of MCE information
in case of nested machine checks.

The reason for using emergency stack over normal kernel stack is that the
machine check might occur in the middle of setting up a stack frame which may
result into improper use of kernel stack.
Signed-off-by: default avatarMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Acked-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent b14a7253
...@@ -152,6 +152,15 @@ struct paca_struct { ...@@ -152,6 +152,15 @@ struct paca_struct {
*/ */
struct opal_machine_check_event *opal_mc_evt; struct opal_machine_check_event *opal_mc_evt;
#endif #endif
#ifdef CONFIG_PPC_BOOK3S_64
/* Exclusive emergency stack pointer for machine check exception. */
void *mc_emergency_sp;
/*
* Flag to check whether we are in machine check early handler
* and already using emergency stack.
*/
u16 in_mce;
#endif
/* Stuff for accurate time accounting */ /* Stuff for accurate time accounting */
u64 user_time; /* accumulated usermode TB ticks */ u64 user_time; /* accumulated usermode TB ticks */
......
...@@ -540,7 +540,8 @@ static void __init exc_lvl_early_init(void) ...@@ -540,7 +540,8 @@ static void __init exc_lvl_early_init(void)
/* /*
* Stack space used when we detect a bad kernel stack pointer, and * Stack space used when we detect a bad kernel stack pointer, and
* early in SMP boots before relocation is enabled. * early in SMP boots before relocation is enabled. Exclusive emergency
* stack for machine checks.
*/ */
static void __init emergency_stack_init(void) static void __init emergency_stack_init(void)
{ {
...@@ -563,6 +564,13 @@ static void __init emergency_stack_init(void) ...@@ -563,6 +564,13 @@ static void __init emergency_stack_init(void)
sp = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit); sp = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit);
sp += THREAD_SIZE; sp += THREAD_SIZE;
paca[i].emergency_sp = __va(sp); paca[i].emergency_sp = __va(sp);
#ifdef CONFIG_PPC_BOOK3S_64
/* emergency stack for machine check exception handling. */
sp = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit);
sp += THREAD_SIZE;
paca[i].mc_emergency_sp = __va(sp);
#endif
} }
} }
......
...@@ -2051,6 +2051,10 @@ static void dump_one_paca(int cpu) ...@@ -2051,6 +2051,10 @@ static void dump_one_paca(int cpu)
DUMP(p, stab_addr, "lx"); DUMP(p, stab_addr, "lx");
#endif #endif
DUMP(p, emergency_sp, "p"); DUMP(p, emergency_sp, "p");
#ifdef CONFIG_PPC_BOOK3S_64
DUMP(p, mc_emergency_sp, "p");
DUMP(p, in_mce, "x");
#endif
DUMP(p, data_offset, "lx"); DUMP(p, data_offset, "lx");
DUMP(p, hw_cpu_id, "x"); DUMP(p, hw_cpu_id, "x");
DUMP(p, cpu_start, "x"); DUMP(p, cpu_start, "x");
......
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