Re: [PATCH v12 05/24] virt: geniezone: Add vm support
From: Liju-clr Chen (陳麗如)
Date: Mon Oct 21 2024 - 23:10:57 EST
On Thu, 2024-08-01 at 18:50 +0800, Hillf Danton wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> On Tue, 30 Jul 2024 16:24:17 +0800 Liju-clr Chen <
> liju-clr.chen@xxxxxxxxxxxx>
> > +
> > +static void gzvm_destroy_vm(struct gzvm *gzvm)
> > +{
> > + pr_debug("VM-%u is going to be destroyed\n", gzvm->vm_id);
> > +
> > + mutex_lock(&gzvm->lock);
> > +
> > + gzvm_arch_destroy_vm(gzvm->vm_id);
> > +
> > + mutex_lock(&gzvm_list_lock);
> > + list_del(&gzvm->vm_list);
> > + mutex_unlock(&gzvm_list_lock);
> > +
> > + mutex_unlock(&gzvm->lock);
> > +
> > + kfree(gzvm);
> > +}
>
> ...
> > +
> > +void gzvm_destroy_all_vms(void)
> > +{
> > + struct gzvm *gzvm, *tmp;
> > +
> > + mutex_lock(&gzvm_list_lock);
> > + if (list_empty(&gzvm_list))
> > + goto out;
> > +
> > + list_for_each_entry_safe(gzvm, tmp, &gzvm_list, vm_list)
> > + gzvm_destroy_vm(gzvm);
> > +
>
> You add a fking deadlock by invoking gzvm_destroy_vm() with
> gzvm_list_lock held.
>
Hi Hillf,
Thank you for reviewing and finding the bug.
It will be fixed in next version.
> > +out:
> > + mutex_unlock(&gzvm_list_lock);
> > +}
BR
Liju