On Wed, Oct 22, 2025 at 04:43:19PM +0200, Jens Remus wrote:

> @@ -26,12 +27,10 @@ get_user_word(unsigned long *word, unsigned long base, 
> int off, unsigned int ws)
>       return get_user(*word, addr);
>  }
>  
> -static int unwind_user_next_fp(struct unwind_user_state *state)
> +static int unwind_user_next_common(struct unwind_user_state *state,
> +                                const struct unwind_user_frame *frame,
> +                                struct pt_regs *regs)
>  {

What is pt_regs for? AFAICT it isn't actually used in any of the
following patches.

> -     const struct unwind_user_frame fp_frame = {
> -             ARCH_INIT_USER_FP_FRAME(state->ws)
> -     };
> -     const struct unwind_user_frame *frame = &fp_frame;
>       unsigned long cfa, fp, ra;
>  
>       if (frame->use_fp) {
> @@ -67,6 +66,26 @@ static int unwind_user_next_fp(struct unwind_user_state 
> *state)
>       return 0;
>  }
>  
> +static int unwind_user_next_sframe(struct unwind_user_state *state)
> +{
> +     struct unwind_user_frame _frame, *frame;
> +
> +     /* sframe expects the frame to be local storage */
> +     frame = &_frame;
> +     if (sframe_find(state->ip, frame))
> +             return -ENOENT;
> +     return unwind_user_next_common(state, frame, task_pt_regs(current));
> +}

Would it not be simpler to write:

static int unwind_user_next_sframe(struct unwind_user_state *state)
{
        struct unwind_user_frame frame;

        /* sframe expects the frame to be local storage */
        if (sframe_find(state->ip, &frame))
                return -ENOENT;
        return unwind_user_next_common(state, &frame, task_pt_regs(current));
}

hmm?

> +static int unwind_user_next_fp(struct unwind_user_state *state)
> +{
> +     const struct unwind_user_frame fp_frame = {
> +             ARCH_INIT_USER_FP_FRAME(state->ws)
> +     };
> +
> +     return unwind_user_next_common(state, &fp_frame, task_pt_regs(current));
> +}
> +
>  static int unwind_user_next(struct unwind_user_state *state)
>  {
>       unsigned long iter_mask = state->available_types;
> @@ -80,6 +99,16 @@ static int unwind_user_next(struct unwind_user_state 
> *state)
>  
>               state->current_type = type;
>               switch (type) {
> +             case UNWIND_USER_TYPE_SFRAME:
> +                     switch (unwind_user_next_sframe(state)) {
> +                     case 0:
> +                             return 0;
> +                     case -ENOENT:
> +                             continue;       /* Try next method. */
> +                     default:
> +                             state->done = true;
> +                     }
> +                     break;

Should it remove SFRAME from state->available_types at this point?

Reply via email to