Skip to contentSkip to conversation

PCI: Add ACS quirk for Pericom PI7C9X2G608 switches [12d8:2608]

PATCH Applied Tim Harvey 3 participants 3 messages Jul 20 – Jul 21

Subsystems (2)
lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH 1/1 PCI: Add ACS quirk for Pericom PI7C9X2G608 switches [12d8:2608]

The Pericom PI7C9X2G608 6-port Gen2 PCIe switch is also affected by the PI7C9X2G errata per the errata document:
E2: ACS P2P Request Redirect Is Not Functional

Apply the same quirk to this PCI ID as well to apply the workaround required if using ACS.

Fixes acd61ffb2f16 ("PCI: Add ACS quirk for Pericom PI7C9X2G switches")
---
 drivers/pci/quirks.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pci/quirks.c +4 -0
index b09f27f7846f..27f7d56c9ac3 100644
@@ -6263,6 +6263,10 @@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0xb404,
 			 pci_fixup_pericom_acs_store_forward);
 DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_PERICOM, 0xb404,
 			 pci_fixup_pericom_acs_store_forward);
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0x2608,
+			 pci_fixup_pericom_acs_store_forward);
+DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_PERICOM, 0x2608,
+			 pci_fixup_pericom_acs_store_forward);
 
 static void nvidia_ion_ahci_fixup(struct pci_dev *pdev)
 {
Signature · 1 line
2.34.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unchecked cross-device configuration space write to upstream bridge --

--- Patch [1]: [PATCH] PCI: Add ACS quirk for Pericom PI7C9X2G608 switches [12d8:2608] --- commit 675033e8622336b73d3cde73c4a110a428c76dc5
Author: Tim Harvey <[email protected]>

PCI: Add ACS quirk for Pericom PI7C9X2G608 switches [12d8:2608]

This commit adds a PCI ACS quirk for the Pericom PI7C9X2G608 switch to address erratum E2. It applies the existing store-forward workaround to device ID 0x2608.

drivers/pci/quirks.c DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0xb404, · line 6269

Quoted 12 lines
drivers/pci/quirks.c +4 -0
index b09f27f7846fc..27f7d56c9ac39 100644
@@ -6263,6 +6263,10 @@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0xb404,
 			 pci_fixup_pericom_acs_store_forward);
 DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_PERICOM, 0xb404,
 			 pci_fixup_pericom_acs_store_forward);
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0x2608,
+			 pci_fixup_pericom_acs_store_forward);
+DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_PERICOM, 0x2608,
+			 pci_fixup_pericom_acs_store_forward);

[Severity: High]
This is a pre-existing issue, but does pci_fixup_pericom_acs_store_forward() safely verify its upstream bridge?

Looking at the callback:

drivers/pci/quirks.c:pci_fixup_pericom_acs_store_forward() {
        ...
        upstream = pci_upstream_bridge(pdev);
        if (!upstream)
                return;

        pci_read_config_word(upstream, PI7C9X2Gxxx_MODE_REG, &val);
        if (!(val & PI7C9X2Gxxx_STORE_FORWARD_MODE)) {
                pci_write_config_word(upstream, PI7C9X2Gxxx_MODE_REG, val |
                                      PI7C9X2Gxxx_STORE_FORWARD_MODE);
        }
}

Because it finds the upstream bridge and unconditionally writes to offset 0x74 (PI7C9X2Gxxx_MODE_REG) without checking if the upstream bridge is actually a Pericom device, could this corrupt standard PCI capabilities such as MSI-X tables?

If a Pericom switch is passed through to a guest via VFIO, the upstream bridge in the guest's virtual topology might be a generic virtual Root Port rather than a Pericom device, exposing the guest kernel to configuration space corruption.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Tim Harvey

[+to Nathan]

Quoted 10 lines · Tim Harvey

The Pericom PI7C9X2G608 6-port Gen2 PCIe switch is also affected by the PI7C9X2G errata per the errata document:
E2: ACS P2P Request Redirect Is Not Functional

Apply the same quirk to this PCI ID as well to apply the workaround required if using ACS.

Fixes acd61ffb2f16 ("PCI: Add ACS quirk for Pericom PI7C9X2G switches")

Applied to pci/virtualization for v7.3, thanks!

Note that Sashiko found what looks like a legit pre-existing issue with acd61ffb2f16 ("PCI: Add ACS quirk for Pericom PI7C9X2G switches"):

https://lore.kernel.org/all/[email protected]

Quoted 22 lines
---
 drivers/pci/quirks.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pci/quirks.c +4 -0
index b09f27f7846f..27f7d56c9ac3 100644
@@ -6263,6 +6263,10 @@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0xb404,
 			 pci_fixup_pericom_acs_store_forward);
 DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_PERICOM, 0xb404,
 			 pci_fixup_pericom_acs_store_forward);
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0x2608,
+			 pci_fixup_pericom_acs_store_forward);
+DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_PERICOM, 0x2608,
+			 pci_fixup_pericom_acs_store_forward);
 
 static void nvidia_ion_ahci_fixup(struct pci_dev *pdev)
 {
Signature · 1 line
2.34.1