Commit a16dad77 authored by Ralf Baechle's avatar Ralf Baechle

MIPS: Fix potencial corruption

Normally r4k_dma_cache_inv should only ever be called with cacheline
aligned addresses.  If however, it isn't there is the theoretical
possibility of data corruption.  There is no correct way of handling this
and anyway, it should only happen if the DMA API is used incorrectly
so drop

There is a different corruption scenario with these CACHE instructions
removed but again there is no way of handling this correctly and it can
be triggered only through incorrect use of the DMA API.

So just get rid of the complexity.
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
Reported-by: default avatarJames Rodriguez <jamesr@juniper.net>
parent 51d943f0
...@@ -632,9 +632,6 @@ static void r4k_dma_cache_inv(unsigned long addr, unsigned long size) ...@@ -632,9 +632,6 @@ static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
if (size >= scache_size) if (size >= scache_size)
r4k_blast_scache(); r4k_blast_scache();
else { else {
unsigned long lsize = cpu_scache_line_size();
unsigned long almask = ~(lsize - 1);
/* /*
* There is no clearly documented alignment requirement * There is no clearly documented alignment requirement
* for the cache instruction on MIPS processors and * for the cache instruction on MIPS processors and
...@@ -643,9 +640,6 @@ static void r4k_dma_cache_inv(unsigned long addr, unsigned long size) ...@@ -643,9 +640,6 @@ static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
* hit ops with insufficient alignment. Solved by * hit ops with insufficient alignment. Solved by
* aligning the address to cache line size. * aligning the address to cache line size.
*/ */
cache_op(Hit_Writeback_Inv_SD, addr & almask);
cache_op(Hit_Writeback_Inv_SD,
(addr + size - 1) & almask);
blast_inv_scache_range(addr, addr + size); blast_inv_scache_range(addr, addr + size);
} }
__sync(); __sync();
...@@ -655,12 +649,7 @@ static void r4k_dma_cache_inv(unsigned long addr, unsigned long size) ...@@ -655,12 +649,7 @@ static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
if (cpu_has_safe_index_cacheops && size >= dcache_size) { if (cpu_has_safe_index_cacheops && size >= dcache_size) {
r4k_blast_dcache(); r4k_blast_dcache();
} else { } else {
unsigned long lsize = cpu_dcache_line_size();
unsigned long almask = ~(lsize - 1);
R4600_HIT_CACHEOP_WAR_IMPL; R4600_HIT_CACHEOP_WAR_IMPL;
cache_op(Hit_Writeback_Inv_D, addr & almask);
cache_op(Hit_Writeback_Inv_D, (addr + size - 1) & almask);
blast_inv_dcache_range(addr, addr + size); blast_inv_dcache_range(addr, addr + size);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment