[U-Boot] [PATCH v2 3/4] api: FreeBSD: flush cache before starting loader/kernel
Emmanuel Vadot
manu at bidouilliste.com
Mon Jan 23 13:50:16 CET 2017
Hi Simon,
On Fri, 20 Jan 2017 20:51:54 -0700
Simon Glass <sjg at chromium.org> wrote:
> Hi,
>
> On 17 January 2017 at 08:50, Emmanuel Vadot <manu at bidouilliste.com> wrote:
> > From: Warner Losh <imp at 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 at 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?
In the same thread, Alexander Graf said that since this are just cache
flush it doesn't even need to be FreeBSD/CONFIG specific so I'll do
that on the v3.
> > +
> > 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
--
Emmanuel Vadot <manu at bidouilliste.com> <manu at freebsd.org>
More information about the U-Boot
mailing list