From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: v6: prevent gcc from reordering extended CP15 reads above is_smp() test
Date: Mon, 29 Jul 2013 11:02:43 +0100 [thread overview]
Message-ID: <20130729100243.GC32383@mudshark.cambridge.arm.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1307282012280.23852@utopia.booyaka.com>
Hi Paul,
On Sun, Jul 28, 2013 at 09:16:29PM +0100, Paul Walmsley wrote:
>
> Commit 621a0147d5c921f4cc33636ccd0602ad5d7cbfbc ("ARM: 7757/1: mm:
> don't flush icache in switch_mm with hardware broadcasting") breaks
> the boot on OMAP2430SDP with omap2plus_defconfig. Tracked to an
> undefined instruction abort from the CP15 read in
> cache_ops_need_broadcast(). It turns out that gcc reorders the
> extended CP15 read above the is_smp() test. This breaks ARM1136 r0
> cores, since they don't support several CP15 registers that later ARM
> cores do. ARM1136JF-S TRM section 3.2.1 "Register allocation" has the
> details.
Cheers for tracking this down. Interestingly, I can't reproduce this with
anything other than GCC 4.5.* tools -- 4.6+ do what we want. Still, it looks
like a valid (if not misguided) thing to do.
> diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
> index 8c25dc4..f428eb0 100644
> --- a/arch/arm/include/asm/cputype.h
> +++ b/arch/arm/include/asm/cputype.h
> @@ -89,13 +89,25 @@ extern unsigned int processor_id;
> __val; \
> })
>
> +
> +# if defined(CONFIG_CPU_V6)
> +/*
> + * The mrc in the read_cpuid_ext macro must not be reordered on ARMv6,
> + * else the compiler may move it before an is_smp() test, causing
> + * undefined instruction aborts on ARM1136 r0.
> + */
> +# define CPUID_EXT_REORDER "cc", "memory"
> +# else
> +# define CPUID_EXT_REORDER "cc"
> +# endif
> +
> #define read_cpuid_ext(ext_reg) \
> ({ \
> unsigned int __val; \
> asm("mrc p15, 0, %0, c0, " ext_reg \
> : "=r" (__val) \
> : \
> - : "cc"); \
> + : CPUID_EXT_REORDER); \
> __val; \
> })
I wouldn't worry about checking for CPU_V6. Besides, we probably need this
to be re-evaluated across barrier() when we get CPU migration on a
big-little platform anyway (we should probably also drop the
__attribute_const__ for that).
So you can just replace the "cc" (now that Nico kindly explained why those
aren't needed the other day) with "memory".
An alternative is to add barrier() between is_smp() and the read_cpuid_ext()
in all callers, adding a fake read from the stack to the latter (like I did
for the per-cpu accessor). However, this relies on fixing all callers for
very little gain, so I don't think it's worth the hassle.
I can cook a patch if you're tied up with other things -- just let me know.
Cheers,
Will
next prev parent reply other threads:[~2013-07-29 10:02 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-22 18:07 OMAP2430 SDP boot broken after Linus' rmk merge Paul Walmsley
2013-07-22 18:43 ` Russell King - ARM Linux
2013-07-22 20:07 ` Paul Walmsley
2013-07-23 7:03 ` Rajendra Nayak
2013-07-23 7:07 ` Paul Walmsley
2013-07-23 9:05 ` Rajendra Nayak
2013-07-24 13:56 ` Will Deacon
2013-07-24 14:17 ` Santosh Shilimkar
2013-07-24 14:20 ` Will Deacon
2013-07-24 14:45 ` Santosh Shilimkar
2013-07-27 4:10 ` Paul Walmsley
2013-07-27 12:22 ` Will Deacon
2013-07-28 5:38 ` Paul Walmsley
2013-07-28 5:46 ` [PATCH] ARM: v6: avoid remaining accesses to missing CP15 registers on ARM1136 r0 Paul Walmsley
2013-07-28 5:58 ` Paul Walmsley
2013-07-28 6:00 ` [PATCH v2] " Paul Walmsley
2013-07-28 19:58 ` Paul Walmsley
2013-07-28 5:43 ` [PATCH] ARM: v6: avoid read_cpuid_ext() on ARM1136r0 in cache_ops_need_broadcast() Paul Walmsley
2013-07-28 11:10 ` Will Deacon
2013-07-28 11:52 ` Russell King - ARM Linux
2013-07-28 19:56 ` Paul Walmsley
2013-07-28 19:47 ` Paul Walmsley
2013-07-28 20:16 ` [PATCH] ARM: v6: prevent gcc from reordering extended CP15 reads above is_smp() test Paul Walmsley
2013-07-29 7:30 ` Tony Lindgren
2013-07-29 10:02 ` Will Deacon [this message]
2013-07-30 10:58 ` Paul Walmsley
2013-07-30 11:32 ` [PATCH v2] ARM: v6: prevent gcc 4.5 " Paul Walmsley
2013-07-30 15:04 ` Will Deacon
2013-07-24 14:52 ` OMAP2430 SDP boot broken after Linus' rmk merge Russell King - ARM Linux
2013-07-24 15:40 ` OMAP4430 SDP boot issues.. (Was Re: OMAP2430 SDP boot broken after Linus' rmk merge) Santosh Shilimkar
2013-07-24 17:23 ` Russell King - ARM Linux
2013-07-24 18:17 ` Santosh Shilimkar
2013-07-25 6:40 ` OMAP2430 SDP boot broken after Linus' rmk merge Tomi Valkeinen
2013-07-25 6:50 ` Tomi Valkeinen
2013-07-26 22:59 ` Russell King - ARM Linux
2013-08-07 18:09 ` Paul Walmsley
2013-08-08 5:37 ` Rajendra Nayak
2013-08-08 10:20 ` Rajendra Nayak
2013-07-23 10:33 ` Jonathan Austin
2013-07-31 0:57 ` Paul Walmsley
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=20130729100243.GC32383@mudshark.cambridge.arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.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).