[U-Boot] [PATCH] ARM v7: Flush icache when executing a program with go

ARM v7 runs with icache enabled. For reliable results the go command needs to flush the icache before jumping or it may risk running cached instructions that differ from what currently is in memory.
--- arch/arm/cpu/armv7/Makefile | 1 + arch/arm/cpu/armv7/cmd_boot.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-) create mode 100644 arch/arm/cpu/armv7/cmd_boot.c
diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index 4fdbee4..da1b5e8 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -31,6 +31,7 @@ COBJS += cache_v7.o
COBJS += cpu.o COBJS += syslib.o +COBJS += cmd_boot.o
ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA20),) SOBJS += lowlevel_init.o diff --git a/arch/arm/cpu/armv7/cmd_boot.c b/arch/arm/cpu/armv7/cmd_boot.c new file mode 100644 index 0000000..6758a55 --- /dev/null +++ b/arch/arm/cpu/armv7/cmd_boot.c @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2000-2003 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * Misc boot support + */ +#include <common.h> +#include <command.h> + +#ifdef CONFIG_CMD_GO +unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, + char * const argv[]) +{ + invalidate_icache_all(); + return entry(argc, argv); +} +#endif

Dear Henrik Nordström,
In message 1353842010.17518.3.camel@home.hno.se you wrote:
ARM v7 runs with icache enabled. For reliable results the go command needs to flush the icache before jumping or it may risk running cached instructions that differ from what currently is in memory.
This should never be an architecutre specific thing. Whether we flush caches or not should be the same on all architectures.
+#ifdef CONFIG_CMD_GO +unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
char * const argv[])
+{
- invalidate_icache_all();
- return entry(argc, argv);
+}
We really need a prototype for this function in a global header file.
Best regards,
Wolfgang Denk

sön 2012-11-25 klockan 18:41 +0100 skrev Wolfgang Denk:
Dear Henrik Nordström,
In message 1353842010.17518.3.camel@home.hno.se you wrote:
ARM v7 runs with icache enabled. For reliable results the go command needs to flush the icache before jumping or it may risk running cached instructions that differ from what currently is in memory.
This should never be an architecutre specific thing. Whether we flush caches or not should be the same on all architectures.
Agreed.
But this needs some "flush icache if supported & enabled for current arch" function that do not yell loudly if icache not supported/enabled. invalidate_icache_all() yells loudly if not implememented by the current arch.
Regards Henrik
participants (2)
-
Henrik Nordström
-
Wolfgang Denk