On Wed, 18 Jun 2025 15:47:58 +0200
Peter Zijlstra <pet...@infradead.org> wrote:

> On Tue, Jun 10, 2025 at 08:54:24PM -0400, Steven Rostedt wrote:
> 
> > +#ifndef arch_unwind_user_init
> > +static inline void arch_unwind_user_init(struct unwind_user_state *state, 
> > struct pt_regs *reg) {}
> > +#endif
> > +
> > +#ifndef arch_unwind_user_next
> > +static inline void arch_unwind_user_next(struct unwind_user_state *state) 
> > {}
> > +#endif  
> 
> The purpose of these arch hooks is so far mysterious. No comments, no
> changelog, no nothing.

I'll add comments.

It's used later in the x86 compat code to allow the architecture to do any
special initialization or to handling moving to the next frame.

From patch 14:

+#define in_compat_mode(regs) !user_64bit_mode(regs)
+
+static inline void arch_unwind_user_init(struct unwind_user_state *state,
+                                        struct pt_regs *regs)
+{
+       unsigned long cs_base, ss_base;
+
+       if (state->type != UNWIND_USER_TYPE_COMPAT_FP)
+               return;
+
+       scoped_guard(irqsave) {
+               cs_base = segment_base_address(regs->cs);
+               ss_base = segment_base_address(regs->ss);
+       }
+
+       state->arch.cs_base = cs_base;
+       state->arch.ss_base = ss_base;
+
+       state->ip += cs_base;
+       state->sp += ss_base;
+       state->fp += ss_base;
+}
+#define arch_unwind_user_init arch_unwind_user_init
+
+static inline void arch_unwind_user_next(struct unwind_user_state *state)
+{
+       if (state->type != UNWIND_USER_TYPE_COMPAT_FP)
+               return;
+
+       state->ip += state->arch.cs_base;
+       state->fp += state->arch.ss_base;
+}
+#define arch_unwind_user_next arch_unwind_user_next

-- Steve

Reply via email to