All of lore.kernel.org
 help / color / mirror / Atom feed
From: Emmanuel Vadot <manu@bidouilliste.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 3/4] api: FreeBSD: flush cache before starting loader/kernel
Date: Tue, 17 Jan 2017 21:45:44 +0100	[thread overview]
Message-ID: <20170117214544.e5462938e21e4c7ce1cccd5b@bidouilliste.com> (raw)
In-Reply-To: <6a101188-aca5-a302-b287-f0b110b4de5c@suse.de>

On Tue, 17 Jan 2017 21:13:51 +0100
Alexander Graf <agraf@suse.de> wrote:

> 
> 
> On 17/01/2017 16:50, Emmanuel Vadot 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>
> 
> Is there any downside to doing the flush always? I would prefer to not 
> conditionalize it on CONFIG_FREEBSD.

 I don't think there is any downside.

> > ---
> >  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
> > +
> >  	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);
> >  }
> >
> > diff --git a/cmd/elf.c b/cmd/elf.c
> > index 5190cc6c0f..b2827fa042 100644
> > --- a/cmd/elf.c
> > +++ b/cmd/elf.c
> > @@ -109,6 +109,7 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
> >  {
> >  	unsigned long ret;
> >
> > +#ifndef CONFIG_FREEBSD
> >  	/*
> >  	 * QNX images require the data cache is disabled.
> >  	 * Data cache is already flushed, so just turn it off.
> > @@ -116,15 +117,20 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
> >  	int dcache = dcache_status();
> >  	if (dcache)
> >  		dcache_disable();
> 
> Can FreeBSD boot with dcache disabled? Is there some way we can 
> determine what payload we have from the elf header?
> 
> 
> Alex

 FreeBSD can boot with dcache disabled (our loader and kernel can)
 I'm not sure I get your other question, sorry.

-- 
Emmanuel Vadot <manu@bidouilliste.com> <manu@freebsd.org>

  reply	other threads:[~2017-01-17 20:45 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-17 15:50 [U-Boot] [PATCH v2 0/4] Add FreeBSD kconfig options Emmanuel Vadot
2017-01-17 15:50 ` [U-Boot] [PATCH v2 1/4] kconfig: Add API kconfig file Emmanuel Vadot
2017-01-17 17:16   ` Andreas Färber
2017-01-17 19:40     ` Emmanuel Vadot
2017-01-17 19:51       ` Warner Losh
2017-01-21  3:51   ` Simon Glass
2017-01-22  4:22     ` Warner Losh
2017-01-23 14:51       ` Tom Rini
2017-01-23 16:05         ` Emmanuel Vadot
2017-01-23 16:22           ` Tom Rini
2017-01-23 12:48     ` Emmanuel Vadot
2017-01-17 15:50 ` [U-Boot] [PATCH v2 2/4] kconfig: Add a FREEBSD option Emmanuel Vadot
2017-01-21  3:51   ` Simon Glass
2017-01-21 10:31     ` Jeroen Hofstee
2017-01-22  4:19     ` Warner Losh
2017-01-17 15:50 ` [U-Boot] [PATCH v2 3/4] api: FreeBSD: flush cache before starting loader/kernel Emmanuel Vadot
2017-01-17 20:13   ` Alexander Graf
2017-01-17 20:45     ` Emmanuel Vadot [this message]
2017-01-17 20:58       ` Alexander Graf
2017-01-18 10:42         ` Emmanuel Vadot
2017-01-21  3:51   ` Simon Glass
2017-01-23 12:50     ` Emmanuel Vadot
2017-01-17 15:50 ` [U-Boot] [PATCH v2 4/4] distro_bootcmd: Add command to run FreeBSD Emmanuel Vadot
2017-01-17 20:15   ` Alexander Graf
2017-01-17 19:36 ` [U-Boot] [PATCH v2 0/4] Add FreeBSD kconfig options Alexander Graf
2017-01-17 19:47   ` Emmanuel Vadot
2017-01-17 19:57     ` Warner Losh
2017-01-17 20:11       ` Alexander Graf
     [not found] ` <f07ec2834278bb372fb456338f2af313@agner.ch>
2017-01-17 19:41   ` Emmanuel Vadot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170117214544.e5462938e21e4c7ce1cccd5b@bidouilliste.com \
    --to=manu@bidouilliste.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.