2019-06-03 07:44:50 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2012-03-05 11:49:27 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
|
|
|
*/
|
|
|
|
|
#ifndef __ASM_STACKTRACE_H
|
|
|
|
|
#define __ASM_STACKTRACE_H
|
|
|
|
|
|
2017-07-20 12:26:48 +01:00
|
|
|
#include <linux/percpu.h>
|
|
|
|
|
#include <linux/sched.h>
|
|
|
|
|
#include <linux/sched/task_stack.h>
|
2021-10-21 09:55:09 +09:00
|
|
|
#include <linux/llist.h>
|
2017-07-20 12:26:48 +01:00
|
|
|
|
|
|
|
|
#include <asm/memory.h>
|
2022-07-26 00:37:38 -07:00
|
|
|
#include <asm/pointer_auth.h>
|
2017-07-20 12:26:48 +01:00
|
|
|
#include <asm/ptrace.h>
|
2018-01-08 15:38:12 +00:00
|
|
|
#include <asm/sdei.h>
|
2015-12-15 17:33:40 +09:00
|
|
|
|
2022-07-26 00:37:34 -07:00
|
|
|
#include <asm/stacktrace/common.h>
|
2018-07-20 14:41:53 -07:00
|
|
|
|
2020-06-08 21:30:23 -07:00
|
|
|
extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
|
|
|
|
|
const char *loglvl);
|
2012-03-05 11:49:27 +00:00
|
|
|
|
2017-07-31 21:17:03 +01:00
|
|
|
DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
|
2017-07-20 12:26:48 +01:00
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
static inline struct stack_info stackinfo_get_irq(void)
|
2020-05-08 11:15:45 +08:00
|
|
|
{
|
|
|
|
|
unsigned long low = (unsigned long)raw_cpu_read(irq_stack_ptr);
|
|
|
|
|
unsigned long high = low + IRQ_STACK_SIZE;
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
return (struct stack_info) {
|
|
|
|
|
.low = low,
|
|
|
|
|
.high = high,
|
|
|
|
|
};
|
2020-05-08 11:15:45 +08:00
|
|
|
}
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
static inline bool on_irq_stack(unsigned long sp, unsigned long size)
|
|
|
|
|
{
|
|
|
|
|
struct stack_info info = stackinfo_get_irq();
|
|
|
|
|
return stackinfo_on_stack(&info, sp, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline struct stack_info stackinfo_get_task(const struct task_struct *tsk)
|
2017-07-20 12:26:48 +01:00
|
|
|
{
|
|
|
|
|
unsigned long low = (unsigned long)task_stack_page(tsk);
|
|
|
|
|
unsigned long high = low + THREAD_SIZE;
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
return (struct stack_info) {
|
|
|
|
|
.low = low,
|
|
|
|
|
.high = high,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool on_task_stack(const struct task_struct *tsk,
|
|
|
|
|
unsigned long sp, unsigned long size)
|
|
|
|
|
{
|
|
|
|
|
struct stack_info info = stackinfo_get_task(tsk);
|
|
|
|
|
return stackinfo_on_stack(&info, sp, size);
|
2017-07-20 12:26:48 +01:00
|
|
|
}
|
|
|
|
|
|
2017-07-14 20:30:35 +01:00
|
|
|
#ifdef CONFIG_VMAP_STACK
|
|
|
|
|
DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack);
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
static inline struct stack_info stackinfo_get_overflow(void)
|
2017-07-14 20:30:35 +01:00
|
|
|
{
|
|
|
|
|
unsigned long low = (unsigned long)raw_cpu_ptr(overflow_stack);
|
|
|
|
|
unsigned long high = low + OVERFLOW_STACK_SIZE;
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
return (struct stack_info) {
|
|
|
|
|
.low = low,
|
|
|
|
|
.high = high,
|
|
|
|
|
};
|
2017-07-14 20:30:35 +01:00
|
|
|
}
|
|
|
|
|
#else
|
2022-09-01 14:06:43 +01:00
|
|
|
#define stackinfo_get_overflow() stackinfo_get_unknown()
|
2022-09-01 14:06:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(CONFIG_ARM_SDE_INTERFACE) && defined(CONFIG_VMAP_STACK)
|
|
|
|
|
DECLARE_PER_CPU(unsigned long *, sdei_stack_normal_ptr);
|
|
|
|
|
DECLARE_PER_CPU(unsigned long *, sdei_stack_critical_ptr);
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
static inline struct stack_info stackinfo_get_sdei_normal(void)
|
2022-09-01 14:06:41 +01:00
|
|
|
{
|
|
|
|
|
unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
|
|
|
|
|
unsigned long high = low + SDEI_STACK_SIZE;
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
return (struct stack_info) {
|
|
|
|
|
.low = low,
|
|
|
|
|
.high = high,
|
|
|
|
|
};
|
2022-09-01 14:06:41 +01:00
|
|
|
}
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
static inline struct stack_info stackinfo_get_sdei_critical(void)
|
2022-09-01 14:06:41 +01:00
|
|
|
{
|
|
|
|
|
unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
|
|
|
|
|
unsigned long high = low + SDEI_STACK_SIZE;
|
|
|
|
|
|
2022-09-01 14:06:43 +01:00
|
|
|
return (struct stack_info) {
|
|
|
|
|
.low = low,
|
|
|
|
|
.high = high,
|
|
|
|
|
};
|
2022-09-01 14:06:41 +01:00
|
|
|
}
|
|
|
|
|
#else
|
2022-09-01 14:06:43 +01:00
|
|
|
#define stackinfo_get_sdei_normal() stackinfo_get_unknown()
|
|
|
|
|
#define stackinfo_get_sdei_critical() stackinfo_get_unknown()
|
2017-07-14 20:30:35 +01:00
|
|
|
#endif
|
|
|
|
|
|
2012-03-05 11:49:27 +00:00
|
|
|
#endif /* __ASM_STACKTRACE_H */
|