From: sashiko-bot@kernel.org
To: "Jose Ignacio Tornos Martinez" <jtornosm@redhat.com>
Cc: kvm@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 2/7] vfio: Add qcom_vfio.h header for MSI cache protocol
Date: Sun, 11 Oct 2026 07:59:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-167114@kernel.org> (raw)
In-Reply-To: <20261011074514.515894-3-jtornosm@redhat.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] pci: hardware state overwrite via pci_find_free_ext_cap_offset()
- [High] pci: out-of-bounds config space read in qcom_vfio_find_msi_cache
- [High] pci/vfio: false positive in linear MSI cache scan risks MSI misconfiguration
--
commit a4701d60f47321f6e79355d9a8e74d4e1c2789b7
Author: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
vfio: Add qcom_vfio.h header for MSI cache protocol
Add a shared header for the qcom-vfio-pci driver and Qualcomm device drivers.
It defines a communication protocol for caching host MSI values in extended
PCI config space with a "QMSI" magic signature for VM discovery. This avoids
offset mismatches when QEMU filters certain capabilities.
> diff --git a/include/linux/qcom_vfio.h b/include/linux/qcom_vfio.h
> new file mode 100644
> index 0000000000000..7553bc382c8e4
> --- /dev/null
> +++ b/include/linux/qcom_vfio.h
> @@ -0,0 +1,90 @@
[ ... ]
> +static inline int qcom_vfio_find_msi_offset(struct pci_dev *pdev)
> +{
> + return pci_find_free_ext_cap_offset(pdev, QCOM_VFIO_MSI_SPACE_SIZE);
> +}
[Severity: High]
Does relying on pci_find_free_ext_cap_offset() risk hardware state overwrite?
The implementation of pci_find_free_ext_cap_offset() does not skip the size
of the last extended capability. It begins scanning for zeroed registers
immediately at the start of the last active capability. Consequently, it can
misidentify zeroed registers (such as reserved or masked fields) inside
active capabilities as free space.
Using this offset to cache MSI values could overwrite live hardware
registers, causing a regression due to hardware state corruption.
Furthermore, if the extended config space is completely empty, it
incorrectly returns 0 instead of 0x100.
[ ... ]
> +static inline int qcom_vfio_find_msi_cache(struct pci_dev *pdev)
> +{
> + u32 magic;
> + int offset;
> +
> + for (offset = PCI_CFG_SPACE_SIZE;
> + offset <= PCI_CFG_SPACE_EXP_SIZE - QCOM_VFIO_MSI_SPACE_SIZE;
> + offset += 4) {
[Severity: High]
Could this loop lead to out-of-bounds config space reads on bare-metal
systems?
The qcom_vfio_find_msi_cache() helper is called directly by the ath11k and
ath12k drivers during normal probe, meaning it executes on bare-metal
systems, not just inside VMs. The loop unconditionally reads up to
PCI_CFG_SPACE_EXP_SIZE (4096 bytes), completely bypassing the dynamic
pdev->cfg_size limit.
The PCI core generic pci_read_config_dword() does not perform bounds
checking against pdev->cfg_size and relies entirely on callers to respect
the boundaries. If the host platform restricts the config space size (for
example, due to a broken ECAM falling back to legacy accesses or a
PCIe-to-PCI bridge), this loop will force reads beyond safe boundaries.
Accessing undefined extended configuration space on bare-metal can cause
regressions like system lockups or fatal PCIe Unsupported Request panics.
> + if (pci_read_config_dword(pdev, offset, &magic))
> + continue;
> + if (magic == QCOM_VFIO_MSI_MAGIC)
> + return offset;
> + }
[Severity: High]
Is it possible for this linear scan to falsely identify unrelated data as
the MSI cache, leading to misconfiguration?
This linear scan bypasses the PCIe standard capability chain traversal and
blindly reads all extended config registers, including dynamic logs like AER.
If a hardware error occurs and the AER Header Log captures a TLP containing
the value 0x49534D51, the scan will falsely identify it as the VFIO MSI
cache. It would then read the adjacent AER log values as msi_addr_lo,
msi_addr_hi, and msi_data, and program the physical device to use a garbage
MSI address.
This could lead to regressions including data corruption, IOMMU faults, and
loss of network interrupts.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261011074514.515894-1-jtornosm@redhat.com?part=2
next prev parent reply other threads:[~2026-10-11 7:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 7:45 [PATCH v2 0/7] Enable Qualcomm WiFi PCIe passthrough to VMs Jose Ignacio Tornos Martinez
2026-10-11 7:45 ` [PATCH v2 1/7] PCI: Add pci_find_free_ext_cap_offset() helper Jose Ignacio Tornos Martinez
2026-10-11 7:57 ` sashiko-bot
2026-10-11 7:45 ` [PATCH v2 2/7] vfio: Add qcom_vfio.h header for MSI cache protocol Jose Ignacio Tornos Martinez
2026-10-11 7:59 ` sashiko-bot [this message]
2026-10-11 7:45 ` [PATCH v2 3/7] vfio/pci: Add qcom-vfio-pci variant driver Jose Ignacio Tornos Martinez
2026-10-11 8:07 ` sashiko-bot
2026-10-11 7:45 ` [PATCH v2 4/7] ath11k: add PCIe link recovery retry Jose Ignacio Tornos Martinez
2026-10-11 7:59 ` sashiko-bot
2026-10-11 7:45 ` [PATCH v2 5/7] ath11k: Use VFIO MSI cache when available Jose Ignacio Tornos Martinez
2026-10-11 8:04 ` sashiko-bot
2026-10-11 7:45 ` [PATCH v2 6/7] ath12k: add PCIe link recovery retry Jose Ignacio Tornos Martinez
2026-10-11 8:05 ` sashiko-bot
2026-10-11 7:45 ` [PATCH v2 7/7] ath12k: Use VFIO MSI cache when available Jose Ignacio Tornos Martinez
2026-10-11 8:02 ` sashiko-bot
2026-10-11 18:22 ` [PATCH v2 0/7] Enable Qualcomm WiFi PCIe passthrough to VMs Jeff Johnson
2026-10-12 14:48 ` Jason Gunthorpe
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-167114@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jtornosm@redhat.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 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.