pci: apply workaround for Intel errata HSE43 and BDF2
PATCH v2 1/1 pci: apply workaround for Intel errata HSE43 and BDF2
This errata affect the values read from the BAR registers, and could render vPCI (and by extension PVH Dom0 unusable).
HSE43 is a Haswell erratum where a non-BAR register is implemented at the position where the first BAR of the device should be found in a Power Control Unit device. Note that there are no BARs on this device, apart from the bogus CSR register positioned on top of the first BAR.
BDF2/BDX2 is a Broadwell erratum where BARs in the Home Agent device will return bogus non-zero values.
In both cases the solution is to treat such devices as having no BARs in the vPCI code.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
---
Some testing would be nice has I don't seem to have any box ATM that contains this errata.
---
Changes since v1:
- Fix wording in the description and reference BDX2 erratum.
- Use a tuple array to store the list of affected devices.
- Return early from init_bars if BARs are ignored.
- Move position of the ignore_bars field in the pci_dev struct.
--- xen/drivers/passthrough/pci.c | 41 +++++++++++++++++++++++++++++++++++ xen/drivers/vpci/header.c | 3 +++ xen/include/xen/pci.h | 3 +++ 3 files changed, 47 insertions(+)
xen/drivers/passthrough/pci.c +41 -0
@@ -17,6 +17,7 @@#include <xen/sched.h> #include <xen/pci.h> #include <xen/pci_regs.h> +#include <xen/pci_ids.h> #include <xen/list.h> #include <xen/prefetch.h> #include <xen/iommu.h>
@@ -298,6 +299,45 @@ static void check_pdev(const struct pci_dev *pdev)#undef PCI_STATUS_CHECK } +static void apply_quirks (struct pci_dev *pdev) +{ +uint16_t vendor =pci_conf_read16 (pdev->seg, pdev->bus, +PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn),PCI_VENDOR_ID ); +uint16_t device =pci_conf_read16 (pdev->seg, pdev->bus, +PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn),PCI_DEVICE_ID ); +const static struct { +uint16_t vendor, device; + } quirks[] = { +/* +* Device [8086:2fc0] +* Erratum HSE43 +* CONFIG_TDP_NOMINAL CSR Implemented at Incorrect Offset +* http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v3-spec-update.html +*/ + {PCI_VENDOR_ID_INTEL ,0x2fc0 }, +/* +* Devices [8086:6f60,6fa0,6fc0] +* Erratum BDF2 +* PCI BARs in the Home Agent Will Return Non-Zero Values During Enumeration +* http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v4-spec-update.html +*/ + {PCI_VENDOR_ID_INTEL ,0x6f60 }, + {PCI_VENDOR_ID_INTEL ,0x6fa0 }, + {PCI_VENDOR_ID_INTEL ,0x6fc0 }, + }; +unsigned int i; + +for ( i =0 ; i <ARRAY_SIZE (quirks); i++) +if ( vendor == quirks[i].vendor && device == quirks[i].device ) +/* +* For both erratas force ignoring the BARs, this prevents vPCI +* from trying to size the BARs or add handlers to trap accesses. +*/ + pdev->ignore_bars = true; +} +static struct pci_dev *alloc_pdev (struct pci_seg *pseg,u8 bus,u8 devfn) {struct pci_dev *pdev;
@@ -397,6 +437,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn) }check_pdev (pdev); +apply_quirks (pdev);return pdev; }
xen/drivers/vpci/header.c +3 -0
@@ -486,6 +486,9 @@ static int init_bars(struct pci_dev *pdev)if ( rc )return rc; +if ( pdev->ignore_bars ) +return 0 ; +/* Disable memory decoding before sizing. */ cmd =pci_conf_read16 (pdev->seg, pdev->bus, slot, func,PCI_COMMAND );if ( cmd &PCI_COMMAND_MEMORY )
xen/include/xen/pci.h +3 -0
@@ -88,6 +88,9 @@ struct pci_dev {nodeid_t node;/* NUMA node */ +/* Device with errata, ignore the BARs. */ +bool ignore_bars; +enum pdev_type {DEV_TYPE_PCI_UNKNOWN , DEV_TYPE_PCIe_ENDPOINT,
Signature · 7 lines
2.19.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 04.12.18 at 11:42, <[email protected]> wrote:
xen/drivers/passthrough/pci.c +1
-0@@ -298,6 +299,45 @@ static void check_pdev(const struct pci_dev *pdev)#undef PCI_STATUS_CHECK } +static void apply_quirks (struct pci_dev *pdev)
xen/drivers/passthrough/pci.c static void check_pdev(const struct pci_dev *pdev) · line 312
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+{ +uint16_t vendor =pci_conf_read16 (pdev->seg, pdev->bus, +PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn),PCI_VENDOR_ID ); +uint16_t device =pci_conf_read16 (pdev->seg, pdev->bus, +PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn),PCI_DEVICE_ID ); +const static struct { +uint16_t vendor, device; + } quirks[] = {
Since this is now a special purpose array, I'd prefer it to have a more specific name. Would you mind if I rename it to ignore_bars[] while committing? I'd perhaps also take the liberty and swap "const" and "static" into their more conventional order.
xen/drivers/passthrough/pci.c static void check_pdev(const struct pci_dev *pdev) · line 322
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+/* +* Device [8086:2fc0] +* Erratum HSE43 +* CONFIG_TDP_NOMINAL CSR Implemented at Incorrect Offset +* http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v3-spec-update.html +*/ + { PCI_VENDOR_ID_INTEL, 0x2fc0 }, +/* +* Devices [8086:6f60,6fa0,6fc0] +* Erratum BDF2
.../BDX2
xen/drivers/passthrough/pci.c static void check_pdev(const struct pci_dev *pdev) · line 335
Quoted 13 lines
xen/drivers/passthrough/pci.c +13
-0+* PCI BARs in the Home Agent Will Return Non-Zero Values During Enumeration +* http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v4-spec-update.html +*/ + { PCI_VENDOR_ID_INTEL, 0x6f60 }, + { PCI_VENDOR_ID_INTEL, 0x6fa0 }, + { PCI_VENDOR_ID_INTEL, 0x6fc0 }, + }; +unsigned int i; + +for ( i =0 ; i <ARRAY_SIZE (quirks); i++) +if ( vendor == quirks[i].vendor && device == quirks[i].device ) +/* +* For both erratas force ignoring the BARs, this prevents vPCI
"errata" is plural already afaik.
With this
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 04.12.18 at 11:42, <[email protected]> wrote:
xen/drivers/passthrough/pci.c +0
-0@@ -298,6 +299,45 @@ static void check_pdev(const struct pci_dev *pdev)#undef PCI_STATUS_CHECK }
Quoted 16 lines
xen/drivers/passthrough/pci.c static void check_pdev(const struct pci_dev *pdev) · line 312
Quoted 11 lines
xen/drivers/passthrough/pci.c +11
-0+static void apply_quirks (struct pci_dev *pdev) +{ +uint16_t vendor =pci_conf_read16 (pdev->seg, pdev->bus, +PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn),PCI_VENDOR_ID ); +uint16_t device =pci_conf_read16 (pdev->seg, pdev->bus, +PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn),PCI_DEVICE_ID ); +const static struct { +uint16_t vendor, device; + } quirks[] = {Since this is now a special purpose array, I'd prefer it to have a more specific name. Would you mind if I rename it to ignore_bars[] while committing? I'd perhaps also take the liberty and swap "const" and "static" into their more conventional order.
Sure, I've thought about using a more specific name, but since it's the only quirk ATM I've decided it wasn't worth it. Feel free to rename it.
Quoted 27 lines
xen/drivers/passthrough/pci.c static void check_pdev(const struct pci_dev *pdev) · line 322
Quoted 10 lines
xen/drivers/passthrough/pci.c +10
-0+/* +* Device [8086:2fc0] +* Erratum HSE43 +* CONFIG_TDP_NOMINAL CSR Implemented at Incorrect Offset +* http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v3-spec-update.html +*/ + { PCI_VENDOR_ID_INTEL, 0x2fc0 }, +/* +* Devices [8086:6f60,6fa0,6fc0] +* Erratum BDF2 .../BDX2
xen/drivers/passthrough/pci.c static void check_pdev(const struct pci_dev *pdev) · line 335
Quoted 13 lines
xen/drivers/passthrough/pci.c +13
-0+* PCI BARs in the Home Agent Will Return Non-Zero Values During Enumeration +* http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v4-spec-update.html +*/ + { PCI_VENDOR_ID_INTEL, 0x6f60 }, + { PCI_VENDOR_ID_INTEL, 0x6fa0 }, + { PCI_VENDOR_ID_INTEL, 0x6fc0 }, + }; +unsigned int i; + +for ( i =0 ; i <ARRAY_SIZE (quirks); i++) +if ( vendor == quirks[i].vendor && device == quirks[i].device ) +/* +* For both erratas force ignoring the BARs, this prevents vPCI
Quoted 4 lines
"errata" is plural already afaik.
With this
Reviewed-by Jan Beulich <[email protected]>
Thanks.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel