[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] 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 the
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 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.

Reported-by: Jan Beulich <jbeulich@xxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Julien Grall <julien.grall@xxxxxxx>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Tim Deegan <tim@xxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
---
Some testing would be nice has I don't seem to have any box ATM that
contains this errata.
---
 xen/drivers/passthrough/pci.c | 30 ++++++++++++++++++++++++++++++
 xen/drivers/vpci/header.c     |  3 +++
 xen/include/xen/pci.h         |  3 +++
 3 files changed, 36 insertions(+)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 7584ce2fbb..d27046c9ea 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -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,34 @@ 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);
+
+    if ( vendor == PCI_VENDOR_ID_INTEL && (device == 0x2fc0 ||
+         device == 0x6f60 || device == 0x6fa0 || device == 0x6fc0) )
+        /*
+         * 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
+         *
+         * 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
+         *
+         * 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 +426,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 
bus, u8 devfn)
     }
 
     check_pdev(pdev);
+    apply_quirks(pdev);
 
     return pdev;
 }
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 43cac3f7d3..71d316112e 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -480,6 +480,9 @@ static int init_bars(struct pci_dev *pdev)
         return -EOPNOTSUPP;
     }
 
+    if ( pdev->ignore_bars )
+        num_bars = 0;
+
     /* Setup a handler for the command register. */
     rc = vpci_add_register(pdev->vpci, vpci_hw_read16, cmd_write, PCI_COMMAND,
                            2, header);
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index 3c361cf0c0..5be9de2df8 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -115,6 +115,9 @@ struct pci_dev {
 
     /* Data for vPCI. */
     struct vpci *vpci;
+
+    /* Device with errata, ignore the BARs. */
+    bool ignore_bars;
 };
 
 #define for_each_pdev(domain, pdev) \
-- 
2.19.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.