From: Elena Ufimtseva Date: Thu, 21 Jul 2016 21:25:27 +0000 (-0400) Subject: xen-pciback: mark device to be hidden on AER error trigger X-Git-Tag: v4.1.12-92~98^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4e1c03794176b8175877fda8ac17f1a59d0d3730;p=users%2Fjedix%2Flinux-maple.git xen-pciback: mark device to be hidden on AER error trigger 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 Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Adnan Misherfi --- diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c index 258b7c325649..a56cbd331fec 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c @@ -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