Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] 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.

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.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

David Woodhouse and committed by
Paul Mackerras
007d88d0 673aeb76

+32 -11
+3
arch/powerpc/kernel/asm-offsets.c
··· 303 303 DEFINE(NSEC_PER_SEC, NSEC_PER_SEC); 304 304 DEFINE(CLOCK_REALTIME_RES, TICK_NSEC); 305 305 306 + #ifdef CONFIG_BUG 307 + DEFINE(BUG_ENTRY_SIZE, sizeof(struct bug_entry)); 308 + #endif 306 309 return 0; 307 310 }
+5 -8
arch/powerpc/kernel/entry_64.S
··· 28 28 #include <asm/asm-offsets.h> 29 29 #include <asm/cputable.h> 30 30 #include <asm/firmware.h> 31 + #include <asm/bug.h> 31 32 32 33 /* 33 34 * System calls. ··· 635 634 li r0,0 636 635 mtcr r0 637 636 637 + #ifdef CONFIG_BUG 638 638 /* There is no way it is acceptable to get here with interrupts enabled, 639 639 * check it with the asm equivalent of WARN_ON 640 640 */ 641 641 lbz r0,PACASOFTIRQEN(r13) 642 642 1: tdnei r0,0 643 - .section __bug_table,"a" 644 - .llong 1b,__LINE__ + 0x1000000, 1f, 2f 645 - .previous 646 - .section .rodata,"a" 647 - 1: .asciz __FILE__ 648 - 2: .asciz "enter_rtas" 649 - .previous 650 - 643 + EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,BUGFLAG_WARNING 644 + #endif 645 + 651 646 /* Hard-disable interrupts */ 652 647 mfmsr r6 653 648 rldicl r7,r6,48,1
+24 -3
include/asm-powerpc/bug.h
··· 11 11 #define BUG_OPCODE .long 0x00b00b00 /* For asm */ 12 12 #define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */ 13 13 14 - #ifndef __ASSEMBLY__ 15 - 16 14 #ifdef CONFIG_BUG 17 15 16 + #ifdef __ASSEMBLY__ 17 + #ifdef CONFIG_DEBUG_BUGVERBOSE 18 + .macro EMIT_BUG_ENTRY addr,file,line,flags 19 + .section __bug_table,"a" 20 + 5001: PPC_LONG \addr, 5002f 21 + .short \line, \flags 22 + .org 5001b+BUG_ENTRY_SIZE 23 + .previous 24 + .section .rodata,"a" 25 + 5002: .asciz "\file" 26 + .previous 27 + .endm 28 + #else 29 + .macro EMIT_BUG_ENTRY addr,file,line,flags 30 + .section __bug_table,"a" 31 + 5001: PPC_LONG \addr 32 + .short \flags 33 + .org 5001b+BUG_ENTRY_SIZE 34 + .previous 35 + .endm 36 + #endif /* verbose */ 37 + 38 + #else /* !__ASSEMBLY__ */ 18 39 /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and 19 40 sizeof(struct bug_entry), respectively */ 20 41 #ifdef CONFIG_DEBUG_BUGVERBOSE ··· 112 91 #define HAVE_ARCH_BUG 113 92 #define HAVE_ARCH_BUG_ON 114 93 #define HAVE_ARCH_WARN_ON 115 - #endif /* CONFIG_BUG */ 116 94 #endif /* __ASSEMBLY __ */ 95 + #endif /* CONFIG_BUG */ 117 96 118 97 #include <asm-generic/bug.h> 119 98