Skip to content

Commit 87b8680

Browse files
sohilmehgregkh
authored andcommitted
iommu/vt-d: Handle domain agaw being less than iommu agaw
commit 3569dd0 upstream. The Intel IOMMU driver opportunistically skips a few top level page tables from the domain paging directory while programming the IOMMU context entry. However there is an implicit assumption in the code that domain's adjusted guest address width (agaw) would always be greater than IOMMU's agaw. The IOMMU capabilities in an upcoming platform cause the domain's agaw to be lower than IOMMU's agaw. The issue is seen when the IOMMU supports both 4-level and 5-level paging. The domain builds a 4-level page table based on agaw of 2. However the IOMMU's agaw is set as 3 (5-level). In this case the code incorrectly tries to skip page page table levels. This causes the IOMMU driver to avoid programming the context entry. The fix handles this case and programs the context entry accordingly. Fixes: de24e55 ("iommu/vt-d: Simplify domain_context_mapping_one") Cc: <stable@vger.kernel.org> Cc: Ashok Raj <ashok.raj@intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reported-by: Ramos Falcon, Ernesto R <ernesto.r.ramos.falcon@intel.com> Tested-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> Signed-off-by: Sohil Mehta <sohil.mehta@intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f408aac commit 87b8680

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/iommu/intel-iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
20692069
* than default. Unnecessary for PT mode.
20702070
*/
20712071
if (translation != CONTEXT_TT_PASS_THROUGH) {
2072-
for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) {
2072+
for (agaw = domain->agaw; agaw > iommu->agaw; agaw--) {
20732073
ret = -ENOMEM;
20742074
pgd = phys_to_virt(dma_pte_addr(pgd));
20752075
if (!dma_pte_present(pgd))
@@ -2083,7 +2083,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
20832083
translation = CONTEXT_TT_MULTI_LEVEL;
20842084

20852085
context_set_address_root(context, virt_to_phys(pgd));
2086-
context_set_address_width(context, iommu->agaw);
2086+
context_set_address_width(context, agaw);
20872087
} else {
20882088
/*
20892089
* In pass through mode, AW must be programmed to

0 commit comments

Comments
 (0)