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

Jan Beulich posted 4 patches 2 weeks, 4 days ago
There is a newer version of this series
[PATCH v2 3/4] PCI: don't look for ext-caps when there's no extended cfg space
Posted by Jan Beulich 2 weeks, 4 days 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);
 
     /*
Re: [PATCH v2 3/4] PCI: don't look for ext-caps when there's no extended cfg space
Posted by Roger Pau Monné 1 week, 1 day ago
On Mon, Jan 19, 2026 at 03:47:29PM +0100, Jan Beulich wrote:
> 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>

Acked-by: Roger Pau Monné <roger.pau@citrix.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".)

I won't backport, prereq changes are too intrusive.

Thanks, Roger.

Re: [PATCH v2 3/4] PCI: don't look for ext-caps when there's no extended cfg space
Posted by Stewart Hildebrand 1 week, 4 days ago
On 1/19/26 09:47, Jan Beulich wrote:
> 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>

Reviewed-by: Stewart Hildebrand <stewart.hildebrand@amd.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".)

I'm also leaning towards no, given that the ->ext_cfg change has grown in
complexity.