From: Marc Zyngier <maz@kernel.org>
To: Yicong Yang <yangyicong@huawei.com>
Cc: <catalin.marinas@arm.com>, <will@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>,
<jonathan.cameron@huawei.com>,
<shameerali.kolothum.thodi@huawei.com>, <linuxarm@huawei.com>,
<prime.zeng@hisilicon.com>, <xuwei5@huawei.com>,
<yangyicong@hisilicon.com>
Subject: Re: [PATCH 2/5] arm64: Add support for FEAT_{LS64, LS64_V, LS64_ACCDATA}
Date: Tue, 03 Dec 2024 09:38:16 +0000 [thread overview]
Message-ID: <87mshdrtrr.wl-maz@kernel.org> (raw)
In-Reply-To: <20241202135504.14252-3-yangyicong@huawei.com>
On Mon, 02 Dec 2024 13:55:01 +0000,
Yicong Yang <yangyicong@huawei.com> wrote:
>
> From: Yicong Yang <yangyicong@hisilicon.com>
>
> Armv8.7 introduces single-copy atomic 64-byte loads and stores
> instructions and its variants named under FEAT_{LS64, LS64_V,
> LS64_ACCDATA}. These features are identified by ID_AA64ISAR1_EL1.LS64
> and the use of such instructions in userspace (EL0) can be trapped.
> In order to support the use of corresponding instructions in userspace:
> - Make ID_AA64ISAR1_EL1.LS64 visbile to userspace
> - Add identifying and enabling in the cpufeature list
> - Expose these support of these features to userspace through HWCAP
> and cpuinfo
>
> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
> ---
> Documentation/arch/arm64/booting.rst | 28 ++++++++++
> Documentation/arch/arm64/elf_hwcaps.rst | 9 ++++
> arch/arm64/include/asm/hwcap.h | 3 ++
> arch/arm64/include/uapi/asm/hwcap.h | 3 ++
> arch/arm64/kernel/cpufeature.c | 70 ++++++++++++++++++++++++-
> arch/arm64/kernel/cpuinfo.c | 3 ++
> arch/arm64/tools/cpucaps | 3 ++
> 7 files changed, 118 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/arch/arm64/booting.rst b/Documentation/arch/arm64/booting.rst
> index 3278fb4bf219..c35cfe9da501 100644
> --- a/Documentation/arch/arm64/booting.rst
> +++ b/Documentation/arch/arm64/booting.rst
> @@ -449,6 +449,34 @@ Before jumping into the kernel, the following conditions must be met:
>
> - HFGWTR_EL2.nGCS_EL0 (bit 52) must be initialised to 0b1.
>
> + For CPUs support for 64-byte loads and stores without status (FEAT_LS64):
> +
> + - If the kernel is entered at EL1 and EL2 is present:
> +
> + - HCRX_EL2.EnALS (bit 1) must be initialised to 0b1.
> +
> + For CPUs support for 64-byte loads and stores with status (FEAT_LS64_V):
> +
> + - If the kernel is entered at EL1 and EL2 is present:
> +
> + - HCRX_EL2.EnASR (bit 2) must be initialised to 0b1.
> +
> + For CPUs support for 64-byte EL0 stores with status (FEAT_LS64_ACCDATA):
> +
> + - If EL3 is present:
> +
> + - SCR_EL3.EnAS0 (bit 36) must be initialised to 0b1.
> +
> + - SCR_EL3.ADEn (bit 37) must be initialised to 0b1.
> +
> + - If the kernel is entered at EL1 and EL2 is present:
> +
> + - HCRX_EL2.EnAS0 (bit 0) must be initialised to 0b1.
> +
> + - HFGRTR_EL2.nACCDATA_EL1 (bit 50) must be initialised to 0b1.
> +
> + - HFGWTR_EL2.nACCDATA_EL1 (bit 50) must be initialised to 0b1.
> +
> The requirements described above for CPU mode, caches, MMUs, architected
> timers, coherency and system registers apply to all CPUs. All CPUs must
> enter the kernel in the same exception level. Where the values documented
> diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch/arm64/elf_hwcaps.rst
> index 2ff922a406ad..6cb2594f0803 100644
> --- a/Documentation/arch/arm64/elf_hwcaps.rst
> +++ b/Documentation/arch/arm64/elf_hwcaps.rst
> @@ -372,6 +372,15 @@ HWCAP2_SME_SF8DP4
> HWCAP2_POE
> Functionality implied by ID_AA64MMFR3_EL1.S1POE == 0b0001.
>
> +HWCAP3_LS64
> + Functionality implied by ID_AA64ISAR1_EL1.LS64 == 0b0001.
> +
> +HWCAP3_LS64_V
> + Functionality implied by ID_AA64ISAR1_EL1.LS64 == 0b0010.
> +
> +HWCAP3_LS64_ACCDATA
> + Functionality implied by ID_AA64ISAR1_EL1.LS64 == 0b0011.
> +
I don't mind the two others, but I seriously question exposing ST64BV0
to userspace. How is ACCDATA_EL1 populated? How is it context-switched?
As it stands, this either does the wrong thing by always having the
low 32bit set to an UNKNOWN value, or actively leaks kernel data.
TBH, I don't see it being usable in practice (the more I read this
part of the architecture, the more broken it looks).
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2024-12-03 9:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 13:54 [PATCH 0/5] Add support for FEAT_{LS64, LS64_V, LS64_ACCDATA} and related tests Yicong Yang
2024-12-02 13:55 ` [PATCH 1/5] arm64: Provide basic EL2 setup for FEAT_{LS64, LS64_V, LS64_ACCDATA} usage at EL0/1 Yicong Yang
2024-12-02 13:55 ` [PATCH 2/5] arm64: Add support for FEAT_{LS64, LS64_V, LS64_ACCDATA} Yicong Yang
2024-12-03 9:38 ` Marc Zyngier [this message]
2024-12-04 9:13 ` Yicong Yang
2024-12-02 13:55 ` [PATCH 3/5] kselftest/arm64: Add HWCAP test " Yicong Yang
2024-12-02 13:55 ` [PATCH 4/5] arm64: Add ESR.DFSC definition of unsupported exclusive or atomic access Yicong Yang
2024-12-02 13:55 ` [PATCH 5/5] KVM: arm64: Handle DABT caused by LS64* instructions on unsupported memory Yicong Yang
2024-12-03 9:38 ` Marc Zyngier
2024-12-04 9:08 ` 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=87mshdrtrr.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=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=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=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).