[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v7 05/26] memory: Introduce IOMMU Memory Region inject_faults API
From: |
Eric Auger |
Subject: |
[RFC v7 05/26] memory: Introduce IOMMU Memory Region inject_faults API |
Date: |
Mon, 16 Nov 2020 19:13:28 +0100 |
This new API allows to inject @count iommu_faults into
the IOMMU memory region.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/exec/memory.h | 24 ++++++++++++++++++++++++
softmmu/memory.c | 10 ++++++++++
2 files changed, 34 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 023aa83c55..a7364875ef 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -67,6 +67,8 @@ struct ReservedRegion {
unsigned type;
};
+struct iommu_fault;
+
typedef struct IOMMUTLBEntry IOMMUTLBEntry;
/* See address_space_translate: bit 0 is read, bit 1 is write. */
@@ -425,6 +427,19 @@ struct IOMMUMemoryRegionClass {
int (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu,
uint64_t page_size_mask,
Error **errp);
+
+ /*
+ * 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);
};
typedef struct CoalescedMemoryRange CoalescedMemoryRange;
@@ -1448,6 +1463,15 @@ int memory_region_iommu_num_indexes(IOMMUMemoryRegion
*iommu_mr);
int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr,
uint64_t page_size_mask,
Error **errp);
+/**
+ * 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/softmmu/memory.c b/softmmu/memory.c
index 71951fe4dc..297ef50545 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2010,6 +2010,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.21.3
- [RFC v7 00/26] vSMMUv3/pSMMUv3 2 stage VFIO integration, Eric Auger, 2020/11/16
- [RFC v7 01/26] update-linux-headers: Import iommu.h, Eric Auger, 2020/11/16
- [RFC v7 02/26] header update against 5.10-rc4 and IOMMU/VFIO nested stage APIs, Eric Auger, 2020/11/16
- [RFC v7 03/26] memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory region attribute, Eric Auger, 2020/11/16
- [RFC v7 04/26] memory: Add IOMMU_ATTR_MSI_TRANSLATE IOMMU memory region attribute, Eric Auger, 2020/11/16
- [RFC v7 05/26] memory: Introduce IOMMU Memory Region inject_faults API,
Eric Auger <=
- [RFC v7 06/26] memory: Add arch_id and leaf fields in IOTLBEntry, Eric Auger, 2020/11/16
- [RFC v7 07/26] iommu: Introduce generic header, Eric Auger, 2020/11/16
- [RFC v7 08/26] pci: introduce PCIPASIDOps to PCIDevice, Eric Auger, 2020/11/16
- [RFC v7 09/26] vfio: Force nested if iommu requires it, Eric Auger, 2020/11/16
- [RFC v7 10/26] vfio: Introduce hostwin_from_range helper, Eric Auger, 2020/11/16
- [RFC v7 11/26] vfio: Introduce helpers to DMA map/unmap a RAM section, Eric Auger, 2020/11/16
- [RFC v7 12/26] vfio: Set up nested stage mappings, Eric Auger, 2020/11/16
- [RFC v7 13/26] vfio: Pass stage 1 MSI bindings to the host, Eric Auger, 2020/11/16
- [RFC v7 14/26] vfio: Helper to get IRQ info including capabilities, Eric Auger, 2020/11/16
- [RFC v7 15/26] vfio/pci: Register handler for iommu fault, Eric Auger, 2020/11/16