[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y9l5OmCRGYZM2nPy@nvidia.com>
Date: Tue, 31 Jan 2023 16:25:30 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Matthew Rosato <mjrosato@...ux.ibm.com>
Cc: alex.williamson@...hat.com, pbonzini@...hat.com,
yi.l.liu@...el.com, cohuck@...hat.com, farman@...ux.ibm.com,
pmorel@...ux.ibm.com, borntraeger@...ux.ibm.com,
frankja@...ux.ibm.com, imbrenda@...ux.ibm.com, david@...hat.com,
akrowiak@...ux.ibm.com, jjherne@...ux.ibm.com, pasic@...ux.ibm.com,
zhenyuw@...ux.intel.com, zhi.a.wang@...el.com, seanjc@...gle.com,
kevin.tian@...el.com, linux-s390@...r.kernel.org,
kvm@...r.kernel.org, intel-gvt-dev@...ts.freedesktop.org,
intel-gfx@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vfio: fix deadlock between group lock and kvm lock
On Tue, Jan 31, 2023 at 03:06:35PM -0500, Matthew Rosato wrote:
> @@ -799,13 +794,14 @@ EXPORT_SYMBOL_GPL(vfio_file_enforced_coherent);
> void vfio_file_set_kvm(struct file *file, struct kvm *kvm)
> {
> struct vfio_group *group = file->private_data;
> + unsigned long flags;
>
> if (!vfio_file_is_group(file))
> return;
>
> - mutex_lock(&group->group_lock);
> + spin_lock_irqsave(&group->kvm_ref_lock, flags);
> group->kvm = kvm;
> - mutex_unlock(&group->group_lock);
> + spin_unlock_irqrestore(&group->kvm_ref_lock, flags);
We know we are in a sleeping context here so these are just
'spin_lock()', same with the other one
Otherwise it seems Ok to me
Reviewed-by: Jason Gunthorpe <jgg@...dia.com>
Jason
Powered by blists - more mailing lists