
Hi,
On 17 January 2017 at 08:50, Emmanuel Vadot manu@bidouilliste.com wrote:
From: Warner Losh imp@freebsd.org
FreeBSD loader(8) just loaded code to some random location that may contain stale icache entries. FreeBSD Kernel needs the icache and dcache flushed. Before running either one of them, flush the icache and dcache.
Signed-off-by: Emmanuel Vadot manu@bidouilliste.com
api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/api/api.c b/api/api.c index 8a1433af78..cc25deca09 100644 --- a/api/api.c +++ b/api/api.c @@ -290,6 +290,11 @@ static int API_dev_close(va_list ap) if (!err) di->state = DEV_STA_CLOSED;
+#ifdef CONFIG_FREEBSD
flush_dcache_all();
invalidate_icache_all();
+#endif
It's not nice IMO to add OS-specific #ifdefs to generic code. Can you instead define a Kconfig option with a sensible name, and have FreeBSD define it?
return err;
}
diff --git a/cmd/boot.c b/cmd/boot.c index 72f2cf362d..a1a91fbf0a 100644 --- a/cmd/boot.c +++ b/cmd/boot.c @@ -19,6 +19,11 @@ __attribute__((weak)) unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, char * const argv[]) { +#ifdef CONFIG_FREEBSD
flush_dcache_all();
invalidate_icache_all();
+#endif
return entry (argc, argv);
}
Regards, Simon