[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 38/41] hw/i386/intel-iommu: Migrate to 3-phase reset
From: |
Michael S. Tsirkin |
Subject: |
[PULL 38/41] hw/i386/intel-iommu: Migrate to 3-phase reset |
Date: |
Fri, 21 Feb 2025 07:24:41 -0500 |
From: Eric Auger <eric.auger@redhat.com>
Currently the IOMMU may be reset before the devices
it protects. For example this happens with virtio devices
but also with VFIO devices. In this latter case this
produces spurious translation faults on host.
Let's use 3-phase reset mechanism and reset the IOMMU on
exit phase after all DMA capable devices have been reset
on 'enter' or 'hold' phase.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Zhenzhong Duan <zhenzhong.duan@intel.com>
Message-Id: <20250218182737.76722-3-eric.auger@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/intel_iommu.c | 12 +++++++++---
hw/i386/trace-events | 1 +
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index f366c223d0..a5cf2d0e81 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -4697,10 +4697,11 @@ static void vtd_init(IntelIOMMUState *s)
/* Should not reset address_spaces when reset because devices will still use
* the address space they got at first (won't ask the bus again).
*/
-static void vtd_reset(DeviceState *dev)
+static void vtd_reset_exit(Object *obj, ResetType type)
{
- IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
+ IntelIOMMUState *s = INTEL_IOMMU_DEVICE(obj);
+ trace_vtd_reset_exit();
vtd_init(s);
vtd_address_space_refresh_all(s);
}
@@ -4864,8 +4865,13 @@ static void vtd_class_init(ObjectClass *klass, void
*data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
X86IOMMUClass *x86_class = X86_IOMMU_DEVICE_CLASS(klass);
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
- device_class_set_legacy_reset(dc, vtd_reset);
+ /*
+ * Use 'exit' reset phase to make sure all DMA requests
+ * have been quiesced during 'enter' or 'hold' phase
+ */
+ rc->phases.exit = vtd_reset_exit;
dc->vmsd = &vtd_vmstate;
device_class_set_props(dc, vtd_properties);
dc->hotpluggable = false;
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
index 53c02d7ac8..ac9e1a10aa 100644
--- a/hw/i386/trace-events
+++ b/hw/i386/trace-events
@@ -68,6 +68,7 @@ vtd_frr_new(int index, uint64_t hi, uint64_t lo) "index %d
high 0x%"PRIx64" low
vtd_warn_invalid_qi_tail(uint16_t tail) "tail 0x%"PRIx16
vtd_warn_ir_vector(uint16_t sid, int index, int vec, int target) "sid
0x%"PRIx16" index %d vec %d (should be: %d)"
vtd_warn_ir_trigger(uint16_t sid, int index, int trig, int target) "sid
0x%"PRIx16" index %d trigger %d (should be: %d)"
+vtd_reset_exit(void) ""
# amd_iommu.c
amdvi_evntlog_fail(uint64_t addr, uint32_t head) "error: fail to write at addr
0x%"PRIx64" + offset 0x%"PRIx32
--
MST
- [PULL 31/41] cryptodev/vhost: allocate CryptoDevBackendVhost using g_mem0(), (continued)
- [PULL 31/41] cryptodev/vhost: allocate CryptoDevBackendVhost using g_mem0(), Michael S. Tsirkin, 2025/02/21
- [PULL 29/41] vhost-iova-tree, svq: Implement GPA->IOVA & partial IOVA->HVA trees, Michael S. Tsirkin, 2025/02/21
- [PULL 32/41] MAINTAINERS: add more files to `vhost`, Michael S. Tsirkin, 2025/02/21
- [PULL 33/41] vdpa: Fix endian bugs in shadow virtqueue, Michael S. Tsirkin, 2025/02/21
- [PULL 30/41] vhost-iova-tree: Update documentation, Michael S. Tsirkin, 2025/02/21
- [PULL 13/41] pcie_sriov: Register VFs after migration, Michael S. Tsirkin, 2025/02/21
- [PULL 34/41] hw/virtio/virtio-nsm: Respond with correct length, Michael S. Tsirkin, 2025/02/21
- [PULL 35/41] net: vhost-user: add QAPI events to report connection state, Michael S. Tsirkin, 2025/02/21
- [PULL 36/41] vhost-user-snd: correct the calculation of config_size, Michael S. Tsirkin, 2025/02/21
- [PULL 37/41] hw/virtio/virtio-iommu: Migrate to 3-phase reset, Michael S. Tsirkin, 2025/02/21
- [PULL 38/41] hw/i386/intel-iommu: Migrate to 3-phase reset,
Michael S. Tsirkin <=
- [PULL 39/41] hw/arm/smmuv3: Move reset to exit phase, Michael S. Tsirkin, 2025/02/21
- [PULL 40/41] hw/vfio/common: Add a trace point in vfio_reset_handler, Michael S. Tsirkin, 2025/02/21
- [PULL 41/41] docs/devel/reset: Document reset expectations for DMA and IOMMU, Michael S. Tsirkin, 2025/02/21
- [PULL 21/41] hw/mem/cxl_type3: Add paired msix_uninit_exclusive_bar() call, Michael S. Tsirkin, 2025/02/21
- Re: [PULL 00/41] virtio,pc,pci: features, fixes, cleanups, Stefan Hajnoczi, 2025/02/21