Skip to content

Commit 2f3b76e

Browse files
groeckakpm00
authored andcommitted
powerpc: add support for suppressing warning backtraces
Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT_SUPPRESS_BACKTRACE and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Alessandro Carminati <[email protected]> Tested-by: Linux Kernel Functional Testing <[email protected]> Acked-by: Dan Carpenter <[email protected]> Acked-by: Michael Ellerman <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Brendan Higgins <[email protected]> Cc: David Gow <[email protected]> Cc: Rae Moar <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Arthur Grillo <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Charlie Jenkins <[email protected]> Cc: Daniel Diaz <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Dave Airlie <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Helge Deller <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jani Nikula <[email protected]> Cc: John Paul Adrian Glaubitz <[email protected]> Cc: Kees Cook <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maíra Canal <[email protected]> Cc: Naresh Kamboju <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Rich Felker <[email protected]> Cc: Simon Horman <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Thomas Zimemrmann <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Ville Syrjala <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yoshinori Sato <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent a6dca5f commit 2f3b76e

File tree

1 file changed

+28
-9
lines changed
  • arch/powerpc/include/asm

1 file changed

+28
-9
lines changed

arch/powerpc/include/asm/bug.h

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
.section __bug_table,"aw"
1515
5001: .4byte \addr - .
1616
.4byte 5002f - .
17+
#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE
18+
.4byte 0
19+
#endif
1720
.short \line, \flags
1821
.org 5001b+BUG_ENTRY_SIZE
1922
.previous
@@ -32,30 +35,46 @@
3235
#endif /* verbose */
3336

3437
#else /* !__ASSEMBLY__ */
35-
/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
36-
sizeof(struct bug_entry), respectively */
38+
/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3,%4 to be FILE, __func__, LINE, flags
39+
and sizeof(struct bug_entry), respectively */
3740
#ifdef CONFIG_DEBUG_BUGVERBOSE
41+
42+
#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE
43+
# define HAVE_BUG_FUNCTION
44+
# define __BUG_FUNC_PTR " .4byte %1 - .\n"
45+
#else
46+
# define __BUG_FUNC_PTR
47+
#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */
48+
3849
#define _EMIT_BUG_ENTRY \
3950
".section __bug_table,\"aw\"\n" \
4051
"2: .4byte 1b - .\n" \
4152
" .4byte %0 - .\n" \
42-
" .short %1, %2\n" \
43-
".org 2b+%3\n" \
53+
__BUG_FUNC_PTR \
54+
" .short %2, %3\n" \
55+
".org 2b+%4\n" \
4456
".previous\n"
4557
#else
4658
#define _EMIT_BUG_ENTRY \
4759
".section __bug_table,\"aw\"\n" \
4860
"2: .4byte 1b - .\n" \
49-
" .short %2\n" \
50-
".org 2b+%3\n" \
61+
" .short %3\n" \
62+
".org 2b+%4\n" \
5163
".previous\n"
5264
#endif
5365

66+
#ifdef HAVE_BUG_FUNCTION
67+
# define __BUG_FUNC __func__
68+
#else
69+
# define __BUG_FUNC NULL
70+
#endif
71+
5472
#define BUG_ENTRY(insn, flags, ...) \
5573
__asm__ __volatile__( \
5674
"1: " insn "\n" \
5775
_EMIT_BUG_ENTRY \
58-
: : "i" (__FILE__), "i" (__LINE__), \
76+
: : "i" (__FILE__), "i" (__BUG_FUNC), \
77+
"i" (__LINE__), \
5978
"i" (flags), \
6079
"i" (sizeof(struct bug_entry)), \
6180
##__VA_ARGS__)
@@ -80,7 +99,7 @@
8099
if (x) \
81100
BUG(); \
82101
} else { \
83-
BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x))); \
102+
BUG_ENTRY(PPC_TLNEI " %5, 0", 0, "r" ((__force long)(x))); \
84103
} \
85104
} while (0)
86105

@@ -90,7 +109,7 @@
90109
if (__ret_warn_on) \
91110
__WARN(); \
92111
} else { \
93-
BUG_ENTRY(PPC_TLNEI " %4, 0", \
112+
BUG_ENTRY(PPC_TLNEI " %5, 0", \
94113
BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \
95114
"r" (__ret_warn_on)); \
96115
} \

0 commit comments

Comments
 (0)