* [U-Boot] [PATCH] api: bootelf: go: flush cache before starting
@ 2017-12-04 18:33 Emmanuel Vadot
2018-01-09 20:59 ` [U-Boot] " Tom Rini
0 siblings, 1 reply; 3+ messages in thread
From: Emmanuel Vadot @ 2017-12-04 18:33 UTC (permalink / raw)
To: u-boot
From: Warner Losh <imp@freebsd.org>
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.
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
---
api/api.c | 5 +++++
cmd/boot.c | 4 ++++
cmd/elf.c | 5 +++++
3 files changed, 14 insertions(+)
diff --git a/api/api.c b/api/api.c
index 7eee2fc083..853a3f7b0a 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;
+ if (dcache_status())
+ flush_dcache_all();
+ if (icache_status())
+ invalidate_icache_all();
+
return err;
}
diff --git a/cmd/boot.c b/cmd/boot.c
index 72f2cf362d..b66ae67fcb 100644
--- a/cmd/boot.c
+++ b/cmd/boot.c
@@ -19,6 +19,10 @@ __attribute__((weak))
unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
char * const argv[])
{
+ if (dcache_status())
+ flush_dcache_all();
+ if (icache_status())
+ invalidate_icache_all();
return entry (argc, argv);
}
diff --git a/cmd/elf.c b/cmd/elf.c
index 5745a389da..5126c0e57d 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -109,6 +109,11 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
{
unsigned long ret;
+ if (dcache_status())
+ flush_dcache_all();
+ if (icache_status())
+ invalidate_icache_all();
+
/*
* pass address parameter as argv[0] (aka command name),
* and all remaining args
--
2.15.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] api: bootelf: go: flush cache before starting
2017-12-04 18:33 [U-Boot] [PATCH] api: bootelf: go: flush cache before starting Emmanuel Vadot
@ 2018-01-09 20:59 ` Tom Rini
2018-01-12 12:53 ` Emmanuel Vadot
0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2018-01-09 20:59 UTC (permalink / raw)
To: u-boot
On Mon, Dec 04, 2017 at 07:33:45PM +0100, Emmanuel Vadot wrote:
> From: Warner Losh <imp@freebsd.org>
>
> 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.
>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
> ---
> api/api.c | 5 +++++
> cmd/boot.c | 4 ++++
> cmd/elf.c | 5 +++++
> 3 files changed, 14 insertions(+)
>
> diff --git a/api/api.c b/api/api.c
> index 7eee2fc083..853a3f7b0a 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;
>
> + if (dcache_status())
> + flush_dcache_all();
> + if (icache_status())
> + invalidate_icache_all();
> +
> return err;
> }
>
> diff --git a/cmd/boot.c b/cmd/boot.c
> index 72f2cf362d..b66ae67fcb 100644
> --- a/cmd/boot.c
> +++ b/cmd/boot.c
> @@ -19,6 +19,10 @@ __attribute__((weak))
> unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
> char * const argv[])
> {
> + if (dcache_status())
> + flush_dcache_all();
> + if (icache_status())
> + invalidate_icache_all();
> return entry (argc, argv);
> }
>
> diff --git a/cmd/elf.c b/cmd/elf.c
> index 5745a389da..5126c0e57d 100644
> --- a/cmd/elf.c
> +++ b/cmd/elf.c
> @@ -109,6 +109,11 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
> {
> unsigned long ret;
>
> + if (dcache_status())
> + flush_dcache_all();
> + if (icache_status())
> + invalidate_icache_all();
> +
> /*
> * pass address parameter as argv[0] (aka command name),
> * and all remaining args
We do not have these flushes on all architectures, so as is travis-ci
would fail, as does 'make tests'. Thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180109/3f2cd15f/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] api: bootelf: go: flush cache before starting
2018-01-09 20:59 ` [U-Boot] " Tom Rini
@ 2018-01-12 12:53 ` Emmanuel Vadot
0 siblings, 0 replies; 3+ messages in thread
From: Emmanuel Vadot @ 2018-01-12 12:53 UTC (permalink / raw)
To: u-boot
On Tue, 9 Jan 2018 15:59:23 -0500
Tom Rini <trini@konsulko.com> wrote:
> On Mon, Dec 04, 2017 at 07:33:45PM +0100, Emmanuel Vadot wrote:
>
> > From: Warner Losh <imp@freebsd.org>
> >
> > 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.
> >
> > Reviewed-by: Tom Rini <trini@konsulko.com>
> > Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
> > ---
> > api/api.c | 5 +++++
> > cmd/boot.c | 4 ++++
> > cmd/elf.c | 5 +++++
> > 3 files changed, 14 insertions(+)
> >
> > diff --git a/api/api.c b/api/api.c
> > index 7eee2fc083..853a3f7b0a 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;
> >
> > + if (dcache_status())
> > + flush_dcache_all();
> > + if (icache_status())
> > + invalidate_icache_all();
> > +
> > return err;
> > }
> >
> > diff --git a/cmd/boot.c b/cmd/boot.c
> > index 72f2cf362d..b66ae67fcb 100644
> > --- a/cmd/boot.c
> > +++ b/cmd/boot.c
> > @@ -19,6 +19,10 @@ __attribute__((weak))
> > unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
> > char * const argv[])
> > {
> > + if (dcache_status())
> > + flush_dcache_all();
> > + if (icache_status())
> > + invalidate_icache_all();
> > return entry (argc, argv);
> > }
> >
> > diff --git a/cmd/elf.c b/cmd/elf.c
> > index 5745a389da..5126c0e57d 100644
> > --- a/cmd/elf.c
> > +++ b/cmd/elf.c
> > @@ -109,6 +109,11 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
> > {
> > unsigned long ret;
> >
> > + if (dcache_status())
> > + flush_dcache_all();
> > + if (icache_status())
> > + invalidate_icache_all();
> > +
> > /*
> > * pass address parameter as argv[0] (aka command name),
> > * and all remaining args
>
> We do not have these flushes on all architectures, so as is travis-ci
> would fail, as does 'make tests'. Thanks!
Yes sorry,
I have a v2 lying around for quite some time now, I'll send it soon.
--
Emmanuel Vadot <manu@bidouilliste.com> <manu@freebsd.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-12 12:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-04 18:33 [U-Boot] [PATCH] api: bootelf: go: flush cache before starting Emmanuel Vadot
2018-01-09 20:59 ` [U-Boot] " Tom Rini
2018-01-12 12:53 ` Emmanuel Vadot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox