aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2015-08-13 05:56:59 -0400
committerJoerg Roedel <jroedel@suse.de>2015-08-13 13:49:56 -0400
commit543c8dcf1d3762c6fe372acf78eedc8898709106 (patch)
treef563cbc81cb4462f9394e4b9ae5141ff9070d742
parentb690420a406256c83ef2c7e96466052e5cab7676 (diff)
iommu/vt-d: Access iomem correctly
This fixes wrong accesses to iomem introduced by the kdump fixing code. Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--drivers/iommu/intel-iommu.c15
-rw-r--r--drivers/iommu/intel_irq_remapping.c4
2 files changed, 11 insertions, 8 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 93f16aa9eb30..a85077d4335b 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2799,15 +2799,18 @@ static void intel_iommu_init_qi(struct intel_iommu *iommu)
2799} 2799}
2800 2800
2801static int copy_context_table(struct intel_iommu *iommu, 2801static int copy_context_table(struct intel_iommu *iommu,
2802 struct root_entry *old_re, 2802 struct root_entry __iomem *old_re,
2803 struct context_entry **tbl, 2803 struct context_entry **tbl,
2804 int bus, bool ext) 2804 int bus, bool ext)
2805{ 2805{
2806 struct context_entry *old_ce = NULL, *new_ce = NULL, ce;
2807 int tbl_idx, pos = 0, idx, devfn, ret = 0, did; 2806 int tbl_idx, pos = 0, idx, devfn, ret = 0, did;
2807 struct context_entry __iomem *old_ce = NULL;
2808 struct context_entry *new_ce = NULL, ce;
2809 struct root_entry re;
2808 phys_addr_t old_ce_phys; 2810 phys_addr_t old_ce_phys;
2809 2811
2810 tbl_idx = ext ? bus * 2 : bus; 2812 tbl_idx = ext ? bus * 2 : bus;
2813 memcpy_fromio(&re, old_re, sizeof(re));
2811 2814
2812 for (devfn = 0; devfn < 256; devfn++) { 2815 for (devfn = 0; devfn < 256; devfn++) {
2813 /* First calculate the correct index */ 2816 /* First calculate the correct index */
@@ -2827,9 +2830,9 @@ static int copy_context_table(struct intel_iommu *iommu,
2827 2830
2828 ret = 0; 2831 ret = 0;
2829 if (devfn < 0x80) 2832 if (devfn < 0x80)
2830 old_ce_phys = root_entry_lctp(old_re); 2833 old_ce_phys = root_entry_lctp(&re);
2831 else 2834 else
2832 old_ce_phys = root_entry_uctp(old_re); 2835 old_ce_phys = root_entry_uctp(&re);
2833 2836
2834 if (!old_ce_phys) { 2837 if (!old_ce_phys) {
2835 if (ext && devfn == 0) { 2838 if (ext && devfn == 0) {
@@ -2854,7 +2857,7 @@ static int copy_context_table(struct intel_iommu *iommu,
2854 } 2857 }
2855 2858
2856 /* Now copy the context entry */ 2859 /* Now copy the context entry */
2857 ce = old_ce[idx]; 2860 memcpy_fromio(&ce, old_ce + idx, sizeof(ce));
2858 2861
2859 if (!__context_present(&ce)) 2862 if (!__context_present(&ce))
2860 continue; 2863 continue;
@@ -2898,8 +2901,8 @@ out:
2898 2901
2899static int copy_translation_tables(struct intel_iommu *iommu) 2902static int copy_translation_tables(struct intel_iommu *iommu)
2900{ 2903{
2904 struct root_entry __iomem *old_rt;
2901 struct context_entry **ctxt_tbls; 2905 struct context_entry **ctxt_tbls;
2902 struct root_entry *old_rt;
2903 phys_addr_t old_rt_phys; 2906 phys_addr_t old_rt_phys;
2904 int ctxt_table_entries; 2907 int ctxt_table_entries;
2905 unsigned long flags; 2908 unsigned long flags;
diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index 27cdfa84ec5b..9ec4e0d94ffd 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -384,7 +384,7 @@ static int set_msi_sid(struct irte *irte, struct pci_dev *dev)
384 384
385static int iommu_load_old_irte(struct intel_iommu *iommu) 385static int iommu_load_old_irte(struct intel_iommu *iommu)
386{ 386{
387 struct irte *old_ir_table; 387 struct irte __iomem *old_ir_table;
388 phys_addr_t irt_phys; 388 phys_addr_t irt_phys;
389 unsigned int i; 389 unsigned int i;
390 size_t size; 390 size_t size;
@@ -413,7 +413,7 @@ static int iommu_load_old_irte(struct intel_iommu *iommu)
413 return -ENOMEM; 413 return -ENOMEM;
414 414
415 /* Copy data over */ 415 /* Copy data over */
416 memcpy(iommu->ir_table->base, old_ir_table, size); 416 memcpy_fromio(iommu->ir_table->base, old_ir_table, size);
417 417
418 __iommu_flush_cache(iommu, iommu->ir_table->base, size); 418 __iommu_flush_cache(iommu, iommu->ir_table->base, size);
419 419