Skip to content

Commit b49e578

Browse files
chleroympe
authored andcommitted
Revert "powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto"
This partly reverts commit 1e688dd. That commit aimed at optimising the code around generation of WARN_ON/BUG_ON but this leads to a lot of dead code erroneously generated by GCC. That dead code becomes a problem when we start using objtool validation because objtool will abort validation with a warning as soon as it detects unreachable code. This is because unreachable code might be the indication that objtool doesn't properly decode object text. text data bss dec hex filename 9551585 3627834 224376 13403795 cc8693 vmlinux.before 9535281 3628358 224376 13388015 cc48ef vmlinux.after Once this change is reverted, in a standard configuration (pmac32 + function tracer) the text is reduced by 16k which is around 1.7% We already had problem with it when starting to use objtool on powerpc as a replacement for recordmcount, see commit 93e3f45 ("powerpc: Fix __WARN_FLAGS() for use with Objtool") There is also a problem with at least GCC 12, on ppc64_defconfig + CONFIG_CC_OPTIMIZE_FOR_SIZE=y + CONFIG_DEBUG_SECTION_MISMATCH=y : LD .tmp_vmlinux.kallsyms1 powerpc64-linux-ld: net/ipv4/tcp_input.o:(__ex_table+0xc4): undefined reference to `.L2136' make[2]: *** [scripts/Makefile.vmlinux:36: vmlinux] Error 1 make[1]: *** [/home/chleroy/linux-powerpc/Makefile:1238: vmlinux] Error 2 Taking into account that other problems are encountered with that 'asm goto' in WARN_ON(), including build failures, keeping that change is not worth it allthough it is primarily a compiler bug. Revert it for now. mpe: Retain EMIT_WARN_ENTRY as a synonym for EMIT_BUG_ENTRY to reduce churn, as there are now nearly as many uses of EMIT_WARN_ENTRY as EMIT_BUG_ENTRY. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Acked-by: Naveen N Rao <naveen@kernel.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20230712134552.534955-1-mpe@ellerman.id.au
1 parent b59c9dc commit b49e578

File tree

2 files changed

+15
-63
lines changed

2 files changed

+15
-63
lines changed

arch/powerpc/include/asm/bug.h

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
#ifdef __KERNEL__
55

66
#include <asm/asm-compat.h>
7-
#include <asm/extable.h>
87

98
#ifdef CONFIG_BUG
109

1110
#ifdef __ASSEMBLY__
1211
#include <asm/asm-offsets.h>
1312
#ifdef CONFIG_DEBUG_BUGVERBOSE
14-
.macro __EMIT_BUG_ENTRY addr,file,line,flags
13+
.macro EMIT_BUG_ENTRY addr,file,line,flags
1514
.section __bug_table,"aw"
1615
5001: .4byte \addr - .
1716
.4byte 5002f - .
@@ -23,7 +22,7 @@
2322
.previous
2423
.endm
2524
#else
26-
.macro __EMIT_BUG_ENTRY addr,file,line,flags
25+
.macro EMIT_BUG_ENTRY addr,file,line,flags
2726
.section __bug_table,"aw"
2827
5001: .4byte \addr - .
2928
.short \flags
@@ -32,18 +31,6 @@
3231
.endm
3332
#endif /* verbose */
3433

35-
.macro EMIT_WARN_ENTRY addr,file,line,flags
36-
EX_TABLE(\addr,\addr+4)
37-
__EMIT_BUG_ENTRY \addr,\file,\line,\flags
38-
.endm
39-
40-
.macro EMIT_BUG_ENTRY addr,file,line,flags
41-
.if \flags & 1 /* BUGFLAG_WARNING */
42-
.err /* Use EMIT_WARN_ENTRY for warnings */
43-
.endif
44-
__EMIT_BUG_ENTRY \addr,\file,\line,\flags
45-
.endm
46-
4734
#else /* !__ASSEMBLY__ */
4835
/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
4936
sizeof(struct bug_entry), respectively */
@@ -73,16 +60,6 @@
7360
"i" (sizeof(struct bug_entry)), \
7461
##__VA_ARGS__)
7562

76-
#define WARN_ENTRY(insn, flags, label, ...) \
77-
asm_volatile_goto( \
78-
"1: " insn "\n" \
79-
EX_TABLE(1b, %l[label]) \
80-
_EMIT_BUG_ENTRY \
81-
: : "i" (__FILE__), "i" (__LINE__), \
82-
"i" (flags), \
83-
"i" (sizeof(struct bug_entry)), \
84-
##__VA_ARGS__ : : label)
85-
8663
/*
8764
* BUG_ON() and WARN_ON() do their best to cooperate with compile-time
8865
* optimisations. However depending on the complexity of the condition
@@ -95,16 +72,7 @@
9572
} while (0)
9673
#define HAVE_ARCH_BUG
9774

98-
#define __WARN_FLAGS(flags) do { \
99-
__label__ __label_warn_on; \
100-
\
101-
WARN_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags), __label_warn_on); \
102-
barrier_before_unreachable(); \
103-
__builtin_unreachable(); \
104-
\
105-
__label_warn_on: \
106-
break; \
107-
} while (0)
75+
#define __WARN_FLAGS(flags) BUG_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags))
10876

10977
#ifdef CONFIG_PPC64
11078
#define BUG_ON(x) do { \
@@ -117,25 +85,15 @@ __label_warn_on: \
11785
} while (0)
11886

11987
#define WARN_ON(x) ({ \
120-
bool __ret_warn_on = false; \
121-
do { \
122-
if (__builtin_constant_p((x))) { \
123-
if (!(x)) \
124-
break; \
88+
int __ret_warn_on = !!(x); \
89+
if (__builtin_constant_p(__ret_warn_on)) { \
90+
if (__ret_warn_on) \
12591
__WARN(); \
126-
__ret_warn_on = true; \
127-
} else { \
128-
__label__ __label_warn_on; \
129-
\
130-
WARN_ENTRY(PPC_TLNEI " %4, 0", \
131-
BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \
132-
__label_warn_on, \
133-
"r" ((__force long)(x))); \
134-
break; \
135-
__label_warn_on: \
136-
__ret_warn_on = true; \
137-
} \
138-
} while (0); \
92+
} else { \
93+
BUG_ENTRY(PPC_TLNEI " %4, 0", \
94+
BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \
95+
"r" (__ret_warn_on)); \
96+
} \
13997
unlikely(__ret_warn_on); \
14098
})
14199

@@ -148,14 +106,13 @@ __label_warn_on: \
148106
#ifdef __ASSEMBLY__
149107
.macro EMIT_BUG_ENTRY addr,file,line,flags
150108
.endm
151-
.macro EMIT_WARN_ENTRY addr,file,line,flags
152-
.endm
153109
#else /* !__ASSEMBLY__ */
154110
#define _EMIT_BUG_ENTRY
155-
#define _EMIT_WARN_ENTRY
156111
#endif
157112
#endif /* CONFIG_BUG */
158113

114+
#define EMIT_WARN_ENTRY EMIT_BUG_ENTRY
115+
159116
#include <asm-generic/bug.h>
160117

161118
#ifndef __ASSEMBLY__

arch/powerpc/kernel/traps.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,13 +1508,8 @@ static void do_program_check(struct pt_regs *regs)
15081508

15091509
if (!(regs->msr & MSR_PR) && /* not user-mode */
15101510
report_bug(bugaddr, regs) == BUG_TRAP_TYPE_WARN) {
1511-
const struct exception_table_entry *entry;
1512-
1513-
entry = search_exception_tables(bugaddr);
1514-
if (entry) {
1515-
regs_set_return_ip(regs, extable_fixup(entry) + regs->nip - bugaddr);
1516-
return;
1517-
}
1511+
regs_add_return_ip(regs, 4);
1512+
return;
15181513
}
15191514

15201515
if (cpu_has_feature(CPU_FTR_DEXCR_NPHIE) && user_mode(regs)) {

0 commit comments

Comments
 (0)