Merge branch 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[platform/kernel/linux-starfive.git] / include / linux / compiler.h
index 043b60d..e786337 100644 (file)
@@ -185,8 +185,34 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 #endif
 
 /* Unreachable code */
+#ifdef CONFIG_STACK_VALIDATION
+#define annotate_reachable() ({                                                \
+       asm("%c0:\n\t"                                                  \
+           ".pushsection .discard.reachable\n\t"                       \
+           ".long %c0b - .\n\t"                                        \
+           ".popsection\n\t" : : "i" (__LINE__));                      \
+})
+#define annotate_unreachable() ({                                      \
+       asm("%c0:\n\t"                                                  \
+           ".pushsection .discard.unreachable\n\t"                     \
+           ".long %c0b - .\n\t"                                        \
+           ".popsection\n\t" : : "i" (__LINE__));                      \
+})
+#define ASM_UNREACHABLE                                                        \
+       "999:\n\t"                                                      \
+       ".pushsection .discard.unreachable\n\t"                         \
+       ".long 999b - .\n\t"                                            \
+       ".popsection\n\t"
+#else
+#define annotate_reachable()
+#define annotate_unreachable()
+#endif
+
+#ifndef ASM_UNREACHABLE
+# define ASM_UNREACHABLE
+#endif
 #ifndef unreachable
-# define unreachable() do { } while (1)
+# define unreachable() do { annotate_reachable(); do { } while (1); } while (0)
 #endif
 
 /*