arm64: stacktrace: move SDEI stack helpers to stacktrace code
authorMark Rutland <mark.rutland@arm.com>
Thu, 1 Sep 2022 13:06:41 +0000 (14:06 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 9 Sep 2022 11:30:07 +0000 (12:30 +0100)
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: Fuad Tabba <tabba@google.com>
Cc: James Morse <james.morse@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20220901130646.1316937-5-mark.rutland@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/sdei.h
arch/arm64/include/asm/stacktrace.h
arch/arm64/kernel/sdei.c
arch/arm64/kernel/stacktrace.c

index 7bea1d705dd6408cf53c41b9491d8b68b1851730..4292d9bafb9d2f85f8106fb6cba63306b614c4fd 100644 (file)
@@ -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 */
index 6ebdcdff77f56c5e8502e45cb04daa2856954b7f..fa2df1ea22ebc462bb6b2393956672fbaf660813 100644 (file)
@@ -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 */
index d20620a1c51a470ed3e43f0ac0370e8c68d9b8e0..d56e170e1ca7c637c61bfdc08c94fa85f09edeb2 100644 (file)
@@ -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)
 {
        /*
index 4c8865e495feabed9b63f7ae32e885ef726a9054..edf9edca205528a556a75863a9fc578095f7d181 100644 (file)
@@ -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;
 }