linux-arm-kernel.lists.infradead.org archive mirror
 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 v4 4/9] arm64: stacktrace: move SDEI stack helpers to stacktrace code
Date: Thu,  1 Sep 2022 14:06:41 +0100	[thread overview]
Message-ID: <20220901130646.1316937-5-mark.rutland@arm.com> (raw)
In-Reply-To: <20220901130646.1316937-1-mark.rutland@arm.com>

For clarity and ease of maintenance, it would be helpful for all the
stack helpers to be in the same place.

Move the SDEI stack helpers into the stacktrace code where all the other
stack helpers live.

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: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Fuad Tabba <tabba@google.com>
Cc: James Morse <james.morse@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/include/asm/sdei.h       | 17 ------------
 arch/arm64/include/asm/stacktrace.h | 40 ++++++++++++++++++++++++++++-
 arch/arm64/kernel/sdei.c            | 32 -----------------------
 arch/arm64/kernel/stacktrace.c      | 11 ++++++--
 4 files changed, 48 insertions(+), 52 deletions(-)

diff --git a/arch/arm64/include/asm/sdei.h b/arch/arm64/include/asm/sdei.h
index 7bea1d705dd64..4292d9bafb9d2 100644
--- a/arch/arm64/include/asm/sdei.h
+++ b/arch/arm64/include/asm/sdei.h
@@ -43,22 +43,5 @@ unsigned long do_sdei_event(struct pt_regs *regs,
 unsigned long sdei_arch_get_entry_point(int conduit);
 #define sdei_arch_get_entry_point(x)	sdei_arch_get_entry_point(x)
 
-struct stack_info;
-
-bool _on_sdei_stack(unsigned long sp, unsigned long size,
-		    struct stack_info *info);
-static inline bool on_sdei_stack(unsigned long sp, unsigned long size,
-				struct stack_info *info)
-{
-	if (!IS_ENABLED(CONFIG_VMAP_STACK))
-		return false;
-	if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE))
-		return false;
-	if (in_nmi())
-		return _on_sdei_stack(sp, size, info);
-
-	return false;
-}
-
 #endif /* __ASSEMBLY__ */
 #endif	/* __ASM_SDEI_H */
diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h
index 6ebdcdff77f56..fa2df1ea22ebc 100644
--- a/arch/arm64/include/asm/stacktrace.h
+++ b/arch/arm64/include/asm/stacktrace.h
@@ -54,7 +54,45 @@ static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
 }
 #else
 static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
-			struct stack_info *info) { return false; }
+				     struct stack_info *info)
+{
+	return false;
+}
+#endif
+
+#if defined(CONFIG_ARM_SDE_INTERFACE) && defined(CONFIG_VMAP_STACK)
+DECLARE_PER_CPU(unsigned long *, sdei_stack_normal_ptr);
+DECLARE_PER_CPU(unsigned long *, sdei_stack_critical_ptr);
+
+static inline bool on_sdei_normal_stack(unsigned long sp, unsigned long size,
+					struct stack_info *info)
+{
+	unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
+	unsigned long high = low + SDEI_STACK_SIZE;
+
+	return on_stack(sp, size, low, high, STACK_TYPE_SDEI_NORMAL, info);
+}
+
+static inline bool on_sdei_critical_stack(unsigned long sp, unsigned long size,
+					  struct stack_info *info)
+{
+	unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
+	unsigned long high = low + SDEI_STACK_SIZE;
+
+	return on_stack(sp, size, low, high, STACK_TYPE_SDEI_CRITICAL, info);
+}
+#else
+static inline bool on_sdei_normal_stack(unsigned long sp, unsigned long size,
+					struct stack_info *info)
+{
+	return false;
+}
+
+static inline bool on_sdei_critical_stack(unsigned long sp, unsigned long size,
+					  struct stack_info *info)
+{
+	return false;
+}
 #endif
 
 #endif	/* __ASM_STACKTRACE_H */
diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c
index d20620a1c51a4..d56e170e1ca7c 100644
--- a/arch/arm64/kernel/sdei.c
+++ b/arch/arm64/kernel/sdei.c
@@ -162,38 +162,6 @@ static int init_sdei_scs(void)
 	return err;
 }
 
-static bool on_sdei_normal_stack(unsigned long sp, unsigned long size,
-				 struct stack_info *info)
-{
-	unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
-	unsigned long high = low + SDEI_STACK_SIZE;
-
-	return on_stack(sp, size, low, high, STACK_TYPE_SDEI_NORMAL, info);
-}
-
-static bool on_sdei_critical_stack(unsigned long sp, unsigned long size,
-				   struct stack_info *info)
-{
-	unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
-	unsigned long high = low + SDEI_STACK_SIZE;
-
-	return on_stack(sp, size, low, high, STACK_TYPE_SDEI_CRITICAL, info);
-}
-
-bool _on_sdei_stack(unsigned long sp, unsigned long size, struct stack_info *info)
-{
-	if (!IS_ENABLED(CONFIG_VMAP_STACK))
-		return false;
-
-	if (on_sdei_critical_stack(sp, size, info))
-		return true;
-
-	if (on_sdei_normal_stack(sp, size, info))
-		return true;
-
-	return false;
-}
-
 unsigned long sdei_arch_get_entry_point(int conduit)
 {
 	/*
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index 4c8865e495fea..edf9edca20552 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -86,8 +86,15 @@ static bool on_accessible_stack(const struct task_struct *tsk,
 		return true;
 	if (on_overflow_stack(sp, size, info))
 		return true;
-	if (on_sdei_stack(sp, size, info))
-		return true;
+
+	if (IS_ENABLED(CONFIG_VMAP_STACK) &&
+	    IS_ENABLED(CONFIG_ARM_SDE_INTERFACE) &&
+	    in_nmi()) {
+		if (on_sdei_critical_stack(sp, size, info))
+			return true;
+		if (on_sdei_normal_stack(sp, size, info))
+			return true;
+	}
 
 	return false;
 }
-- 
2.30.2


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

  parent reply	other threads:[~2022-09-01 13:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01 13:06 [PATCH v4 0/9] arm64: stacktrace: cleanups and improvements Mark Rutland
2022-09-01 13:06 ` [PATCH v4 1/9] arm64: stacktrace: fix kerneldoc comments Mark Rutland
2022-09-01 13:06 ` [PATCH v4 2/9] arm64: stacktrace: simplify unwind_next_common() Mark Rutland
2022-09-01 13:06 ` [PATCH v4 3/9] arm64: stacktrace: rename unwind_next_common() -> unwind_next_frame_record() Mark Rutland
2022-09-01 13:06 ` Mark Rutland [this message]
2022-09-01 13:06 ` [PATCH v4 5/9] arm64: stacktrace: add stackinfo_on_stack() helper Mark Rutland
2022-09-01 13:06 ` [PATCH v4 6/9] arm64: stacktrace: rework stack boundary discovery Mark Rutland
2022-09-01 13:06 ` [PATCH v4 7/9] arm64: stacktrace: remove stack type from fp translator Mark Rutland
2022-09-01 13:06 ` [PATCH v4 8/9] arm64: stacktrace: track all stack boundaries explicitly Mark Rutland
2022-09-01 13:06 ` [PATCH v4 9/9] arm64: stacktrace: track hyp stacks in unwinder's address space Mark Rutland
2022-09-09 18:08 ` [PATCH v4 0/9] arm64: stacktrace: cleanups and improvements Catalin Marinas

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=20220901130646.1316937-5-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;
as well as URLs for NNTP newsgroup(s).