From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796293197; b=Mly2O0vKear1KTWqEXTl/rkzAL1XLB+h+/67ST/zb3gfm4EQgyBJ0R8Uvg3poZfUzg8K BLtA9fCvW9Mpf6ho8jyfqFekTElOnPcHMC8/RBKItcC/MmQVoIAoHxafqrcB6FOI4uytQ l8Zc87YTOx4UzPDAf19RtZViwvT4eUa5tEiFC9lkxO/sRsHwpLX+T/wf7fZPgdYVZxe+H QNcAkY3Oq1Xo3i0hH++zqhx1SHrGt01ttPJQ8KIe0JwTBm0E2Hn3bqNsd2Gwg9NYC1UdC G4Cqw6yWEORfiFO+BphvL9cWquroPn/1uLZXz3XbzcZ6ByknHBWE3dM2lgTZo/V+hYQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796293197; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=tFzeY6Sp8jCDN7cmiUcIUl/gkpue9jX84IUTl3MFu9M=; b=n2hyAVayI4dA15rn0fWbyF8+LifwhGsc93i3GMhC9ZLVso1bSEgSM4LWZpfuAls7USzy GN9JvI2KZ0aXt1iItwR0MkI0WBNTiGIle9eezcHga8NBn3f1rSlVVIWsHhaC3q+3QM2u6 XyKskmDIx/8Uq9YKSvzsvFtmAtWT0eUwzb9AZTo29CN8Ijetr4ez5/KwLXK13/IeIaGcw o3jPRcGWG/nRksDqP+eFUZKOTXlXsZNfOGQw/1RokSeKr6ysWhEQNCopRlScp0JKsPevI L3okREqw19gJB1cUQu5ll5V+rzaC4kbTGatRMCD/bSH92/VDwHOtN+5tdl1E4s+nfyA== 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=PofTw53o; 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 60472606A32C; Thu, 3 Dec 2026 10:19:57 +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=PofTw53o Received: by smtp.kernel.org (Postfix) with ESMTPSA id B031C1F000C1; Thu, 3 Dec 2026 10:19:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796293196; bh=tFzeY6Sp8jCDN7cmiUcIUl/gkpue9jX84IUTl3MFu9M=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=PofTw53oDT4ENcWX+GWlXm6AO8v4rRiNaVvbv90+3uK6Cu7PTqRD5MUKCgiuV73l3 aR/im77yfwOcBFDUQTAScB3mibNVGAmWGLk5B3D9d1FWZauLkoUSm73xvlgwD5OnCa R0V3jnginLYvKbthHlwYrCBrkkA6+qE7Y+zTpfX0jQlF6yvmLziXsSIwNSHOBQaU3e u8iJDcbBEw/dLcsiYv/SanEDEZMbwKF1V0WzuKVKI1vJCYAB6B/85NVvApekz4/7zt 82oGd3AytAE2h4VjsIcgwkfB6iPq8Lj6Fj3Yd6pB8U62B0BVxQzwsscaQThEM1NOx2 Q2rJzY6x0haCg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 3/4] arm64: add HWCAP3_LS64_ACCDATA 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-4-arnd@kernel.org> References: <20261203095703.655796-1-arnd@kernel.org> <20261203095703.655796-4-arnd@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 10:19:56 +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 4 potential issues to consider: - [Critical] arm64: NULL mm dereference in ls64_accdata_thread_switch() on task exit - [Medium] arm64: HWCAP3_LS64_ACCDATA advertised without CONFIG_ARM64_LS64_ACCDATA - [Low] arm64: elf_hwcaps.rst overstates SIGBUS scope and uses >=3D convention - [Low] arm64: elf_hwcaps.rst unconfirmed st64bv0 bits 31:0 overwrite claim -- commit f0a6f157224e6ac0c0f369c507739103758e5747 Author: Arnd Bergmann arm64: add HWCAP3_LS64_ACCDATA This commit exposes FEAT_LS64_ACCDATA to userspace via HWCAP3_LS64_ACCDATA and /proc/cpuinfo, and documents its semantics in elf_hwcaps.rst. Link: https://www.kernel.org/doc/html/v7.3/arch/x86/sva.html#enqcmd > diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch= /arm64/elf_hwcaps.rst > index f60ca5612daa4..f56b38e4349b6 100644 > --- a/Documentation/arch/arm64/elf_hwcaps.rst > +++ b/Documentation/arch/arm64/elf_hwcaps.rst > @@ -478,6 +478,17 @@ HWCAP3_SVE_LUT6 > Functionality implied by ID_AA64PFR0_EL1.SVE =3D=3D 0b0001 and > ID_AA64ISAR2_EL1.LUT =3D=3D 0b0010. > =20 > +HWCAP3_LS64_ACCDATA > + Functionality implied by ID_AA64ISAR1_EL1.LS64 >=3D 0b0011. > + Note that the function of instruction st64bv0 requires support > + by CPU, system and target (device) memory location and a matching > + device driver. HWCAP3_LS64_ACCDATA implies the support of CPU only. > + The kernel uses ACCDATA_EL1 to supply the Process Address Space ID > + (PASID) of the calling process. The CPU replaces bits [31:0] of the > + 64-byte store data with this value. st64bv0 can only be used after [Severity: Low] This rests on an arm64 architectural detail that could not be confirmed from the kernel source: does st64bv0 transmit ACCDATA_EL1[31:0] as separate transaction metadata alongside the 64-byte store payload rather than overwriting bits [31:0] of the 64-byte store data? If so, this documentation would mislead userspace about how to lay out its 64-byte st64bv0 work descriptors. > + a device driver has bound the process address space to a device that > + supports this instruction. Any other I/O access raises SIGBUS with > + si_code =3D=3D BUS_OBJERR. [Severity: Low] Does this overstate when SIGBUS with si_code =3D=3D BUS_OBJERR is raised? Only trapped st64bv0 instructions inject SIGBUS/BUS_OBJERR in do_el0_other(), not general I/O accesses. Furthermore, once try_enable_st64bv0() sets SCTLR_EL1_EnAS0 for a thread, it is not cleared on iommu_sva_unbind_device(), so later st64bv0 accesses by that thread to unbound or unsupported mappings no longer trap to do_el0_other() and are not guaranteed to raise SIGBUS. Also, ID_AA64ISAR1_EL1.LS64 >=3D 0b0011 is the only entry in this file using >=3D instead of the idreg.field =3D=3D val convention described in Section 2. [ ... ] > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeatur= e.c > index 866385b490eb7..8f874e344e52d 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -3223,6 +3223,7 @@ static const struct arm64_cpu_capabilities arm64_el= f_hwcaps[] =3D { > HWCAP_CAP(ID_AA64ISAR1_EL1, DGH, IMP, CAP_HWCAP, KERNEL_HWCAP_DGH), > HWCAP_CAP(ID_AA64ISAR1_EL1, I8MM, IMP, CAP_HWCAP, KERNEL_HWCAP_I8MM), > HWCAP_CAP(ID_AA64ISAR1_EL1, LS64, LS64, CAP_HWCAP, KERNEL_HWCAP_LS64), > + HWCAP_CAP(ID_AA64ISAR1_EL1, LS64, LS64_ACCDATA, CAP_HWCAP, KERNEL_HWCAP= _LS64_ACCDATA), [Severity: Medium] As reported by Catalin Marinas on v2 [1], should this entry and system_supports_ls64_accdata() be gated on CONFIG_ARM64_LS64_ACCDATA? With CONFIG_IOMMU_SVA=3Dy and CONFIG_ARM64_LS64_ACCDATA=3Dn, in-tree SVA drivers such as uacce still bind via iommu_sva_bind_device() without checking CONFIG_ARM64_LS64_ACCDATA, while userspace sees HWCAP3_LS64_ACCDATA set with no way to tell that kernel ACCDATA_EL1 support is compiled out. Issuing st64bv0 then unconditionally fails with SIGBUS (BUS_OBJERR) in try_enable_st64bv0(). Guarding both the arm64_elf_hwcaps[] entry with #ifdef CONFIG_ARM64_LS64_ACCDATA and system_supports_ls64_accdata() with IS_ENABLED(CONFIG_ARM64_LS64_ACCDATA) would match the other Kconfig-gated EL0 features in this table. [Severity: Critical] Once userspace discovers HWCAP3_LS64_ACCDATA and executes st64bv0, can ls64_accdata_thread_switch() dereference a NULL next->mm on task exit? In commit "arm64: dynamically enable st64bv0 for SVA", try_enable_st64bv0() sets SCTLR_EL1_EnAS0 in current->thread.sctlr_user, which is never cleared on exit. During do_exit(), exit_mm() sets current->mm =3D NULL before sleepable teardown steps such as exit_files(). If the exiting task sleeps or is preempted and later scheduled back in, __switch_to() calls ls64_accdata_thread_switch(): arch/arm64/kernel/process.c:ls64_accdata_thread_switch() { 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); } mm_get_enqcmd_pasid() unconditionally dereferences mm->iommu_mm, causing a kernel NULL pointer dereference inside __switch_to() with interrupts disabled and the runqueue lock held. Any unprivileged user with access to an SVA device can panic the kernel by running st64bv0 and exiting. Similarly, ls64_accdata_suspend_exit() in arch/arm64/kernel/suspend.c passes current->mm to mm_get_enqcmd_pasid() without checking for NULL, and writes the result to SYS_ACCDATA_EL1 without checking for IOMMU_PASID_INVALID. [1] https://lore.kernel.org/r/aw26TP1HH-oo1kjf@arm.com --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203095703.6557= 96-1-arnd@kernel.org?part=3D3