From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 26 Jul 2016 15:18:54 +0200
Subject: iommu/amd: Update Alias-DTE in update_device_table()
Git-commit: 3254de6bf74fe94c197c9f819fe62a3a3c36f073
Patch-mainline: v4.8-rc1
References: bsc#1106105

Not doing so might cause IO-Page-Faults when a device uses
an alias request-id and the alias-dte is left in a lower
page-mode which does not cover the address allocated from
the iova-allocator.

Fixes: 492667dacc0a ('x86/amd-iommu: Remove amd_iommu_pd_table')
Cc: stable@vger.kernel.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/amd_iommu.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1900,7 +1900,14 @@ static void update_device_table(struct p
 	list_for_each_entry(dev_data, &domain->dev_list, list) {
 		struct pci_dev *pdev = to_pci_dev(dev_data->dev);
 		u16 devid = get_device_id(dev_data->dev);
+		u16 alias = get_device_id(dev_data->alias);
 		set_dte_entry(devid, domain, pci_ats_enabled(pdev));
+
+		if (devid == alias)
+			continue;
+
+		/* There is an alias, update device table entry for it */
+		set_dte_entry(alias, domain, pci_ats_enabled(pdev));
 	}
 }
 
