public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: broonie@kernel.org, catalin.marinas@arm.com, james.morse@arm.com,
	kaleshsingh@google.com, madvenka@linux.microsoft.com,
	mark.rutland@arm.com, maz@kernel.org, tabba@google.com,
	will@kernel.org
Subject: [PATCH v2 1/8] arm64: stacktrace: simplify unwind_next_common()
Date: Fri,  5 Aug 2022 13:45:15 +0100	[thread overview]
Message-ID: <20220805124522.706457-2-mark.rutland@arm.com> (raw)
In-Reply-To: <20220805124522.706457-1-mark.rutland@arm.com>

Currently unwind_next_common() takes a pointer to a stack_info which is
only ever used within unwind_next_common().

Make it a local variable and simplify callers.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Kalesh Singh <kaleshsingh@google.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Cc: Fuad Tabba <tabba@google.com>
Cc: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
Cc: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/include/asm/stacktrace/common.h | 12 ++++++------
 arch/arm64/kernel/stacktrace.c             |  3 +--
 arch/arm64/kvm/hyp/nvhe/stacktrace.c       |  4 +---
 arch/arm64/kvm/stacktrace.c                |  4 +---
 4 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h
index f58eb944c46fb..01dc9f44a24a7 100644
--- a/arch/arm64/include/asm/stacktrace/common.h
+++ b/arch/arm64/include/asm/stacktrace/common.h
@@ -140,27 +140,27 @@ typedef bool (*on_accessible_stack_fn)(const struct task_struct *tsk,
 				       struct stack_info *info);
 
 static inline int unwind_next_common(struct unwind_state *state,
-				     struct stack_info *info,
 				     on_accessible_stack_fn accessible,
 				     stack_trace_translate_fp_fn translate_fp)
 {
+	struct stack_info info;
 	unsigned long fp = state->fp, kern_fp = fp;
 	struct task_struct *tsk = state->task;
 
 	if (fp & 0x7)
 		return -EINVAL;
 
-	if (!accessible(tsk, fp, 16, info))
+	if (!accessible(tsk, fp, 16, &info))
 		return -EINVAL;
 
-	if (test_bit(info->type, state->stacks_done))
+	if (test_bit(info.type, state->stacks_done))
 		return -EINVAL;
 
 	/*
 	 * If fp is not from the current address space perform the necessary
 	 * translation before dereferencing it to get the next fp.
 	 */
-	if (translate_fp && !translate_fp(&kern_fp, info->type))
+	if (translate_fp && !translate_fp(&kern_fp, info.type))
 		return -EINVAL;
 
 	/*
@@ -177,7 +177,7 @@ static inline int unwind_next_common(struct unwind_state *state,
 	 * stack to another, it's never valid to unwind back to that first
 	 * stack.
 	 */
-	if (info->type == state->prev_type) {
+	if (info.type == state->prev_type) {
 		if (fp <= state->prev_fp)
 			return -EINVAL;
 	} else {
@@ -191,7 +191,7 @@ static inline int unwind_next_common(struct unwind_state *state,
 	state->fp = READ_ONCE(*(unsigned long *)(kern_fp));
 	state->pc = READ_ONCE(*(unsigned long *)(kern_fp + 8));
 	state->prev_fp = fp;
-	state->prev_type = info->type;
+	state->prev_type = info.type;
 
 	return 0;
 }
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index ce190ee18a201..056fb045d0e0c 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -103,14 +103,13 @@ static int notrace unwind_next(struct unwind_state *state)
 {
 	struct task_struct *tsk = state->task;
 	unsigned long fp = state->fp;
-	struct stack_info info;
 	int err;
 
 	/* Final frame; nothing to unwind */
 	if (fp == (unsigned long)task_pt_regs(tsk)->stackframe)
 		return -ENOENT;
 
-	err = unwind_next_common(state, &info, on_accessible_stack, NULL);
+	err = unwind_next_common(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 58f645ad66bcb..50a1fa6b5c044 100644
--- a/arch/arm64/kvm/hyp/nvhe/stacktrace.c
+++ b/arch/arm64/kvm/hyp/nvhe/stacktrace.c
@@ -71,9 +71,7 @@ static bool on_accessible_stack(const struct task_struct *tsk,
 
 static int unwind_next(struct unwind_state *state)
 {
-	struct stack_info info;
-
-	return unwind_next_common(state, &info, on_accessible_stack, NULL);
+	return unwind_next_common(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 949d19d603fba..b9cf551d9d31d 100644
--- a/arch/arm64/kvm/stacktrace.c
+++ b/arch/arm64/kvm/stacktrace.c
@@ -97,9 +97,7 @@ static bool on_accessible_stack(const struct task_struct *tsk,
 
 static int unwind_next(struct unwind_state *state)
 {
-	struct stack_info info;
-
-	return unwind_next_common(state, &info, on_accessible_stack,
+	return unwind_next_common(state, on_accessible_stack,
 				  kvm_nvhe_stack_kern_va);
 }
 
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-08-05 12:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-05 12:45 [PATCH v2 0/8] arm64: stacktrace: cleanups and improvements Mark Rutland
2022-08-05 12:45 ` Mark Rutland [this message]
2022-08-05 12:45 ` [PATCH v2 2/8] arm64: stacktrace: rename unwind_next_common() -> unwind_next_frame_record() Mark Rutland
2022-08-08 11:38   ` Will Deacon
2022-08-08 11:46     ` Mark Rutland
2022-08-05 12:45 ` [PATCH v2 3/8] arm64: stacktrace: move SDEI stack helpers to stacktrace code Mark Rutland
2022-08-05 12:45 ` [PATCH v2 4/8] arm64: stacktrace: add stackinfo_on_stack() helper Mark Rutland
2022-08-05 12:45 ` [PATCH v2 5/8] arm64: stacktrace: rework stack boundary discovery Mark Rutland
2022-08-05 12:45 ` [PATCH v2 6/8] arm64: stacktrace: remove stack type from fp translator Mark Rutland
2022-08-08 11:55   ` Will Deacon
2022-08-08 12:08     ` Mark Rutland
2022-08-08 12:30       ` Mark Rutland
2022-08-08 11:56   ` Mark Brown
2022-08-05 12:45 ` [PATCH v2 7/8] arm64: stacktrace: track all stack boundaries explicitly Mark Rutland
2022-08-08 12:04   ` Mark Brown
2022-08-05 12:45 ` [PATCH v2 8/8] arm64: stacktrace: track hyp stacks in unwinder's address space Mark Rutland
2022-08-08 12:09   ` Mark Brown
2022-08-06  1:11 ` [PATCH v2 0/8] arm64: stacktrace: cleanups and improvements Madhavan T. Venkataraman
2022-08-08 11:59 ` Will Deacon
2022-08-08 12:11   ` Mark Rutland
2022-08-08 12:28     ` Will Deacon
2022-08-08 12:33       ` Mark Rutland
2022-08-08 12:38     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220805124522.706457-2-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=kaleshsingh@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=madvenka@linux.microsoft.com \
    --cc=maz@kernel.org \
    --cc=tabba@google.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox