From: sashiko-bot@kernel.org
To: "Chengwen Feng" <fengchengwen@huawei.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v8 7/7] vfio/pci: Add PCIe TPH SET_ST interface
Date: Fri, 08 May 2026 21:49:22 +0000 [thread overview]
Message-ID: <20260508214923.44016C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508064053.37529-8-fengchengwen@huawei.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The error path in `vfio_pci_tph_set_st()` destructively zeroes out successfully programmed ST entries on partial failure, causing an unknown and inconsistent device state.
- [High] Positive PCIBIOS error codes from `pcie_tph_set_st_entry()` are propagated to userspace `ioctl()`, resulting in false success reporting.
--
commit c7946d420debcc101b2f2daf21858db188b20ee7
Author: Chengwen Feng <fengchengwen@huawei.com>
vfio/pci: Add PCIe TPH SET_ST interface
This commit adds the VFIO_PCI_TPH_SET_ST operation to support batch programming
of steering tag entries. It includes an error path that attempts to roll back
successfully programmed entries to 0 if any entry fails.
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
[ ... ]
> @@ -1606,6 +1606,94 @@ static int vfio_pci_tph_get_st(struct vfio_pci_core_device *vdev,
> return err;
> }
>
> +static int vfio_pci_tph_set_st(struct vfio_pci_core_device *vdev,
> + struct vfio_device_pci_tph_op *op,
> + void __user *uarg)
> +{
[ ... ]
> + if (ents[i].cpu == U32_MAX) {
> + err = pcie_tph_set_st_entry(pdev, ents[i].index, 0);
> + if (err)
> + goto out;
Could this return a positive PCIBIOS error code to userspace?
pcie_tph_set_st_entry() eventually calls pci_write_config_word(), which returns
positive PCIBIOS_* error codes (like PCIBIOS_SET_FAILED). Since the VFS ioctl
handler only treats strictly negative values as errors, returning a positive
value directly will cause userspace to falsely assume the ioctl succeeded.
Should this error be converted using pcibios_err_to_errno()?
> + continue;
> + }
> +
> + err = pcie_tph_get_cpu_st(pdev, mtype, ents[i].cpu, &st_val);
> + if (err)
> + goto out;
> + err = pcie_tph_set_st_entry(pdev, ents[i].index, st_val);
> + if (err)
> + goto out;
> + }
> +
> +out:
> + if (err) {
> + /* Roll back previously programmed entries to 0 */
> + for (j = 0; j < i; j++)
> + pcie_tph_set_st_entry(pdev, ents[j].index, 0);
Does this error path actually leave the device in an inconsistent state if the
entries contained valid non-zero tags before this ioctl was called?
Since the original ST values are not read or saved prior to modification,
this "rollback" destructively overwrites them with 0 rather than restoring the
true previous state.
Could we read and save the original values before modifying them, or return
an error without attempting a partial revert?
> + }
> + kvfree(ents);
> + return err;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508064053.37529-1-fengchengwen@huawei.com?part=7
prev parent reply other threads:[~2026-05-08 21:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 6:40 [PATCH v8 0/7] vfio/pci: Add PCIe TPH support Chengwen Feng
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-12 9:41 ` fengchengwen
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 [this message]
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=20260508214923.44016C2BCB0@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.