Signed-off-by: Clement Mathieu--Drif <clement.mathieu--drif@eviden.com>
---
hw/i386/intel_iommu.c | 13 +++++++++++++
hw/i386/intel_iommu_internal.h | 7 +++++++
2 files changed, 20 insertions(+)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 6a168d5107..8dbc4ea508 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -5326,6 +5326,17 @@ static const TypeInfo vtd_info = {
.class_init = vtd_class_init,
};
+static int vtd_attrs_to_index(IOMMUMemoryRegion *iommu_mr, MemTxAttrs attrs)
+{
+ return attrs.address_type == PCI_AT_TRANSLATED ?
+ VTD_IDX_TRANSLATED : VTD_IDX_UNTRANSLATED;
+}
+
+static int vtd_num_indexes(IOMMUMemoryRegion *iommu)
+{
+ return VTD_IDX_COUNT;
+}
+
static void vtd_iommu_memory_region_class_init(ObjectClass *klass,
const void *data)
{
@@ -5334,6 +5345,8 @@ static void vtd_iommu_memory_region_class_init(ObjectClass *klass,
imrc->translate = vtd_iommu_translate;
imrc->notify_flag_changed = vtd_iommu_notify_flag_changed;
imrc->replay = vtd_iommu_replay;
+ imrc->attrs_to_index = vtd_attrs_to_index;
+ imrc->num_indexes = vtd_num_indexes;
}
static const TypeInfo vtd_iommu_memory_region_info = {
diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
index 0f6a1237e4..3a1f7a1d99 100644
--- a/hw/i386/intel_iommu_internal.h
+++ b/hw/i386/intel_iommu_internal.h
@@ -660,4 +660,11 @@ typedef struct VTDRootEntry VTDRootEntry;
/* Bits to decide the offset for each level */
#define VTD_LEVEL_BITS 9
+/* IOMMU Index */
+typedef enum VTDIOMMUIndex {
+ VTD_IDX_UNTRANSLATED = 0, /* Default */
+ VTD_IDX_TRANSLATED = 1,
+ VTD_IDX_COUNT = 2, /* Number of supported indexes */
+} VTDIOMMUIndex;
+
#endif
--
2.51.0