Commit 36f9a879 authored by Mark Rutland's avatar Mark Rutland Committed by Catalin Marinas

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: default avatarMark Rutland <mark.rutland@arm.com>
Reviewed-by: default avatarKalesh Singh <kaleshsingh@google.com>
Reviewed-by: default avatarMadhavan T. Venkataraman <madvenka@linux.microsoft.com>
Reviewed-by: default avatarMark Brown <broonie@kernel.org>
Cc: Fuad Tabba <tabba@google.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20220901130646.1316937-6-mark.rutland@arm.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 75758d51
...@@ -65,21 +65,34 @@ struct unwind_state { ...@@ -65,21 +65,34 @@ struct unwind_state {
struct task_struct *task; 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, static inline bool on_stack(unsigned long sp, unsigned long size,
unsigned long low, unsigned long high, unsigned long low, unsigned long high,
enum stack_type type, struct stack_info *info) enum stack_type type, struct stack_info *info)
{ {
if (!low) struct stack_info tmp = {
return false; .low = low,
.high = high,
.type = type,
};
if (sp < low || sp + size < sp || sp + size > high) if (!stackinfo_on_stack(&tmp, sp, size))
return false; return false;
if (info) { if (info)
info->low = low; *info = tmp;
info->high = high;
info->type = type;
}
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment