Message ID | 1562324511-2910-8-git-send-email-yi.l.liu@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | intel_iommu: expose Shared Virtual Addressing to VM | expand |
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@intel.com> > Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> > Cc: Peter Xu <peterx@redhat.com> > Cc: Eric Auger <eric.auger@redhat.com> > Cc: Yi Sun <yi.y.sun@linux.intel.com> > Cc: David Gibson <david@gibson.dropbear.id.au> > Signed-off-by: Liu Yi L <yi.l.liu@intel.com> > --- > 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
Hi Eric, > From: Auger Eric [mailto:eric.auger@redhat.com] > Sent: Tuesday, July 9, 2019 4:38 PM > To: Liu, Yi L <yi.l.liu@intel.com>; qemu-devel@nongnu.org; mst@redhat.com; > Subject: Re: [RFC v1 07/18] hw/pci: add pci_device_bind/unbind_gpasid > > 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@intel.com> > > Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> > > Cc: Peter Xu <peterx@redhat.com> > > Cc: Eric Auger <eric.auger@redhat.com> > > Cc: Yi Sun <yi.y.sun@linux.intel.com> > > Cc: David Gibson <david@gibson.dropbear.id.au> > > Signed-off-by: Liu Yi L <yi.l.liu@intel.com> > > --- > > 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__ Oops, thanks for the remind. Regards, Yi Liu
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) +{ + 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)
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@intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Peter Xu <peterx@redhat.com> Cc: Eric Auger <eric.auger@redhat.com> Cc: Yi Sun <yi.y.sun@linux.intel.com> Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Liu Yi L <yi.l.liu@intel.com> --- hw/pci/pci.c | 30 ++++++++++++++++++++++++++++++ include/hw/pci/pci.h | 9 +++++++++ 2 files changed, 39 insertions(+)