Skip to content

Commit 6584ff2

Browse files
hcahcaingomolnar
authored andcommitted
bugs/s390: Use 'cond_str' in __EMIT_BUG()
The simple thing would be to add the string as an assembly immediate input operand. Some older gcc variants cannot handle strings as immediate input operands for inline assemblies. Doing so may result in compile errors. Rewrite the s390 generic bug support very similar to arm64 and loongarch, and get rid of all input operands to fix this. [ peterz: backmerge fix and massage changelog ] [ bp: clang integrated assembler concatenates only .ascii strings: https://lore.kernel.org/r/202507020528.N0LtekXt-lkp@intel.com ] Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> # Fixed the tags section Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: linux-arch@vger.kernel.org Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: linux-s390@vger.kernel.org Link: https://lore.kernel.org/r/20250520133927.7932C19-hca@linux.ibm.com Link: https://lore.kernel.org/r/20250617135042.1878068-3-hca@linux.ibm.com
1 parent 7ce0f69 commit 6584ff2

1 file changed

Lines changed: 38 additions & 39 deletions

File tree

  • arch/s390/include/asm

arch/s390/include/asm/bug.h

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,52 @@
22
#ifndef _ASM_S390_BUG_H
33
#define _ASM_S390_BUG_H
44

5-
#include <linux/compiler.h>
5+
#include <linux/stringify.h>
66

7-
#ifdef CONFIG_BUG
7+
#ifndef CONFIG_DEBUG_BUGVERBOSE
8+
#define _BUGVERBOSE_LOCATION(file, line)
9+
#else
10+
#define __BUGVERBOSE_LOCATION(file, line) \
11+
.pushsection .rodata.str, "aMS", @progbits, 1; \
12+
10002: .ascii file "\0"; \
13+
.popsection; \
14+
\
15+
.long 10002b - .; \
16+
.short line;
17+
#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
18+
#endif
819

9-
#ifdef CONFIG_DEBUG_BUGVERBOSE
20+
#ifndef CONFIG_GENERIC_BUG
21+
#define __BUG_ENTRY(cond_str, flags)
22+
#else
23+
#define __BUG_ENTRY(cond_str, flags) \
24+
.pushsection __bug_table, "aw"; \
25+
.align 4; \
26+
10000: .long 10001f - .; \
27+
_BUGVERBOSE_LOCATION(WARN_CONDITION_STR(cond_str) __FILE__, __LINE__) \
28+
.short flags; \
29+
.popsection; \
30+
10001:
31+
#endif
1032

11-
#define __EMIT_BUG(cond_str, x) do { \
12-
asm_inline volatile( \
13-
"0: mc 0,0\n" \
14-
".section .rodata.str,\"aMS\",@progbits,1\n" \
15-
"1: .asciz \""__FILE__"\"\n" \
16-
".previous\n" \
17-
".section __bug_table,\"aw\"\n" \
18-
"2: .long 0b-.\n" \
19-
" .long 1b-.\n" \
20-
" .short %0,%1\n" \
21-
" .org 2b+%2\n" \
22-
".previous\n" \
23-
: : "i" (__LINE__), \
24-
"i" (x), \
25-
"i" (sizeof(struct bug_entry))); \
26-
} while (0)
27-
28-
#else /* CONFIG_DEBUG_BUGVERBOSE */
33+
#define ASM_BUG_FLAGS(cond_str, flags) \
34+
__BUG_ENTRY(cond_str, flags) \
35+
mc 0,0
2936

30-
#define __EMIT_BUG(cond_str, x) do { \
31-
asm_inline volatile( \
32-
"0: mc 0,0\n" \
33-
".section __bug_table,\"aw\"\n" \
34-
"1: .long 0b-.\n" \
35-
" .short %0\n" \
36-
" .org 1b+%1\n" \
37-
".previous\n" \
38-
: : "i" (x), \
39-
"i" (sizeof(struct bug_entry))); \
40-
} while (0)
37+
#define ASM_BUG() ASM_BUG_FLAGS("", 0)
4138

42-
#endif /* CONFIG_DEBUG_BUGVERBOSE */
39+
#define __BUG_FLAGS(cond_str, flags) \
40+
asm_inline volatile(__stringify(ASM_BUG_FLAGS(cond_str, flags)));
4341

44-
#define BUG() do { \
45-
__EMIT_BUG("", 0); \
46-
unreachable(); \
42+
#define __WARN_FLAGS(cond_str, flags) \
43+
do { \
44+
__BUG_FLAGS(cond_str, BUGFLAG_WARNING|(flags)); \
4745
} while (0)
4846

49-
#define __WARN_FLAGS(cond_str, flags) do { \
50-
__EMIT_BUG(cond_str, BUGFLAG_WARNING|(flags)); \
47+
#define BUG() \
48+
do { \
49+
__BUG_FLAGS("", 0); \
50+
unreachable(); \
5151
} while (0)
5252

5353
#define WARN_ON(x) ({ \
@@ -64,7 +64,6 @@
6464

6565
#define HAVE_ARCH_BUG
6666
#define HAVE_ARCH_WARN_ON
67-
#endif /* CONFIG_BUG */
6867

6968
#include <asm-generic/bug.h>
7069

0 commit comments

Comments
 (0)