2022-07-15 06:13:19

by Kalesh Singh

[permalink] [raw]
Subject: [PATCH v4 02/18] arm64: stacktrace: Factor out on_accessible_stack_common()

Move common on_accessible_stack checks to stacktrace/common.h. This is
used in the implementation of the nVHE hypervisor unwinder later in
this series.

Signed-off-by: Kalesh Singh <[email protected]>
---
arch/arm64/include/asm/stacktrace.h | 8 ++------
arch/arm64/include/asm/stacktrace/common.h | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h
index 79f455b37c84..a4f8b84fb459 100644
--- a/arch/arm64/include/asm/stacktrace.h
+++ b/arch/arm64/include/asm/stacktrace.h
@@ -56,7 +56,6 @@ static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
struct stack_info *info) { return false; }
#endif

-
/*
* We can only safely access per-cpu stacks from current in a non-preemptible
* context.
@@ -65,8 +64,8 @@ static inline bool on_accessible_stack(const struct task_struct *tsk,
unsigned long sp, unsigned long size,
struct stack_info *info)
{
- if (info)
- info->type = STACK_TYPE_UNKNOWN;
+ if (on_accessible_stack_common(tsk, sp, size, info))
+ return true;

if (on_task_stack(tsk, sp, size, info))
return true;
@@ -74,12 +73,9 @@ static inline bool on_accessible_stack(const struct task_struct *tsk,
return false;
if (on_irq_stack(sp, size, info))
return true;
- if (on_overflow_stack(sp, size, info))
- return true;
if (on_sdei_stack(sp, size, info))
return true;

return false;
}
-
#endif /* __ASM_STACKTRACE_H */
diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h
index 64ae4f6b06fe..f58b786460d3 100644
--- a/arch/arm64/include/asm/stacktrace/common.h
+++ b/arch/arm64/include/asm/stacktrace/common.h
@@ -62,6 +62,9 @@ struct unwind_state {
struct task_struct *task;
};

+static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
+ struct stack_info *info);
+
static inline bool on_stack(unsigned long sp, unsigned long size,
unsigned long low, unsigned long high,
enum stack_type type, struct stack_info *info)
@@ -80,6 +83,21 @@ static inline bool on_stack(unsigned long sp, unsigned long size,
return true;
}

+static inline bool on_accessible_stack_common(const struct task_struct *tsk,
+ unsigned long sp,
+ unsigned long size,
+ struct stack_info *info)
+{
+ if (info)
+ info->type = STACK_TYPE_UNKNOWN;
+
+ /*
+ * Both the kernel and nvhe hypervisor make use of
+ * an overflow_stack
+ */
+ return on_overflow_stack(sp, size, info);
+}
+
static inline void unwind_init_common(struct unwind_state *state,
struct task_struct *task)
{
--
2.37.0.170.g444d1eabd0-goog


2022-07-15 14:56:41

by Fuad Tabba

[permalink] [raw]
Subject: Re: [PATCH v4 02/18] arm64: stacktrace: Factor out on_accessible_stack_common()

Hi Kalesh,

On Fri, Jul 15, 2022 at 7:10 AM Kalesh Singh <[email protected]> wrote:
>
> Move common on_accessible_stack checks to stacktrace/common.h. This is
> used in the implementation of the nVHE hypervisor unwinder later in
> this series.
>
> Signed-off-by: Kalesh Singh <[email protected]>
> ---

Reviewed-by: Fuad Tabba <[email protected]>

Thanks,
/fuad


> arch/arm64/include/asm/stacktrace.h | 8 ++------
> arch/arm64/include/asm/stacktrace/common.h | 18 ++++++++++++++++++
> 2 files changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h
> index 79f455b37c84..a4f8b84fb459 100644
> --- a/arch/arm64/include/asm/stacktrace.h
> +++ b/arch/arm64/include/asm/stacktrace.h
> @@ -56,7 +56,6 @@ static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
> struct stack_info *info) { return false; }
> #endif
>
> -
> /*
> * We can only safely access per-cpu stacks from current in a non-preemptible
> * context.
> @@ -65,8 +64,8 @@ static inline bool on_accessible_stack(const struct task_struct *tsk,
> unsigned long sp, unsigned long size,
> struct stack_info *info)
> {
> - if (info)
> - info->type = STACK_TYPE_UNKNOWN;
> + if (on_accessible_stack_common(tsk, sp, size, info))
> + return true;
>
> if (on_task_stack(tsk, sp, size, info))
> return true;
> @@ -74,12 +73,9 @@ static inline bool on_accessible_stack(const struct task_struct *tsk,
> return false;
> if (on_irq_stack(sp, size, info))
> return true;
> - if (on_overflow_stack(sp, size, info))
> - return true;
> if (on_sdei_stack(sp, size, info))
> return true;
>
> return false;
> }
> -
> #endif /* __ASM_STACKTRACE_H */
> diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h
> index 64ae4f6b06fe..f58b786460d3 100644
> --- a/arch/arm64/include/asm/stacktrace/common.h
> +++ b/arch/arm64/include/asm/stacktrace/common.h
> @@ -62,6 +62,9 @@ struct unwind_state {
> struct task_struct *task;
> };
>
> +static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
> + struct stack_info *info);
> +
> static inline bool on_stack(unsigned long sp, unsigned long size,
> unsigned long low, unsigned long high,
> enum stack_type type, struct stack_info *info)
> @@ -80,6 +83,21 @@ static inline bool on_stack(unsigned long sp, unsigned long size,
> return true;
> }
>
> +static inline bool on_accessible_stack_common(const struct task_struct *tsk,
> + unsigned long sp,
> + unsigned long size,
> + struct stack_info *info)
> +{
> + if (info)
> + info->type = STACK_TYPE_UNKNOWN;
> +
> + /*
> + * Both the kernel and nvhe hypervisor make use of
> + * an overflow_stack
> + */
> + return on_overflow_stack(sp, size, info);
> +}
> +
> static inline void unwind_init_common(struct unwind_state *state,
> struct task_struct *task)
> {
> --
> 2.37.0.170.g444d1eabd0-goog
>

2022-07-15 16:31:00

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v4 02/18] arm64: stacktrace: Factor out on_accessible_stack_common()

On Thu, Jul 14, 2022 at 11:10:11PM -0700, Kalesh Singh wrote:

> @@ -56,7 +56,6 @@ static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
> struct stack_info *info) { return false; }
> #endif
>
> -
> /*
> * We can only safely access per-cpu stacks from current in a non-preemptible
> * context.

Random perfectly fine but unrelated whitespace change here. Otherwise

Reviewed-by: Mark Brown <[email protected]>


Attachments:
(No filename) (459.00 B)
signature.asc (499.00 B)
Download all attachments