[PATCH v2 3/4] PCI: don't look for ext-caps when there's no extended cfg space

Jan Beulich posted 4 patches 6 days, 16 hours ago
[PATCH v2 3/4] PCI: don't look for ext-caps when there's no extended cfg space
Posted by Jan Beulich 6 days, 16 hours ago
Avoid interpreting as extended capabilities what may be about anything. In
doing so, vPCI then also won't mis-interpret data from beyond base config
space anymore.

Fixes: 3b35911d709e ("Enable pci mmcfg and ATS for x86_64")
Fixes: a845b50c12f3 ("vpci/header: Emulate extended capability list for dom0")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Because of the multiple prereq changes, despite the Fixes: tags I'm not
quite sure whether to backport this. (I'm leaning towards "no".)

--- a/xen/drivers/pci/pci.c
+++ b/xen/drivers/pci/pci.c
@@ -113,6 +113,12 @@ unsigned int pci_find_next_ext_capabilit
     int ttl = 480; /* 3840 bytes, minimum 8 bytes per capability */
     unsigned int pos = max(start, PCI_CFG_SPACE_SIZE + 0U);
 
+    if ( !pdev->ext_cfg )
+    {
+        ASSERT(!start);
+        return 0;
+    }
+
     header = pci_conf_read32(pdev->sbdf, pos);
 
     /*