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 1/4] arm64: kvm: save and restore ACCDATA_EL1 if used by host
Date: Thu, 03 Dec 2026 10:16:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-247556@kernel.org> (raw)
In-Reply-To: <20261203095703.655796-2-arnd@kernel.org>
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 <arnd@arndb.de>
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;
>
> - /* 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;
>
> + /* 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 = ctxt_to_vcpu(ctxt);
> return kvm_has_feat(kern_hyp_va(vcpu->kvm), ID_AA64ISAR1_EL1, LS64, LS64_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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203095703.655796-1-arnd@kernel.org?part=1
next prev parent reply other threads:[~2026-12-03 10:16 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 [this message]
2026-12-03 9:57 ` [PATCH v3 2/4] arm64: dynamically enable st64bv0 for SVA Arnd Bergmann
2026-12-03 10:26 ` sashiko-bot
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-247556@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