From: Ingo Molnar <mingo@elte.hu>
To: Petr Tesarik <ptesarik@suse.cz>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
"H. Peter Anvin" <hpa@zytor.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: remove unneeded endless loop in BUG()
Date: Thu, 19 Feb 2009 19:59:35 +0100 [thread overview]
Message-ID: <20090219185935.GA21820@elte.hu> (raw)
In-Reply-To: <1235068713.15053.99.camel@nathan.suse.cz>
* Petr Tesarik <ptesarik@suse.cz> wrote:
> Since __builtin_trap() will always generate an illegal
> instruction, we can replace the explicit asm("ud2") with it.
>
> This way gcc will understand that the function never returns,
> plus it won't emit any extra instructions.
>
> Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
> +#define DO_BUG() \
> +do { \
> + __builtin_trap(); \
> + printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
> + panic("BUG!"); \
> +} while(0)
> +
> #ifdef CONFIG_DEBUG_BUGVERBOSE
>
> #ifdef CONFIG_X86_32
> @@ -14,7 +21,7 @@
>
> #define BUG() \
> do { \
> - asm volatile("1:\tud2\n" \
> + asm volatile("1:\n" \
> ".pushsection __bug_table,\"a\"\n" \
> __BUG_C0 \
> "\t.word %c1, 0\n" \
> @@ -22,15 +29,11 @@ do { \
> ".popsection" \
> : : "i" (__FILE__), "i" (__LINE__), \
> "i" (sizeof(struct bug_entry))); \
> - for (;;) ; \
> + DO_BUG(); \
the problem is that the DO_BUG() will generate the u2d
instruction into a random place where GCC puts it. It certainly
wont be in the place where the __bug_table logic above expects
it.
The result will be cryptic crashes instead of a clean BUG
message assert.
Ingo
next prev parent reply other threads:[~2009-02-19 19:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-19 18:38 [PATCH] x86: remove unneeded endless loop in BUG() Petr Tesarik
2009-02-19 18:40 ` H. Peter Anvin
2009-02-19 18:59 ` Ingo Molnar [this message]
2009-02-19 19:53 ` H. Peter Anvin
2009-02-19 20:47 ` Jeremy Fitzhardinge
2009-02-19 20:48 ` H. Peter Anvin
2009-02-20 8:28 ` Petr Tesarik
2009-02-19 20:29 ` H. Peter Anvin
2009-02-19 20:32 ` Ingo Molnar
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=20090219185935.GA21820@elte.hu \
--to=mingo@elte.hu \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ptesarik@suse.cz \
/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