]> git.proxmox.com Git - mirror_qemu.git/commit - hw/i386/trace-events
intel-iommu: rework the page walk logic
authorPeter Xu <peterx@redhat.com>
Fri, 18 May 2018 07:25:17 +0000 (15:25 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 23 May 2018 14:34:05 +0000 (17:34 +0300)
commit63b88968f139b6a77f2f81e6f1eedf70c0170a85
tree3aa392b629ecbc71706564d25400baa5a31e09ce
parenteecf5eedbdc0fc04f39abcf3afeedfbf21b25ca4
intel-iommu: rework the page walk logic

This patch fixes a potential small window that the DMA page table might
be incomplete or invalid when the guest sends domain/context
invalidations to a device.  This can cause random DMA errors for
assigned devices.

This is a major change to the VT-d shadow page walking logic. It
includes but is not limited to:

- For each VTDAddressSpace, now we maintain what IOVA ranges we have
  mapped and what we have not.  With that information, now we only send
  MAP or UNMAP when necessary.  Say, we don't send MAP notifies if we
  know we have already mapped the range, meanwhile we don't send UNMAP
  notifies if we know we never mapped the range at all.

- Introduce vtd_sync_shadow_page_table[_range] APIs so that we can call
  in any places to resync the shadow page table for a device.

- When we receive domain/context invalidation, we should not really run
  the replay logic, instead we use the new sync shadow page table API to
  resync the whole shadow page table without unmapping the whole
  region.  After this change, we'll only do the page walk once for each
  domain invalidations (before this, it can be multiple, depending on
  number of notifiers per address space).

While at it, the page walking logic is also refactored to be simpler.

CC: QEMU Stable <qemu-stable@nongnu.org>
Reported-by: Jintack Lim <jintack@cs.columbia.edu>
Tested-by: Jintack Lim <jintack@cs.columbia.edu>
Signed-off-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
hw/i386/trace-events
include/hw/i386/intel_iommu.h