From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: linux-kernel@vger.kernel.org, npiggin@gmail.com,
Paul Mackerras <paulus@samba.org>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/bug: Remove specific powerpc BUG_ON()
Date: Thu, 11 Feb 2021 08:30:59 -0600 [thread overview]
Message-ID: <20210211143059.GE28121@gate.crashing.org> (raw)
In-Reply-To: <6126ca14-419a-9e15-7ffa-b295f26a552e@csgroup.eu>
On Thu, Feb 11, 2021 at 03:09:43PM +0100, Christophe Leroy wrote:
> Le 11/02/2021 à 12:49, Segher Boessenkool a écrit :
> >On Thu, Feb 11, 2021 at 07:41:52AM +0000, Christophe Leroy wrote:
> >>powerpc BUG_ON() is based on using twnei or tdnei instruction,
> >>which obliges gcc to format the condition into a 0 or 1 value
> >>in a register.
> >
> >Huh? Why is that?
> >
> >Will it work better if this used __builtin_trap? Or does the kernel only
> >detect very specific forms of trap instructions?
>
> We already made a try with __builtin_trap() 1,5 year ago, see
> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20510ce03cc9463f1c9e743c1d93b939de501b53.1566219503.git.christophe.leroy@c-s.fr/
>
> The main problems encountered are:
> - It is only possible to use it for BUG_ON, not for WARN_ON because GCC
> considers it as noreturn. Is there any workaround ?
A trap is noreturn by definition:
-- Built-in Function: void __builtin_trap (void)
This function causes the program to exit abnormally.
> - The kernel (With CONFIG_DEBUG_BUGVERBOSE) needs to be able to identify
> the source file and line corresponding to the trap. How can that be done
> with __builtin_trap() ?
The DWARF debug info should be sufficient. Perhaps you can post-process
some way?
You can create a trap that falls through yourself (by having a trap-on
condition with a condition that is always true, but make the compiler
not see that). This isn't efficient though.
Could you file a feature request (in bugzilla)? It is probably useful
for generic code as well, but we could implement this for powerpc only
if needed.
Segher
next prev parent reply other threads:[~2021-02-11 14:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 7:41 [PATCH] powerpc/bug: Remove specific powerpc BUG_ON() Christophe Leroy
2021-02-11 10:04 ` Nicholas Piggin
2021-02-11 11:50 ` Segher Boessenkool
2021-02-11 22:47 ` Nicholas Piggin
2021-02-11 12:22 ` Segher Boessenkool
2021-02-11 11:49 ` Segher Boessenkool
2021-02-11 12:26 ` Christophe Leroy
2021-02-11 12:39 ` Segher Boessenkool
2021-02-11 14:09 ` Christophe Leroy
2021-02-11 14:30 ` Segher Boessenkool [this message]
2021-02-11 15:30 ` Christophe Leroy
2021-02-27 10:31 ` Christophe Leroy
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=20210211143059.GE28121@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
/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).