Skip to content

Commit 7ea5571

Browse files
committed
arm64: efi: Account for the EFI runtime stack in stack unwinder
The EFI runtime services run from a dedicated stack now, and so the stack unwinder needs to be informed about this. Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 8a9a1a1 commit 7ea5571

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

arch/arm64/include/asm/stacktrace.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,19 @@ static inline struct stack_info stackinfo_get_sdei_critical(void)
106106
#define stackinfo_get_sdei_critical() stackinfo_get_unknown()
107107
#endif
108108

109+
#ifdef CONFIG_EFI
110+
extern u64 *efi_rt_stack_top;
111+
112+
static inline struct stack_info stackinfo_get_efi(void)
113+
{
114+
unsigned long high = (u64)efi_rt_stack_top;
115+
unsigned long low = high - THREAD_SIZE;
116+
117+
return (struct stack_info) {
118+
.low = low,
119+
.high = high,
120+
};
121+
}
122+
#endif
123+
109124
#endif /* __ASM_STACKTRACE_H */

arch/arm64/kernel/stacktrace.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
* Copyright (C) 2012 ARM Ltd.
66
*/
77
#include <linux/kernel.h>
8+
#include <linux/efi.h>
89
#include <linux/export.h>
910
#include <linux/ftrace.h>
1011
#include <linux/sched.h>
1112
#include <linux/sched/debug.h>
1213
#include <linux/sched/task_stack.h>
1314
#include <linux/stacktrace.h>
1415

16+
#include <asm/efi.h>
1517
#include <asm/irq.h>
1618
#include <asm/stack_pointer.h>
1719
#include <asm/stacktrace.h>
@@ -186,6 +188,13 @@ void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
186188
: stackinfo_get_unknown(); \
187189
})
188190

191+
#define STACKINFO_EFI \
192+
({ \
193+
((task == current) && current_in_efi()) \
194+
? stackinfo_get_efi() \
195+
: stackinfo_get_unknown(); \
196+
})
197+
189198
noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry,
190199
void *cookie, struct task_struct *task,
191200
struct pt_regs *regs)
@@ -199,6 +208,9 @@ noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry,
199208
#if defined(CONFIG_VMAP_STACK) && defined(CONFIG_ARM_SDE_INTERFACE)
200209
STACKINFO_SDEI(normal),
201210
STACKINFO_SDEI(critical),
211+
#endif
212+
#ifdef CONFIG_EFI
213+
STACKINFO_EFI,
202214
#endif
203215
};
204216
struct unwind_state state = {

0 commit comments

Comments
 (0)