Xen SR-IOV support initiation
Subsystems (2)
Greetings,
Following commits from the upstream kernel are backported to the Domain0 kernel as the first step of enabling Xen SR-IOV. Hopefully the SR-IOV core patches for the upstream kernel would be applied on the PCI subsystem tree in the next several days. Will backport them immediately they are in-tree so Xen 3.4 release could have the SR-IOV support.
PCI: define PCI resource names in an 'enum'
PCI: remove unnecessary condition check in pci_restore_bars()
PCI: add a new function to map BAR offsets
PCI: rewrite PCI BAR reading code
PCI: handle 64-bit resources better on 32-bit machines
PCI: fix 64-vbit prefetchable memory resource BARs
PCI: export __pci_read_base()
PCI: support PCIe ARI capability
PCI: fix ARI code to be compatible with mixed ARI/non-ARI systems
PCI: enhance pci_ari_enabled()
PCI: allow pci_alloc_child_bus() to handle a NULL bridge
PCI: remove unnecessary arg of pci_update_resource()
drivers/pci/pci-sysfs.c | 4 drivers/pci/pci.c | 104 +++++++++++++------ drivers/pci/pci.h | 29 ++++- drivers/pci/probe.c | 252 ++++++++++++++++++++++++++++------------------- drivers/pci/proc.c | 7 - drivers/pci/quirks.c | 2 drivers/pci/setup-res.c | 20 +-- include/linux/pci.h | 40 ++++--- include/linux/pci_regs.h | 15 ++ 9 files changed, 310 insertions(+), 163 deletions(-)
---
The SR-IOV specification (requires membership) can be found at:
* http://www.pcisig.com/members/downloads/specifications/iov/sr-iov1.0_11Sep07.pdf
The latest SR-IOV core patches for the upstream kernel are:
PCI: initialize and release SR-IOV capability
* http://patchwork.kernel.org/patch/11062/
PCI: restore saved SR-IOV state
* http://patchwork.kernel.org/patch/11063/
PCI: reserve bus range for SR-IOV device
* http://patchwork.kernel.org/patch/11064/
PCI: centralize device setup code
* http://patchwork.kernel.org/patch/11065/
PCI: add SR-IOV API for Physical Function driver
* http://patchwork.kernel.org/patch/11070/
PCI: handle SR-IOV Virtual Function Migration
* http://patchwork.kernel.org/patch/11066/
PCI: document SR-IOV sysfs entries
* http://patchwork.kernel.org/patch/11068/
PCI: manual for SR-IOV user and driver developer
* http://patchwork.kernel.org/patch/11069/
Intel 82576 Gigabit Ethernet Controller datasheet is available at:
* http://download.intel.com/design/network/datashts/82576_Datasheet.pdf
The patches to enable the SR-IOV capability of Intel 82576 NIC are available at (a.k.a Physical Function driver):
* http://patchwork.kernel.org/patch/8063/
* http://patchwork.kernel.org/patch/8064/
* http://patchwork.kernel.org/patch/8065/
* http://patchwork.kernel.org/patch/8066/
And the driver for Intel 82576 Virtual Function is available at:
* http://patchwork.kernel.org/patch/11029/
* http://patchwork.kernel.org/patch/11028/
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909107 14400
# Node ID 7f81d57622ccb390212d1c76308664115ae3a955 # Parent 0430b1dbfb3af5f374921b903c96b9b3234cd77c
Backport: PCI: rewrite PCI BAR reading code
commit 6ac665c63dcac8fcec534a1d224ecbb8b867ad59
Author: Matthew Wilcox <[email protected]>
Date: Mon Jul 28 13:38:59 2008 -0400
PCI: rewrite PCI BAR reading code
Factor out the code to read one BAR from the loop in pci_read_bases into a new function, __pci_read_base. The new code is slightly more readable, better commented and removes the ifdef.
drivers/pci/probe.c +130 -83
@@ -123,12 +123,9 @@return IORESOURCE_MEM ; } -/* -* Find the extent of a PCI decode.. -*/ -static u32 pci_size (u32 base,u32 maxbase,u32 mask) +static u64 pci_size (u64 base,u64 maxbase,u64 mask) { -u32 size = mask & maxbase;/* Find the significant bits */ +u64 size = mask & maxbase;/* Find the significant bits */ if (!size)return 0 ;
@@ -144,91 +141,141 @@return size; } +enum pci_bar_type { + pci_bar_unknown,/* Standard PCI BAR probe */ + pci_bar_io,/* An io port BAR */ + pci_bar_mem32,/* A 32-bit memory BAR */ + pci_bar_mem64,/* A 64-bit memory BAR */ +}; + +static inline enum pci_bar_type decode_bar (struct resource *res,u32 bar) +{ +if ((bar &PCI_BASE_ADDRESS_SPACE ) ==PCI_BASE_ADDRESS_SPACE_IO ) { + res->flags = bar & ~PCI_BASE_ADDRESS_IO_MASK ; +return pci_bar_io; + } + + res->flags = bar & ~PCI_BASE_ADDRESS_MEM_MASK ; + +if (res->flags ==PCI_BASE_ADDRESS_MEM_TYPE_64 ) +return pci_bar_mem64; +return pci_bar_mem32; +} + +/* +* If the type is not unknown, we assume that the lowest bit is 'enable'. +* Returns 1 if the BAR was 64-bit and 0 if it was 32-bit. +*/ +static int __pci_read_base (struct pci_dev *dev,enum pci_bar_type type, +struct resource *res,unsigned int pos) +{ +u32 l, sz, mask; + + mask = type ? ~PCI_ROM_ADDRESS_ENABLE : ~0 ; + + res->name =pci_name (dev); + +pci_read_config_dword (dev, pos, &l); +pci_write_config_dword (dev, pos, mask); +pci_read_config_dword (dev, pos, &sz); +pci_write_config_dword (dev, pos, l); + +/* +* All bits set in sz means the device isn't working properly. +* If the BAR isn't implemented, all bits must be 0. If it's a +* memory BAR or a ROM, bit 0 must be clear; if it's an io BAR, bit +* 1 must be clear. +*/ +if (!sz || sz ==0xffffffff ) + goto fail; + +/* +* I don't know how l can have all bits set. Copied from old code. +* Maybe it fixes a bug on some ancient platform. +*/ +if (l ==0xffffffff ) + l =0 ; + +if (type == pci_bar_unknown) { + type =decode_bar (res, l); + res->flags |=pci_calc_resource_flags (l); +if (type == pci_bar_io) { + l &=PCI_BASE_ADDRESS_IO_MASK ; + mask =PCI_BASE_ADDRESS_IO_MASK &0xffff ; + }else { + l &=PCI_BASE_ADDRESS_MEM_MASK ; + mask = (u32 )PCI_BASE_ADDRESS_MEM_MASK ; + } + }else { + res->flags |= (l &IORESOURCE_ROM_ENABLE ); + l &=PCI_ROM_ADDRESS_MASK ; + mask = (u32 )PCI_ROM_ADDRESS_MASK ; + } + +if (type == pci_bar_mem64) { +u64 l64 = l; +u64 sz64 = sz; +u64 mask64 = mask | (u64 )~0 <<32 ; + +pci_read_config_dword (dev, pos +4 , &l); +pci_write_config_dword (dev, pos +4 , ~0 ); +pci_read_config_dword (dev, pos +4 , &sz); +pci_write_config_dword (dev, pos +4 , l); + + l64 |= ((u64 )l <<32 ); + sz64 |= ((u64 )sz <<32 ); + + sz64 =pci_size (l64, sz64, mask64); + +if (!sz64) + goto fail; + +if ((BITS_PER_LONG <64 ) && (sz64 >0x100000000ULL )) { +dev_err (&dev->dev,"can't handle 64-bit BAR\n" ); + goto fail; + }else if ((BITS_PER_LONG <64 ) && l) { +/* Address above 32-bit boundary; disable the BAR */ +pci_write_config_dword (dev, pos,0 ); +pci_write_config_dword (dev, pos +4 ,0 ); + res->start =0 ; + res->end = sz64; + }else { + res->start = l64; + res->end = l64 + sz64; + } + }else { + sz =pci_size (l, sz, mask); + +if (!sz) + goto fail; + + res->start = l; + res->end = l + sz; + } + + out: +return (type == pci_bar_mem64) ?1 :0 ; + fail: + res->flags =0 ; + goto out; +} +static void pci_read_bases (struct pci_dev *dev,unsigned int howmany,int rom) { -unsigned int pos, reg, next; -u32 l, sz; -struct resource *res; +unsigned int pos, reg; -for (pos=0 ; pos<howmany; pos = next) { - next = pos+1 ; - res = &dev->resource[pos]; - res->name =pci_name (dev); +for (pos =0 ; pos < howmany; pos++) { +struct resource *res = &dev->resource[pos]; reg =PCI_BASE_ADDRESS_0 + (pos <<2 ); -pci_read_config_dword (dev, reg, &l); -pci_write_config_dword (dev, reg, ~0 ); -pci_read_config_dword (dev, reg, &sz); -pci_write_config_dword (dev, reg, l); -if (!sz || sz ==0xffffffff ) -continue ; -if (l ==0xffffffff ) - l =0 ; -if ((l &PCI_BASE_ADDRESS_SPACE ) ==PCI_BASE_ADDRESS_SPACE_MEMORY ) { - sz =pci_size (l, sz, (u32 )PCI_BASE_ADDRESS_MEM_MASK ); -if (!sz) -continue ; - res->start = l &PCI_BASE_ADDRESS_MEM_MASK ; - res->flags |= l & ~PCI_BASE_ADDRESS_MEM_MASK ; - }else { - sz =pci_size (l, sz,PCI_BASE_ADDRESS_IO_MASK &0xffff ); -if (!sz) -continue ; - res->start = l &PCI_BASE_ADDRESS_IO_MASK ; - res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK ; - } - res->end = res->start + (unsigned long ) sz; - res->flags |=pci_calc_resource_flags (l); -if ((l & (PCI_BASE_ADDRESS_SPACE |PCI_BASE_ADDRESS_MEM_TYPE_MASK )) - == (PCI_BASE_ADDRESS_SPACE_MEMORY |PCI_BASE_ADDRESS_MEM_TYPE_64 )) { -u32 szhi, lhi; -pci_read_config_dword (dev, reg+4 , &lhi); -pci_write_config_dword (dev, reg+4 , ~0 ); -pci_read_config_dword (dev, reg+4 , &szhi); -pci_write_config_dword (dev, reg+4 , lhi); - szhi =pci_size (lhi, szhi,0xffffffff ); - next++; -#if BITS_PER_LONG ==64 - res->start |= ((unsigned long ) lhi) <<32 ; - res->end = res->start + sz; -if (szhi) { -/* This BAR needs > 4GB? Wow. */ - res->end |= (unsigned long )szhi<<32 ; - } -#else -if (szhi) { -printk (KERN_ERR "PCI: Unable to handle 64-bit BAR for device %s\n" ,pci_name (dev)); - res->start =0 ; - res->flags =0 ; - }else if (lhi) { -/* 64-bit wide address, treat as disabled */ -pci_write_config_dword (dev, reg, l & ~(u32 )PCI_BASE_ADDRESS_MEM_MASK ); -pci_write_config_dword (dev, reg+4 ,0 ); - res->start =0 ; - res->end = sz; - } -#endif - } + pos +=__pci_read_base (dev, pci_bar_unknown, res, reg); } +if (rom) { +struct resource *res = &dev->resource[PCI_ROM_RESOURCE ]; dev->rom_base_reg = rom; - res = &dev->resource[PCI_ROM_RESOURCE ]; - res->name =pci_name (dev); -pci_read_config_dword (dev, rom, &l); -pci_write_config_dword (dev, rom, ~PCI_ROM_ADDRESS_ENABLE ); -pci_read_config_dword (dev, rom, &sz); -pci_write_config_dword (dev, rom, l); -if (l ==0xffffffff ) - l =0 ; -if (sz && sz !=0xffffffff ) { - sz =pci_size (l, sz, (u32 )PCI_ROM_ADDRESS_MASK ); -if (sz) { - res->flags = (l &IORESOURCE_ROM_ENABLE ) | -IORESOURCE_MEM |IORESOURCE_PREFETCH | -IORESOURCE_READONLY |IORESOURCE_CACHEABLE ; - res->start = l &PCI_ROM_ADDRESS_MASK ; - res->end = res->start + (unsigned long ) sz; - } - } + res->flags =IORESOURCE_MEM |IORESOURCE_PREFETCH | +IORESOURCE_READONLY |IORESOURCE_CACHEABLE ; +__pci_read_base (dev, pci_bar_mem32, res, rom); } }
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909173 14400
# Node ID 8bac898877bc9fb52befd566bbb8f04c190006f4
# Parent 7f81d57622ccb390212d1c76308664115ae3a955
Backport: PCI: handle 64-bit resources better on 32-bit machines
commit cc5499c3a607a392e8a7adb934aaf14b2c6a3519
Author: Matthew Wilcox <[email protected]>
Date: Mon Jul 28 13:39:00 2008 -0400
PCI: handle 64-bit resources better on 32-bit machines
If the kernel is configured to support 64-bit resources on a 32-bit machine, we can support 64-bit BARs properly. Just change the condition to check sizeof(resource_size_t) instead of BITS_PER_LONG.
drivers/pci/probe.c +2 -2
@@ -230,10 +230,10 @@if (!sz64) goto fail; -if ((BITS_PER_LONG <64 ) && (sz64 >0x100000000ULL )) { +if ((sizeof (resource_size_t) <8 ) && (sz64 >0x100000000ULL )) {dev_err (&dev->dev,"can't handle 64-bit BAR\n" ); goto fail; - }else if ((BITS_PER_LONG <64 ) && l) { + }else if ((sizeof (resource_size_t) <8 ) && l) {/* Address above 32-bit boundary; disable the BAR */ pci_write_config_dword (dev, pos,0 );pci_write_config_dword (dev, pos +4 ,0 );
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909216 14400
# Node ID 8de852cacf43ac03f7f4819589bc22f62a8d1b3c # Parent 8bac898877bc9fb52befd566bbb8f04c190006f4
Backport: PCI: fix 64-vbit prefetchable memory resource BARs
commit e354597cce8d219d135d65e585dc4f30323486b9
Author: Peter Chubb <[email protected]>
Date: Mon Oct 13 11:49:04 2008 +1100
PCI: fix 64-vbit prefetchable memory resource BARs
Since patch 6ac665c63dcac8fcec534a1d224ecbb8b867ad59 my infiniband controller hasn't worked. This is because it has 64-bit prefetchable memory, which was mistakenly being taken to be 32-bit memory. The resource flags in this case are PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH.
This patch checks only for the PCI_BASE_ADDRESS_MEM_TYPE_64 bit; thus whether the region is prefetchable or not is ignored. This fixes my Infiniband.
drivers/pci/probe.c +1 -1
@@ -157,7 +157,7 @@ res->flags = bar & ~PCI_BASE_ADDRESS_MEM_MASK ; -if (res->flags ==PCI_BASE_ADDRESS_MEM_TYPE_64 ) +if (res->flags &PCI_BASE_ADDRESS_MEM_TYPE_64 )return pci_bar_mem64;return pci_bar_mem32; }
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909313 14400
# Node ID 66f3de153185eddae2d118d088ecfc17e96bf706 # Parent 8de852cacf43ac03f7f4819589bc22f62a8d1b3c
Backport: PCI: export __pci_read_base()
commit 0b400c7ed4d027e02f6231afa39852a2d48e6f25
Author: Yu Zhao <[email protected]>
Date: Sat Nov 22 02:40:40 2008 +0800
PCI: export __pci_read_base()
Export __pci_read_base() so it can be used by whole PCI subsystem.
drivers/pci/pci.h +10 -0
@@ -109,3 +109,13 @@#ifdef CONFIG_PCI_GUESTDEV int pci_is_guestdev_to_reassign (struct pci_dev *dev);#endif /* CONFIG_PCI_GUESTDEV */ + +enum pci_bar_type { + pci_bar_unknown,/* Standard PCI BAR probe */ + pci_bar_io,/* An io port BAR */ + pci_bar_mem32,/* A 32-bit memory BAR */ + pci_bar_mem64,/* A 64-bit memory BAR */ +}; + +extern int __pci_read_base (struct pci_dev *dev,enum pci_bar_type type, +struct resource *res,unsigned int reg);
drivers/pci/probe.c +9 -11
@@ -141,13 +141,6 @@return size; } -enum pci_bar_type { - pci_bar_unknown,/* Standard PCI BAR probe */ - pci_bar_io,/* An io port BAR */ - pci_bar_mem32,/* A 32-bit memory BAR */ - pci_bar_mem64,/* A 64-bit memory BAR */ -}; -static inline enum pci_bar_type decode_bar (struct resource *res,u32 bar) {if ((bar &PCI_BASE_ADDRESS_SPACE ) ==PCI_BASE_ADDRESS_SPACE_IO ) {
@@ -162,11 +155,16 @@return pci_bar_mem32; } -/* -* If the type is not unknown, we assume that the lowest bit is 'enable'. -* Returns 1 if the BAR was 64-bit and 0 if it was 32-bit. +/** +* pci_read_base - read a PCI BAR +* @dev: the PCI device +* @type: type of the BAR +* @res: resource buffer to be filled in +* @pos: BAR position in the config space +* +* Returns 1 if the BAR is 64-bit, or 0 if 32-bit. */ -static int __pci_read_base (struct pci_dev *dev,enum pci_bar_type type, +int __pci_read_base (struct pci_dev *dev,enum pci_bar_type type,struct resource *res,unsigned int pos) {u32 l, sz, mask;
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909443 14400
# Node ID 313310b824c81e803a698ee3a1a8a94075096060 # Parent 66f3de153185eddae2d118d088ecfc17e96bf706
Backport: PCI: support PCIe ARI capability
commit 58c3a727cb73b75a9104d295f096cca12959a5a5
Author: Yu Zhao <[email protected]>
Date: Tue Oct 14 14:02:53 2008 +0800
PCI: support PCIe ARI capability
This patch adds support for PCI Express Alternative Routing-ID Interpretation (ARI) capability.
The ARI capability extends the Function Number field of the PCI Express Endpoint by reusing the Device Number which is otherwise hardwired to 0. With ARI, an Endpoint can have up to 256 functions.
drivers/pci/pci.c +32 -0
@@ -629,6 +629,38 @@return 0 ; } +/** +* pci_enable_ari - enable ARI forwarding if hardware support it +* @dev: the PCI device +*/ +void pci_enable_ari (struct pci_dev *dev) +{ +int pos; +u32 cap; +u16 ctrl; + +if (!dev->is_pcie) +return ; + +if (dev->pcie_type !=PCI_EXP_TYPE_ROOT_PORT && + dev->pcie_type !=PCI_EXP_TYPE_DOWNSTREAM ) +return ; + + pos =pci_find_capability (dev,PCI_CAP_ID_EXP ); +if (!pos) +return ; + +pci_read_config_dword (dev, pos +PCI_EXP_DEVCAP2 , &cap); +if (!(cap &PCI_EXP_DEVCAP2_ARI )) +return ; + +pci_read_config_word (dev, pos +PCI_EXP_DEVCTL2 , &ctrl); + ctrl |=PCI_EXP_DEVCTL2_ARI ; +pci_write_config_word (dev, pos +PCI_EXP_DEVCTL2 , ctrl); + + dev->ari_enabled =1 ; +} +int pci_get_interrupt_pin (struct pci_dev *dev,struct pci_dev **bridge) {
drivers/pci/pci.h +11 -0
@@ -119,3 +119,14 @@extern int __pci_read_base (struct pci_dev *dev,enum pci_bar_type type,struct resource *res,unsigned int reg); +extern void pci_enable_ari (struct pci_dev *dev); +/** +* pci_ari_enabled - query ARI forwarding status +* @dev: the PCI device +* +* Returns 1 if ARI forwarding is enabled, or 0 if not enabled; +*/ +static inline int pci_ari_enabled (struct pci_dev *dev) +{ +return dev->ari_enabled; +}
drivers/pci/probe.c +3 -0
@@ -885,6 +885,9 @@/* Fix up broken headers */ pci_fixup_device (pci_fixup_header, dev); +/* Alternative Routing-ID Forwarding */ +pci_enable_ari (dev); +/* * Add the device to our list of discovered devices * and the bus list for fixup functions, etc.
include/linux/pci.h +1 -0
@@ -172,6 +172,7 @@struct bin_attribute *rom_attr;/* attribute descriptor for sysfs ROM entry */ int rom_attr_enabled;/* has display of the rom attribute been enabled? */ struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE ];/* sysfs file for resources */ + unsigned int ari_enabled:1; /* ARI forwarding */ };#define pci_dev_g (n) list_entry(n, struct pci_dev, global_list)
include/linux/pci_regs.h +15 -0
@@ -378,6 +378,10 @@#define PCI_EXP_RTCTL_CRSSVE 0x10/* CRS Software Visibility Enable */ #define PCI_EXP_RTCAP 30/* Root Capabilities */ #define PCI_EXP_RTSTA 32/* Root Status */ +#define PCI_EXP_DEVCAP2 36/* Device Capabilities 2 */ +#define PCI_EXP_DEVCAP2_ARI 0x20/* Alternative Routing-ID */ +#define PCI_EXP_DEVCTL2 40/* Device Control 2 */ +#define PCI_EXP_DEVCTL2_ARI 0x20/* Alternative Routing-ID */ /* Extended Capabilities (PCI-X 2.0 and Express) */ #define PCI_EXT_CAP_ID (header) (header & 0x0000ffff)
@@ -388,6 +392,7 @@#define PCI_EXT_CAP_ID_VC 2#define PCI_EXT_CAP_ID_DSN 3#define PCI_EXT_CAP_ID_PWR 4 +#define PCI_EXT_CAP_ID_ARI 14/* Advanced Error Reporting */ #define PCI_ERR_UNCOR_STATUS 4/* Uncorrectable Error Status */
@@ -463,4 +468,14 @@#define PCI_PWR_CAP 12/* Capability */ #define PCI_PWR_CAP_BUDGET (x) ((x) & 1)/* Included in system budget */ +/* Alternative Routing-ID Interpretation */ +#define PCI_ARI_CAP 0x04/* ARI Capability Register */ +#define PCI_ARI_CAP_MFVC 0x0001/* MFVC Function Groups Capability */ +#define PCI_ARI_CAP_ACS 0x0002/* ACS Function Groups Capability */ +#define PCI_ARI_CAP_NFN (x) (((x) >> 8) & 0xff)/* Next Function Number */ +#define PCI_ARI_CTRL 0x06/* ARI Control Register */ +#define PCI_ARI_CTRL_MFVC 0x0001/* MFVC Function Groups Enable */ +#define PCI_ARI_CTRL_ACS 0x0002/* ACS Function Groups Enable */ +#define PCI_ARI_CTRL_FG (x) (((x) >> 4) & 7)/* Function Group */ +#endif /* LINUX_PCI_REGS_H */
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909504 14400
# Node ID 16659f5d8bb0d9d4b47cdb4a8c086c89deba793d
# Parent 313310b824c81e803a698ee3a1a8a94075096060
Backport: PCI: fix ARI code to be compatible with mixed ARI/non-ARI systems
commit 8113587c2d14d3be2414190845b2e2617c0aa33b
Author: Zhao, Yu <[email protected]>
Date: Thu Oct 23 13:15:39 2008 +0800
PCI: fix ARI code to be compatible with mixed ARI/non-ARI systems
The original ARI support code has a compatibility problem with non-ARI devices. If a device doesn't support ARI, turning on ARI forwarding on its upper level bridge will cause undefined behavior.
This fix turns on ARI forwarding only when the subordinate devices support it.
drivers/pci/pci.c +15 -10
@@ -638,27 +638,32 @@int pos;u32 cap;u16 ctrl; +struct pci_dev *bridge; -if (!dev->is_pcie) +if (dev->devfn)return ; -if (dev->pcie_type !=PCI_EXP_TYPE_ROOT_PORT && - dev->pcie_type !=PCI_EXP_TYPE_DOWNSTREAM ) -return ; - - pos =pci_find_capability (dev,PCI_CAP_ID_EXP ); + pos =pci_find_ext_capability (dev,PCI_EXT_CAP_ID_ARI );if (!pos)return ; -pci_read_config_dword (dev, pos +PCI_EXP_DEVCAP2 , &cap); + bridge = dev->bus->self; +if (!bridge) +return ; + + pos =pci_find_capability (bridge,PCI_CAP_ID_EXP ); +if (!pos) +return ; + +pci_read_config_dword (bridge, pos +PCI_EXP_DEVCAP2 , &cap);if (!(cap &PCI_EXP_DEVCAP2_ARI ))return ; -pci_read_config_word (dev, pos +PCI_EXP_DEVCTL2 , &ctrl); +pci_read_config_word (bridge, pos +PCI_EXP_DEVCTL2 , &ctrl); ctrl |=PCI_EXP_DEVCTL2_ARI ; -pci_write_config_word (dev, pos +PCI_EXP_DEVCTL2 , ctrl); +pci_write_config_word (bridge, pos +PCI_EXP_DEVCTL2 , ctrl); - dev->ari_enabled =1 ; + bridge->ari_enabled =1 ; }int
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909555 14400
# Node ID fe864af8b34bb03cdfe51dae05e2e3bcce2c5d69 # Parent 16659f5d8bb0d9d4b47cdb4a8c086c89deba793d
Backport: PCI: enhance pci_ari_enabled()
commit 6a49d8120021897e139641062236215aac5d220e
Author: Yu Zhao <[email protected]>
Date: Sat Nov 22 02:38:21 2008 +0800
PCI: enhance pci_ari_enabled()
Change parameter of pci_ari_enabled() from 'pci_dev' to 'pci_bus'.
ARI forwarding on the bridge mostly concerns the subordinate devices rather than the bridge itself. So this change will make the function easier to use.
drivers/pci/pci.h +3 -3
@@ -122,11 +122,11 @@extern void pci_enable_ari (struct pci_dev *dev);/** * pci_ari_enabled - query ARI forwarding status -* @dev: the PCI device +* @bus: the PCI bus * * Returns 1 if ARI forwarding is enabled, or 0 if not enabled; */ -static inline int pci_ari_enabled (struct pci_dev *dev) +static inline int pci_ari_enabled (struct pci_bus *bus) { -return dev->ari_enabled; +return bus->self && bus->self->ari_enabled; }
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909605 14400
# Node ID b9b4e811af229682d7c6a70aabffd5ade5876c91
# Parent fe864af8b34bb03cdfe51dae05e2e3bcce2c5d69
Backport: PCI: allow pci_alloc_child_bus() to handle a NULL bridge
commit 3789fa8a2e534523c896a32a9f27f78d52ad7d82
Author: Yu Zhao <[email protected]>
Date: Sat Nov 22 02:41:07 2008 +0800
PCI: allow pci_alloc_child_bus() to handle a NULL bridge
Allow pci_alloc_child_bus() to allocate buses without bridge devices. Some SR-IOV devices can occupy more than one bus number, but there is no explicit bridges because that have internal routing mechanism.
drivers/pci/probe.c +6 -2
@@ -392,12 +392,10 @@if (!child)return NULL ; - child->self = bridge; child->parent = parent; child->ops = parent->ops; child->sysdata = parent->sysdata; child->bus_flags = parent->bus_flags; - child->bridge =get_device (&bridge->dev); child->class_dev.class = &pcibus_class;sprintf (child->class_dev.class_id,"%04x:%02x" ,pci_domain_nr (child), busnr);
@@ -411,6 +409,12 @@ child->number = child->secondary = busnr; child->primary = parent->secondary; child->subordinate =0xff ; + +if (!bridge) +return child; + + child->self = bridge; + child->bridge =get_device (&bridge->dev);/* Set up default resource pointers and names.. */ for (i =0 ; i <4 ; i++) {
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236909787 14400
# Node ID c0e566166776cb7e096ee182bde557554fa4167e
# Parent b9b4e811af229682d7c6a70aabffd5ade5876c91
Backport: PCI: remove unnecessary arg of pci_update_resource()
commit 14add80b5120966fe0659d61815b9e9b4b68fdc5
Author: Yu Zhao <[email protected]>
Date: Sat Nov 22 02:38:52 2008 +0800
PCI: remove unnecessary arg of pci_update_resource()
This cleanup removes unnecessary argument 'struct resource *res' in pci_update_resource(), so it takes same arguments as other companion functions (pci_assign_resource(), etc.).
drivers/pci/pci.c +2 -2
@@ -273,8 +273,8 @@return ; } -for (i =0 ; i < numres; i ++) -pci_update_resource (dev, &dev->resource[i], i); +for (i =0 ; i < numres; i++) +pci_update_resource (dev, &dev->resource[i]); }int (*platform_pci_set_power_state)(struct pci_dev *dev,pci_power_t t);
drivers/pci/quirks.c +1 -1
@@ -56,7 +56,7 @@ r->start =0 ;if (i <PCI_BRIDGE_RESOURCES ) { -pci_update_resource (dev, r, i); +pci_update_resource (dev, i); } }/* need to disable bridge's resource window,
drivers/pci/setup-res.c +4 -3
@@ -27,11 +27,12 @@void -pci_update_resource (struct pci_dev *dev,struct resource *res,int resno) +pci_update_resource (struct pci_dev *dev,int resno) {struct pci_bus_region region;u32 new, check, mask;int reg; +struct resource *res = dev->resource + resno;/* Ignore resources for unimplemented BARs and unused resource slots for 64 bit BARs. */
@@ -183,7 +184,7 @@"%016llx - %016llx\n" , resno,pci_name (dev), (unsigned long long )res->start, (unsigned long long)res->end); -pci_update_resource (dev, res, resno); +pci_update_resource (dev, resno); }return ret;
@@ -221,7 +222,7 @@ resno, (unsigned long long )(res->end - res->start +1 ), (unsigned long long)res->start, pci_name(dev)); }else if (resno <PCI_BRIDGE_RESOURCES ) { -pci_update_resource (dev, res, resno); +pci_update_resource (dev, resno); }return ret;
include/linux/pci.h +1 -1
@@ -500,7 +500,7 @@void pci_intx (struct pci_dev *dev,int enable);int pci_set_dma_mask (struct pci_dev *dev,u64 mask);int pci_set_consistent_dma_mask (struct pci_dev *dev,u64 mask); -void pci_update_resource (struct pci_dev *dev,struct resource *res,int resno); +void pci_update_resource (struct pci_dev *dev,int resno);int pci_assign_resource (struct pci_dev *dev,int i);int pci_assign_resource_fixed (struct pci_dev *dev,int i);void pci_restore_bars (struct pci_dev *dev);
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236910004 14400
# Node ID ee3f8ec76f20de0e818621c8f86122427532bc3d # Parent c0e566166776cb7e096ee182bde557554fa4167e
Backport: PCI: define PCI resource names in an 'enum'
commit fde09c6d8f92de0c9f75698a75f0989f2234c517
Author: Yu Zhao <[email protected]>
Date: Sat Nov 22 02:39:32 2008 +0800
PCI: define PCI resource names in an 'enum'
This patch moves all definitions of the PCI resource names to an 'enum', and also replaces some hard-coded resource variables with symbol names. This change eases introduction of device specific resources.
drivers/pci/pci-sysfs.c +3 -1
@@ -85,11 +85,13 @@struct pci_dev * pci_dev =to_pci_dev (dev);char * str = buf;int i; -int max =7 ; +int max;resource_size_t start, end;if (pci_dev->subordinate) max =DEVICE_COUNT_RESOURCE ; +else + max =PCI_BRIDGE_RESOURCES ;for (i =0 ; i < max; i++) {struct resource *res = &pci_dev->resource[i];
drivers/pci/probe.c +1 -1
@@ -417,7 +417,7 @@ child->bridge =get_device (&bridge->dev);/* Set up default resource pointers and names.. */ -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <PCI_BRIDGE_RESOURCE_NUM ; i++) { child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES +i]; child->resource[i]->name = child->name; }
drivers/pci/proc.c +4 -3
@@ -348,15 +348,16 @@ dev->vendor, dev->device, dev->irq); -/* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */ -for (i=0 ; i<7 ; i++) { + +/* only print standard and ROM resources to preserve compatibility */ +for (i =0 ; i <=PCI_ROM_RESOURCE ; i++) {resource_size_t start, end;pci_resource_to_user (dev, i, &dev->resource[i], &start, &end);seq_printf (m,"\t%16llx" , (unsigned long long )(start | (dev->resource[i].flags &PCI_REGION_FLAG_MASK ))); } -for (i=0 ; i<7 ; i++) { +for (i =0 ; i <=PCI_ROM_RESOURCE ; i++) {resource_size_t start, end;pci_resource_to_user (dev, i, &dev->resource[i], &start, &end); seq_printf(m, "\t%16llx",
include/linux/pci.h +24 -13
@@ -65,8 +65,31 @@#define PCI_DMA_NONE 3#define DEVICE_COUNT_COMPATIBLE 4 -#define DEVICE_COUNT_RESOURCE 12 +/* +* For PCI devices, the region numbers are assigned this way: +*/ +enum { +/* #0-5: standard PCI resources */ +PCI_STD_RESOURCES , +PCI_STD_RESOURCE_END =5 , + +/* #6: expansion ROM resource */ +PCI_ROM_RESOURCE , + +/* resources assigned to buses behind the bridge */ +#define PCI_BRIDGE_RESOURCE_NUM 4 + +PCI_BRIDGE_RESOURCES , +PCI_BRIDGE_RESOURCE_END =PCI_BRIDGE_RESOURCES + +PCI_BRIDGE_RESOURCE_NUM -1 , + +/* total resources associated with a PCI device */ +PCI_NUM_RESOURCES , + +/* preserve this for compatibility */ +DEVICE_COUNT_RESOURCE +};typedef int __bitwise pci_power_t ;#define PCI_D0 ((pci_power_t __force) 0)
@@ -203,18 +226,6 @@ {hlist_del (&cap->next); } - -/* -* For PCI devices, the region numbers are assigned this way: -* -* 0-5 standard PCI regions -* 6 expansion ROM -* 7-10 bridges: address space assigned to buses behind the bridge -*/ - -#define PCI_ROM_RESOURCE 6 -#define PCI_BRIDGE_RESOURCES 7 -#define PCI_NUM_RESOURCES 11#ifndef PCI_BUS_NUM_RESOURCES #define PCI_BUS_NUM_RESOURCES 8
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236910104 14400
# Node ID 4bc56b3855d6449abcf402f3be106102ecd667de
# Parent ee3f8ec76f20de0e818621c8f86122427532bc3d
Backport: PCI: remove unnecessary condition check in pci_restore_bars()
commit bc5f5a8277cb353161454b6704b3186ebcf3a2a3
Author: Yu Zhao <[email protected]>
Date: Sat Nov 22 02:40:00 2008 +0800
PCI: remove unnecessary condition check in pci_restore_bars()
Remove the unnecessary number of resources condition checks because the pci_update_resource() will check availability of the resources.
drivers/pci/pci.c +3 -18
@@ -256,25 +256,10 @@void pci_restore_bars (struct pci_dev *dev) { -int i, numres; +int i; -switch (dev->hdr_type) { -case PCI_HEADER_TYPE_NORMAL : - numres =6 ; -break ; -case PCI_HEADER_TYPE_BRIDGE : - numres =2 ; -break ; -case PCI_HEADER_TYPE_CARDBUS : - numres =1 ; -break ; -default : -/* Should never get here, but just in case... */ -return ; - } - -for (i =0 ; i < numres; i++) -pci_update_resource (dev, &dev->resource[i]); +for (i =0 ; i <PCI_BRIDGE_RESOURCES ; i++) +pci_update_resource (dev, i); }int (*platform_pci_set_power_state)(struct pci_dev *dev,pci_power_t t);
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1236910170 14400
# Node ID ebec1feb35c3a3efe319853a31acee72924453f3 # Parent 4bc56b3855d6449abcf402f3be106102ecd667de
Backport: PCI: add a new function to map BAR offsets
commit 613e7ed6f72b1a115f7ece8ce1b66cf095de1348
Author: Yu Zhao <[email protected]>
Date: Sat Nov 22 02:41:27 2008 +0800
PCI: add a new function to map BAR offsets
Add a function to map a given resource number to a corresponding register so drivers can get the offset and type of device specific BARs.
drivers/pci/pci.c +22 -0
@@ -949,6 +949,28 @@ }#endif +/** +* pci_resource_bar - get position of the BAR associated with a resource +* @dev: the PCI device +* @resno: the resource number +* @type: the BAR type to be filled in +* +* Returns BAR position in config space, or 0 if the BAR is invalid. +*/ +int pci_resource_bar (struct pci_dev *dev,int resno,enum pci_bar_type *type) +{ +if (resno <PCI_ROM_RESOURCE ) { + *type = pci_bar_unknown; +return PCI_BASE_ADDRESS_0 +4 * resno; + }else if (resno ==PCI_ROM_RESOURCE ) { + *type = pci_bar_mem32; +return dev->rom_base_reg; + } + +dev_err (&dev->dev,"BAR: invalid resource #%d\n" , resno); +return 0 ; +} +static int __devinit pci_init (void ) {struct pci_dev *dev =NULL ;
drivers/pci/pci.h +2 -0
@@ -119,6 +119,8 @@extern int __pci_read_base (struct pci_dev *dev,enum pci_bar_type type,struct resource *res,unsigned int reg); +extern int pci_resource_bar (struct pci_dev *dev,int resno, +enum pci_bar_type *type);extern void pci_enable_ari (struct pci_dev *dev);/** * pci_ari_enabled - query ARI forwarding status
drivers/pci/setup-res.c +5 -8
@@ -32,6 +32,7 @@struct pci_bus_region region;u32 new, check, mask;int reg; +enum pci_bar_type type;struct resource *res = dev->resource + resno;/* Ignore resources for unimplemented BARs and unused resource slots
@@ -52,17 +53,13 @@else mask = (u32 )PCI_BASE_ADDRESS_MEM_MASK ; -if (resno <6 ) { - reg =PCI_BASE_ADDRESS_0 +4 * resno; - }else if (resno ==PCI_ROM_RESOURCE ) { + reg =pci_resource_bar (dev, resno, &type); +if (!reg) +return ; +if (type != pci_bar_unknown) {if (!(res->flags &IORESOURCE_ROM_ENABLE ))return ; new |=PCI_ROM_ADDRESS_ENABLE ; - reg = dev->rom_base_reg; - }else { -/* Hmm, non-standard resource. */ - -return ;/* kill uninitialised var warning */ }pci_write_config_dword (dev, reg, new);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Xen SR-IOV core patches
Greetings,
The latest SR-IOV core patches for the native Linux kernel are backported to Xen/Dom0. I planed to do it after they are applied on the native kernel tree, however, Xen 3.4 is going to freeze. I had to ask Keir to take the SR-IOV patches for 3.4 so it wouldn't disappoint a lot of people who are expecting the SR-IOV support in 3.4 release. Since the SR-IOV patches for the native kernel have been reviewed by some key kernel developers during a long development time cycle, the SR-IOV Physical Function driver API is stable and will not cost any extra porting effort for people who want to develop the Physical Function driver for both Xen/Dom0 and native Linux.
The SR-IOV core patches backported to Xen/Dom0 are:
PCI: initialize and release SR-IOV capability (hg c/s: 822)
PCI: restore saved SR-IOV state (hg c/s: 823)
PCI: reserve bus range for SR-IOV device (hg c/s: 824)
PCI: centralize device setup code (hg c/s: 825)
PCI: add SR-IOV API for Physical Function driver (hg c/s: 826)
Following patches are not backported:
PCI: handle SR-IOV Virtual Function Migration
* This is for using the SR-IOV in conjunction with the MR-IOV. It won't be needed until the MR-IOV is fully supported.
PCI: document SR-IOV sysfs entries
* The sysfs ABI document, which has a gap between the upstream and the Dom0 kernels. So please use the latest upstream kernel ABI document instead before Dom0 switches to the pv_ops kernel.
PCI: manual for SR-IOV user and driver developer
* The PCI subsystem document, same as above.
drivers/pci/Kconfig | 9 drivers/pci/Makefile | 2 drivers/pci/iov.c | 537 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 9 drivers/pci/pci.h | 49 ++++ drivers/pci/probe.c | 49 ++-- include/linux/pci.h | 33 ++ include/linux/pci_regs.h | 33 ++ 8 files changed, 699 insertions(+), 22 deletions(-)
PCIe 2.0, VT-d and Intel 82576 enhancement for Xen SR-IOV
In reply to Yu ZhaoGreetings,
Following patches enhance the VT-d and PCI code, and add a quirk for Intel 82576 SR-IOV NIC, so they can work better with the SR-IOV core.
PCI: pass ARI and SR-IOV device information to the hypervisor
PCI: add a SR-IOV quirk for Intel 82576 NIC
PCI: save and restore PCIe 2.0 registers
drivers/pci/pci.c | 11 +++++++ drivers/pci/quirks.c | 57 ++++++++++++++++++++++++++++++++++++++++ drivers/xen/core/pci.c | 27 ++++++++++++++++-- include/linux/pci_regs.h | 2 + include/xen/interface/physdev.h | 16 +++++++++++ 5 files changed, 109 insertions(+), 4 deletions(-)
Xen: use proper device ID to search VT-d unit for ARI and SR-IOV device
arch/ia64/xen/hypercall.c | 22 +++++++++++++++++++ arch/x86/physdev.c | 22 +++++++++++++++++++ drivers/passthrough/pci.c | 41 +++++++++++++++++++++++++++++++++++++ drivers/passthrough/vtd/dmar.c | 14 +++++++++++- drivers/passthrough/vtd/dmar.h | 2 - drivers/passthrough/vtd/intremap.c | 4 +-- drivers/passthrough/vtd/iommu.c | 14 +++++++++--- include/public/physdev.h | 16 ++++++++++++++ include/xen/pci.h | 11 +++++++++ 9 files changed, 138 insertions(+), 8 deletions(-)
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1237441331 14400
# Node ID a5d36fbbdea4c1fa0b925689834cf6775066f6f1 # Parent 4839e34e67952b540fa258811324a85ace7feb79
PCI: pass ARI and SR-IOV device information to the hypervisor
PCIe Alternative Routing-ID Interpretation (ARI) ECN defines the Extended Function -- a function whose function number is greater than 7 within an ARI Device. Intel VT-d spec 1.2 section 8.3.2 specifies that the Extended Function is under the scope of the same remapping unit as the traditional function. The hypervisor needs to know if a function is Extended Function so it can find proper DMAR for it.
And section 8.3.3 specifies that the SR-IOV Virtual Function is under the scope of the same remapping unit as the Physical Function. The hypervisor also needs to know if a function is the Virtual Function and which Physical Function it's associated with for same reason.
drivers/xen/core/pci.c +24 -3
@@ -6,6 +6,7 @@#include <linux/init.h> #include <linux/pci.h> #include <xen/interface/physdev.h> +#include "../../pci/pci.h" static int (*pci_bus_probe)(struct device *dev);static int (*pci_bus_remove)(struct device *dev);
@@ -15,10 +16,30 @@int r;struct pci_dev *pci_dev =to_pci_dev (dev);struct physdev_manage_pci manage_pci; - manage_pci.bus = pci_dev->bus->number; - manage_pci.devfn = pci_dev->devfn; +struct physdev_manage_pci_ext manage_pci_ext; - r =HYPERVISOR_physdev_op (PHYSDEVOP_manage_pci_add, &manage_pci); +if (pci_dev->is_virtfn) { +memset (&manage_pci_ext,0 ,sizeof (manage_pci_ext)); + manage_pci_ext.bus = pci_dev->bus->number; + manage_pci_ext.devfn = pci_dev->devfn; + manage_pci_ext.is_virtfn =1 ; + manage_pci_ext.physfn.bus = pci_dev->physfn->bus->number; + manage_pci_ext.physfn.devfn = pci_dev->physfn->devfn; + r =HYPERVISOR_physdev_op (PHYSDEVOP_manage_pci_add_ext, + &manage_pci_ext); + }else if (pci_ari_enabled (pci_dev->bus) &&PCI_SLOT (pci_dev->devfn)) { +memset (&manage_pci_ext,0 ,sizeof (manage_pci_ext)); + manage_pci_ext.bus = pci_dev->bus->number; + manage_pci_ext.devfn = pci_dev->devfn; + manage_pci_ext.is_extfn =1 ; + r =HYPERVISOR_physdev_op (PHYSDEVOP_manage_pci_add_ext, + &manage_pci_ext); + }else { + manage_pci.bus = pci_dev->bus->number; + manage_pci.devfn = pci_dev->devfn; + r =HYPERVISOR_physdev_op (PHYSDEVOP_manage_pci_add, + &manage_pci); + }if (r && r != -ENOSYS )return r;
include/xen/interface/physdev.h +16 -0
@@ -192,6 +192,22 @@typedef struct physdev_restore_msi physdev_restore_msi_t ;DEFINE_XEN_GUEST_HANDLE (physdev_restore_msi_t); +#define PHYSDEVOP_manage_pci_add_ext 20 +struct physdev_manage_pci_ext { +/* IN */ +uint8_t bus; +uint8_t devfn; +unsigned is_extfn; +unsigned is_virtfn; +struct { +uint8_t bus; +uint8_t devfn; + } physfn; +}; + +typedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t ; +DEFINE_XEN_GUEST_HANDLE (physdev_manage_pci_ext_t); +/* * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() * hypercall since 0x00030202.
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1237442468 14400
# Node ID 2bd960a6fe028119867357f0d99f3388d7a14047 # Parent a5d36fbbdea4c1fa0b925689834cf6775066f6f1
PCI: save and restore PCIe 2.0 registers
PCIe 2.0 defines several new registers (Device Control 2, Link Control 2, and Slot Control 2). Save and retore them in pci_save_pcie_state() and pci_restore_pcie_state().
drivers/pci/pci.c +10 -1
@@ -428,6 +428,8 @@EXPORT_SYMBOL (pci_choose_state); +#define PCI_EXP_SAVE_REGS 7 +static int pci_save_pcie_state (struct pci_dev *dev) {int pos, i =0 ;
@@ -449,6 +451,9 @@pci_read_config_word (dev, pos +PCI_EXP_LNKCTL , &cap[i++]);pci_read_config_word (dev, pos +PCI_EXP_SLTCTL , &cap[i++]);pci_read_config_word (dev, pos +PCI_EXP_RTCTL , &cap[i++]); +pci_read_config_word (dev, pos +PCI_EXP_DEVCTL2 , &cap[i++]); +pci_read_config_word (dev, pos +PCI_EXP_LNKCTL2 , &cap[i++]); +pci_read_config_word (dev, pos +PCI_EXP_SLTCTL2 , &cap[i++]);return 0 ; }
@@ -469,6 +474,9 @@pci_write_config_word (dev, pos +PCI_EXP_LNKCTL , cap[i++]);pci_write_config_word (dev, pos +PCI_EXP_SLTCTL , cap[i++]);pci_write_config_word (dev, pos +PCI_EXP_RTCTL , cap[i++]); +pci_write_config_word (dev, pos +PCI_EXP_DEVCTL2 , cap[i++]); +pci_write_config_word (dev, pos +PCI_EXP_LNKCTL2 , cap[i++]); +pci_write_config_word (dev, pos +PCI_EXP_SLTCTL2 , cap[i++]); }
@@ -739,7 +747,8 @@ {int error; - error =pci_add_cap_save_buffer (dev,PCI_CAP_ID_EXP ,4 *sizeof (u16)); + error =pci_add_cap_save_buffer (dev,PCI_CAP_ID_EXP , +PCI_EXP_SAVE_REGS *sizeof (u16));if (error)dev_err (&dev->dev,"unable to preallocate PCI Express save buffer\n" );
include/linux/pci_regs.h +2 -0
@@ -383,6 +383,8 @@#define PCI_EXP_DEVCAP2_ARI 0x20/* Alternative Routing-ID */ #define PCI_EXP_DEVCTL2 40/* Device Control 2 */ #define PCI_EXP_DEVCTL2_ARI 0x20/* Alternative Routing-ID */ +#define PCI_EXP_LNKCTL2 48/* Link Control 2 */ +#define PCI_EXP_SLTCTL2 56/* Slot Control 2 */ /* Extended Capabilities (PCI-X 2.0 and Express) */ #define PCI_EXT_CAP_ID (header) (header & 0x0000ffff)
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1237445637 14400
# Node ID cdfa79a9463c46ac99b4ce543c86951cfbc40c43 # Parent 2bd960a6fe028119867357f0d99f3388d7a14047
PCI: add a SR-IOV quirk for Intel 82576 NIC
If BIOS doesn't allocate resources for VF BARs, zero Flash BAR and program VF BARs to use the old Flash Memory Space.
Please refer to Intel 82576 Gigabit Ethernet Controller Datasheet section 7.9.2.14.2 for details.
http://download.intel.com/design/network/datashts/82576_Datasheet.pdf
drivers/pci/quirks.c +57 -0
60 lines not on this page · raw message
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1237441166 14400
# Node ID 1e79dfa07877236ce5abcc61b916c8b5a67cb2c3
# Parent 2039e82710512f2b4b45f83cf4cdb3b037bf0d7c
Xen: use proper device ID to search VT-d unit for ARI and SR-IOV device
PCIe Alternative Routing-ID Interpretation (ARI) ECN defines the Extended Function -- a function whose function number is greater than 7 within an ARI Device. Intel VT-d spec 1.2 section 8.3.2 specifies that the Extended Function is under the scope of the same remapping unit as the traditional function. The hypervisor needs to know if a function is Extended Function so it can find proper DMAR for it.
And section 8.3.3 specifies that the SR-IOV Virtual Function is under the scope of the same remapping unit as the Physical Function. The hypervisor also needs to know if a function is the Virtual Function and which Physical Function it's associated with for same reason.
xen/arch/ia64/xen/hypercall.c +22 -0
@@ -674,6 +674,28 @@break ; } +case PHYSDEVOP_manage_pci_add_ext: { +struct physdev_manage_pci_ext manage_pci_ext; +struct pci_dev_info pdev_info; + + ret = -EPERM ; +if ( !IS_PRIV (current->domain) ) +break ; + + ret = -EFAULT ; +if (copy_from_guest (&manage_pci_ext, arg,1 ) !=0 ) +break ; + + pdev_info.is_extfn = manage_pci_ext.is_extfn; + pdev_info.is_virtfn = manage_pci_ext.is_virtfn; + pdev_info.physfn.bus = manage_pci_ext.physfn.bus; + pdev_info.physfn.devfn = manage_pci_ext.physfn.devfn; + ret =pci_add_device_ext (manage_pci_ext.bus, + manage_pci_ext.devfn, + &pdev_info); +break ; + } +default : ret = -ENOSYS ;printk ("not implemented do_physdev_op: %d\n" , cmd);
xen/arch/x86/physdev.c +22 -0
@@ -421,6 +421,28 @@break ; } +case PHYSDEVOP_manage_pci_add_ext: { +struct physdev_manage_pci_ext manage_pci_ext; +struct pci_dev_info pdev_info; + + ret = -EPERM ; +if ( !IS_PRIV (current->domain) ) +break ; + + ret = -EFAULT ; +if (copy_from_guest (&manage_pci_ext, arg,1 ) !=0 ) +break ; + + pdev_info.is_extfn = manage_pci_ext.is_extfn; + pdev_info.is_virtfn = manage_pci_ext.is_virtfn; + pdev_info.physfn.bus = manage_pci_ext.physfn.bus; + pdev_info.physfn.devfn = manage_pci_ext.physfn.devfn; + ret =pci_add_device_ext (manage_pci_ext.bus, + manage_pci_ext.devfn, + &pdev_info); +break ; + } +case PHYSDEVOP_restore_msi: {struct physdev_restore_msi restore_msi;struct pci_dev *pdev;
xen/drivers/passthrough/pci.c +41 -0
47 lines not on this page · raw message
xen/drivers/passthrough/vtd/dmar.c +13 -1
@@ -152,11 +152,23 @@return 0 ; } -struct acpi_drhd_unit *acpi_find_matched_drhd_unit (u8 bus,u8 devfn) +struct acpi_drhd_unit *acpi_find_matched_drhd_unit (struct pci_dev *pdev) { +u8 bus, devfn;struct acpi_drhd_unit *drhd;struct acpi_drhd_unit *found =NULL , *include_all =NULL ;int i; + +if (pdev->info.is_extfn) { + bus = pdev->bus; + devfn =0 ; + }else if (pdev->info.is_virtfn) { + bus = pdev->info.physfn.bus; + devfn =PCI_SLOT (pdev->info.physfn.devfn) ?0 : pdev->info.physfn.devfn; + }else { + bus = pdev->bus; + devfn = pdev->devfn; + } list_for_each_entry ( drhd, &acpi_drhd_units, list ) {
xen/drivers/passthrough/vtd/dmar.h +1 -1
@@ -79,7 +79,7 @@for (idx =0 ; (bdf = rmrr->scope.devices[idx]) && \ idx < rmrr->scope.devices_cnt; idx++) -struct acpi_drhd_unit * acpi_find_matched_drhd_unit(u8 bus, u8 devfn); +struct acpi_drhd_unit * acpi_find_matched_drhd_unit(struct pci_dev *pdev);struct acpi_atsr_unit *acpi_find_matched_atsr_unit (u8 bus,u8 devfn);void dmar_scope_add_buses (struct dmar_scope *scope,u16 sec,u16 sub);void dmar_scope_remove_buses (struct dmar_scope *scope,u16 sec,u16 sub);
xen/drivers/passthrough/vtd/intremap.c +2 -2
@@ -450,7 +450,7 @@struct iommu *iommu =NULL ;struct ir_ctrl *ir_ctrl; - drhd =acpi_find_matched_drhd_unit (pdev->bus, pdev->devfn); + drhd =acpi_find_matched_drhd_unit (pdev); iommu = drhd->iommu; ir_ctrl =iommu_ir_ctrl (iommu);
@@ -468,7 +468,7 @@struct iommu *iommu =NULL ;struct ir_ctrl *ir_ctrl; - drhd =acpi_find_matched_drhd_unit (pdev->bus, pdev->devfn); + drhd =acpi_find_matched_drhd_unit (pdev); iommu = drhd->iommu; ir_ctrl =iommu_ir_ctrl (iommu);
xen/drivers/passthrough/vtd/iommu.c +10 -4
@@ -1193,8 +1193,11 @@u16 sec_bus, sub_bus;u32 type;u8 secbus, secdevfn; +struct pci_dev *pdev =pci_get_pdev (bus, devfn); - drhd =acpi_find_matched_drhd_unit (bus, devfn); +BUG_ON (!pdev); + + drhd =acpi_find_matched_drhd_unit (pdev);if ( !drhd )return -ENODEV ;
@@ -1319,8 +1322,11 @@int ret =0 ;u32 type;u8 secbus, secdevfn; +struct pci_dev *pdev =pci_get_pdev (bus, devfn); - drhd =acpi_find_matched_drhd_unit (bus, devfn); +BUG_ON (!pdev); + + drhd =acpi_find_matched_drhd_unit (pdev);if ( !drhd )return -ENODEV ;
@@ -1392,7 +1398,7 @@if (!pdev)return -ENODEV ; - drhd =acpi_find_matched_drhd_unit (bus, devfn); + drhd =acpi_find_matched_drhd_unit (pdev); pdev_iommu = drhd->iommu;domain_context_unmap (source, bus, devfn);
@@ -1405,7 +1411,7 @@ for_each_pdev ( source, pdev ) { - drhd =acpi_find_matched_drhd_unit (pdev->bus, pdev->devfn); + drhd =acpi_find_matched_drhd_unit (pdev);if ( drhd->iommu == pdev_iommu ) { found =1 ;
xen/include/public/physdev.h +16 -0
@@ -183,6 +183,22 @@typedef struct physdev_manage_pci physdev_manage_pci_t ;DEFINE_XEN_GUEST_HANDLE (physdev_manage_pci_t); +#define PHYSDEVOP_manage_pci_add_ext 20 +struct physdev_manage_pci_ext { +/* IN */ +uint8_t bus; +uint8_t devfn; +unsigned is_extfn; +unsigned is_virtfn; +struct { +uint8_t bus; +uint8_t devfn; + } physfn; +}; + +typedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t ; +DEFINE_XEN_GUEST_HANDLE (physdev_manage_pci_ext_t); +#define PHYSDEVOP_restore_msi 19struct physdev_restore_msi {/* IN */
xen/include/xen/pci.h +11 -0
@@ -31,6 +31,15 @@#define MAX_MSIX_TABLE_ENTRIES 2048#define MAX_MSIX_TABLE_PAGES 8 +struct pci_dev_info { +unsigned is_extfn; +unsigned is_virtfn; +struct { +u8 bus; +u8 devfn; + } physfn; +}; +struct pci_dev {struct list_head alldevs_list;struct list_head domain_list;
@@ -43,6 +52,7 @@struct domain *domain;const u8 bus;const u8 devfn; +struct pci_dev_info info; };#define for_each_pdev (domain, pdev) \
@@ -64,6 +74,7 @@void pci_release_devices (struct domain *d);int pci_add_device (u8 bus,u8 devfn);int pci_remove_device (u8 bus,u8 devfn); +int pci_add_device_ext (u8 bus,u8 devfn,struct pci_dev_info *info);struct pci_dev *pci_get_pdev (int bus,int devfn);struct pci_dev *pci_get_pdev_by_domain (struct domain *d,int bus,int devfn);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Xen doc for VT-d/SR-IOV
In reply to Yu ZhaoHow-to for using the SR-IOV device with VT-d.
# HG changeset patch
# User Yu Zhao <[email protected]>
# Date 1237455233 14400
# Node ID ca4f6ffcde880d3f1e187cfd99fd427b334e325f # Parent 1e79dfa07877236ce5abcc61b916c8b5a67cb2c3
Xen: documentation for VT-d/SR-IOV
Add a section about how to use the SR-IOV device with VT-d.
docs/misc/vtd.txt +91 -1
@@ -26,7 +26,18 @@ module /boot/vmlinuz-2.6.18.8-xen root=LABEL=/ ro xencons=ttyS console=tty0 console=ttyS0, pciback.hide=(01:00.0)(03:00.0) module /boot/initrd-2.6.18-xen.img -12) reboot system + or use dynamic hiding via PCI backend sysfs interface: + a) check if the driver has binded to the device + ls -l /sys/bus/pci/devices/0000:01:00.0/driver + ... /sys/bus/pci/devices/0000:01:00.0/driver -> ../../../../bus/pci/drivers/igb + b) if yes, then unload the driver first + echo -n 0000:01:00.0 >/sys/bus/pci/drivers/igb/unbind + c) add the device to the PCI backend + echo -n 0000:01:00.0 >/sys/bus/pci/drivers/pciback/new_slot + d) let the PCI backend bind to the device + echo -n 0000:01:00.0 >/sys/bus/pci/drivers/pciback/bind + +12) reboot system (not requires if you use the dynamic hiding method) 13) add "pci" line in /etc/xen/hvm.conf for to assigned devices pci = [ '01:00.0', '03:00.0' ] 15) start hvm guest and use "lspci" to see the passthru device and
@@ -160,3 +171,82 @@ buffer specified by driver. Such devices assigned to HVM domain currently do not work. + + +Using SR-IOV with VT-d +-------------------------------- + +The Single Root I/O Virtualization is a PCI Express feature supported by +some devices such as Intel 82576 which allows you to create virtual PCI +devices (Virtual Function) and assign them to the HVM guest. + +You can use latest lspci (v3.1 and above) to check if your PCIe device +supports the SR-IOV capability or not. + + $ lspci -s 01:00.0 -vvv + + 01:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) + Subsystem: Intel Corporation Gigabit ET Dual Port Server Adapter + + ... + + Capabilities: [160] Single Root I/O Virtualization (SR-IOV) + IOVCap: Migration-, Interrupt Message Number: 000 + IOVCtl: Enable+ Migration- Interrupt- MSE+ ARIHierarchy+ + IOVSta: Migration- + Initial VFs: 8, Total VFs: 8, Number of VFs: 7, Function Dependency Link: 00 + VF offset: 128, stride: 2, Device ID: 10ca + Supported Page Size: 00000553, System Page Size: 00000001 + VF Migration: offset: 00000000, BIR: 0 + Kernel driver in use: igb + + +The function that has the SR-IOV capability is also known as Physical +Function. You need the Physical Function driver (runs in the Dom0 and +controls the physical resources allocation) to enable the Virtual Function. +Following is the Virtual Functions associated with above Physical Function. + + $ lspci | grep -e 01:1[01].[0246] + + 01:10.0 Ethernet controller: Intel Corporation Device 10ca (rev 01) + 01:10.2 Ethernet controller: Intel Corporation Device 10ca (rev 01) + 01:10.4 Ethernet controller: Intel Corporation Device 10ca (rev 01) + 01:10.6 Ethernet controller: Intel Corporation Device 10ca (rev 01) + 01:11.0 Ethernet controller: Intel Corporation Device 10ca (rev 01) + 01:11.2 Ethernet controller: Intel Corporation Device 10ca (rev 01) + 01:11.4 Ethernet controller: Intel Corporation Device 10ca (rev 01) + +We can tell that Physical Function 01:00.0 has 7 Virtual Functions (01:10.0, +01:10.2, 01:10.4, 01:10.6, 01:11.0, 01:11.2, 01:11.4). And the Virtual +Function PCI Configuration Space looks just like normal PCI device. + + $ lspci -s 01:10.0 -vvv + + 01:10.0 Ethernet controller: Intel Corporation 82576 Gigabit Virtual Function + Subsystem: Intel Corporation Gigabit Virtual Function + Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- + Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- + Region 0: [virtual] Memory at d2840000 (64-bit, non-prefetchable) [size=16K] + Region 3: [virtual] Memory at d2860000 (64-bit, non-prefetchable) [size=16K] + Capabilities: [70] MSI-X: Enable+ Mask- TabSize=3 + Vector table: BAR=3 offset=00000000 + PBA: BAR=3 offset=00002000 + Capabilities: [a0] Express (v2) Endpoint, MSI 00 + + ... + + +The Virtual Function only appears after the Physical Function driver +is loaded. Once the Physical Function driver is unloaded. All Virtual +Functions associated with this Physical Function disappear. + +The Virtual Function is essentially same as the normal PCI device when +using it in VT-d environment. You need to hide the Virtual Function, +use the Virtual Function bus, device and function number in the HVM +guest configuration file and then boot the HVM guest. You also need the +Virtual Function driver which is the normal PCI device driver in the +HMV guest to drive the Virtual Function. The PCIe SR-IOV specification +requires that the Virtual Function can only support MSI/MSI-x if it +uses interrupt. This means you also need to enable Xen/MSI support. +Since the Virtual Function is dynamically allocated by Physical Function +driver, you might want to use the dynamic hiding method mentioned above.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: PCIe 2.0, VT-d and Intel 82576 enhancement for Xen SR-IOV
In reply to Yu ZhaoWhy put all this logic into Xen itself? Finding the matching DRHD unit will often "just work" anyway by the way the DHRD scope matching is performed.
That said, yes, I get it that it might sometimes be better to actually map the VFs and ARI functions back to the PF before matching. However, why not extend the current device_add function and hypercall with a master BDF pointing back to the BDF "owning" the function? This leaves all of the matching up logic out of the hypervisor. A zero or -1 master BDF could indicate that there is no owner (i.e., it owns itself).
eSk
[Yu Zhao]
Quoted 11 lines
PCIe Alternative Routing-ID Interpretation (ARI) ECN defines the Extended Function -- a function whose function number is greater than 7 within an ARI Device. Intel VT-d spec 1.2 section 8.3.2 specifies that the Extended Function is under the scope of the same remapping unit as the traditional function. The hypervisor needs to know if a function is Extended Function so it can find proper DMAR for it.
And section 8.3.3 specifies that the SR-IOV Virtual Function is under the scope of the same remapping unit as the Physical Function. The hypervisor also needs to know if a function is the Virtual Function and which Physical Function it's associated with for same reason.
Re: PCIe 2.0, VT-d and Intel 82576 enhancement for Xen SR-IOV
Yes, using the master BDF can move current logic into Dom0 and makes hypervisor cleaner. And it does work for VT-d spec 1.2.
But if VT-d spec 1.3 (or AMD/IBM/Sun IOMMU specs) says that the ARI device and the Virtual Function have their own remapping unit or something like this, rather than use their masters', how could we support it using the master BDF? Things evolve fast, we would need to add another hypercall to enhance the master BDF one after it's in 3.4 -- it would be like when the device_add was added, the VT-d spec didn't have such requirement, but now we have to add device_add_ext because the compatibility requirement.
Passing these device specific information down and doing the IOMMU specific work inside the hypervisor hereditarily come with current passthrough architecture. After choosing putting all IOMMU things (both high level remapping data structures and logics, and low level hardware drivers) into hypervisor, we lost the flexibility to split the matching up logic and move it back to the Dom0 kernel.
Thanks,
Yu
Quoted 28 lines · Espen Skoglund
Why put all this logic into Xen itself? Finding the matching DRHD unit will often "just work" anyway by the way the DHRD scope matching is performed.
That said, yes, I get it that it might sometimes be better to actually map the VFs and ARI functions back to the PF before matching. However, why not extend the current
device_addfunction and hypercall with a master BDF pointing back to the BDF "owning" the function? This leaves all of the matching up logic out of the hypervisor. A zero or -1 master BDF could indicate that there is no owner (i.e., it owns itself).eSk
[Yu Zhao]
Quoted 11 lines
PCIe Alternative Routing-ID Interpretation (ARI) ECN defines the Extended Function -- a function whose function number is greater than 7 within an ARI Device. Intel VT-d spec 1.2 section 8.3.2 specifies that the Extended Function is under the scope of the same remapping unit as the traditional function. The hypervisor needs to know if a function is Extended Function so it can find proper DMAR for it.
And section 8.3.3 specifies that the SR-IOV Virtual Function is under the scope of the same remapping unit as the Physical Function. The hypervisor also needs to know if a function is the Virtual Function and which Physical Function it's associated with for same reason.
Re: PCIe 2.0, VT-d and Intel 82576 enhancement for Xen SR-IOV
[Yu Zhao]
Quoted 7 lines
Yes, using the master BDF can move current logic into Dom0 and makes hypervisor cleaner. And it does work for VT-d spec 1.2.
But if VT-d spec 1.3 (or AMD/IBM/Sun IOMMU specs) says that the ARI device and the Virtual Function have their own remapping unit or something like this, rather than use their masters', how could we support it using the master BDF?
If this happens the dom0 kernel will detect it and pass a different master BDF to the hypervisor. This was the whole point of my comment; the hypervisor should need not know what type of device function it is dealing with. The logic for handling this should if possible be kept out of the hypervisor (and if these kind of changes came along you would still need dom0 support for handling it anyway).
Quoted 6 lines
Things evolve fast, we would need
to add another hypercall to enhance the master BDF one after it's in 3.4 -- it would be like when thedevice_addwas added, the VT-d spec didn't have such requirement, but now we have to adddevice_add_extbecause the compatibility requirement.
Quoted 6 lines
Passing these device specific information down and doing the IOMMU specific work inside the hypervisor hereditarily come with current passthrough architecture. After choosing putting all IOMMU things (both high level remapping data structures and logics, and low level hardware drivers) into hypervisor, we lost the flexibility to split the matching up logic and move it back to the Dom0 kernel.
I don't buy this argument. You seem to be indicating that the mechanism for configuring a given setup can not be separated from the mechanism which actually enforces that configuration. This is not true. It's all a matter of finding the right abstraction for the configuration interface. Flexibility need not be sacrificed. I guess the main problem here is that there was never much thought put into how to best express the interfaces and abstractions for dealing with IOMMUs, and as newer generations of IOMMU and PCIe hardware came along the lack of flexibility in the original abstractions has come back to bite us.
eSk
Quoted 32 lines
Thanks,
YuQuoted 28 lines · Espen Skoglund
Why put all this logic into Xen itself? Finding the matching DRHD unit will often "just work" anyway by the way the DHRD scope matching is performed.
That said, yes, I get it that it might sometimes be better to actually map the VFs and ARI functions back to the PF before matching. However, why not extend the current
device_addfunction and hypercall with a master BDF pointing back to the BDF "owning" the function? This leaves all of the matching up logic out of the hypervisor. A zero or -1 master BDF could indicate that there is no owner (i.e., it owns itself).eSk
[Yu Zhao]
Quoted 11 lines
PCIe Alternative Routing-ID Interpretation (ARI) ECN defines the Extended Function -- a function whose function number is greater than 7 within an ARI Device. Intel VT-d spec 1.2 section 8.3.2 specifies that the Extended Function is under the scope of the same remapping unit as the traditional function. The hypervisor needs to know if a function is Extended Function so it can find proper DMAR for it.
And section 8.3.3 specifies that the SR-IOV Virtual Function is under the scope of the same remapping unit as the Physical Function. The hypervisor also needs to know if a function is the Virtual Function and which Physical Function it's associated with for same reason.
Re: PCIe 2.0, VT-d and Intel 82576 enhancement for Xen SR-IOV
Quoted 9 lines · Espen Skoglund
[Yu Zhao]
Quoted 7 lines
Yes, using the master BDF can move current logic into Dom0 and makes hypervisor cleaner. And it does work for VT-d spec 1.2.
But if VT-d spec 1.3 (or AMD/IBM/Sun IOMMU specs) says that the ARI device and the Virtual Function have their own remapping unit or something like this, rather than use their masters', how could we support it using the master BDF?
Quoted 6 lines
If this happens the dom0 kernel will detect it and pass a different master BDF to the hypervisor. This was the whole point of my comment; the hypervisor should need not know what type of device function it is dealing with. The logic for handling this should if possible be kept out of the hypervisor (and if these kind of changes came along you would still need dom0 support for handling it anyway).
Yes, I understand you point but didn't make myself clear:
1) we can't extend device_add existing in 3.3 release for compatibility reason.
2) the master BDF can only cover current VT-d 1.2 spec case -- IOMMUs from other vendors may require the ARI Extended Function or the Virtual Function to use a seperate remapping that can't indicated by the master BDF. They may use a simple algorithm as:
if (is_ari_extfn)
use IOMMU_1
else if (is_sriov_virtfn)
use IOMMU_2
else
use BDF to find a proper IOMMU
or something like this which doesn't have the master BDF concept at all. And the Virtual Function ATS has following requirement:
PCI SR-IOV 1.0 section 3.7.4:
However, all VFs associated with a PF share a single input queue in the PF. To implement Invalidation flow control, the TA must ensure that the total number of outstanding Invalidate Requests to the shared PF queue (targeted to the PF and its associated VFs) does not exceed the value in the PF Invalidate Queue Depth field.
Which means if we want to enable ATS for a Virtual Function, we must know it's a Virtual Function first, then its associated Physical Function. Only knowing its master BDF can't give IOMMU enough hint to setup the Invalidation Queue (IOMMU won't figure out the function type behind the master BDF).
Eventually we still need to pass the function type to the hypervisor and let the IOMMU code to do something else even we have found the master BDF for DRHD unit matching in the Dom0. This makes me feel no difference between putting a small part this kind logics in the Dom0 while leaving most of them in the hypervisor and putting all of them in the hypervisor.
Quoted 13 lines
Quoted 6 lines
Things evolve fast, we would need
to add another hypercall to enhance the master BDF one after it's in 3.4 -- it would be like when thedevice_addwas added, the VT-d spec didn't have such requirement, but now we have to adddevice_add_extbecause the compatibility requirement.Quoted 6 lines
Passing these device specific information down and doing the IOMMU specific work inside the hypervisor hereditarily come with current passthrough architecture. After choosing putting all IOMMU things (both high level remapping data structures and logics, and low level hardware drivers) into hypervisor, we lost the flexibility to split the matching up logic and move it back to the Dom0 kernel.
Quoted 10 lines
I don't buy this argument. You seem to be indicating that the mechanism for configuring a given setup can not be separated from the mechanism which actually enforces that configuration. This is not true. It's all a matter of finding the right abstraction for the configuration interface. Flexibility need not be sacrificed. I guess the main problem here is that there was never much thought put into how to best express the interfaces and abstractions for dealing with IOMMUs, and as newer generations of IOMMU and PCIe hardware came along the lack of flexibility in the original abstractions has come back to bite us.
Yes, VT-d used to not cover the SR-IOV/ARI device because the PCIe IOV specs appeared relatively late and hardware having these new features is rarely supported by VMMs.
Any comments on improving interfaces and abstractions are welcome.
Thanks,
Yu