powerpc: Allow relative pointers in bug table entries
PATCH 1/1 powerpc: Allow relative pointers in bug table entries
This enables GENERIC_BUG_RELATIVE_POINTERS on Power so that 32-bit offsets are stored in the bug entries rather than 64-bit pointers.
--- arch/powerpc/Kconfig | 4 ++++ arch/powerpc/include/asm/bug.h | 37 ++++++++++++++++++++++++++++++++-- arch/powerpc/xmon/xmon.c | 17 ++++++++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-)
arch/powerpc/Kconfig +4 -0
@@ -311,6 +311,10 @@ config GENERIC_BUG default y depends on BUG +config GENERIC_BUG_RELATIVE_POINTERS + def_bool y + depends on GENERIC_BUG + config SYS_SUPPORTS_APM_EMULATION default y if PMAC_APM_EMU bool
arch/powerpc/include/asm/bug.h +35 -2
@@ -12,7 +12,11 @@#ifdef CONFIG_DEBUG_BUGVERBOSE .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS 5001: PPC_LONG \addr, 5002f +#else +5001: .4byte \addr - 5001b, 5002f - 5001b +#endif /* CONFIG_GENERIC_BUG_RELATIVE_POINTERS */ .short \line, \flags .org 5001b+BUG_ENTRY_SIZE .previous
@@ -23,7 +27,11 @@#else .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS 5001: PPC_LONG \addr +#else +5001: .4byte \addr - 5001b +#endif /* CONFIG_GENERIC_BUG_RELATIVE_POINTERS */ .short \flags .org 5001b+BUG_ENTRY_SIZE .previous
@@ -34,20 +42,45 @@/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and sizeof(struct bug_entry), respectively */ #ifdef CONFIG_DEBUG_BUGVERBOSE +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS #define _EMIT_BUG_ENTRY \ ".section __bug_table,\"aw\"\n" \ "2:\t" PPC_LONG "1b, %0\n" \ "\t.short %1, %2\n" \ ".org 2b+%3\n" \ ".previous\n" -#else + +#else /* relative pointers */ + +#define _EMIT_BUG_ENTRY \ + ".section __bug_table,\"aw\"\n" \ + "2:\t.4byte 1b - 2b, %0 - 2b\n" \ + "\t.short %1, %2\n" \ + ".org 2b+%3\n" \ + ".previous\n" +#endif /* relative pointers */ + +#else /* verbose */ + +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS #define _EMIT_BUG_ENTRY \ ".section __bug_table,\"aw\"\n" \ "2:\t" PPC_LONG "1b\n" \ "\t.short %2\n" \ ".org 2b+%3\n" \ ".previous\n" -#endif + +#else /* relative pointers */ + +#define _EMIT_BUG_ENTRY \ + ".section __bug_table,\"aw\"\n" \ + "2:\t.4byte 1b - 2b\n" \ + "\t.short %2\n" \ + ".org 2b+%3\n" \ + ".previous\n" + +#endif /* relative pointers */ +#endif /* verbose */ #define BUG_ENTRY (insn, flags, ...) \ __asm__ __volatile__( \
arch/powerpc/xmon/xmon.c +15 -2
@@ -1731,6 +1731,9 @@ static void print_bug_trap(struct pt_regs *regs)#ifdef CONFIG_BUG const struct bug_entry *bug;unsigned long addr; +#ifdef CONFIG_DEBUG_BUGVERBOSE +char *file; +#endif if (regs->msr &MSR_PR )return ;/* not in kernel */
@@ -1744,10 +1747,20 @@ static void print_bug_trap(struct pt_regs *regs)return ;#ifdef CONFIG_DEBUG_BUGVERBOSE +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS + file = bug->file; +#else /* relative pointers */ + file = (char *)bug + bug->file_disp; +#endif /* relative pointers */ printf ("kernel BUG at %s:%u!\n" , - bug->file, bug->line); + file, bug->line);#else -printf ("kernel BUG at %px!\n" , (void *)bug->bug_addr); +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS + addr = bug->addr; +#else /* relative pointers */ + addr = (unsigned long )bug + bug->bug_addr_disp; +#endif /* relative pointers */ +printf ("kernel BUG at %px!\n" , (void *)addr);#endif #endif /* CONFIG_BUG */ }
Signature · 1 line
2.17.1
Le 27/11/2020 à 04:02, Jordan Niethe a écrit :
Quoted 30 lines
This enables
GENERIC_BUG_RELATIVE_POINTERSon Power so that 32-bit offsets are stored in the bug entries rather than 64-bit pointers.Signed-off-by Jordan Niethe <[email protected]>--- arch/powerpc/Kconfig | 4 ++++ arch/powerpc/include/asm/bug.h | 37 ++++++++++++++++++++++++++++++++-- arch/powerpc/xmon/xmon.c | 17 ++++++++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-)arch/powerpc/Kconfig +4
-0@@ -311,6 +311,10 @@ config GENERIC_BUG default y depends on BUG +config GENERIC_BUG_RELATIVE_POINTERS + def_bool y + depends on GENERIC_BUG + config SYS_SUPPORTS_APM_EMULATION default y if PMAC_APM_EMU boolarch/powerpc/include/asm/bug.h +0
-0
arch/powerpc/include/asm/bug.h line 15
Quoted 4 lines
arch/powerpc/include/asm/bug.h +1
-0@@ -12,7 +12,11 @@#ifdef CONFIG_DEBUG_BUGVERBOSE .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
As far as I understand, as soon as CONFIG_BUG is selected, GENERIC_BUG is automatically selected so GENERIC_BUG_RELATIVE_POINTERS is selected as well. Therefore this #ifndef is never possible.
arch/powerpc/include/asm/bug.h line 30
Quoted 12 lines
arch/powerpc/include/asm/bug.h +4
-05001: PPC_LONG \addr, 5002f +#else +5001: .4byte \addr - 5001b, 5002f - 5001b +#endif /* CONFIG_GENERIC_BUG_RELATIVE_POINTERS */ .short \line, \flags .org 5001b+BUG_ENTRY_SIZE .previous@@ -23,7 +27,11 @@#else .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
Same
arch/powerpc/include/asm/bug.h line 45
Quoted 12 lines
arch/powerpc/include/asm/bug.h +4
-05001: PPC_LONG \addr +#else +5001: .4byte \addr - 5001b +#endif /* CONFIG_GENERIC_BUG_RELATIVE_POINTERS */ .short \flags .org 5001b+BUG_ENTRY_SIZE .previous@@ -34,20 +42,45 @@/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and sizeof(struct bug_entry), respectively */ #ifdef CONFIG_DEBUG_BUGVERBOSE +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
Same
Quoted 11 lines
arch/powerpc/include/asm/bug.h +4
-1#define _EMIT_BUG_ENTRY \ ".section __bug_table,\"aw\"\n" \ "2:\t" PPC_LONG "1b, %0\n" \ "\t.short %1, %2\n" \ ".org 2b+%3\n" \ ".previous\n" -#else + +#else /* relative pointers */ + +#define _EMIT_BUG_ENTRY \
arch/powerpc/include/asm/bug.h line 65
Quoted 10 lines
arch/powerpc/include/asm/bug.h +10
-0+".section __bug_table,\"aw\"\n" \ +"2:\t.4byte 1b - 2b, %0 - 2b\n" \ +"\t.short %1, %2\n" \ +".org 2b+%3\n" \ + ".previous\n" +#endif /* relative pointers */ + +#else /* verbose */ + +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
Same
Quoted 37 lines
arch/powerpc/include/asm/bug.h +12
-1#define _EMIT_BUG_ENTRY \ ".section __bug_table,\"aw\"\n" \ "2:\t" PPC_LONG "1b\n" \ "\t.short %2\n" \ ".org 2b+%3\n" \ ".previous\n" -#endif + +#else /* relative pointers */ + +#define _EMIT_BUG_ENTRY \ + ".section __bug_table,\"aw\"\n" \ + "2:\t.4byte 1b - 2b\n" \ + "\t.short %2\n" \ + ".org 2b+%3\n" \ + ".previous\n" + +#endif /* relative pointers */ +#endif /* verbose */ #define BUG_ENTRY (insn, flags, ...) \ __asm__ __volatile__( \arch/powerpc/xmon/xmon.c +3
-0@@ -1731,6 +1731,9 @@ static void print_bug_trap(struct pt_regs *regs)#ifdef CONFIG_BUG const struct bug_entry *bug;unsigned long addr; +#ifdef CONFIG_DEBUG_BUGVERBOSE +char *file; +#endif if (regs->msr &MSR_PR )return ;/* not in kernel */
arch/powerpc/xmon/xmon.c static void print_bug_trap(struct pt_regs *regs) · line 1750
Quoted 4 lines
arch/powerpc/xmon/xmon.c +1
-0@@ -1744,10 +1747,20 @@ static void print_bug_trap(struct pt_regs *regs)return ;#ifdef CONFIG_DEBUG_BUGVERBOSE +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
Same
arch/powerpc/xmon/xmon.c static void print_bug_trap(struct pt_regs *regs) · line 1758
Quoted 10 lines
arch/powerpc/xmon/xmon.c +6
-2+ file = bug->file; +#else /* relative pointers */ + file = (char *)bug + bug->file_disp; +#endif /* relative pointers */ printf ("kernel BUG at %s:%u!\n" , - bug->file, bug->line); + file, bug->line);#else -printf ("kernel BUG at %px!\n" , (void *)bug->bug_addr); +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
Same
arch/powerpc/xmon/xmon.c static void print_bug_trap(struct pt_regs *regs) · line 1766
Quoted 9 lines
arch/powerpc/xmon/xmon.c +5
-0+ addr = bug->addr; +#else /* relative pointers */ + addr = (unsigned long )bug + bug->bug_addr_disp; +#endif /* relative pointers */ +printf ("kernel BUG at %px!\n" , (void *)addr);#endif #endif /* CONFIG_BUG */ }
Christophe
Quoted 33 lines · Christophe Leroy
Quoted 29 lines · Jordan Niethe
This enables
GENERIC_BUG_RELATIVE_POINTERSon Power so that 32-bit offsets are stored in the bug entries rather than 64-bit pointers.Signed-off-by Jordan Niethe <[email protected]>--- arch/powerpc/Kconfig | 4 ++++ arch/powerpc/include/asm/bug.h | 37 ++++++++++++++++++++++++++++++++-- arch/powerpc/xmon/xmon.c | 17 ++++++++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-)arch/powerpc/Kconfig +4
-0@@ -311,6 +311,10 @@ config GENERIC_BUG default y depends on BUG +config GENERIC_BUG_RELATIVE_POINTERS + def_bool y + depends on GENERIC_BUG + config SYS_SUPPORTS_APM_EMULATION default y if PMAC_APM_EMU boolarch/powerpc/include/asm/bug.h +0
-0
Quoted 8 lines
arch/powerpc/include/asm/bug.h line 15
Quoted 5 lines
arch/powerpc/include/asm/bug.h +1
-0@@ -12,7 +12,11 @@#ifdef CONFIG_DEBUG_BUGVERBOSE .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS As far as I understand, as soon as
CONFIG_BUGis selected,GENERIC_BUGis automatically selected soGENERIC_BUG_RELATIVE_POINTERSis selected as well. Therefore this #ifndef is never possible.
Thanks, you are right. I'll fix that up.
Quoted 123 lines
arch/powerpc/include/asm/bug.h line 30
Quoted 13 lines
arch/powerpc/include/asm/bug.h +4
-05001: PPC_LONG \addr, 5002f +#else +5001: .4byte \addr - 5001b, 5002f - 5001b +#endif /* CONFIG_GENERIC_BUG_RELATIVE_POINTERS */ .short \line, \flags .org 5001b+BUG_ENTRY_SIZE .previous@@ -23,7 +27,11 @@#else .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS Same
arch/powerpc/include/asm/bug.h line 45
Quoted 12 lines
arch/powerpc/include/asm/bug.h +4
-05001: PPC_LONG \addr +#else +5001: .4byte \addr - 5001b +#endif /* CONFIG_GENERIC_BUG_RELATIVE_POINTERS */ .short \flags .org 5001b+BUG_ENTRY_SIZE .previous@@ -34,20 +42,45 @@/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and sizeof(struct bug_entry), respectively */ #ifdef CONFIG_DEBUG_BUGVERBOSE +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS Same
Quoted 11 lines
arch/powerpc/include/asm/bug.h +4
-1#define _EMIT_BUG_ENTRY \ ".section __bug_table,\"aw\"\n" \ "2:\t" PPC_LONG "1b, %0\n" \ "\t.short %1, %2\n" \ ".org 2b+%3\n" \ ".previous\n" -#else + +#else /* relative pointers */ + +#define _EMIT_BUG_ENTRY \arch/powerpc/include/asm/bug.h line 65
Quoted 10 lines
arch/powerpc/include/asm/bug.h +10
-0+".section __bug_table,\"aw\"\n" \ +"2:\t.4byte 1b - 2b, %0 - 2b\n" \ +"\t.short %1, %2\n" \ +".org 2b+%3\n" \ + ".previous\n" +#endif /* relative pointers */ + +#else /* verbose */ + +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS Same
Quoted 37 lines
arch/powerpc/include/asm/bug.h +12
-1#define _EMIT_BUG_ENTRY \ ".section __bug_table,\"aw\"\n" \ "2:\t" PPC_LONG "1b\n" \ "\t.short %2\n" \ ".org 2b+%3\n" \ ".previous\n" -#endif + +#else /* relative pointers */ + +#define _EMIT_BUG_ENTRY \ + ".section __bug_table,\"aw\"\n" \ + "2:\t.4byte 1b - 2b\n" \ + "\t.short %2\n" \ + ".org 2b+%3\n" \ + ".previous\n" + +#endif /* relative pointers */ +#endif /* verbose */ #define BUG_ENTRY (insn, flags, ...) \ __asm__ __volatile__( \arch/powerpc/xmon/xmon.c +3
-0@@ -1731,6 +1731,9 @@ static void print_bug_trap(struct pt_regs *regs)#ifdef CONFIG_BUG const struct bug_entry *bug;unsigned long addr; +#ifdef CONFIG_DEBUG_BUGVERBOSE +char *file; +#endif if (regs->msr &MSR_PR )return ;/* not in kernel */ arch/powerpc/xmon/xmon.c static void print_bug_trap(struct pt_regs *regs) · line 1750
Quoted 4 lines
arch/powerpc/xmon/xmon.c +1
-0@@ -1744,10 +1747,20 @@ static void print_bug_trap(struct pt_regs *regs)return ;#ifdef CONFIG_DEBUG_BUGVERBOSE +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS Same
arch/powerpc/xmon/xmon.c static void print_bug_trap(struct pt_regs *regs) · line 1758
Quoted 10 lines
arch/powerpc/xmon/xmon.c +6
-2+ file = bug->file; +#else /* relative pointers */ + file = (char *)bug + bug->file_disp; +#endif /* relative pointers */ printf ("kernel BUG at %s:%u!\n" , - bug->file, bug->line); + file, bug->line);#else -printf ("kernel BUG at %px!\n" , (void *)bug->bug_addr); +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS Same
arch/powerpc/xmon/xmon.c static void print_bug_trap(struct pt_regs *regs) · line 1766
Quoted 9 lines
arch/powerpc/xmon/xmon.c +5
-0+ addr = bug->addr; +#else /* relative pointers */ + addr = (unsigned long )bug + bug->bug_addr_disp; +#endif /* relative pointers */ +printf ("kernel BUG at %px!\n" , (void *)addr);#endif #endif /* CONFIG_BUG */ }Christophe
Michael Ellerman
reviewerQuoted 30 lines · Christophe Leroy
Le 27/11/2020 à 04:02, Jordan Niethe a écrit :
Quoted 29 lines
This enables
GENERIC_BUG_RELATIVE_POINTERSon Power so that 32-bit offsets are stored in the bug entries rather than 64-bit pointers.Signed-off-by Jordan Niethe <[email protected]>--- arch/powerpc/Kconfig | 4 ++++ arch/powerpc/include/asm/bug.h | 37 ++++++++++++++++++++++++++++++++-- arch/powerpc/xmon/xmon.c | 17 ++++++++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-)arch/powerpc/Kconfig +4
-0@@ -311,6 +311,10 @@ config GENERIC_BUG default y depends on BUG +config GENERIC_BUG_RELATIVE_POINTERS + def_bool y + depends on GENERIC_BUG + config SYS_SUPPORTS_APM_EMULATION default y if PMAC_APM_EMU boolarch/powerpc/include/asm/bug.h +0
-0
Quoted 8 lines
arch/powerpc/include/asm/bug.h line 15
Quoted 5 lines
arch/powerpc/include/asm/bug.h +1
-0@@ -12,7 +12,11 @@#ifdef CONFIG_DEBUG_BUGVERBOSE .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS As far as I understand, as soon as
CONFIG_BUGis selected,GENERIC_BUGis automatically selected soGENERIC_BUG_RELATIVE_POINTERSis selected as well. Therefore this #ifndef is never possible.
Yeah.
There is one place in the generic code that has an ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS but that's because it has to support arches that don't select it.
In the arch code we know that it's enabled, so there should be no need for any ifdefs.
cheers
Quoted 41 lines · Michael Ellerman
Quoted 30 lines · Christophe Leroy
Quoted 29 lines · Jordan Niethe
This enables
GENERIC_BUG_RELATIVE_POINTERSon Power so that 32-bit offsets are stored in the bug entries rather than 64-bit pointers.Signed-off-by Jordan Niethe <[email protected]>--- arch/powerpc/Kconfig | 4 ++++ arch/powerpc/include/asm/bug.h | 37 ++++++++++++++++++++++++++++++++-- arch/powerpc/xmon/xmon.c | 17 ++++++++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-)arch/powerpc/Kconfig +4
-0@@ -311,6 +311,10 @@ config GENERIC_BUG default y depends on BUG +config GENERIC_BUG_RELATIVE_POINTERS + def_bool y + depends on GENERIC_BUG + config SYS_SUPPORTS_APM_EMULATION default y if PMAC_APM_EMU boolarch/powerpc/include/asm/bug.h +0
-0Quoted 8 lines
arch/powerpc/include/asm/bug.h line 15
Quoted 5 lines
arch/powerpc/include/asm/bug.h +1
-0@@ -12,7 +12,11 @@#ifdef CONFIG_DEBUG_BUGVERBOSE .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS As far as I understand, as soon as
CONFIG_BUGis selected,GENERIC_BUGis automatically selected soGENERIC_BUG_RELATIVE_POINTERSis selected as well. Therefore this #ifndef is never possible.
Quoted 7 lines
Yeah.
There is one place in the generic code that has an ifndef
CONFIG_GENERIC_BUG_RELATIVE_POINTERSbut that's because it has to support arches that don't select it.In the arch code we know that it's enabled, so there should be no need for any ifdefs.
For 32bit, pointers are 4 bytes anyway so it would be pointless to store a displacement, so won't we need some ifdefs for that?
Quoted 2 lines
cheers
Le 30/11/2020 à 02:50, Jordan Niethe a écrit :
Quoted 44 lines · Michael Ellerman
Quoted 43 lines
Quoted 30 lines · Christophe Leroy
Quoted 29 lines · Jordan Niethe
This enables
GENERIC_BUG_RELATIVE_POINTERSon Power so that 32-bit offsets are stored in the bug entries rather than 64-bit pointers.Signed-off-by Jordan Niethe <[email protected]>--- arch/powerpc/Kconfig | 4 ++++ arch/powerpc/include/asm/bug.h | 37 ++++++++++++++++++++++++++++++++-- arch/powerpc/xmon/xmon.c | 17 ++++++++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-)arch/powerpc/Kconfig +4
-0@@ -311,6 +311,10 @@ config GENERIC_BUG default y depends on BUG +config GENERIC_BUG_RELATIVE_POINTERS + def_bool y + depends on GENERIC_BUG + config SYS_SUPPORTS_APM_EMULATION default y if PMAC_APM_EMU boolarch/powerpc/include/asm/bug.h +0
-0Quoted 8 lines
arch/powerpc/include/asm/bug.h line 15
Quoted 5 lines
arch/powerpc/include/asm/bug.h +1
-0@@ -12,7 +12,11 @@#ifdef CONFIG_DEBUG_BUGVERBOSE .macro EMIT_BUG_ENTRY addr,file,line,flags .section __bug_table,"aw" +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS As far as I understand, as soon as
CONFIG_BUGis selected,GENERIC_BUGis automatically selected soGENERIC_BUG_RELATIVE_POINTERSis selected as well. Therefore this #ifndef is never possible.Yeah.
Quoted 7 lines
Quoted 5 lines
There is one place in the generic code that has an ifndef
CONFIG_GENERIC_BUG_RELATIVE_POINTERSbut that's because it has to support arches that don't select it.In the arch code we know that it's enabled, so there should be no need for any ifdefs.
For 32bit, pointers are 4 bytes anyway so it would be pointless to store a displacement, so won't we need some ifdefs for that?
I'd say it the other way round:
For 32bit, pointers are 4 bytes anyway so it would be pointless to make it different from 64bit.
We are definitely not on a performance critical path when dealing with bug entries, so I think it is better to keep a common code for PPC32 and PPC64.
Christophe