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=1796292988; b=LgJVJFfTIgftk2KN0w84ZChUYUcPGYyIfsnymQGZo4hASX1rii0Ad4Mo0kfr65E3PJ/p XPw371OU4FLd2PX2W3UR7o0BgD2e5zTDoEUGjK+7oWOB2laT2oMqVBIQuZMulKTBpLBsD cicdixnpwyBDRMAg0poOjfls2CtxoeabVvE1Gg0AF9GUj8dPOk/dAcMu7UVArKKqU5/Y8 7EOqdk0km/Ceh5XWITMKKfuJwbuxiPu4EHsQ1JKO0NDAaVA/XCDh3CDKSHvaJklbKJ4Qw zQay3+gm3qEGvOLqfosqulHUxE0Iu0C6yy214H42uqoSpHzQJBPNv5tBtsVYWYkK+kA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796292988; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Hv7OTMFELz1OFakGEYxEb+Zu7kV7qAxAMRhWV66f7oY=; b=HpL8lihEwNSxaK9z8/o8hgtCJ1UVfPCZn2p4YAXZnGjvUrPMFiuJbwCUY+1Ex7iN9uGm cTmGKUB4qhj73BJ+k4GnRxa/dnNC/a9CqwRiESgCBocxUGwBvrzN9o2vXvgDqTqtgeJd6 Ct/kC4ObDbZcejy4BNcZNh8zYsWIK251myrILPNK4mXmuM6Tdgacy+NdLFcxr5AolbZbJ YbbeQD4oBRySRWSpR9roV4wlxESXYah9H5bNGXOiszwgjn5TuKDkdwdMbxC+MhuzcXLBu DbOA4aoL1DCfLv/EyxEJFZlNHHSTrPJjcvebUAGmFG97VWRKv+kcqZwhG7zgQuhZOPw== 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=b9J7q8Ve; 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 7C026606A32C; Thu, 3 Dec 2026 10:16:28 +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=b9J7q8Ve Received: by smtp.kernel.org (Postfix) with ESMTPSA id C86171F0089A; Thu, 3 Dec 2026 10:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796292988; bh=Hv7OTMFELz1OFakGEYxEb+Zu7kV7qAxAMRhWV66f7oY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=b9J7q8VecZDoNN/+QWp8argBfVed/kYlJi2yfY0vMlLRsaKyqQWXiiT260kwvFnCd YL6jRYrh8HCI4SLfLU2XLewHoeqcPyKBg+HnSuy7KfIrKDYAF8+aGPt44tiAqlYD/N fI3Qy438hxGQokgFOrNXdsaOYjz49LOeIoW/TBSeI6idsYe6aESa78hROFhthsLSiB EhXwjBuN0B5j587nCXIPdgS2tKNXueY78qaCr+TfGFqCx4Vp8CMQwVBpHoXrWQTny7 PhsmK6PKG8Mo61QftNLGWSTrO3fKnj2+vprUFCaI5z9CLJL29NEc67ph89x/TRylCA ZPCSYO9ttLj5g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 1/4] arm64: kvm: save and restore ACCDATA_EL1 if used by host 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-2-arnd@kernel.org> References: <20261203095703.655796-1-arnd@kernel.org> <20261203095703.655796-2-arnd@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 10:16:27 +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 2 potential issues to consider: - [Low] KVM: arm64: ctxt_has_accdata() skips guest feature check for host context - [Low] KVM: arm64: host ACCDATA_EL1 exposure if LS64_ACCDATA exists without FGT/HCX -- commit e99c2c724dcc1601daf22519f4aeb9ec876d3278 Author: Arnd Bergmann arm64: kvm: save and restore ACCDATA_EL1 if used by host This commit updates ctxt_has_accdata() so KVM saves and restores the host's ACCDATA_EL1 register when the hardware supports ARM64_HAS_LS64_ACCDATA and CONFIG_ARM64_LS64_ACCDATA is enabled. > diff --git a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h b/arch/arm64/kvm/= hyp/include/hyp/sysreg-sr.h > index 4a008c8a696ba..43c020ca3d8d5 100644 > --- a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h > +++ b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h > @@ -143,10 +143,14 @@ static inline bool ctxt_has_accdata(struct kvm_cpu_= context *ctxt) > { > struct kvm_vcpu *vcpu; > =20 > - /* The host never uses ACCDATA_EL1 */ > - if (!cpus_have_final_cap(ARM64_HAS_LS64_ACCDATA) || !ctxt_is_guest(ctxt= )) > + /* The hardware does not support ACCDATA_EL1 */ > + if (!cpus_have_final_cap(ARM64_HAS_LS64_ACCDATA)) > return false; > =20 > + /* host only cares if SVA is enabled */ > + if (!ctxt_is_guest(ctxt)) > + return IS_ENABLED(CONFIG_ARM64_LS64_ACCDATA); [Severity: Low] Should this fall through to the guest kvm_has_feat() check instead of returning early for the host context? When running a guest without FEAT_LS64_ACCDATA (such as a pKVM protected VM), guest ACCDATA_EL1 accesses are trapped and HCRX_EL2_EnAS0 is clear. Returning early causes KVM to save and restore the unchanged host SYS_ACCDATA_EL1 on every nVHE/pKVM world switch and VHE vCPU load/put. Returning false only when !ctxt_is_guest(ctxt) && !IS_ENABLED(CONFIG_ARM64_LS64_ACCDATA) and falling through to kvm_has_feat() would avoid those accesses and match the sibling ctxt_has_*() helpers in this header. > + > vcpu =3D ctxt_to_vcpu(ctxt); > return kvm_has_feat(kern_hyp_va(vcpu->kvm), ID_AA64ISAR1_EL1, LS64, LS6= 4_ACCDATA); > } [Severity: Low] Can a CPU implement FEAT_LS64_ACCDATA without implementing FEAT_FGT or FEAT_HCX? This question rests on an ARM64 architecture detail that could not be confirmed from the kernel source. If so, entering a guest without FEAT_LS64_ACCDATA leaves the host's live SVA PASID in SYS_ACCDATA_EL1, since __sysreg_restore_user_state() skips writing it when ctxt_has_accdata(guest_ctxt) is false. Because ACCDATA_EL1 trapping in __activate_traps_hfgxtr() is gated on ARM64_HAS_FGT and HCRX_EL2.EnAS0 in __activate_traps_common() is gated on ARM64_HAS_HCX, the guest could read or use the host's ACCDATA_EL1 value without trapping to EL2. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203095703.6557= 96-1-arnd@kernel.org?part=3D1