diff mbox series

[U-Boot,4/5] cmd: go: Flush cache before starting

Message ID 20180430083436.72659-1-manu@freebsd.org
State Deferred
Delegated to: Tom Rini
Headers show
Series None | expand

Commit Message

Emmanuel Vadot April 30, 2018, 8:34 a.m. UTC
Some application might load some code at location that contain stale
cache entries. Before running a elf or raw binary, flush the caches
if they are enabled.

Signed-off-by: Emmanuel Vadot <manu@freebsd.org>
---
 cmd/boot.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/cmd/boot.c b/cmd/boot.c
index 72f2cf362d..0b3979f6a5 100644
--- a/cmd/boot.c
+++ b/cmd/boot.c
@@ -19,6 +19,16 @@  __attribute__((weak))
 unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
 				 char * const argv[])
 {
+#if defined(CONFIG_SYS_HAVE_DCACHE_MAINTENANCE) && \
+	!defined(CONFIG_SYS_DCACHE_OFF)
+	if (dcache_status())
+		flush_dcache_all();
+#endif
+#if defined(CONFIG_SYS_HAVE_ICACHE_MAINTENANCE) && \
+	!defined(CONFIG_SYS_ICACHE_OFF)
+	if (icache_status())
+		invalidate_icache_all();
+#endif
 	return entry (argc, argv);
 }