Commit 69505e3d authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Peter Zijlstra

bug: Use normal relative pointers in 'struct bug_entry'

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: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Sven Schnelle <svens@linux.ibm.com> # s390
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com> [arm64]
Link: https://lkml.kernel.org/r/f0e05be797a16f4fc2401eeb88c8450dcbe61df6.1652362951.git.jpoimboe@kernel.org
parent a7fed5c0
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14472: .string file; \ 14472: .string file; \
.popsection; \ .popsection; \
\ \
.long 14472b - 14470b; \ .long 14472b - .; \
.short line; .short line;
#else #else
#define _BUGVERBOSE_LOCATION(file, line) #define _BUGVERBOSE_LOCATION(file, line)
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define __BUG_ENTRY(flags) \ #define __BUG_ENTRY(flags) \
.pushsection __bug_table,"aw"; \ .pushsection __bug_table,"aw"; \
.align 2; \ .align 2; \
14470: .long 14471f - 14470b; \ 14470: .long 14471f - .; \
_BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
.short flags; \ .short flags; \
.popsection; \ .popsection; \
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
.macro __EMIT_BUG_ENTRY addr,file,line,flags .macro __EMIT_BUG_ENTRY addr,file,line,flags
.section __bug_table,"aw" .section __bug_table,"aw"
5001: .4byte \addr - 5001b, 5002f - 5001b 5001: .4byte \addr - .
.4byte 5002f - .
.short \line, \flags .short \line, \flags
.org 5001b+BUG_ENTRY_SIZE .org 5001b+BUG_ENTRY_SIZE
.previous .previous
...@@ -24,7 +25,7 @@ ...@@ -24,7 +25,7 @@
#else #else
.macro __EMIT_BUG_ENTRY addr,file,line,flags .macro __EMIT_BUG_ENTRY addr,file,line,flags
.section __bug_table,"aw" .section __bug_table,"aw"
5001: .4byte \addr - 5001b 5001: .4byte \addr - .
.short \flags .short \flags
.org 5001b+BUG_ENTRY_SIZE .org 5001b+BUG_ENTRY_SIZE
.previous .previous
...@@ -49,15 +50,16 @@ ...@@ -49,15 +50,16 @@
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
#define _EMIT_BUG_ENTRY \ #define _EMIT_BUG_ENTRY \
".section __bug_table,\"aw\"\n" \ ".section __bug_table,\"aw\"\n" \
"2:\t.4byte 1b - 2b, %0 - 2b\n" \ "2: .4byte 1b - .\n" \
"\t.short %1, %2\n" \ " .4byte %0 - .\n" \
" .short %1, %2\n" \
".org 2b+%3\n" \ ".org 2b+%3\n" \
".previous\n" ".previous\n"
#else #else
#define _EMIT_BUG_ENTRY \ #define _EMIT_BUG_ENTRY \
".section __bug_table,\"aw\"\n" \ ".section __bug_table,\"aw\"\n" \
"2:\t.4byte 1b - 2b\n" \ "2: .4byte 1b - .\n" \
"\t.short %2\n" \ " .short %2\n" \
".org 2b+%3\n" \ ".org 2b+%3\n" \
".previous\n" ".previous\n"
#endif #endif
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
typedef u32 bug_insn_t; typedef u32 bug_insn_t;
#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
#define __BUG_ENTRY_ADDR RISCV_INT " 1b - 2b" #define __BUG_ENTRY_ADDR RISCV_INT " 1b - ."
#define __BUG_ENTRY_FILE RISCV_INT " %0 - 2b" #define __BUG_ENTRY_FILE RISCV_INT " %0 - ."
#else #else
#define __BUG_ENTRY_ADDR RISCV_PTR " 1b" #define __BUG_ENTRY_ADDR RISCV_PTR " 1b"
#define __BUG_ENTRY_FILE RISCV_PTR " %0" #define __BUG_ENTRY_FILE RISCV_PTR " %0"
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
"1: .asciz \""__FILE__"\"\n" \ "1: .asciz \""__FILE__"\"\n" \
".previous\n" \ ".previous\n" \
".section __bug_table,\"awM\",@progbits,%2\n" \ ".section __bug_table,\"awM\",@progbits,%2\n" \
"2: .long 0b-2b,1b-2b\n" \ "2: .long 0b-.\n" \
" .long 1b-.\n" \
" .short %0,%1\n" \ " .short %0,%1\n" \
" .org 2b+%2\n" \ " .org 2b+%2\n" \
".previous\n" \ ".previous\n" \
...@@ -30,7 +31,7 @@ ...@@ -30,7 +31,7 @@
asm_inline volatile( \ asm_inline volatile( \
"0: mc 0,0\n" \ "0: mc 0,0\n" \
".section __bug_table,\"awM\",@progbits,%1\n" \ ".section __bug_table,\"awM\",@progbits,%1\n" \
"1: .long 0b-1b\n" \ "1: .long 0b-.\n" \
" .short %0\n" \ " .short %0\n" \
" .org 1b+%1\n" \ " .org 1b+%1\n" \
".previous\n" \ ".previous\n" \
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
# define __BUG_REL(val) ".long " __stringify(val) # define __BUG_REL(val) ".long " __stringify(val)
#else #else
# define __BUG_REL(val) ".long " __stringify(val) " - 2b" # define __BUG_REL(val) ".long " __stringify(val) " - ."
#endif #endif
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
......
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
CONFIG_BUG - emit BUG traps. Nothing happens without this. CONFIG_BUG - emit BUG traps. Nothing happens without this.
CONFIG_GENERIC_BUG - enable this code. CONFIG_GENERIC_BUG - enable this code.
CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit pointers relative to CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file
the containing struct bug_entry for bug_addr and file.
CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG
CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable
...@@ -53,10 +52,10 @@ extern struct bug_entry __start___bug_table[], __stop___bug_table[]; ...@@ -53,10 +52,10 @@ extern struct bug_entry __start___bug_table[], __stop___bug_table[];
static inline unsigned long bug_addr(const struct bug_entry *bug) static inline unsigned long bug_addr(const struct bug_entry *bug)
{ {
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
return bug->bug_addr; return (unsigned long)&bug->bug_addr_disp + bug->bug_addr_disp;
#else #else
return (unsigned long)bug + bug->bug_addr_disp; return bug->bug_addr;
#endif #endif
} }
...@@ -131,10 +130,10 @@ void bug_get_file_line(struct bug_entry *bug, const char **file, ...@@ -131,10 +130,10 @@ void bug_get_file_line(struct bug_entry *bug, const char **file,
unsigned int *line) unsigned int *line)
{ {
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
*file = bug->file; *file = (const char *)&bug->file_disp + bug->file_disp;
#else #else
*file = (const char *)bug + bug->file_disp; *file = bug->file;
#endif #endif
*line = bug->line; *line = bug->line;
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment