[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB5276E39EE37A7BA2E1B896278CD19@BN9PR11MB5276.namprd11.prod.outlook.com>
Date: Wed, 1 Feb 2023 06:13:11 +0000
From: "Tian, Kevin" <kevin.tian@...el.com>
To: Matthew Rosato <mjrosato@...ux.ibm.com>,
"alex.williamson@...hat.com" <alex.williamson@...hat.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"Liu, Yi L" <yi.l.liu@...el.com>, "jgg@...dia.com" <jgg@...dia.com>
CC: "cohuck@...hat.com" <cohuck@...hat.com>,
"farman@...ux.ibm.com" <farman@...ux.ibm.com>,
"pmorel@...ux.ibm.com" <pmorel@...ux.ibm.com>,
"borntraeger@...ux.ibm.com" <borntraeger@...ux.ibm.com>,
"frankja@...ux.ibm.com" <frankja@...ux.ibm.com>,
"imbrenda@...ux.ibm.com" <imbrenda@...ux.ibm.com>,
"david@...hat.com" <david@...hat.com>,
"akrowiak@...ux.ibm.com" <akrowiak@...ux.ibm.com>,
"jjherne@...ux.ibm.com" <jjherne@...ux.ibm.com>,
"pasic@...ux.ibm.com" <pasic@...ux.ibm.com>,
"zhenyuw@...ux.intel.com" <zhenyuw@...ux.intel.com>,
"Wang, Zhi A" <zhi.a.wang@...el.com>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"intel-gvt-dev@...ts.freedesktop.org"
<intel-gvt-dev@...ts.freedesktop.org>,
"intel-gfx@...ts.freedesktop.org" <intel-gfx@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] vfio: fix deadlock between group lock and kvm lock
> From: Matthew Rosato <mjrosato@...ux.ibm.com>
> Sent: Wednesday, February 1, 2023 4:07 AM
>
> - device->kvm = kvm;
> + /*
> + * Get the KVM pointer currently associated with the group, if there
> + * is one, and obtain a reference now that will be held until the
> + * open_count reaches 0. Save the pointer in the device for use by
> + * drivers.
> + */
> + spin_lock_irqsave(&group->kvm_ref_lock, flags);
> + if (group->kvm && vfio_kvm_get_kvm_safe(device, group->kvm))
> + device->kvm = group->kvm;
> + spin_unlock_irqrestore(&group->kvm_ref_lock, flags);
> +
No group reference in vfio_main.c.
btw Yi, looks the deadlock issue also exists in your cdev work.
kvm_vfio_release() holds kvm lock and then try to acquire
device->device_set->lock in vfio_device_file_set_kvm().
vfio_device_ioctl_bind_iommufd() holds device->device_set->lock
and then call vfio_device_open() which finally hit kvm lock
acquisition in driver's open_device routine (e.g. vfio-ap).
A similar fix is required in your series.
Thanks
Kevin
Powered by blists - more mailing lists