summaryrefslogtreecommitdiff
path: root/drivers/xen/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen/pci.c')
-rw-r--r--drivers/xen/pci.c59
1 files changed, 50 insertions, 9 deletions
diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c
index 72d4e3f193af..bfe07adb3e3a 100644
--- a/drivers/xen/pci.c
+++ b/drivers/xen/pci.c
@@ -43,16 +43,24 @@ static int xen_add_device(struct device *dev)
pci_mcfg_reserved = true;
}
#endif
+
+ if (pci_domain_nr(pci_dev->bus) >> 16) {
+ /*
+ * The hypercall interface is limited to 16bit PCI segment
+ * values, do not attempt to register devices with Xen in
+ * segments greater or equal than 0x10000.
+ */
+ dev_info(dev,
+ "not registering with Xen: invalid PCI segment\n");
+ return 0;
+ }
+
if (pci_seg_supported) {
- struct {
- struct physdev_pci_device_add add;
- uint32_t pxm;
- } add_ext = {
- .add.seg = pci_domain_nr(pci_dev->bus),
- .add.bus = pci_dev->bus->number,
- .add.devfn = pci_dev->devfn
- };
- struct physdev_pci_device_add *add = &add_ext.add;
+ DEFINE_RAW_FLEX(struct physdev_pci_device_add, add, optarr, 1);
+
+ add->seg = pci_domain_nr(pci_dev->bus);
+ add->bus = pci_dev->bus->number;
+ add->devfn = pci_dev->devfn;
#ifdef CONFIG_ACPI
acpi_handle handle;
@@ -153,6 +161,16 @@ static int xen_remove_device(struct device *dev)
int r;
struct pci_dev *pci_dev = to_pci_dev(dev);
+ if (pci_domain_nr(pci_dev->bus) >> 16) {
+ /*
+ * The hypercall interface is limited to 16bit PCI segment
+ * values.
+ */
+ dev_info(dev,
+ "not unregistering with Xen: invalid PCI segment\n");
+ return 0;
+ }
+
if (pci_seg_supported) {
struct physdev_pci_device device = {
.seg = pci_domain_nr(pci_dev->bus),
@@ -177,6 +195,29 @@ static int xen_remove_device(struct device *dev)
return r;
}
+int xen_reset_device(const struct pci_dev *dev)
+{
+ struct pci_device_reset device = {
+ .dev.seg = pci_domain_nr(dev->bus),
+ .dev.bus = dev->bus->number,
+ .dev.devfn = dev->devfn,
+ .flags = PCI_DEVICE_RESET_FLR,
+ };
+
+ if (pci_domain_nr(dev->bus) >> 16) {
+ /*
+ * The hypercall interface is limited to 16bit PCI segment
+ * values.
+ */
+ dev_info(&dev->dev,
+ "unable to notify Xen of device reset: invalid PCI segment\n");
+ return 0;
+ }
+
+ return HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_reset, &device);
+}
+EXPORT_SYMBOL_GPL(xen_reset_device);
+
static int xen_pci_notifier(struct notifier_block *nb,
unsigned long action, void *data)
{