]> git.proxmox.com Git - mirror_qemu.git/commit - hw/i386/trace-events
intel_iommu: allow dynamic switch of IOMMU region
authorPeter Xu <peterx@redhat.com>
Fri, 7 Apr 2017 10:59:14 +0000 (18:59 +0800)
committerEduardo Habkost <ehabkost@redhat.com>
Thu, 20 Apr 2017 18:22:41 +0000 (15:22 -0300)
commit558e0024a428a8f21605dc8aa026612ccc0f14cd
treed8fda3ec15502eda5fa9b8623c5ee225dce0670a
parentf06a696dc958dd80f7eaf5be66fdefac77741ee0
intel_iommu: allow dynamic switch of IOMMU region

This is preparation work to finally enabled dynamic switching ON/OFF for
VT-d protection. The old VT-d codes is using static IOMMU address space,
and that won't satisfy vfio-pci device listeners.

Let me explain.

vfio-pci devices depend on the memory region listener and IOMMU replay
mechanism to make sure the device mapping is coherent with the guest
even if there are domain switches. And there are two kinds of domain
switches:

  (1) switch from domain A -> B
  (2) switch from domain A -> no domain (e.g., turn DMAR off)

Case (1) is handled by the context entry invalidation handling by the
VT-d replay logic. What the replay function should do here is to replay
the existing page mappings in domain B.

However for case (2), we don't want to replay any domain mappings - we
just need the default GPA->HPA mappings (the address_space_memory
mapping). And this patch helps on case (2) to build up the mapping
automatically by leveraging the vfio-pci memory listeners.

Another important thing that this patch does is to seperate
IR (Interrupt Remapping) from DMAR (DMA Remapping). IR region should not
depend on the DMAR region (like before this patch). It should be a
standalone region, and it should be able to be activated without
DMAR (which is a common behavior of Linux kernel - by default it enables
IR while disabled DMAR).

Reviewed-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: \"Michael S. Tsirkin\" <mst@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <1491562755-23867-9-git-send-email-peterx@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
hw/i386/intel_iommu.c
hw/i386/trace-events
include/hw/i386/intel_iommu.h