From: sashiko-bot@kernel.org
To: "Chengwen Feng" <fengchengwen@huawei.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v7 3/6] vfio/pci: Add PCIe TPH interface with capability query
Date: Thu, 07 May 2026 23:20:17 +0000 [thread overview]
Message-ID: <20260507232017.A0AC6C2BCB2@smtp.kernel.org> (raw)
In-Reply-To: <20260507130956.34441-4-fengchengwen@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The ST table size (`st_table_sz`) is incorrectly reported as 0 when the Steering Tag (ST) table is located in the MSI-X table.
--
commit 84cffb4ace52d740319be3c3a2f634b68268963c
Author: Chengwen Feng <fengchengwen@huawei.com>
vfio/pci: Add PCIe TPH interface with capability query
This commit adds the VFIO_DEVICE_PCI_TPH IOCTL to allow userspace to query
device TPH capabilities, supported modes, and steering tag table information.
It also introduces a module parameter to restrict unsafe device-specific TPH
mode to trusted userspace only.
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index 3f8d093aacf8a..e7efa8f230bec 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
[ ... ]
> @@ -1461,6 +1463,55 @@ static int vfio_pci_ioctl_ioeventfd(struct vfio_pci_core_device *vdev,
> ioeventfd.fd);
> }
>
> +static int vfio_pci_tph_get_cap(struct vfio_pci_core_device *vdev,
> + struct vfio_device_pci_tph_op *op,
> + void __user *uarg)
> +{
> + struct pci_dev *pdev = vdev->pdev;
> + struct vfio_pci_tph_cap cap = {0};
> + u8 mode;
> +
> + if (op->argsz < offsetofend(struct vfio_device_pci_tph_op, cap))
> + return -EINVAL;
> +
> + mode = pcie_tph_get_st_modes(pdev);
> + if (!enable_unsafe_tph_ds_mode)
> + mode &= ~PCI_TPH_CAP_ST_DS;
> + if (mode == 0 || mode == PCI_TPH_CAP_ST_NS)
> + return -EOPNOTSUPP;
> +
> + if (mode & PCI_TPH_CAP_ST_IV)
> + cap.supported_modes |= VFIO_PCI_TPH_MODE_IV;
> + if (mode & PCI_TPH_CAP_ST_DS)
> + cap.supported_modes |= VFIO_PCI_TPH_MODE_DS;
> +
> + if (pcie_tph_get_st_table_loc(pdev) != PCI_TPH_LOC_NONE)
> + cap.st_table_sz = pcie_tph_get_st_table_size(pdev);
Is it possible that st_table_sz is incorrectly reported as 0 here when the
Steering Tag (ST) table is located in the MSI-X table?
The kernel function pcie_tph_get_st_table_size() returns 0 if the ST table
location is anything other than PCI_TPH_LOC_CAP, meaning it returns 0 for
PCI_TPH_LOC_MSIX.
As a result, userspace would receive st_table_sz == 0, which the UAPI
documentation explicitly defines as 'no ST table'.
Furthermore, because the location is not PCI_TPH_LOC_NONE, any subsequent
userspace attempt to use VFIO_PCI_TPH_GET_ST would be rejected by the kernel
with -EOPNOTSUPP.
This would leave userspace completely unable to properly program the ST table
using SET_ST because it falsely believes the table size is 0 and cannot query
the CPU tags.
Should the MSI-X table size (e.g., via pci_msix_vec_count(pdev)) be used to
populate st_table_sz when the location is PCI_TPH_LOC_MSIX?
> +
> + if (copy_to_user(uarg, &cap, sizeof(cap)))
> + return -EFAULT;
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260507130956.34441-1-fengchengwen@huawei.com?part=3
next prev parent reply other threads:[~2026-05-07 23:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 13:09 [PATCH v7 0/6] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-05-07 13:09 ` [PATCH v7 1/6] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-05-07 13:09 ` [PATCH v7 2/6] PCI/TPH: Export pcie_tph_get_st_modes() for external use Chengwen Feng
2026-05-07 22:19 ` sashiko-bot
2026-05-07 13:09 ` [PATCH v7 3/6] vfio/pci: Add PCIe TPH interface with capability query Chengwen Feng
2026-05-07 23:20 ` sashiko-bot [this message]
2026-05-07 13:09 ` [PATCH v7 4/6] vfio/pci: Add PCIe TPH enable/disable support Chengwen Feng
2026-05-07 23:49 ` sashiko-bot
2026-05-07 13:09 ` [PATCH v7 5/6] vfio/pci: Add PCIe TPH GET_ST interface Chengwen Feng
2026-05-08 0:18 ` sashiko-bot
2026-05-07 13:09 ` [PATCH v7 6/6] vfio/pci: Add PCIe TPH SET_ST interface Chengwen Feng
2026-05-08 0:52 ` 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=20260507232017.A0AC6C2BCB2@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fengchengwen@huawei.com \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
/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