public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@nxp.com>
To: Michael Matz <matz@suse.de>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>,
	"james.greenhalgh@arm.com"	<james.greenhalgh@arm.com>,
	"nd@arm.com" <nd@arm.com>,
	"jailhouse-dev@googlegroups.com" <jailhouse-dev@googlegroups.com>,
	"will.deacon@arm.com" <will.deacon@arm.com>,
	Catalin Marinas	<catalin.marinas@arm.com>
Subject: RE: Warning: unpredictable: identical transfer and status registers --`stxr w4,x5,[x4] using aarch64 poky gcc 8.3
Date: Wed, 13 Feb 2019 14:42:00 -0000	[thread overview]
Message-ID: <DB7PR04MB44903CFFCEC6FB2DA87068B888660@DB7PR04MB4490.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <alpine.LSU.2.21.1902131425580.5354@wotan.suse.de>

Hi Michael,

> -----Original Message-----
> From: Michael Matz [mailto:matz@suse.de]
> Sent: 2019年2月13日 22:28
> To: Peng Fan <peng.fan@nxp.com>
> Cc: gcc@gcc.gnu.org; james.greenhalgh@arm.com; nd@arm.com;
> jailhouse-dev@googlegroups.com; will.deacon@arm.com; Catalin Marinas
> <catalin.marinas@arm.com>
> Subject: Re: Warning: unpredictable: identical transfer and status registers
> --`stxr w4,x5,[x4] using aarch64 poky gcc 8.3
> 
> Hi,
> 
> On Wed, 13 Feb 2019, Peng Fan wrote:
> 
> >                 asm volatile (
> >                         "ldxr   %3, %2\n\t"
> >                         "ands   %1, %3, %4\n\t"
> >                         "b.ne   1f\n\t"
> >                         "orr    %3, %3, %4\n\t"
> >                         "1:\n\t"
> >                         "stxr   %w0, %3, %2\n\t"
> >                         "dmb    ish\n\t"
> >                         : "=r" (ret), "=&r" (test),
> >                           "+Q" (*(volatile unsigned long *)addr),
> >                           "=r" (tmp)
> >                         : "r" (1ul << nr));
> 
> As Andreas says, you need to add an early-clobber for op3 for correctness (to
> force it into a different register from op4).  And you also need an
> early-clobber on op0 to force it into a different register from op2 (which for
> purposes of register assignment is an input operand holding an address).

So the fix should be the following, right?
        do {
                asm volatile (
                        "ldxr   %3, %2\n\t"
                        "ands   %1, %3, %4\n\t"
                        "b.ne   1f\n\t"
                        "orr    %3, %3, %4\n\t"
                        "1:\n\t"
                        "stxr   %w0, %3, %2\n\t"
                        "dmb    ish\n\t"
                        : "=&r" (ret), "=&r" (test),
                          "+Q" (*(volatile unsigned long *)addr),
                          "=&r" (tmp)
                        : "r" (1ul << nr));
        } while (ret);

Thanks,
Peng.

> 
> 
> Ciao,
> Michael.

  reply	other threads:[~2019-02-13 14:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13  7:13 Peng Fan
2019-02-13  9:44 ` Segher Boessenkool
2019-02-13 13:41   ` Peng Fan
2019-02-13 13:59 ` Andreas Schwab
2019-02-13 14:43   ` Peng Fan
2019-02-13 14:28 ` Michael Matz
2019-02-13 14:42   ` Peng Fan [this message]
2019-02-13 14:44     ` Michael Matz
2019-02-14  8:23       ` Peng Fan

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=DB7PR04MB44903CFFCEC6FB2DA87068B888660@DB7PR04MB4490.eurprd04.prod.outlook.com \
    --to=peng.fan@nxp.com \
    --cc=catalin.marinas@arm.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jailhouse-dev@googlegroups.com \
    --cc=james.greenhalgh@arm.com \
    --cc=matz@suse.de \
    --cc=nd@arm.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 read-only IMAP folder(s) and NNTP newsgroup(s).