[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 25/28] memory: Introduce IOMMU Memory Region inject
From: |
Eric Auger |
Subject: |
[Qemu-devel] [RFC v2 25/28] memory: Introduce IOMMU Memory Region inject_faults API |
Date: |
Fri, 21 Sep 2018 10:18:16 +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 | 26 ++++++++++++++++++++++++++
memory.c | 12 ++++++++++++
2 files changed, 38 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index f54c39b248..45bcca2081 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -391,6 +391,20 @@ typedef struct IOMMUMemoryRegionClass {
* @iommu: the IOMMUMemoryRegion
*/
int (*num_indexes)(IOMMUMemoryRegion *iommu);
+
+#ifdef CONFIG_LINUX
+ /* 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);
+#endif
} IOMMUMemoryRegionClass;
typedef struct CoalescedMemoryRange CoalescedMemoryRange;
@@ -1203,6 +1217,18 @@ int memory_region_iommu_attrs_to_index(IOMMUMemoryRegion
*iommu_mr,
*/
int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr);
+#ifdef CONFIG_LINUX
+/**
+ * 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);
+#endif
+
/**
* memory_region_name: get a memory region's name
*
diff --git a/memory.c b/memory.c
index 2c320bc14b..6ba8d31773 100644
--- a/memory.c
+++ b/memory.c
@@ -1976,6 +1976,18 @@ int memory_region_iommu_num_indexes(IOMMUMemoryRegion
*iommu_mr)
return imrc->num_indexes(iommu_mr);
}
+#ifdef CONFIG_LINUX
+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);
+}
+#endif
+
void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client)
{
uint8_t mask = 1 << client;
--
2.17.1
- [Qemu-devel] [RFC v2 16/28] hw/arm/smmuv3: Fill the IOTLBEntry arch_id on NH_VA invalidation, (continued)
- [Qemu-devel] [RFC v2 16/28] hw/arm/smmuv3: Fill the IOTLBEntry arch_id on NH_VA invalidation, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 15/28] hw/arm/smmuv3: Notify on config changes, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 17/28] hw/vfio/common: Introduce vfio_alloc_guest_iommu helper, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 18/28] hw/vfio/common: Introduce vfio_dma_(un)map_ram_section helpers, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 19/28] hw/vfio/common: Register specific nested mode notifiers and memory_listener, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 20/28] hw/vfio/common: Register MAP notifier for MSI binding, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 22/28] vfio/pci: Always set up MSI route before enabling vectors, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 21/28] target/arm/kvm: Notifies IOMMU on MSI stage 1 binding, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 23/28] hw/arm/smmuv3: Remove warning about unsupported MAP notifiers, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 24/28] memory: Introduce IOMMU_NOTIFIER_INIT_CFG IOMMU Config Notifier, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 25/28] memory: Introduce IOMMU Memory Region inject_faults API,
Eric Auger <=
- [Qemu-devel] [RFC v2 26/28] hw/vfio/common: Handle fault_handler, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 27/28] hw/arm/smmuv3: Init fault handling, Eric Auger, 2018/09/21
- [Qemu-devel] [RFC v2 28/28] hw/arm/smmuv3: Implement fault injection, Eric Auger, 2018/09/21