From: James Hogan <jhogan@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>,
linux-mips@linux-mips.org, Paul Burton <paul.burton@mips.com>,
Maciej Rozycki <macro@mips.com>
Cc: linux-arch@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
linux-kbuild@vger.kernel.org, Vineet Gupta <vgupta@synopsys.com>,
Mikael Starvik <starvik@axis.com>,
Jesper Nilsson <jesper.nilsson@axis.com>,
Tony Luck <tony.luck@intel.com>,
Fenghua Yu <fenghua.yu@intel.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
"David S. Miller" <davem@davemloft.net>,
Christopher Li <sparse@chrisli.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Kees Cook <keescook@chromium.org>, Ingo Molnar <mingo@kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Will Deacon <will.deacon@arm.com>,
"Steven Rostedt (VMware)" <rostedt@goodmis.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-snps-arc@lists.infradead.org, linux-kern
Subject: Re: [PATCH] bug.h: Work around GCC PR82365 in BUG()
Date: Tue, 10 Apr 2018 23:48:06 +0100 [thread overview]
Message-ID: <20180410224805.GA21429@saruman> (raw)
In-Reply-To: <20171219114112.939391-1-arnd@arndb.de>
[-- Attachment #1: Type: text/plain, Size: 2572 bytes --]
Hi Arnd,
On Tue, Dec 19, 2017 at 12:39:33PM +0100, Arnd Bergmann wrote:
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index 5d595cfdb2c4..66cfdad68f7e 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -205,6 +205,15 @@
> #endif
>
> /*
> + * calling noreturn functions, __builtin_unreachable() and __builtin_trap()
> + * confuse the stack allocation in gcc, leading to overly large stack
> + * frames, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365
> + *
> + * Adding an empty inline assembly before it works around the problem
> + */
> +#define barrier_before_unreachable() asm volatile("")
> +
> +/*
> * Mark a position in code as unreachable. This can be used to
> * suppress control flow warnings after asm blocks that transfer
> * control elsewhere.
> @@ -214,7 +223,11 @@
> * unreleased. Really, we need to have autoconf for the kernel.
> */
> #define unreachable() \
> - do { annotate_unreachable(); __builtin_unreachable(); } while (0)
> + do { \
> + annotate_unreachable(); \
> + barrier_before_unreachable(); \
> + __builtin_unreachable(); \
> + } while (0)
Unfortunately this breaks microMIPS builds (e.g. MIPS
micro32r2_defconfig and micro32r2el_defconfig) on gcc 7.2, due to the
lack of .insn in the asm volatile. Because of the
__builtin_unreachable() there is no code following it. Without the empty
asm the compiler will apparently put the .insn there automatically, but
with the empty asm it doesn't. Therefore the assembler won't treat an
immediately preceeding label as pointing at 16-bit microMIPS
instructions which need the ISA bit set, i.e. bit 0 of the address.
This causes assembler errors since the branch target is treated as a
different ISA mode:
arch/mips/mm/dma-default.s:3265: Error: branch to a symbol in another ISA mode
arch/mips/mm/dma-default.s:5027: Error: branch to a symbol in another ISA mode
Due to a compiler bug on gcc 4.9.2 -> somewhere before 7.2, Paul
submitted these patches a while back:
https://patchwork.linux-mips.org/patch/13360/
https://patchwork.linux-mips.org/patch/13361/
Your patch (suitably fixed for microMIPS) would I imagine fix that issue
too (it certainly fixes the resulting link error on microMIPS builds
with an old toolchain).
Before I forward port those patches to add .insn for MIPS, is that sort
of approach (an arch specific asm/compiler-gcc.h to allow MIPS to
override barrier_before_unreachable()) an acceptable fix?
Thanks
James
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-04-10 22:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-19 11:39 [PATCH] bug.h: Work around GCC PR82365 in BUG() Arnd Bergmann
2017-12-19 11:49 ` Geert Uytterhoeven
2017-12-19 16:57 ` Vineet Gupta
2017-12-19 20:13 ` Arnd Bergmann
2017-12-19 22:38 ` Vineet Gupta
2017-12-20 9:01 ` Arnd Bergmann
2018-04-10 22:48 ` James Hogan [this message]
2018-04-11 7:30 ` Arnd Bergmann
2018-04-11 9:54 ` James Hogan
2018-04-11 10:08 ` Arnd Bergmann
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=20180410224805.GA21429@saruman \
--to=jhogan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=fenghua.yu@intel.com \
--cc=geert@linux-m68k.org \
--cc=jesper.nilsson@axis.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=macro@mips.com \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=paul.burton@mips.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sparse@chrisli.org \
--cc=starvik@axis.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vgupta@synopsys.com \
--cc=will.deacon@arm.com \
/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).