aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/dma-mapping.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2014-07-17 07:17:45 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-07-17 14:26:08 -0400
commit6b076991dca9817e75c37e2f0db6d52611ea42fa (patch)
tree3dff1d567131ebba9695a1a57896dd3faff9a3e0 /arch/arm/mm/dma-mapping.c
parentcda390bb8f0fc751194ef5f4c691ca8d3ff91009 (diff)
ARM: DMA: ensure that old section mappings are flushed from the TLB
When setting up the CMA region, we must ensure that the old section mappings are flushed from the TLB before replacing them with page tables, otherwise we can suffer from mismatched aliases if the CPU speculatively prefetches from these mappings at an inopportune time. A mismatched alias can occur when the TLB contains a section mapping, but a subsequent prefetch causes it to load a page table mapping, resulting in the possibility of the TLB containing two matching mappings for the same virtual address region. Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/dma-mapping.c')
-rw-r--r--arch/arm/mm/dma-mapping.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 4c88935654ca..1f88db06b133 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -461,12 +461,21 @@ void __init dma_contiguous_remap(void)
461 map.type = MT_MEMORY_DMA_READY; 461 map.type = MT_MEMORY_DMA_READY;
462 462
463 /* 463 /*
464 * Clear previous low-memory mapping 464 * Clear previous low-memory mapping to ensure that the
465 * TLB does not see any conflicting entries, then flush
466 * the TLB of the old entries before creating new mappings.
467 *
468 * This ensures that any speculatively loaded TLB entries
469 * (even though they may be rare) can not cause any problems,
470 * and ensures that this code is architecturally compliant.
465 */ 471 */
466 for (addr = __phys_to_virt(start); addr < __phys_to_virt(end); 472 for (addr = __phys_to_virt(start); addr < __phys_to_virt(end);
467 addr += PMD_SIZE) 473 addr += PMD_SIZE)
468 pmd_clear(pmd_off_k(addr)); 474 pmd_clear(pmd_off_k(addr));
469 475
476 flush_tlb_kernel_range(__phys_to_virt(start),
477 __phys_to_virt(end));
478
470 iotable_init(&map, 1); 479 iotable_init(&map, 1);
471 } 480 }
472} 481}