mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
BACKPORT: arm64: Copy the task argument to unwind_state
Copy the task argument passed to arch_stack_walk() to unwind_state so that
it can be passed to unwind functions via unwind_state rather than as a
separate argument. The task is a fundamental part of the unwind state.
Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20220617180219.20352-3-madvenka@linux.microsoft.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 82a592c13b)
[willdeacon@: Resolve context conflict with kretprobes field in
'struct unwind_state']
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 233587962
Bug: 233588291
Change-Id: Icf29c7da8111dd5f7a25d99e6277a99c78e1ec23
This commit is contained in:
committed by
Quentin Perret
parent
e12793be98
commit
b922edc361
@@ -34,6 +34,8 @@
|
||||
* @prev_type: The type of stack this frame record was on, or a synthetic
|
||||
* value of STACK_TYPE_UNKNOWN. This is used to detect a
|
||||
* transition from one stack to another.
|
||||
*
|
||||
* @task: The task being unwound.
|
||||
*/
|
||||
struct unwind_state {
|
||||
unsigned long fp;
|
||||
@@ -41,10 +43,14 @@ struct unwind_state {
|
||||
DECLARE_BITMAP(stacks_done, __NR_STACK_TYPES);
|
||||
unsigned long prev_fp;
|
||||
enum stack_type prev_type;
|
||||
struct task_struct *task;
|
||||
};
|
||||
|
||||
static void unwind_init_common(struct unwind_state *state)
|
||||
static void unwind_init_common(struct unwind_state *state,
|
||||
struct task_struct *task)
|
||||
{
|
||||
state->task = task;
|
||||
|
||||
/*
|
||||
* Prime the first unwind.
|
||||
*
|
||||
@@ -69,7 +75,7 @@ static void unwind_init_common(struct unwind_state *state)
|
||||
static inline void unwind_init_from_regs(struct unwind_state *state,
|
||||
struct pt_regs *regs)
|
||||
{
|
||||
unwind_init_common(state);
|
||||
unwind_init_common(state, current);
|
||||
|
||||
state->fp = regs->regs[29];
|
||||
state->pc = regs->pc;
|
||||
@@ -85,7 +91,7 @@ static inline void unwind_init_from_regs(struct unwind_state *state,
|
||||
*/
|
||||
static __always_inline void unwind_init_from_caller(struct unwind_state *state)
|
||||
{
|
||||
unwind_init_common(state);
|
||||
unwind_init_common(state, current);
|
||||
|
||||
state->fp = (unsigned long)__builtin_frame_address(1);
|
||||
state->pc = (unsigned long)__builtin_return_address(0);
|
||||
@@ -104,7 +110,7 @@ static __always_inline void unwind_init_from_caller(struct unwind_state *state)
|
||||
static inline void unwind_init_from_task(struct unwind_state *state,
|
||||
struct task_struct *task)
|
||||
{
|
||||
unwind_init_common(state);
|
||||
unwind_init_common(state, task);
|
||||
|
||||
state->fp = thread_saved_fp(task);
|
||||
state->pc = thread_saved_pc(task);
|
||||
@@ -117,9 +123,9 @@ static inline void unwind_init_from_task(struct unwind_state *state,
|
||||
* records (e.g. a cycle), determined based on the location and fp value of A
|
||||
* and the location (but not the fp value) of B.
|
||||
*/
|
||||
static int notrace unwind_next(struct task_struct *tsk,
|
||||
struct unwind_state *state)
|
||||
static int notrace unwind_next(struct unwind_state *state)
|
||||
{
|
||||
struct task_struct *tsk = state->task;
|
||||
unsigned long fp = state->fp;
|
||||
struct stack_info info;
|
||||
|
||||
@@ -189,8 +195,7 @@ static int notrace unwind_next(struct task_struct *tsk,
|
||||
}
|
||||
NOKPROBE_SYMBOL(unwind_next);
|
||||
|
||||
static void notrace unwind(struct task_struct *tsk,
|
||||
struct unwind_state *state,
|
||||
static void notrace unwind(struct unwind_state *state,
|
||||
stack_trace_consume_fn consume_entry, void *cookie)
|
||||
{
|
||||
while (1) {
|
||||
@@ -198,7 +203,7 @@ static void notrace unwind(struct task_struct *tsk,
|
||||
|
||||
if (!consume_entry(cookie, state->pc))
|
||||
break;
|
||||
ret = unwind_next(tsk, state);
|
||||
ret = unwind_next(state);
|
||||
if (ret < 0)
|
||||
break;
|
||||
}
|
||||
@@ -245,12 +250,15 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry,
|
||||
{
|
||||
struct unwind_state state;
|
||||
|
||||
if (regs)
|
||||
if (regs) {
|
||||
if (task != current)
|
||||
return;
|
||||
unwind_init_from_regs(&state, regs);
|
||||
else if (task == current)
|
||||
} else if (task == current) {
|
||||
unwind_init_from_caller(&state);
|
||||
else
|
||||
} else {
|
||||
unwind_init_from_task(&state, task);
|
||||
}
|
||||
|
||||
unwind(task, &state, consume_entry, cookie);
|
||||
unwind(&state, consume_entry, cookie);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user