(v)PCI: extended capability handling
cover (v)PCI: extended capability handling
This is a follow-on to 'vPCI: avoid bogus "overlap in extended cap list" warnings', addressing further issues noted there.
1: PCI: determine whether a device has extended config space 2: PCI: pass pdev to pci_ats_{device,enabled}()
3: x86/MSI: pass pdev to read_pci_mem_bar()
4: PCI: pass pdev to pci_find_{,next_}ext_capability() 5: PCI: don't look for ext-caps when there's no extended cfg space 6: vPCI/DomU: really no ext-caps without extended config space
Jan
PATCH 1/6 PCI: determine whether a device has extended config space
Legacy PCI devices don't have any extended config space. Reading any part thereof may return all ones or other arbitrary data, e.g. in some cases base config space contents repeatedly.
Logic follows Linux 6.19-rc's pci_cfg_space_size(), albeit leveraging our determination of device type; in particular some comments are taken verbatim from there.
---
Note that alloc_pdev()'s switch doesn't handle DEV_TYPE_PCI2PCIe_BRIDGE at all. Such bridges will therefore not have ->ext_cfg set (which is likely wrong). Shouldn't we handle them like DEV_TYPE_LEGACY_PCI_BRIDGE (or DEV_TYPE_PCI?) anyway (just like VT-d's set_msi_source_id() does)?
Linux also has CONFIG_PCI_QUIRKS, allowing to compile out the slightly risky code (as reads may in principle have side effects). Should we gain such, too?
xen/drivers/passthrough/pci.c +66 -1
@@ -310,6 +310,41 @@ static void apply_quirks(struct pci_dev* from trying to size the BARs or add handlers to trap accesses. */ pdev->ignore_bars = true; + +if ( pdev->ext_cfg ) + { +unsigned int pos; + +/* +* PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says +* that when forwarding a type1 configuration request the bridge must +* check that the extended register address field is zero. The bridge +* is not permitted to forward the transactions and must handle it as +* an Unsupported Request. Some bridges do not follow this rule and +* simply drop the extended register bits, resulting in the standard +* config space being aliased, every 256 bytes across the entire +* configuration space. Test for this condition by comparing the first +* dword of each potential alias to the vendor/device ID. +* Known offenders: +* ASM1083/1085 PCIe-to-PCI Reversible Bridge (1b21:1080, rev 01 & 03) +* AMD/ATI SBx00 PCI to PCI Bridge (1002:4384, rev 40) +*/ +for ( pos =PCI_CFG_SPACE_SIZE ; + pos <PCI_CFG_SPACE_EXP_SIZE ; pos +=PCI_CFG_SPACE_SIZE ) + { +if (pci_conf_read16 (pdev->sbdf, pos) != vendor || +pci_conf_read16 (pdev->sbdf, pos +2 ) != device ) +break ; + } + +if ( pos >=PCI_CFG_SPACE_EXP_SIZE ) + { +printk (XENLOG_WARNING +"%pp: extended config space aliases base one\n" , + &pdev->sbdf); + pdev->ext_cfg = false; + } + } }static struct pci_dev *alloc_pdev (struct pci_seg *pseg,u8 bus,u8 devfn)
@@ -351,6 +386,8 @@ static struct pci_dev *alloc_pdev(structunsigned long flags;case DEV_TYPE_PCIe2PCI_BRIDGE: + pdev->ext_cfg = true; + fallthrough;case DEV_TYPE_LEGACY_PCI_BRIDGE : sec_bus =pci_conf_read8 (pdev->sbdf,PCI_SECONDARY_BUS ); sub_bus =pci_conf_read8 (pdev->sbdf,PCI_SUBORDINATE_BUS );
@@ -363,9 +400,19 @@ static struct pci_dev *alloc_pdev(struct pseg->bus2bridge[sec_bus].devfn = devfn; }spin_unlock_irqrestore (&pseg->bus2bridge_lock, flags); + + fallthrough; +case DEV_TYPE_PCI : + pos =pci_find_cap_offset (pdev->sbdf,PCI_CAP_ID_PCIX ); +if ( pos && + (pci_conf_read32 (pdev->sbdf, pos +PCI_X_STATUS ) & + (PCI_X_STATUS_266MHZ |PCI_X_STATUS_533MHZ )) ) + pdev->ext_cfg = true;break ;case DEV_TYPE_PCIe_ENDPOINT: + pdev->ext_cfg = true; + pos =pci_find_cap_offset (pdev->sbdf,PCI_CAP_ID_EXP );BUG_ON (!pos); cap =pci_conf_read16 (pdev->sbdf, pos +PCI_EXP_DEVCAP );
@@ -409,9 +456,9 @@ static struct pci_dev *alloc_pdev(struct }break ; -case DEV_TYPE_PCI :case DEV_TYPE_PCIe_BRIDGE:case DEV_TYPE_PCI_HOST_BRIDGE : + pdev->ext_cfg = true;break ;default :
@@ -420,6 +467,19 @@ static struct pci_dev *alloc_pdev(structbreak ; } +if ( pdev->ext_cfg && +/* +* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express +* devices have 4096 bytes. Even if the device is capable, that +* doesn't mean we can access it. Maybe we don't have a way to +* generate extended config space accesses, or the device is behind a +* reverse Express bridge. So we try reading the dword at +* PCI_CFG_SPACE_SIZE which must either be 0 or a valid extended +* capability header. +*/ +pci_conf_read32 (pdev->sbdf,PCI_CFG_SPACE_SIZE ) ==0xffffffffU ) + pdev->ext_cfg = false; +apply_quirks (pdev);check_pdev (pdev);
@@ -717,6 +777,11 @@ int pci_add_device(u16 seg, u8 bus, u8 dlist_add (&pdev->vf_list, &pf_pdev->vf_list); } + +if ( !pdev->ext_cfg ) +printk (XENLOG_WARNING +"%pp: VF without extended config space?\n" , + &pdev->sbdf); } }
xen/include/xen/pci.h +3 -0
@@ -126,6 +126,9 @@ struct pci_dev {nodeid_t node;/* NUMA node */ +/* Whether the device has extended config space. */ +bool ext_cfg; +/* Device to be quarantined, don't automatically re-assign to dom0 */ bool quarantine;
Re: [PATCH 1/6] PCI: determine whether a device has extended config space
Le 06/01/2026 à 14:50, Jan Beulich a écrit :
Quoted 50 lines
Legacy PCI devices don't have any extended config space. Reading any part thereof may return all ones or other arbitrary data, e.g. in some cases base config space contents repeatedly.
Logic follows Linux 6.19-rc's
pci_cfg_space_size(), albeit leveraging our determination of device type; in particular some comments are taken verbatim from there.Signed-off-by Jan Beulich <[email protected]>---
Note that alloc_pdev()'s switch doesn't handleDEV_TYPE_PCI2PCIe_BRIDGEat all. Such bridges will therefore not have ->ext_cfg set (which is likely wrong). Shouldn't we handle them likeDEV_TYPE_LEGACY_PCI_BRIDGE(orDEV_TYPE_PCI?) anyway (just like VT-d'sset_msi_source_id()does)?Linux also has
CONFIG_PCI_QUIRKS, allowing to compile out the slightly risky code (as reads may in principle have side effects). Should we gain such, too?xen/drivers/passthrough/pci.c +25
-0@@ -310,6 +310,41 @@ static void apply_quirks(struct pci_dev* from trying to size the BARs or add handlers to trap accesses. */ pdev->ignore_bars = true; + +if ( pdev->ext_cfg ) + { +unsigned int pos; + +/* +* PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says +* that when forwarding a type1 configuration request the bridge must +* check that the extended register address field is zero. The bridge +* is not permitted to forward the transactions and must handle it as +* an Unsupported Request. Some bridges do not follow this rule and +* simply drop the extended register bits, resulting in the standard +* config space being aliased, every 256 bytes across the entire +* configuration space. Test for this condition by comparing the first +* dword of each potential alias to the vendor/device ID. +* Known offenders: +* ASM1083/1085 PCIe-to-PCI Reversible Bridge (1b21:1080, rev 01 & 03) +* AMD/ATI SBx00 PCI to PCI Bridge (1002:4384, rev 40) +*/ +for ( pos =PCI_CFG_SPACE_SIZE ; + pos <PCI_CFG_SPACE_EXP_SIZE ; pos +=PCI_CFG_SPACE_SIZE ) + { +if (pci_conf_read16 (pdev->sbdf, pos) != vendor || +pci_conf_read16 (pdev->sbdf, pos +2 ) != device ) +break ;
xen/drivers/passthrough/pci.c static void apply_quirks(struct pci_dev · line 347
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+ } + +if ( pos >=PCI_CFG_SPACE_EXP_SIZE ) + { +printk (XENLOG_WARNING +"%pp: extended config space aliases base one\n" , + &pdev->sbdf); + pdev->ext_cfg = false; + } + }
Given that it only appears to be the case for PCIe to PCI/PCI-X bridges, do we want to check this for all devices ?
Quoted 80 lines
xen/drivers/passthrough/pci.c +31
-1}static struct pci_dev *alloc_pdev (struct pci_seg *pseg,u8 bus,u8 devfn)@@ -351,6 +386,8 @@ static struct pci_dev *alloc_pdev(structunsigned long flags;case DEV_TYPE_PCIe2PCI_BRIDGE: + pdev->ext_cfg = true; + fallthrough;case DEV_TYPE_LEGACY_PCI_BRIDGE : sec_bus =pci_conf_read8 (pdev->sbdf,PCI_SECONDARY_BUS ); sub_bus =pci_conf_read8 (pdev->sbdf,PCI_SUBORDINATE_BUS );@@ -363,9 +400,19 @@ static struct pci_dev *alloc_pdev(struct pseg->bus2bridge[sec_bus].devfn = devfn; }spin_unlock_irqrestore (&pseg->bus2bridge_lock, flags); + + fallthrough; +case DEV_TYPE_PCI : + pos =pci_find_cap_offset (pdev->sbdf,PCI_CAP_ID_PCIX ); +if ( pos && + (pci_conf_read32 (pdev->sbdf, pos +PCI_X_STATUS ) & + (PCI_X_STATUS_266MHZ |PCI_X_STATUS_533MHZ )) ) + pdev->ext_cfg = true;break ;case DEV_TYPE_PCIe_ENDPOINT: + pdev->ext_cfg = true; + pos =pci_find_cap_offset (pdev->sbdf,PCI_CAP_ID_EXP );BUG_ON (!pos); cap =pci_conf_read16 (pdev->sbdf, pos +PCI_EXP_DEVCAP );@@ -409,9 +456,9 @@ static struct pci_dev *alloc_pdev(struct }break ; -case DEV_TYPE_PCI :case DEV_TYPE_PCIe_BRIDGE:case DEV_TYPE_PCI_HOST_BRIDGE : + pdev->ext_cfg = true;break ;default :@@ -420,6 +467,19 @@ static struct pci_dev *alloc_pdev(structbreak ; } +if ( pdev->ext_cfg && +/* +* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express +* devices have 4096 bytes. Even if the device is capable, that +* doesn't mean we can access it. Maybe we don't have a way to +* generate extended config space accesses, or the device is behind a +* reverse Express bridge. So we try reading the dword at +* PCI_CFG_SPACE_SIZE which must either be 0 or a valid extended +* capability header. +*/ +pci_conf_read32 (pdev->sbdf,PCI_CFG_SPACE_SIZE ) ==0xffffffffU ) + pdev->ext_cfg = false; +apply_quirks (pdev);check_pdev (pdev);@@ -717,6 +777,11 @@ int pci_add_device(u16 seg, u8 bus, u8 dlist_add (&pdev->vf_list, &pf_pdev->vf_list); } + +if ( !pdev->ext_cfg ) +printk (XENLOG_WARNING +"%pp: VF without extended config space?\n" , + &pdev->sbdf); } }
xen/include/xen/pci.h struct pci_dev { · line 134
Quoted 9 lines
xen/include/xen/pci.h +3
-0@@ -126,6 +126,9 @@ struct pci_dev {nodeid_t node;/* NUMA node */ +/* Whether the device has extended config space. */ +bool ext_cfg; +/* Device to be quarantined, don't automatically re-assign to dom0 */ bool quarantine;
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Re: [PATCH 1/6] PCI: determine whether a device has extended config space
Quoted 37 lines · Teddy Astie
Le 06/01/2026 à 14:50, Jan Beulich a écrit :
Quoted 36 lines
xen/drivers/passthrough/pci.c +30
-0@@ -310,6 +310,41 @@ static void apply_quirks(struct pci_dev* from trying to size the BARs or add handlers to trap accesses. */ pdev->ignore_bars = true; + +if ( pdev->ext_cfg ) + { +unsigned int pos; + +/* +* PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says +* that when forwarding a type1 configuration request the bridge must +* check that the extended register address field is zero. The bridge +* is not permitted to forward the transactions and must handle it as +* an Unsupported Request. Some bridges do not follow this rule and +* simply drop the extended register bits, resulting in the standard +* config space being aliased, every 256 bytes across the entire +* configuration space. Test for this condition by comparing the first +* dword of each potential alias to the vendor/device ID. +* Known offenders: +* ASM1083/1085 PCIe-to-PCI Reversible Bridge (1b21:1080, rev 01 & 03) +* AMD/ATI SBx00 PCI to PCI Bridge (1002:4384, rev 40) +*/ +for ( pos =PCI_CFG_SPACE_SIZE ; + pos <PCI_CFG_SPACE_EXP_SIZE ; pos +=PCI_CFG_SPACE_SIZE ) + { +if (pci_conf_read16 (pdev->sbdf, pos) != vendor || +pci_conf_read16 (pdev->sbdf, pos +2 ) != device ) +break ; + } + +if ( pos >=PCI_CFG_SPACE_EXP_SIZE ) + { + printk(XENLOG_WARNING
Quoted 8 lines
xen/drivers/passthrough/pci.c static void apply_quirks(struct pci_dev · line 347
Quoted 5 lines
xen/drivers/passthrough/pci.c +5
-0+"%pp: extended config space aliases base one\n" , + &pdev->sbdf); + pdev->ext_cfg = false; + } + }Given that it only appears to be the case for PCIe to PCI/PCI-X bridges, do we want to check this for all devices ?
Yes. Bridges are only the main examples, but in the few systems I tested this on so far I have at least one ordinary device which also aliases base config space. Also note that Linux, where the base logic is taken from, also doesn't restrict this checking (if I'm reading the code right).
Jan
Re: [PATCH 1/6] PCI: determine whether a device has extended config space
In reply to Jan BeulichQuoted 8 lines · Jan Beulich
Legacy PCI devices don't have any extended config space. Reading any part thereof may return all ones or other arbitrary data, e.g. in some cases base config space contents repeatedly.
Logic follows Linux 6.19-rc's
pci_cfg_space_size(), albeit leveraging our determination of device type; in particular some comments are taken verbatim from there.
Quoted 5 lines
Signed-off-by Jan Beulich <[email protected]>---
Note that alloc_pdev()'s switch doesn't handleDEV_TYPE_PCI2PCIe_BRIDGEat all. Such bridges will therefore not have ->ext_cfg set (which is likely wrong).
I initially read "set" as in "set to true", but I think you mean that ext_cfg isn't assigned at all. Though perhaps it should actually be set to true, because ...
Quoted 2 lines
Shouldn't we handle them like
DEV_TYPE_LEGACY_PCI_BRIDGE(orDEV_TYPE_PCI?) anyway (just like VT-d'sset_msi_source_id()does)?
... in pdev_type(), we will only reach DEV_TYPE_PCI2PCIe_BRIDGE if it has PCI_CAP_ID_EXP, which would indicate the device has extended config. So maybe it would be better to handle it similar to DEV_TYPE_PCIe2PCI_BRIDGE in alloc_pdev().
Quoted 3 lines
Linux also has
CONFIG_PCI_QUIRKS, allowing to compile out the slightly risky code (as reads may in principle have side effects). Should we gain such, too?
I don't have a strong opinion here.
Quoted 90 lines
xen/drivers/passthrough/pci.c +50
-1@@ -310,6 +310,41 @@ static void apply_quirks(struct pci_dev* from trying to size the BARs or add handlers to trap accesses. */ pdev->ignore_bars = true; + +if ( pdev->ext_cfg ) + { +unsigned int pos; + +/* +* PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says +* that when forwarding a type1 configuration request the bridge must +* check that the extended register address field is zero. The bridge +* is not permitted to forward the transactions and must handle it as +* an Unsupported Request. Some bridges do not follow this rule and +* simply drop the extended register bits, resulting in the standard +* config space being aliased, every 256 bytes across the entire +* configuration space. Test for this condition by comparing the first +* dword of each potential alias to the vendor/device ID. +* Known offenders: +* ASM1083/1085 PCIe-to-PCI Reversible Bridge (1b21:1080, rev 01 & 03) +* AMD/ATI SBx00 PCI to PCI Bridge (1002:4384, rev 40) +*/ +for ( pos =PCI_CFG_SPACE_SIZE ; + pos <PCI_CFG_SPACE_EXP_SIZE ; pos +=PCI_CFG_SPACE_SIZE ) + { +if (pci_conf_read16 (pdev->sbdf, pos) != vendor || +pci_conf_read16 (pdev->sbdf, pos +2 ) != device ) +break ; + } + +if ( pos >=PCI_CFG_SPACE_EXP_SIZE ) + { +printk (XENLOG_WARNING +"%pp: extended config space aliases base one\n" , + &pdev->sbdf); + pdev->ext_cfg = false; + } + } }static struct pci_dev *alloc_pdev (struct pci_seg *pseg,u8 bus,u8 devfn)@@ -351,6 +386,8 @@ static struct pci_dev *alloc_pdev(structunsigned long flags;case DEV_TYPE_PCIe2PCI_BRIDGE: + pdev->ext_cfg = true; + fallthrough;case DEV_TYPE_LEGACY_PCI_BRIDGE : sec_bus =pci_conf_read8 (pdev->sbdf,PCI_SECONDARY_BUS ); sub_bus =pci_conf_read8 (pdev->sbdf,PCI_SUBORDINATE_BUS );@@ -363,9 +400,19 @@ static struct pci_dev *alloc_pdev(struct pseg->bus2bridge[sec_bus].devfn = devfn; }spin_unlock_irqrestore (&pseg->bus2bridge_lock, flags); + + fallthrough; +case DEV_TYPE_PCI : + pos =pci_find_cap_offset (pdev->sbdf,PCI_CAP_ID_PCIX ); +if ( pos && + (pci_conf_read32 (pdev->sbdf, pos +PCI_X_STATUS ) & + (PCI_X_STATUS_266MHZ |PCI_X_STATUS_533MHZ )) ) + pdev->ext_cfg = true;break ;case DEV_TYPE_PCIe_ENDPOINT: + pdev->ext_cfg = true; + pos =pci_find_cap_offset (pdev->sbdf,PCI_CAP_ID_EXP );BUG_ON (!pos); cap =pci_conf_read16 (pdev->sbdf, pos +PCI_EXP_DEVCAP );@@ -409,9 +456,9 @@ static struct pci_dev *alloc_pdev(struct }break ; -case DEV_TYPE_PCI :case DEV_TYPE_PCIe_BRIDGE:case DEV_TYPE_PCI_HOST_BRIDGE : + pdev->ext_cfg = true;break ;default :@@ -420,6 +467,19 @@ static struct pci_dev *alloc_pdev(structbreak ; } + if ( pdev->ext_cfg && +/*
xen/drivers/passthrough/pci.c static struct pci_dev *alloc_pdev(struct · line 481
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express +* devices have 4096 bytes. Even if the device is capable, that +* doesn't mean we can access it. Maybe we don't have a way to +* generate extended config space accesses, or the device is behind a +* reverse Express bridge. So we try reading the dword at +* PCI_CFG_SPACE_SIZE which must either be 0 or a valid extended +* capability header. +*/ + pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE) == 0xffffffffU ) + pdev->ext_cfg = false;
I'm using a machine where xen/arch/x86/x86_64/mmconfig-shared.c:is_mmconf_reserved() will initially return false during Xen boot:
(XEN) PCI: MCFG configuration 0: base f0000000 segment 0000 buses 00 - 3f (XEN) PCI: Not using MCFG for segment 0000 bus 00-3f
Then, during dom0 boot, dom0 will call PHYSDEVOP_pci_mmcfg_reserved, after which MCFG becomes enabled in Xen:
(XEN) PCI: Using MCFG for segment 0000 bus 00-3f
On such machines where mmcfg/ECAM is initially disabled, this will effectively set ->ext_cfg to false for all devices discovered at Xen boot.
I'm not really sure if I have any good suggestions, but perhaps we could add a macro or small function that returns something like
( pdev->ext_cfg && pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE) != 0xffffffffU )
to allow this checking to happen dynamically (but this still wouldn't handle the aliasing quirk). Maybe re-run the ext_cfg detection logic at the end of PHYSDEVOP_pci_mmcfg_reserved?
Regardless, I'd be happy to provide my R-b without this addressed, but I am curious if others think this as an issue?
Quoted 19 lines
xen/drivers/passthrough/pci.c +6
-0+apply_quirks (pdev);check_pdev (pdev);@@ -717,6 +777,11 @@ int pci_add_device(u16 seg, u8 bus, u8 dlist_add (&pdev->vf_list, &pf_pdev->vf_list); } + +if ( !pdev->ext_cfg ) +printk (XENLOG_WARNING +"%pp: VF without extended config space?\n" , + &pdev->sbdf); } }
xen/include/xen/pci.h struct pci_dev { · line 129
Quoted 4 lines
xen/include/xen/pci.h +1
-0@@ -126,6 +126,9 @@ struct pci_dev {nodeid_t node;/* NUMA node */ +/* Whether the device has extended config space. */
Nit: it would be nice to clearly state if this means the extended config is accessible, or whether the device merely has it (but might not be accessible).
Quoted 6 lines
xen/include/xen/pci.h +2
-0+bool ext_cfg; +/* Device to be quarantined, don't automatically re-assign to dom0 */ bool quarantine;
Re: [PATCH 1/6] PCI: determine whether a device has extended config space
Quoted 8 lines · Stewart Hildebrand
Quoted 4 lines · Jan Beulich
---
Note that alloc_pdev()'s switch doesn't handleDEV_TYPE_PCI2PCIe_BRIDGEat all. Such bridges will therefore not have ->ext_cfg set (which is likely wrong).I initially read "set" as in "set to true", but I think you mean that
ext_cfgisn't assigned at all.
Both are the same really, due to alloc_pdev() using xzalloc().
Quoted 9 lines
Though perhaps it should actually be set to true, because ...
Quoted 2 lines
Shouldn't we handle them like
DEV_TYPE_LEGACY_PCI_BRIDGE(orDEV_TYPE_PCI?) anyway (just like VT-d'sset_msi_source_id()does)?... in
pdev_type(), we will only reachDEV_TYPE_PCI2PCIe_BRIDGEif it hasPCI_CAP_ID_EXP, which would indicate the device has extended config. So maybe it would be better to handle it similar toDEV_TYPE_PCIe2PCI_BRIDGEinalloc_pdev().
Hence my question. Since apparently you agree, I'll make that change. Maybe in a separate, prereq patch.
Quoted 39 lines
Quoted 6 lines
xen/drivers/passthrough/pci.c +2
-0@@ -420,6 +467,19 @@ static struct pci_dev *alloc_pdev(structbreak ; } + if ( pdev->ext_cfg && +/* xen/drivers/passthrough/pci.c static struct pci_dev *alloc_pdev(struct · line 481
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express +* devices have 4096 bytes. Even if the device is capable, that +* doesn't mean we can access it. Maybe we don't have a way to +* generate extended config space accesses, or the device is behind a +* reverse Express bridge. So we try reading the dword at +* PCI_CFG_SPACE_SIZE which must either be 0 or a valid extended +* capability header. +*/ + pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE) == 0xffffffffU ) + pdev->ext_cfg = false;I'm using a machine where xen/arch/x86/x86_64/mmconfig-shared.c:is_mmconf_reserved() will initially return false during Xen boot:
(XEN) PCI: MCFG configuration 0: base
f0000000segment 0000 buses 00 - 3f (XEN) PCI: Not using MCFG for segment 0000 bus 00-3fThen, during dom0 boot, dom0 will call
PHYSDEVOP_pci_mmcfg_reserved, after which MCFG becomes enabled in Xen:(XEN) PCI: Using MCFG for segment 0000 bus 00-3f
On such machines where mmcfg/ECAM is initially disabled, this will effectively set ->ext_cfg to false for all devices discovered at Xen boot.
I'm not really sure if I have any good suggestions, but perhaps we could add a macro or small function that returns something like
(pdev->ext_cfg&&pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE)!=0xffffffffU)
to allow this checking to happen dynamically (but this still wouldn't handle the aliasing quirk). Maybe re-run theext_cfgdetection logic at the end ofPHYSDEVOP_pci_mmcfg_reserved?
Quoted 2 lines
Regardless, I'd be happy to provide my R-b without this addressed, but I am curious if others think this as an issue?
Hmm, no, I forgot to consider that case (which in principle I'm well aware of). Will need to fix in v2.
Quoted 10 lines
xen/include/xen/pci.h struct pci_dev { · line 129
Quoted 7 lines
xen/include/xen/pci.h +1
-0@@ -126,6 +126,9 @@ struct pci_dev {nodeid_t node;/* NUMA node */ +/* Whether the device has extended config space. */ Nit: it would be nice to clearly state if this means the extended config is accessible, or whether the device merely has it (but might not be accessible).
Well. Would the indicator be of any use if it wasn't accessible? Because if it isn't accessible, we may not even be certain it exists. But yes, I can surely make it "... has (accessible) extended ...".
Jan
Re: [PATCH 1/6] PCI: determine whether a device has extended config space
Quoted 41 lines · Jan Beulich
Quoted 40 lines · Stewart Hildebrand
Quoted 6 lines · Jan Beulich
xen/drivers/passthrough/pci.c +2
-0@@ -420,6 +467,19 @@ static struct pci_dev *alloc_pdev(structbreak ; } + if ( pdev->ext_cfg && +/* xen/drivers/passthrough/pci.c static struct pci_dev *alloc_pdev(struct · line 481
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express +* devices have 4096 bytes. Even if the device is capable, that +* doesn't mean we can access it. Maybe we don't have a way to +* generate extended config space accesses, or the device is behind a +* reverse Express bridge. So we try reading the dword at +* PCI_CFG_SPACE_SIZE which must either be 0 or a valid extended +* capability header. +*/ + pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE) == 0xffffffffU ) + pdev->ext_cfg = false;I'm using a machine where xen/arch/x86/x86_64/mmconfig-shared.c:is_mmconf_reserved() will initially return false during Xen boot:
(XEN) PCI: MCFG configuration 0: base
f0000000segment 0000 buses 00 - 3f (XEN) PCI: Not using MCFG for segment 0000 bus 00-3fThen, during dom0 boot, dom0 will call
PHYSDEVOP_pci_mmcfg_reserved, after which MCFG becomes enabled in Xen:(XEN) PCI: Using MCFG for segment 0000 bus 00-3f
On such machines where mmcfg/ECAM is initially disabled, this will effectively set ->ext_cfg to false for all devices discovered at Xen boot.
I'm not really sure if I have any good suggestions, but perhaps we could add a macro or small function that returns something like
(pdev->ext_cfg&&pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE)!=0xffffffffU)
to allow this checking to happen dynamically (but this still wouldn't handle the aliasing quirk). Maybe re-run theext_cfgdetection logic at the end ofPHYSDEVOP_pci_mmcfg_reserved?
Quoted 5 lines
Quoted 2 lines
Regardless, I'd be happy to provide my R-b without this addressed, but I am curious if others think this as an issue?
Hmm, no, I forgot to consider that case (which in principle I'm well aware of). Will need to fix in v2.
That'll be a little interesting, since per Dom0's request we may also lose MCFG access to a range of busses. Looks like we indeed need to fully re- evaluate ->ext_cfg.
Jan
Re: [PATCH 1/6] PCI: determine whether a device has extended config space
In reply to Jan BeulichQuoted 41 lines · Jan Beulich
Quoted 40 lines · Stewart Hildebrand
Quoted 6 lines · Jan Beulich
xen/drivers/passthrough/pci.c +2
-0@@ -420,6 +467,19 @@ static struct pci_dev *alloc_pdev(structbreak ; } + if ( pdev->ext_cfg && +/* xen/drivers/passthrough/pci.c static struct pci_dev *alloc_pdev(struct · line 481
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express +* devices have 4096 bytes. Even if the device is capable, that +* doesn't mean we can access it. Maybe we don't have a way to +* generate extended config space accesses, or the device is behind a +* reverse Express bridge. So we try reading the dword at +* PCI_CFG_SPACE_SIZE which must either be 0 or a valid extended +* capability header. +*/ + pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE) == 0xffffffffU ) + pdev->ext_cfg = false;I'm using a machine where xen/arch/x86/x86_64/mmconfig-shared.c:is_mmconf_reserved() will initially return false during Xen boot:
(XEN) PCI: MCFG configuration 0: base
f0000000segment 0000 buses 00 - 3f (XEN) PCI: Not using MCFG for segment 0000 bus 00-3fThen, during dom0 boot, dom0 will call
PHYSDEVOP_pci_mmcfg_reserved, after which MCFG becomes enabled in Xen:(XEN) PCI: Using MCFG for segment 0000 bus 00-3f
On such machines where mmcfg/ECAM is initially disabled, this will effectively set ->ext_cfg to false for all devices discovered at Xen boot.
I'm not really sure if I have any good suggestions, but perhaps we could add a macro or small function that returns something like
(pdev->ext_cfg&&pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE)!=0xffffffffU)
to allow this checking to happen dynamically (but this still wouldn't handle the aliasing quirk). Maybe re-run theext_cfgdetection logic at the end ofPHYSDEVOP_pci_mmcfg_reserved?
Quoted 5 lines
Quoted 2 lines
Regardless, I'd be happy to provide my R-b without this addressed, but I am curious if others think this as an issue?
Hmm, no, I forgot to consider that case (which in principle I'm well aware of). Will need to fix in v2.
My reply yesterday was actually not quite sufficient. On a system like yours, isn't it the case that PVH Dom0 then also doesn't work quite right (yet), due to parts of vPCI depending on extended config space accesses now? All of what we presently do during boot, and which requires extended config space access, would need re-doing once extended config space access becomes available (or goes away) for a (sub)set of devices.
Jan
Re: [PATCH 1/6] PCI: determine whether a device has extended config space
Quoted 48 lines · Jan Beulich
Quoted 41 lines · Jan Beulich
Quoted 40 lines · Stewart Hildebrand
Quoted 6 lines · Jan Beulich
xen/drivers/passthrough/pci.c +2
-0@@ -420,6 +467,19 @@ static struct pci_dev *alloc_pdev(structbreak ; } + if ( pdev->ext_cfg && +/* xen/drivers/passthrough/pci.c static struct pci_dev *alloc_pdev(struct · line 481
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express +* devices have 4096 bytes. Even if the device is capable, that +* doesn't mean we can access it. Maybe we don't have a way to +* generate extended config space accesses, or the device is behind a +* reverse Express bridge. So we try reading the dword at +* PCI_CFG_SPACE_SIZE which must either be 0 or a valid extended +* capability header. +*/ + pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE) == 0xffffffffU ) + pdev->ext_cfg = false;I'm using a machine where xen/arch/x86/x86_64/mmconfig-shared.c:is_mmconf_reserved() will initially return false during Xen boot:
(XEN) PCI: MCFG configuration 0: base
f0000000segment 0000 buses 00 - 3f (XEN) PCI: Not using MCFG for segment 0000 bus 00-3fThen, during dom0 boot, dom0 will call
PHYSDEVOP_pci_mmcfg_reserved, after which MCFG becomes enabled in Xen:(XEN) PCI: Using MCFG for segment 0000 bus 00-3f
On such machines where mmcfg/ECAM is initially disabled, this will effectively set ->ext_cfg to false for all devices discovered at Xen boot.
I'm not really sure if I have any good suggestions, but perhaps we could add a macro or small function that returns something like
(pdev->ext_cfg&&pci_conf_read32(pdev->sbdf, PCI_CFG_SPACE_SIZE)!=0xffffffffU)
to allow this checking to happen dynamically (but this still wouldn't handle the aliasing quirk). Maybe re-run theext_cfgdetection logic at the end ofPHYSDEVOP_pci_mmcfg_reserved?Quoted 5 lines
Quoted 2 lines
Regardless, I'd be happy to provide my R-b without this addressed, but I am curious if others think this as an issue?
Hmm, no, I forgot to consider that case (which in principle I'm well aware of). Will need to fix in v2.
Quoted 6 lines
My reply yesterday was actually not quite sufficient. On a system like yours, isn't it the case that PVH Dom0 then also doesn't work quite right (yet), due to parts of vPCI depending on extended config space accesses now? All of what we presently do during boot, and which requires extended config space access, would need re-doing once extended config space access becomes available (or goes away) for a (sub)set of devices.
Right, e.g. rebar will fail to initialize. One possible approach might be to do some variation of this at the end of PHYSDEVOP_pci_mmcfg_reserved (untested):
for_each_pdev ( hardware_domain, pdev )
vpci_reset_device(pdev);
This would be better than nothing IMO, however, as you point out, it may only be needed for a subset of devices.
PATCH 2/6 PCI: pass pdev to pci_ats_{device,enabled}()
In reply to Jan BeulichThis not only brings both in sync with {en,dis}able_ats_device() but also prepares for doing the same to pci_find_{,next_}ext_capability().
xen/drivers/passthrough/amd/iommu_cmd.c +1 -1
@@ -285,7 +285,7 @@ void amd_iommu_flush_iotlb(u8 devfn, conif ( !ats_enabled )return ; -if ( !pci_ats_enabled (pdev->seg, pdev->bus, pdev->devfn) ) +if ( !pci_ats_enabled (pdev) )return ; iommu =find_iommu_for_device (pdev->sbdf);
xen/drivers/passthrough/amd/pci_amd_iommu.c +3 -5
@@ -121,7 +121,7 @@ static bool use_ats( {return !ivrs_dev->block_ats &&iommu_has_cap (iommu,PCI_CAP_IOTLB_SHIFT ) && -pci_ats_device (iommu->sbdf.seg, pdev->bus, pdev->devfn); +pci_ats_device (pdev); } static int __must_check amd_iommu_setup_domain_device(
@@ -274,8 +274,7 @@ static int __must_check amd_iommu_setup_ASSERT (pcidevs_locked ()); -if (use_ats (pdev, iommu, ivrs_dev) && - !pci_ats_enabled (iommu->sbdf.seg, bus, pdev->devfn) ) +if (use_ats (pdev, iommu, ivrs_dev) && !pci_ats_enabled (pdev) ) {if ( devfn == pdev->devfn )enable_ats_device (pdev, &iommu->ats_devices);
@@ -418,8 +417,7 @@ static void amd_iommu_disable_domain_devASSERT (pcidevs_locked ()); -if (pci_ats_device (iommu->sbdf.seg, bus, pdev->devfn) && -pci_ats_enabled (iommu->sbdf.seg, bus, pdev->devfn) ) +if (pci_ats_device (pdev) &&pci_ats_enabled (pdev) )disable_ats_device (pdev);BUG_ON ( iommu->dev_table.buffer ==NULL );
xen/drivers/passthrough/ats.h +5 -7
@@ -27,27 +27,25 @@ extern bool ats_enabled;int enable_ats_device (struct pci_dev *pdev,struct list_head *ats_list);void disable_ats_device (struct pci_dev *pdev); -static inline int pci_ats_enabled (int seg,int bus,int devfn) +static inline int pci_ats_enabled (const struct pci_dev *pdev) {u32 value;int pos; - pos =pci_find_ext_capability (PCI_SBDF (seg, bus, devfn), -PCI_EXT_CAP_ID_ATS ); + pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS );BUG_ON (!pos); - value =pci_conf_read16 (PCI_SBDF (seg, bus, devfn), pos +ATS_REG_CTL ); + value =pci_conf_read16 (pdev->sbdf, pos +ATS_REG_CTL );return value &ATS_ENABLE ; } -static inline int pci_ats_device (int seg,int bus,int devfn) +static inline int pci_ats_device (const struct pci_dev *pdev) {if ( !ats_enabled )return 0 ; -return pci_find_ext_capability (PCI_SBDF (seg, bus, devfn), -PCI_EXT_CAP_ID_ATS ); +return pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS ); }#endif /* DRIVERS__PASSTHROUGH__ATS_H */
Re: [PATCH 2/6] PCI: pass pdev to pci_ats_{device,enabled}()
Hello,
Le 06/01/2026 à 14:51, Jan Beulich a écrit :
Quoted 74 lines
This not only brings both in sync with {en,dis}able_ats_device() but also prepares for doing the same to pci_find_{,next_}ext_capability().
Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/amd/iommu_cmd.c +1
-1@@ -285,7 +285,7 @@ void amd_iommu_flush_iotlb(u8 devfn, conif ( !ats_enabled )return ; -if ( !pci_ats_enabled (pdev->seg, pdev->bus, pdev->devfn) ) +if ( !pci_ats_enabled (pdev) )return ; iommu =find_iommu_for_device (pdev->sbdf);xen/drivers/passthrough/amd/pci_amd_iommu.c +3
-5@@ -121,7 +121,7 @@ static bool use_ats( {return !ivrs_dev->block_ats &&iommu_has_cap (iommu,PCI_CAP_IOTLB_SHIFT ) && -pci_ats_device (iommu->sbdf.seg, pdev->bus, pdev->devfn); +pci_ats_device (pdev); } static int __must_check amd_iommu_setup_domain_device(@@ -274,8 +274,7 @@ static int __must_check amd_iommu_setup_ASSERT (pcidevs_locked ()); -if (use_ats (pdev, iommu, ivrs_dev) && - !pci_ats_enabled (iommu->sbdf.seg, bus, pdev->devfn) ) +if (use_ats (pdev, iommu, ivrs_dev) && !pci_ats_enabled (pdev) ) {if ( devfn == pdev->devfn )enable_ats_device (pdev, &iommu->ats_devices);@@ -418,8 +417,7 @@ static void amd_iommu_disable_domain_devASSERT (pcidevs_locked ()); -if (pci_ats_device (iommu->sbdf.seg, bus, pdev->devfn) && -pci_ats_enabled (iommu->sbdf.seg, bus, pdev->devfn) ) +if (pci_ats_device (pdev) &&pci_ats_enabled (pdev) )disable_ats_device (pdev);BUG_ON ( iommu->dev_table.buffer ==NULL );xen/drivers/passthrough/ats.h +4
-5@@ -27,27 +27,25 @@ extern bool ats_enabled;int enable_ats_device (struct pci_dev *pdev,struct list_head *ats_list);void disable_ats_device (struct pci_dev *pdev); -static inline int pci_ats_enabled (int seg,int bus,int devfn) +static inline int pci_ats_enabled (const struct pci_dev *pdev) {u32 value;int pos; - pos =pci_find_ext_capability (PCI_SBDF (seg, bus, devfn), -PCI_EXT_CAP_ID_ATS ); + pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS );BUG_ON (!pos); - value =pci_conf_read16 (PCI_SBDF (seg, bus, devfn), pos +ATS_REG_CTL ); + value =pci_conf_read16 (pdev->sbdf, pos +ATS_REG_CTL );return value &ATS_ENABLE ; } -static inline int pci_ats_device (int seg,int bus,int devfn) +static inline int pci_ats_device (const struct pci_dev *pdev)
xen/drivers/passthrough/ats.h extern bool ats_enabled; · line 51
Quoted 10 lines
xen/drivers/passthrough/ats.h +1
-2{if ( !ats_enabled )return 0 ; -return pci_find_ext_capability (PCI_SBDF (seg, bus, devfn), -PCI_EXT_CAP_ID_ATS ); +return pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS ); }#endif /* DRIVERS__PASSTHROUGH__ATS_H */
Teddy
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
PATCH 3/6 x86/MSI: pass pdev to read_pci_mem_bar()
In reply to Jan BeulichThis not only reduces the number of parameters and local variables, but also prepares for doing the same to pci_find_{,next_}ext_capability().
xen/arch/x86/msi.c +19 -38
@@ -662,11 +662,11 @@ static int msi_capability_init(struct pcreturn 0 ; } -static uint64_t read_pci_mem_bar (pci_sbdf_t sbdf,uint8_t bir,int vf, -const struct pf_info *pf_info) +static uint64_t read_pci_mem_bar (const struct pci_dev *pdev,uint8_t bir, +int vf) { -uint16_t seg = sbdf.seg; -uint8_t bus = sbdf.bus, slot = sbdf.dev, func = sbdf.fn; +uint16_t seg = pdev->sbdf.seg; +uint8_t bus = pdev->sbdf.bus, slot = pdev->sbdf.dev, func = pdev->sbdf.fn;u8 limit;u32 addr, base =PCI_BASE_ADDRESS_0 ;u64 disp =0 ;
@@ -676,20 +676,18 @@ static uint64_t read_pci_mem_bar(pci_sbdunsigned int pos;uint16_t ctrl, num_vf, offset, stride; -ASSERT (pf_info); - - pos =pci_find_ext_capability (sbdf,PCI_EXT_CAP_ID_SRIOV ); - ctrl =pci_conf_read16 (sbdf, pos +PCI_SRIOV_CTRL ); - num_vf =pci_conf_read16 (sbdf, pos +PCI_SRIOV_NUM_VF ); - offset =pci_conf_read16 (sbdf, pos +PCI_SRIOV_VF_OFFSET ); - stride =pci_conf_read16 (sbdf, pos +PCI_SRIOV_VF_STRIDE ); + pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_SRIOV ); + ctrl =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_CTRL ); + num_vf =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_NUM_VF ); + offset =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_VF_OFFSET ); + stride =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_VF_STRIDE );if ( !pos || !(ctrl &PCI_SRIOV_CTRL_VFE ) || !(ctrl &PCI_SRIOV_CTRL_MSE ) || !num_vf || !offset || (num_vf >1 && !stride) || bir >=PCI_SRIOV_NUM_BARS || - !pf_info->vf_rlen[bir] ) + !pdev->physfn.vf_rlen[bir] )return 0 ; base = pos +PCI_SRIOV_BAR ; vf -=PCI_BDF (bus, slot, func) + offset;
@@ -703,8 +701,8 @@ static uint64_t read_pci_mem_bar(pci_sbd }if ( vf >= num_vf )return 0 ; -BUILD_BUG_ON (ARRAY_SIZE (pf_info->vf_rlen) !=PCI_SRIOV_NUM_BARS ); - disp = vf * pf_info->vf_rlen[bir]; +BUILD_BUG_ON (ARRAY_SIZE (pdev->physfn.vf_rlen) !=PCI_SRIOV_NUM_BARS ); + disp = vf * pdev->physfn.vf_rlen[bir]; limit =PCI_SRIOV_NUM_BARS ; } else switch ( pci_conf_read8(PCI_SBDF(seg, bus, slot, func),
@@ -759,10 +757,6 @@ static int msix_capability_init(struct pu16 control;u64 table_paddr;u32 table_offset; -u16 seg = dev->seg; -u8 bus = dev->bus; -u8 slot =PCI_SLOT (dev->devfn); -u8 func =PCI_FUNC (dev->devfn);bool maskall = msix->host_maskall, zap_on_error = false;unsigned int pos = dev->msix_pos;
@@ -809,32 +803,20 @@ static int msix_capability_init(struct p (is_hardware_domain(current->domain) && (dev->domain == current->domain || dev->domain == dom_io))) ) { -unsigned int bir = table_offset &PCI_MSIX_BIRMASK , pbus, pslot, pfunc; -int vf; +unsigned int bir = table_offset &PCI_MSIX_BIRMASK ; +int vf =-1 ; +const struct pci_dev *pf_dev = dev;paddr_t pba_paddr;unsigned int pba_offset; -const struct pf_info *pf_info; -if ( !dev->info.is_virtfn ) - { - pbus = bus; - pslot = slot; - pfunc = func; - vf =-1 ; - pf_info =NULL ; - } -else +if ( dev->info.is_virtfn ) { - pbus = dev->info.physfn.bus; - pslot =PCI_SLOT (dev->info.physfn.devfn); - pfunc =PCI_FUNC (dev->info.physfn.devfn); vf = dev->sbdf.bdf;ASSERT (dev->pf_pdev); - pf_info = &dev->pf_pdev->physfn; + pf_dev = dev->pf_pdev; } - table_paddr =read_pci_mem_bar (PCI_SBDF (seg, pbus, pslot, pfunc), bir, - vf, pf_info); + table_paddr =read_pci_mem_bar (pf_dev, bir, vf);WARN_ON (msi && msi->table_base != table_paddr);if ( !table_paddr ) {
@@ -857,8 +839,7 @@ static int msix_capability_init(struct p pba_offset =pci_conf_read32 (dev->sbdf,msix_pba_offset_reg (pos)); bir = (u8)(pba_offset &PCI_MSIX_BIRMASK ); - pba_paddr =read_pci_mem_bar (PCI_SBDF (seg, pbus, pslot, pfunc), bir, vf, - pf_info); + pba_paddr =read_pci_mem_bar (pf_dev, bir, vf);WARN_ON (!pba_paddr); pba_paddr += pba_offset & ~PCI_MSIX_BIRMASK ;
Re: [PATCH 3/6] x86/MSI: pass pdev to read_pci_mem_bar()
Le 06/01/2026 à 14:51, Jan Beulich a écrit :
Quoted 114 lines
This not only reduces the number of parameters and local variables, but also prepares for doing the same to pci_find_{,next_}ext_capability().
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/msi.c +18
-36@@ -662,11 +662,11 @@ static int msi_capability_init(struct pcreturn 0 ; } -static uint64_t read_pci_mem_bar (pci_sbdf_t sbdf,uint8_t bir,int vf, -const struct pf_info *pf_info) +static uint64_t read_pci_mem_bar (const struct pci_dev *pdev,uint8_t bir, +int vf) { -uint16_t seg = sbdf.seg; -uint8_t bus = sbdf.bus, slot = sbdf.dev, func = sbdf.fn; +uint16_t seg = pdev->sbdf.seg; +uint8_t bus = pdev->sbdf.bus, slot = pdev->sbdf.dev, func = pdev->sbdf.fn;u8 limit;u32 addr, base =PCI_BASE_ADDRESS_0 ;u64 disp =0 ;@@ -676,20 +676,18 @@ static uint64_t read_pci_mem_bar(pci_sbdunsigned int pos;uint16_t ctrl, num_vf, offset, stride; -ASSERT (pf_info); - - pos =pci_find_ext_capability (sbdf,PCI_EXT_CAP_ID_SRIOV ); - ctrl =pci_conf_read16 (sbdf, pos +PCI_SRIOV_CTRL ); - num_vf =pci_conf_read16 (sbdf, pos +PCI_SRIOV_NUM_VF ); - offset =pci_conf_read16 (sbdf, pos +PCI_SRIOV_VF_OFFSET ); - stride =pci_conf_read16 (sbdf, pos +PCI_SRIOV_VF_STRIDE ); + pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_SRIOV ); + ctrl =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_CTRL ); + num_vf =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_NUM_VF ); + offset =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_VF_OFFSET ); + stride =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_VF_STRIDE );if ( !pos || !(ctrl &PCI_SRIOV_CTRL_VFE ) || !(ctrl &PCI_SRIOV_CTRL_MSE ) || !num_vf || !offset || (num_vf >1 && !stride) || bir >=PCI_SRIOV_NUM_BARS || - !pf_info->vf_rlen[bir] ) + !pdev->physfn.vf_rlen[bir] )return 0 ; base = pos +PCI_SRIOV_BAR ; vf -=PCI_BDF (bus, slot, func) + offset;@@ -703,8 +701,8 @@ static uint64_t read_pci_mem_bar(pci_sbd }if ( vf >= num_vf )return 0 ; -BUILD_BUG_ON (ARRAY_SIZE (pf_info->vf_rlen) !=PCI_SRIOV_NUM_BARS ); - disp = vf * pf_info->vf_rlen[bir]; +BUILD_BUG_ON (ARRAY_SIZE (pdev->physfn.vf_rlen) !=PCI_SRIOV_NUM_BARS ); + disp = vf * pdev->physfn.vf_rlen[bir]; limit =PCI_SRIOV_NUM_BARS ; } else switch ( pci_conf_read8(PCI_SBDF(seg, bus, slot, func),@@ -759,10 +757,6 @@ static int msix_capability_init(struct pu16 control;u64 table_paddr;u32 table_offset; -u16 seg = dev->seg; -u8 bus = dev->bus; -u8 slot =PCI_SLOT (dev->devfn); -u8 func =PCI_FUNC (dev->devfn);bool maskall = msix->host_maskall, zap_on_error = false;unsigned int pos = dev->msix_pos;@@ -809,32 +803,20 @@ static int msix_capability_init(struct p (is_hardware_domain(current->domain) && (dev->domain == current->domain || dev->domain == dom_io))) ) { -unsigned int bir = table_offset &PCI_MSIX_BIRMASK , pbus, pslot, pfunc; -int vf; +unsigned int bir = table_offset &PCI_MSIX_BIRMASK ; +int vf =-1 ; +const struct pci_dev *pf_dev = dev;paddr_t pba_paddr;unsigned int pba_offset; -const struct pf_info *pf_info; -if ( !dev->info.is_virtfn ) - { - pbus = bus; - pslot = slot; - pfunc = func; - vf =-1 ; - pf_info =NULL ; - } -else +if ( dev->info.is_virtfn ) { - pbus = dev->info.physfn.bus; - pslot =PCI_SLOT (dev->info.physfn.devfn); - pfunc =PCI_FUNC (dev->info.physfn.devfn); vf = dev->sbdf.bdf;ASSERT (dev->pf_pdev); - pf_info = &dev->pf_pdev->physfn; + pf_dev = dev->pf_pdev; } - table_paddr =read_pci_mem_bar (PCI_SBDF (seg, pbus, pslot, pfunc), bir, - vf, pf_info); + table_paddr =read_pci_mem_bar (pf_dev, bir, vf);WARN_ON (msi && msi->table_base != table_paddr);if ( !table_paddr ) {
xen/arch/x86/msi.c static int msix_capability_init(struct p · line 845
Quoted 9 lines
xen/arch/x86/msi.c +1
-2@@ -857,8 +839,7 @@ static int msix_capability_init(struct p pba_offset =pci_conf_read32 (dev->sbdf,msix_pba_offset_reg (pos)); bir = (u8)(pba_offset &PCI_MSIX_BIRMASK ); - pba_paddr =read_pci_mem_bar (PCI_SBDF (seg, pbus, pslot, pfunc), bir, vf, - pf_info); + pba_paddr =read_pci_mem_bar (pf_dev, bir, vf);WARN_ON (!pba_paddr); pba_paddr += pba_offset & ~PCI_MSIX_BIRMASK ;
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
PATCH 4/6 PCI: pass pdev to pci_find_{,next_}ext_capability()
In reply to Jan BeulichThis is in preparation of using attributes recorded for devices. Additionally locating (extended) capabilities of non-devices (e.g. phantom functions) makes no sense.
While there also eliminate open-coding of PCI_CFG_SPACE_SIZE in adjacent code.
xen/arch/x86/msi.c +1 -1
@@ -676,7 +676,7 @@ static uint64_t read_pci_mem_bar(const sunsigned int pos;uint16_t ctrl, num_vf, offset, stride; - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_SRIOV ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_SRIOV ); ctrl =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_CTRL ); num_vf =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_NUM_VF ); offset =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_VF_OFFSET );
xen/drivers/passthrough/ats.c +1 -1
@@ -26,7 +26,7 @@ int enable_ats_device(struct pci_dev *pdu32 value;int pos; - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ATS );BUG_ON (!pos);if ( iommu_verbose )
xen/drivers/passthrough/ats.h +2 -2
@@ -32,7 +32,7 @@ static inline int pci_ats_enabled(constu32 value;int pos; - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ATS );BUG_ON (!pos); value =pci_conf_read16 (pdev->sbdf, pos +ATS_REG_CTL );
@@ -45,7 +45,7 @@ static inline int pci_ats_device(const sif ( !ats_enabled )return 0 ; - return pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS); + return pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS); }#endif /* DRIVERS__PASSTHROUGH__ATS_H */
xen/drivers/passthrough/pci.c +2 -3
@@ -641,7 +641,7 @@ static void pci_enable_acs(struct pci_deif ( !is_iommu_enabled (pdev->domain) )return ; - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ACS ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ACS );if (!pos)return ;
@@ -787,8 +787,7 @@ int pci_add_device(u16 seg, u8 bus, u8 dif ( !pdev->info.is_virtfn && !pdev->physfn.vf_rlen[0 ] ) { -unsigned int pos =pci_find_ext_capability (pdev->sbdf, -PCI_EXT_CAP_ID_SRIOV ); +unsigned int pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_SRIOV );uint16_t ctrl =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_CTRL );if ( !pos )
xen/drivers/passthrough/vtd/x86/ats.c +1 -1
@@ -62,7 +62,7 @@ int ats_device(const struct pci_dev *pdereturn 0 ; ats_drhd =find_ats_dev_drhd (drhd->iommu); - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ATS );if ( pos && (ats_drhd ==NULL ) ) {
xen/drivers/passthrough/vtd/quirks.c +3 -3
@@ -531,10 +531,10 @@ void pci_vtd_quirk(const struct pci_dev/* Sandybridge-EP (Romley) */ case 0x3c00 :/* host bridge */ case 0x3c01 ... 0x3c0b: /* root ports */ - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ERR ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ERR );if ( !pos ) { - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_VNDR ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_VNDR );while ( pos ) { val =pci_conf_read32 (pdev->sbdf, pos +PCI_VNDR_HEADER );
@@ -543,7 +543,7 @@ void pci_vtd_quirk(const struct pci_dev pos +=PCI_VNDR_HEADER ;break ; } - pos =pci_find_next_ext_capability (pdev->sbdf, pos, + pos =pci_find_next_ext_capability (pdev, pos,PCI_EXT_CAP_ID_VNDR ); } ff =0 ;
xen/drivers/pci/pci.c +9 -7
@@ -89,9 +89,10 @@ unsigned int pci_find_next_cap(pci_sbdf_* within the device's PCI configuration space or 0 if the device does * not support it. */ -unsigned int pci_find_ext_capability (pci_sbdf_t sbdf,unsigned int cap) +unsigned int pci_find_ext_capability (const struct pci_dev *pdev, +unsigned int cap) { -return pci_find_next_ext_capability (sbdf,0 , cap); +return pci_find_next_ext_capability (pdev,0 , cap); }/**
@@ -104,14 +105,15 @@ unsigned int pci_find_ext_capability(pci* within the device's PCI configuration space or 0 if the device does * not support it. */ -unsigned int pci_find_next_ext_capability (pci_sbdf_t sbdf,unsigned int start, +unsigned int pci_find_next_ext_capability (const struct pci_dev *pdev, +unsigned int start,unsigned int cap) {u32 header;int ttl =480 ;/* 3840 bytes, minimum 8 bytes per capability */ -unsigned int pos =max (start,0x100U ); +unsigned int pos =max (start,PCI_CFG_SPACE_SIZE +0U ); - header =pci_conf_read32 (sbdf, pos); + header =pci_conf_read32 (pdev->sbdf, pos);/* * If we have no capabilities, this is indicated by cap ID,
@@ -125,9 +127,9 @@ unsigned int pci_find_next_ext_capabilitif (PCI_EXT_CAP_ID (header) == cap && pos != start )return pos; pos =PCI_EXT_CAP_NEXT (header); -if ( pos <0x100 ) +if ( pos <PCI_CFG_SPACE_SIZE )break ; - header =pci_conf_read32 (sbdf, pos); + header =pci_conf_read32 (pdev->sbdf, pos); }return 0 ; }
xen/drivers/vpci/rebar.c +1 -1
@@ -53,7 +53,7 @@ static int cf_check init_rebar(struct pc {uint32_t ctrl;unsigned int nbars; -unsigned int rebar_offset =pci_find_ext_capability (pdev->sbdf, +unsigned int rebar_offset =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_REBAR );if ( !rebar_offset )
xen/drivers/vpci/vpci.c +3 -3
@@ -196,7 +196,7 @@ static struct vpci_register *vpci_get_prstatic int vpci_ext_capability_hide (const struct pci_dev *pdev,unsigned int cap) { -const unsigned int offset =pci_find_ext_capability (pdev->sbdf, cap); +const unsigned int offset =pci_find_ext_capability (pdev, cap);struct vpci_register *r, *prev_r;struct vpci *vpci = pdev->vpci;uint32_t header, pre_header;
@@ -264,7 +264,7 @@ static int vpci_init_capabilities(structif ( !is_ext ) pos =pci_find_cap_offset (pdev->sbdf, cap);else if (is_hardware_domain (pdev->domain) ) - pos =pci_find_ext_capability (pdev->sbdf, cap); + pos =pci_find_ext_capability (pdev, cap);if ( !pos )continue ;
@@ -333,7 +333,7 @@ void vpci_deassign_device(struct pci_devif ( !capability->is_ext ) pos =pci_find_cap_offset (pdev->sbdf, cap);else if (is_hardware_domain (pdev->domain) ) - pos =pci_find_ext_capability (pdev->sbdf, cap); + pos =pci_find_ext_capability (pdev, cap);if ( pos ) {int rc = capability->cleanup (pdev, false);
xen/include/xen/pci.h +4 -2
@@ -263,8 +263,10 @@ unsigned int pci_find_next_cap_ttl(pci_s unsigned int *ttl);unsigned int pci_find_next_cap (pci_sbdf_t sbdf,unsigned int pos,unsigned int cap); -unsigned int pci_find_ext_capability (pci_sbdf_t sbdf,unsigned int cap); -unsigned int pci_find_next_ext_capability (pci_sbdf_t sbdf,unsigned int start, +unsigned int pci_find_ext_capability (const struct pci_dev *pdev, +unsigned int cap); +unsigned int pci_find_next_ext_capability (const struct pci_dev *pdev, +unsigned int start,unsigned int cap);const char *parse_pci (const char *s,unsigned int *seg_p,unsigned int *bus_p,unsigned int *dev_p,unsigned int *func_p);
Re: [PATCH 4/6] PCI: pass pdev to pci_find_{,next_}ext_capability()
Le 06/01/2026 à 14:52, Jan Beulich a écrit :
Quoted 200 lines
This is in preparation of using attributes recorded for devices. Additionally locating (extended) capabilities of non-devices (e.g. phantom functions) makes no sense.
While there also eliminate open-coding of
PCI_CFG_SPACE_SIZEin adjacent code.Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/msi.c +1
-1@@ -676,7 +676,7 @@ static uint64_t read_pci_mem_bar(const sunsigned int pos;uint16_t ctrl, num_vf, offset, stride; - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_SRIOV ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_SRIOV ); ctrl =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_CTRL ); num_vf =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_NUM_VF ); offset =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_VF_OFFSET );xen/drivers/passthrough/ats.c +1
-1@@ -26,7 +26,7 @@ int enable_ats_device(struct pci_dev *pdu32 value;int pos; - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ATS );BUG_ON (!pos);if ( iommu_verbose )xen/drivers/passthrough/ats.h +2
-2@@ -32,7 +32,7 @@ static inline int pci_ats_enabled(constu32 value;int pos; - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ATS );BUG_ON (!pos); value =pci_conf_read16 (pdev->sbdf, pos +ATS_REG_CTL );@@ -45,7 +45,7 @@ static inline int pci_ats_device(const sif ( !ats_enabled )return 0 ; - return pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS); + return pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS); }#endif /* DRIVERS__PASSTHROUGH__ATS_H */ xen/drivers/passthrough/pci.c +2
-3@@ -641,7 +641,7 @@ static void pci_enable_acs(struct pci_deif ( !is_iommu_enabled (pdev->domain) )return ; - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ACS ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ACS );if (!pos)return ;@@ -787,8 +787,7 @@ int pci_add_device(u16 seg, u8 bus, u8 dif ( !pdev->info.is_virtfn && !pdev->physfn.vf_rlen[0 ] ) { -unsigned int pos =pci_find_ext_capability (pdev->sbdf, -PCI_EXT_CAP_ID_SRIOV ); +unsigned int pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_SRIOV );uint16_t ctrl =pci_conf_read16 (pdev->sbdf, pos +PCI_SRIOV_CTRL );if ( !pos )xen/drivers/passthrough/vtd/x86/ats.c +1
-1@@ -62,7 +62,7 @@ int ats_device(const struct pci_dev *pdereturn 0 ; ats_drhd =find_ats_dev_drhd (drhd->iommu); - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ATS ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ATS );if ( pos && (ats_drhd ==NULL ) ) {xen/drivers/passthrough/vtd/quirks.c +3
-3@@ -531,10 +531,10 @@ void pci_vtd_quirk(const struct pci_dev/* Sandybridge-EP (Romley) */ case 0x3c00 :/* host bridge */ case 0x3c01 ... 0x3c0b: /* root ports */ - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_ERR ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_ERR );if ( !pos ) { - pos =pci_find_ext_capability (pdev->sbdf,PCI_EXT_CAP_ID_VNDR ); + pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_VNDR );while ( pos ) { val =pci_conf_read32 (pdev->sbdf, pos +PCI_VNDR_HEADER );@@ -543,7 +543,7 @@ void pci_vtd_quirk(const struct pci_dev pos +=PCI_VNDR_HEADER ;break ; } - pos =pci_find_next_ext_capability (pdev->sbdf, pos, + pos =pci_find_next_ext_capability (pdev, pos,PCI_EXT_CAP_ID_VNDR ); } ff =0 ;xen/drivers/pci/pci.c +9
-7@@ -89,9 +89,10 @@ unsigned int pci_find_next_cap(pci_sbdf_* within the device's PCI configuration space or 0 if the device does * not support it. */ -unsigned int pci_find_ext_capability (pci_sbdf_t sbdf,unsigned int cap) +unsigned int pci_find_ext_capability (const struct pci_dev *pdev, +unsigned int cap) { -return pci_find_next_ext_capability (sbdf,0 , cap); +return pci_find_next_ext_capability (pdev,0 , cap); }/** @@ -104,14 +105,15 @@ unsigned int pci_find_ext_capability(pci* within the device's PCI configuration space or 0 if the device does * not support it. */ -unsigned int pci_find_next_ext_capability (pci_sbdf_t sbdf,unsigned int start, +unsigned int pci_find_next_ext_capability (const struct pci_dev *pdev, +unsigned int start,unsigned int cap) {u32 header;int ttl =480 ;/* 3840 bytes, minimum 8 bytes per capability */ -unsigned int pos =max (start,0x100U ); +unsigned int pos =max (start,PCI_CFG_SPACE_SIZE +0U ); - header =pci_conf_read32 (sbdf, pos); + header =pci_conf_read32 (pdev->sbdf, pos);/* * If we have no capabilities, this is indicated by cap ID, @@ -125,9 +127,9 @@ unsigned int pci_find_next_ext_capabilitif (PCI_EXT_CAP_ID (header) == cap && pos != start )return pos; pos =PCI_EXT_CAP_NEXT (header); -if ( pos <0x100 ) +if ( pos <PCI_CFG_SPACE_SIZE )break ; - header =pci_conf_read32 (sbdf, pos); + header =pci_conf_read32 (pdev->sbdf, pos); }return 0 ; }xen/drivers/vpci/rebar.c +1
-1@@ -53,7 +53,7 @@ static int cf_check init_rebar(struct pc {uint32_t ctrl;unsigned int nbars; -unsigned int rebar_offset =pci_find_ext_capability (pdev->sbdf, +unsigned int rebar_offset =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_REBAR );if ( !rebar_offset )xen/drivers/vpci/vpci.c +3
-3@@ -196,7 +196,7 @@ static struct vpci_register *vpci_get_prstatic int vpci_ext_capability_hide (const struct pci_dev *pdev,unsigned int cap) { -const unsigned int offset =pci_find_ext_capability (pdev->sbdf, cap); +const unsigned int offset =pci_find_ext_capability (pdev, cap);struct vpci_register *r, *prev_r;struct vpci *vpci = pdev->vpci;uint32_t header, pre_header;@@ -264,7 +264,7 @@ static int vpci_init_capabilities(structif ( !is_ext ) pos =pci_find_cap_offset (pdev->sbdf, cap);else if (is_hardware_domain (pdev->domain) ) - pos =pci_find_ext_capability (pdev->sbdf, cap); + pos =pci_find_ext_capability (pdev, cap);if ( !pos )continue ;@@ -333,7 +333,7 @@ void vpci_deassign_device(struct pci_devif ( !capability->is_ext ) pos =pci_find_cap_offset (pdev->sbdf, cap);else if (is_hardware_domain (pdev->domain) ) - pos =pci_find_ext_capability (pdev->sbdf, cap); + pos =pci_find_ext_capability (pdev, cap);if ( pos ) {int rc = capability->cleanup (pdev, false);xen/include/xen/pci.h +0
-0@@ -263,8 +263,10 @@ unsigned int pci_find_next_cap_ttl(pci_s unsigned int *ttl); unsigned int pci_find_next_cap(pci_sbdf_t sbdf, unsigned int pos,
xen/include/xen/pci.h unsigned int pci_find_next_cap_ttl(pci_s · line 272
Quoted 10 lines
xen/include/xen/pci.h +4
-2unsigned int cap); -unsigned int pci_find_ext_capability (pci_sbdf_t sbdf,unsigned int cap); -unsigned int pci_find_next_ext_capability (pci_sbdf_t sbdf,unsigned int start, +unsigned int pci_find_ext_capability (const struct pci_dev *pdev, +unsigned int cap); +unsigned int pci_find_next_ext_capability (const struct pci_dev *pdev, +unsigned int start,unsigned int cap);const char *parse_pci (const char *s,unsigned int *seg_p,unsigned int *bus_p,unsigned int *dev_p,unsigned int *func_p);
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
PATCH 5/6 PCI: don't look for ext-caps when there's no extended cfg space
In reply to Jan BeulichAvoid 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.
---
Because of the multiple prereq changes, despite the Fixes: tags I'm not quite sure whether to backport this. (I'm leaning towards "no".)
xen/drivers/pci/pci.c +6 -0
@@ -113,6 +113,12 @@ unsigned int pci_find_next_ext_capabilitint 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);/*
PATCH 6/6 vPCI/DomU: really no ext-caps without extended config space
In reply to Jan BeulichWhether 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().
xen/drivers/vpci/header.c +5 -0
@@ -830,9 +830,14 @@ static int vpci_init_ext_capability_listunsigned int pos =PCI_CFG_SPACE_SIZE ;if ( !is_hardware_domain (pdev->domain) ) + { +if ( !pdev->ext_cfg ) +return 0 ; +/* Extended capabilities read as zero, write ignore for DomU */ return vpci_add_register (pdev->vpci, vpci_read_val,NULL , pos,4 , (void *)0 ); + } do {