@@ -872,6 +872,10 @@ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus,
if ( ret )
goto out;
+ ret = vpci_deassign_device(d, pdev);
+ if ( ret )
+ goto out;
+
if ( pdev->domain == hardware_domain )
pdev->quarantine = false;
@@ -1431,6 +1435,11 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
rc = hd->platform_ops->assign_device(d, devfn, pci_to_dev(pdev), flag);
}
+ if ( rc )
+ goto done;
+
+ rc = vpci_assign_device(d, pdev);
+
done:
if ( rc )
printk(XENLOG_G_WARNING "%pd: assign (%pp) failed (%d)\n",
@@ -86,6 +86,27 @@ int __hwdom_init vpci_add_handlers(struct pci_dev *pdev)
return rc;
}
+
+/* Notify vPCI that device is assigned to guest. */
+int vpci_assign_device(struct domain *d, const struct pci_dev *dev)
+{
+ /* It only makes sense to assign for hwdom or guest domain. */
+ if ( is_system_domain(d) || !has_vpci(d) )
+ return 0;
+
+ return 0;
+}
+
+/* Notify vPCI that device is de-assigned from guest. */
+int vpci_deassign_device(struct domain *d, const struct pci_dev *dev)
+{
+ /* It only makes sense to de-assign from hwdom or guest domain. */
+ if ( is_system_domain(d) || !has_vpci(d) )
+ return 0;
+
+ return 0;
+}
+
#endif /* __XEN__ */
static int vpci_register_cmp(const struct vpci_register *r1,
@@ -26,6 +26,12 @@ typedef int vpci_register_init_t(struct pci_dev *dev);
/* Add vPCI handlers to device. */
int __must_check vpci_add_handlers(struct pci_dev *dev);
+/* Notify vPCI that device is assigned/de-assigned to/from guest. */
+int __must_check vpci_assign_device(struct domain *d,
+ const struct pci_dev *dev);
+int __must_check vpci_deassign_device(struct domain *d,
+ const struct pci_dev *dev);
+
/* Remove all handlers and free vpci related structures. */
void vpci_remove_device(struct pci_dev *pdev);
/* Remove all handlers for the device given. */
@@ -220,6 +226,18 @@ static inline int vpci_add_handlers(struct pci_dev *pdev)
return 0;
}
+static inline int vpci_assign_device(struct domain *d,
+ const struct pci_dev *dev)
+{
+ return 0;
+};
+
+static inline int vpci_deassign_device(struct domain *d,
+ const struct pci_dev *dev)
+{
+ return 0;
+};
+
static inline void vpci_dump_msi(void) { }
static inline uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg,