linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
@ 2017-03-14 21:39 Arnd Bergmann
  2017-03-20 19:09 ` Will Deacon
  2017-03-22 14:37 ` Catalin Marinas
  0 siblings, 2 replies; 10+ messages in thread
From: Arnd Bergmann @ 2017-03-14 21:39 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Arnd Bergmann, linux-arm-kernel, linux-kernel

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]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
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(-)

diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h
index 561190d15881..bfc6021760e5 100644
--- a/arch/arm64/include/asm/bug.h
+++ b/arch/arm64/include/asm/bug.h
@@ -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>
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-14 21:39 [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG Arnd Bergmann
@ 2017-03-20 19:09 ` Will Deacon
  2017-03-21 10:35   ` Arnd Bergmann
  2017-03-22 14:37 ` Catalin Marinas
  1 sibling, 1 reply; 10+ messages in thread
From: Will Deacon @ 2017-03-20 19:09 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Catalin Marinas, linux-arm-kernel, linux-kernel

Hi Arnd,

On Tue, Mar 14, 2017 at 10:39:21PM +0100, Arnd Bergmann wrote:
> 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]
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> 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(-)

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

> diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h
> index 561190d15881..bfc6021760e5 100644
> --- a/arch/arm64/include/asm/bug.h
> +++ b/arch/arm64/include/asm/bug.h
> @@ -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)

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

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-20 19:09 ` Will Deacon
@ 2017-03-21 10:35   ` Arnd Bergmann
  2017-03-21 11:51     ` Will Deacon
  0 siblings, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2017-03-21 10:35 UTC (permalink / raw)
  To: Will Deacon; +Cc: Catalin Marinas, Linux ARM, Linux Kernel Mailing List

On Mon, Mar 20, 2017 at 8:09 PM, Will Deacon <will.deacon@arm.com> wrote:

>>
>> -#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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-21 10:35   ` Arnd Bergmann
@ 2017-03-21 11:51     ` Will Deacon
  2017-03-21 14:11       ` Catalin Marinas
  0 siblings, 1 reply; 10+ messages in thread
From: Will Deacon @ 2017-03-21 11:51 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Catalin Marinas, Linux ARM, Linux Kernel Mailing List

On Tue, Mar 21, 2017 at 11:35:16AM +0100, Arnd Bergmann wrote:
> On Mon, Mar 20, 2017 at 8:09 PM, Will Deacon <will.deacon@arm.com> wrote:
> 
> >>
> >> -#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?

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

Acked-by: Will Deacon <will.deacon@arm.com>

Thanks,

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-21 11:51     ` Will Deacon
@ 2017-03-21 14:11       ` Catalin Marinas
  0 siblings, 0 replies; 10+ messages in thread
From: Catalin Marinas @ 2017-03-21 14:11 UTC (permalink / raw)
  To: Will Deacon; +Cc: Arnd Bergmann, Linux Kernel Mailing List, Linux ARM

On Tue, Mar 21, 2017 at 11:51:57AM +0000, Will Deacon wrote:
> On Tue, Mar 21, 2017 at 11:35:16AM +0100, Arnd Bergmann wrote:
> > On Mon, Mar 20, 2017 at 8:09 PM, Will Deacon <will.deacon@arm.com> wrote:
> > 
> > >>
> > >> -#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?
> 
> I suspect Catalin can do that when he takes the patch. With that fixup:
> 
> Acked-by: Will Deacon <will.deacon@arm.com>

Applied. Thanks.

-- 
Catalin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-14 21:39 [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG Arnd Bergmann
  2017-03-20 19:09 ` Will Deacon
@ 2017-03-22 14:37 ` Catalin Marinas
  2017-03-22 14:51   ` Arnd Bergmann
  1 sibling, 1 reply; 10+ messages in thread
From: Catalin Marinas @ 2017-03-22 14:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Will Deacon, linux-arm-kernel, linux-kernel

Hi Arnd,

On Tue, Mar 14, 2017 at 10:39:21PM +0100, Arnd Bergmann wrote:
> 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]
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

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.

-- 
Catalin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-22 14:37 ` Catalin Marinas
@ 2017-03-22 14:51   ` Arnd Bergmann
  2017-03-22 15:32     ` Catalin Marinas
  0 siblings, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2017-03-22 14:51 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Will Deacon, Linux ARM, Linux Kernel Mailing List

On Wed, Mar 22, 2017 at 3:37 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> Hi Arnd,
>
> On Tue, Mar 14, 2017 at 10:39:21PM +0100, Arnd Bergmann wrote:
>> 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]
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-22 14:51   ` Arnd Bergmann
@ 2017-03-22 15:32     ` Catalin Marinas
  2017-03-22 16:29       ` Arnd Bergmann
  0 siblings, 1 reply; 10+ messages in thread
From: Catalin Marinas @ 2017-03-22 15:32 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Will Deacon, Linux Kernel Mailing List, Linux ARM

On Wed, Mar 22, 2017 at 03:51:54PM +0100, Arnd Bergmann wrote:
> On Wed, Mar 22, 2017 at 3:37 PM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > Hi Arnd,
> >
> > On Tue, Mar 14, 2017 at 10:39:21PM +0100, Arnd Bergmann wrote:
> >> 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]
> >>
> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> >
> > 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)

-- 
Catalin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-22 15:32     ` Catalin Marinas
@ 2017-03-22 16:29       ` Arnd Bergmann
  2017-03-22 16:57         ` Catalin Marinas
  0 siblings, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2017-03-22 16:29 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Will Deacon, Linux Kernel Mailing List, Linux ARM

On Wed, Mar 22, 2017 at 4:32 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Wed, Mar 22, 2017 at 03:51:54PM +0100, Arnd Bergmann wrote:
>> On Wed, Mar 22, 2017 at 3:37 PM, Catalin Marinas
>> <catalin.marinas@arm.com> 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

diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h
index bfc6021760e5..ff030254f791 100644
--- a/arch/arm64/include/asm/bug.h
+++ b/arch/arm64/include/asm/bug.h
@@ -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(); \

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG
  2017-03-22 16:29       ` Arnd Bergmann
@ 2017-03-22 16:57         ` Catalin Marinas
  0 siblings, 0 replies; 10+ messages in thread
From: Catalin Marinas @ 2017-03-22 16:57 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Will Deacon, Linux Kernel Mailing List, Linux ARM

On Wed, Mar 22, 2017 at 05:29:19PM +0100, Arnd Bergmann wrote:
> On Wed, Mar 22, 2017 at 4:32 PM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > On Wed, Mar 22, 2017 at 03:51:54PM +0100, Arnd Bergmann wrote:
> >> On Wed, Mar 22, 2017 at 3:37 PM, Catalin Marinas
> >> <catalin.marinas@arm.com> 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?

I'll fold it in. Thanks.

-- 
Catalin

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-03-22 16:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14 21:39 [PATCH] [v2] arm64: define BUG() instruction without CONFIG_BUG Arnd Bergmann
2017-03-20 19:09 ` Will Deacon
2017-03-21 10:35   ` Arnd Bergmann
2017-03-21 11:51     ` Will Deacon
2017-03-21 14:11       ` Catalin Marinas
2017-03-22 14:37 ` Catalin Marinas
2017-03-22 14:51   ` Arnd Bergmann
2017-03-22 15:32     ` Catalin Marinas
2017-03-22 16:29       ` Arnd Bergmann
2017-03-22 16:57         ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).