]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xen-pciback: mark device to be hidden on AER error trigger
authorElena Ufimtseva <elena.ufimtseva@oracle.com>
Thu, 21 Jul 2016 21:25:27 +0000 (17:25 -0400)
committerChuck Anderson <chuck.anderson@oracle.com>
Sun, 31 Jul 2016 05:53:13 +0000 (22:53 -0700)
Some platforms are configured to reboot the machine upon
AER unrecoverable error and some virtualized systems are subject
to security risks described in XSA-124.
This patch allows for simple AER unrecoverable errors containment
together with killing the guest upon receiving of fatal AER error.
Patch stores in xenstore sbdf of passed through device that triggered
AER unrecoverable error. This will allow xend to make device
unassignable until next reboot or special hypervisor hypercall.

OraBug: 24377669

Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Adnan Misherfi <adnan.misherfi@oracle.com>
drivers/xen/xen-pciback/pci_stub.c

index 258b7c3256499aa8105a3674a98c853f04f0ddc1..a56cbd331fec518f58f16c368c6b4947cd893f52 100644 (file)
@@ -604,11 +604,13 @@ static const struct pci_device_id pcistub_ids[] = {
 };
 
 #define PCI_NODENAME_MAX 40
+#define PCI_DEVICENAME_MAX 14
 static void kill_domain_by_device(struct pcistub_device *psdev)
 {
        struct xenbus_transaction xbt;
        int err;
        char nodename[PCI_NODENAME_MAX];
+       char devicename[PCI_DEVICENAME_MAX];
 
        BUG_ON(!psdev);
        snprintf(nodename, PCI_NODENAME_MAX, "/local/domain/0/backend/pci/%d/0",
@@ -619,7 +621,7 @@ again:
        if (err) {
                dev_err(&psdev->dev->dev,
                        "error %d when start xenbus transaction\n", err);
-               return;
+               goto hide_dev;
        }
        /*PV AER handlers will set this flag*/
        xenbus_printf(xbt, nodename, "aerState" , "aerfail");
@@ -629,8 +631,32 @@ again:
                        goto again;
                dev_err(&psdev->dev->dev,
                        "error %d when end xenbus transaction\n", err);
+       }
+
+hide_dev:
+       snprintf(devicename, PCI_DEVICENAME_MAX, "%04x:%02x:%02x.%x",
+                pci_domain_nr(psdev->dev->bus),
+                psdev->dev->bus->number,
+                PCI_SLOT(psdev->dev->devfn), PCI_FUNC(psdev->dev->devfn));
+
+dev_again:
+       err = xenbus_transaction_start(&xbt);
+       if (err) {
+               dev_err(&psdev->dev->dev,
+                       "error %d when start xenbus transaction\n", err);
                return;
        }
+
+       xenbus_printf(xbt, nodename, "aerFailedSBDF" , devicename);
+       err = xenbus_transaction_end(xbt, 0);
+       if (err) {
+               if (err == -EAGAIN) {
+                       cond_resched();
+                       goto dev_again;
+               }
+               dev_err(&psdev->dev->dev,
+                       "error %d when end xenbus transaction\n", err);
+       }
 }
 
 /* For each aer recovery step error_detected, mmio_enabled, etc, front_end and