{"id":2234856,"url":"http://patchwork.ozlabs.org/api/1.2/covers/2234856/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/cover/20260508064053.37529-1-fengchengwen@huawei.com/","project":{"id":28,"url":"http://patchwork.ozlabs.org/api/1.2/projects/28/?format=json","name":"Linux PCI development","link_name":"linux-pci","list_id":"linux-pci.vger.kernel.org","list_email":"linux-pci@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260508064053.37529-1-fengchengwen@huawei.com>","list_archive_url":null,"date":"2026-05-08T06:40:46","name":"[v8,0/7] vfio/pci: Add PCIe TPH support","submitter":{"id":92756,"url":"http://patchwork.ozlabs.org/api/1.2/people/92756/?format=json","name":"fengchengwen","email":"fengchengwen@huawei.com"},"mbox":"http://patchwork.ozlabs.org/project/linux-pci/cover/20260508064053.37529-1-fengchengwen@huawei.com/mbox/","series":[{"id":503332,"url":"http://patchwork.ozlabs.org/api/1.2/series/503332/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=503332","date":"2026-05-08T06:40:48","name":"vfio/pci: Add PCIe TPH support","version":8,"mbox":"http://patchwork.ozlabs.org/series/503332/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/covers/2234856/comments/","headers":{"Return-Path":"\n <linux-pci+bounces-54233-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 (1024-bit key;\n unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256\n header.s=dkim header.b=ArCIBStd;\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-54233-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com\n header.b=\"ArCIBStd\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=113.46.200.224","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=huawei.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=huawei.com"],"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 4gBffc3dcsz1yCg\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 08 May 2026 16:41:44 +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 00041300652F\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  8 May 2026 06:41:37 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id D7160379EF0;\n\tFri,  8 May 2026 06:41:21 +0000 (UTC)","from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com\n [113.46.200.224])\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 6B07231AAB8;\n\tFri,  8 May 2026 06:41:14 +0000 (UTC)","from mail.maildlp.com (unknown [172.19.163.15])\n\tby canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4gBfT44tJpz1cyPS;\n\tFri,  8 May 2026 14:33:28 +0800 (CST)","from kwepemk500009.china.huawei.com (unknown [7.202.194.94])\n\tby mail.maildlp.com (Postfix) with ESMTPS id 58AC240539;\n\tFri,  8 May 2026 14:41:01 +0800 (CST)","from localhost.localdomain (10.50.163.32) by\n kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.2.1544.11; Fri, 8 May 2026 14:41:00 +0800"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778222480; cv=none;\n b=bctzgwdXR+LGvq+bLhp/eaSjKpFDGwEg46m31gpg/Yj5wI3sBg0IY4TrkvAACqnO9vW/a9dv4Vg7ccjCn9Vl93GlUzbjJ+/rEsSAkQAXjOE2EXlE1q7MS6iqpqKksXckHhHfwiE3snuz7ho0cVgH49N6/uhpYs2IsM+aOd/3he0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778222480; c=relaxed/simple;\n\tbh=xGRZ4OmQ0KuvcjKHeUJmCWEEs9vMlK4loRI41L5P5g4=;\n\th=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type;\n b=Xbk2K4E1J/bwejBqIRQM12jcDmEh023oA3vltVuKPc0qupkJe+hgtWc1PzTjFMiw0vnal183dBCw2lQKOz8tWrwBDSYKyexwRvSvxhA5gxLHTs/NH/6b3Q1o7o5jLxAec3MLeaWvS4kuJxcTRPAWXU7wPAx+z/G2193WOMnJ4J0=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=huawei.com;\n spf=pass smtp.mailfrom=huawei.com;\n dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com\n header.b=ArCIBStd; arc=none smtp.client-ip=113.46.200.224","dkim-signature":"v=1; a=rsa-sha256; d=huawei.com; s=dkim;\n\tc=relaxed/relaxed; q=dns/txt;\n\th=From;\n\tbh=nyHR0B63wyTaTh8o4kUl/34N5xi2G3wRGQ5CBNhUZEc=;\n\tb=ArCIBStduRjJXjzwZS0UshBaz55ml9Whqk9SIwPvpQ9w10TUQQKomUmfUzyYHaf0Q5LWEYAqf\n\tE3dwpWpLQg2vKLKeTt41a62QV8EDeXSuzwBD6wTMuMaLIz45GkIqkYsirbQlNWcLbBGWnlc3yAZ\n\t9y8pmyJ5rP4Uwe5VWc3yB5U=","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>,\n\t<wangzhou1@hisilicon.com>, <wangyushan12@huawei.com>,\n\t<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","Message-ID":"<20260508064053.37529-1-fengchengwen@huawei.com>","X-Mailer":"git-send-email 2.17.1","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","X-ClientProxiedBy":"kwepems100002.china.huawei.com (7.221.188.206) To\n kwepemk500009.china.huawei.com (7.202.194.94)"},"content":"This patchset enables userspace control over PCIe TPH steering tags,\nmotivated by the following considerations:\n\n1. Why userspace needs the capability to control steering tags:\n   When PCIe devices are fully owned by userspace workloads such as DPDK\n   and SPDK, only userspace has full knowledge of core binding policies\n   and traffic distribution strategies. Without this series, userspace\n   cannot enable TPH or configure steering tags, leaving built-in PCIe\n   performance optimizations unused in high-throughput polling I/O\n   scenarios.\n\n2. Why this interface must be implemented in VFIO:\n   VFIO is the standard, secure community solution for granting full\n   PCIe device ownership to userspace. Existing kernel TPH interfaces\n   are designed purely for in-kernel drivers. For user-owned devices,\n   VFIO provides the only isolated and correct path to expose per-device\n   TPH management.\n\nTPH supports both IV and DS modes. Since device-specific (DS) TPH mode\nintroduces cross-VM isolation risks such as untrusted guests programming\narbitrary steering tags to impact other domains, so a new module parameter\n`enable_unsafe_tph_ds_mode` is added. It defaults to off, and blocks all\nunsafe DS-mode TPH operations when disabled.\n\nTo restrict abuse of SET_ST and prevent arbitrary steering tag programming\nfrom userspace, the interface only accepts explicit CPU ID, memory type\nand index inputs. The kernel resolves the corresponding steering tag\ninternally before programming, limiting userspace to controlled,\nindex-based configuration.\n\nBased on earlier RFC work by Wathsala Vithanage\n\nv8:\n- Make GET_ST op could retrieve CPU's steer tags for DS mode.\n  note: the original impl could for DS mode + No ST Table, the\n  backgroud is that we found one netcard defined ST table with DS\n  mode, but also need to config set ST by device-specific way.\n- Support verify index when SET_ST.\n- Fix Sashiko review comments:\n  1. Add fix pcie_tph_get_st_table_size for msi-x table commit\n  2. Add argsz validation for GET/SET_ST copy st\n  3. Verify mem-type when SET_ST with cpu=U32_MAX\nv7:\n- Address Bjorn's comment on [1/6] commit.\n- Don't report ds mode defaultly (enable_unsafe_tph_ds_mode=0)\n- Fix Sashiko review comments:\n  1. pcie_tph_get_st_table_loc()'s stub return 0\n  2. Tph ioctl argsz validation wrong use offsetofend\n  3. Disable TPH when device was taken-over/close to/by userspace\n  4. Serialize all TPH operations under vdev->igate to prevent hardware\n     control and bitfield races.\n  5. Check unused ioctl field to be zero.\nv6:\n- Address Alex's comment on [1/6] commit.\n- Fix Sashiko review comments:\n  Add tph_cap validation for pcie_tph_get_st_modes/st_table_loc.\n  Add argsz validation for each op cmd.\n  Move disable tph from ioctl-reset to register.\n  Verify reserved field for get/set ST op.\n  Fix ABI mismatch due to pointer arithmetic of get/st ST op.\n\nChengwen Feng (7):\n  PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction\n  PCI/TPH: Export pcie_tph_get_st_modes() for external use\n  PCI/TPH: Fix pcie_tph_get_st_table_size() for MSI-X table location\n  vfio/pci: Add PCIe TPH interface with capability query\n  vfio/pci: Add PCIe TPH enable/disable support\n  vfio/pci: Add PCIe TPH GET_ST interface\n  vfio/pci: Add PCIe TPH SET_ST interface\n\n drivers/pci/tph.c                |  31 ++--\n drivers/vfio/pci/vfio_pci.c      |  13 +-\n drivers/vfio/pci/vfio_pci_core.c | 270 ++++++++++++++++++++++++++++++-\n include/linux/pci-tph.h          |   7 +\n include/linux/vfio_pci_core.h    |   3 +-\n include/uapi/linux/vfio.h        | 133 +++++++++++++++\n 6 files changed, 444 insertions(+), 13 deletions(-)"}