public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Leon Romanovsky <leon@kernel.org>
Cc: Zhiping Zhang <zhipingz@meta.com>, Jason Gunthorpe <jgg@ziepe.ca>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-rdma@vger.kernel.org, linux-pci@vger.kernel.org,
	netdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Yochai Cohen <yochai@nvidia.com>,
	Yishai Hadas <yishaih@nvidia.com>,
	Bjorn Helgaas <helgaas@kernel.org>
Subject: Re: [RFC v2 1/2] vfio: add callback to get tph info for dmabuf
Date: Tue, 31 Mar 2026 07:00:07 -0600	[thread overview]
Message-ID: <acvFV8c5QVxnt3Em@kbusch-mbp> (raw)
In-Reply-To: <20260331083758.GA814676@unreal>

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);
> ~

  reply	other threads:[~2026-03-31 13:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260324234615.3731237-1-zhipingz@meta.com>
     [not found] ` <20260324234615.3731237-2-zhipingz@meta.com>
2026-03-25  8:25   ` [RFC v2 1/2] vfio: add callback to get tph info for dmabuf Leon Romanovsky
2026-03-26 22:41     ` Keith Busch
2026-03-26 22:55       ` Zhiping Zhang
2026-03-31  8:39         ` Leon Romanovsky
2026-03-31  8:37       ` Leon Romanovsky
2026-03-31 13:00         ` Keith Busch [this message]
2026-03-31 13:29           ` Leon Romanovsky
2026-03-31 13:35             ` Keith Busch
2026-03-31 14:03               ` Leon Romanovsky
2026-03-31 14:13                 ` Keith Busch
2026-03-31 19:02                   ` Leon Romanovsky
2026-03-31 19:44                     ` Keith Busch
2026-03-28  2:21   ` fengchengwen
2026-03-31  0:49     ` Zhiping Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=acvFV8c5QVxnt3Em@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=helgaas@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yishaih@nvidia.com \
    --cc=yochai@nvidia.com \
    --cc=zhipingz@meta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox