aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/process.c
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2021-02-03 00:02:06 +1100
committerMichael Ellerman <mpe@ellerman.id.au>2021-02-09 01:10:16 +1100
commit0ecf6a9e47d825b7dddfebca738386b809e59a94 (patch)
treee3074c3b0caa3e00e4f053caf4879296702319ca /arch/powerpc/kernel/process.c
parentpowerpc64/idle: Fix SP offsets when saving GPRs (diff)
downloadlinux-dev-0ecf6a9e47d825b7dddfebca738386b809e59a94.tar.xz
linux-dev-0ecf6a9e47d825b7dddfebca738386b809e59a94.zip
powerpc/64: Make stack tracing work during very early boot
If we try to stack trace very early during boot, either due to a WARN/BUG or manual dump_stack(), we will oops in valid_emergency_stack() when we try to dereference the paca_ptrs array. The fix is simple, we just return false if paca_ptrs isn't allocated yet. The stack pointer definitely isn't part of any emergency stack because we haven't allocated any yet. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20210202130207.1303975-1-mpe@ellerman.id.au
Diffstat (limited to 'arch/powerpc/kernel/process.c')
-rw-r--r--arch/powerpc/kernel/process.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 8520ed5ae144..e296440e9d16 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -2047,6 +2047,9 @@ static inline int valid_emergency_stack(unsigned long sp, struct task_struct *p,
unsigned long stack_page;
unsigned long cpu = task_cpu(p);
+ if (!paca_ptrs)
+ return 0;
+
stack_page = (unsigned long)paca_ptrs[cpu]->emergency_sp - THREAD_SIZE;
if (sp >= stack_page && sp <= stack_page + THREAD_SIZE - nbytes)
return 1;