[PATCH v3 4/6] vPCI: really no ext-caps without extended config space

Jan Beulich posted 6 patches 1 week, 1 day ago
[PATCH v3 4/6] vPCI: really no ext-caps without extended config space
Posted by Jan Beulich 1 week, 1 day ago
For DomU-s, whether to emulate accesses to the first 32 bits of extended
config space as read-as-zero or read-as-all-ones depends on whether a
device actually has extended config space. If it doesn't, read-as-zero
isn't correct; not getting this right may confuse functions like Linux
6.19-rc's pci_ext_cfg_is_aliased().

For Dom0 this then simply allows dropping a later conditional.

Fixes: a845b50c12f3 ("vpci/header: Emulate extended capability list for dom0")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v3: Move code condition to top-level function scope. Eliminate a later
    conditional in exchange.

--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -829,6 +829,9 @@ static int vpci_init_ext_capability_list
 {
     unsigned int pos = PCI_CFG_SPACE_SIZE;
 
+    if ( !pdev->ext_cfg )
+        return 0;
+
     if ( !is_hardware_domain(pdev->domain) )
         /* Extended capabilities read as zero, write ignore for DomU */
         return vpci_add_register(pdev->vpci, vpci_read_val, NULL,
@@ -841,10 +844,9 @@ static int vpci_init_ext_capability_list
 
         if ( header == 0xffffffffU )
         {
-            if ( pos != PCI_CFG_SPACE_SIZE )
-                printk(XENLOG_WARNING
-                       "%pd %pp: broken extended cap list, offset %#x\n",
-                       pdev->domain, &pdev->sbdf, pos);
+            printk(XENLOG_WARNING
+                   "%pd %pp: broken extended cap list, offset %#x\n",
+                   pdev->domain, &pdev->sbdf, pos);
             return 0;
         }
Re: [PATCH v3 4/6] vPCI: really no ext-caps without extended config space
Posted by Roger Pau Monné 1 week, 1 day ago
On Thu, Jan 29, 2026 at 02:09:27PM +0100, Jan Beulich wrote:
> For DomU-s, whether to emulate accesses to the first 32 bits of extended
> config space as read-as-zero or read-as-all-ones depends on whether a
> device actually has extended config space. If it doesn't, read-as-zero
> isn't correct; not getting this right may confuse functions like Linux
> 6.19-rc's pci_ext_cfg_is_aliased().
> 
> For Dom0 this then simply allows dropping a later conditional.
> 
> 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>

Thanks, Roger.