On Tue, Mar 31, 2026 at 11:37:58AM +0300, Leon Romanovsky wrote: > On Thu, Mar 26, 2026 at 04:41:11PM -0600, Keith Busch wrote: > > > > You're suggesting that Ziping append the new fields to the end of this > > struct? I don't think we can modify the layout of a uapi. > > He needs to add before flex array. This struct is submitted by the user > and kernel can easily calculate the position of that array.
No, you can't just do that. Existing applications would break when they compile against the updated kernel header. They don't know about this new "tph" supplied flag, but they'll all accidently use the new dma_ranges offset. > Something like this: > diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c > b/drivers/vfio/pci/vfio_pci_dmabuf.c > index b1d658b8f7b51..d78d915992232 100644 > --- a/drivers/vfio/pci/vfio_pci_dmabuf.c > +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c > @@ -237,7 +237,11 @@ int vfio_pci_core_feature_dma_buf(struct > vfio_pci_core_device *vdev, u32 flags, > if (get_dma_buf.region_index >= VFIO_PCI_ROM_REGION_INDEX) > return -ENODEV; > > - dma_ranges = memdup_array_user(&arg->dma_ranges, > get_dma_buf.nr_ranges, > + if (!tph_supplied) > + dma_ranges = memdup_array_user(old_dma_ranges_pos, > get_dma_buf.nr_ranges, > + sizeof(*dma_ranges)); > + else > + dma_ranges = memdup_array_user(&arg->dma_ranges, > get_dma_buf.nr_ranges, > sizeof(*dma_ranges)); > if (IS_ERR(dma_ranges)) > return PTR_ERR(dma_ranges); > ~
