From: Will Deacon <will@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Andrew Pinski <pinskia@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Jeremy Linton <jeremy.linton@arm.com>,
GCC Mailing List <gcc@gcc.gnu.org>,
f.fainelli@gmail.com, maz@kernel.org, marcan@marcan.st,
LKML <linux-kernel@vger.kernel.org>,
opendmb@gmail.com, Catalin Marinas <catalin.marinas@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64/io: Remind compiler that there is a memory side effect
Date: Mon, 4 Apr 2022 10:14:06 +0100 [thread overview]
Message-ID: <20220404091405.GB22649@willie-the-truck> (raw)
In-Reply-To: <CAMj1kXGpWNJSQ6My5EM1ctHgH3WDjTqLwVocxjmiNzK7hBYhBQ@mail.gmail.com>
On Sun, Apr 03, 2022 at 09:47:47AM +0200, Ard Biesheuvel wrote:
> On Sun, 3 Apr 2022 at 09:47, Ard Biesheuvel <ardb@kernel.org> wrote:
> > On Sun, 3 Apr 2022 at 09:38, Andrew Pinski <pinskia@gmail.com> wrote:
> > > It might not be the most restricted fix but it is a fix.
> > > The best fix is to tell that you are writing to that location of memory.
> > > volatile asm does not do what you think it does.
> > > You didn't read further down about memory clobbers:
> > > https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Clobbers-and-Scratch-Registers
> > > Specifically this part:
> > > The "memory" clobber tells the compiler that the assembly code
> > > performs memory reads or writes to items other than those listed in
> > > the input and output operands
> > >
> >
> > So should we be using "m"(*addr) instead of "r"(addr) here?
> >
> > (along with the appropriately sized casts)
>
> I mean "=m" not "m"
That can generate writeback addressing modes, which I think breaks
MMIO virtualisation. We usually end up using "Q" instead but the codegen
tends to be worse iirc.
In any case, for this specific problem I think we either need a fixed
compiler or some kbuild magic to avoid using it / disable the new behaviour.
We rely on 'asm volatile' not being elided in other places too.
Will
next prev parent reply other threads:[~2022-04-04 9:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 16:44 Jeremy Linton
2022-04-01 17:22 ` Mark Rutland
2022-04-03 7:36 ` Andrew Pinski
2022-04-03 7:47 ` Ard Biesheuvel
2022-04-03 7:47 ` Ard Biesheuvel
2022-04-04 9:14 ` Will Deacon [this message]
2022-04-03 17:40 ` Doug Berger
2022-04-05 12:51 ` GCC 12 miscompilation of volatile asm (was: Re: [PATCH] arm64/io: Remind compiler that there is a memory side effect) Mark Rutland
2022-04-05 13:04 ` Mark Rutland
2022-04-05 13:20 ` Andrew Cooper
2022-04-05 14:05 ` Peter Zijlstra
2022-04-11 10:22 ` Mark Rutland
2022-04-11 10:31 ` Mark Rutland
2022-04-11 19:02 ` Jeremy Linton
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=20220404091405.GB22649@willie-the-truck \
--to=will@kernel.org \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=f.fainelli@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=jeremy.linton@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=opendmb@gmail.com \
--cc=pinskia@gmail.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 read-only IMAP folder(s) and NNTP newsgroup(s).