android_kernel_motorola_sm6225/drivers/iommu
Saeed Mirzamohammadi 6a9449e956 iommu/vt-d: Fix agaw for a supported 48 bit guest address width
[ Upstream commit 327d5b2fee91c404a3956c324193892cf2cc9528 ]

The IOMMU driver calculates the guest addressability for a DMA request
based on the value of the mgaw reported from the IOMMU. However, this
is a fused value and as mentioned in the spec, the guest width
should be calculated based on the minimum of supported adjusted guest
address width (SAGAW) and MGAW.

This is from specification:
"Guest addressability for a given DMA request is limited to the
minimum of the value reported through this field and the adjusted
guest address width of the corresponding page-table structure.
(Adjusted guest address widths supported by hardware are reported
through the SAGAW field)."

This causes domain initialization to fail and following
errors appear for EHCI PCI driver:

[    2.486393] ehci-pci 0000:01:00.4: EHCI Host Controller
[    2.486624] ehci-pci 0000:01:00.4: new USB bus registered, assigned bus
number 1
[    2.489127] ehci-pci 0000:01:00.4: DMAR: Allocating domain failed
[    2.489350] ehci-pci 0000:01:00.4: DMAR: 32bit DMA uses non-identity
mapping
[    2.489359] ehci-pci 0000:01:00.4: can't setup: -12
[    2.489531] ehci-pci 0000:01:00.4: USB bus 1 deregistered
[    2.490023] ehci-pci 0000:01:00.4: init 0000:01:00.4 fail, -12
[    2.490358] ehci-pci: probe of 0000:01:00.4 failed with error -12

This issue happens when the value of the sagaw corresponds to a
48-bit agaw. This fix updates the calculation of the agaw based on
the minimum of IOMMU's sagaw value and MGAW.

This issue happens on the code path of getting a private domain for a
device. A private domain was needed when the domain of an iommu group
couldn't meet the requirement of a device. The IOMMU core has been
evolved to eliminate the need for private domain, hence this code path
has alreay been removed from the upstream since commit 327d5b2fee91c
("iommu/vt-d: Allow 32bit devices to uses DMA domain"). Instead of back
porting all patches that are required for removing the private domain,
this simply fixes it in the affected stable kernel between v4.16 and v5.7.

[baolu: The orignal patch could be found here
 https://lore.kernel.org/linux-iommu/20210412202736.70765-1-saeed.mirzamohammadi@oracle.com/.
 I added commit message according to Greg's comments at
 https://lore.kernel.org/linux-iommu/YHZ%2FT9x7Xjf1r6fI@kroah.com/.]

Cc: Joerg Roedel <joro@8bytes.org>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: stable@vger.kernel.org #v4.16+
Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
Tested-by: Camille Lu <camille.lu@hpe.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-26 08:36:42 -04:00
..
amd_iommu.c iommu/amd: Fix sleeping in atomic in increase_address_space() 2021-03-11 14:05:01 +01:00
amd_iommu.h
amd_iommu_debugfs.c
amd_iommu_init.c iommu/amd: Fix over-read of ACPI UID from IVRS table 2020-05-27 17:37:30 +02:00
amd_iommu_proto.h
amd_iommu_quirks.c
amd_iommu_types.h iommu/amd: Set DTE[IntTabLen] to represent 512 IRTEs 2020-12-11 13:25:03 +01:00
amd_iommu_v2.c iommu/amd: Do not use IOMMUv2 functionality when SME is active 2020-09-17 13:45:26 +02:00
arm-smmu-regs.h
arm-smmu-v3.c iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE 2020-02-24 08:34:48 +01:00
arm-smmu.c
dma-iommu.c iommu/dma: Fix MSI reservation allocation 2020-03-18 07:14:22 +01:00
dmar.c iommu/vt-d: Fix sysfs leak in alloc_iommu() 2021-06-03 08:38:02 +02:00
exynos-iommu.c iommu/exynos: add missing put_device() call in exynos_iommu_of_xlate() 2020-10-07 08:00:07 +02:00
fsl_pamu.c
fsl_pamu.h
fsl_pamu_domain.c
fsl_pamu_domain.h
intel-iommu.c iommu/vt-d: Fix agaw for a supported 48 bit guest address width 2021-08-26 08:36:42 -04:00
intel-pasid.c
intel-pasid.h
intel-svm.c iommu/vt-d: Fix mm reference leak 2020-04-23 10:30:21 +02:00
intel_irq_remapping.c iommu/intel: Fix memleak in intel_irq_remapping_alloc 2021-01-17 14:04:22 +01:00
io-pgtable-arm-v7s.c
io-pgtable-arm.c
io-pgtable.c
io-pgtable.h
iommu-debugfs.c iommu: Fix IOMMU debugfs fallout 2020-01-27 14:50:28 +01:00
iommu-sysfs.c
iommu-traces.c
iommu.c iommu: Fix reference count leak in iommu_group_alloc. 2020-06-03 08:19:41 +02:00
iova.c iommu/iova: Don't BUG on invalid PFNs 2020-09-03 11:24:19 +02:00
ipmmu-vmsa.c
irq_remapping.c
irq_remapping.h
Kconfig
Makefile
msm_iommu.c
msm_iommu.h
msm_iommu_hw-8xxx.h
mtk_iommu.c iommu/mediatek: Fix iova_to_phys PA start for 4GB mode 2020-01-27 14:51:07 +01:00
mtk_iommu.h
mtk_iommu_v1.c
of_iommu.c
omap-iommu-debug.c iommu/omap: Check for failure of a call to omap_iommu_dump_ctx 2020-08-21 11:05:36 +02:00
omap-iommu.c
omap-iommu.h
omap-iopgtable.h
qcom_iommu.c iommu/qcom: Fix local_base status check 2020-05-06 08:13:31 +02:00
rockchip-iommu.c iommu: rockchip: Free domain on .domain_free 2020-01-04 19:12:37 +01:00
s390-iommu.c
tegra-gart.c
tegra-smmu.c iommu/tegra-smmu: Fix page tables in > 4 GiB memory 2020-01-04 19:12:38 +01:00