[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 07/15] intel-iommu: Implement get_attr() method
|
From: |
Joao Martins |
|
Subject: |
[PATCH v3 07/15] intel-iommu: Implement get_attr() method |
|
Date: |
Tue, 30 May 2023 18:59:29 +0100 |
Implement get_attr() method and use the IntelIOMMUState::dma_translation
field to report the IOMMU_ATTR_DMA_TRANSLATION attribute.
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
hw/i386/intel_iommu.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index c344d49fe290..1906f3a67960 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3861,6 +3861,29 @@ static void vtd_iommu_replay(IOMMUMemoryRegion
*iommu_mr, IOMMUNotifier *n)
return;
}
+static int vtd_iommu_get_attr(IOMMUMemoryRegion *iommu_mr,
+ enum IOMMUMemoryRegionAttr attr, void *data)
+{
+ VTDAddressSpace *vtd_as = container_of(iommu_mr, VTDAddressSpace, iommu);
+ IntelIOMMUState *s = vtd_as->iommu_state;
+ int ret = 0;
+
+ switch (attr) {
+ case IOMMU_ATTR_DMA_TRANSLATION:
+ {
+ bool *enabled = data;
+
+ *enabled = s->dma_translation;
+ break;
+ }
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
/* Do the initialization. It will also be called when reset, so pay
* attention when adding new initialization stuff.
*/
@@ -4194,6 +4217,7 @@ 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->get_attr = vtd_iommu_get_attr;
}
static const TypeInfo vtd_iommu_memory_region_info = {
--
2.39.3
- [PATCH v3 00/15] vfio: VFIO migration support with vIOMMU, Joao Martins, 2023/05/30
- [PATCH v3 02/15] hw/pci: Add a pci_setup_iommu_info() helper, Joao Martins, 2023/05/30
- [PATCH v3 01/15] hw/pci: Refactor pci_device_iommu_address_space(), Joao Martins, 2023/05/30
- [PATCH v3 03/15] hw/pci: Add a pci_device_iommu_memory_region() helper, Joao Martins, 2023/05/30
- [PATCH v3 04/15] intel-iommu: Switch to pci_setup_iommu_info(), Joao Martins, 2023/05/30
- [PATCH v3 05/15] vfio/common: Track the IOMMU MR behind the device in addition to the AS, Joao Martins, 2023/05/30
- [PATCH v3 06/15] memory/iommu: Add IOMMU_ATTR_DMA_TRANSLATION attribute, Joao Martins, 2023/05/30
- [PATCH v3 07/15] intel-iommu: Implement get_attr() method,
Joao Martins <=
- [PATCH v3 08/15] vfio/common: Relax vIOMMU detection when DMA translation is off, Joao Martins, 2023/05/30
- [PATCH v3 09/15] memory/iommu: Add IOMMU_ATTR_MAX_IOVA attribute, Joao Martins, 2023/05/30
- [PATCH v3 10/15] intel-iommu: Implement IOMMU_ATTR_MAX_IOVA get_attr() attribute, Joao Martins, 2023/05/30
- [PATCH v3 11/15] vfio/common: Move dirty tracking ranges update to helper, Joao Martins, 2023/05/30
- [PATCH v3 12/15] vfio/common: Support device dirty page tracking with vIOMMU, Joao Martins, 2023/05/30