Re: [PATCH 1/7] Add conditional oopsing with annotation

From
Mike Frysinger <hidden>
Date
2011-12-17 19:16:00
Also in
lkml
Reply to
David Howells, 2011-12-16
On Friday 16 December 2011 09:13:57 David Howells wrote:
quoted hunk ↗ jump to hunk
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h

+extern const void __arch_annotated_bug;
+#define arch_annotated_bug(desc)				\
+	do {							\
+		asm volatile(".globl __arch_annotated_bug\n"	\
+			     "__arch_annotated_bug:\n"		\
+			     "	ud2\n"				\
+			     : : "d" (desc));			\
+		unreachable();					\
+	} while (0)
+
+#define is_arch_annotated_bug(regs)					\
+	({ ((const void *)regs->ip == &__arch_annotated_bug) ?		\
+			(struct annotated_bug *)regs->dx : NULL; })
seems like this is making arches duplicate a bit of logic they shouldn't have 
to ... you could have asm-generic/bug.h do:

#ifdef arch_annotated_bug_fail

extern const void __arch_annotated_bug;
# define ARCH_ANNOTATED_SYM_STR CONFIG_SYMBOL_PREFIX"__arch_annotated_bug"

# define arch_annotated_bug(desc) \
	do { \
		asm volatile(".globl " ARCH_ANNOTATED_SYM ";\n" \
			ARCH_ANNOTATED_SYM_STR":\n"); \
		arch_annotated_bug_fail(desc) ; \
		unreachable(); \
	} while (0)

# define is_arch_annotated_bug(regs) \
	({ (instruction_pointer(regs) == &__arch_annotated_bug) ? \
		(struct annotated_bug *)arch_annotated_bug_struct(regs) : \
		NULL; })

#endif

so now arches have to define two small bits.  in the x86 case:
#define arch_annotated_bug_fail(desc) asm volatile("ud2;" : : "d" (desc))
#define arch_annotated_bug_struct(regs) (regs)->dx
-mike

Attachments

Thread (10 messages) 10 messages, 3 authors, last reply 2011-12-20
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help