From: Catalin Marinas <catalin.marinas@arm.com>
To: Yicong Yang <yangyicong@huawei.com>
Cc: Will Deacon <will@kernel.org>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
yangyicong@hisilicon.com, maz@kernel.org, oliver.upton@linux.dev,
corbet@lwn.net, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org,
linux-doc@vger.kernel.org, joey.gouly@arm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com, shuah@kernel.org,
shameerali.kolothum.thodi@huawei.com, linuxarm@huawei.com,
prime.zeng@hisilicon.com, xuwei5@huawei.com,
tangchengchang@huawei.com, wangzhou1@hisilicon.com
Subject: Re: [PATCH v4 5/7] arm64: Add support for FEAT_{LS64, LS64_V}
Date: Tue, 16 Sep 2025 15:56:59 +0100 [thread overview]
Message-ID: <aMl6u7xTDLhrZmqK@arm.com> (raw)
In-Reply-To: <666e3588-2e42-2275-f9ec-94ba0954bdc6@huawei.com>
On Mon, Sep 15, 2025 at 04:29:25PM +0800, Yicong Yang wrote:
> On 2025/9/12 21:47, Jonathan Cameron wrote:
> > On Thu, 11 Sep 2025 16:50:14 +0100
> > Will Deacon <will@kernel.org> wrote:
> >> On Tue, Sep 09, 2025 at 09:48:04AM +0800, Yicong Yang wrote:
> >>> per ARM DDI0487 L.b section C3.2.6,
> >>>
> >>> When the instructions access a memory type that is not one of the following,
> >>> a data abort for unsupported Exclusive or atomic access is generated...
> >>
> >> That's about the memory _type_. I'm talking about a supported memory type
> >> (e.g. writeback cacheable) but when the physical location doesn't support
> >> the instruction. That's captured a little later in the same section:
> >>
> >> | If the target memory location does not support the LD64B or ST64B
> >> | instructions, then one of the following behaviors occurs:
> >> | * A stage 1 Data Abort, reported using the DFSC code of 0b110101,
> >> | is generated.
> >> | * The instruction performs the memory accesses, but the accesses
> >> | are not single-copy atomic above the byte level
Is this a new addition to the L.b release of the ARM ARM? Maybe it was
there before in some other form (or a different place). At least it
doesn't say "unpredictable".
> >> and I think that's a bad interface to expose blindly to userspace solely
> >> as a boolean hwcap.
> >
> > Nasty, so now I'm curious. Any thoughts on how to expose what regions it is appropriate
> > for? I can think of various heavy weight options but wondering if there is a simple
> > solution.
>
> in my understanding the hwcap only describes the capabilities of the CPU but not
> the whole system. the users should make sure the function works as expected if the
> CPU supports it and they're going to use it. specifically the LS64 is intended for
> device memory only, so the user should take responsibility of using it on supported
> memory.
We have other cases like MTE where we avoid exposing the HWCAP to user
if we know the memory system does not support MTE, though we intercepted
this early and asked the (micro)architects to tie the CPU ID field to
what the system supports.
> may raise the similar question if use other atomic instructions (e.g. LSE) on the
> memory does not support atomicity. find this restriction in ARM DDI0487 L.b section B2.2.6
>
> Some system implementations might not support atomic instructions for all regions of the
> memory
With exclusives or atomics, we require that the general purpose (system)
RAM supports the feature, otherwise Linux won't work properly (I don't
think we specifically documented this but it would be fairly obvious
when the kernel doesn't boot or user-space randomly crashes).
> and if perform atomic instruction on unsupported memory it's allowed to implement as
>
> * The instruction generates a synchronous External abort.
> * The instruction generates a System Error interrupt.
> * The instruction generates an IMPLEMENTATION DEFINED MMU fault reported using the Data
> Abort Fault status code of ESR_ELx.DFSC = 110101.
> * The instruction is treated as a NOP.
> * The instructions are performed, but there is no guarantee that the memory accesses were
> performed atomically in regard to other agents that access memory. In this case, the
> instruction might also generate a System Error interrupt.
>
> if instruction performed without generate a SEI in the last implementation, it's quite similar
> to the condition of LS64.
The difference is that we don't support Linux on such systems.
Arguably, the use of LD/ST64B* is fairly specialised and won't be used
on the general purpose RAM and by random applications. It needs a device
driver to create the NC/Device mapping and specific programs/libraries
to access it. I'm not sure the LS64 properties are guaranteed by the
device alone or the device together with the interconnect. I suspect the
latter and neither the kernel driver nor user space can tell. In the
best case, you get a fault and realise the system doesn't work as
expected. Worse is the non-atomicity with potentially silent corruption.
So, to Will's point, the HWCAP is not sufficient for user space to make
an informed decision on whether it can safely use the LS64 instructions.
Can a (generic) device driver tell or do we need additional information
in firmware tables to advertise the correct behaviour?
--
Catalin
next prev parent reply other threads:[~2025-09-16 14:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 8:13 [PATCH v4 0/7] Add support for FEAT_{LS64, LS64_V} and related tests Yicong Yang
2025-07-15 8:13 ` [PATCH v4 1/7] KVM: arm64: Add exit to userspace on {LD,ST}64B* outside of memslots Yicong Yang
2025-07-15 8:13 ` [PATCH v4 2/7] KVM: arm64: Add documentation for KVM_EXIT_ARM_LDST64B Yicong Yang
2025-07-15 8:13 ` [PATCH v4 3/7] KVM: arm64: Handle DABT caused by LS64* instructions on unsupported memory Yicong Yang
2025-07-15 8:13 ` [PATCH v4 4/7] arm64: Provide basic EL2 setup for FEAT_{LS64, LS64_V} usage at EL0/1 Yicong Yang
2025-09-08 11:48 ` Will Deacon
2025-07-15 8:13 ` [PATCH v4 5/7] arm64: Add support for FEAT_{LS64, LS64_V} Yicong Yang
2025-09-08 12:01 ` Will Deacon
2025-09-09 1:48 ` Yicong Yang
2025-09-11 15:50 ` Will Deacon
2025-09-12 13:47 ` Jonathan Cameron
2025-09-15 8:29 ` Yicong Yang
2025-09-16 14:56 ` Catalin Marinas [this message]
2025-09-17 3:51 ` Yicong Yang
2025-09-17 4:00 ` Yicong Yang
2025-09-17 14:20 ` Catalin Marinas
2025-09-18 9:09 ` Yicong Yang
2025-07-15 8:13 ` [PATCH v4 6/7] KVM: arm64: Enable FEAT_{LS64, LS64_V} in the supported guest Yicong Yang
2025-07-15 8:13 ` [PATCH v4 7/7] kselftest/arm64: Add HWCAP test for FEAT_{LS64, LS64_V} Yicong Yang
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=aMl6u7xTDLhrZmqK@arm.com \
--to=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=joey.gouly@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=prime.zeng@hisilicon.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tangchengchang@huawei.com \
--cc=wangzhou1@hisilicon.com \
--cc=will@kernel.org \
--cc=xuwei5@huawei.com \
--cc=yangyicong@hisilicon.com \
--cc=yangyicong@huawei.com \
--cc=yuzenghui@huawei.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).