From: Mark Charlebois <charlebm@gmail.com>
To: Will Deacon <will.deacon@arm.com>
Cc: "behanw@converseincode.com" <behanw@converseincode.com>,
"anderson@redhat.com" <anderson@redhat.com>,
Catalin Marinas <Catalin.Marinas@arm.com>,
"cl@linux.com" <cl@linux.com>,
"cov@codeaurora.org" <cov@codeaurora.org>,
"jays.lee@samsung.com" <jays.lee@samsung.com>,
"msalter@redhat.com" <msalter@redhat.com>,
"sandeepa.prabhu@linaro.org" <sandeepa.prabhu@linaro.org>,
"srivatsa.bhat@linux.vnet.ibm.com"
<srivatsa.bhat@linux.vnet.ibm.com>,
"steve.capper@linaro.org" <steve.capper@linaro.org>,
Sudeep Holla <Sudeep.Holla@arm.com>,
"takahiro.akashi@linaro.org" <takahiro.akashi@linaro.org>,
"Vijaya.Kumar@caviumnetworks.com"
<Vijaya.Kumar@caviumnetworks.com>,
"a.p.zijlstra@chello.nl" <a.p.zijlstra@chello.nl>,
"acme@kernel.org" <acme@kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
Marc Zyngier <Marc.Zyngier@arm.com>,
Matthew Leach <Matthew.Leach@arm.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"olof@lixom.net" <olof@lixom.net>,
"paulus@samba.org" <paulus@samba.org>
Subject: Re: [PATCH] arm64: LLVMLinux: Fix inline arm64 assembly for use with clang
Date: Mon, 8 Sep 2014 11:35:47 -0700 [thread overview]
Message-ID: <CAFzeTN2Q-RkOeDx4jG5jiEtiN7i+gkfmyvBC1b3B1wpDPUDdxw@mail.gmail.com> (raw)
In-Reply-To: <20140908105307.GF26030@arm.com>
When I compile
int main()
{
u64 foo, tmp;
// This works for both clang and gcc
asm volatile(
" mrs %0, mair_el1\n"
" bfi %0, %1, %2, #8\n"
" msr mair_el1, %0\n"
" isb\n"
: "=&r" (tmp)
: "r" (foo), "i" (MT_NORMAL * 8));
}
with clang I get:
00000000004004f0 <main>:
4004f0: d538a208 mrs x8, mair_el1
4004f4: b3601d08 bfi x8, x8, #32, #8
4004f8: d518a208 msr mair_el1, x8
4004fc: d5033fdf isb
400500: 2a1f03e0 mov w0, wzr
400504: d65f03c0 ret
When I compile it with GCC I get:
0000000000400510 <main>:
400510: d10043ff sub sp, sp, #0x10
400514: f94003e1 ldr x1, [sp]
400518: d538a200 mrs x0, mair_el1
40051c: b3601c20 bfi x0, x1, #32, #8
400520: d518a200 msr mair_el1, x0
400524: d5033fdf isb
400528: f90007e0 str x0, [sp,#8]
40052c: 910043ff add sp, sp, #0x10
400530: d65f03c0 ret
When I compile
int main()
{
u64 foo, tmp;
// This fails for clang but not gcc
asm volatile(
" mrs %0, mair_el1\n"
" bfi %0, %1, #%2, #8\n"
" msr mair_el1, %0\n"
" isb\n"
: "=&r" (tmp)
: "r" (foo), "i" (MT_NORMAL * 8));
}
Clang fails and GCC generates:
00000000004004f0 <main>:
4004f0: d538a208 mrs x8, mair_el1
4004f4: b3601d08 bfi x8, x8, #32, #8
4004f8: d518a208 msr mair_el1, x8
4004fc: d5033fdf isb
400500: 2a1f03e0 mov w0, wzr
400504: d65f03c0 ret
On Mon, Sep 8, 2014 at 3:53 AM, Will Deacon <will.deacon@arm.com> wrote:
> On Sat, Sep 06, 2014 at 12:24:20AM +0100, behanw@converseincode.com wrote:
>> From: Mark Charlebois <charlebm@gmail.com>
>>
>> Fix variable types for 64-bit inline assembly.
>>
>> This patch now works with both gcc and clang.
>
> Really? This looks like something the clang needs to do better on, as I
> really don't see people adding these casts to future code. They're ugly and
> redundant (or GCC).
>
> This hunk:
>
>> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
>> index c555672..6894ef3 100644
>> --- a/arch/arm64/mm/mmu.c
>> +++ b/arch/arm64/mm/mmu.c
>> @@ -94,7 +94,7 @@ static int __init early_cachepolicy(char *p)
>> */
>> asm volatile(
>> " mrs %0, mair_el1\n"
>> - " bfi %0, %1, #%2, #8\n"
>> + " bfi %0, %1, %2, #8\n"
>> " msr mair_el1, %0\n"
>> " isb\n"
>> : "=&r" (tmp)
>
> also looks fishy. Does gas accept that without the '#' prefix?
>
> Will
next prev parent reply other threads:[~2014-09-08 18:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 23:24 [PATCH] arm64: LLVMLinux: Fix inline arm64 assembly for use with clang behanw
2014-09-08 9:30 ` Olof Johansson
2014-09-10 17:38 ` Will Deacon
2014-09-10 17:49 ` Ard Biesheuvel
2014-09-08 10:53 ` Will Deacon
2014-09-08 18:35 ` Mark Charlebois [this message]
2014-09-09 10:15 ` Will Deacon
2014-09-15 5:30 ` behanw
2014-09-15 16:02 ` Will Deacon
2014-09-15 16:26 ` Catalin Marinas
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=CAFzeTN2Q-RkOeDx4jG5jiEtiN7i+gkfmyvBC1b3B1wpDPUDdxw@mail.gmail.com \
--to=charlebm@gmail.com \
--cc=Catalin.Marinas@arm.com \
--cc=Lorenzo.Pieralisi@arm.com \
--cc=Marc.Zyngier@arm.com \
--cc=Matthew.Leach@arm.com \
--cc=Sudeep.Holla@arm.com \
--cc=Vijaya.Kumar@caviumnetworks.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anderson@redhat.com \
--cc=behanw@converseincode.com \
--cc=cl@linux.com \
--cc=cov@codeaurora.org \
--cc=jays.lee@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=msalter@redhat.com \
--cc=olof@lixom.net \
--cc=paulus@samba.org \
--cc=sandeepa.prabhu@linaro.org \
--cc=srivatsa.bhat@linux.vnet.ibm.com \
--cc=steve.capper@linaro.org \
--cc=takahiro.akashi@linaro.org \
--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).