From: sashiko-bot@kernel.org
To: "Fuad Tabba" <fuad.tabba@linux.dev>
Cc: "Oliver Upton" <oupton@kernel.org>,
kvmarm@lists.linux.dev, "Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v4 6/8] KVM: arm64: Minimise EL2's exposure of host VGIC state during world switch
Date: Mon, 06 Jul 2026 10:28:17 +0000 [thread overview]
Message-ID: <20260706102817.B03AF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706095927.560795-7-fuad.tabba@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Userspace KVM_SET_ONE_REG modifications to ICC_VMCR_EL1 and Active Priority Registers (APRs) are silently overwritten and lost on vcpu_put() under pKVM.
--
commit 8bda67fe364c44ad574acb3da5de4bf16e0ccbbf
Author: Marc Zyngier <maz@kernel.org>
KVM: arm64: Minimise EL2's exposure of host VGIC state during world switch
This commit avoids exposing the host's entire vgic_v3_cpu_if to EL2 by
copying only the necessary vgic_vmcr and active priority registers during
save and restore operations.
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index 45d717889f6ea..f3233ee343a39 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
[ ... ]
> @@ -508,16 +520,63 @@ static void handle___vgic_v3_save_aprs(struct kvm_cpu_context *host_ctxt)
> {
> - DECLARE_REG(struct vgic_v3_cpu_if *, cpu_if, host_ctxt, 1);
> + struct pkvm_hyp_vcpu *hyp_vcpu;
> + struct kvm_vcpu *host_vcpu;
>
> - __vgic_v3_save_aprs(kern_hyp_va(cpu_if));
> + host_vcpu = get_host_hyp_vcpus_from_vgic_v3_cpu_if(host_ctxt, 1,
> + &hyp_vcpu);
> + if (!host_vcpu)
> + return;
> +
> + if (unlikely(hyp_vcpu)) {
> + struct vgic_v3_cpu_if *hyp_cpu_if, *host_cpu_if;
> + int i;
> +
> + hyp_cpu_if = &hyp_vcpu->vcpu.arch.vgic_cpu.vgic_v3;
> + __vgic_v3_save_aprs(hyp_cpu_if);
> +
> + host_cpu_if = &host_vcpu->arch.vgic_cpu.vgic_v3;
> + host_cpu_if->vgic_vmcr = hyp_cpu_if->vgic_vmcr;
> + for (i = 0; i < ARRAY_SIZE(host_cpu_if->vgic_ap0r); i++) {
> + host_cpu_if->vgic_ap0r[i] = hyp_cpu_if->vgic_ap0r[i];
> + host_cpu_if->vgic_ap1r[i] = hyp_cpu_if->vgic_ap1r[i];
> + }
[Severity: High]
Does this sequence risk clobbering userspace writes to ICC_VMCR_EL1 and the
Active Priority Registers?
When userspace modifies the GIC CPU interface via KVM_SET_ONE_REG, the
ioctl is wrapped by vcpu_load() and vcpu_put().
Under pKVM, vcpu_load() calls __vgic_v3_restore_vmcr_aprs, which restores
the hardware with the current values.
The ioctl then updates host_cpu_if in memory with the new userspace values.
Finally, vcpu_put() issues the __vgic_v3_save_aprs hypercall.
Since the hardware and hyp_cpu_if only have the pre-ioctl stale values,
will this explicit copy back to host_cpu_if overwrite the new values set
by userspace? This could cause state restoration or live migration to
silently lose these register updates.
> + } else {
> + __vgic_v3_save_aprs(&host_vcpu->arch.vgic_cpu.vgic_v3);
> + }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706095927.560795-1-fuad.tabba@linux.dev?part=6
next prev parent reply other threads:[~2026-07-06 10:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 9:59 [PATCH v4 0/8] KVM: arm64: pKVM vCPU state management at EL2 (series A) Fuad Tabba
2026-07-06 9:59 ` [PATCH v4 1/8] KVM: arm64: Extract MPIDR computation into a shared header Fuad Tabba
2026-07-06 9:59 ` [PATCH v4 2/8] KVM: arm64: Make vcpu_{read,write}_sys_reg available to HYP code Fuad Tabba
2026-07-06 10:25 ` sashiko-bot
2026-07-06 11:48 ` Fuad Tabba
2026-07-14 0:30 ` Oliver Upton
2026-07-14 6:41 ` Fuad Tabba
2026-07-06 9:59 ` [PATCH v4 3/8] KVM: arm64: Factor out reusable vCPU reset helpers Fuad Tabba
2026-07-06 9:59 ` [PATCH v4 4/8] KVM: arm64: Move PSCI helper functions to a shared header Fuad Tabba
2026-07-06 9:59 ` [PATCH v4 5/8] KVM: arm64: Add host and hypervisor vCPU lookup primitives Fuad Tabba
2026-07-06 9:59 ` [PATCH v4 6/8] KVM: arm64: Minimise EL2's exposure of host VGIC state during world switch Fuad Tabba
2026-07-06 10:28 ` sashiko-bot [this message]
2026-07-06 11:53 ` Fuad Tabba
2026-07-06 9:59 ` [PATCH v4 7/8] KVM: arm64: Add primitives to flush/sync the VGIC state at EL2 Fuad Tabba
2026-07-06 9:59 ` [PATCH v4 8/8] KVM: arm64: Implement lazy vCPU state sync for non-protected guests Fuad Tabba
2026-07-06 10:36 ` sashiko-bot
2026-07-06 11:59 ` Fuad Tabba
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=20260706102817.B03AF1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fuad.tabba@linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.