iommu/vt-d: Fix iotlb psi missing for mappings
authorPeter Xu <peterx@redhat.com>
Fri, 4 May 2018 02:34:53 +0000 (10:34 +0800)
committerJoerg Roedel <jroedel@suse.de>
Tue, 15 May 2018 14:31:41 +0000 (16:31 +0200)
commit87684fd997a6f12486bb0a638c7dba3130afb376
tree7901692aa08cba54a1c44d4c7328fb39785c7565
parenteed91a0b85e55bcda8849d191604537b9933594f
iommu/vt-d: Fix iotlb psi missing for mappings

When caching mode is enabled for IOMMU, we should send explicit IOTLB
PSIs even for newly created mappings.  However these events are missing
for all intel_iommu_map() callers, e.g., iommu_map().  One direct user
is the vfio-pci driver.

To make sure we'll send the PSIs always when necessary, this patch
firstly introduced domain_mapping() helper for page mappings, then fixed
the problem by generalizing the explicit map IOTLB PSI logic into that
new helper. With that, we let iommu_domain_identity_map() to use the
simplified version to avoid sending the notifications, while for all the
rest of cases we send the notifications always.

For VM case, we send the PSIs to all the backend IOMMUs for the domain.

This patch allows the nested device assignment to work with QEMU (assign
device firstly to L1 guest, then assign it again to L2 guest).

Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel-iommu.c