arm64: define BUG() instruction without CONFIG_BUG
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
@@ -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
Hi Arnd,
Quoted 14 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]>---
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@@ -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
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_FLAGSused 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
Will Deacon
Acked-byQuoted 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_FLAGSused 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
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_FLAGSused 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:
Acked-by Will Deacon <[email protected]>
Applied. Thanks.
Signature · 1 line
Catalin
Catalin Marinas
maintainerHi Arnd,
Quoted 9 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]>
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
Quoted 8 lines · Catalin Marinas
Hi Arnd,
Quoted 5 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:
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]Signed-off-by Arnd Bergmann <[email protected]>A side-effect of this patch is that it turns WARN into BUG. I hit the
WARN_ONCEinarch/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
Catalin Marinas
maintainerQuoted 13 lines · Arnd Bergmann
Quoted 11 lines · Catalin Marinas
Hi Arnd,
Quoted 8 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]
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Arnd Bergmann <[email protected]>A side-effect of this patch is that it turns WARN into BUG. I hit the
WARN_ONCEinarch/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_BUGandCONFIG_BUGVERBOSE?
CONFIG_BUG=yCONFIG_DEBUG_BUGVERBOSE=y
(just defconfig + 64K pages)
Signature · 1 line
Catalin
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_BUGandCONFIG_BUGVERBOSE?
CONFIG_BUG=yCONFIG_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
@@ -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(); \
Catalin Marinas
maintainerQuoted 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_BUGandCONFIG_BUGVERBOSE?
CONFIG_BUG=yCONFIG_DEBUG_BUGVERBOSE=yOk, 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