[PATCH 2/8] arm64: stacktrace: rename unwind_next_common() -> unwind_next_frame_record()

Kalesh Singh kaleshsingh at google.com
Mon Aug 1 21:38:00 PDT 2022


On Mon, Aug 1, 2022 at 5:12 AM Mark Rutland <mark.rutland at arm.com> wrote:
>
> The unwind_next_common() function unwinds a single frame record. There
> are other unwind steps (e.g. unwinding through trampolines) which are
> handled in the regular kernel unwinder, and in future there may be other
> common unwind helpers.
>
> Clarify the purpose of unwind_next_common() by renaming it to
> unwind_next_frame_record(). At the same time, add commentary, and delete
> the redundant comment at the top of asm/stacktrace/common.h.
>
> There should be no functional change as a result of this patch.
>
> Signed-off-by: Mark Rutland <mark.rutland at arm.com>
> Cc: Fuad Tabba <tabba at google.com>
> Cc: Kalesh Singh <kaleshsingh at google.com>
> Cc: Madhavan T. Venkataraman <madvenka at linux.microsoft.com>
> Cc: Marc Zyngier <maz at kernel.org>
> Cc: Mark Brown <broonie at kernel.org>

Reviewed-by: Kalesh Singh <kaleshsingh at google.com>

> ---
>  arch/arm64/include/asm/stacktrace/common.h | 22 ++++++++++++----------
>  arch/arm64/kernel/stacktrace.c             |  2 +-
>  arch/arm64/kvm/hyp/nvhe/stacktrace.c       |  2 +-
>  arch/arm64/kvm/stacktrace.c                |  4 ++--
>  4 files changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h
> index 01dc9f44a24a7..676002d7d333c 100644
> --- a/arch/arm64/include/asm/stacktrace/common.h
> +++ b/arch/arm64/include/asm/stacktrace/common.h
> @@ -2,13 +2,6 @@
>  /*
>   * Common arm64 stack unwinder code.
>   *
> - * To implement a new arm64 stack unwinder:
> - *     1) Include this header
> - *
> - *     2) Call into unwind_next_common() from your top level unwind
> - *        function, passing it the validation and translation callbacks
> - *        (though the later can be NULL if no translation is required).
> - *
>   * See: arch/arm64/kernel/stacktrace.c for the reference implementation.
>   *
>   * Copyright (C) 2012 ARM Ltd.
> @@ -139,9 +132,18 @@ typedef bool (*on_accessible_stack_fn)(const struct task_struct *tsk,
>                                        unsigned long sp, unsigned long size,
>                                        struct stack_info *info);
>
> -static inline int unwind_next_common(struct unwind_state *state,
> -                                    on_accessible_stack_fn accessible,
> -                                    stack_trace_translate_fp_fn translate_fp)
> +/*
> + * unwind_next_frame_record() - Unwind to the next frame record indicated by
> + * @state->fp.
> + *
> + * @state:        the current unwind state.
> + * @accessible:   determines whether the frame record is accessible
> + * @translate_fp: translates the fp prior to access (may be NULL)
> + */
> +static inline int
> +unwind_next_frame_record(struct unwind_state *state,
> +                        on_accessible_stack_fn accessible,
> +                        stack_trace_translate_fp_fn translate_fp)
>  {
>         struct stack_info info;
>         unsigned long fp = state->fp, kern_fp = fp;
> diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
> index 056fb045d0e0c..4c8865e495fea 100644
> --- a/arch/arm64/kernel/stacktrace.c
> +++ b/arch/arm64/kernel/stacktrace.c
> @@ -109,7 +109,7 @@ static int notrace unwind_next(struct unwind_state *state)
>         if (fp == (unsigned long)task_pt_regs(tsk)->stackframe)
>                 return -ENOENT;
>
> -       err = unwind_next_common(state, on_accessible_stack, NULL);
> +       err = unwind_next_frame_record(state, on_accessible_stack, NULL);
>         if (err)
>                 return err;
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/stacktrace.c b/arch/arm64/kvm/hyp/nvhe/stacktrace.c
> index 50a1fa6b5c044..579b46aa9a553 100644
> --- a/arch/arm64/kvm/hyp/nvhe/stacktrace.c
> +++ b/arch/arm64/kvm/hyp/nvhe/stacktrace.c
> @@ -71,7 +71,7 @@ static bool on_accessible_stack(const struct task_struct *tsk,
>
>  static int unwind_next(struct unwind_state *state)
>  {
> -       return unwind_next_common(state, on_accessible_stack, NULL);
> +       return unwind_next_frame_record(state, on_accessible_stack, NULL);
>  }
>
>  static void notrace unwind(struct unwind_state *state,
> diff --git a/arch/arm64/kvm/stacktrace.c b/arch/arm64/kvm/stacktrace.c
> index b9cf551d9d31d..b69c18a26567d 100644
> --- a/arch/arm64/kvm/stacktrace.c
> +++ b/arch/arm64/kvm/stacktrace.c
> @@ -97,8 +97,8 @@ static bool on_accessible_stack(const struct task_struct *tsk,
>
>  static int unwind_next(struct unwind_state *state)
>  {
> -       return unwind_next_common(state, on_accessible_stack,
> -                                 kvm_nvhe_stack_kern_va);
> +       return unwind_next_frame_record(state, on_accessible_stack,
> +                                       kvm_nvhe_stack_kern_va);
>  }
>
>  static void unwind(struct unwind_state *state,
> --
> 2.30.2
>



More information about the linux-arm-kernel mailing list