[PATCH 11/43] KVM: arm64: gic-v5: Make VPEs valid in vgic_v5_reset()
Sascha Bischoff
Sascha.Bischoff at arm.com
Fri May 8 10:08:18 PDT 2026
On Thu, 2026-04-30 at 10:37 +0100, Marc Zyngier wrote:
> On Mon, 27 Apr 2026 17:09:47 +0100,
> Sascha Bischoff <Sascha.Bischoff at arm.com> wrote:
> >
> > When resetting VPEs, also mark them as valid in the VM VPE Table.
> > This
> > is required as it informs the IRS that a specific VPE may be made
> > resident, and without this the IRS will treat the VPE as invalid.
> >
> > As part of this change, we also introduce a wrapper around the VPE
> > doorbells - vgic_v5_send_command(). This takes a struct kvm_vcpu
> > pointer, and the command to run, and triggers the function bound to
> > the command via that vcpu's doorbell. This is a convenience
> > function
> > to simplify the code.
> >
> > Signed-off-by: Sascha Bischoff <sascha.bischoff at arm.com>
> > ---
> > arch/arm64/kvm/vgic/vgic-v5.c | 22 ++++++++++++++++++++++
> > 1 file changed, 22 insertions(+)
> >
> > diff --git a/arch/arm64/kvm/vgic/vgic-v5.c
> > b/arch/arm64/kvm/vgic/vgic-v5.c
> > index 0649729f6b834..92bb63b6dd6bb 100644
> > --- a/arch/arm64/kvm/vgic/vgic-v5.c
> > +++ b/arch/arm64/kvm/vgic/vgic-v5.c
> > @@ -518,6 +518,18 @@ static int vgic_v5_irs_vpe_cr0_update(int
> > vm_id, int vpe_id, u32 cr0)
> > return 0;
> > }
> >
> > +static int vgic_v5_send_command(struct kvm_vcpu *vcpu,
> > + enum gicv5_vcpu_info_cmd_type
> > type)
> > +{
> > + struct gicv5_cmd_info cmd_info;
> > +
> > + if (!vcpu)
> > + return -EINVAL;
>
> Drop this. If we must crash, let's crash early, in the most
> spectacular way, and leaving a backtrace. Trying to gracefully handle
> this stuff is making it harder to track and debug such problems.
OK, noted.
>
> Also, if we made it that far, it is very likely that vcpu isn't NULL.
Yeah, in which case the backtrace is certainly most useful.
>
> > +
> > + cmd_info.cmd_type = type;
> > + return irq_set_vcpu_affinity(vgic_v5_vpe_db(vcpu),
> > &cmd_info);
> > +}
> > +
> > static int vgic_v5_db_set_vcpu_affinity(struct irq_data *data,
> > void *vcpu_info)
> > {
> > struct vgic_v5_vm *vm = data->domain->host_data;
> > @@ -691,6 +703,8 @@ static void
> > vgic_v5_teardown_per_vm_domain(struct vgic_v5_vm *vm)
> >
> > void vgic_v5_reset(struct kvm_vcpu *vcpu)
> > {
> > + int rc;
> > +
> > /*
> > * We always present 16-bits of ID space to the guest,
> > irrespective of
> > * the host allowing more.
> > @@ -702,6 +716,14 @@ void vgic_v5_reset(struct kvm_vcpu *vcpu)
> > * CPUIF (but potentially fewer in the IRS).
> > */
> > vcpu->arch.vgic_cpu.num_pri_bits = 5;
> > +
> > + /* Make the VPE valid in the VPET */
> > + rc = vgic_v5_send_command(vcpu, VPE_MAKE_VALID);
> > + if (rc) {
>
> nit: rc serves no purpose here. Just write it as:
>
> if (vgic_v5_send_command(...))
>
> > + /* We can't continue, so mark the VM as dead */
> > + kvm_vm_dead(vcpu->kvm);
> > + return;
>
> But we probably should dump some traces here, rather than silently
> mark the VM as fsck'd. THis is the sign that something has gone very
> wrong.
OK, I've changed this to drop the rc, WARN_ON, and return.
>
> Thanks,
>
> M.
>
Thanks,
Sascha
More information about the linux-arm-kernel
mailing list