Hi Eric, On 2020/11/16 19:00, Eric Auger wrote: > This patch adds the VFIO_IOMMU_SET_MSI_BINDING ioctl which aim > to (un)register the guest MSI binding to the host. This latter > then can use those stage 1 bindings to build a nested stage > binding targeting the physical MSIs. [...] > +static int vfio_iommu_type1_set_msi_binding(struct vfio_iommu *iommu, > + unsigned long arg) > +{ > + struct vfio_iommu_type1_set_msi_binding msi_binding; > + unsigned long minsz; > + int ret = -EINVAL; > + > + minsz = offsetofend(struct vfio_iommu_type1_set_msi_binding, > + size); > + > + if (copy_from_user(&msi_binding, (void __user *)arg, minsz)) > + return -EFAULT; > + > + if (msi_binding.argsz < minsz) > + return -EINVAL; We can check BIND and UNBIND are not set simultaneously, just like VFIO_IOMMU_SET_PASID_TABLE. > + > + if (msi_binding.flags == VFIO_IOMMU_UNBIND_MSI) { > + vfio_unbind_msi(iommu, msi_binding.iova); > + ret = 0; > + } else if (msi_binding.flags == VFIO_IOMMU_BIND_MSI) { > + ret = vfio_bind_msi(iommu, msi_binding.iova, > + msi_binding.gpa, msi_binding.size); > + } > + return ret; > +} > + Thanks, Keqian