[PATCH v2 01/12] x86: Rework __bug_table helpers

Peter Zijlstra posted 12 patches 1 month, 1 week ago
[PATCH v2 01/12] x86: Rework __bug_table helpers
Posted by Peter Zijlstra 1 month, 1 week ago
Rework the __bug_table helpers such that extension becomes easier.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/include/asm/bug.h |   37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -37,39 +37,42 @@
 #ifdef CONFIG_GENERIC_BUG
 
 #ifdef CONFIG_X86_32
-# define __BUG_REL(val)	".long " val
+#define __BUG_REL(val)		".long " val
 #else
-# define __BUG_REL(val)	".long " val " - ."
+#define __BUG_REL(val)		".long " val " - ."
 #endif
 
 #ifdef CONFIG_DEBUG_BUGVERBOSE
-#define __BUG_ENTRY(file, line, flags)					\
-	"2:\t" __BUG_REL("1b") "\t# bug_entry::bug_addr\n"		\
+#define __BUG_ENTRY_VERBOSE(file, line)					\
 	"\t" __BUG_REL(file)   "\t# bug_entry::file\n"			\
-	"\t.word " line        "\t# bug_entry::line\n"			\
-	"\t.word " flags       "\t# bug_entry::flags\n"
+	"\t.word " line        "\t# bug_entry::line\n"
 #else
-#define __BUG_ENTRY(file, line, flags)					\
-	"2:\t" __BUG_REL("1b") "\t# bug_entry::bug_addr\n"		\
-	"\t.word " flags       "\t# bug_entry::flags\n"
+#define __BUG_ENTRY_VERBOSE(file, line)
 #endif
 
+#define __BUG_ENTRY(file, line, flags)					\
+	__BUG_REL("1b")		"\t# bug_entry::bug_addr\n"		\
+	__BUG_ENTRY_VERBOSE(file, line)					\
+	"\t.word " flags	"\t# bug_entry::flags\n"
+
 #define _BUG_FLAGS_ASM(ins, file, line, flags, size, extra)		\
 	"1:\t" ins "\n"							\
-	".pushsection __bug_table,\"aw\"\n"				\
+	".pushsection __bug_table,\"aw\"\n\t"				\
 	ANNOTATE_DATA_SPECIAL						\
+	"2:\n\t"							\
 	__BUG_ENTRY(file, line, flags)					\
 	"\t.org 2b + " size "\n"					\
 	".popsection\n"							\
 	extra
 
-#define _BUG_FLAGS(cond_str, ins, flags, extra)						\
-do {											\
-	asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c0",					\
-					   "%c1", "%c2", "%c3", extra)			\
-		     : : "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__),	\
-			 "i" (flags),							\
-			 "i" (sizeof(struct bug_entry)));				\
+#define _BUG_FLAGS(cond_str, ins, flags, extra)				\
+do {									\
+	asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c0",			\
+					   "%c1", "%c2", "%c3", extra)	\
+		   : : "i" (WARN_CONDITION_STR(cond_str) __FILE__),	\
+		       "i" (__LINE__),					\
+		       "i" (flags),					\
+		       "i" (sizeof(struct bug_entry)));			\
 } while (0)
 
 #define ARCH_WARN_ASM(file, line, flags, size)				\