arm64: define BUG() instruction without CONFIG_BUG
PATCH 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]
--- arch/arm64/include/asm/bug.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm64/include/asm/bug.h +10 -1
@@ -20,9 +20,10 @@#include <asm/brk-imm.h> -#ifdef CONFIG_GENERIC_BUG #define HAVE_ARCH_BUG +#ifdef CONFIG_GENERIC_BUG +#ifdef CONFIG_DEBUG_BUGVERBOSE #define _BUGVERBOSE_LOCATION (file, line) __BUGVERBOSE_LOCATION(file, line)#define __BUGVERBOSE_LOCATION (file, line) \
@@ -57,6 +58,14 @@ _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \#define __WARN_TAINT (taint) _BUG_FLAGS(BUGFLAG_TAINT(taint)) +#else + +#define BUG () do { \ + asm volatile("brk %[imm]" \ + :: [imm] "i" (BUG_BRK_IMM)); \ + unreachable(); \ +} while (0) +#endif /* ! CONFIG_GENERIC_BUG */ #include <asm-generic/bug.h>
Signature · 1 line
2.9.0
Quoted 30 lines · Arnd Bergmann
This mirrors commit
e9c38ceba8d9("ARM: 8455/1: define__BUGasasm(BUG_INSTR)withoutCONFIG_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]Signed-off-by Arnd Bergmann <[email protected]>--- arch/arm64/include/asm/bug.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)arch/arm64/include/asm/bug.h +2
-1@@ -20,9 +20,10 @@#include <asm/brk-imm.h> -#ifdef CONFIG_GENERIC_BUG #define HAVE_ARCH_BUG +#ifdef CONFIG_GENERIC_BUG +#ifdef CONFIG_DEBUG_BUGVERBOSE #define _BUGVERBOSE_LOCATION (file, line) __BUGVERBOSE_LOCATION(file, line)#define __BUGVERBOSE_LOCATION (file, line) \
arch/arm64/include/asm/bug.h _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ · line 67
Quoted 10 lines
arch/arm64/include/asm/bug.h +7
-0@@ -57,6 +58,14 @@ _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \#define __WARN_TAINT (taint) _BUG_FLAGS(BUGFLAG_TAINT(taint)) +#else + +#define BUG () do { \ + asm volatile("brk %[imm]" \ + :: [imm] "i" (BUG_BRK_IMM)); \ + unreachable(); \ +} while (0)
Do we need to duplicate the asm, or can we reuse the existing BUG definition in this header? The only extra thing we do is push a __bug_table entry, but I can't see why that would be a problem.
Will
Quoted 5 lines · Will Deacon
Quoted 4 lines · Arnd Bergmann
arch/arm64/include/asm/bug.h +0
-0@@ -57,6 +58,14 @@ _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \#define __WARN_TAINT (taint) _BUG_FLAGS(BUGFLAG_TAINT(taint))
Quoted 11 lines
arch/arm64/include/asm/bug.h _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ · line 67
Quoted 7 lines
arch/arm64/include/asm/bug.h +7
-0+#else + +#define BUG () do { \ + asm volatile("brk %[imm]" \ + :: [imm] "i" (BUG_BRK_IMM)); \ + unreachable(); \ +} while (0)Do we need to duplicate the asm, or can we reuse the existing BUG definition in this header? The only extra thing we do is push a
__bug_tableentry, but I can't see why that would be a problem.
The only reason for turning off CONFIG_BUG is to save a little extra space in the kernel image, so I think we really don't want the __bug_table to be generated.
However, we could split the existing asm in two and have only one definition for the asm containing the brk instruction.
Arnd