Hi Liu, On 7/5/19 1:01 PM, Liu Yi L wrote: > This patch adds two callbacks pci_device_bind/unbind_gpasid() to > PCIPASIDOps. These two callbacks are used to propagate guest pasid > bind/unbind to host. The implementations of the callbacks would be > device passthru modules like vfio. > > Cc: Kevin Tian <kevin.tian@xxxxxxxxx> > Cc: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx> > Cc: Peter Xu <peterx@xxxxxxxxxx> > Cc: Eric Auger <eric.auger@xxxxxxxxxx> > Cc: Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx> > Cc: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> > Signed-off-by: Liu Yi L <yi.l.liu@xxxxxxxxx> > --- > hw/pci/pci.c | 30 ++++++++++++++++++++++++++++++ > include/hw/pci/pci.h | 9 +++++++++ > 2 files changed, 39 insertions(+) > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index 710f9e9..2229229 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -2676,6 +2676,36 @@ int pci_device_request_pasid_free(PCIBus *bus, int32_t devfn, > return -1; > } > > +void pci_device_bind_gpasid(PCIBus *bus, int32_t devfn, > + struct gpasid_bind_data *g_bind_data) struct gpasid_bind_data is defined in linux headers so I think you would need: #ifdef __linux__ > +{ > + PCIDevice *dev; > + > + if (!bus) { > + return; > + } > + > + dev = bus->devices[devfn]; > + if (dev && dev->pasid_ops) { > + dev->pasid_ops->bind_gpasid(bus, devfn, g_bind_data); > + } > +} > + > +void pci_device_unbind_gpasid(PCIBus *bus, int32_t devfn, > + struct gpasid_bind_data *g_bind_data) > +{ > + PCIDevice *dev; > + > + if (!bus) { > + return; > + } > + > + dev = bus->devices[devfn]; > + if (dev && dev->pasid_ops) { > + dev->pasid_ops->unbind_gpasid(bus, devfn, g_bind_data); > + } > +} > + > static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque) > { > Range *range = opaque; > diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h > index 16e5b8e..8d849e6 100644 > --- a/include/hw/pci/pci.h > +++ b/include/hw/pci/pci.h > @@ -9,6 +9,7 @@ > #include "hw/isa/isa.h" > > #include "hw/pci/pcie.h" > +#include <linux/iommu.h> > > extern bool pci_available; > > @@ -267,6 +268,10 @@ struct PCIPASIDOps { > int (*alloc_pasid)(PCIBus *bus, int32_t devfn, > uint32_t min_pasid, uint32_t max_pasid); > int (*free_pasid)(PCIBus *bus, int32_t devfn, uint32_t pasid); > + void (*bind_gpasid)(PCIBus *bus, int32_t devfn, > + struct gpasid_bind_data *g_bind_data); > + void (*unbind_gpasid)(PCIBus *bus, int32_t devfn, > + struct gpasid_bind_data *g_bind_data); > }; > > struct PCIDevice { > @@ -497,6 +502,10 @@ bool pci_device_is_ops_set(PCIBus *bus, int32_t devfn); > int pci_device_request_pasid_alloc(PCIBus *bus, int32_t devfn, > uint32_t min_pasid, uint32_t max_pasid); > int pci_device_request_pasid_free(PCIBus *bus, int32_t devfn, uint32_t pasid); > +void pci_device_bind_gpasid(PCIBus *bus, int32_t devfn, > + struct gpasid_bind_data *g_bind_data); > +void pci_device_unbind_gpasid(PCIBus *bus, int32_t devfn, > + struct gpasid_bind_data *g_bind_data); > > static inline void > pci_set_byte(uint8_t *config, uint8_t val) > Thanks Eric