[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 6/6] intel_iommu: Block migration if cap is updated
From: |
Zhenzhong Duan |
Subject: |
[PATCH v1 6/6] intel_iommu: Block migration if cap is updated |
Date: |
Wed, 28 Feb 2024 17:44:32 +0800 |
When there is VFIO device and vIOMMU cap/ecap is updated based on host
IOMMU cap/ecap, migration should be blocked.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
hw/i386/intel_iommu.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index e474284e43..9ca47dbf9a 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -40,6 +40,7 @@
#include "hw/i386/apic_internal.h"
#include "kvm/kvm_i386.h"
#include "migration/vmstate.h"
+#include "migration/blocker.h"
#include "trace.h"
#define S_AW_BITS (VTD_MGAW_FROM_CAP(s->cap) + 1)
@@ -3830,6 +3831,8 @@ static int vtd_check_legacy_hdev(IntelIOMMUState *s,
return 0;
}
+static Error *vtd_mig_blocker;
+
static int vtd_check_iommufd_hdev(IntelIOMMUState *s,
IOMMUFDDevice *idev,
Error **errp)
@@ -3861,8 +3864,17 @@ static int vtd_check_iommufd_hdev(IntelIOMMUState *s,
tmp_cap |= VTD_CAP_MGAW(host_mgaw + 1);
}
- s->cap = tmp_cap;
- return 0;
+ if (s->cap != tmp_cap) {
+ if (vtd_mig_blocker == NULL) {
+ error_setg(&vtd_mig_blocker,
+ "cap/ecap update from host IOMMU block migration");
+ ret = migrate_add_blocker(&vtd_mig_blocker, errp);
+ }
+ if (!ret) {
+ s->cap = tmp_cap;
+ }
+ }
+ return ret;
}
static int vtd_check_hdev(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hdev,
--
2.34.1
- [PATCH v1 0/6] Check and sync host IOMMU cap/ecap with vIOMMU, Zhenzhong Duan, 2024/02/28
- [PATCH v1 1/6] intel_iommu: Add set/unset_iommu_device callback, Zhenzhong Duan, 2024/02/28
- [PATCH v1 2/6] intel_iommu: Extract out vtd_cap_init to initialize cap/ecap, Zhenzhong Duan, 2024/02/28
- [PATCH v1 3/6] intel_iommu: Add a framework to check and sync host IOMMU cap/ecap, Zhenzhong Duan, 2024/02/28
- [PATCH v1 4/6] intel_iommu: Implement check and sync mechanism in iommufd mode, Zhenzhong Duan, 2024/02/28
- [PATCH v1 5/6] intel_iommu: Use mgaw instead of s->aw_bits, Zhenzhong Duan, 2024/02/28
- [PATCH v1 6/6] intel_iommu: Block migration if cap is updated,
Zhenzhong Duan <=