From: Keir Fraser <keir.xen@gmail.com>
To: Tim Deegan <tim@xen.org>, xen-devel@lists.xen.org
Cc: jbeulich@suse.com
Subject: Re: [PATCH] x86: mark BUG()s and assertion failures as terminal.
Date: Thu, 19 Sep 2013 15:56:50 +0100 [thread overview]
Message-ID: <CE60CF42.33DA4%keir.xen@gmail.com> (raw)
In-Reply-To: <1379601586-27173-1-git-send-email-tim@xen.org>
On 19/09/2013 15:39, "Tim Deegan" <tim@xen.org> wrote:
> This helps avoid static analysis false-positives, and might lead to
> better code density as the compiler knows it doesn't have to restore
> spilled state &c.
>
> Signed-off-by: Tim Deegan <tim@xen.org>
> ---
> xen/include/asm-x86/bug.h | 11 ++++++++---
> xen/include/xen/compiler.h | 6 ++++++
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/xen/include/asm-x86/bug.h b/xen/include/asm-x86/bug.h
> index e5dd559..956bfd2 100644
> --- a/xen/include/asm-x86/bug.h
> +++ b/xen/include/asm-x86/bug.h
> @@ -46,12 +46,17 @@ struct bug_frame {
>
>
> #define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, NULL)
> -#define BUG() BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, NULL)
> +#define BUG() do { \
> + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, NULL); \
> + unreachable(); \
> +} while (0)
>
> #define run_in_exception_handler(fn) BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0,
> NULL)
>
> -#define assert_failed(msg) \
> - BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg)
> +#define assert_failed(msg) do { \
> + BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg); \
> + unreachable(); \
> +} while (0)
>
> extern const struct bug_frame __start_bug_frames[],
> __stop_bug_frames_0[],
> diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h
> index 7009a09..7d6805c 100644
> --- a/xen/include/xen/compiler.h
> +++ b/xen/include/xen/compiler.h
> @@ -14,6 +14,12 @@
> #define always_inline __inline__ __attribute__ ((always_inline))
> #define noinline __attribute__((noinline))
>
> +#if (!defined(__clang__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5))
Do you mean for gcc-3.4 to use __builtin_unreachable()? This might be
clearer, correcter, and better match the prevailing compiler.h style, if it
was switched round to handle the __builtin_unreachable() case first.
-- Keir
> +#define unreachable() do {} while (1)
> +#else
> +#define unreachable() __builtin_unreachable()
> +#endif
> +
> #ifdef __clang__
> /* Clang can replace some vars with new automatic ones that go in .data;
> * mark all explicit-segment vars 'used' to prevent that. */
next prev parent reply other threads:[~2013-09-19 14:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-19 14:39 [PATCH] x86: mark BUG()s and assertion failures as terminal Tim Deegan
2013-09-19 14:56 ` Keir Fraser [this message]
2013-09-19 15:07 ` Tim Deegan
2013-09-19 15:10 ` Tim Deegan
2013-09-19 15:17 ` Keir Fraser
2013-09-19 15:13 ` Keir Fraser
2013-09-19 15:44 ` Andrew Cooper
2013-09-19 16:52 ` Tim Deegan
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=CE60CF42.33DA4%keir.xen@gmail.com \
--to=keir.xen@gmail.com \
--cc=jbeulich@suse.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.