3939 * associated with the most recently encountered replacement lr
4040 * value.
4141 */
42- struct stackframe {
42+ struct unwind_state {
4343 unsigned long fp ;
4444 unsigned long pc ;
4545 DECLARE_BITMAP (stacks_done , __NR_STACK_TYPES );
@@ -50,13 +50,13 @@ struct stackframe {
5050#endif
5151};
5252
53- static notrace void unwind_init (struct stackframe * frame , unsigned long fp ,
53+ static notrace void unwind_init (struct unwind_state * state , unsigned long fp ,
5454 unsigned long pc )
5555{
56- frame -> fp = fp ;
57- frame -> pc = pc ;
56+ state -> fp = fp ;
57+ state -> pc = pc ;
5858#ifdef CONFIG_KRETPROBES
59- frame -> kr_cur = NULL ;
59+ state -> kr_cur = NULL ;
6060#endif
6161
6262 /*
@@ -68,9 +68,9 @@ static notrace void unwind_init(struct stackframe *frame, unsigned long fp,
6868 * prev_fp value won't be used, but we set it to 0 such that it is
6969 * definitely not an accessible stack address.
7070 */
71- bitmap_zero (frame -> stacks_done , __NR_STACK_TYPES );
72- frame -> prev_fp = 0 ;
73- frame -> prev_type = STACK_TYPE_UNKNOWN ;
71+ bitmap_zero (state -> stacks_done , __NR_STACK_TYPES );
72+ state -> prev_fp = 0 ;
73+ state -> prev_type = STACK_TYPE_UNKNOWN ;
7474}
7575NOKPROBE_SYMBOL (unwind_init );
7676
@@ -82,9 +82,9 @@ NOKPROBE_SYMBOL(unwind_init);
8282 * and the location (but not the fp value) of B.
8383 */
8484static int notrace unwind_next (struct task_struct * tsk ,
85- struct stackframe * frame )
85+ struct unwind_state * state )
8686{
87- unsigned long fp = frame -> fp ;
87+ unsigned long fp = state -> fp ;
8888 struct stack_info info ;
8989
9090 /* Final frame; nothing to unwind */
@@ -97,7 +97,7 @@ static int notrace unwind_next(struct task_struct *tsk,
9797 if (!on_accessible_stack (tsk , fp , 16 , & info ))
9898 return - EINVAL ;
9999
100- if (test_bit (info .type , frame -> stacks_done ))
100+ if (test_bit (info .type , state -> stacks_done ))
101101 return - EINVAL ;
102102
103103 /*
@@ -113,60 +113,60 @@ static int notrace unwind_next(struct task_struct *tsk,
113113 * stack to another, it's never valid to unwind back to that first
114114 * stack.
115115 */
116- if (info .type == frame -> prev_type ) {
117- if (fp <= frame -> prev_fp )
116+ if (info .type == state -> prev_type ) {
117+ if (fp <= state -> prev_fp )
118118 return - EINVAL ;
119119 } else {
120- set_bit (frame -> prev_type , frame -> stacks_done );
120+ set_bit (state -> prev_type , state -> stacks_done );
121121 }
122122
123123 /*
124124 * Record this frame record's values and location. The prev_fp and
125125 * prev_type are only meaningful to the next unwind_next() invocation.
126126 */
127- frame -> fp = READ_ONCE_NOCHECK (* (unsigned long * )(fp ));
128- frame -> pc = READ_ONCE_NOCHECK (* (unsigned long * )(fp + 8 ));
129- frame -> prev_fp = fp ;
130- frame -> prev_type = info .type ;
127+ state -> fp = READ_ONCE_NOCHECK (* (unsigned long * )(fp ));
128+ state -> pc = READ_ONCE_NOCHECK (* (unsigned long * )(fp + 8 ));
129+ state -> prev_fp = fp ;
130+ state -> prev_type = info .type ;
131131
132- frame -> pc = ptrauth_strip_insn_pac (frame -> pc );
132+ state -> pc = ptrauth_strip_insn_pac (state -> pc );
133133
134134#ifdef CONFIG_FUNCTION_GRAPH_TRACER
135135 if (tsk -> ret_stack &&
136- (frame -> pc == (unsigned long )return_to_handler )) {
136+ (state -> pc == (unsigned long )return_to_handler )) {
137137 unsigned long orig_pc ;
138138 /*
139139 * This is a case where function graph tracer has
140140 * modified a return address (LR) in a stack frame
141141 * to hook a function return.
142142 * So replace it to an original value.
143143 */
144- orig_pc = ftrace_graph_ret_addr (tsk , NULL , frame -> pc ,
145- (void * )frame -> fp );
146- if (WARN_ON_ONCE (frame -> pc == orig_pc ))
144+ orig_pc = ftrace_graph_ret_addr (tsk , NULL , state -> pc ,
145+ (void * )state -> fp );
146+ if (WARN_ON_ONCE (state -> pc == orig_pc ))
147147 return - EINVAL ;
148- frame -> pc = orig_pc ;
148+ state -> pc = orig_pc ;
149149 }
150150#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
151151#ifdef CONFIG_KRETPROBES
152- if (is_kretprobe_trampoline (frame -> pc ))
153- frame -> pc = kretprobe_find_ret_addr (tsk , (void * )frame -> fp , & frame -> kr_cur );
152+ if (is_kretprobe_trampoline (state -> pc ))
153+ state -> pc = kretprobe_find_ret_addr (tsk , (void * )state -> fp , & state -> kr_cur );
154154#endif
155155
156156 return 0 ;
157157}
158158NOKPROBE_SYMBOL (unwind_next );
159159
160160static void notrace unwind (struct task_struct * tsk ,
161- struct stackframe * frame ,
161+ struct unwind_state * state ,
162162 bool (* fn )(void * , unsigned long ), void * data )
163163{
164164 while (1 ) {
165165 int ret ;
166166
167- if (!fn (data , frame -> pc ))
167+ if (!fn (data , state -> pc ))
168168 break ;
169- ret = unwind_next (tsk , frame );
169+ ret = unwind_next (tsk , state );
170170 if (ret < 0 )
171171 break ;
172172 }
@@ -210,17 +210,17 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry,
210210 void * cookie , struct task_struct * task ,
211211 struct pt_regs * regs )
212212{
213- struct stackframe frame ;
213+ struct unwind_state state ;
214214
215215 if (regs )
216- unwind_init (& frame , regs -> regs [29 ], regs -> pc );
216+ unwind_init (& state , regs -> regs [29 ], regs -> pc );
217217 else if (task == current )
218- unwind_init (& frame ,
218+ unwind_init (& state ,
219219 (unsigned long )__builtin_frame_address (1 ),
220220 (unsigned long )__builtin_return_address (0 ));
221221 else
222- unwind_init (& frame , thread_saved_fp (task ),
222+ unwind_init (& state , thread_saved_fp (task ),
223223 thread_saved_pc (task ));
224224
225- unwind (task , & frame , consume_entry , cookie );
225+ unwind (task , & state , consume_entry , cookie );
226226}
0 commit comments