mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 22:55:21 +07:00
325cdacd03
Mike Galbraith reported a situation where a WARN_ON_ONCE() call in DRM code turned into an oops. As it turns out, WARN_ON_ONCE() seems to be completely broken when called from a module. The bug was introduced with the following commit:19d436268d
("debug: Add _ONCE() logic to report_bug()") That commit changed WARN_ON_ONCE() to move its 'once' logic into the bug trap handler. It requires a writable bug table so that the BUGFLAG_DONE bit can be written to the flags to indicate the first warning has occurred. The bug table was made writable for vmlinux, which relies on vmlinux.lds.S and vmlinux.lds.h for laying out the sections. However, it wasn't made writable for modules, which rely on the ELF section header flags. Reported-by: Mike Galbraith <efault@gmx.de> Tested-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes:19d436268d
("debug: Add _ONCE() logic to report_bug()") Link: http://lkml.kernel.org/r/a53b04235a65478dd9afc51f5b329fdc65c84364.1500095401.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
95 lines
2.3 KiB
C
95 lines
2.3 KiB
C
#ifndef _PARISC_BUG_H
|
|
#define _PARISC_BUG_H
|
|
|
|
#include <linux/kernel.h> /* for BUGFLAG_TAINT */
|
|
|
|
/*
|
|
* Tell the user there is some problem.
|
|
* The offending file and line are encoded in the __bug_table section.
|
|
*/
|
|
|
|
#ifdef CONFIG_BUG
|
|
#define HAVE_ARCH_BUG
|
|
#define HAVE_ARCH_WARN_ON
|
|
|
|
/* the break instruction is used as BUG() marker. */
|
|
#define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff"
|
|
#define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */
|
|
|
|
#if defined(CONFIG_64BIT)
|
|
#define ASM_WORD_INSN ".dword\t"
|
|
#else
|
|
#define ASM_WORD_INSN ".word\t"
|
|
#endif
|
|
|
|
#ifdef CONFIG_DEBUG_BUGVERBOSE
|
|
#define BUG() \
|
|
do { \
|
|
asm volatile("\n" \
|
|
"1:\t" PARISC_BUG_BREAK_ASM "\n" \
|
|
"\t.pushsection __bug_table,\"aw\"\n" \
|
|
"2:\t" ASM_WORD_INSN "1b, %c0\n" \
|
|
"\t.short %c1, %c2\n" \
|
|
"\t.org 2b+%c3\n" \
|
|
"\t.popsection" \
|
|
: : "i" (__FILE__), "i" (__LINE__), \
|
|
"i" (0), "i" (sizeof(struct bug_entry)) ); \
|
|
unreachable(); \
|
|
} while(0)
|
|
|
|
#else
|
|
#define BUG() \
|
|
do { \
|
|
asm volatile(PARISC_BUG_BREAK_ASM : : ); \
|
|
unreachable(); \
|
|
} while(0)
|
|
#endif
|
|
|
|
#ifdef CONFIG_DEBUG_BUGVERBOSE
|
|
#define __WARN_FLAGS(flags) \
|
|
do { \
|
|
asm volatile("\n" \
|
|
"1:\t" PARISC_BUG_BREAK_ASM "\n" \
|
|
"\t.pushsection __bug_table,\"aw\"\n" \
|
|
"2:\t" ASM_WORD_INSN "1b, %c0\n" \
|
|
"\t.short %c1, %c2\n" \
|
|
"\t.org 2b+%c3\n" \
|
|
"\t.popsection" \
|
|
: : "i" (__FILE__), "i" (__LINE__), \
|
|
"i" (BUGFLAG_WARNING|(flags)), \
|
|
"i" (sizeof(struct bug_entry)) ); \
|
|
} while(0)
|
|
#else
|
|
#define __WARN_FLAGS(flags) \
|
|
do { \
|
|
asm volatile("\n" \
|
|
"1:\t" PARISC_BUG_BREAK_ASM "\n" \
|
|
"\t.pushsection __bug_table,\"aw\"\n" \
|
|
"2:\t" ASM_WORD_INSN "1b\n" \
|
|
"\t.short %c0\n" \
|
|
"\t.org 2b+%c1\n" \
|
|
"\t.popsection" \
|
|
: : "i" (BUGFLAG_WARNING|(flags)), \
|
|
"i" (sizeof(struct bug_entry)) ); \
|
|
} while(0)
|
|
#endif
|
|
|
|
|
|
#define WARN_ON(x) ({ \
|
|
int __ret_warn_on = !!(x); \
|
|
if (__builtin_constant_p(__ret_warn_on)) { \
|
|
if (__ret_warn_on) \
|
|
__WARN(); \
|
|
} else { \
|
|
if (unlikely(__ret_warn_on)) \
|
|
__WARN(); \
|
|
} \
|
|
unlikely(__ret_warn_on); \
|
|
})
|
|
|
|
#endif
|
|
|
|
#include <asm-generic/bug.h>
|
|
#endif
|
|
|