]> git.itanic.dy.fi Git - linux-stable/commit
iommu/vt-d: Correctly calculate sagaw value of IOMMU
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 23 Aug 2022 06:15:55 +0000 (14:15 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Sep 2022 10:38:31 +0000 (12:38 +0200)
commit0a81ddfc20cce49606c1aadc8c6171cb1d4fe273
treebbb817a49d36557086ba912f01b00bd6adac4475
parent5ce1b0a0c27cd38ee908e5ac581ead717943632b
iommu/vt-d: Correctly calculate sagaw value of IOMMU

[ Upstream commit 53fc7ad6edf210b497230ce74b61b322a202470c ]

The Intel IOMMU driver possibly selects between the first-level and the
second-level translation tables for DMA address translation. However,
the levels of page-table walks for the 4KB base page size are calculated
from the SAGAW field of the capability register, which is only valid for
the second-level page table. This causes the IOMMU driver to stop working
if the hardware (or the emulated IOMMU) advertises only first-level
translation capability and reports the SAGAW field as 0.

This solves the above problem by considering both the first level and the
second level when calculating the supported page table levels.

Fixes: b802d070a52a1 ("iommu/vt-d: Use iova over first level")
Cc: stable@vger.kernel.org
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20220817023558.3253263-1-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/intel/iommu.c