linux-mips
[Top] [All Lists]

[PATCH 50/58] MIPS: mm: c-r4k: Flush scache to avoid cache aliases

To: <linux-mips@linux-mips.org>
Subject: [PATCH 50/58] MIPS: mm: c-r4k: Flush scache to avoid cache aliases
From: Markos Chandras <markos.chandras@imgtec.com>
Date: Mon, 27 Jan 2014 20:19:37 +0000
Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>, Markos Chandras <markos.chandras@imgtec.com>
In-reply-to: <1390853985-14246-1-git-send-email-markos.chandras@imgtec.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1390853985-14246-1-git-send-email-markos.chandras@imgtec.com>
Sender: linux-mips-bounce@linux-mips.org
From: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>

There is a chance for the secondary cache to have memory
aliases. This can happen if the bootloader is in a non-EVA mode
(or even in EVA mode but with different mapping from the kernel)
and the kernel switching to EVA afterwards. It's best to flush
the icache to avoid having the secondary CPUs fetching stale
data from it.

Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
 arch/mips/mm/c-r4k.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 5f8da6a..9761dfa 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -633,6 +633,17 @@ static inline void local_r4k_flush_icache_range(unsigned 
long start, unsigned lo
                        break;
                }
        }
+#ifdef CONFIG_EVA
+       /*
+        * Due to all possible segment mappings, there might cache aliases
+        * caused by the bootloader being in non-EVA mode, and the CPU switching
+        * to EVA during early kernel init. It's best to flush the scache
+        * to avoid having secondary cores fetching stale data and lead to
+        * kernel crashes.
+        */
+       bc_wback_inv(start, (end - start));
+       __sync();
+#endif
 }
 
 static inline void local_r4k_flush_icache_range_ipi(void *args)
-- 
1.8.5.3



<Prev in Thread] Current Thread [Next in Thread>