[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3.1 05/22] hw/pci: add pci_device_setup_iommu
From: |
Liu Yi L |
Subject: |
[RFC v3.1 05/22] hw/pci: add pci_device_setup_iommu |
Date: |
Sat, 22 Feb 2020 00:07:06 -0800 |
HostIOMMUContext was introduced to provide an explicit way for vIOMMU
emulators call into pass-through components (e.g. VFIO). vIOMMU needs
to get the HostIOMMUContext before using it. This patch adds a new
callback in PCIDevice, which would be set by pass-through components,
and be used by vIOMMU emulators to get HostIOMMUContext.
Cc: Kevin Tian <address@hidden>
Cc: Jacob Pan <address@hidden>
Cc: Peter Xu <address@hidden>
Cc: Eric Auger <address@hidden>
Cc: Yi Sun <address@hidden>
Cc: David Gibson <address@hidden>
Cc: Michael S. Tsirkin <address@hidden>
Signed-off-by: Liu, Yi L <address@hidden>
---
hw/pci/pci.c | 10 ++++++++++
include/hw/pci/pci.h | 6 ++++++
2 files changed, 16 insertions(+)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index e1ed667..3166cc3 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2695,6 +2695,16 @@ void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void
*opaque)
bus->iommu_opaque = opaque;
}
+void pci_device_setup_iommu(PCIDevice *dev, PCIHostIOMMUFunc fn)
+{
+ dev->host_iommu_fn = fn;
+}
+
+void pci_device_unset_iommu(PCIDevice *dev)
+{
+ dev->host_iommu_fn = NULL;
+}
+
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 2acd832..e44eefb 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -8,6 +8,7 @@
#include "hw/isa/isa.h"
#include "hw/pci/pcie.h"
+#include "hw/iommu/host_iommu_context.h"
extern bool pci_available;
@@ -248,6 +249,7 @@ typedef void (*MSIVectorReleaseNotifier)(PCIDevice *dev,
unsigned int vector);
typedef void (*MSIVectorPollNotifier)(PCIDevice *dev,
unsigned int vector_start,
unsigned int vector_end);
+typedef HostIOMMUContext *(*PCIHostIOMMUFunc)(PCIDevice *);
enum PCIReqIDType {
PCI_REQ_ID_INVALID = 0,
@@ -356,6 +358,8 @@ struct PCIDevice {
/* ID of standby device in net_failover pair */
char *failover_pair_id;
+ /* Callback to get host iommu context */
+ PCIHostIOMMUFunc host_iommu_fn;
};
void pci_register_bar(PCIDevice *pci_dev, int region_num,
@@ -488,6 +492,8 @@ typedef AddressSpace *(*PCIIOMMUFunc)(PCIBus *, void *,
int);
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque);
+void pci_device_setup_iommu(PCIDevice *dev, PCIHostIOMMUFunc fn);
+void pci_device_unset_iommu(PCIDevice *dev);
static inline void
pci_set_byte(uint8_t *config, uint8_t val)
--
2.7.4
- [RFC v3.1 00/22] intel_iommu: expose Shared Virtual Addressing to VMs, Liu Yi L, 2020/02/22
- [RFC v3.1 03/22] vfio: check VFIO_TYPE1_NESTING_IOMMU support, Liu Yi L, 2020/02/22
- [RFC v3.1 09/22] hw/pci: add pci_device_host_iommu_context(), Liu Yi L, 2020/02/22
- [RFC v3.1 13/22] vfio: add bind stage-1 page table support, Liu Yi L, 2020/02/22
- [RFC v3.1 06/22] vfio/pci: init HostIOMMUContext per-container, Liu Yi L, 2020/02/22
- [RFC v3.1 01/22] scripts/update-linux-headers: Import iommu.h, Liu Yi L, 2020/02/22
- [RFC v3.1 05/22] hw/pci: add pci_device_setup_iommu,
Liu Yi L <=
- [RFC v3.1 08/22] vfio/common: add pasid_alloc/free support, Liu Yi L, 2020/02/22
- [RFC v3.1 11/22] intel_iommu: process pasid cache invalidation, Liu Yi L, 2020/02/22
- [RFC v3.1 19/22] intel_iommu: process PASID-based iotlb invalidation, Liu Yi L, 2020/02/22
- [RFC v3.1 04/22] hw/iommu: introduce HostIOMMUContext, Liu Yi L, 2020/02/22
- [RFC v3.1 07/22] vfio: get nesting iommu cap info from Kernel, Liu Yi L, 2020/02/22
- [RFC v3.1 10/22] intel_iommu: add virtual command capability support, Liu Yi L, 2020/02/22
- [RFC v3.1 17/22] intel_iommu: do not pass down pasid bind for PASID #0, Liu Yi L, 2020/02/22
- [RFC v3.1 21/22] intel_iommu: process PASID-based Device-TLB invalidation, Liu Yi L, 2020/02/22
- [RFC v3.1 15/22] intel_iommu: replay guest pasid bindings to host, Liu Yi L, 2020/02/22
- [RFC v3.1 02/22] header file update VFIO/IOMMU vSVA APIs, Liu Yi L, 2020/02/22