[{"id":3680671,"web_url":"http://patchwork.ozlabs.org/comment/3680671/","msgid":"<20260422092327.3f629ad6@shazbot.org>","list_archive_url":null,"date":"2026-04-22T15:23:27","subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","submitter":{"id":91887,"url":"http://patchwork.ozlabs.org/api/people/91887/","name":"Alex Williamson","email":"alex@shazbot.org"},"content":"On Mon, 20 Apr 2026 11:39:15 -0700\nZhiping Zhang <zhipingz@meta.com> wrote:\n\n> Add a dma-buf callback that returns raw TPH metadata from the exporter\n> so peer devices can reuse the steering tag and processing hint\n> associated with a VFIO-exported buffer.\n> \n> Keep the existing VFIO_DEVICE_FEATURE_DMA_BUF uAPI layout intact by\n> using a flag plus one extra trailing entries[] object for the optional\n> TPH metadata. Rename the uAPI field dma_ranges to entries. The\n> nr_ranges field remains the DMA range count; when VFIO_DMABUF_FLAG_TPH\n> is set the kernel reads one extra entry beyond nr_ranges for the TPH\n> metadata.\n> \n> Add an st_width parameter to get_tph() so the exporter can reject\n> steering tags that exceed the consumer's supported width (8 vs 16 bit).\n> When no TPH metadata was supplied, make get_tph() return -EOPNOTSUPP.\n> \n> Signed-off-by: Zhiping Zhang <zhipingz@meta.com>\n> ---\n>  drivers/vfio/pci/vfio_pci_dmabuf.c | 62 +++++++++++++++++++++++-------\n>  include/linux/dma-buf.h            | 17 ++++++++\n>  include/uapi/linux/vfio.h          | 28 ++++++++++++--\n>  3 files changed, 89 insertions(+), 18 deletions(-)\n> \n> diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c\n> index b1d658b8f7b5..fdc05f9ab3ae 100644\n> --- a/drivers/vfio/pci/vfio_pci_dmabuf.c\n> +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c\n> @@ -17,6 +17,9 @@ struct vfio_pci_dma_buf {\n>  \tstruct phys_vec *phys_vec;\n>  \tstruct p2pdma_provider *provider;\n>  \tu32 nr_ranges;\n> +\tu16 steering_tag;\n> +\tu8 ph;\n> +\tu8 tph_present : 1;\n>  \tu8 revoked : 1;\n>  };\n>  \n> @@ -60,6 +63,22 @@ vfio_pci_dma_buf_map(struct dma_buf_attachment *attachment,\n>  \t\t\t\t       priv->size, dir);\n>  }\n>  \n> +static int vfio_pci_dma_buf_get_tph(struct dma_buf *dmabuf, u16 *steering_tag,\n> +\t\t\t\t    u8 *ph, u8 st_width)\n> +{\n> +\tstruct vfio_pci_dma_buf *priv = dmabuf->priv;\n> +\n> +\tif (!priv->tph_present)\n> +\t\treturn -EOPNOTSUPP;\n> +\n> +\tif (st_width < 16 && priv->steering_tag > ((1U << st_width) - 1))\n> +\t\treturn -EINVAL;\n> +\n> +\t*steering_tag = priv->steering_tag;\n> +\t*ph = priv->ph;\n> +\treturn 0;\n> +}\n> +\n>  static void vfio_pci_dma_buf_unmap(struct dma_buf_attachment *attachment,\n>  \t\t\t\t   struct sg_table *sgt,\n>  \t\t\t\t   enum dma_data_direction dir)\n> @@ -89,6 +108,7 @@ static const struct dma_buf_ops vfio_pci_dmabuf_ops = {\n>  \t.pin = vfio_pci_dma_buf_pin,\n>  \t.unpin = vfio_pci_dma_buf_unpin,\n>  \t.attach = vfio_pci_dma_buf_attach,\n> +\t.get_tph = vfio_pci_dma_buf_get_tph,\n>  \t.map_dma_buf = vfio_pci_dma_buf_map,\n>  \t.unmap_dma_buf = vfio_pci_dma_buf_unmap,\n>  \t.release = vfio_pci_dma_buf_release,\n> @@ -211,7 +231,9 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags,\n>  \t\t\t\t  size_t argsz)\n>  {\n>  \tstruct vfio_device_feature_dma_buf get_dma_buf = {};\n> -\tstruct vfio_region_dma_range *dma_ranges;\n> +\tbool tph_supplied;\n> +\tu32 tph_index;\n> +\tstruct vfio_region_dma_range *entries;\n>  \tDEFINE_DMA_BUF_EXPORT_INFO(exp_info);\n>  \tstruct vfio_pci_dma_buf *priv;\n>  \tsize_t length;\n> @@ -228,7 +250,10 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags,\n>  \tif (copy_from_user(&get_dma_buf, arg, sizeof(get_dma_buf)))\n>  \t\treturn -EFAULT;\n>  \n> -\tif (!get_dma_buf.nr_ranges || get_dma_buf.flags)\n> +\ttph_supplied = !!(get_dma_buf.flags & VFIO_DMABUF_FLAG_TPH);\n> +\ttph_index = get_dma_buf.nr_ranges;\n> +\tif (!get_dma_buf.nr_ranges ||\n> +\t    (get_dma_buf.flags & ~VFIO_DMABUF_FLAG_TPH))\n>  \t\treturn -EINVAL;\n>  \n>  \t/*\n> @@ -237,19 +262,21 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags,\n>  \tif (get_dma_buf.region_index >= VFIO_PCI_ROM_REGION_INDEX)\n>  \t\treturn -ENODEV;\n>  \n> -\tdma_ranges = memdup_array_user(&arg->dma_ranges, get_dma_buf.nr_ranges,\n> -\t\t\t\t       sizeof(*dma_ranges));\n> -\tif (IS_ERR(dma_ranges))\n> -\t\treturn PTR_ERR(dma_ranges);\n> +\tentries = memdup_array_user(&arg->entries,\n> +\t\t\t\t    get_dma_buf.nr_ranges +\n> +\t\t\t\t\t(tph_supplied ? 1 : 0),\n> +\t\t\t\t    sizeof(*entries));\n> +\tif (IS_ERR(entries))\n> +\t\treturn PTR_ERR(entries);\n>  \n> -\tret = validate_dmabuf_input(&get_dma_buf, dma_ranges, &length);\n> +\tret = validate_dmabuf_input(&get_dma_buf, entries, &length);\n>  \tif (ret)\n> -\t\tgoto err_free_ranges;\n> +\t\tgoto err_free_entries;\n>  \n>  \tpriv = kzalloc_obj(*priv);\n>  \tif (!priv) {\n>  \t\tret = -ENOMEM;\n> -\t\tgoto err_free_ranges;\n> +\t\tgoto err_free_entries;\n>  \t}\n>  \tpriv->phys_vec = kzalloc_objs(*priv->phys_vec, get_dma_buf.nr_ranges);\n>  \tif (!priv->phys_vec) {\n> @@ -260,15 +287,22 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags,\n>  \tpriv->vdev = vdev;\n>  \tpriv->nr_ranges = get_dma_buf.nr_ranges;\n>  \tpriv->size = length;\n> +\n> +\tif (tph_supplied) {\n> +\t\tpriv->steering_tag = entries[tph_index].tph.steering_tag;\n> +\t\tpriv->ph = entries[tph_index].tph.ph;\n> +\t\tpriv->tph_present = 1;\n> +\t}\n> +\n>  \tret = vdev->pci_ops->get_dmabuf_phys(vdev, &priv->provider,\n>  \t\t\t\t\t     get_dma_buf.region_index,\n> -\t\t\t\t\t     priv->phys_vec, dma_ranges,\n> +\t\t\t\t\t     priv->phys_vec, entries,\n>  \t\t\t\t\t     priv->nr_ranges);\n>  \tif (ret)\n>  \t\tgoto err_free_phys;\n>  \n> -\tkfree(dma_ranges);\n> -\tdma_ranges = NULL;\n> +\tkfree(entries);\n> +\tentries = NULL;\n>  \n>  \tif (!vfio_device_try_get_registration(&vdev->vdev)) {\n>  \t\tret = -ENODEV;\n> @@ -311,8 +345,8 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags,\n>  \tkfree(priv->phys_vec);\n>  err_free_priv:\n>  \tkfree(priv);\n> -err_free_ranges:\n> -\tkfree(dma_ranges);\n> +err_free_entries:\n> +\tkfree(entries);\n>  \treturn ret;\n>  }\n>  \n> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h\n> index 133b9e637b55..b0a79ccbe100 100644\n> --- a/include/linux/dma-buf.h\n> +++ b/include/linux/dma-buf.h\n> @@ -113,6 +113,23 @@ struct dma_buf_ops {\n>  \t */\n>  \tvoid (*unpin)(struct dma_buf_attachment *attach);\n>  \n> +\t/**\n> +\t * @get_tph:\n> +\t * @dmabuf: DMA buffer for which to retrieve TPH metadata\n> +\t * @steering_tag: Returns the raw TPH steering tag\n> +\t * @ph: Returns the TPH processing hint\n> +\t * @st_width: Consumer's supported steering tag width in bits (8 or 16)\n> +\t *\n> +\t * Return the TPH (TLP Processing Hints) metadata associated with this\n> +\t * DMA buffer. Exporters that do not provide TPH metadata should return\n> +\t * -EOPNOTSUPP. If the steering tag exceeds @st_width bits, return\n> +\t * -EINVAL.\n> +\t *\n> +\t * This callback is optional.\n> +\t */\n> +\tint (*get_tph)(struct dma_buf *dmabuf, u16 *steering_tag, u8 *ph,\n> +\t\t       u8 st_width);\n> +\n>  \t/**\n>  \t * @map_dma_buf:\n>  \t *\n> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h\n> index bb7b89330d35..a0bd24623c52 100644\n> --- a/include/uapi/linux/vfio.h\n> +++ b/include/uapi/linux/vfio.h\n> @@ -1490,16 +1490,36 @@ struct vfio_device_feature_bus_master {\n>   * open_flags are the typical flags passed to open(2), eg O_RDWR, O_CLOEXEC,\n>   * etc. offset/length specify a slice of the region to create the dmabuf from.\n>   * nr_ranges is the total number of (P2P DMA) ranges that comprise the dmabuf.\n> + * When VFIO_DMABUF_FLAG_TPH is set, entries[] contains one extra trailing\n> + * object after the nr_ranges DMA ranges carrying the TPH steering tag and\n> + * processing hint.\n\nI really don't think we want to design an API where entries is\nimplicitly one-off from what's actually there.  This feeds back into\nthe below removal of the __counted by attribute, which is a red flag\nthat this is the wrong approach.\n\nIn general though, I'm really hoping that someone interested in\nenabling TPH as an interface through vfio actually decides to take\nresource targeting and revocation seriously.  There's no validation of\nthe steering tag here relative to what the user has access to and no\nmechanism to revoke those tags if access changes.  In fact, there's not\neven a proposed mechanism allowing the user to derive valid steering\ntags.  Does the user implicitly know the value and the kernel just\nallows it because... yolo?  Thanks,\n\nAlex\n\n>   *\n> - * flags should be 0.\n> + * flags should be 0 or VFIO_DMABUF_FLAG_TPH.\n>   *\n>   * Return: The fd number on success, -1 and errno is set on failure.\n>   */\n>  #define VFIO_DEVICE_FEATURE_DMA_BUF 11\n>  \n> +enum vfio_device_feature_dma_buf_flags {\n> +\tVFIO_DMABUF_FLAG_TPH = 1 << 0,\n> +};\n> +\n> +struct vfio_region_dma_tph {\n> +\t__u16 steering_tag;\n> +\t__u8 ph;\n> +\t__u8 reserved;\n> +\t__u32 reserved2;\n> +};\n> +\n>  struct vfio_region_dma_range {\n> -\t__u64 offset;\n> -\t__u64 length;\n> +\tunion {\n> +\t\t__u64 offset;\n> +\t\tstruct vfio_region_dma_tph tph;\n> +\t};\n> +\tunion {\n> +\t\t__u64 length;\n> +\t\t__u64 reserved;\n> +\t};\n>  };\n>  \n>  struct vfio_device_feature_dma_buf {\n> @@ -1507,7 +1527,7 @@ struct vfio_device_feature_dma_buf {\n>  \t__u32\topen_flags;\n>  \t__u32   flags;\n>  \t__u32   nr_ranges;\n> -\tstruct vfio_region_dma_range dma_ranges[] __counted_by(nr_ranges);\n> +\tstruct vfio_region_dma_range entries[];\n>  };\n>  \n>  /* -------- API for Type1 VFIO IOMMU -------- */","headers":{"Return-Path":"\n <linux-pci+bounces-52985-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=shazbot.org header.i=@shazbot.org header.a=rsa-sha256\n header.s=fm1 header.b=rUc2xiht;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=messagingengine.com header.i=@messagingengine.com\n header.a=rsa-sha256 header.s=fm2 header.b=QKfQ4zVP;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52985-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org\n header.b=\"rUc2xiht\";\n\tdkim=pass (2048-bit key) header.d=messagingengine.com\n header.i=@messagingengine.com header.b=\"QKfQ4zVP\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=103.168.172.152","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=shazbot.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=shazbot.org"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g135j5wjqz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 01:28:25 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 9454B30C9774\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 15:23:34 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id ACF7E17BB21;\n\tWed, 22 Apr 2026 15:23:33 +0000 (UTC)","from fhigh-a1-smtp.messagingengine.com\n (fhigh-a1-smtp.messagingengine.com [103.168.172.152])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A67621CC51;\n\tWed, 22 Apr 2026 15:23:30 +0000 (UTC)","from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41])\n\tby mailfhigh.phl.internal (Postfix) with ESMTP id 6F5301400064;\n\tWed, 22 Apr 2026 11:23:29 -0400 (EDT)","from phl-frontend-03 ([10.202.2.162])\n  by phl-compute-01.internal (MEProxy); Wed, 22 Apr 2026 11:23:29 -0400","by mail.messagingengine.com (Postfix) with ESMTPA; Wed,\n 22 Apr 2026 11:23:28 -0400 (EDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776871413; cv=none;\n b=UZLjBUhE+pPCrPxKi7VeuyOgFmv8CcGHh5/UE/g3dpgwdX1DM02sS8wc4GhBNhxcFID/xBRRDoPCGGLOIDZ7Iyoahwz5460nYrLjPxgE2jFfPDQdus8GEBsmPztg/z5BMyh66d4SufmWjZNpGBHXHXg7jsgvdgW3J1ZXCSyrfIk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776871413; c=relaxed/simple;\n\tbh=NsV+bBhHjOzB6IJQMX7cu6lNjhAwM7eboDvjOAiCCS0=;\n\th=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=V7P6a5CgCr2uqSgfuQdlOFmkg/7+G5EbXSKNK5Ocvl/PD6WE+yicMzhQfA6WuTwnEaksadcMlymI6KEcAcshG9ykI7CF2srP6U1RrkiyQ5UMPg6FqqrK9lplApB4mkofV1hb46nlWfXVo3tUhgHVIKA1dWrSCNq9hXxOWmkrsa8=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=shazbot.org;\n spf=pass smtp.mailfrom=shazbot.org;\n dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org\n header.b=rUc2xiht;\n dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com\n header.b=QKfQ4zVP; arc=none smtp.client-ip=103.168.172.152","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h=\n\tcc:cc:content-transfer-encoding:content-type:content-type:date\n\t:date:from:from:in-reply-to:in-reply-to:message-id:mime-version\n\t:references:reply-to:subject:subject:to:to; s=fm1; t=1776871409;\n\t x=1776957809; bh=hQMlk9Xq+ZB050Bu5h5Pj79B23kU/VRcG/nsXr+g5/Q=; b=\n\trUc2xihtS2cQdAuSwUnr0y9hgq5IwBRt0Tsc8ILzmkJmagGjVApGux4WHK2ycA0K\n\t3IS7iCY8miyNBJfCA4fxgdr0GzuMGowKP3VSbdI74uFkrYLvcTNq2fFdsjs4wfjp\n\t29OkpB2eDocEBVWejYCaxAh9nsGQzIBCPissSi56G8Q6Upw8QKd5A0lr33z7CwQ+\n\tJutrxlpmR1oU+/sTRc00/T0wOFMU/EkFGEmWtacf3k8mI+4BdjJly7Zu3yca06NI\n\tO8u5maNR0b4k1ErHzlc7ecxIuTdkJvwnjP/+0Ynsn5BW2pvpL/hvpV2sAkF55Fay\n\tEoFPDNl0v0lQGE5hWIweHQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n\tmessagingengine.com; h=cc:cc:content-transfer-encoding\n\t:content-type:content-type:date:date:feedback-id:feedback-id\n\t:from:from:in-reply-to:in-reply-to:message-id:mime-version\n\t:references:reply-to:subject:subject:to:to:x-me-proxy\n\t:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1776871409; x=\n\t1776957809; bh=hQMlk9Xq+ZB050Bu5h5Pj79B23kU/VRcG/nsXr+g5/Q=; b=Q\n\tKfQ4zVPMkiNPasEcIuOzqkJ6IyhtBK/0QDCAcy6He4QNOwK2Cb9B8mYpiy2tQNsZ\n\t/g12FdDPrpuLb6ND3dc5PpL2sDCPHe1+EC94Ltr6aPsPVMU/hm254xwGu93FijKX\n\t6kklVb7VCFSK3feEUb+yZE9XlCOOGmaiaKTQh/DkEbleHNDV8MDs/eq9tGYbOeA/\n\tWdqHwlp/Gm529uiII0FQl0Nd/Mr6XI4HbUd8ecf5ZEkVnIIoyKqkZn0UPgF4XYAk\n\tGrc/Mn4k48zei00i9tGR3/P3w3FUC++OZXHR/Ws2yvvB8n4ZUkXnftanCbLRmD1h\n\tPuj8udp4gf1zjyssWHLaA=="],"X-ME-Sender":"<xms:8efoaRVM9j15U5FN97It6PPOed7eKcPS-2D9fypr3_rxwCt4Nv9tbw>\n    <xme:8efoaVQ2W6El0ICXVel6Kmlv6SM6w-D1b7t5wVz_SqPhD4KLZ9D3xqPlIGID05jbq\n    yuCfekr7Az6TojO2J5qjXsy5ihwxxM1Ti5ofo8vybAVxZBqpFFwyA>","X-ME-Received":"\n <xmr:8efoaWDnjFvkN2nEp_g06_i1lvCZvWQeE6vm-Sc3XlQnFtSSNXqhsCt0rd4>","X-ME-Proxy-Cause":"\n gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeigeeivdcutefuodetggdotefrod\n    ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr\n    ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug\n    hrpeffhffvvefukfgjfhfogggtgfesthejredtredtvdenucfhrhhomheptehlvgigucgh\n    ihhllhhirghmshhonhcuoegrlhgvgiesshhhrgiisghothdrohhrgheqnecuggftrfgrth\n    htvghrnhepvdekfeejkedvudfhudfhteekudfgudeiteetvdeukedvheetvdekgfdugeev\n    ueeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg\n    hlvgigsehshhgriigsohhtrdhorhhgpdhnsggprhgtphhtthhopedufedpmhhouggvpehs\n    mhhtphhouhhtpdhrtghpthhtohepiihhihhpihhnghiisehmvghtrgdrtghomhdprhgtph\n    htthhopehsughfsehmvghtrgdrtghomhdprhgtphhtthhopehksghushgthheskhgvrhhn\n    vghlrdhorhhgpdhrtghpthhtohepjhhgghesiihivghpvgdrtggrpdhrtghpthhtoheplh\n    gvohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgv\n    lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhrughmrgesvhhgvghrrdhkvghrnhgvlh\n    drohhrghdprhgtphhtthhopehlihhnuhigqdhptghisehvghgvrhdrkhgvrhhnvghlrdho\n    rhhgpdhrtghpthhtohepnhgvthguvghvsehvghgvrhdrkhgvrhhnvghlrdhorhhg","X-ME-Proxy":"<xmx:8efoaVsL30-Su4EHn6o1-1kxUePqFEnl0e0Q9han8VdJCNIZO5HbgQ>\n    <xmx:8efoac8feudf5sBZX0d9MbXUD-5TarHV7tn1c18EQUbIymllH2nt_Q>\n    <xmx:8efoaUTEhbrfTEuus2mOtj_Ysmuu-ybaNO1Yr76hqg-9Y5KWoucqHA>\n    <xmx:8efoaWU8dWKKFCRUIRCIQDOfFzW-yhNTf9qKpNTV-wpL_lWXeig7aQ>\n    <xmx:8efoaQze75CZ1fViASTOyrH-Gxcsrhd8qrd5j9hAHQr-9AEtcU9I-qNd>","Feedback-ID":"i03f14258:Fastmail","Date":"Wed, 22 Apr 2026 09:23:27 -0600","From":"Alex Williamson <alex@shazbot.org>","To":"Zhiping Zhang <zhipingz@meta.com>","Cc":"Stanislav Fomichev <sdf@meta.com>, Keith Busch <kbusch@kernel.org>,\n Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>, Bjorn\n Helgaas <helgaas@kernel.org>, <linux-rdma@vger.kernel.org>,\n <linux-pci@vger.kernel.org>, <netdev@vger.kernel.org>,\n <dri-devel@lists.freedesktop.org>, Yochai Cohen <yochai@nvidia.com>, Yishai\n Hadas <yishaih@nvidia.com>, alex@shazbot.org","Subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","Message-ID":"<20260422092327.3f629ad6@shazbot.org>","In-Reply-To":"<20260420183920.3626389-2-zhipingz@meta.com>","References":"<20260420183920.3626389-1-zhipingz@meta.com>\n\t<20260420183920.3626389-2-zhipingz@meta.com>","X-Mailer":"Claws Mail 4.3.1 (GTK 3.24.51; x86_64-pc-linux-gnu)","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit"}},{"id":3680692,"web_url":"http://patchwork.ozlabs.org/comment/3680692/","msgid":"<20260422162928.GL3611611@ziepe.ca>","list_archive_url":null,"date":"2026-04-22T16:29:28","subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","submitter":{"id":73018,"url":"http://patchwork.ozlabs.org/api/people/73018/","name":"Jason Gunthorpe","email":"jgg@ziepe.ca"},"content":"On Wed, Apr 22, 2026 at 09:23:27AM -0600, Alex Williamson wrote:\n> In general though, I'm really hoping that someone interested in\n> enabling TPH as an interface through vfio actually decides to take\n> resource targeting and revocation seriously.  There's no validation of\n> the steering tag here relative to what the user has access to and no\n> mechanism to revoke those tags if access changes.  In fact, there's not\n> even a proposed mechanism allowing the user to derive valid steering\n> tags.  Does the user implicitly know the value and the kernel just\n> allows it because... yolo? \n\nThis is the steering tag that remote devices will send *INTO* the VFIO\ndevice.\n\nIMHO it is entirely appropriate that the driver controlling the device\ndecide what tags are sent into it and when, so that's the VFIO\nuserspace.\n\nThere is no concept of access here since the entire device is captured\nby VFIO.\n\nIf the VFIO device catastrophically malfunctions when receiving\ncertain steering tags then it is incompatible with VFIO and we should\nat least block this new API..\n\nThe only requirement is that the device limit the TPH to only the\nfunction that is perceiving them. If a device is really broken and\ndoesn't meet that then it should be blocked off and it is probably not\nsafe to be used with VMs at all.\n\nJason","headers":{"Return-Path":"\n <linux-pci+bounces-53011-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256\n header.s=google header.b=pJvx2Y7f;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-53011-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca\n header.b=\"pJvx2Y7f\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.222.172","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=ziepe.ca","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=ziepe.ca"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g14SJ2DHHz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 02:29:36 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id A40A430055A3\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 16:29:33 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 6D36437F72C;\n\tWed, 22 Apr 2026 16:29:32 +0000 (UTC)","from mail-qk1-f172.google.com (mail-qk1-f172.google.com\n [209.85.222.172])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id F37E137CD5A\n\tfor <linux-pci@vger.kernel.org>; Wed, 22 Apr 2026 16:29:30 +0000 (UTC)","by mail-qk1-f172.google.com with SMTP id\n af79cd13be357-8e8c0c2d2bcso707822685a.1\n        for <linux-pci@vger.kernel.org>; Wed, 22 Apr 2026 09:29:30 -0700 (PDT)","from ziepe.ca\n (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net.\n [47.54.130.67])\n        by smtp.gmail.com with ESMTPSA id\n d75a77b69052e-50e5d5ecffdsm83483301cf.29.2026.04.22.09.29.29\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Wed, 22 Apr 2026 09:29:29 -0700 (PDT)","from jgg by wakko with local (Exim 4.97)\n\t(envelope-from <jgg@ziepe.ca>)\n\tid 1wFaS8-00000008cG7-3pDK;\n\tWed, 22 Apr 2026 13:29:28 -0300"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776875372; cv=none;\n b=BlR28zz7r4DeXr5hluApSgTsusEmjMZv7D7Ls/L6YoCV/FODyYdnzb/OVy0pN6HK4U/V3Jx94uKzIjS7dh27fzOAB3ILvboOzSrb7x9igOUDi3BeIYOXVKvUKiWzVCOUHNJzbuXrYR6gDsisxjo8NOR8DU1P+nhWEsXMcG59CqU=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776875372; c=relaxed/simple;\n\tbh=7nUTpLDZcNwHVIBFnUXlZ2h+DqdD9r7qtP5b75FfdX8=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=q1LIOFXdVRn10sWAFqIJkvIWnegizOxvrTQPQFAs0kftCZ+w9eVBaEOFaJN1CdZjUnfN/QyGu8GWFcTVqHI2kco05uVkhFUVFAki3A7JgSpWpznr+yGOLuegZEG3kuA6vmO0BcZc4MvUDQci8nW58LtdDqgBKK5k+argt7wc/tU=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=ziepe.ca;\n spf=pass smtp.mailfrom=ziepe.ca;\n dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca\n header.b=pJvx2Y7f; arc=none smtp.client-ip=209.85.222.172","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=ziepe.ca; s=google; t=1776875370; x=1777480170;\n darn=vger.kernel.org;\n        h=in-reply-to:content-disposition:mime-version:references:message-id\n         :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to;\n        bh=h9IY/0ZHCf/patsFxziV9u+pjgUJWDhTV7Q7rdgygPM=;\n        b=pJvx2Y7fJ5pRaa87U2jGMRAagGCpZPf/KPXYOkaL7GhCt6l6UhqQZ/A0y/BhTI0DcR\n         7ESGzMELWUIIPm4cauAh9D/DzCJU3MXqnZn2QEj6UXZlGvpe5AaCgULd5jhGWP5gbC5k\n         cjW1khqmaDO4AAgE+7i1Jw32Lif3HY4W15HkkQ1O8iHli1j3wVrEWMW1GJlZlvSYlXmi\n         RGyaDzp7uoxx3YF1rVKy04lCwZazcXGkSorGhtUb9eygF71AqmacasFi+VsHlXGIZeln\n         +7qjZktq7NYcYRfxHPfvoZyhSRbvw9gYj1nNZUu7kCiMf3BpsGBEvSzo4Jfcxon6U5zl\n         k5SA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776875370; x=1777480170;\n        h=in-reply-to:content-disposition:mime-version:references:message-id\n         :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc\n         :subject:date:message-id:reply-to;\n        bh=h9IY/0ZHCf/patsFxziV9u+pjgUJWDhTV7Q7rdgygPM=;\n        b=b5HjMZQdSYAV2WbJq1fNsRIYBIGB96mFfg6TZ7KHRSuLVe0X7NJIWNWWCRSCc4DzXM\n         cbcWSBrtLU588XLZPmNgYwx0PGyU7Y96YEvEbC/F+KgP4Zp0K3wpXFhq3btqhlr4R/q2\n         RJygziiZeasLfRZ42z78tnmZ+jAHxsoQcVG5cq+JbTgbcRXn5+cTy2U5Cnud6SAO94NN\n         NWigw5shP12DCy4h593FF6ycJlALXlSmT3x7t9yMpTMkUBQFYath1IT/kWkeZ9DxHFce\n         wHg3ZcF7ulw6goB7GPUsnkdTR9acTBXG2z3e7QMwFwb39RFAC5wXQN3+GgQ3MWitGGGF\n         zV1w==","X-Forwarded-Encrypted":"i=1;\n AFNElJ+y5HhezGBgw4yNpWARa15cPLcmteUF9nauKoujFOyX9svbPZOrp0osQ1VzA/viiZxL3DvRN4FKo2c=@vger.kernel.org","X-Gm-Message-State":"AOJu0YyoW0HgqxEDIoBQjO9atDHzhJWWlNXIlljKY6Rt0bd2LCC268CG\n\tX5H66CYqhQ0TSnMbIsD0cCruEqsTEtWsNrpDSLd/qnrUzPb9CgebdAnhdQ2j/K5TcbE=","X-Gm-Gg":"AeBDieultByJtGkUi6OSORf+S3r721CNKN4LlZb+DCJQLThCi6loW6FBFvJoudyqbaE\n\tzfLp0/nbnR2DYnL/agM++b2y1hVp9hAtlNrs1j50znh2a66W3pxVbfCQUKwXIEofx7CMseSH+j7\n\tj7yNzKoTqtRqQ2Wj6xjOYq85pmGubhbO1RJenz79dEB23JCdPnTCrRDg/viGeXPgIijqXmRbVS3\n\tCQem62JysIf5DdTPPoRlHyYqK26wljIenuQ3A+g7T+5hoNz4sc9z58WRIRcJoamDRb17KhJTR+x\n\tDYsT97W88aQcWeZJ3renPxQvVerPanzyD+OlU3xqgefZ/ikdyWt5v1gK3yJDSv0ahLKFpUsKPwf\n\t1QRRUDtCH0oWqNoACv8jZ9XC2a9ZGYlyCIavD8oMa1C8TYNrQKtGaMk+NW1JRMR/fUghJPJlcMR\n\tvXpVOVeyLKzjoAoiHlfPs5oJLb37Yg30AfgIoJWagjk0mrBhEh7mYWdBvF/YXPx68To1iQLvw94\n\t58djcIfsnBEe8ql","X-Received":"by 2002:ac8:58c6:0:b0:50e:635b:5579 with SMTP id\n d75a77b69052e-50e635b57e4mr184629681cf.19.1776875369960;\n        Wed, 22 Apr 2026 09:29:29 -0700 (PDT)","Date":"Wed, 22 Apr 2026 13:29:28 -0300","From":"Jason Gunthorpe <jgg@ziepe.ca>","To":"Alex Williamson <alex@shazbot.org>","Cc":"Zhiping Zhang <zhipingz@meta.com>, Stanislav Fomichev <sdf@meta.com>,\n\tKeith Busch <kbusch@kernel.org>, Leon Romanovsky <leon@kernel.org>,\n\tBjorn Helgaas <helgaas@kernel.org>, linux-rdma@vger.kernel.org,\n\tlinux-pci@vger.kernel.org, netdev@vger.kernel.org,\n\tdri-devel@lists.freedesktop.org, Yochai Cohen <yochai@nvidia.com>,\n\tYishai Hadas <yishaih@nvidia.com>","Subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","Message-ID":"<20260422162928.GL3611611@ziepe.ca>","References":"<20260420183920.3626389-1-zhipingz@meta.com>\n <20260420183920.3626389-2-zhipingz@meta.com>\n <20260422092327.3f629ad6@shazbot.org>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260422092327.3f629ad6@shazbot.org>"}},{"id":3680911,"web_url":"http://patchwork.ozlabs.org/comment/3680911/","msgid":"<20260422132740.5f809bf7@shazbot.org>","list_archive_url":null,"date":"2026-04-22T19:27:40","subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","submitter":{"id":91887,"url":"http://patchwork.ozlabs.org/api/people/91887/","name":"Alex Williamson","email":"alex@shazbot.org"},"content":"On Wed, 22 Apr 2026 13:29:28 -0300\nJason Gunthorpe <jgg@ziepe.ca> wrote:\n\n> On Wed, Apr 22, 2026 at 09:23:27AM -0600, Alex Williamson wrote:\n> > In general though, I'm really hoping that someone interested in\n> > enabling TPH as an interface through vfio actually decides to take\n> > resource targeting and revocation seriously.  There's no validation of\n> > the steering tag here relative to what the user has access to and no\n> > mechanism to revoke those tags if access changes.  In fact, there's not\n> > even a proposed mechanism allowing the user to derive valid steering\n> > tags.  Does the user implicitly know the value and the kernel just\n> > allows it because... yolo?   \n> \n> This is the steering tag that remote devices will send *INTO* the VFIO\n> device.\n> \n> IMHO it is entirely appropriate that the driver controlling the device\n> decide what tags are sent into it and when, so that's the VFIO\n> userspace.\n> \n> There is no concept of access here since the entire device is captured\n> by VFIO.\n> \n> If the VFIO device catastrophically malfunctions when receiving\n> certain steering tags then it is incompatible with VFIO and we should\n> at least block this new API..\n> \n> The only requirement is that the device limit the TPH to only the\n> function that is perceiving them. If a device is really broken and\n> doesn't meet that then it should be blocked off and it is probably not\n> safe to be used with VMs at all.\n\nOk, if the vfio user is only suggesting steering tags for another\ndriver to use when accessing their own device through the dma-buf, and\nthe lifecycle is bound to that dma-buf, maybe I'm overreacting on the\nsecurity aspect.\n\nI don't know how to qualify the statement in the last paragraph about\n\"[t]he only requirement is that the device limit the TPH to only the\nfunction that is perceiving them\", though.  Is that implicit in being\nassociated to the dma-buf for the user owned device, or is it a\nproperty of the suggested steering tags, that we're not validating?\n\nSteering tags can induce caching abuse, as interpreted in the\ninterconnect fabric, but maybe we've already conceded that as\nfundamental aspect of TPH in general.\n\nSo why does vfio need to be involved in any of the sequence proposed\nhere?  It seems like it would be a much cleaner design, avoiding\noverloading the existing vfio feature and questionable array semantics,\nif there were a set-tph ioctl on the resulting dma-buf instead of\nmaking some vfio specific interface bundling creation with tph hints.\nThanks,\n\nAlex","headers":{"Return-Path":"\n <linux-pci+bounces-53021-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=shazbot.org header.i=@shazbot.org header.a=rsa-sha256\n header.s=fm1 header.b=H2zqWgVu;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=messagingengine.com header.i=@messagingengine.com\n header.a=rsa-sha256 header.s=fm2 header.b=JCcSbt3U;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-pci+bounces-53021-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org\n header.b=\"H2zqWgVu\";\n\tdkim=pass (2048-bit key) header.d=messagingengine.com\n header.i=@messagingengine.com header.b=\"JCcSbt3U\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=202.12.124.146","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=shazbot.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=shazbot.org"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g18Rv22d3z1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 05:29:31 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id E24FB30E91FB\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 19:27:53 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 877C53F1642;\n\tWed, 22 Apr 2026 19:27:50 +0000 (UTC)","from fout-b3-smtp.messagingengine.com\n (fout-b3-smtp.messagingengine.com [202.12.124.146])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 389FE36E476;\n\tWed, 22 Apr 2026 19:27:45 +0000 (UTC)","from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46])\n\tby mailfout.stl.internal (Postfix) with ESMTP id B08AE1D0020D;\n\tWed, 22 Apr 2026 15:27:43 -0400 (EDT)","from phl-frontend-04 ([10.202.2.163])\n  by phl-compute-06.internal (MEProxy); Wed, 22 Apr 2026 15:27:44 -0400","by mail.messagingengine.com (Postfix) with ESMTPA; Wed,\n 22 Apr 2026 15:27:42 -0400 (EDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776886070; cv=none;\n b=eeU7XO7PwNYkcQ9uAsjcUXpXemNUCrudJ3kkH5FAw55gCpGWzqCJtzBJYnxsk9vmE5OfEjRikwdSAT5H55X8VXWqpcMycv9nFzgW4X1MatlSU4TafWDPHdSy6OMCeH2hRQKmYnlkxqKecBy2PYZLKOr09gto9q8Mn6JNz++b8J8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776886070; c=relaxed/simple;\n\tbh=CEPx4xBqpn/LM6mI/TJkP9S6SW10V8v4HWFrbAPvs3k=;\n\th=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=hf+mRD7dZIUhTvOAEnziAKbueb/BV4/mfe6E0RRPXx+s3PKLkkGo3PTIDa5qc11fG63o8EI/PNrCDQs94zM17HctXt9sgGiJKR3JrUgUKJubvqWKn7R+bw+04k/pM4IqBBL5uYEp7V6PWWMpwo/Jprf8KhmlNo62GQmX3atsct8=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=shazbot.org;\n spf=pass smtp.mailfrom=shazbot.org;\n dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org\n header.b=H2zqWgVu;\n dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com\n header.b=JCcSbt3U; arc=none smtp.client-ip=202.12.124.146","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h=\n\tcc:cc:content-transfer-encoding:content-type:content-type:date\n\t:date:from:from:in-reply-to:in-reply-to:message-id:mime-version\n\t:references:reply-to:subject:subject:to:to; s=fm1; t=1776886063;\n\t x=1776972463; bh=ggHJMFIMAYIVtfMm4SfiR6xNegxNgGhsEzHrf1YC/TQ=; b=\n\tH2zqWgVueVdHhGmA/l+SyejrcQJIuT0lMHQWPHderHUkwn/xcF3Cp84eTGQ2+kxL\n\t9ClJS3wT30glCIX1XF7Hw9s9/VzKwITM+pfCvJHSQpxf5aYzMYZgRIHqKdMPXSgW\n\t8bYv89IVb79UbHWFo0LKfep+X8FHZUSAioBYN6cvzzHQURLO4TeV9m/M6nWJF5nw\n\t8baettDbtFyn8jFTZBNWAVTwMv93ivokyrwZ6SZQ2UDTTrJ6KjDNKxdeShjhec2f\n\t3w3GKgJvEXf4Jv9Fcpfmfo+ArBZyRLasqCz2qmRQn6TkF3Bu/+8MswTi/qgwL+VY\n\t/QwEq2CqGn5i0kveGXEopg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n\tmessagingengine.com; h=cc:cc:content-transfer-encoding\n\t:content-type:content-type:date:date:feedback-id:feedback-id\n\t:from:from:in-reply-to:in-reply-to:message-id:mime-version\n\t:references:reply-to:subject:subject:to:to:x-me-proxy\n\t:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1776886063; x=\n\t1776972463; bh=ggHJMFIMAYIVtfMm4SfiR6xNegxNgGhsEzHrf1YC/TQ=; b=J\n\tCcSbt3UXqNDZdMAD+suswr0h55WRx5sH5kDsgz2ZD/mFSD5LMFjnExdX3DJGW57H\n\tsXQdLhcASd1/XUOpVYj6MATwIgP3lcMTuUfr3kSXvpWEKD7ip9zI9ZqbPFyRY3mo\n\tnJheiYHwKVoDcjZYqGjtNSI9bxDtL+fQx79a93anFOQkqIzWthsMRtVzFbL1JifQ\n\twbsUwHJWTJf3LuUPGugAkrz2x9nYoH5uJMBTKCHWFeGNnGvWI+AYyvyHpy1BqDKp\n\twpCw34NR3bkCCJIZrR/BISsN2qnXLSg60po+9MP2qsgspiGpuhzmKLIpyaLdfwAX\n\t9qGljhxwyc+JDez89jMqQ=="],"X-ME-Sender":"<xms:LyHpaSO4p1kHk-rcqnzezrRe1Kkm-d6OD7Ij4Z8yMuTOIHL9meDRcg>\n    <xme:LyHpaUrM4pP9b-SGUaPuwE9GU82tfhZ7_99k0_J_7AUHAFUisqzAVg60y8nMWtkDJ\n    qxI0FxGkM8qs0bTfcC1QJWNDwBRSzKKSc4GlIJ5pb3kRTjG-J6SmQE>","X-ME-Received":"\n <xmr:LyHpaR7FygKgFPat_6DK2XSoqf46NHfZF2B0nXadDscvLwZ_-J66Mjj1rFI>","X-ME-Proxy-Cause":"\n gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeiheduudcutefuodetggdotefrod\n    ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr\n    ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug\n    hrpeffhffvvefukfgjfhfogggtgfesthejredtredtvdenucfhrhhomheptehlvgigucgh\n    ihhllhhirghmshhonhcuoegrlhgvgiesshhhrgiisghothdrohhrgheqnecuggftrfgrth\n    htvghrnhepvdekfeejkedvudfhudfhteekudfgudeiteetvdeukedvheetvdekgfdugeev\n    ueeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg\n    hlvgigsehshhgriigsohhtrdhorhhgpdhnsggprhgtphhtthhopedufedpmhhouggvpehs\n    mhhtphhouhhtpdhrtghpthhtohepjhhgghesiihivghpvgdrtggrpdhrtghpthhtohepii\n    hhihhpihhnghiisehmvghtrgdrtghomhdprhgtphhtthhopehsughfsehmvghtrgdrtgho\n    mhdprhgtphhtthhopehksghushgthheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplh\n    gvohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgv\n    lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhrughmrgesvhhgvghrrdhkvghrnhgvlh\n    drohhrghdprhgtphhtthhopehlihhnuhigqdhptghisehvghgvrhdrkhgvrhhnvghlrdho\n    rhhgpdhrtghpthhtohepnhgvthguvghvsehvghgvrhdrkhgvrhhnvghlrdhorhhg","X-ME-Proxy":"<xmx:LyHpaUEpl0kbj3Zr_QkWClsrz5XH3Tb_GgEKBR7JhjCI0jIr-WH32g>\n    <xmx:LyHpab1-w6l48axOOr6APQzH6pTOpV24DSq5gzvVEIlVGn1Zj-gL0A>\n    <xmx:LyHpaZoDdUZ7d1egrMVpR02SBwN3wIqZ_DIsOpTJx97x6ZPSSIlwbg>\n    <xmx:LyHpaQN4guGLPxrPWNIvZBxwAXksahGHRXiNIZ8zqKvvNnqeT_fw_w>\n    <xmx:LyHpaWrLBulWkK53QFC7Xs3L67e0zKDXohnMzX3K4_ecS8-S26PQiG2V>","Feedback-ID":"i03f14258:Fastmail","Date":"Wed, 22 Apr 2026 13:27:40 -0600","From":"Alex Williamson <alex@shazbot.org>","To":"Jason Gunthorpe <jgg@ziepe.ca>","Cc":"Zhiping Zhang <zhipingz@meta.com>, Stanislav Fomichev <sdf@meta.com>,\n Keith Busch <kbusch@kernel.org>, Leon Romanovsky <leon@kernel.org>, Bjorn\n Helgaas <helgaas@kernel.org>, linux-rdma@vger.kernel.org,\n linux-pci@vger.kernel.org, netdev@vger.kernel.org,\n dri-devel@lists.freedesktop.org, Yochai Cohen <yochai@nvidia.com>, Yishai\n Hadas <yishaih@nvidia.com>, alex@shazbot.org","Subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","Message-ID":"<20260422132740.5f809bf7@shazbot.org>","In-Reply-To":"<20260422162928.GL3611611@ziepe.ca>","References":"<20260420183920.3626389-1-zhipingz@meta.com>\n\t<20260420183920.3626389-2-zhipingz@meta.com>\n\t<20260422092327.3f629ad6@shazbot.org>\n\t<20260422162928.GL3611611@ziepe.ca>","X-Mailer":"Claws Mail 4.3.1 (GTK 3.24.51; x86_64-pc-linux-gnu)","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit"}},{"id":3681500,"web_url":"http://patchwork.ozlabs.org/comment/3681500/","msgid":"<20260423142828.GQ3611611@ziepe.ca>","list_archive_url":null,"date":"2026-04-23T14:28:28","subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","submitter":{"id":73018,"url":"http://patchwork.ozlabs.org/api/people/73018/","name":"Jason Gunthorpe","email":"jgg@ziepe.ca"},"content":"On Wed, Apr 22, 2026 at 01:27:40PM -0600, Alex Williamson wrote:\n> I don't know how to qualify the statement in the last paragraph about\n> \"[t]he only requirement is that the device limit the TPH to only the\n> function that is perceiving them\", though.  Is that implicit in being\n> associated to the dma-buf for the user owned device, or is it a\n> property of the suggested steering tags, that we're not validating?\n\nIt is a property of VFs and VFIO.\n\nFor instance if an insane device allows a steering tag to reach\noutside the VF's memory space then it can't really be used with VFIO.\n\n> Steering tags can induce caching abuse, as interpreted in the\n> interconnect fabric, but maybe we've already conceded that as\n> fundamental aspect of TPH in general.\n\nsteering tags are opaque, we don't know what a device will do when it\nreceives them.\n\nThe common CPU issue is indeed cache abuse, but who knows what a\ndevice will do with them.\n\n> So why does vfio need to be involved in any of the sequence proposed\n> here?  It seems like it would be a much cleaner design, avoiding\n> overloading the existing vfio feature and questionable array semantics,\n> if there were a set-tph ioctl on the resulting dma-buf instead of\n> making some vfio specific interface bundling creation with tph\n> hints.\n\nRealistically only VFIO dmabufs will have this property that user\nspace can set any TPH.\n\nOther in-kernel drivers should accept some kind of hint from userspace\nwhen creating their dmabuf that makes sense for their device, not a\nraw TPH value. Like a GPU might accept a hint that specifies which\ndielet or something like that.\n\nSo I don't see a generality here from that perspective. The generality\nis that exporting drivers that can use TPH now have the option to tell\nthe importing driver to send them.\n\nJason","headers":{"Return-Path":"\n <linux-pci+bounces-53046-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256\n header.s=google header.b=IgRZtKjP;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-53046-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca\n header.b=\"IgRZtKjP\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.222.172","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=ziepe.ca","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=ziepe.ca"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1dt765d7z1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 00:35:27 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 11F5630B3F0D\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 14:28:42 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 808B2330D25;\n\tThu, 23 Apr 2026 14:28:32 +0000 (UTC)","from mail-qk1-f172.google.com (mail-qk1-f172.google.com\n [209.85.222.172])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id DEA8732BF52\n\tfor <linux-pci@vger.kernel.org>; Thu, 23 Apr 2026 14:28:30 +0000 (UTC)","by mail-qk1-f172.google.com with SMTP id\n af79cd13be357-8ef2118b478so279245385a.0\n        for <linux-pci@vger.kernel.org>; Thu, 23 Apr 2026 07:28:30 -0700 (PDT)","from ziepe.ca\n (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net.\n [47.54.130.67])\n        by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8eb3aa60b99sm1331296285a.42.2026.04.23.07.28.29\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Thu, 23 Apr 2026 07:28:29 -0700 (PDT)","from jgg by wakko with local (Exim 4.97)\n\t(envelope-from <jgg@ziepe.ca>)\n\tid 1wFv2a-0000000EFmA-3Fc7;\n\tThu, 23 Apr 2026 11:28:28 -0300"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776954512; cv=none;\n b=eCgsie3Vi+apjf/Vrcj9wDfkaTABCzRWAx5p5WyeSTBP3+X0hxj+D3IIlHMWRID/FIhV5dZSORvSU+8ApICSxGp3f9ZzOFM70WxrOQkdZ0wDx4+yMI6Pvi+4pqPHvt+R8hBNxgVpepdNM/yAuMUbxQzYaLtFK1f8b2L5g0Zuf1g=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776954512; c=relaxed/simple;\n\tbh=Q+CH0cryHB9H3XngNd6AR9iIUT0JpK6a3rt8/T4ped4=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=sVTs0sjXQBSV9MxPaFQEuNxBfR4ObmV4oOpDA+PpQX412u1G9FbUqztzMuYNHFW/xL2NjVXrGnHkZ0UsBqzknxMNJIfo5xwfjGKGBAL7U0M56NjBeTKqTGzZQlDd1rtxR18wQIad2DhOOjDX4OTaUIOuZ/gje/MR4hwjm7+m/lM=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=ziepe.ca;\n spf=pass smtp.mailfrom=ziepe.ca;\n dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca\n header.b=IgRZtKjP; arc=none smtp.client-ip=209.85.222.172","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=ziepe.ca; s=google; t=1776954510; x=1777559310;\n darn=vger.kernel.org;\n        h=in-reply-to:content-disposition:mime-version:references:message-id\n         :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to;\n        bh=U8vZETDzbkQ40NDAvMNX2MsWW7x5AHD6ZgWcNohscU8=;\n        b=IgRZtKjPwbD7AUMKdw6B5nazR9uBXdJ0EO4L1N/1p3itfssrbvjjqDXItCJbJZSvDM\n         fGAYoi+uT+KmXsF/N8/tZfMu2onpq9j6Iq9ycJTiYQLqorQ7WxY1d1mo2NFuZPJun1QL\n         Ce5AXmkRXAUwUyQlikMy1ilW1hSk075Tr5ruqtqARmIbdtCW9Td15eMq1DJusFThNLVS\n         iSPdo+JIM5Ig1mTA7L7a9lVEYuYOi7cpmH9MKkjM4IaXqHVJcv12atji+r7YIWNN+zSi\n         bWN3qLY330G0D5pnwH9j5VjSTTkmYNUvRbAjMwWMtCtbyYcSFByWPd/nWUhttt0j2KWo\n         BbGg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776954510; x=1777559310;\n        h=in-reply-to:content-disposition:mime-version:references:message-id\n         :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc\n         :subject:date:message-id:reply-to;\n        bh=U8vZETDzbkQ40NDAvMNX2MsWW7x5AHD6ZgWcNohscU8=;\n        b=lFHJZQVYnKogS59jhfE4IBlMoJZi+Tv5jlHREirkfgBYIxN8AXaD7eU1netDw2rTNc\n         4uGCmM54xTW1rHx+Ji4on4Fc8UFptDAySNBKWiW2uc/S9p5YMftvWK3LlOCczCADYNlL\n         VYBNwBMRwiO62vu/bWqQlXVImf2kbiaYlUzEn6rzN5HqfT6OqSAdHwUEp5RaarKNfmWQ\n         S2DpU7mPVMoV+ubDeZkeelByIuAduIup8lr49anuDiayzwwBAQA5lZ70pfd8zSAIXmv3\n         C/3em7d0WQUO9RzcGak9JSmTyUrF83SfVfKIoh1p1ZwKLwDpq739HGQ3yKchVRJvyt96\n         f2cA==","X-Forwarded-Encrypted":"i=1;\n AFNElJ8/yrBikgMHl7sxDgV5Yh1tNv3jrmvKVlX8fgxNKGCe0p8nOkimOdaLe8TiwP/EIRYCYgs1expdJNU=@vger.kernel.org","X-Gm-Message-State":"AOJu0Yx2fSZ/W9SIRzRanueqHRR+ENGzueZQECZ+dHRv+w58TAgx3BkF\n\toE26RYT6hWCwlwJzuLJlllF6YL4p4gg5qDcy5W+58z0ZJV2EENXar2k4eNPULzAhbkI=","X-Gm-Gg":"AeBDieuc+9uImSbPHQ8rs5PCvJLWTBWkmfzaEOo8MYO+4WBDOIw6IGlMUfQtqszkNEH\n\t42YbXTlF1aueFI8MVm+OvCyUoXfqahl/MGbSjntwPvMO0cwksL+8Yb1c5mHtM5WKs2HC487yjRM\n\ttzixSpWPjQH3eOR0nQ6qx4npQQ8OnMG4AkECbxyS/fL1OLms3x/8h60RWhrREsMURxASypfsyvy\n\tDFInG5ZChCTAx/OQDmsKf4SnVxNYjH2e1t5zKaQpSu5E/P9FnwGBkt+g1O4ib7rj+nxZWA2xwYc\n\t3O+IumDXnunAwUN0aSuxAs+CR9SFJ5DrE3Mxu8wquzq5bGupycpB/y25V+jNyT6owCJEPa07BA/\n\tzTHEg3d0cOx1S3+gjZlsB0cHG1OsaiI0VVQcJkChdSMt6QVqhn1uqi+eDEhNnRN6P/qomlT9v4o\n\to4hxYkBY/3ihBmrxJOoZ3oOm0JVvG1UiXT6kV8DNHUfU8e1u5W9prWrhs0gYYiVapSM1IkVbJYK\n\tMd/+mNjM5S+ceMD","X-Received":"by 2002:a05:620a:4089:b0:8d5:bb98:f3f3 with SMTP id\n af79cd13be357-8e78f82cf44mr4032915785a.15.1776954509767;\n        Thu, 23 Apr 2026 07:28:29 -0700 (PDT)","Date":"Thu, 23 Apr 2026 11:28:28 -0300","From":"Jason Gunthorpe <jgg@ziepe.ca>","To":"Alex Williamson <alex@shazbot.org>","Cc":"Zhiping Zhang <zhipingz@meta.com>, Stanislav Fomichev <sdf@meta.com>,\n\tKeith Busch <kbusch@kernel.org>, Leon Romanovsky <leon@kernel.org>,\n\tBjorn Helgaas <helgaas@kernel.org>, linux-rdma@vger.kernel.org,\n\tlinux-pci@vger.kernel.org, netdev@vger.kernel.org,\n\tdri-devel@lists.freedesktop.org, Yochai Cohen <yochai@nvidia.com>,\n\tYishai Hadas <yishaih@nvidia.com>","Subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","Message-ID":"<20260423142828.GQ3611611@ziepe.ca>","References":"<20260420183920.3626389-1-zhipingz@meta.com>\n <20260420183920.3626389-2-zhipingz@meta.com>\n <20260422092327.3f629ad6@shazbot.org>\n <20260422162928.GL3611611@ziepe.ca>\n <20260422132740.5f809bf7@shazbot.org>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260422132740.5f809bf7@shazbot.org>"}},{"id":3681649,"web_url":"http://patchwork.ozlabs.org/comment/3681649/","msgid":"<20260423132016.4a25e074@shazbot.org>","list_archive_url":null,"date":"2026-04-23T19:20:16","subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","submitter":{"id":91887,"url":"http://patchwork.ozlabs.org/api/people/91887/","name":"Alex Williamson","email":"alex@shazbot.org"},"content":"On Thu, 23 Apr 2026 11:28:28 -0300\nJason Gunthorpe <jgg@ziepe.ca> wrote:\n> On Wed, Apr 22, 2026 at 01:27:40PM -0600, Alex Williamson wrote:\n> \n> > So why does vfio need to be involved in any of the sequence proposed\n> > here?  It seems like it would be a much cleaner design, avoiding\n> > overloading the existing vfio feature and questionable array semantics,\n> > if there were a set-tph ioctl on the resulting dma-buf instead of\n> > making some vfio specific interface bundling creation with tph\n> > hints.  \n> \n> Realistically only VFIO dmabufs will have this property that user\n> space can set any TPH.\n> \n> Other in-kernel drivers should accept some kind of hint from userspace\n> when creating their dmabuf that makes sense for their device, not a\n> raw TPH value. Like a GPU might accept a hint that specifies which\n> dielet or something like that.\n> \n> So I don't see a generality here from that perspective. The generality\n> is that exporting drivers that can use TPH now have the option to tell\n> the importing driver to send them.\n\nOk, if dma_buf_ops.get_tph serves the common case of the driver\npresenting TPH values and vfio's case of the driver being only a\nconduit of user specified TPH values is unique, let's work on the vfio\nuAPI.\n\nWhy do we need to bundle dma-buf creation and TPH setting into a single\nioctl?  That's what the proposal here does and it results in a really\nugly extension with an off-by-one baked into it.\n\nMy suggestion would be that we leave VFIO_DEVICE_FEATURE_DMA_BUF\nunchanged and add a VFIO_DEVICE_FEATURE_DMA_BUF_TPH ioctl which takes\nthe fd from VFIO_DEVICE_FEATURE_DMA_BUF, along with a steering tag and\nprocessing hint.  It would fdget() the dmabuf fd, validate it's a\ndmabuf via f_ops, validate it's a vfio exported dmabuf via dmabuf->ops,\nfind the matching vfio_pci_dma_buf via priv under memory_lock, and\nstuff the provided TPH values into the object.  It would be left to the\nuser to sequence setting the TPH values on the dmabuf before the dmabuf\nis consumed by the importer.\n\nIs that a more reasonable uAPI?  Thanks,\n\nAlex","headers":{"Return-Path":"\n <linux-pci+bounces-53064-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=shazbot.org header.i=@shazbot.org header.a=rsa-sha256\n header.s=fm1 header.b=gdx1ISCQ;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=messagingengine.com header.i=@messagingengine.com\n header.a=rsa-sha256 header.s=fm2 header.b=ZUvdr8y6;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-pci+bounces-53064-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org\n header.b=\"gdx1ISCQ\";\n\tdkim=pass (2048-bit key) header.d=messagingengine.com\n header.i=@messagingengine.com header.b=\"ZUvdr8y6\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=103.168.172.153","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=shazbot.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=shazbot.org"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1mHr2qxQz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 05:24:40 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id BEE1C3029C30\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 19:20:25 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 6885F391833;\n\tThu, 23 Apr 2026 19:20:22 +0000 (UTC)","from fhigh-a2-smtp.messagingengine.com\n (fhigh-a2-smtp.messagingengine.com [103.168.172.153])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E9D83909B8;\n\tThu, 23 Apr 2026 19:20:18 +0000 (UTC)","from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46])\n\tby mailfhigh.phl.internal (Postfix) with ESMTP id 517CD140016D;\n\tThu, 23 Apr 2026 15:20:18 -0400 (EDT)","from phl-frontend-03 ([10.202.2.162])\n  by phl-compute-06.internal (MEProxy); Thu, 23 Apr 2026 15:20:18 -0400","by mail.messagingengine.com (Postfix) with ESMTPA; Thu,\n 23 Apr 2026 15:20:17 -0400 (EDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776972022; cv=none;\n b=Q5Flld9huVbWJg15xXRKye27E7Lh0oz4VeybOTDOQS08fBgk+yrFBs0juJY5YVsXAV17dC+qGkDFiZDxySRbjQ2ehkf/bUQYC8hITe0TxD+kQQ0jVN1z3pCb0U054/AyCaPsjpONT/8Y82ExfNlOawzOfK0iNgDg/eS8xviLl+4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776972022; c=relaxed/simple;\n\tbh=7OAMBqFezqilmW4ZrrxTT+MbAtt0mJHp17fXOTvbY7g=;\n\th=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=OobOmx6ylQdH+hY3ZWAuEScJUqXpRjM1yA5cQQPkRSKAac4PG1LNeCzslSKQ1cotf9guUldNe8GrLgr1bhwhatFd29CtL5fCft94Str2K49yAmYOWzDrZwkmTzFr6D4ZTX3eUlQGjMq4bsOxbCbaiNX9p21MYgiT/yx1BkpP064=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=shazbot.org;\n spf=pass smtp.mailfrom=shazbot.org;\n dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org\n header.b=gdx1ISCQ;\n dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com\n header.b=ZUvdr8y6; arc=none smtp.client-ip=103.168.172.153","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h=\n\tcc:cc:content-transfer-encoding:content-type:content-type:date\n\t:date:from:from:in-reply-to:in-reply-to:message-id:mime-version\n\t:references:reply-to:subject:subject:to:to; s=fm1; t=1776972018;\n\t x=1777058418; bh=zgX8pUM+ByGW1BJ4PzJmLl3HUKg2UKXk7RpMYuVX26w=; b=\n\tgdx1ISCQg+TSBOVzJw59r+B2kL6yGJACfaN4o+jfw1+LVBJo8M4CLyvxMZqpWhIx\n\t8fpOYl9DQkAlFfIqSSi144Ul6oti8nQ6hSCVKDwxC+s/lBtdHrv7lReF2ZngadSN\n\tOd1QCcLnTHuxXOT44WWZfQzQACQhujzMpDPuxVnmfq8rkKaOQ+ikX7We+iSqzRzO\n\tlrBOtjeU4I9U3WCOUqUbHutFZXTRaEeWJ9839dNT5HYMu8eu7IaaETPPNEntcAqf\n\t63YieUjaDu3Uo65EwCqgbc3T4uzS9avWCXOdukTXE1yhHm8iyNTcNLelKZkXBko7\n\tFtdcikH0aPB8qC7aZQPDxQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n\tmessagingengine.com; h=cc:cc:content-transfer-encoding\n\t:content-type:content-type:date:date:feedback-id:feedback-id\n\t:from:from:in-reply-to:in-reply-to:message-id:mime-version\n\t:references:reply-to:subject:subject:to:to:x-me-proxy\n\t:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1776972018; x=\n\t1777058418; bh=zgX8pUM+ByGW1BJ4PzJmLl3HUKg2UKXk7RpMYuVX26w=; b=Z\n\tUvdr8y6kuGVNdu3c0ZQYsoJsU40DdAh5s3HryOIhEf7x0mApZTi4iFdEyC/sOHH+\n\t7uxNgxnxV0i/uJwA9+WLgOk7+eKspnp5ZmPGowwF76c5XZwyVTXpJCuE6G9SI9pI\n\tJCXmyMKupSQ7GgZl01RmGH4oa/94yXKLCW9Jopu44qiDXX7TzAG9eJuKBK3KwBOp\n\t53Gh7vFoSv8P9lglzIdViXCpVS4wYjSOwwFvMBAmTuraMIYTfxi5YM5DohZxfUsS\n\tzagp3HpVZ+gSqBaYoQKpsSWl2Gh7GpamX+WRzFOIOfxUOSimzBmOvbZCFSowXc1n\n\ts/AaHraDRy7mAx+OBWdZQ=="],"X-ME-Sender":"<xms:8nDqaSocVBUsGX6Dqv_G5w1rlJmoZL84errVQL3TlmWj8TRDyuK1aw>\n    <xme:8nDqaV0BVjnH0Hj5F-hlKcd8X682cxE0tqu2brwkqUO7P9eoU9sbW3qd158Z-qwg3\n    dcfVuqBvxksctosoEesiDf4wm47d41NEex_UAhQcNeIFqWc4Db3og>","X-ME-Received":"\n <xmr:8nDqaamq_rWSOK6CdZLMRBlb5SJREhMRV-lT_9V1GmTwxSd5W0bWC35lALQ>","X-ME-Proxy-Cause":"\n gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeijeeljecutefuodetggdotefrod\n    ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr\n    ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug\n    hrpeffhffvvefukfgjfhfogggtgfesthejredtredtvdenucfhrhhomheptehlvgigucgh\n    ihhllhhirghmshhonhcuoegrlhgvgiesshhhrgiisghothdrohhrgheqnecuggftrfgrth\n    htvghrnhepvdekfeejkedvudfhudfhteekudfgudeiteetvdeukedvheetvdekgfdugeev\n    ueeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg\n    hlvgigsehshhgriigsohhtrdhorhhgpdhnsggprhgtphhtthhopedufedpmhhouggvpehs\n    mhhtphhouhhtpdhrtghpthhtohepjhhgghesiihivghpvgdrtggrpdhrtghpthhtohepii\n    hhihhpihhnghiisehmvghtrgdrtghomhdprhgtphhtthhopehsughfsehmvghtrgdrtgho\n    mhdprhgtphhtthhopehksghushgthheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplh\n    gvohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgv\n    lhdrohhrghdprhgtphhtthhopehlihhnuhigqdhrughmrgesvhhgvghrrdhkvghrnhgvlh\n    drohhrghdprhgtphhtthhopehlihhnuhigqdhptghisehvghgvrhdrkhgvrhhnvghlrdho\n    rhhgpdhrtghpthhtohepnhgvthguvghvsehvghgvrhdrkhgvrhhnvghlrdhorhhg","X-ME-Proxy":"<xmx:8nDqaRa_rMoY3-Gu0IG6in9WxOQrtHLSZfodCQRs-3oWG0hGYNOALQ>\n    <xmx:8nDqac-z_p1atCzPwxluejmtD6AzXG34JJfqwXlRQXFPUayD4aMd4w>\n    <xmx:8nDqaREJs6AGZct-AGSAW1QRMET9_rt_kBglLTDnxIKI0-7uxp8MxQ>\n    <xmx:8nDqaWezx6LiHdIh6_5BLrSXwi94wLwltOZ7z-ABrrvRs79Kw8U4iQ>\n    <xmx:8nDqaSlZyN88SxHutEDRqgWwDrmlZGWMI7VKYXHLfjociova4Iy6orlE>","Feedback-ID":"i03f14258:Fastmail","Date":"Thu, 23 Apr 2026 13:20:16 -0600","From":"Alex Williamson <alex@shazbot.org>","To":"Jason Gunthorpe <jgg@ziepe.ca>","Cc":"Zhiping Zhang <zhipingz@meta.com>, Stanislav Fomichev <sdf@meta.com>,\n Keith Busch <kbusch@kernel.org>, Leon Romanovsky <leon@kernel.org>, Bjorn\n Helgaas <helgaas@kernel.org>, linux-rdma@vger.kernel.org,\n linux-pci@vger.kernel.org, netdev@vger.kernel.org,\n dri-devel@lists.freedesktop.org, Yochai Cohen <yochai@nvidia.com>, Yishai\n Hadas <yishaih@nvidia.com>, alex@shazbot.org","Subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","Message-ID":"<20260423132016.4a25e074@shazbot.org>","In-Reply-To":"<20260423142828.GQ3611611@ziepe.ca>","References":"<20260420183920.3626389-1-zhipingz@meta.com>\n\t<20260420183920.3626389-2-zhipingz@meta.com>\n\t<20260422092327.3f629ad6@shazbot.org>\n\t<20260422162928.GL3611611@ziepe.ca>\n\t<20260422132740.5f809bf7@shazbot.org>\n\t<20260423142828.GQ3611611@ziepe.ca>","X-Mailer":"Claws Mail 4.3.1 (GTK 3.24.51; x86_64-pc-linux-gnu)","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit"}},{"id":3681706,"web_url":"http://patchwork.ozlabs.org/comment/3681706/","msgid":"<20260423224626.GV3611611@ziepe.ca>","list_archive_url":null,"date":"2026-04-23T22:46:26","subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","submitter":{"id":73018,"url":"http://patchwork.ozlabs.org/api/people/73018/","name":"Jason Gunthorpe","email":"jgg@ziepe.ca"},"content":"On Thu, Apr 23, 2026 at 01:20:16PM -0600, Alex Williamson wrote:\n\n> My suggestion would be that we leave VFIO_DEVICE_FEATURE_DMA_BUF\n> unchanged and add a VFIO_DEVICE_FEATURE_DMA_BUF_TPH ioctl which takes\n> the fd from VFIO_DEVICE_FEATURE_DMA_BUF, along with a steering tag and\n> processing hint.  It would fdget() the dmabuf fd, validate it's a\n> dmabuf via f_ops, validate it's a vfio exported dmabuf via dmabuf->ops,\n> find the matching vfio_pci_dma_buf via priv under memory_lock, and\n> stuff the provided TPH values into the object.  It would be left to the\n> user to sequence setting the TPH values on the dmabuf before the dmabuf\n> is consumed by the importer.\n> \n> Is that a more reasonable uAPI?  Thanks,\n\nOff hand I think it can work, with the proviso that if userspace uses\nthe dmabuf before setting the tph the importer may ignore it. I don't\nthink that is a problem in practice.\n\nJason","headers":{"Return-Path":"\n <linux-pci+bounces-53082-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256\n header.s=google header.b=gHsocES4;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-53082-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca\n header.b=\"gHsocES4\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.222.171","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=ziepe.ca","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=ziepe.ca"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1rmn0MTPz1yDD\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 08:46:33 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id ECC003016ED6\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 22:46:29 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 7BC5C30FC03;\n\tThu, 23 Apr 2026 22:46:29 +0000 (UTC)","from mail-qk1-f171.google.com (mail-qk1-f171.google.com\n [209.85.222.171])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 37DE12D23A6\n\tfor <linux-pci@vger.kernel.org>; Thu, 23 Apr 2026 22:46:28 +0000 (UTC)","by mail-qk1-f171.google.com with SMTP id\n af79cd13be357-8cb20bcff5aso672493585a.3\n        for <linux-pci@vger.kernel.org>; Thu, 23 Apr 2026 15:46:28 -0700 (PDT)","from ziepe.ca\n (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net.\n [47.54.130.67])\n        by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8e7d98c15a9sm1970538185a.43.2026.04.23.15.46.26\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Thu, 23 Apr 2026 15:46:26 -0700 (PDT)","from jgg by wakko with local (Exim 4.97)\n\t(envelope-from <jgg@ziepe.ca>)\n\tid 1wG2oU-0000000GMBz-0jKo;\n\tThu, 23 Apr 2026 19:46:26 -0300"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776984389; cv=none;\n b=uqkvGpIy1NSByD2ytFHP0+FUvce52A7b9vxqwFmyQqN2gis+n8s59EeYkZ4ahWc79WszYCgcB0Vj9+hsc/3w5v5yjgFTZSCGVZsvvPGmqXrNuJCzHTBwuIsRYV8MWS999/l9Z2eYzg0EyAT52TqzwKUCbSNUdjy5zz9Jj73A04w=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776984389; c=relaxed/simple;\n\tbh=l9uHSdgj37MlVqmUNMTjAdytE8mxXV9iMRTSDZHL+Qo=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=UrwCZSuegSKNjWpH3LU72R9HyFGawMwMkDsnGn+JFh6oWOT/SgCwTO0hF9PoKU4uyg+YxX+NfuOgebP3OWjWXv/KUcR6SQhiiTbCB8mns1MQobNiiG4rSEdO+MWSBh1lkUk0pKlf4uxRcAqEdjZkxoSJFBBGytghipRYQCT0jD4=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=ziepe.ca;\n spf=pass smtp.mailfrom=ziepe.ca;\n dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca\n header.b=gHsocES4; arc=none smtp.client-ip=209.85.222.171","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=ziepe.ca; s=google; t=1776984387; x=1777589187;\n darn=vger.kernel.org;\n        h=in-reply-to:content-disposition:mime-version:references:message-id\n         :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to;\n        bh=LOyCcpWY9ETk6/DQ/Zzf9IsC2/j7viPfylDYdsbXpuw=;\n        b=gHsocES4rM2iEUWKqG8kp+69ntn5/8KkwOOSvqiYUtEDR23ce6l56FUnFcdYvMklOU\n         d4iVS5lIb3Y+GL0Pnq9sDAjar03xr2XnLZije5OdOOdjBatHPNLRzHwLUkXjsDLM25G1\n         HPol8Kez21ljDOoCS1nRmB9Bl2hxNYShOzDakJLxpTpzUDnbLkKpVZZe9Hf8si1UWDLl\n         /Cj/tkVtPO0B6oC/FFGdIQihVUQjyOgTJxjcv9iAiTPKYvDblGzxvu9aLUQxbRuQ4I6I\n         q9T4Qp3qASJDwtuUTFCpGZq4yXMEbbQ+J5KEDDPrrylcADSqCh6vlyled3ozriSBybLE\n         EDGQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776984387; x=1777589187;\n        h=in-reply-to:content-disposition:mime-version:references:message-id\n         :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc\n         :subject:date:message-id:reply-to;\n        bh=LOyCcpWY9ETk6/DQ/Zzf9IsC2/j7viPfylDYdsbXpuw=;\n        b=ncPjXhQbvDCNcgf5WJdIvwF6OPS7JgkxxR6LBjrS2Zk24iiuPkUrkLf9mtxt9+fFyV\n         BmP/M4A3CNL6n999AckrsbzkOvh+sqN/Gv5Noek4+8DBZP/pnbVlgsxgqG9TqqoVHD6c\n         tZhIaunUoAA2de43KcNYNovdHs3X5YnemZrYFY1KQ0iajfLdOq7DLQcFojcE2Ov+Q993\n         a1AmMPH5w+JcLi1+rcbCawNWPUCmUl3gaYFYjfkSACVRUjXsYgQMyR7gdIysgalYpwr6\n         fxXFQOLLF/fztAaIVTB6zEse7q7f6i6KuBwFKtrhZ7k+vGHphGbhv+a+8NiSS55wTGzN\n         EP5Q==","X-Forwarded-Encrypted":"i=1;\n AFNElJ+2ihRsQY2G6c+OCcyflb6rzaWsrT7DJPdaQMl/PqBMnOpkh/pRNm31/J7QmdDgh5O7FvIZi+Aws4o=@vger.kernel.org","X-Gm-Message-State":"AOJu0YzwCzmm5vyZ1uwEiN6/LnL32Bag0/dQrjMapCaQIPpeR42giMkd\n\tcNv+iJ5KEV+Ygd1DPLBVCRCfy9eHsE7elOnRQVhxwetO58V2BE0CAyp8MQVB1lsUh2w=","X-Gm-Gg":"AeBDiesi2FlNDhFavst+QZznLa9pJ6q1JXV4ExJ/nQkl2HWAkWZdIt/bs64ayksJCW+\n\thfLolDplrlg1wHdyJ7q5Y1jWfWU/JpXWobrmXw+ul9nTU+iN7K5wDdMgFmLpb2+i+RM9x6AjFxM\n\t1U3mr5Fi/3De1ZjgWJAMta/Z7WyPRzkqJNVEBQcThq0hNom+TgKVfp7Lv7Q0MkJ5eEgUf8X+5yl\n\tAZndcqF4+qbNgZC/AQeYEtC+gJzZBq3NJntwsvr45tO1qPU9ffFsx10IJUDfNTi7NrZ9rN+XKXC\n\tkZC+/BzdziegU7mXWwfuz8H2u6RUmWLpPeVynK7VZn7G95rX0dz6mxHWIc4D+8LUj1evdHVTcgv\n\tot/aVJcv4eXghE2NXRVGmMI6+bU1OEYywgmZ9/bTL9hBS+DjW8CnQDDtqcnwWyMVw7LhJs3YEZ7\n\tvugdBA4DX4zmi42FaVJzHcYXRI2zDU8KbfpsT+ifZ+QF7etrvSoNFNNRR+rjvIRZrpKICx3crav\n\tWHm26ypH8NnCSb3L/ZQUokUTfI=","X-Received":"by 2002:a05:620a:440d:b0:8ef:74c9:daa7 with SMTP id\n af79cd13be357-8ef74c9e32fmr1451093685a.8.1776984387201;\n        Thu, 23 Apr 2026 15:46:27 -0700 (PDT)","Date":"Thu, 23 Apr 2026 19:46:26 -0300","From":"Jason Gunthorpe <jgg@ziepe.ca>","To":"Alex Williamson <alex@shazbot.org>","Cc":"Zhiping Zhang <zhipingz@meta.com>, Stanislav Fomichev <sdf@meta.com>,\n\tKeith Busch <kbusch@kernel.org>, Leon Romanovsky <leon@kernel.org>,\n\tBjorn Helgaas <helgaas@kernel.org>, linux-rdma@vger.kernel.org,\n\tlinux-pci@vger.kernel.org, netdev@vger.kernel.org,\n\tdri-devel@lists.freedesktop.org, Yochai Cohen <yochai@nvidia.com>,\n\tYishai Hadas <yishaih@nvidia.com>","Subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","Message-ID":"<20260423224626.GV3611611@ziepe.ca>","References":"<20260420183920.3626389-1-zhipingz@meta.com>\n <20260420183920.3626389-2-zhipingz@meta.com>\n <20260422092327.3f629ad6@shazbot.org>\n <20260422162928.GL3611611@ziepe.ca>\n <20260422132740.5f809bf7@shazbot.org>\n <20260423142828.GQ3611611@ziepe.ca>\n <20260423132016.4a25e074@shazbot.org>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260423132016.4a25e074@shazbot.org>"}},{"id":3681774,"web_url":"http://patchwork.ozlabs.org/comment/3681774/","msgid":"<CAH3zFs3z5WPBygyk+ZZcDhZitj3+e3=sDsyE5ZmL2iwa=Cxykw@mail.gmail.com>","list_archive_url":null,"date":"2026-04-24T05:41:28","subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","submitter":{"id":92088,"url":"http://patchwork.ozlabs.org/api/people/92088/","name":"Zhiping Zhang","email":"zhipingz@meta.com"},"content":"On Thu, Apr 23, 2026 at 3:46 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:\n>\n> >\n> On Thu, Apr 23, 2026 at 01:20:16PM -0600, Alex Williamson wrote:\n>\n> > My suggestion would be that we leave VFIO_DEVICE_FEATURE_DMA_BUF\n> > unchanged and add a VFIO_DEVICE_FEATURE_DMA_BUF_TPH ioctl which takes\n> > the fd from VFIO_DEVICE_FEATURE_DMA_BUF, along with a steering tag and\n> > processing hint.  It would fdget() the dmabuf fd, validate it's a\n> > dmabuf via f_ops, validate it's a vfio exported dmabuf via dmabuf->ops,\n> > find the matching vfio_pci_dma_buf via priv under memory_lock, and\n> > stuff the provided TPH values into the object.  It would be left to the\n> > user to sequence setting the TPH values on the dmabuf before the dmabuf\n> > is consumed by the importer.\n> >\n> > Is that a more reasonable uAPI?  Thanks,\n>\n> Off hand I think it can work, with the proviso that if userspace uses\n> the dmabuf before setting the tph the importer may ignore it. I don't\n> think that is a problem in practice.\n>\n> Jason\n\nThanks Alex and Jason!\n\nI agree that the separate feature sounds like a cleaner design and could avoid\nthe uAPI complications. For v2 I'll:\n    - Leave VFIO_DEVICE_FEATURE_DMA_BUF unchanged,\n    - Add VFIO_DEVICE_FEATURE_DMA_BUF_TPH as a SET-only feature that\n      takes the dmabuf fd, steering tag, and processing hint,\n    - Keep the dma_buf_ops.get_tph callback as-is.\nand then the userspace sequence would become:\n1. fd = VFIO_DEVICE_FEATURE_DMA_BUF  (create dmabuf, unchanged)\n2. VFIO_DEVICE_FEATURE_DMA_BUF_TPH   (set TPH on fd)\n3. pass fd to importer\n\nZhiping","headers":{"Return-Path":"\n <linux-pci+bounces-53102-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=meta.com header.i=@meta.com header.a=rsa-sha256\n header.s=s2048-2025-q2 header.b=Lm/Az7wf;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-53102-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com\n header.b=\"Lm/Az7wf\"","smtp.subspace.kernel.org;\n arc=fail smtp.client-ip=67.231.153.30","smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=meta.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=meta.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g22125kR9z1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 15:42:46 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id CAAB8300E24E\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 05:41:43 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 48BCB3451AB;\n\tFri, 24 Apr 2026 05:41:43 +0000 (UTC)","from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com\n [67.231.153.30])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B01313451B3\n\tfor <linux-pci@vger.kernel.org>; Fri, 24 Apr 2026 05:41:41 +0000 (UTC)","from pps.filterd (m0089730.ppops.net [127.0.0.1])\n\tby m0089730.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 63NH8hji1998000\n\tfor <linux-pci@vger.kernel.org>; Thu, 23 Apr 2026 22:41:40 -0700","from mail-ot1-f72.google.com (mail-ot1-f72.google.com\n [209.85.210.72])\n\tby m0089730.ppops.net (PPS) with ESMTPS id 4dpepamkda-1\n\t(version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n\tfor <linux-pci@vger.kernel.org>; Thu, 23 Apr 2026 22:41:40 -0700 (PDT)","by mail-ot1-f72.google.com with SMTP id\n 46e09a7af769-7dcc59fe0d8so5750050a34.2\n        for <linux-pci@vger.kernel.org>; Thu, 23 Apr 2026 22:41:40 -0700 (PDT)"],"ARC-Seal":["i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777009303; cv=fail;\n b=PQkl0UG0H1PVXqOw6qr4Kj4HUlmCeNGqUZtm+rYCo794kktridIoqZWo4mptislhA4xgt8p3yx5/xby0/uZNcLK/325XG7VGL1oR7iEe/GyUUnncAk8GbhrwbF3qXyV574PYiZajumAiFyTG+4thTYEoP8HQcz1HQ9zL0M8PgnE=","i=1; a=rsa-sha256; t=1777009300; cv=none;\n        d=google.com; s=arc-20240605;\n        b=CrjGOjonwHtMCizM8X/r+MhgFsZauHT9lDdGpuDyartedj+m/tGQZaO71OKLVcG/lj\n         71djXX78DyTBt+HtGhH550CtO3s7buA+ZPt+h/Lrbpp8dnNNe4VOqGXFg8NSGElyqgEc\n         1f6INJy0kCM0xbkJomvUdr4qthIpxWd21ZhBziLrvG3fC/2OYSfU1fDCQMiQKA9x2UkT\n         180JwmwEy9+T5IMXMeR7aliRzfD1cUtqPHQDtW0d3Bv+PxELDY0lW7yfCYEHr4CUADw4\n         zi+Yk4BpLrQrqyFqVU5WgXdGR27dWgdPPytByt7ypQly0MKjbfS/oJisG1aSKd6agVP5\n         uUgg=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777009303; c=relaxed/simple;\n\tbh=Q0GtZzioBAe1xOAjDbkhlrB1hPU4MmLixdCpyIV7MDw=;\n\th=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:\n\t To:Cc:Content-Type;\n b=IyQ9dKNV2nyH6iLp7RH8s97z5QLTCscK3l2/p+NjFsDy1uc5jTG/mkoH/uZghpOSJ/N7YS0af14phjtD14QdyNSpV5tUeLMfVJtpS2ElT2J4wE9H4T7c9jQa8StjMJKURFmKMVfTnQvCUMoTlFojgvAAJa32O1jwLEtmey0x2dU=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n        h=content-transfer-encoding:cc:to:subject:message-id:date:from\n         :in-reply-to:references:mime-version;\n        bh=a9nQ1tVs6iATHtHJgJt0jwwPeY71kxSwK9rxJ53fqFI=;\n        fh=fkv7hYQsrGW8zkbKQ4auIjUHagKZU97ZQia7WgAZ9l4=;\n        b=KWog2Bfcd0Fk7c+uRJ9+Jlo0o5SH3r9mutz/ov1YZa6yq+ItPQEl3SjdOps63TlvlK\n         4gxPvP9/ng8gb0Tm4UXkKEl2k2nxs4IMSVZqrKJwxGhLKAKzeo1KCjM5tlHZP1T2c4yJ\n         GlGqIHlTpKEVlz3AbgwWP1DpKSrlqIEUAFXkuk6JGju8vr9InePGzErr3r7h3jAwzqJl\n         86esoN3t5S/O0kg1JD25fr2ViZcF+8VN63ClCCjcT4nS0vYyDmJgbVT8XbF2RJJPtf97\n         mc+Tji2MCnTxi1n2yu/eeVJMLrdXOWp3JlD0EL+24SWRtftl3nhqLyTuoyLtN8WFlk1M\n         fTBg==;\n        darn=vger.kernel.org"],"ARC-Authentication-Results":["i=2; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=meta.com;\n spf=pass smtp.mailfrom=meta.com;\n dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com\n header.b=Lm/Az7wf; arc=fail smtp.client-ip=67.231.153.30","i=1; mx.google.com; arc=none"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=cc\n\t:content-transfer-encoding:content-type:date:from:in-reply-to\n\t:message-id:mime-version:references:subject:to; s=s2048-2025-q2;\n\t bh=9DPAzRc9hNFtKml/U1KgfOpti+rrtUBR6KtYeiX3hBQ=; b=Lm/Az7wf7xyF\n\tbrokmQfLsNW68y66IP7SZ8nGC1KsXbutmXjSA8cmHA2Jk5qKrwkv66B6NLirRkP7\n\tQPJwKH1umKEEjOC/XCpEBPz8VR5HvrCHOhrvpKJ8eh9uddFh+K22h5l6zVDTktN7\n\tjLt8ikr16+iDaTHEYZBdj9EwQNQuPWk9M1lNVPnUjA9qvJyXuvqeoXu9WoHbWI9B\n\tL0t0VhbSUUEr2S6i4dfX70Bl57EMc2glo6cixMdYzAixPwMAfd/ptjPwyZbZODg2\n\tEv/aMiLmg2rES2HuztP8JKZyiegA5AN6JmiDik/5gngMEQiS5J4atlbQWviM1YCu\n\tHCwba9g+jQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1777009300; x=1777614100;\n        h=content-transfer-encoding:cc:to:subject:message-id:date:from\n         :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=a9nQ1tVs6iATHtHJgJt0jwwPeY71kxSwK9rxJ53fqFI=;\n        b=JxmvQkys/my85xdCw7oUOEg70z8IwZlgp5f7wLjuOjIaNenGbyFQeOfWSioiWFqscE\n         1TLx2RCqjI0r+IXFkK6HVYmeUgALNcPFfHxl2BwfX6OUafcye5eP/E/ykhkkzEXkI+vk\n         yP7XxhyWcA/6/yCgGF3AEfPSSm7X6g0jLCkSTValxlD+izdcIY1dy8xlsGOdUv3sb9bM\n         ANtZm4Y1ZsynHHLVlhPb8V7Dq5NVSTRxA8eYPGON1jyUan1QdOZuTxiDMU8o0NSt6Hmi\n         hw/0RjwE6ESE7NCeDrY29hbJsXykiAHAsnW5A6XyHgseH2OEtrIwBTxFv47AvolF3DAz\n         Po/A==","X-Forwarded-Encrypted":"i=1;\n AFNElJ8v6XSaCseHhG/yNwpyGVXvFFhOxYW1gPuOPHRTdI4fte76Nfvw5Ep58xsPCvaTyr8WVkIV8IXAne8=@vger.kernel.org","X-Gm-Message-State":"AOJu0YwqiHcNB1gMX97o8ZQbamYEPc3hJ9tzpel7/SfwJU++91d/IgXi\n\tkRJztPBvZ7DoWih/t6+mhqPQ+JYGc324FpGH0jPQ30sCwWgCuoBGtFrbuy5LDnMhVDiZSLCUY6O\n\tgsjEE2sbOXJUMMF8eC0FOCBRVky/18Ti2N1vMlcS4Yc5amEergXqPHiQZzjk9/sz7xP/AkCYwGE\n\tDuJYaDJ4y8wfQ6+b2X8DL3pkbk0PMuXQv8Mpw=","X-Gm-Gg":"AeBDiesaptt7c0XSKTsIlzz01hDH99SJnsl4E8fGx3W763CgabWA6BXH+ZYUAiv/VrG\n\t/ZqhIqwENu1gspP58HJo3e3Pnwh0sPRY/T7/0nSpjch0PHmHjfrkJecTSOvTsT5/+HMdh1c68CJ\n\tmBevmBwgvHJWmyc5E7J/mYe65uucbxj3M1yfJBVwZO+Sk3R2HC+OGUfHj1Qup+ifwsgmn8QRsN9\n\tp4ufmo2XB2/eHUQCRrvCFxoG1pSo8VEM7Jew3+i6ZDjS4qHF+k=","X-Received":["by 2002:a05:6830:6583:b0:7dc:dd58:50c7 with SMTP id\n 46e09a7af769-7dcdd585530mr8104217a34.18.1777009299914;\n        Thu, 23 Apr 2026 22:41:39 -0700 (PDT)","by 2002:a05:6830:6583:b0:7dc:dd58:50c7 with SMTP id\n 46e09a7af769-7dcdd585530mr8104199a34.18.1777009299430; Thu, 23 Apr 2026\n 22:41:39 -0700 (PDT)"],"Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","References":"<20260420183920.3626389-1-zhipingz@meta.com>\n <20260420183920.3626389-2-zhipingz@meta.com>\n <20260422092327.3f629ad6@shazbot.org> <20260422162928.GL3611611@ziepe.ca>\n <20260422132740.5f809bf7@shazbot.org> <20260423142828.GQ3611611@ziepe.ca>\n <20260423132016.4a25e074@shazbot.org> <20260423224626.GV3611611@ziepe.ca>","In-Reply-To":"<20260423224626.GV3611611@ziepe.ca>","From":"Zhiping Zhang <zhipingz@meta.com>","Date":"Thu, 23 Apr 2026 22:41:28 -0700","X-Gm-Features":"AQROBzB7q1PXr8uzLTg3LU7rQ4HbjUzfZl_SYDl7pi8tYSw_JSwSgZ8wHqWD6es","Message-ID":"\n <CAH3zFs3z5WPBygyk+ZZcDhZitj3+e3=sDsyE5ZmL2iwa=Cxykw@mail.gmail.com>","Subject":"Re: [PATCH v1 1/2] vfio: add callback to get tph info for dma-buf","To":"Jason Gunthorpe <jgg@ziepe.ca>","Cc":"Alex Williamson <alex@shazbot.org>, Stanislav Fomichev <sdf@meta.com>,\n        Keith Busch <kbusch@kernel.org>, Leon Romanovsky <leon@kernel.org>,\n        Bjorn Helgaas <helgaas@kernel.org>, linux-rdma@vger.kernel.org,\n        linux-pci@vger.kernel.org, netdev@vger.kernel.org,\n        dri-devel@lists.freedesktop.org, Yochai Cohen <yochai@nvidia.com>,\n        Yishai Hadas <yishaih@nvidia.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","X-Proofpoint-ORIG-GUID":"yj9PDlngPmeFrA3vTsxQob0mYB-44MWv","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDI0MDA0OCBTYWx0ZWRfXwFzyCVf52WVS\n /bvPbViitPmI6LbvnQjk058wH0EGs6gAIsz7QbwcmqB6RhMXJMFDmuSQhk/qjjMG4X6nZUJEfKn\n o9xmTR9RReP675b55dMPJRweDPHIArtWYrJku593TONs+UxmsxpNPf+3UkNcNl/xUXf43AoQGKy\n Pj+uiT/Ml0HYHPPqDHE6znNyWKOpsrPE+vSTgr/dd+hwrvR+M5BtPHFhy9SbdFui0QREXFFjh+X\n C44Gb6ZR5TYs0CcF3qd7KkBXgttWPh00IVhkHkgY4jS+s4qyP2eSaGv8hdXL2BJS6pqTqtMhN8T\n kZKmyzq4T4UvBaFdZjKg6FPokl0MI/H8NyrF5dpsp+/n0AYykdz7eKw9StNApsecsKYg5e6Z1bo\n qQd0LkV+ZpxLBcEalltkOIgNngL2Qm5pKQBge1LUHGRBaqn1dxVJbAelCdLGHP6MUTpPon1SDzx\n LKS2Ap5R1aGe++jFJRg==","X-Proofpoint-GUID":"yj9PDlngPmeFrA3vTsxQob0mYB-44MWv","X-Authority-Analysis":"v=2.4 cv=MIJQXsZl c=1 sm=1 tr=0 ts=69eb0294 cx=c_pps\n a=+3WqYijBVYhDct2f5Fivkw==:117 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10\n a=VkNPw1HP01LnGYTKEx00:22 a=7x6HtfJdh03M6CCDgxCd:22 a=855S8uPTkML1Oy45N9_h:22\n a=9jRdOu3wAAAA:8 a=4OgE2WNpP8yww339eGMA:9 a=QEXdDO2ut3YA:10\n a=ZE6KLimJVUuLrTuGpvhn:22","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-23_03,2026-04-21_02,2025-10-01_01"}}]