Skip to contentSkip to conversation

arm64: define BUG() instruction without CONFIG_BUG

PATCH Applied Arnd Bergmann 3 participants 10 messages Mar 14, 2017 – Mar 22, 2017 arm64

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm64: define BUG() instruction without CONFIG_BUG

This mirrors commit e9c38ceba8d9 ("ARM: 8455/1: define __BUG as asm(BUG_INSTR) without CONFIG_BUG") to make the behavior of arm64 consistent with arm and x86, and avoids lots of warnings in randconfig builds, such as:

kernel/seccomp.c: In function '__seccomp_filter':
kernel/seccomp.c:666:1: error: no return statement in function returning non-void [-Werror=return-type]

---
Originally submitted v1 on Feb 14 as a simple addition of a few lines. v2 is a new version doing the same thing with a cleaner rewrite of the file, using three lines less, after a suggested from Will Deacon.

No need to get this into v4.11 though, especially as the rewrite makes it a bit risky. Please queue this for v4.12 if you like the new version.

---
 arch/arm64/include/asm/bug.h | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)
arch/arm64/include/asm/bug.h +20 -14
index 561190d15881..bfc6021760e5 100644
@@ -20,9 +20,6 @@
 
 #include <asm/brk-imm.h>
 
-#ifdef CONFIG_GENERIC_BUG
-#define HAVE_ARCH_BUG
-
 #ifdef CONFIG_DEBUG_BUGVERBOSE
 #define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
 #define __BUGVERBOSE_LOCATION(file, line)				\
@@ -36,28 +33,37 @@
 #define _BUGVERBOSE_LOCATION(file, line)
 #endif
 
-#define _BUG_FLAGS(flags) __BUG_FLAGS(flags)
+#ifdef CONFIG_GENERIC_BUG
 
-#define __BUG_FLAGS(flags) asm volatile (		\
+#define __BUG_ENTRY(flags) 				\
 		".pushsection __bug_table,\"a\"\n\t"	\
 		".align 2\n\t"				\
 	"0:	.long 1f - 0b\n\t"			\
 _BUGVERBOSE_LOCATION(__FILE__, __LINE__)		\
 		".short " #flags "\n\t"			\
 		".popsection\n"				\
-							\
-	"1:	brk %[imm]"				\
-		:: [imm] "i" (BUG_BRK_IMM)		\
-)
+	"1:	"
+#else
+#define __BUG_ENTRY(flags) ""
+#endif
+
+#define __BUG_FLAGS(flags)				\
+	asm volatile (					\
+		__BUG_ENTRY(0)				\
+		"brk %[imm]" :: [imm] "i" (BUG_BRK_IMM)	\
+	);
 
-#define BUG() do {				\
-	_BUG_FLAGS(0);				\
-	unreachable();				\
+#define _BUG_FLAGS(flags) __BUG_FLAGS(flags)
+
+#define BUG() do {					\
+	__BUG_FLAGS(0);					\
+	unreachable();					\
 } while (0)
 
-#define __WARN_TAINT(taint) _BUG_FLAGS(BUGFLAG_TAINT(taint))
+#define __WARN_TAINT(taint) 				\
+	__BUG_FLAGS(BUGFLAG_TAINT(taint))
 
-#endif /* ! CONFIG_GENERIC_BUG */
+#define HAVE_ARCH_BUG
 
 #include <asm-generic/bug.h>
 
Signature · 1 line
2.9.0
#1 lore raw

Hi Arnd,

Quoted 14 lines · Arnd Bergmann

This mirrors commit e9c38ceba8d9 ("ARM: 8455/1: define __BUG as asm(BUG_INSTR) without CONFIG_BUG") to make the behavior of arm64 consistent with arm and x86, and avoids lots of warnings in randconfig builds, such as:

kernel/seccomp.c: In function '__seccomp_filter':
kernel/seccomp.c:666:1: error: no return statement in function returning non-void [-Werror=return-type]

---
Originally submitted v1 on Feb 14 as a simple addition of a few lines. v2 is a new version doing the same thing with a cleaner rewrite of the file, using three lines less, after a suggested from Will Deacon.

Quoted 6 lines

No need to get this into v4.11 though, especially as the rewrite makes it a bit risky. Please queue this for v4.12 if you like the new version.

---
 arch/arm64/include/asm/bug.h | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

Thanks for updating this. It looks correct to me, but I have one question below.

Quoted 38 lines
arch/arm64/include/asm/bug.h +7 -9
index 561190d15881..bfc6021760e5 100644
@@ -20,9 +20,6 @@
 
 #include <asm/brk-imm.h>
 
-#ifdef CONFIG_GENERIC_BUG
-#define HAVE_ARCH_BUG
-
 #ifdef CONFIG_DEBUG_BUGVERBOSE
 #define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
 #define __BUGVERBOSE_LOCATION(file, line)				\
@@ -36,28 +33,37 @@
 #define _BUGVERBOSE_LOCATION(file, line)
 #endif
 
-#define _BUG_FLAGS(flags) __BUG_FLAGS(flags)
+#ifdef CONFIG_GENERIC_BUG
 
-#define __BUG_FLAGS(flags) asm volatile (		\
+#define __BUG_ENTRY(flags) 				\
 		".pushsection __bug_table,\"a\"\n\t"	\
 		".align 2\n\t"				\
 	"0:	.long 1f - 0b\n\t"			\
 _BUGVERBOSE_LOCATION(__FILE__, __LINE__)		\
 		".short " #flags "\n\t"			\
 		".popsection\n"				\
-							\
-	"1:	brk %[imm]"				\
-		:: [imm] "i" (BUG_BRK_IMM)		\
-)
+	"1:	"
+#else
+#define __BUG_ENTRY(flags) ""
+#endif
+

arch/arm64/include/asm/bug.h line 56

Quoted 10 lines
arch/arm64/include/asm/bug.h +6 -3
+#define __BUG_FLAGS(flags)				\
+	asm volatile (					\
+		__BUG_ENTRY(0)				\
+		"brk %[imm]" :: [imm] "i" (BUG_BRK_IMM)	\
+	);
 
-#define BUG() do {				\
-	_BUG_FLAGS(0);				\
-	unreachable();				\
+#define _BUG_FLAGS(flags) __BUG_FLAGS(flags)

What is this for? I don't see _BUG_FLAGS used anywhere, but I could be missing some macro expansion.

Will

#2 lore raw
Quoted 8 lines · Will Deacon

arch/arm64/include/asm/bug.h line 56

Quoted 5 lines
arch/arm64/include/asm/bug.h +1 -3
-#define BUG() do {                           \
-     _BUG_FLAGS(0);                          \
-     unreachable();                          \
+#define _BUG_FLAGS(flags) __BUG_FLAGS(flags)

What is this for? I don't see _BUG_FLAGS used anywhere, but I could be missing some macro expansion.

I think I accidentally left this after removing the last user from an intermediate
version of the patch. Do you want me to send an updated version, or could you just drop this line when applying?

Arnd

Acked-by
#3 lore raw
Quoted 11 lines · Arnd Bergmann
Quoted 8 lines · Will Deacon

arch/arm64/include/asm/bug.h line 56

Quoted 5 lines
arch/arm64/include/asm/bug.h +1 -3
-#define BUG() do {                           \
-     _BUG_FLAGS(0);                          \
-     unreachable();                          \
+#define _BUG_FLAGS(flags) __BUG_FLAGS(flags)

What is this for? I don't see _BUG_FLAGS used anywhere, but I could be missing some macro expansion.

Quoted 4 lines

I think I accidentally left this after removing the last user from an intermediate
version of the patch. Do you want me to send an updated version, or could you just drop this line when applying?

I suspect Catalin can do that when he takes the patch. With that fixup:

Thanks,

Will

maintainer Applied
#4 lore raw
Quoted 12 lines · Will Deacon
Quoted 11 lines · Arnd Bergmann
Quoted 8 lines · Will Deacon

arch/arm64/include/asm/bug.h line 56

Quoted 5 lines
arch/arm64/include/asm/bug.h +1 -3
-#define BUG() do {                           \
-     _BUG_FLAGS(0);                          \
-     unreachable();                          \
+#define _BUG_FLAGS(flags) __BUG_FLAGS(flags)

What is this for? I don't see _BUG_FLAGS used anywhere, but I could be missing some macro expansion.

Quoted 8 lines
Quoted 4 lines

I think I accidentally left this after removing the last user from an intermediate
version of the patch. Do you want me to send an updated version, or could you just drop this line when applying?

I suspect Catalin can do that when he takes the patch. With that fixup:

Applied. Thanks.

Signature · 1 line
Catalin
maintainer
#5 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Quoted 9 lines · Arnd Bergmann

This mirrors commit e9c38ceba8d9 ("ARM: 8455/1: define __BUG as asm(BUG_INSTR) without CONFIG_BUG") to make the behavior of arm64 consistent with arm and x86, and avoids lots of warnings in randconfig builds, such as:

kernel/seccomp.c: In function '__seccomp_filter':
kernel/seccomp.c:666:1: error: no return statement in function returning non-void [-Werror=return-type]

A side-effect of this patch is that it turns WARN into BUG. I hit the WARN_ONCE in arch/arm64/kernel/efi.c:34 (on Juno with 64K pages) and with your patch applied, the kernel panics.

Signature · 1 line
Catalin
#6 lore raw
Quoted 8 lines · Catalin Marinas

Hi Arnd,

Quoted 5 lines · Arnd Bergmann

This mirrors commit e9c38ceba8d9 ("ARM: 8455/1: define __BUG as asm(BUG_INSTR) without CONFIG_BUG") to make the behavior of arm64 consistent with arm and x86, and avoids lots of warnings in randconfig builds, such as:

Quoted 8 lines
Quoted 4 lines

kernel/seccomp.c: In function '__seccomp_filter':
kernel/seccomp.c:666:1: error: no return statement in function returning non-void [-Werror=return-type]

A side-effect of this patch is that it turns WARN into BUG. I hit the WARN_ONCE in arch/arm64/kernel/efi.c:34 (on Juno with 64K pages) and with your patch applied, the kernel panics.

Taht was certainly not intended, and I don't see yet what exactly is going on. What is your setting for CONFIG_BUG and CONFIG_BUGVERBOSE?

Arnd

maintainer
#7 lore raw
Quoted 13 lines · Arnd Bergmann
Quoted 11 lines · Catalin Marinas

Hi Arnd,

Quoted 8 lines · Arnd Bergmann

This mirrors commit e9c38ceba8d9 ("ARM: 8455/1: define __BUG as asm(BUG_INSTR) without CONFIG_BUG") to make the behavior of arm64 consistent with arm and x86, and avoids lots of warnings in randconfig builds, such as:

kernel/seccomp.c: In function '__seccomp_filter':
kernel/seccomp.c:666:1: error: no return statement in function returning non-void [-Werror=return-type]

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

A side-effect of this patch is that it turns WARN into BUG. I hit the WARN_ONCE in arch/arm64/kernel/efi.c:34 (on Juno with 64K pages) and with your patch applied, the kernel panics.

Taht was certainly not intended, and I don't see yet what exactly is going on. What is your setting for CONFIG_BUG and CONFIG_BUGVERBOSE?

CONFIG_BUG=y
CONFIG_DEBUG_BUGVERBOSE=y

(just defconfig + 64K pages)

Signature · 1 line
Catalin
#8 lore raw
Quoted 9 lines · Catalin Marinas
Quoted 5 lines · Arnd Bergmann

On Wed, Mar 22, 2017 at 3:37 PM, Catalin Marinas
<[email protected]> wrote:

Taht was certainly not intended, and I don't see yet what exactly is going on. What is your setting for CONFIG_BUG and CONFIG_BUGVERBOSE?

CONFIG_BUG=y
CONFIG_DEBUG_BUGVERBOSE=y

Ok, I found the typo, can you just fold this in, or should I send an updated patch?

Arnd

arch/arm64/include/asm/bug.h +1 -1
index bfc6021760e5..ff030254f791 100644
@@ -49,10 +49,10 @@ _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
 
 #define __BUG_FLAGS(flags) \
  asm volatile ( \
- __BUG_ENTRY(0) \
+ __BUG_ENTRY(flags) \
  "brk %[imm]" :: [imm] "i" (BUG_BRK_IMM) \
  );
 
 #define BUG() do { \
  __BUG_FLAGS(0); \
  unreachable(); \
maintainer
#9 lore raw
Quoted 6 lines · Arnd Bergmann
Quoted 3 lines · Catalin Marinas
Quoted 2 lines · Arnd Bergmann

On Wed, Mar 22, 2017 at 3:37 PM, Catalin Marinas
<[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Taht was certainly not intended, and I don't see yet what exactly is going on. What is your setting for CONFIG_BUG and CONFIG_BUGVERBOSE?

CONFIG_BUG=y
CONFIG_DEBUG_BUGVERBOSE=y

Ok, I found the typo, can you just fold this in, or should I send an updated patch?

I'll fold it in. Thanks.

Signature · 1 line
Catalin