Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1629900

Re: [PATCH] arm64: Add ASM modifier for xN register operands

From Matthias Kaehlcke <mka@chromium.org>
Newsgroups linux.kernel
Subject Re: [PATCH] arm64: Add ASM modifier for xN register operands
Date 2017-04-24 21:20 +0200
Message-ID <tzRGF-2y4-3@gated-at.bofh.it> (permalink)
References <typ9L-3Yq-15@gated-at.bofh.it> <tzPES-1jt-21@gated-at.bofh.it> <tzPYe-1pP-13@gated-at.bofh.it> <tzQ7U-1tV-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi,

El Mon, Apr 24, 2017 at 06:34:14PM +0100 Will Deacon ha dit:

> On Mon, Apr 24, 2017 at 06:22:51PM +0100, Ard Biesheuvel wrote:
> > On 24 April 2017 at 18:00, Will Deacon <will.deacon@arm.com> wrote:
> > > Hi Matthias,
> > >
> > > On Thu, Apr 20, 2017 at 11:30:53AM -0700, Matthias Kaehlcke wrote:
> > >> Many inline assembly statements don't include the 'x' modifier when
> > >> using xN registers as operands. This is perfectly valid, however it
> > >> causes clang to raise warnings like this:
> > >>
> > >> warning: value size does not match register size specified by the
> > >>   constraint and modifier [-Wasm-operand-widths]
> > >> ...
> > >> arch/arm64/include/asm/barrier.h:62:23: note: expanded from macro
> > >>   '__smp_store_release'
> > >>     asm volatile ("stlr %1, %0"
> > >
> > > If I understand this correctly, then the warning is emitted when we pass
> > > in a value smaller than 64-bit, but refer to %<n> without a modifier
> > > in the inline asm.

To be honest I don't understand completely when clang emits the
warning and when not. I'm probably just not fluent enough in (inline)
assembly to see the pattern.

> > > However, if that's the case then I don't understand why:
> > >
> > >> diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
> > >> index 0c00c87bb9dd..021e1733da0c 100644
> > >> --- a/arch/arm64/include/asm/io.h
> > >> +++ b/arch/arm64/include/asm/io.h
> > >> @@ -39,33 +39,33 @@
> > >>  #define __raw_writeb __raw_writeb
> > >>  static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
> > >>  {
> > >> -     asm volatile("strb %w0, [%1]" : : "rZ" (val), "r" (addr));
> > >> +     asm volatile("strb %w0, [%x1]" : : "rZ" (val), "r" (addr));
> > >
> > > is necessary. addr is a pointer type, so is 64-bit.
> > >
> > > Given that the scattergun nature of this patch implies that you've been
> > > fixing the places where warnings are reported, then I'm confused as to
> > > why a warning is generated for the case above.

In this case actually no warning is generated.

My idea was to add the modifier in all cases for consistency, not only
to get rid of the warnings. I'm fine with only addressing the warnings
if that is preferred.

> > AIUI, Clang now always complains for missing register width modifiers,
> > not just for placeholders that resolve to a 32-bit (or smaller)
> > quantity.
> 
> Ok, in which case this patch is incomplete as there's a bunch of asm that
> isn't updated (e.g. spinlock.h).

Sorry, my grep pattern was a bit naive and didn't take multiline
inline assembly into account.

If you are ok with adding modifiers everywhere I'll add the missing
bits, otherwise I'll rework the patch to only change the instances
where clang emits the warning.

Cheers

Matthias

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] arm64: Add ASM modifier for xN register operands Matthias Kaehlcke <mka@chromium.org> - 2017-04-20 20:40 +0200
  Re: [PATCH] arm64: Add ASM modifier for xN register operands Will Deacon <will.deacon@arm.com> - 2017-04-24 19:10 +0200
    Re: [PATCH] arm64: Add ASM modifier for xN register operands Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-04-24 19:30 +0200
      Re: [PATCH] arm64: Add ASM modifier for xN register operands Will Deacon <will.deacon@arm.com> - 2017-04-24 19:40 +0200
        Re: [PATCH] arm64: Add ASM modifier for xN register operands Matthias Kaehlcke <mka@chromium.org> - 2017-04-24 21:20 +0200
          Re: [PATCH] arm64: Add ASM modifier for xN register operands Will Deacon <will.deacon@arm.com> - 2017-04-25 14:20 +0200

csiph-web