kernel_optimize_test/drivers/iommu
Singh, Brijesh b3e9b515b0 iommu/amd: Clear memory encryption mask from physical address
Boris Ostrovsky reported a memory leak with device passthrough when SME
is active.

The VFIO driver uses iommu_iova_to_phys() to get the physical address for
an iova. This physical address is later passed into vfio_unmap_unpin() to
unpin the memory. The vfio_unmap_unpin() uses pfn_valid() before unpinning
the memory. The pfn_valid() check was failing because encryption mask was
part of the physical address returned. This resulted in the memory not
being unpinned and therefore leaked after the guest terminates.

The memory encryption mask must be cleared from the physical address in
iommu_iova_to_phys().

Fixes: 2543a786aa ("iommu/amd: Allow the AMD IOMMU to work with memory encryption")
Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: <iommu@lists.linux-foundation.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: <stable@vger.kernel.org> # 4.14+
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
2018-10-05 10:20:24 +02:00
..
amd_iommu_debugfs.c
amd_iommu_init.c Merge branches 'arm/shmobile', 'arm/renesas', 'arm/msm', 'arm/smmu', 'arm/omap', 'x86/amd', 'x86/vt-d' and 'core' into next 2018-08-08 12:02:27 +02:00
amd_iommu_proto.h
amd_iommu_types.h Merge branches 'arm/shmobile', 'arm/renesas', 'arm/msm', 'arm/smmu', 'arm/omap', 'x86/amd', 'x86/vt-d' and 'core' into next 2018-08-08 12:02:27 +02:00
amd_iommu_v2.c mm: convert return type of handle_mm_fault() caller to vm_fault_t 2018-08-17 16:20:28 -07:00
amd_iommu.c iommu/amd: Clear memory encryption mask from physical address 2018-10-05 10:20:24 +02:00
arm-smmu-regs.h
arm-smmu-v3.c IOMMU Update for Linux v4.19 2018-08-24 13:10:38 -07:00
arm-smmu.c IOMMU Update for Linux v4.19 2018-08-24 13:10:38 -07:00
dma-iommu.c iommu/dma: Respect bus DMA limit for IOVAs 2018-07-27 19:01:06 +02:00
dmar.c
exynos-iommu.c IOMMU Update for Linux v4.19 2018-08-24 13:10:38 -07:00
fsl_pamu_domain.c
fsl_pamu_domain.h
fsl_pamu.c
fsl_pamu.h
intel_irq_remapping.c
intel-iommu.c iommu/vt-d: Handle memory shortage on pasid table allocation 2018-09-25 14:33:02 +02:00
intel-pasid.c
intel-pasid.h iommu/vt-d: Handle memory shortage on pasid table allocation 2018-09-25 14:33:02 +02:00
intel-svm.c IOMMU Update for Linux v4.19 2018-08-24 13:10:38 -07:00
io-pgtable-arm-v7s.c
io-pgtable-arm.c
io-pgtable.c
io-pgtable.h
iommu-debugfs.c
iommu-sysfs.c
iommu-traces.c
iommu.c iommu: Remove the ->map_sg indirection 2018-08-08 11:06:20 +02:00
iova.c
ipmmu-vmsa.c IOMMU Update for Linux v4.19 2018-08-24 13:10:38 -07:00
irq_remapping.c
irq_remapping.h
Kconfig Merge branches 'arm/shmobile', 'arm/renesas', 'arm/msm', 'arm/smmu', 'arm/omap', 'x86/amd', 'x86/vt-d' and 'core' into next 2018-08-08 12:02:27 +02:00
Makefile Merge branches 'arm/shmobile', 'arm/renesas', 'arm/msm', 'arm/smmu', 'arm/omap', 'x86/amd', 'x86/vt-d' and 'core' into next 2018-08-08 12:02:27 +02:00
msm_iommu_hw-8xxx.h
msm_iommu.c IOMMU Update for Linux v4.19 2018-08-24 13:10:38 -07:00
msm_iommu.h
mtk_iommu_v1.c iommu: Remove the ->map_sg indirection 2018-08-08 11:06:20 +02:00
mtk_iommu.c iommu: Remove the ->map_sg indirection 2018-08-08 11:06:20 +02:00
mtk_iommu.h
of_iommu.c
omap-iommu-debug.c
omap-iommu.c Merge branches 'arm/shmobile', 'arm/renesas', 'arm/msm', 'arm/smmu', 'arm/omap', 'x86/amd', 'x86/vt-d' and 'core' into next 2018-08-08 12:02:27 +02:00
omap-iommu.h
omap-iopgtable.h
qcom_iommu.c IOMMU Update for Linux v4.19 2018-08-24 13:10:38 -07:00
rockchip-iommu.c iommu/rockchip: Free irqs in shutdown handler 2018-09-25 11:13:34 +02:00
s390-iommu.c
tegra-gart.c iommu: Remove the ->map_sg indirection 2018-08-08 11:06:20 +02:00
tegra-smmu.c iommu: Remove the ->map_sg indirection 2018-08-08 11:06:20 +02:00