From: sashiko-bot@kernel.org
To: "Chengwen Feng" <fengchengwen@huawei.com>
Cc: kvm@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v20 14/16] vfio/pci: Add DS-ST TPH policy and extend TPH_RESOLVE capabilities
Date: Tue, 14 Jul 2026 11:12:34 +0000 [thread overview]
Message-ID: <20260714111235.3D3D11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714104325.54444-15-fengchengwen@huawei.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [Medium] The newly introduced UAPI capability flag `VFIO_DEVICE_TPH_CAP_RESOLVE_DMABUF_ST` is never exposed to userspace.
- [Medium] DMABUF steering tag resolution returns a steering tag based solely on policy, ignoring physical device support.
Pre-existing issues:
- [High] Unbalanced lock release in `vfio_pci_get_dmabuf_tph()` due to unconditionally calling `dma_resv_unlock()`.
--
--- Patch [14]: [PATCH v20 14/16] vfio/pci: Add DS-ST TPH policy and extend TPH_RESOLVE capabilities ---
commit e8e0f1c694e6597598ac910df3f902bedd7601ee
Author: Chengwen Feng <fengchengwen@huawei.com>
Subject: vfio/pci: Add DS-ST TPH policy and extend TPH_RESOLVE capabilities
Extends VFIO TPH policy to add DS-ST level 2 policy, relaxing write
restrictions and extending TPH_RESOLVE logic. Adds support for CPU
memory sources and DMABUF sources returning both PH and ST under the
DS-ST policy.
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index df31f4e8766fa..ae2e0e2252a1e 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
[ ... ]
> @@ -1622,6 +1640,17 @@ static u32 vfio_pci_get_tph_capability(struct vfio_pci_core_device *vdev)
> if (pcie_tph_dsm_supported(vdev->pdev))
> flags |= VFIO_DEVICE_TPH_CAP_ST_CPU;
> }
> + if (vdev->tph_policy >= VFIO_PCI_TPH_POLICY_DS_ST &&
> + (vdev->tph_cap_virt & PCI_TPH_CAP_ST_DS)) {
> + if (vfio_pci_get_tph_st_size(vdev) > 0) {
> + flags |= VFIO_DEVICE_TPH_CAP_ST_NONE;
> + flags |= VFIO_DEVICE_TPH_CAP_ST_DMABUF;
> + if (pcie_tph_dsm_supported(vdev->pdev))
> + flags |= VFIO_DEVICE_TPH_CAP_ST_CPU;
> + }
> + if (pcie_tph_dsm_supported(vdev->pdev))
> + flags |= VFIO_DEVICE_TPH_CAP_RESOLVE_CPU_ST;
> + }
[Severity: Medium]
The commit message and headers mention adding the capability
VFIO_DEVICE_TPH_CAP_RESOLVE_DMABUF_ST. Should it be added to the flags
bitmask here alongside VFIO_DEVICE_TPH_CAP_RESOLVE_CPU_ST?
If it's left out, userspace might not be able to discover that the feature
is actually supported.
>
> return flags;
> }
[ ... ]
> @@ -1751,6 +1784,7 @@ static int vfio_pci_core_feature_tph_resolve(struct vfio_pci_core_device *vdev,
>
> resolve.valid = 0;
> resolve.ph = 0;
> + resolve.st = 0;
>
> if (user_flags & VFIO_DEVICE_TPH_SRC_DMABUF) {
> ret = vfio_pci_get_dmabuf_tph(resolve.src, extended,
[Severity: High]
This isn't a bug introduced by this patch, but looking at
vfio_pci_get_dmabuf_tph() which is called here:
vfio_pci_get_dmabuf_tph() {
ret = dma_resv_lock_interruptible(dmabuf->resv, NULL);
if (ret == 0)
ret = dma_buf_get_pci_tph(dmabuf, extended, st, ph);
dma_resv_unlock(dmabuf->resv);
...
}
If dma_resv_lock_interruptible() fails (for example, if it's interrupted
by a signal and returns -EINTR), will the unconditional call to
dma_resv_unlock() corrupt the underlying ww_mutex state?
> @@ -1759,8 +1793,21 @@ static int vfio_pci_core_feature_tph_resolve(struct vfio_pci_core_device *vdev,
> return ret;
> resolve.ph = ph;
> resolve.valid = VFIO_DEVICE_TPH_VALID_PH;
> + if (vdev->tph_policy >= VFIO_PCI_TPH_POLICY_DS_ST) {
> + resolve.st = tag;
> + resolve.valid |= VFIO_DEVICE_TPH_VALID_ST;
> + }
> + goto out;
> }
[Severity: Medium]
Does this evaluation need to also check if the physical device supports the
DS-ST mode?
If the global module policy allows DS-ST but the device lacks the underlying
capability (vdev->tph_cap_virt & PCI_TPH_CAP_ST_DS), it seems this could
still return a valid steering tag to userspace for a tag it cannot actually
program.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714104325.54444-1-fengchengwen@huawei.com?part=14
next prev parent reply other threads:[~2026-07-14 11:12 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 10:43 [PATCH v20 00/16] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-07-14 10:43 ` [PATCH v20 01/16] PCI/TPH: Add requester/completer type helpers Chengwen Feng
2026-07-14 10:54 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 02/16] dma-buf: add optional get_pci_tph() callback Chengwen Feng
2026-07-14 10:50 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 03/16] vfio/pci: implement get_pci_tph and DMA_BUF_TPH feature Chengwen Feng
2026-07-14 10:50 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 04/16] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-07-14 10:54 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 05/16] PCI/TPH: Fix tph_enabled concurrent update race by bitfield packing Chengwen Feng
2026-07-14 11:00 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 06/16] PCI/TPH: Cache negotiated max requester type at probe time Chengwen Feng
2026-07-14 10:57 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 07/16] PCI/TPH: Refactor pcie_enable_tph and add requester variant Chengwen Feng
2026-07-14 10:58 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 08/16] PCI/TPH: Refactor pcie_tph_get_cpu_st & " Chengwen Feng
2026-07-14 11:00 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 09/16] PCI/TPH: Add macros to check standard and extended TPH support Chengwen Feng
2026-07-14 11:07 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 10/16] PCI/TPH: Add pcie_tph_set_st_entries() batch ST entry programming helper Chengwen Feng
2026-07-14 11:11 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 11/16] PCI/TPH: Add pci_tph_dsm_supported() helper to detect device TPH ST _DSM Chengwen Feng
2026-07-14 11:27 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 12/16] vfio/pci: Add basic NO-ST TPH VFIO device feature support Chengwen Feng
2026-07-14 11:10 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 13/16] vfio/pci: Add IV-ST TPH policy and VFIO TPH_ST batch programming support Chengwen Feng
2026-07-14 11:14 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 14/16] vfio/pci: Add DS-ST TPH policy and extend TPH_RESOLVE capabilities Chengwen Feng
2026-07-14 11:12 ` sashiko-bot [this message]
2026-07-14 10:43 ` [PATCH v20 15/16] vfio/pci: Sync core PCI TPH software state across device lifecycle and resets Chengwen Feng
2026-07-14 11:28 ` sashiko-bot
2026-07-14 10:43 ` [PATCH v20 16/16] vfio/pci: Expose per-device TPH state via debugfs Chengwen Feng
2026-07-14 11:17 ` 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=20260714111235.3D3D11F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fengchengwen@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@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