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