On Tue, Sep 16, 2025 at 11:33:21AM +0100, Shameer Kolothum wrote:
> > I found a new problem here that we initialize new as_sysmem per
> > VFIO device. So, sdevs would return own individual AS pointers
> > here at this get_address_space function, although they point to
> > the same system address space.
> >
> > Since address space pointers are returned differently for VFIO
> > devices, this fails to reuse ioas_id in iommufd_cdev_attach(),
> > and ends up with allocating a new ioas for each device.
> >
> > I think we can try the following change to make sure all accel
> > linked VFIO devices would share the same ioas_id, though I am
> > not sure if SMMUBaseClass is the right place to go. Please take
> > a look.
> 
> Ok. I think it is better to move that to SMMUv3AccelState and call
> address_space_init() in smmuv3_accel_init() instead. Something like
> below. Please take a look and let me know.

[...]

> @@ -37,7 +37,6 @@ typedef struct SMMUS1Hwpt {
> 
>  typedef struct SMMUv3AccelDevice {
>      SMMUDevice  sdev;
> -    AddressSpace as_sysmem;
>      HostIOMMUDeviceIOMMUFD *idev;
>      SMMUS1Hwpt  *s1_hwpt;
>      SMMUViommu *viommu;
> @@ -48,6 +47,7 @@ typedef struct SMMUv3AccelDevice {
>  typedef struct SMMUv3AccelState {
>      MemoryRegion root;
>      MemoryRegion sysmem;
> +    AddressSpace as_sysmem;
>      SMMUViommu *viommu;
>      struct iommu_hw_info_arm_smmuv3 info;
>  } SMMUv3AccelState;

That's changing from an ioas_id per VFIO device to an ioas_id per
vSMMU instance, right? I think it's still not enough.

All vSMMU instances could share the same ioas_id. That is why I
put in the SMMUBaseClass as it's shared structure across vSMMUs.

Nicolin

Reply via email to