Re: [PATCH 1/3] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them

Fuad Tabba <[email protected]>
Newsgroups dev.linux.lists.kvmarm,dev.linux.lists.sashiko-reviews
Message-ID <CA+EHjTyaKjHpBHG3ZmwTPj93wZLa5pSVzYNT6YpboE40NaDERA@mail.gmail.com>
Hi Marc,

On Sun, 23 Aug 2026 at 10:44, Marc Zyngier <[email protected]> wrote:
...
> > The actual patch would factor the shared teardown tail into a helper
> > rather than duplicate it.
> >
> > If you (Marc) agree, I'll send this as a separate patch (after testing
> > it), or as part of a possible respin in a couple of days.
>
> Why isn't this as simple as:
>
> diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c
> index ed236f083f0d7..57a16530801c0 100644
> --- a/arch/arm64/kvm/vgic/vgic-v4.c
> +++ b/arch/arm64/kvm/vgic/vgic-v4.c
> @@ -333,6 +333,8 @@ void vgic_v4_teardown(struct kvm *kvm)
>                 free_irq(irq, vcpu);
>         }
>
> +       /* Make sure we free all VM-wide, per-CPU resources */
> +       its_vm->nr_vpes = aromic_read(&kvm->online_vcpus);
>         its_free_vcpu_irqs(its_vm);
>         kfree(its_vm->vpes);
>         its_vm->nr_vpes = 0;

With the typo fixed, it is ;), but on top of patch 3 of this series.
Without that, a vgic_init() failing after vgic_v4_init() succeeded
leaves the vPE array behind while precreate still admits vCPUs, so
online_vcpus can outgrow the array. If you agree, I'll add it after
patch 3, noting the dependency in the commit message when I respin.

Separately, and I might be missing something: is there anything
stopping KVM_CREATE_VCPU from running concurrently with vgic_init()?
Coming from KVM_DEV_ARM_VGIC_CTRL_INIT it makes the same
created_vcpus/online_vcpus comparison as kvm_vgic_create(), but under
the config_lock alone, where kvm_vgic_create() holds kvm->lock and the
vCPU mutexes too. And precreate admits vCPUs until dist->initialized
is set at the end, so if one lands in the middle, vgic_v4_init() sizes
vpes[] from one read of online_vcpus and fills it from another. If
there isn't, I'll send a fix as a separate patch.

Cheers,
/fuad

> Thanks,
>
>         M.
>
> --
> Jazz isn't dead. It just smells funny.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.