From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCApG-0000rp-2c for qemu-devel@nongnu.org; Thu, 24 Dec 2015 13:41:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aCApB-00018i-Vt for qemu-devel@nongnu.org; Thu, 24 Dec 2015 13:41:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCApB-00018e-Lf for qemu-devel@nongnu.org; Thu, 24 Dec 2015 13:41:17 -0500 Message-ID: <1450982475.2950.116.camel@redhat.com> From: Alex Williamson Date: Thu, 24 Dec 2015 11:41:15 -0700 In-Reply-To: <20151224202221-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> <1450981226.2950.111.camel@redhat.com> <20151224202221-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:23 +0200, Michael S. Tsirkin wrote: > On Thu, Dec 24, 2015 at 11:20:26AM -0700, Alex Williamson wrote: > > 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 affect= ed > > > > > > device, > > > > > > 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->= domain && 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=A0PCIHostDeviceAdd= ress > > > > > > *host2) > > > > > > +{ > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0return (vfio_pci_host_slot_match(hos= t1, 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 opaq= ue; > > > > > > + > > > > > > +=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)= , "vfio-pci")) { > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!dc->res= et) { > > > > > > +=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, pd= ev, pdev); > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0if (!(vdev->features & VFIO_FEATURE_= ENABLE_AER) && > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0!vdev->vbase= dev.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 opaq= ue; > > > > > > + > > > > > > +=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 *de= vices; > > > > > > +=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= , &info); > > > > > > +=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= ("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" devic= e 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->v= basedev.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 = reset */ > > > > > > +=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 group= s required */ > > > > > > +=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=A0PCIHostDevic= eAddress host; > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0VFIOPCIDevic= e *tmp; > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0VFIODevice *= vbasedev_iter; > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool found =3D= false; > > > > > > + > > > > > > +=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= devices[i].bus; > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0host.slot =3D= PCI_SLOT(devices[i].devfn); > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0host.functio= n =3D PCI_FUNC(devices[i].devfn); > > > > > > + > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* Skip the = current device */ > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (vfio_pci= _host_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_FOREAC= H(group, &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 af= fected devices for reset on/blow the > > > > > > bus > > > > > > */ > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0QLIST_FOREAC= H(vbasedev_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 vfio > > > > > > 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 of > > > > > > 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 whe= ther > > > > > > 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=A0if (vfio_pci_host_slot_match(&vdev->h= ost, > > > > > > &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->featur= es & > > > > > > 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 depe= ndent 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->vbas= edev.name, 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=A0device_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 depen= dent device %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->vbas= edev.name, 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 al= l affected 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=A0Each > > > > 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 th= e > > > > user > > > > 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 ... > >=20 > > The host may support hotplug, what's possible at setup time may not > > be > > possible when an error occurs. >=20 > How does this patch help solve this problem? I believe there's a patch in this series that re-tests on the occurrence of an error, before injecting the AER into the guest. > > It's unlikely, but worth considering I > > think. >=20 > I suspect vfio will have to solve this in kernel > (e.g. automatically add all new devices in the same group > wrt reset). Nope, the user simply loses their ability to reset the bus if they don't own all the groups at the time they attempt to do a bus reset. =C2=A0Mixing bus isolation and DMA isolation would cause a mess of groups= .