aboutsummaryrefslogtreecommitdiff
path: root/core/cpu.c
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2018-04-08 16:49:38 +1000
committerStewart Smith <stewart@linux.ibm.com>2018-04-18 20:23:07 -0500
commit3fdd2629516dd8be2b52a3a13e7ef5713411c7bf (patch)
tree5001a42b2b3d17fa03500ca97849c658715a1c6e /core/cpu.c
parent8514e4dc9a82f3ff85d40138f2c8e8a1dc64efa4 (diff)
downloadskiboot-3fdd2629516dd8be2b52a3a13e7ef5713411c7bf.zip
skiboot-3fdd2629516dd8be2b52a3a13e7ef5713411c7bf.tar.gz
skiboot-3fdd2629516dd8be2b52a3a13e7ef5713411c7bf.tar.bz2
core/opal: Emergency stack for re-entry
This detects OPAL being re-entered by the OS, and switches to an emergency stack if it was. This protects the firmware's main stack from re-entrancy and allows the OS to use NMI facilities for crash / debug functionality. Further nested re-entry will destroy the previous emergency stack and prevent returning, but those should be rare cases. This stack is sized at 16kB, which doubles the size of CPU stacks, so as not to introduce a regression in primary stack size. The 16kB stack originally had a 4kB machine check stack at the top, which was removed by 80eee1946 ("opal: Remove machine check interrupt patching in OPAL."). So it is possible the size could be tightened again, but that would require further analysis. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'core/cpu.c')
-rw-r--r--core/cpu.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/core/cpu.c b/core/cpu.c
index b8d31e2..b2eecda 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -79,15 +79,18 @@ unsigned long __attrconst cpu_stack_bottom(unsigned int pir)
unsigned long __attrconst cpu_stack_top(unsigned int pir)
{
- /* This is the top of the MC stack which is above the normal
- * stack, which means a SP between cpu_stack_bottom() and
- * cpu_stack_top() can either be a normal stack pointer or
- * a Machine Check stack pointer
- */
+ /* This is the top of the normal stack. */
return ((unsigned long)&cpu_stacks[pir]) +
NORMAL_STACK_SIZE - STACK_TOP_GAP;
}
+unsigned long __attrconst cpu_emergency_stack_top(unsigned int pir)
+{
+ /* This is the top of the emergency stack, above the normal stack. */
+ return ((unsigned long)&cpu_stacks[pir]) +
+ NORMAL_STACK_SIZE + EMERGENCY_STACK_SIZE - STACK_TOP_GAP;
+}
+
static void cpu_wake(struct cpu_thread *cpu)
{
/* Is it idle ? If not, no need to wake */