aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Rutland <[email protected]>2022-09-01 14:06:42 +0100
committerCatalin Marinas <[email protected]>2022-09-09 12:30:07 +0100
commit36f9a8793c16da01dffe0718b66c884933b06b98 (patch)
tree0cd8c7aa4ce883fe7661dc3a072e3aa16a357f16
parent75758d511432c129db39b50dd3c108e65dd1a2b1 (diff)
arm64: stacktrace: add stackinfo_on_stack() helper
Factor the core predicate out of on_stack() into a helper which can be used on a pre-populated stack_info. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <[email protected]> Reviewed-by: Kalesh Singh <[email protected]> Reviewed-by: Madhavan T. Venkataraman <[email protected]> Reviewed-by: Mark Brown <[email protected]> Cc: Fuad Tabba <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
-rw-r--r--arch/arm64/include/asm/stacktrace/common.h29
1 files changed, 21 insertions, 8 deletions
diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h
index a74fa301fe95..81c21378b1ac 100644
--- a/arch/arm64/include/asm/stacktrace/common.h
+++ b/arch/arm64/include/asm/stacktrace/common.h
@@ -65,21 +65,34 @@ struct unwind_state {
struct task_struct *task;
};
+static inline bool stackinfo_on_stack(const struct stack_info *info,
+ unsigned long sp, unsigned long size)
+{
+ if (!info->low)
+ return false;
+
+ if (sp < info->low || sp + size < sp || sp + size > info->high)
+ return false;
+
+ return true;
+}
+
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)
{
- if (!low)
- return false;
+ struct stack_info tmp = {
+ .low = low,
+ .high = high,
+ .type = type,
+ };
- if (sp < low || sp + size < sp || sp + size > high)
+ if (!stackinfo_on_stack(&tmp, sp, size))
return false;
- if (info) {
- info->low = low;
- info->high = high;
- info->type = type;
- }
+ if (info)
+ *info = tmp;
+
return true;
}