aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>2013-10-30 10:34:00 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-12-05 00:02:05 -0500
commit729b0f715371ce1e7636b4958fc45d6882442456 (patch)
tree10563ebf4b7536a781eef24ce2e09025f519d275
parentb14a7253cf999412e5a0dd39d58b0a42d19fd73a (diff)
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: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Acked-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/include/asm/paca.h9
-rw-r--r--arch/powerpc/kernel/setup_64.c10
-rw-r--r--arch/powerpc/xmon/xmon.c4
3 files changed, 22 insertions, 1 deletions
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index b6ea9e068c13..c3523d1dda58 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -152,6 +152,15 @@ struct paca_struct {
152 */ 152 */
153 struct opal_machine_check_event *opal_mc_evt; 153 struct opal_machine_check_event *opal_mc_evt;
154#endif 154#endif
155#ifdef CONFIG_PPC_BOOK3S_64
156 /* Exclusive emergency stack pointer for machine check exception. */
157 void *mc_emergency_sp;
158 /*
159 * Flag to check whether we are in machine check early handler
160 * and already using emergency stack.
161 */
162 u16 in_mce;
163#endif
155 164
156 /* Stuff for accurate time accounting */ 165 /* Stuff for accurate time accounting */
157 u64 user_time; /* accumulated usermode TB ticks */ 166 u64 user_time; /* accumulated usermode TB ticks */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 5760b9bea936..2232aff66059 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -540,7 +540,8 @@ static void __init exc_lvl_early_init(void)
540 540
541/* 541/*
542 * Stack space used when we detect a bad kernel stack pointer, and 542 * Stack space used when we detect a bad kernel stack pointer, and
543 * early in SMP boots before relocation is enabled. 543 * early in SMP boots before relocation is enabled. Exclusive emergency
544 * stack for machine checks.
544 */ 545 */
545static void __init emergency_stack_init(void) 546static void __init emergency_stack_init(void)
546{ 547{
@@ -563,6 +564,13 @@ static void __init emergency_stack_init(void)
563 sp = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit); 564 sp = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit);
564 sp += THREAD_SIZE; 565 sp += THREAD_SIZE;
565 paca[i].emergency_sp = __va(sp); 566 paca[i].emergency_sp = __va(sp);
567
568#ifdef CONFIG_PPC_BOOK3S_64
569 /* emergency stack for machine check exception handling. */
570 sp = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit);
571 sp += THREAD_SIZE;
572 paca[i].mc_emergency_sp = __va(sp);
573#endif
566 } 574 }
567} 575}
568 576
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index af9d3469fb99..a90731b3d44a 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2051,6 +2051,10 @@ static void dump_one_paca(int cpu)
2051 DUMP(p, stab_addr, "lx"); 2051 DUMP(p, stab_addr, "lx");
2052#endif 2052#endif
2053 DUMP(p, emergency_sp, "p"); 2053 DUMP(p, emergency_sp, "p");
2054#ifdef CONFIG_PPC_BOOK3S_64
2055 DUMP(p, mc_emergency_sp, "p");
2056 DUMP(p, in_mce, "x");
2057#endif
2054 DUMP(p, data_offset, "lx"); 2058 DUMP(p, data_offset, "lx");
2055 DUMP(p, hw_cpu_id, "x"); 2059 DUMP(p, hw_cpu_id, "x");
2056 DUMP(p, cpu_start, "x"); 2060 DUMP(p, cpu_start, "x");