qemu/hw/i386
Peter Xu 63b88968f1 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>
2018-05-23 17:34:05 +03:00
..
kvm x86/cpu: use standard-headers/asm-x86.kvm_para.h 2018-05-23 03:14:41 +03:00
xen xen: Use newly added dmops for mapping VGA memory 2018-04-26 16:29:51 +01:00
acpi-build.c pc: rename "hotplug memory" terminology to "device memory" 2018-05-07 10:00:02 -03:00
acpi-build.h Use scripts/clean-includes to drop redundant qemu/typedefs.h 2016-03-22 22:20:16 +01:00
amd_iommu.c x86_iommu: Move machine check to x86_iommu_realize() 2018-01-18 21:52:38 +02:00
amd_iommu.h amd_iommu: avoid needless includes in header file 2017-12-18 17:07:02 +03:00
intel_iommu_internal.h intel-iommu: Extend address width to 48 bits 2018-01-18 21:52:38 +02:00
intel_iommu.c intel-iommu: rework the page walk logic 2018-05-23 17:34:05 +03:00
kvmvapic.c mttcg/i386: Patch instruction using async_safe_* framework 2017-07-14 12:04:35 +02:00
Makefile.objs hw/i386: make IOMMUs configurable via default-configs/ 2018-03-12 16:12:46 +01:00
multiboot.c opts: don't silently truncate long option values 2018-05-09 00:13:39 +02:00
multiboot.h refer to FWCfgState explicitly 2013-06-02 18:14:02 +03:00
pc_piix.c pc: add 2.13 machine types 2018-05-15 11:33:33 -03:00
pc_q35.c pc: add 2.13 machine types 2018-05-15 11:33:33 -03:00
pc_sysfw.c target/i386: encrypt bios rom 2018-03-13 17:36:05 +01:00
pc.c make sure that we aren't overwriting mc->get_hotplug_handler by accident 2018-05-10 18:10:56 +01:00
trace-events intel-iommu: rework the page walk logic 2018-05-23 17:34:05 +03:00
vmmouse.c hw/input/i8042: Extract declarations from i386/pc.h into input/i8042.h 2018-03-12 16:12:48 +01:00
vmport.c hw/input/i8042: Extract declarations from i386/pc.h into input/i8042.h 2018-03-12 16:12:48 +01:00
x86-iommu.c x86_iommu: check if machine has PCI bus 2018-01-18 21:52:38 +02:00