From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Michael Ellerman <mpe@ellerman.id.au>
Cc: "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: WARN_ON() is buggy for 32 bit systems
Date: Wed, 26 Jan 2022 12:21:49 +0000 [thread overview]
Message-ID: <8bfa7bbe-7343-2d2f-d20b-d4789523c89c@csgroup.eu> (raw)
In-Reply-To: <20220126115616.GY1978@kadam>
Hi Dan,
Le 26/01/2022 à 12:56, Dan Carpenter a écrit :
>
> Hi Michael,
>
> Commit e432fe97f3e5 ("powerpc/bug: Cast to unsigned long before passing
> to inline asm") breaks WARN_ON() for 32 bit systems.
I think you missed commit db87a7199229 ("powerpc/bug: Remove specific
powerpc BUG_ON() and WARN_ON() on PPC32")
>
> arch/powerpc/include/asm/bug.h
> 109 #define WARN_ON(x) ({ \
> 110 bool __ret_warn_on = false; \
> 111 do { \
> 112 if (__builtin_constant_p((x))) { \
> 113 if (!(x)) \
> 114 break; \
> 115 __WARN(); \
> 116 __ret_warn_on = true; \
> 117 } else { \
> 118 __label__ __label_warn_on; \
> 119 \
> 120 WARN_ENTRY(PPC_TLNEI " %4, 0", \
> 121 BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \
> 122 __label_warn_on, \
> 123 "r" ((__force long)(x))); \
> ^^^^
> If the code is "if (WARN_ON(some_u64)) {" then the cast to long will
> truncate away the high bits so it's wrong. (Or at least that's how it
> works on x86, I'm working on a work around for Smatch to be able to
> parse this WARN_ON(). I don't know anything about PowerPC.)
The code is enclosed in a #ifdef CONFIG_PPC64, it is not used for PPC32:
/arch/powerpc/include/asm/bug.h
99 #ifdef CONFIG_PPC64
100 #define BUG_ON(x) do { \
...
109 #define WARN_ON(x) ({ \
...
132 #define HAVE_ARCH_BUG_ON
133 #define HAVE_ARCH_WARN_ON
134 #endif
Christophe
>
> 124 break; \
> 125 __label_warn_on: \
> 126 __ret_warn_on = true; \
> 127 } \
> 128 } while (0); \
> 129 unlikely(__ret_warn_on); \
> 130 })
>
> regards,
> dan carpenter
>
next prev parent reply other threads:[~2022-01-26 12:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 11:56 WARN_ON() is buggy for 32 bit systems Dan Carpenter
2022-01-26 12:21 ` Christophe Leroy [this message]
2022-01-26 13:49 ` Dan Carpenter
2022-01-27 11:10 ` Michael Ellerman
2022-01-27 13:37 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8bfa7bbe-7343-2d2f-d20b-d4789523c89c@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=dan.carpenter@oracle.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).