[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v4 10/29] memory: Introduce IOMMU Memory Region inject
From: |
Eric Auger |
Subject: |
[Qemu-devel] [RFC v4 10/29] memory: Introduce IOMMU Memory Region inject_faults API |
Date: |
Thu, 11 Jul 2019 19:28:26 +0200 |
This new API allows to inject @count iommu_faults into
the IOMMU memory region.
Signed-off-by: Eric Auger <address@hidden>
---
include/exec/memory.h | 25 +++++++++++++++++++++++++
memory.c | 10 ++++++++++
2 files changed, 35 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 593ef947c6..d0de192887 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -54,6 +54,8 @@ struct MemoryRegionMmio {
CPUWriteMemoryFunc *write[3];
};
+struct iommu_fault;
+
typedef struct IOMMUTLBEntry IOMMUTLBEntry;
/* See address_space_translate: bit 0 is read, bit 1 is write. */
@@ -342,6 +344,19 @@ typedef struct IOMMUMemoryRegionClass {
* @iommu: the IOMMUMemoryRegion
*/
int (*num_indexes)(IOMMUMemoryRegion *iommu);
+
+ /*
+ * Inject @count faults into the IOMMU memory region
+ *
+ * Optional method: if this method is not provided, then
+ * memory_region_injection_faults() will return -ENOENT
+ *
+ * @iommu: the IOMMU memory region to inject the faults in
+ * @count: number of faults to inject
+ * @buf: fault buffer
+ */
+ int (*inject_faults)(IOMMUMemoryRegion *iommu, int count,
+ struct iommu_fault *buf);
} IOMMUMemoryRegionClass;
typedef struct CoalescedMemoryRange CoalescedMemoryRange;
@@ -1123,6 +1138,16 @@ int memory_region_iommu_attrs_to_index(IOMMUMemoryRegion
*iommu_mr,
*/
int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr);
+/**
+ * memory_region_inject_faults : inject @count faults stored in @buf
+ *
+ * @iommu_mr: the IOMMU memory region
+ * @count: number of faults to be injected
+ * @buf: buffer containing the faults
+ */
+int memory_region_inject_faults(IOMMUMemoryRegion *iommu_mr, int count,
+ struct iommu_fault *buf);
+
/**
* memory_region_name: get a memory region's name
*
diff --git a/memory.c b/memory.c
index 90967b579d..d81525fe11 100644
--- a/memory.c
+++ b/memory.c
@@ -2000,6 +2000,16 @@ int memory_region_iommu_num_indexes(IOMMUMemoryRegion
*iommu_mr)
return imrc->num_indexes(iommu_mr);
}
+int memory_region_inject_faults(IOMMUMemoryRegion *iommu_mr, int count,
+ struct iommu_fault *buf)
+{
+ IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr);
+ if (!imrc->inject_faults) {
+ return -ENOENT;
+ }
+ return imrc->inject_faults(iommu_mr, count, buf);
+}
+
void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client)
{
uint8_t mask = 1 << client;
--
2.20.1
- [Qemu-devel] [RFC v4 00/29] vSMMUv3/pSMMUv3 2 stage VFIO integration, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 01/29] memory: Remove unused memory_region_iommu_replay_all(), Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 02/29] memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory region attribute, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 03/29] hw/vfio/common: Assert in case of nested mode, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 05/29] hw/arm/smmuv3: Remove spurious error messages on IOVA invalidations, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 04/29] hw/arm/smmuv3: Log a guest error when decoding an invalid STE, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 06/29] update-linux-headers: Import iommu.h, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 07/29] update-linux-headers: Add sve_context.h to asm-arm64, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 08/29] header update against 5.3.0-rc0 and IOMMU/VFIO nested stage APIs, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 09/29] memory: Add IOMMU_ATTR_MSI_TRANSLATE IOMMU memory region attribute, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 10/29] memory: Introduce IOMMU Memory Region inject_faults API,
Eric Auger <=
- [Qemu-devel] [RFC v4 11/29] memory: Add arch_id and leaf fields in IOTLBEntry, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 12/29] iommu: Introduce generic header, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 13/29] pci: introduce PCIPASIDOps to PCIDevice, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 14/29] vfio: Force nested if iommu requires it, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 15/29] vfio: Introduce hostwin_from_range helper, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 16/29] vfio: Introduce helpers to DMA map/unmap a RAM section, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 17/29] vfio: Set up nested stage mappings, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 18/29] vfio: Pass stage 1 MSI bindings to the host, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 19/29] vfio: Helper to get IRQ info including capabilities, Eric Auger, 2019/07/11
- [Qemu-devel] [RFC v4 20/29] vfio/pci: Register handler for iommu fault, Eric Auger, 2019/07/11