lkml.org 
[lkml]   [2011]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 1/7] Add conditional oopsing with annotation
Date
On Friday 16 December 2011 09:13:57 David Howells wrote:
> --- 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
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2011-12-17 20:19    [W:0.099 / U:2.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site