linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kernel] powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path
@ 2017-06-14  3:01 Alexey Kardashevskiy
  2017-06-14 11:04 ` Michael Ellerman
  2017-06-16  9:49 ` [kernel] " Michael Ellerman
  0 siblings, 2 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2017-06-14  3:01 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Alexey Kardashevskiy, Benjamin Herrenschmidt, Michael Ellerman,
	Paul Mackerras, Peter Zijlstra, linux-kernel

When trapped on WARN_ON(), report_bug() is expected to return
BUG_TRAP_TYPE_WARN so the caller could increment NIP by 4 and continue.
The __builtin_constant_p() path of the PPC's WARN_ON() calls (indirectly)
__WARN_FLAGS() which has BUGFLAG_WARNING set, however the other branch
does not which makes report_bug() report a bug rather than a warning.

Fixes: 19d436268dde95389 ("debug: Add _ONCE() logic to report_bug()")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

Actually 19d436268dde95389 replaced __WARN_TAINT() with __WARN_FLAGS()
and lost BUGFLAG_TAINT() and this is not in the commit log so it is
unclear:
1) why
2) whether this particular patch should be doing
   BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)
 or
   BUGFLAG_WARNING|(flags)

Any ideas? Thanks.


---
 arch/powerpc/include/asm/bug.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index f2c562a0a427..0151af6c2a50 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -104,7 +104,7 @@
 		"1:	"PPC_TLNEI"	%4,0\n"			\
 		_EMIT_BUG_ENTRY					\
 		: : "i" (__FILE__), "i" (__LINE__),		\
-		  "i" (BUGFLAG_TAINT(TAINT_WARN)),		\
+		  "i" (BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)),\
 		  "i" (sizeof(struct bug_entry)),		\
 		  "r" (__ret_warn_on));				\
 	}							\
-- 
2.11.0

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

* Re: [PATCH kernel] powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path
  2017-06-14  3:01 [PATCH kernel] powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path Alexey Kardashevskiy
@ 2017-06-14 11:04 ` Michael Ellerman
  2017-06-15  0:00   ` Alexey Kardashevskiy
  2017-06-16  9:49 ` [kernel] " Michael Ellerman
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2017-06-14 11:04 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Alexey Kardashevskiy, Benjamin Herrenschmidt, Paul Mackerras,
	Peter Zijlstra, linux-kernel, dan.carpenter

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> When trapped on WARN_ON(), report_bug() is expected to return
> BUG_TRAP_TYPE_WARN so the caller could increment NIP by 4 and continue.
> The __builtin_constant_p() path of the PPC's WARN_ON() calls (indirectly)
> __WARN_FLAGS() which has BUGFLAG_WARNING set, however the other branch
> does not which makes report_bug() report a bug rather than a warning.
>
> Fixes: 19d436268dde95389 ("debug: Add _ONCE() logic to report_bug()")
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> Actually 19d436268dde95389 replaced __WARN_TAINT() with __WARN_FLAGS()
> and lost BUGFLAG_TAINT() and this is not in the commit log so it is
> unclear:
> 1) why

I think the rename is because previously the argument was a taint value,
whereas now it is a flags value (which is a superset of taint).

> 2) whether this particular patch should be doing
>    BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)
>  or
>    BUGFLAG_WARNING|(flags)

There is no flags here so the latter won't work AFAICS.

> Any ideas? Thanks.

Your patch looks correct to me. I assume it works?


The bug isn't introduced by 19d436268dde ("debug: Add _ONCE() logic to
report_bug()") as far as I can see.

If you check out that revision you see that BUGFLAG_TAINT still contains
BUGFLAG_WARNING:

#define BUGFLAG_TAINT(taint)	(BUGFLAG_WARNING | ((taint) << 8))

But that was removed in f26dee15103f ("debug: Avoid setting
BUGFLAG_WARNING twice"). So I think the Fixes: tag should point at that
commit.

cheers

> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> index f2c562a0a427..0151af6c2a50 100644
> --- a/arch/powerpc/include/asm/bug.h
> +++ b/arch/powerpc/include/asm/bug.h
> @@ -104,7 +104,7 @@
>  		"1:	"PPC_TLNEI"	%4,0\n"			\
>  		_EMIT_BUG_ENTRY					\
>  		: : "i" (__FILE__), "i" (__LINE__),		\
> -		  "i" (BUGFLAG_TAINT(TAINT_WARN)),		\
> +		  "i" (BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)),\
>  		  "i" (sizeof(struct bug_entry)),		\
>  		  "r" (__ret_warn_on));				\
>  	}							\
> -- 
> 2.11.0

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

* Re: [PATCH kernel] powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path
  2017-06-14 11:04 ` Michael Ellerman
@ 2017-06-15  0:00   ` Alexey Kardashevskiy
  2017-06-15  6:20     ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Kardashevskiy @ 2017-06-15  0:00 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Peter Zijlstra,
	linux-kernel, dan.carpenter

On 14/06/17 21:04, Michael Ellerman wrote:
> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> 
>> When trapped on WARN_ON(), report_bug() is expected to return
>> BUG_TRAP_TYPE_WARN so the caller could increment NIP by 4 and continue.
>> The __builtin_constant_p() path of the PPC's WARN_ON() calls (indirectly)
>> __WARN_FLAGS() which has BUGFLAG_WARNING set, however the other branch
>> does not which makes report_bug() report a bug rather than a warning.
>>
>> Fixes: 19d436268dde95389 ("debug: Add _ONCE() logic to report_bug()")
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>
>> Actually 19d436268dde95389 replaced __WARN_TAINT() with __WARN_FLAGS()
>> and lost BUGFLAG_TAINT() and this is not in the commit log so it is
>> unclear:
>> 1) why
> 
> I think the rename is because previously the argument was a taint value,
> whereas now it is a flags value (which is a superset of taint).
> 
>> 2) whether this particular patch should be doing
>>    BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)
>>  or
>>    BUGFLAG_WARNING|(flags)
> 
> There is no flags here so the latter won't work AFAICS.
> 
>> Any ideas? Thanks.
> 
> Your patch looks correct to me. I assume it works?

Yes, it does.

> 
> 
> The bug isn't introduced by 19d436268dde ("debug: Add _ONCE() logic to
> report_bug()") as far as I can see.
> 
> If you check out that revision you see that BUGFLAG_TAINT still contains
> BUGFLAG_WARNING:
> 
> #define BUGFLAG_TAINT(taint)	(BUGFLAG_WARNING | ((taint) << 8))
> 
> But that was removed in f26dee15103f ("debug: Avoid setting
> BUGFLAG_WARNING twice"). So I think the Fixes: tag should point at that
> commit.

Ah, you're right. Should I repost the patch with the updated "fixes:" clause?


> 
> cheers
> 
>> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
>> index f2c562a0a427..0151af6c2a50 100644
>> --- a/arch/powerpc/include/asm/bug.h
>> +++ b/arch/powerpc/include/asm/bug.h
>> @@ -104,7 +104,7 @@
>>  		"1:	"PPC_TLNEI"	%4,0\n"			\
>>  		_EMIT_BUG_ENTRY					\
>>  		: : "i" (__FILE__), "i" (__LINE__),		\
>> -		  "i" (BUGFLAG_TAINT(TAINT_WARN)),		\
>> +		  "i" (BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)),\
>>  		  "i" (sizeof(struct bug_entry)),		\
>>  		  "r" (__ret_warn_on));				\
>>  	}							\
>> -- 
>> 2.11.0


-- 
Alexey

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

* Re: [PATCH kernel] powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path
  2017-06-15  0:00   ` Alexey Kardashevskiy
@ 2017-06-15  6:20     ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-06-15  6:20 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Peter Zijlstra,
	linux-kernel, dan.carpenter

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> On 14/06/17 21:04, Michael Ellerman wrote:
>> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
>> 
>>> When trapped on WARN_ON(), report_bug() is expected to return
>>> BUG_TRAP_TYPE_WARN so the caller could increment NIP by 4 and continue.
>>> The __builtin_constant_p() path of the PPC's WARN_ON() calls (indirectly)
>>> __WARN_FLAGS() which has BUGFLAG_WARNING set, however the other branch
>>> does not which makes report_bug() report a bug rather than a warning.
>>>
>>> Fixes: 19d436268dde95389 ("debug: Add _ONCE() logic to report_bug()")
>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>> ---
>>>
>>> Actually 19d436268dde95389 replaced __WARN_TAINT() with __WARN_FLAGS()
>>> and lost BUGFLAG_TAINT() and this is not in the commit log so it is
>>> unclear:
>>> 1) why
>> 
>> I think the rename is because previously the argument was a taint value,
>> whereas now it is a flags value (which is a superset of taint).
>> 
>>> 2) whether this particular patch should be doing
>>>    BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)
>>>  or
>>>    BUGFLAG_WARNING|(flags)
>> 
>> There is no flags here so the latter won't work AFAICS.
>> 
>>> Any ideas? Thanks.
>> 
>> Your patch looks correct to me. I assume it works?
>
> Yes, it does.

Thanks.

>> The bug isn't introduced by 19d436268dde ("debug: Add _ONCE() logic to
>> report_bug()") as far as I can see.
>> 
>> If you check out that revision you see that BUGFLAG_TAINT still contains
>> BUGFLAG_WARNING:
>> 
>> #define BUGFLAG_TAINT(taint)	(BUGFLAG_WARNING | ((taint) << 8))
>> 
>> But that was removed in f26dee15103f ("debug: Avoid setting
>> BUGFLAG_WARNING twice"). So I think the Fixes: tag should point at that
>> commit.
>
> Ah, you're right. Should I repost the patch with the updated "fixes:" clause?

No that's fine I can update it.

cheers

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

* Re: [kernel] powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path
  2017-06-14  3:01 [PATCH kernel] powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path Alexey Kardashevskiy
  2017-06-14 11:04 ` Michael Ellerman
@ 2017-06-16  9:49 ` Michael Ellerman
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-06-16  9:49 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Alexey Kardashevskiy, linux-kernel, Peter Zijlstra, Paul Mackerras

On Wed, 2017-06-14 at 03:01:25 UTC, Alexey Kardashevskiy wrote:
> When trapped on WARN_ON(), report_bug() is expected to return
> BUG_TRAP_TYPE_WARN so the caller could increment NIP by 4 and continue.
> The __builtin_constant_p() path of the PPC's WARN_ON() calls (indirectly)
> __WARN_FLAGS() which has BUGFLAG_WARNING set, however the other branch
> does not which makes report_bug() report a bug rather than a warning.
> 
> Fixes: f26dee15103f ("debug: Avoid setting BUGFLAG_WARNING twice")
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/a093c92dc7f96a15de98ec8cfe38e6

cheers

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

end of thread, other threads:[~2017-06-16  9:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-14  3:01 [PATCH kernel] powerpc/debug: Add missing warn flag to WARN_ON's non-builtin path Alexey Kardashevskiy
2017-06-14 11:04 ` Michael Ellerman
2017-06-15  0:00   ` Alexey Kardashevskiy
2017-06-15  6:20     ` Michael Ellerman
2017-06-16  9:49 ` [kernel] " Michael Ellerman

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).