From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCAV7-00056e-W3 for qemu-devel@nongnu.org; Thu, 24 Dec 2015 13:20:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aCAV3-0006E5-85 for qemu-devel@nongnu.org; Thu, 24 Dec 2015 13:20:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCAV2-0006DI-Ub for qemu-devel@nongnu.org; Thu, 24 Dec 2015 13:20:29 -0500 Message-ID: <1450981226.2950.111.camel@redhat.com> From: Alex Williamson Date: Thu, 24 Dec 2015 11:20:26 -0700 In-Reply-To: <20151224200603-mutt-send-email-mst@redhat.com> References: <20151224163132-mutt-send-email-mst@redhat.com> <1450979226.2950.108.camel@redhat.com> <20151224200603-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v14 Resend 08/13] vfio: add check host bus reset is support or not List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: chen.fan.fnst@cn.fujitsu.com, Cao jin , qemu-devel@nongnu.org On Thu, 2015-12-24 at 20:06 +0200, Michael S. Tsirkin wrote: > On Thu, Dec 24, 2015 at 10:47:06AM -0700, Alex Williamson wrote: > > On Thu, 2015-12-24 at 16:32 +0200, Michael S. Tsirkin wrote: > > > On Thu, Dec 17, 2015 at 09:41:49AM +0800, Cao jin wrote: > > > > From: Chen Fan > > > >=20 > > > > when init vfio devices done, we should test all the devices > > > > supported > > > > aer whether conflict with others. For each one, get the hot > > > > reset > > > > info for the affected device list.=C2=A0=C2=A0For each affected d= evice, > > > > all > > > > should attach to the VM and on/below the same bus. also, we > > > > should > > > > test > > > > all of the non-AER supporting vfio-pci devices on or below the > > > > target > > > > bus to verify they have a reset mechanism. > > > >=20 > > > > Signed-off-by: Chen Fan > > > > --- > > > > =C2=A0hw/vfio/pci.c | 236 > > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- > > > > =C2=A0hw/vfio/pci.h |=C2=A0=C2=A0=C2=A01 + > > > > =C2=A02 files changed, 230 insertions(+), 7 deletions(-) > > > >=20 > > > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > > > > index d00b0e4..6926dcc 100644 > > > > --- a/hw/vfio/pci.c > > > > +++ b/hw/vfio/pci.c > > > > @@ -1806,6 +1806,216 @@ static int > > > > vfio_add_std_cap(VFIOPCIDevice > > > > *vdev, uint8_t pos) > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return 0; > > > > =C2=A0} > > > > =C2=A0 > > > > +static bool vfio_pci_host_slot_match(PCIHostDeviceAddress > > > > *host1, > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0PCIHostDeviceAddress > > > > *host2) > > > > +{ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0return (host1->domain =3D=3D host2->doma= in && host1->bus =3D=3D > > > > host2- > > > > > bus && > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0host1->slot =3D=3D host2->slot); > > > > +} > > > > + > > > > +static bool vfio_pci_host_match(PCIHostDeviceAddress *host1, > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0PCIHostDeviceAddress *= host2) > > > > +{ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0return (vfio_pci_host_slot_match(host1, = host2) && > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0host1->function =3D=3D host2->function); > > > > +} > > > > + > > > > +struct VFIODeviceFind { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0PCIDevice *pdev; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0bool found; > > > > +}; > > > > + > > > > +static void vfio_check_device_noreset(PCIBus *bus, PCIDevice > > > > *pdev, > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0void *opaque) > > > > +{ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0DeviceState *dev =3D DEVICE(pdev); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0DeviceClass *dc =3D DEVICE_GET_CLASS(dev= ); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0VFIOPCIDevice *vdev; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0struct VFIODeviceFind *find =3D opaque; > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0if (find->found) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0if (!object_dynamic_cast(OBJECT(dev), "v= fio-pci")) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!dc->reset) = { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0goto found; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0} > > > > +=C2=A0=C2=A0=C2=A0=C2=A0vdev =3D DO_UPCAST(VFIOPCIDevice, pdev, = pdev); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0if (!(vdev->features & VFIO_FEATURE_ENAB= LE_AER) && > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0!vdev->vbasedev.= reset_works) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0goto found; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0return; > > > > +found: > > > > +=C2=A0=C2=A0=C2=A0=C2=A0find->pdev =3D pdev; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0find->found =3D true; > > > > +} > > > > + > > > > +static void device_find(PCIBus *bus, PCIDevice *pdev, void > > > > *opaque) > > > > +{ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0struct VFIODeviceFind *find =3D opaque; > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0if (find->found) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0if (pdev =3D=3D find->pdev) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0find->found =3D = true; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0} > > > > +} > > > > + > > > > +static int vfio_check_host_bus_reset(VFIOPCIDevice *vdev) > > > > +{ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0PCIBus *bus =3D vdev->pdev.bus; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0struct vfio_pci_hot_reset_info *info =3D= NULL; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0struct vfio_pci_dependent_device *device= s; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0VFIOGroup *group; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0struct VFIODeviceFind find; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0int ret, i; > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0ret =3D vfio_get_hot_reset_info(vdev, &i= nfo); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0if (ret) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0error_report("vf= io: Cannot enable AER for device %s," > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0" device does= not support hot reset.", > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vdev->vbasede= v.name); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0goto out; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0/* List all affected devices by bus rese= t */ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0devices =3D &info->devices[0]; > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0/* Verify that we have all the groups re= quired */ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0for (i =3D 0; i < info->count; i++) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0PCIHostDeviceAdd= ress host; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0VFIOPCIDevice *t= mp; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0VFIODevice *vbas= edev_iter; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool found =3D f= alse; > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0host.domain =3D = devices[i].segment; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0host.bus =3D dev= ices[i].bus; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0host.slot =3D PC= I_SLOT(devices[i].devfn); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0host.function =3D= PCI_FUNC(devices[i].devfn); > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* Skip the curr= ent device */ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (vfio_pci_hos= t_match(&host, &vdev->host)) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0continue; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* Ensure we own= the group of the affected device */ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0QLIST_FOREACH(gr= oup, &vfio_group_list, next) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0if (group->groupid =3D=3D devices[i].group_id) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0break; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0} > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!group) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0error_report("vfio: Cannot enable AER for device > > > > %s, " > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0"depends on group %d which is not > > > > owned.", > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0vdev->vbasedev.name, > > > > devices[i].group_id); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0ret =3D -1; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0goto out; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* Ensure affect= ed devices for reset on/blow the bus > > > > */ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0QLIST_FOREACH(vb= asedev_iter, &group->device_list, > > > > next) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0if (vbasedev_iter->type !=3D VFIO_DEVICE_TYPE_PCI) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0continue; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0} > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0tmp =3D container_of(vbasedev_iter, VFIOPCIDevice, > > > > vbasedev); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0if (vfio_pci_host_match(&host, &tmp->host)) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0PCIDevice *pci =3D PCI_DEVICE(tmp); > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* For multifunction device, due to vf= io > > > > driver > > > > signal all > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* functions under the upstream link o= f the > > > > end > > > > point. here > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* we validate all functions whether e= nable > > > > AER. > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0*/ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (vfio_pci_host_slot_match(&vdev->host, > > > > &tmp- > > > > > host) && > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0!(tmp->features & > > > > VFIO_FEATURE_ENABLE_AER)) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0error_report("vfio:= Cannot enable AER for > > > > device %s, on same slot" > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0" the dependent = device %s > > > > which > > > > does not enable AER.", > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vdev->vbasedev.n= ame, tmp- > > > > > vbasedev.name); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ret =3D -1; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0goto out; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0find.pdev =3D pci; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0find.found =3D false; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0pci_for_each_device(bus, pci_bus_num(bus), > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= device_find, &find); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!find.found) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0error_report("vfio:= Cannot enable AER for > > > > device %s, " > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"the dependent d= evice %s is > > > > not > > > > under the same bus", > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vdev->vbasedev.n= ame, tmp- > > > > > vbasedev.name); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ret =3D -1; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0goto out; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0found =3D true; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0break; > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0} > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* Ensure all af= fected devices assigned to VM */ > > >=20 > > > I am puzzled. > > > Does not kernel enforce this already? > > > If not it's a security problem. > > > If yes why does userspace need to check this? > >=20 > > DMA isolation and bus level isolation are separate concepts. =C2=A0Ea= ch > > function of a multi-function device can have DMA isolation, but a > > user > > needs to own all of the functions affected by a bus reset in order > > to > > perform one. =C2=A0An AER configuration can only be created if the us= er > > can > > translate a guest bus reset into a host bus reset and therefore > > needs > > to test whether it has the permissions to do so. =C2=A0I believe over > > the > > course of reviews we've also added some simplifying constraints > > around > > this to reduce the problem set, things like all the groups being > > assigned rather than just owned by the user. =C2=A0However, I believe > > the > > kernel is sound in how it provides security for bus resets. > > =C2=A0Thanks, > >=20 > > Alex >=20 > Yes, sounds good. >=20 > So how about just trying to do bus reset at setup time? > If kernel allows this, we know it is safe ... The host may support hotplug, what's possible at setup time may not be possible when an error occurs. =C2=A0It's unlikely, but worth considering= I think. =C2=A0Thanks, Alex