From: sashiko-bot@kernel.org
To: "Arnd Bergmann" <arnd@kernel.org>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
"Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v3 2/4] arm64: dynamically enable st64bv0 for SVA
Date: Thu, 03 Dec 2026 10:26:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-247571@kernel.org> (raw)
In-Reply-To: <20261203095703.655796-3-arnd@kernel.org>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Critical] arm64: NULL pointer dereference in
ls64_accdata_thread_switch() on task exit
- [Medium] arm64: do_el0_other() drops esr_context on SIGILL by passing
0 for esr
- [Low] KVM: arm64: unnecessary host ACCDATA_EL1 save/restore in
ctxt_has_accdata()
- [Low] arm64: missing FEAT_LS64_ACCDATA EL2 boot requirements in
booting.rst
- [Low] arm64: missing SIGBUS description in force_signal_inject()
--
commit 0483e6ecd8d45bd772eb519deb0c8760bf621a7c
Author: Arnd Bergmann <arnd@arndb.de>
arm64: dynamically enable st64bv0 for SVA
This commit adds CONFIG_ARM64_LS64_ACCDATA to enable EL0 st64bv0 on
demand via do_el0_other() when a process has an IOMMU SVA PASID, and
manages SCTLR_EL1.EnAS0 and ACCDATA_EL1 across fork, exec, context
switch, and suspend.
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index f28c54007cf9f..c4f555e04348a 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -2309,6 +2309,19 @@ config ARM64_EPAN
>
> The feature is detected at runtime, and will remain disabled
> if the cpu does not implement the feature.
> +
> +config ARM64_LS64_ACCDATA
> + bool "Enable support for 64-byte EL0 stores with status (LS64_ACCDATA)"
> + depends on IOMMU_SVA
> + default y
[Severity: Low]
Does enabling CONFIG_ARM64_LS64_ACCDATA cause unnecessary host
ACCDATA_EL1 save/restore in KVM when a guest does not use the feature?
In commit "arm64: kvm: save and restore ACCDATA_EL1 if used by host",
ctxt_has_accdata() returns IS_ENABLED(CONFIG_ARM64_LS64_ACCDATA) early
for host contexts before checking the guest's feature set. As a result,
KVM saves and restores SYS_ACCDATA_EL1 on every VHE vcpu_load/vcpu_put
and nVHE VM-entry/exit even when the guest does not expose
FEAT_LS64_ACCDATA and traps any access.
Returning false only when !ctxt_is_guest(ctxt) &&
!IS_ENABLED(CONFIG_ARM64_LS64_ACCDATA) and falling through to
kvm_has_feat() would avoid those redundant host register accesses.
[ ... ]
> diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h
> index 12a5001812911..fd6e06bdacfb4 100644
> --- a/arch/arm64/include/asm/el2_setup.h
> +++ b/arch/arm64/include/asm/el2_setup.h
> @@ -93,6 +93,9 @@
> cmp x1, #ID_AA64ISAR1_EL1_LS64_LS64_V
> b.lt .Lset_hcrx_\@
> orr x0, x0, #HCRX_EL2_EnASR
> + cmp x1, #ID_AA64ISAR1_EL1_LS64_LS64_ACCDATA
> + b.lt .Lset_hcrx_\@
> + orr x0, x0, #HCRX_EL2_EnAS0
>
> .Lset_hcrx_\@:
> msr_s SYS_HCRX_EL2, x0
[ ... ]
> @@ -394,6 +397,15 @@
> orr x0, x0, #HFGRTR_EL2_nGCS_EL0_MASK
>
> .Lskip_gce_fgt_\@:
> + mrs_s x1, SYS_ID_AA64ISAR1_EL1
> + ubfx x1, x1, #ID_AA64ISAR1_EL1_LS64_SHIFT, #4
> + cmp x1, #ID_AA64ISAR1_EL1_LS64_LS64_ACCDATA
> + b.lt .Lskip_ls64_accdata_\@
> +
> + /* Disable traps of access to ACCDATA_EL1 register */
> + orr x0, x0, #HFGRTR_EL2_nACCDATA_EL1
> +
> +.Lskip_ls64_accdata_\@:
[Severity: Low]
As reported by Catalin Marinas on v2 [1], should
Documentation/arch/arm64/booting.rst also document the EL2 requirements
for FEAT_LS64_ACCDATA when the kernel is entered at EL1?
booting.rst already documents HCRX_EL2.EnALS and HCRX_EL2.EnASR for
FEAT_LS64 and FEAT_LS64_V, but omits HCRX_EL2.EnAS0 (bit 0) and
HFGRTR_EL2.nACCDATA_EL1 / HFGWTR_EL2.nACCDATA_EL1 (bit 50). Without
this, firmware or hypervisors entering Linux at EL1 may leave these
traps enabled.
[ ... ]
> diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
> index 42b15b0c069ff..9063218f20f0a 100644
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
[ ... ]
> +/* switch PASID if new task has enabled st64bv0 */
> +static void ls64_accdata_thread_switch(struct task_struct *next)
> +{
> + u32 pasid;
> +
> + if (!(next->thread.sctlr_user & SCTLR_EL1_EnAS0))
> + return;
> +
> + pasid = mm_get_enqcmd_pasid(next->mm);
> + if (pasid != IOMMU_PASID_INVALID)
> + write_sysreg_s(pasid, SYS_ACCDATA_EL1);
> +}
[Severity: Critical]
Can ls64_accdata_thread_switch() cause a NULL pointer dereference on
next->mm when an exiting task is scheduled back in?
SCTLR_EL1_EnAS0 is not cleared on task exit, so it stays set after
do_exit() -> exit_mm() clears current->mm during sleepable teardown
like exit_files(). When the task is rescheduled, __switch_to() passes
NULL to mm_get_enqcmd_pasid(), which dereferences mm->iommu_mm.
ls64_accdata_suspend_exit() in arch/arm64/kernel/suspend.c also passes
current->mm without a NULL check and writes SYS_ACCDATA_EL1 without
checking for IOMMU_PASID_INVALID.
Guarding next->mm (and clearing SCTLR_EL1_EnAS0 in deactivate_mm()),
along with checking current->mm and IOMMU_PASID_INVALID in
ls64_accdata_suspend_exit(), would prevent the crash.
[ ... ]
> diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
> index d6391ab20db38..2ba9344c35606 100644
> --- a/arch/arm64/kernel/traps.c
> +++ b/arch/arm64/kernel/traps.c
[ ... ]
> +void do_el0_other(struct pt_regs *regs, unsigned long esr)
> +{
> + switch (ESR_ELx_ISS(esr)) {
> + case ESR_ELx_ISS_OTHER_ST64BV0:
> + if (!system_supports_ls64_accdata())
> + break;
> +
> + if (try_enable_st64bv0())
> + return;
> +
> + force_signal_inject(SIGBUS, BUS_OBJERR, regs->pc, 0);
> + return;
[Severity: Low]
Does force_signal_inject() have a description for SIGBUS?
Its switch statement only handles SIGILL and SIGSEGV, so an unhandled
SIGBUS from st64bv0 falls through to default and logs "unknown or
unrecoverable error" when show_unhandled_signals is enabled. Adding a
SIGBUS case to force_signal_inject() would fix the log message.
> +
> + case ESR_ELx_ISS_OTHER_ST64BV:
> + case ESR_ELx_ISS_OTHER_LDST64B:
> + default:
> + break;
> + }
> +
> + /* Treat all other "other" trapping instructions as illegal opcode */
> + force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
> +}
[Severity: Medium]
As reported by Catalin Marinas on v2 [1], does passing 0 instead of esr
here drop struct esr_context from the SIGILL signal frame?
Previously, unhandled ESR_ELx_EC_OTHER traps fell through to
bad_el0_sync(regs, 0, esr), which saved esr in
current->thread.fault_code so setup_sigframe() included esr_context.
Passing esr as the fourth argument or reusing bad_el0_sync() would
preserve the existing userspace behavior.
[1] https://lore.kernel.org/r/aw2xOFFqAXsx_Nqd@arm.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203095703.655796-1-arnd@kernel.org?part=2
next prev parent reply other threads:[~2026-12-03 10:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 9:56 [PATCH v3 0/4] st64bv0 support in iommu-sva Arnd Bergmann
2026-12-03 9:57 ` [PATCH v3 1/4] arm64: kvm: save and restore ACCDATA_EL1 if used by host Arnd Bergmann
2026-12-03 10:16 ` sashiko-bot
2026-12-03 9:57 ` [PATCH v3 2/4] arm64: dynamically enable st64bv0 for SVA Arnd Bergmann
2026-12-03 10:26 ` sashiko-bot [this message]
2026-12-03 9:57 ` [PATCH v3 3/4] arm64: add HWCAP3_LS64_ACCDATA Arnd Bergmann
2026-12-03 10:19 ` sashiko-bot
2026-12-03 9:57 ` [PATCH v3 4/4] kselftest/arm64: Add HWCAP test for FEAT_LS64_ACCDATA Arnd Bergmann
2026-12-03 10:14 ` sashiko-bot
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=sashiko-outbox-247571@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arnd@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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