From: sashiko-bot@kernel.org
To: "Chengwen Feng" <fengchengwen@huawei.com>
Cc: kvm@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v21 01/13] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction
Date: Wed, 18 Nov 2026 09:29:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-220561@kernel.org> (raw)
In-Reply-To: <20261118091238.45992-2-fengchengwen@huawei.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] PCI/TPH: undeclared PCI_TPH_LOC_NONE in pci-tph.h when
!CONFIG_PCIE_TPH
- [Low] PCI/TPH: inaccurate Fixes trailer in commit message
--
commit 47bc8345d31e14953151f380f2af4f107d3d65ae
Author: Chengwen Feng <fengchengwen@huawei.com>
> PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction
>
> pcie_tph_get_st_table_loc() incorrectly uses FIELD_GET(), which shifts the
> field value to bit 0. But the function is designed to return raw
> PCI_TPH_LOC_* values as defined in the function comment.
>
> This causes incorrect ST table location detection. Fix it by using bitwise
> AND with PCI_TPH_CAP_LOC_MASK to return the unshifted field value matching
> the function specification.
>
> This doesn't make a difference to mlx5_st_create(), the lone external
> caller, because it only checks for PCI_TPH_LOC_NONE (0), but will be needed
> for callers that check for PCI_TPH_LOC_CAP or PCI_TPH_LOC_MSIX.
>
> Also add tph_cap validation for pcie_tph_get_st_table_loc() to prevent
> invalid PCI configuration space access when TPH is not supported. Add stub
> functions for pcie_tph_get_st_table_size() and pcie_tph_get_st_table_loc()
> when !CONFIG_PCIE_TPH.
>
> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Alex Williamson <alex.williamson@nvidia.com>
> Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
[Severity: Low]
In d2e8a34876ce ("PCI/TPH: Add Steering Tag support"), get_st_table_loc()
and get_st_table_size() were static helpers whose internal callers already
validated pdev->tph_cap and shifted the return value with FIELD_PREP().
Should the Fixes: tags point to the commits that exported these functions
without stubs or pdev->tph_cap checks instead:
Fixes: 0a61ec9cc51b ("PCI/TPH: Expose pcie_tph_get_st_table_size()")
Fixes: 7b8a8ec20cfc ("PCI/TPH: Expose pcie_tph_get_st_table_loc()")
[ ... ]
> diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h
> index be68cd17f2f83..159ffb82b34ec 100644
> --- a/include/linux/pci-tph.h
> +++ b/include/linux/pci-tph.h
> @@ -41,6 +41,10 @@ static inline int pcie_tph_get_cpu_st(struct pci_dev *dev,
> static inline void pcie_disable_tph(struct pci_dev *pdev) { }
> static inline int pcie_enable_tph(struct pci_dev *pdev, int mode)
> { return -EINVAL; }
> +static inline u16 pcie_tph_get_st_table_size(struct pci_dev *pdev)
> +{ return 0; }
> +static inline u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev)
> +{ return PCI_TPH_LOC_NONE; }
> #endif
>
> #endif /* LINUX_PCI_TPH_H */
[Severity: High]
Does this break the build when CONFIG_PCIE_TPH is disabled?
include/linux/pci-tph.h uses PCI_TPH_LOC_NONE here without including
linux/pci.h or uapi/linux/pci_regs.h. Because include/rdma/ib_verbs.h
includes linux/pci-tph.h before any header that pulls in pci_regs.h,
translation units such as drivers/infiniband/core/mr_pool.c and
drivers/infiniband/hw/mlx5/dmah.c fail to compile with PCI_TPH_LOC_NONE
undeclared.
A later patch in the series, commit "PCI/TPH: Add macros to check standard
and extended TPH support", adds #include <linux/pci.h> to this header,
leaving earlier commits in the series and standalone stable backports of
this patch broken when CONFIG_PCIE_TPH is disabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118091238.45992-1-fengchengwen@huawei.com?part=1
next prev parent reply other threads:[~2026-11-18 9:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 9:12 [PATCH v21 00/13] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-11-18 9:12 ` [PATCH v21 01/13] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-11-18 9:29 ` sashiko-bot [this message]
2026-11-18 9:12 ` [PATCH v21 02/13] PCI/TPH: Fix tph_enabled concurrent update race by bitfield packing Chengwen Feng
2026-11-18 9:38 ` sashiko-bot
2026-11-18 9:12 ` [PATCH v21 03/13] PCI/TPH: Cache negotiated max requester type at probe time Chengwen Feng
2026-11-18 9:45 ` sashiko-bot
2026-11-18 9:12 ` [PATCH v21 04/13] PCI/TPH: Refactor pcie_enable_tph and add requester variant Chengwen Feng
2026-11-18 9:48 ` sashiko-bot
2026-11-18 9:12 ` [PATCH v21 05/13] PCI/TPH: Refactor pcie_tph_get_cpu_st & " Chengwen Feng
2026-11-18 9:53 ` sashiko-bot
2026-11-18 9:12 ` [PATCH v21 06/13] PCI/TPH: Add macros to check standard and extended TPH support Chengwen Feng
2026-11-18 10:06 ` sashiko-bot
2026-11-18 9:12 ` [PATCH v21 07/13] PCI/TPH: Add pcie_tph_set_st_entries() batch ST entry programming helper Chengwen Feng
2026-11-18 10:15 ` sashiko-bot
2026-11-18 9:12 ` [PATCH v21 08/13] PCI/TPH: Add pci_tph_dsm_supported() helper to detect device TPH ST _DSM Chengwen Feng
2026-11-18 9:12 ` [PATCH v21 09/13] vfio/pci: Add basic NO-ST TPH VFIO device feature support Chengwen Feng
2026-11-18 9:12 ` [PATCH v21 10/13] vfio/pci: Add IV-ST TPH policy and TPH_PROGRAM batch programming support Chengwen Feng
2026-11-18 9:12 ` [PATCH v21 11/13] vfio/pci: Add DS-ST TPH policy and TPH_RESOLVE capability Chengwen Feng
2026-11-18 9:12 ` [PATCH v21 12/13] vfio/pci: Reset PCIe TPH state on device open and close Chengwen Feng
2026-11-18 9:12 ` [PATCH v21 13/13] vfio/pci: Expose per-device TPH state via debugfs Chengwen Feng
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=sashiko-outbox-220561@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