From: Mark Rutland <mark.rutland@arm.com>
To: "tiantao (H)" <tiantao6@hisilicon.com>
Cc: catalin.marinas@arm.com, will@kernel.org,
jonathan.cameron@huawei.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linuxarm@huawei.com
Subject: Re: [PATCH] arm64: Add ARM64_HAS_LSE2 CPU capability
Date: Fri, 6 Sep 2024 14:05:57 +0100 [thread overview]
Message-ID: <Ztr-FHF5MG1YvLse@J2N7QTR9R3.cambridge.arm.com> (raw)
In-Reply-To: <54980e73-4a1c-1eb2-98b4-fbb49e9a9b8f@hisilicon.com>
On Fri, Sep 06, 2024 at 08:20:19PM +0800, tiantao (H) wrote:
>
> 在 2024/9/6 19:42, Mark Rutland 写道:
> > On Fri, Sep 06, 2024 at 06:58:19PM +0800, tiantao (H) wrote:
> > > 在 2024/9/6 17:44, Mark Rutland 写道:
> > > > On Fri, Sep 06, 2024 at 05:08:12PM +0800, Tian Tao wrote:
> > > I've come across a situation where the simplified code is as follows:
> > >
> > > long address = (long) mmap(NULL,1024*1024*2,PROT_READ|PROT_WRITE,
> > > MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
> > >
> > > long new_address = address + 9;
> > >
> > > long *p = (long*) new_address;
> > > long v = -1;
> > >
> > > __atomic_store(p, &v, __ATOMIC_RELEASE);
> > Hold on; looking at the ARM ARM (ARM DDI 0487K.a), the example and the
> > patch are both bogus. NAK to this patch, explanation below.
> >
> > Per section B2.2.1.1 "Changes to single-copy atomicity in Armv8.4", all of the
> > LSE2 relaxations on alignment require:
> >
> > | all bytes being accessed are within a 16-byte quantity that is aligned
> > | to 16 bytes
> >
> > In your example you perform an 8-byte access at an offset of 9 bytes,
> > which means the access is *not* contained within 16 bytes, and is *not*
> > guaranteed to be atomic. That code simply has to be fixed, the kernel
> > cannot magically make it safe.
> >
> > Regardless of that, the nAA bit *only* causes an alignment fault for
> > accesses which cannot be atomic. If a CPU has LSE2 and SCTLR_ELx.nAA=0,
> > an unaligned access within 16 bytes (which would be atomic) does not
> > cause an alignment fault. That's pretty clear from the description of
> > nAA and the AArch64.UnalignedAccessFaults() pseudocode:
>
> Sorry, this example is just for verifying nnA, it's not an example of a real
> scenario,
>
> we have scenarios that don't require atomicity to be guaranteed, they just
> require that coredump doesn't occur when non-aligned
Please give a concrete explanation of such a scenario, with an
explanation of why atomicity is not required.
Mark.
prev parent reply other threads:[~2024-09-06 13:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-06 9:08 [PATCH] arm64: Add ARM64_HAS_LSE2 CPU capability Tian Tao
2024-09-06 9:44 ` Mark Rutland
2024-09-06 10:58 ` tiantao (H)
2024-09-06 11:09 ` Mark Rutland
2024-09-06 11:18 ` tiantao (H)
2024-09-06 11:42 ` Mark Rutland
2024-09-06 12:20 ` tiantao (H)
2024-09-06 13:05 ` Mark Rutland [this message]
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=Ztr-FHF5MG1YvLse@J2N7QTR9R3.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=catalin.marinas@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=tiantao6@hisilicon.com \
--cc=will@kernel.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