From: Chengwen Feng <fengchengwen@huawei.com>
To: <alex@shazbot.org>, <jgg@ziepe.ca>
Cc: <wathsala.vithanage@arm.com>, <helgaas@kernel.org>,
<wei.huang2@amd.com>, <wangzhou1@hisilicon.com>,
<wangyushan12@huawei.com>, <liuyonglong@huawei.com>,
<kvm@vger.kernel.org>, <linux-pci@vger.kernel.org>
Subject: [PATCH v8 0/7] vfio/pci: Add PCIe TPH support
Date: Fri, 8 May 2026 14:40:46 +0800 [thread overview]
Message-ID: <20260508064053.37529-1-fengchengwen@huawei.com> (raw)
This patchset enables userspace control over PCIe TPH steering tags,
motivated by the following considerations:
1. Why userspace needs the capability to control steering tags:
When PCIe devices are fully owned by userspace workloads such as DPDK
and SPDK, only userspace has full knowledge of core binding policies
and traffic distribution strategies. Without this series, userspace
cannot enable TPH or configure steering tags, leaving built-in PCIe
performance optimizations unused in high-throughput polling I/O
scenarios.
2. Why this interface must be implemented in VFIO:
VFIO is the standard, secure community solution for granting full
PCIe device ownership to userspace. Existing kernel TPH interfaces
are designed purely for in-kernel drivers. For user-owned devices,
VFIO provides the only isolated and correct path to expose per-device
TPH management.
TPH supports both IV and DS modes. Since device-specific (DS) TPH mode
introduces cross-VM isolation risks such as untrusted guests programming
arbitrary steering tags to impact other domains, so a new module parameter
`enable_unsafe_tph_ds_mode` is added. It defaults to off, and blocks all
unsafe DS-mode TPH operations when disabled.
To restrict abuse of SET_ST and prevent arbitrary steering tag programming
from userspace, the interface only accepts explicit CPU ID, memory type
and index inputs. The kernel resolves the corresponding steering tag
internally before programming, limiting userspace to controlled,
index-based configuration.
Based on earlier RFC work by Wathsala Vithanage
v8:
- Make GET_ST op could retrieve CPU's steer tags for DS mode.
note: the original impl could for DS mode + No ST Table, the
backgroud is that we found one netcard defined ST table with DS
mode, but also need to config set ST by device-specific way.
- Support verify index when SET_ST.
- Fix Sashiko review comments:
1. Add fix pcie_tph_get_st_table_size for msi-x table commit
2. Add argsz validation for GET/SET_ST copy st
3. Verify mem-type when SET_ST with cpu=U32_MAX
v7:
- Address Bjorn's comment on [1/6] commit.
- Don't report ds mode defaultly (enable_unsafe_tph_ds_mode=0)
- Fix Sashiko review comments:
1. pcie_tph_get_st_table_loc()'s stub return 0
2. Tph ioctl argsz validation wrong use offsetofend
3. Disable TPH when device was taken-over/close to/by userspace
4. Serialize all TPH operations under vdev->igate to prevent hardware
control and bitfield races.
5. Check unused ioctl field to be zero.
v6:
- Address Alex's comment on [1/6] commit.
- Fix Sashiko review comments:
Add tph_cap validation for pcie_tph_get_st_modes/st_table_loc.
Add argsz validation for each op cmd.
Move disable tph from ioctl-reset to register.
Verify reserved field for get/set ST op.
Fix ABI mismatch due to pointer arithmetic of get/st ST op.
Chengwen Feng (7):
PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction
PCI/TPH: Export pcie_tph_get_st_modes() for external use
PCI/TPH: Fix pcie_tph_get_st_table_size() for MSI-X table location
vfio/pci: Add PCIe TPH interface with capability query
vfio/pci: Add PCIe TPH enable/disable support
vfio/pci: Add PCIe TPH GET_ST interface
vfio/pci: Add PCIe TPH SET_ST interface
drivers/pci/tph.c | 31 ++--
drivers/vfio/pci/vfio_pci.c | 13 +-
drivers/vfio/pci/vfio_pci_core.c | 270 ++++++++++++++++++++++++++++++-
include/linux/pci-tph.h | 7 +
include/linux/vfio_pci_core.h | 3 +-
include/uapi/linux/vfio.h | 133 +++++++++++++++
6 files changed, 444 insertions(+), 13 deletions(-)
--
2.17.1
next reply other threads:[~2026-05-08 6:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 6:40 Chengwen Feng [this message]
2026-05-08 6:40 ` [PATCH v8 1/7] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-05-08 6:40 ` [PATCH v8 2/7] PCI/TPH: Export pcie_tph_get_st_modes() for external use Chengwen Feng
2026-05-08 19:02 ` sashiko-bot
2026-05-08 6:40 ` [PATCH v8 3/7] PCI/TPH: Fix pcie_tph_get_st_table_size() for MSI-X table location Chengwen Feng
2026-05-08 19:31 ` sashiko-bot
2026-05-08 6:40 ` [PATCH v8 4/7] vfio/pci: Add PCIe TPH interface with capability query Chengwen Feng
2026-05-08 20:03 ` sashiko-bot
2026-05-08 22:40 ` Alex Williamson
2026-05-09 3:28 ` fengchengwen
2026-05-11 4:36 ` Alex Williamson
2026-05-08 6:40 ` [PATCH v8 5/7] vfio/pci: Add PCIe TPH enable/disable support Chengwen Feng
2026-05-08 20:46 ` sashiko-bot
2026-05-08 6:40 ` [PATCH v8 6/7] vfio/pci: Add PCIe TPH GET_ST interface Chengwen Feng
2026-05-08 6:40 ` [PATCH v8 7/7] vfio/pci: Add PCIe TPH SET_ST interface Chengwen Feng
2026-05-08 21:49 ` 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=20260508064053.37529-1-fengchengwen@huawei.com \
--to=fengchengwen@huawei.com \
--cc=alex@shazbot.org \
--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 \
/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