[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v7 25/26] pci: Add return_page_response pci ops
From: |
Eric Auger |
Subject: |
[RFC v7 25/26] pci: Add return_page_response pci ops |
Date: |
Mon, 16 Nov 2020 19:13:48 +0100 |
Add a new PCI operation that allows to return page responses
to registered VFIO devices
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/iommu/iommu.h | 8 ++++++++
include/hw/pci/pci.h | 4 ++++
hw/pci/pci.c | 16 ++++++++++++++++
3 files changed, 28 insertions(+)
diff --git a/include/hw/iommu/iommu.h b/include/hw/iommu/iommu.h
index 12092bda7b..5890f095b1 100644
--- a/include/hw/iommu/iommu.h
+++ b/include/hw/iommu/iommu.h
@@ -24,5 +24,13 @@ typedef struct IOMMUConfig {
};
} IOMMUConfig;
+typedef struct IOMMUPageResponse {
+ union {
+#ifdef __linux__
+ struct iommu_page_response resp;
+#endif
+ };
+} IOMMUPageResponse;
+
#endif /* QEMU_HW_IOMMU_IOMMU_H */
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 833b330ee1..c4baadf77e 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -267,6 +267,8 @@ typedef struct PCIReqIDCache PCIReqIDCache;
struct PCIPASIDOps {
int (*set_pasid_table)(PCIBus *bus, int32_t devfn, IOMMUConfig *config);
+ int (*return_page_response)(PCIBus *bus, int32_t devfn,
+ IOMMUPageResponse *resp);
};
typedef struct PCIPASIDOps PCIPASIDOps;
@@ -498,6 +500,8 @@ void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void
*opaque);
void pci_setup_pasid_ops(PCIDevice *dev, PCIPASIDOps *ops);
bool pci_device_is_pasid_ops_set(PCIBus *bus, int32_t devfn);
int pci_device_set_pasid_table(PCIBus *bus, int32_t devfn, IOMMUConfig
*config);
+int pci_device_return_page_response(PCIBus *bus, int32_t devfn,
+ IOMMUPageResponse *resp);
static inline void
pci_set_byte(uint8_t *config, uint8_t val)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 4e21feb758..5dd207bc22 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2759,6 +2759,22 @@ int pci_device_set_pasid_table(PCIBus *bus, int32_t
devfn,
return -ENOENT;
}
+int pci_device_return_page_response(PCIBus *bus, int32_t devfn,
+ IOMMUPageResponse *resp)
+{
+ PCIDevice *dev;
+
+ if (!bus) {
+ return -EINVAL;
+ }
+
+ dev = bus->devices[devfn];
+ if (dev && dev->pasid_ops && dev->pasid_ops->return_page_response) {
+ return dev->pasid_ops->return_page_response(bus, devfn, resp);
+ }
+ return -ENOENT;
+}
+
static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
{
Range *range = opaque;
--
2.21.3
- [RFC v7 15/26] vfio/pci: Register handler for iommu fault, (continued)
- [RFC v7 15/26] vfio/pci: Register handler for iommu fault, Eric Auger, 2020/11/16
- [RFC v7 16/26] vfio/pci: Set up the DMA FAULT region, Eric Auger, 2020/11/16
- [RFC v7 17/26] vfio/pci: Implement the DMA fault handler, Eric Auger, 2020/11/16
- [RFC v7 18/26] hw/arm/smmuv3: Advertise MSI_TRANSLATE attribute, Eric Auger, 2020/11/16
- [RFC v7 19/26] hw/arm/smmuv3: Store the PASID table GPA in the translation config, Eric Auger, 2020/11/16
- [RFC v7 20/26] hw/arm/smmuv3: Fill the IOTLBEntry arch_id on NH_VA invalidation, Eric Auger, 2020/11/16
- [RFC v7 21/26] hw/arm/smmuv3: Fill the IOTLBEntry leaf field on NH_VA invalidation, Eric Auger, 2020/11/16
- [RFC v7 23/26] hw/arm/smmuv3: Implement fault injection, Eric Auger, 2020/11/16
- [RFC v7 22/26] hw/arm/smmuv3: Pass stage 1 configurations to the host, Eric Auger, 2020/11/16
- [RFC v7 24/26] hw/arm/smmuv3: Allow MAP notifiers, Eric Auger, 2020/11/16
- [RFC v7 25/26] pci: Add return_page_response pci ops,
Eric Auger <=
- [RFC v7 26/26] vfio/pci: Implement return_page_response page response callback, Eric Auger, 2020/11/16