mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Lior Weintraub <liorw@pliops.com>
Cc: "andrew.smirnov@gmail.com" <andrew.smirnov@gmail.com>,
	"barebox@lists.infradead.org" <barebox@lists.infradead.org>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: Re: ARM: aarch64: lowlevel: potential bug in arm_cpu_lowlevel_init
Date: Wed, 16 Aug 2023 12:01:46 +0200	[thread overview]
Message-ID: <20230816100146.GF5650@pengutronix.de> (raw)
In-Reply-To: <PR3P195MB0555C0CAAE5F70743B7DC534C317A@PR3P195MB0555.EURP195.PROD.OUTLOOK.COM>

Hi Lior,

On Mon, Aug 14, 2023 at 11:35:05AM +0000, Lior Weintraub wrote:
>    Link: [1]File-List
>    Hi Andrew,
>     
>    I am asking about a patch you've introduced about 4 years ago:
>    Commit: cd6e1857a6a824d562bd27379d191602c074f6b7
>     
>    ENTRY(arm_cpu_lowlevel_init)
>                    switch_el x1, 3f, 2f, 1f
>     
>    3:
>                    mov       x0, #1                                    /*
>    Non-Secure EL0/1 */
>                    orr          x0, x0, #(1 << 10)              /* 64-bit EL2
>    */
>                    msr        scr_el3, x0
>                    msr        cptr_el3, xzr
>     
>                    mrs        x0, sctlr_el3
>                    ldr           x1, =SCTLR_ELx_FLAGS
>                    bic          x0, x0, x1
>                    msr        sctlr_el3, x0
>                    isb
>     
>                    b             done
>     
>    This code has introduced a bug in our barebox porting.
>    It could be our mistake but then again we couldn't find any prerequisites
>    conditions that bootloaders need to meet before passing control to barebox
>    pbl.
>    There are 2 bugs that can happen here:
>     1. The bootloader enabled MMU and set the SRAM (given to barebox) as
>        non-secure – This issue can be resolved with adding "dsb sy" command
>        before the "isb"
>     2. The bootloader enabled MMU and dcache on SRAM (given to barebox) as
>        non-secure – This is a bit harder to solve because it needs to call
>        cache invalidate on the stack.

Eventhough it might not be explicitly documented, barebox normally
expects to be called with MMU disabled.

When the MMU is enabled it could have virtually any mapping and there's
no sane way to disable the MMU then.

If your bootloader enables the MMU and there is no way to change that,
then it's up to your board entry code to disable the MMU before calling into
barebox. That said, when there's something can change in arm_cpu_lowlevel_init()
to help you with your case, then we can do that, but I wouldn't consider
this a bug in barebox.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  parent reply	other threads:[~2023-08-16 10:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <PR3P195MB0555C0CAAE5F70743B7DC534C317A@PR3P195MB0555.EURP195.PROD.OUTLOOK.COM>
2023-08-14 11:41 ` Lior Weintraub
2023-08-16 10:01 ` Sascha Hauer [this message]
2023-08-16 10:14   ` Lior Weintraub
2023-09-07  8:26     ` Ahmad Fatoum
2023-09-07  8:30       ` Lior Weintraub

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=20230816100146.GF5650@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=liorw@pliops.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox