Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: stacktrace: move SDEI stack helpers to stacktrace code

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>

authored by

Mark Rutland and committed by
Catalin Marinas
75758d51 b532ab5f

+48 -52
-17
arch/arm64/include/asm/sdei.h
··· 43 43 unsigned long sdei_arch_get_entry_point(int conduit); 44 44 #define sdei_arch_get_entry_point(x) sdei_arch_get_entry_point(x) 45 45 46 - struct stack_info; 47 - 48 - bool _on_sdei_stack(unsigned long sp, unsigned long size, 49 - struct stack_info *info); 50 - static inline bool on_sdei_stack(unsigned long sp, unsigned long size, 51 - struct stack_info *info) 52 - { 53 - if (!IS_ENABLED(CONFIG_VMAP_STACK)) 54 - return false; 55 - if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE)) 56 - return false; 57 - if (in_nmi()) 58 - return _on_sdei_stack(sp, size, info); 59 - 60 - return false; 61 - } 62 - 63 46 #endif /* __ASSEMBLY__ */ 64 47 #endif /* __ASM_SDEI_H */
+39 -1
arch/arm64/include/asm/stacktrace.h
··· 54 54 } 55 55 #else 56 56 static inline bool on_overflow_stack(unsigned long sp, unsigned long size, 57 - struct stack_info *info) { return false; } 57 + struct stack_info *info) 58 + { 59 + return false; 60 + } 61 + #endif 62 + 63 + #if defined(CONFIG_ARM_SDE_INTERFACE) && defined(CONFIG_VMAP_STACK) 64 + DECLARE_PER_CPU(unsigned long *, sdei_stack_normal_ptr); 65 + DECLARE_PER_CPU(unsigned long *, sdei_stack_critical_ptr); 66 + 67 + static inline bool on_sdei_normal_stack(unsigned long sp, unsigned long size, 68 + struct stack_info *info) 69 + { 70 + unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr); 71 + unsigned long high = low + SDEI_STACK_SIZE; 72 + 73 + return on_stack(sp, size, low, high, STACK_TYPE_SDEI_NORMAL, info); 74 + } 75 + 76 + static inline bool on_sdei_critical_stack(unsigned long sp, unsigned long size, 77 + struct stack_info *info) 78 + { 79 + unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr); 80 + unsigned long high = low + SDEI_STACK_SIZE; 81 + 82 + return on_stack(sp, size, low, high, STACK_TYPE_SDEI_CRITICAL, info); 83 + } 84 + #else 85 + static inline bool on_sdei_normal_stack(unsigned long sp, unsigned long size, 86 + struct stack_info *info) 87 + { 88 + return false; 89 + } 90 + 91 + static inline bool on_sdei_critical_stack(unsigned long sp, unsigned long size, 92 + struct stack_info *info) 93 + { 94 + return false; 95 + } 58 96 #endif 59 97 60 98 #endif /* __ASM_STACKTRACE_H */
-32
arch/arm64/kernel/sdei.c
··· 162 162 return err; 163 163 } 164 164 165 - static bool on_sdei_normal_stack(unsigned long sp, unsigned long size, 166 - struct stack_info *info) 167 - { 168 - unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr); 169 - unsigned long high = low + SDEI_STACK_SIZE; 170 - 171 - return on_stack(sp, size, low, high, STACK_TYPE_SDEI_NORMAL, info); 172 - } 173 - 174 - static bool on_sdei_critical_stack(unsigned long sp, unsigned long size, 175 - struct stack_info *info) 176 - { 177 - unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr); 178 - unsigned long high = low + SDEI_STACK_SIZE; 179 - 180 - return on_stack(sp, size, low, high, STACK_TYPE_SDEI_CRITICAL, info); 181 - } 182 - 183 - bool _on_sdei_stack(unsigned long sp, unsigned long size, struct stack_info *info) 184 - { 185 - if (!IS_ENABLED(CONFIG_VMAP_STACK)) 186 - return false; 187 - 188 - if (on_sdei_critical_stack(sp, size, info)) 189 - return true; 190 - 191 - if (on_sdei_normal_stack(sp, size, info)) 192 - return true; 193 - 194 - return false; 195 - } 196 - 197 165 unsigned long sdei_arch_get_entry_point(int conduit) 198 166 { 199 167 /*
+9 -2
arch/arm64/kernel/stacktrace.c
··· 86 86 return true; 87 87 if (on_overflow_stack(sp, size, info)) 88 88 return true; 89 - if (on_sdei_stack(sp, size, info)) 90 - return true; 89 + 90 + if (IS_ENABLED(CONFIG_VMAP_STACK) && 91 + IS_ENABLED(CONFIG_ARM_SDE_INTERFACE) && 92 + in_nmi()) { 93 + if (on_sdei_critical_stack(sp, size, info)) 94 + return true; 95 + if (on_sdei_normal_stack(sp, size, info)) 96 + return true; 97 + } 91 98 92 99 return false; 93 100 }