Fix manual assembly WARN_ON() in enter_rtas().
PATCH 1/1 Fix manual assembly WARN_ON() in enter_rtas().
When we switched over to the generic BUG mechanism we forgot to change the assembly code which open-codes a WARN_ON() in enter_rtas(), so the bug table got corrupted.
This patch provides an EMIT_BUG_ENTRY macro for use in assembly code, and uses it in entry_64.S. Tested with CONFIG_DEBUG_BUGVERBOSE on ppc64 but not without -- I tried to turn it off but it wouldn't go away; I suspect Aunt Tillie probably needed it.
arch/powerpc/kernel/asm-offsets.c +3 -0
@@ -303,5 +303,8 @@ int main(void)DEFINE (NSEC_PER_SEC ,NSEC_PER_SEC );DEFINE (CLOCK_REALTIME_RES ,TICK_NSEC ); +#ifdef CONFIG_BUG +DEFINE (BUG_ENTRY_SIZE ,sizeof (struct bug_entry )); +#endif return 0 ; }
arch/powerpc/kernel/entry_64.S +5 -8
@@ -28,6 +28,7 @@ #include <asm/asm-offsets.h> #include <asm/cputable.h> #include <asm/firmware.h> +#include <asm/bug.h> /* * System calls.
@@ -634,19 +635,15 @@ _GLOBAL(enter_rtas) li r0,0 mtcr r0 +#ifdef CONFIG_BUG /* There is no way it is acceptable to get here with interrupts enabled, * check it with the asm equivalent of WARN_ON */ lbz r0,PACASOFTIRQEN(r13) 1: tdnei r0,0 -.section __bug_table,"a" - .llong 1b,__LINE__ + 0x1000000, 1f, 2f -.previous -.section .rodata,"a" -1: .asciz __FILE__ -2: .asciz "enter_rtas" -.previous - + EMIT_BUG_ENTRY 1b,BUGFLAG_WARNING +#endif + /* Hard-disable interrupts */ mfmsr r6 rldicl r7,r6,48,1
include/asm-powerpc/bug.h +26 -3
@@ -11,10 +11,33 @@#define BUG_OPCODE .long 0x00b00b00/* For asm */ #define BUG_ILLEGAL_INSTR "0x00b00b00"/* For BUG macro */ -#ifndef __ASSEMBLY__ -#ifdef CONFIG_BUG +#ifdef __ASSEMBLY__ +/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and +sizeof(struct bug_entry), respectively */ +#ifdef CONFIG_DEBUG_BUGVERBOSE +.macro EMIT_BUG_ENTRY addr,flags + .section __bug_table,"a" +5001: PPC_LONG \addr, 5002f + .short __LINE__, \flags + .org 5001b+BUG_ENTRY_SIZE + .previous + .section .rodata,"a" +5002: .asciz __FILE__ + .previous +.endm +#else +.macro EMIT_BUG_ENTRY addr,flags + .section __bug_table,"a" +5001: PPC_LONG \addr + .short \flags + .org 5001b+BUG_ENTRY_SIZE + .previous +.endm +#endif /* verbose */ + +#else /* !__ASSEMBLY__ */ /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and sizeof(struct bug_entry), respectively */ #ifdef CONFIG_DEBUG_BUGVERBOSE
@@ -91,8 +114,8 @@#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG_ON #define HAVE_ARCH_WARN_ON -#endif /* CONFIG_BUG */ #endif /* __ASSEMBLY __ */ +#endif /* CONFIG_BUG */ #include <asm-generic/bug.h>
Signature · 1 line
dwmw2
Quoted 8 lines · David Woodhouse
When we switched over to the generic BUG mechanism we forgot to change the assembly code which open-codes a
WARN_ON()inenter_rtas(), so the bug table got corrupted.This patch provides an
EMIT_BUG_ENTRYmacro for use in assembly code, and uses it inentry_64.S. Tested withCONFIG_DEBUG_BUGVERBOSEon ppc64 but not without -- I tried to turn it off but it wouldn't go away; I suspect Aunt Tillie probably needed it.
This version gets __FILE__ and __LINE__ right in the assembly version -- rather than saying include/asm-powerpc/bug.h line 21 every time which is a little suboptimal.
arch/powerpc/kernel/asm-offsets.c +3 -0
@@ -303,5 +303,8 @@ int main(void)DEFINE (NSEC_PER_SEC ,NSEC_PER_SEC );DEFINE (CLOCK_REALTIME_RES ,TICK_NSEC ); +#ifdef CONFIG_BUG +DEFINE (BUG_ENTRY_SIZE ,sizeof (struct bug_entry )); +#endif return 0 ; }
arch/powerpc/kernel/entry_64.S +5 -8
@@ -28,6 +28,7 @@ #include <asm/asm-offsets.h> #include <asm/cputable.h> #include <asm/firmware.h> +#include <asm/bug.h> /* * System calls.
@@ -634,19 +635,15 @@ _GLOBAL(enter_rtas) li r0,0 mtcr r0 +#ifdef CONFIG_BUG /* There is no way it is acceptable to get here with interrupts enabled, * check it with the asm equivalent of WARN_ON */ lbz r0,PACASOFTIRQEN(r13) 1: tdnei r0,0 -.section __bug_table,"a" - .llong 1b,__LINE__ + 0x1000000, 1f, 2f -.previous -.section .rodata,"a" -1: .asciz __FILE__ -2: .asciz "enter_rtas" -.previous - + EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,BUGFLAG_WARNING +#endif + /* Hard-disable interrupts */ mfmsr r6 rldicl r7,r6,48,1
include/asm-powerpc/bug.h +24 -3
@@ -11,10 +11,31 @@#define BUG_OPCODE .long 0x00b00b00/* For asm */ #define BUG_ILLEGAL_INSTR "0x00b00b00"/* For BUG macro */ -#ifndef __ASSEMBLY__ -#ifdef CONFIG_BUG +#ifdef __ASSEMBLY__ +#ifdef CONFIG_DEBUG_BUGVERBOSE +.macro EMIT_BUG_ENTRY addr,file,line,flags + .section __bug_table,"a" +5001: PPC_LONG \addr, 5002f + .short \line, \flags + .org 5001b+BUG_ENTRY_SIZE + .previous + .section .rodata,"a" +5002: .asciz "\file" + .previous +.endm +#else + .macro EMIT_BUG_ENTRY addr,file,line,flags + .section __bug_table,"a" +5001: PPC_LONG \addr + .short \flags + .org 5001b+BUG_ENTRY_SIZE + .previous +.endm +#endif /* verbose */ + +#else /* !__ASSEMBLY__ */ /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and sizeof(struct bug_entry), respectively */ #ifdef CONFIG_DEBUG_BUGVERBOSE
@@ -91,8 +112,8 @@#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG_ON #define HAVE_ARCH_WARN_ON -#endif /* CONFIG_BUG */ #endif /* __ASSEMBLY __ */ +#endif /* CONFIG_BUG */ #include <asm-generic/bug.h>
Signature · 1 line
dwmw2