Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Alex Williamson <alex@shazbot.org>
To: Chengwen Feng <fengchengwen@huawei.com>
Cc: <jgg@ziepe.ca>, <helgaas@kernel.org>,
	<wathsala.vithanage@arm.com>, <wei.huang2@amd.com>,
	<zhipingz@meta.com>, <wangzhou1@hisilicon.com>,
	<wangyushan12@huawei.com>, <liuyonglong@huawei.com>,
	<kvm@vger.kernel.org>, <linux-pci@vger.kernel.org>,
	alex@shazbot.org
Subject: Re: [PATCH v19 10/18] vfio/pci: Introduce tph policy parameter for staged TPH feature enablement
Date: Wed, 8 Jul 2026 17:31:41 -0600	[thread overview]
Message-ID: <20260708173141.31aae027@shazbot.org> (raw)
In-Reply-To: <20260702124224.57168-11-fengchengwen@huawei.com>

On Thu, 2 Jul 2026 20:42:16 +0800
Chengwen Feng <fengchengwen@huawei.com> wrote:

> Add a module parameter 'tph' to implement staged TPH feature enabling
> policy. The parameter accepts a value from 0 to 3 to progressively enable
> TPH capabilities:
> 
> 0 = No-ST mode: RESOLVE only returns PH for DMABUF source;
>                 ST programming unavailable
> 1 = Add IV mode: RESOLVE only returns PH for DMABUF source;
>                  ST program supports NONE/DMABUF/CPU sources
> 2 = Add DS mode: RESOLVE returns PH+ST for DMABUF/CPU sources;
>                  ST program supports NONE/DMABUF/CPU sources
> 3 = Add LITERAL: RESOLVE returns PH+ST for DMABUF/CPU sources;
>                  ST program supports NONE/DMABUF/CPU/LITERAL sources
> 
> This commit only adds parameter plumbing and state storage, no
> functional TPH logic is introduced yet.

This adds module options for a feature that doesn't exist yet.  That's
the wrong ordering.  The module option is the only introspection that
the administrator has to the capabilities of the driver.

The intention of the proposal was also that support is added
incrementally, ie. "an incremental support path".

We should start with adding No-ST support to the driver, concluding
with the module parameter infrastructure that essentially advertises
the driver support on the host, 0 (default) is the only accepted value.

The next step would be incrementally revising the driver support to
include IV mode, concluding with exposing it and configuring it through
the driver option. Repeat for DS mode.  Repeat for LITERAL mode.

This is what allows us to decide where to stop in the implementation.
For example, we've designed LITERAL mode, but if no VMM intends to
support it, why implement it?

Also, this module option is being defined on vfio_pci.  Are we
intending that this is a feature that each variant driver would
opt-in to via their own module options?  LITERAL mode is incompatible
with migration, so it's possible each variant driver would define what
level of support they expose.  Thanks,

Alex

 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  drivers/vfio/pci/vfio_pci.c      | 25 +++++++++++++++++++++++++
>  drivers/vfio/pci/vfio_pci_priv.h |  7 +++++++
>  include/linux/vfio_pci_core.h    |  1 +
>  3 files changed, 33 insertions(+)
> 
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 830369ff878d..7ef82b445722 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -60,6 +60,28 @@ static bool disable_denylist;
>  module_param(disable_denylist, bool, 0444);
>  MODULE_PARM_DESC(disable_denylist, "Disable use of device denylist. Disabling the denylist allows binding to devices with known errata that may lead to exploitable stability or security issues when accessed by untrusted users.");
>  
> +static unsigned int tph_policy;
> +static int tph_set(const char *val, const struct kernel_param *kp)
> +{
> +	return param_set_uint_minmax(val, kp, VFIO_PCI_TPH_POLICY_NO_ST,
> +				     VFIO_PCI_TPH_POLICY_LITERAL);
> +}
> +static const struct kernel_param_ops tph_param_ops = {
> +	.set = tph_set,
> +	.get = param_get_uint,
> +};
> +module_param_cb(tph, &tph_param_ops, &tph_policy, 0644);
> +MODULE_PARM_DESC(tph,
> +	"Global TPH policy level (0=default No-ST):\n"
> +	"0 = No-ST mode: RESOLVE only returns PH for DMABUF source;\n"
> +	"                ST programming unavailable\n"
> +	"1 = Add IV mode: RESOLVE only returns PH for DMABUF source;\n"
> +	"                 ST program supports NONE/DMABUF/CPU sources\n"
> +	"2 = Add DS mode: RESOLVE returns PH+ST for DMABUF/CPU sources;\n"
> +	"                 ST program supports NONE/DMABUF/CPU sources\n"
> +	"3 = Add LITERAL: RESOLVE returns PH+ST for DMABUF/CPU sources;\n"
> +	"                 ST program supports NONE/DMABUF/CPU/LITERAL sources\n");
> +
>  static bool vfio_pci_dev_in_denylist(struct pci_dev *pdev)
>  {
>  	switch (pdev->vendor) {
> @@ -142,6 +164,9 @@ static int vfio_pci_init_dev(struct vfio_device *core_vdev)
>  #ifdef CONFIG_VFIO_PCI_VGA
>  	vdev->disable_vga = disable_vga;
>  #endif
> +#ifdef CONFIG_PCIE_TPH
> +	vdev->tph_policy = tph_policy;
> +#endif
>  
>  	return vfio_pci_core_init_dev(core_vdev);
>  }
> diff --git a/drivers/vfio/pci/vfio_pci_priv.h b/drivers/vfio/pci/vfio_pci_priv.h
> index fca9d0dfac90..c997cc9bf330 100644
> --- a/drivers/vfio/pci/vfio_pci_priv.h
> +++ b/drivers/vfio/pci/vfio_pci_priv.h
> @@ -11,6 +11,13 @@
>  /* Cap maximum number of ioeventfds per device (arbitrary) */
>  #define VFIO_PCI_IOEVENTFD_MAX		1000
>  
> +enum vfio_pci_tph_policy {
> +	VFIO_PCI_TPH_POLICY_NO_ST = 0,
> +	VFIO_PCI_TPH_POLICY_IV_ST = 1,
> +	VFIO_PCI_TPH_POLICY_DS_ST = 2,
> +	VFIO_PCI_TPH_POLICY_LITERAL = 3,
> +};
> +
>  struct vfio_pci_ioeventfd {
>  	struct list_head	next;
>  	struct vfio_pci_core_device	*vdev;
> diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h
> index 9a1674c152aa..a0641286dd90 100644
> --- a/include/linux/vfio_pci_core.h
> +++ b/include/linux/vfio_pci_core.h
> @@ -149,6 +149,7 @@ struct vfio_pci_core_device {
>  	struct notifier_block	nb;
>  	struct rw_semaphore	memory_lock;
>  	struct list_head	dmabufs;
> +	u8			tph_policy;
>  };
>  
>  enum vfio_pci_io_width {


  parent reply	other threads:[~2026-07-08 23:33 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 12:42 [PATCH v19 00/18] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-07-02 12:42 ` [PATCH v19 01/18] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-07-02 12:51   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 02/18] PCI/TPH: Fix tph_enabled concurrent update race by bitfield packing Chengwen Feng
2026-07-02 12:51   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 03/18] PCI/TPH: Cache TPH requester capability at probe time Chengwen Feng
2026-07-02 12:55   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 04/18] PCI/TPH: Refactor pcie_enable_tph & add explicit requester variant Chengwen Feng
2026-07-02 12:50   ` sashiko-bot
2026-07-08 23:33   ` Alex Williamson
2026-07-09  9:22     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 05/18] PCI/TPH: Refactor pcie_tph_get_cpu_st & add explicit variant Chengwen Feng
2026-07-02 12:56   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 06/18] PCI/TPH: Expose the enabled TPH requester type Chengwen Feng
2026-07-02 12:49   ` sashiko-bot
2026-07-08 23:33   ` Alex Williamson
2026-07-09  9:30     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 07/18] PCI/TPH: Add pcie_tph_supported() helper to check TPH capability attributes Chengwen Feng
2026-07-02 12:53   ` sashiko-bot
2026-07-03  0:39     ` fengchengwen
2026-07-08 23:32   ` Alex Williamson
2026-07-09  9:36     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 08/18] PCI/TPH: Add pci_tph_dsm_supported() helper to detect device TPH ST _DSM Chengwen Feng
2026-07-02 12:55   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 09/18] vfio/pci: Hide TPH capability when TPH is unsupported Chengwen Feng
2026-07-02 13:00   ` sashiko-bot
2026-07-03  0:36     ` fengchengwen
2026-07-08 23:32   ` Alex Williamson
2026-07-09 11:00     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 10/18] vfio/pci: Introduce tph policy parameter for staged TPH feature enablement Chengwen Feng
2026-07-02 12:50   ` sashiko-bot
2026-07-08 23:31   ` Alex Williamson [this message]
2026-07-09 11:29     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 11/18] vfio/pci: Virtualize PCIe TPH capability registers Chengwen Feng
2026-07-02 13:04   ` sashiko-bot
2026-07-03  0:51     ` fengchengwen
2026-07-08 23:31   ` Alex Williamson
2026-07-09 11:40     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 12/18] vfio/pci: Add dmabuf TPH metadata storage and fd query helper Chengwen Feng
2026-07-02 12:56   ` sashiko-bot
2026-07-03  0:53     ` fengchengwen
2026-07-08 23:31   ` Alex Williamson
2026-07-09 11:49     ` fengchengwen
2026-07-09 18:50       ` Alex Williamson
2026-07-02 12:42 ` [PATCH v19 13/18] vfio/pci: Introduce VFIO_DEVICE_FEATURE_TPH family uapi for PCI TPH control Chengwen Feng
2026-07-02 13:01   ` sashiko-bot
2026-07-03  0:57     ` fengchengwen
2026-07-08 23:31   ` Alex Williamson
2026-07-09 11:56     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 14/18] vfio/pci: Implement VFIO_DEVICE_FEATURE_TPH and valid TPH config write support Chengwen Feng
2026-07-02 13:04   ` sashiko-bot
2026-07-03  1:16     ` fengchengwen
2026-07-08 23:30   ` Alex Williamson
2026-07-09 12:16     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 15/18] vfio/pci: Implement TPH_RESOLVE feature for DMABUF and CPU source resolving Chengwen Feng
2026-07-02 13:00   ` sashiko-bot
2026-07-03  1:26     ` fengchengwen
2026-07-08 23:31   ` Alex Williamson
2026-07-09 12:20     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 16/18] vfio/pci: Implement TPH_ST feature for batch ST table programming Chengwen Feng
2026-07-02 13:04   ` sashiko-bot
2026-07-03  1:42     ` fengchengwen
2026-07-08 23:29   ` Alex Williamson
2026-07-09 12:36     ` fengchengwen
2026-07-09 13:49       ` Alex Williamson
2026-07-02 12:42 ` [PATCH v19 17/18] vfio/pci: Reset hardware TPH state on device enable/disable Chengwen Feng
2026-07-02 13:00   ` sashiko-bot
2026-07-08 23:29   ` Alex Williamson
2026-07-09 12:39     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 18/18] vfio/pci: Expose tph_policy via debugfs Chengwen Feng
2026-07-02 12:59   ` sashiko-bot

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=20260708173141.31aae027@shazbot.org \
    --to=alex@shazbot.org \
    --cc=fengchengwen@huawei.com \
    --cc=helgaas@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kvm@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=wangyushan12@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=wathsala.vithanage@arm.com \
    --cc=wei.huang2@amd.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