On Mon, Mar 17, 2025 at 08:38:23AM +0000, Shameerali Kolothum Thodi wrote: > Hi Nicolin, > > > -----Original Message----- > > From: Nicolin Chen <nicol...@nvidia.com> > > Sent: Tuesday, March 11, 2025 9:08 PM > > To: Shameerali Kolothum Thodi <shameerali.kolothum.th...@huawei.com> > > Cc: qemu-...@nongnu.org; qemu-devel@nongnu.org; > > eric.au...@redhat.com; peter.mayd...@linaro.org; j...@nvidia.com; > > ddut...@redhat.com; berra...@redhat.com; nath...@nvidia.com; > > mo...@nvidia.com; smost...@google.com; Linuxarm > > <linux...@huawei.com>; Wangzhou (B) <wangzh...@hisilicon.com>; > > jiangkunkun <jiangkun...@huawei.com>; Jonathan Cameron > > <jonathan.came...@huawei.com>; zhangfei....@linaro.org > > Subject: Re: [RFC PATCH v2 09/20] hw/arm/smmuv3-accel: Add > > set/unset_iommu_device callback > > > > On Tue, Mar 11, 2025 at 02:10:34PM +0000, Shameer Kolothum wrote: > > > @@ -30,6 +32,185 @@ static SMMUv3AccelDevice > > *smmuv3_accel_get_dev(SMMUState *s, SMMUPciBus *sbus, > > > return accel_dev; > > > } > > > > > > +static bool > > > +smmuv3_accel_dev_attach_viommu(SMMUv3AccelDevice *accel_dev, > > > + HostIOMMUDeviceIOMMUFD *idev, Error > > > **errp) > > > > With vEVENTQ v9, vDEVICE (vSID) is required to attach a device > > to a proxy NESTED hwpt (applicable to bypass/abort HWPTs too). > > So, host_iommu_device_iommufd_attach_hwpt() would fail in this > > function because vSID isn't ready at this stage. So all those > > calls should be moved out of the function, then this should be > > likely "smmuv3_accel_dev_alloc_viommu"? > > > > That being said, I don't know when QEMU actually prepare a BDF > > number for a vfio-pci device. The only place that I see it is > > ready is at guest-level SMMU installing the Stream Table, i.e. > > in smmuv3_accel_install_nested_ste().
> > > + /* > > > + * Attach the bypass STE which means S1 bypass and S2 translate. > > > + * This is to make sure that the vIOMMU object is now associated > > > + * with the device and has this STE installed in the host SMMUV3. > > > + */ > > > + if (!host_iommu_device_iommufd_attach_hwpt( > > > + idev, viommu->bypass_hwpt_id, errp)) { > > > + error_report("failed to attach the bypass pagetable"); > > > + goto free_bypass_hwpt; > > > + } > > > > Ditto. We have to postpone this until vdevice is allocated. > > Ok. I will take a look based on the vEVENTQ v9 series. > I guess this Qemu branch of yours is a more representative of the changes > described > above? > https://github.com/nicolinc/qemu/commits/wip/for_iommufd_veventq-v9/ Yes. Mainly this change: https://github.com/nicolinc/qemu/commit/d8f496eaf528f1c397f2374a999b8b23fd55c75b Thanks Nicolin