Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796293570; b=k9iK7rlw2gVMZwdpvRfOKX9WsW6h/zfSXJEheQl7Nk/QrqUw1R/5/H+dTu02UzeP2Lvb YQATtlTBuLs9hf00QilSQ7BD0W9UcTCpLEN69fxcxDgcyVwQqPqy4moq/hJZEDJrP2qsz QXtgp+9kN3V2pVweI/7syzTmcBDn3I9O5/6VJ5tJMQoLYqxNh9MapV4zdLbdX5wNEdEqm SyGrsgmYWbKaL0N6VNbU149Rx88uzd5FmlGxw8CZ6mIM8vqaR3toNRww6rvNLLvMnRIZE 9XRNnUD7KHloqch6aGLTfX42z1KKKqb2QVsOk14Hdr/z6Nf1G1sfXyW1muzYW4cCGJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796293570; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=gpIaJHF8XD9hdKChaXj0zK70ZDMVRXidPN1pO4bGqCg=; b=NSV9xmOen/hNKsjVbXtpc+S/wbEFyum6A05c3D05mf85UVOD5tG9FrGj3LB6ptkckEyC AthqkmJ+7TJXQ05JPDrVPuMZhEg1yVLjybwyl6aKis0e83dyLPIhxKjkhIifmM294DEjW uwNDC1+IhrwOU7q0qlTx76JLDwKQge0mZxyg7m9WFUSx09Mvpu1tkkytXRD9g5I7D+tIR pkHFmEOaZ+YIePFdaGlgC1gDcg+ACV3rSbr3oUiHMRskxKFV29wQp6Z9M9KesZsk+GMZz b+pIEHmdzDBj6pMbU3okugZ7blaTr1lsT/RcZ0z8ybnEbaD1jlmArWgVkPu7mTjoXsw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M+zEfPTb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD99A606A322; Thu, 3 Dec 2026 10:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M+zEfPTb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 370081F00896; Thu, 3 Dec 2026 10:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796293570; bh=gpIaJHF8XD9hdKChaXj0zK70ZDMVRXidPN1pO4bGqCg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=M+zEfPTbhQpnjA6s7WqSuWa1spTdZODPJ5rnSWx0FE3FkprIlwTRHMiKIrWbkqVSe 9KtoZzQU1fgnG8gBBOuSdUIJbniB0KMULqsOsyrn/hdS5wMgPC4hXB6BKdt4aaue9R YQB2uIhwPGutCOiHjJVXQtykgpMNDlGrxf9iZ4IrkcQmq+8Q5LQ+oJ3aJ1at5esysX Ynfnc/1pdz6PlJ6peWnXgj0mb5GHaNzHNAWBEhtWl1nUPxFJvIRcnWHrDiAIpCvAIe GYw3dGWWPyWrAossQdjgbkvW1ASvV54JJHtzlTDmBM/zKpHjcQCfXnUA/b7we934ko yMp8TJs7GIfdw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/4] arm64: dynamically enable st64bv0 for SVA Reply-To: sashiko-reviews@lists.linux.dev To: "Arnd Bergmann" Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261203095703.655796-3-arnd@kernel.org> References: <20261203095703.655796-1-arnd@kernel.org> <20261203095703.655796-3-arnd@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 10:26:09 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 > =20 > 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 > =20 > .Lset_hcrx_\@: > msr_s SYS_HCRX_EL2, x0 [ ... ] > @@ -394,6 +397,15 @@ > orr x0, x0, #HFGRTR_EL2_nGCS_EL0_MASK > =20 > .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 =3D mm_get_enqcmd_pasid(next->mm); > + if (pasid !=3D 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 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203095703.6557= 96-1-arnd@kernel.org?part=3D2