[PATCH] bug: Use normal relative pointers in 'struct bug_entry'
Michael Ellerman
mpe at ellerman.id.au
Mon May 9 05:31:14 PDT 2022
Josh Poimboeuf <jpoimboe at kernel.org> writes:
> With CONFIG_GENERIC_BUG_RELATIVE_POINTERS, the addr/file relative
> pointers are calculated weirdly: based on the beginning of the bug_entry
> struct address, rather than their respective pointer addresses.
>
> Make the relative pointers less surprising to both humans and tools by
> calculating them the normal way.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe at kernel.org>
> ---
...
> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> index ecbae1832de3..76252576d889 100644
> --- a/arch/powerpc/include/asm/bug.h
> +++ b/arch/powerpc/include/asm/bug.h
> @@ -13,7 +13,8 @@
> #ifdef CONFIG_DEBUG_BUGVERBOSE
> .macro __EMIT_BUG_ENTRY addr,file,line,flags
> .section __bug_table,"aw"
> -5001: .4byte \addr - 5001b, 5002f - 5001b
> +5001: .4byte \addr - .
> + .4byte 5002f - .
> .short \line, \flags
> .org 5001b+BUG_ENTRY_SIZE
> .previous
> @@ -24,7 +25,7 @@
> #else
> .macro __EMIT_BUG_ENTRY addr,file,line,flags
> .section __bug_table,"aw"
> -5001: .4byte \addr - 5001b
> +5001: .4byte \addr - .
> .short \flags
> .org 5001b+BUG_ENTRY_SIZE
> .previous
Embarrassingly, we have another copy of the logic, used in the C
versions, they need updating too:
diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index ecbae1832de3..3fde35fd67f8 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -49,14 +49,14 @@
#ifdef CONFIG_DEBUG_BUGVERBOSE
#define _EMIT_BUG_ENTRY \
".section __bug_table,\"aw\"\n" \
- "2:\t.4byte 1b - 2b, %0 - 2b\n" \
+ "2:\t.4byte 1b - ., %0 - .\n" \
"\t.short %1, %2\n" \
".org 2b+%3\n" \
".previous\n"
#else
#define _EMIT_BUG_ENTRY \
".section __bug_table,\"aw\"\n" \
- "2:\t.4byte 1b - 2b\n" \
+ "2:\t.4byte 1b - .\n" \
"\t.short %2\n" \
".org 2b+%3\n" \
".previous\n"
With that added it seems to be working correctly for me.
Acked-by: Michael Ellerman <mpe at ellerman.id.au> (powerpc)
cheers
More information about the linux-riscv
mailing list