public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 2/3] arm64: Bail out PIE builds early if load address is not 4K aligned
Date: Mon, 7 Sep 2020 15:40:06 +0200	[thread overview]
Message-ID: <20200907134006.GZ14249@toto> (raw)
In-Reply-To: <20200907125739.GL24856@bill-the-cat>

On Mon, Sep 07, 2020 at 08:57:39AM -0400, Tom Rini wrote:
> On Mon, Sep 07, 2020 at 11:52:35AM +0200, Edgar E. Iglesias wrote:
> > On Fri, Sep 04, 2020 at 12:43:57PM -0600, Stephen Warren wrote:
> > > On 9/4/20 3:07 AM, Edgar E. Iglesias wrote:
> > > > From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
> > > > 
> > > > PIE requires a 4K aligned load address. If this is not met, trap
> > > > the startup sequence in a WFI loop rather than running into obscure
> > > > failures.
> > > 
> > > > diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
> > > >  #if CONFIG_POSITION_INDEPENDENT
> > > > +	/* Verify that we're 4K aligned.  */
> > > 
> > > Similar to the comment on the previous patch: I believe the code that
> > > implements this check should be outside the #if check, since it's always
> > > needed.
> > 
> > But a check for non-PIE would have to be stricter, wouldn't it?
> > I.e the load address needs to exactly match the link-time address.
> > 
> > Perhaps we should add the non-PIE check in a separate patch (if at all)?
> 
> If we can catch a bad configuration at link time in the non-PIE case (as
> said in another part of this thread I believe) then we should, yes,
> thanks!

The non-PIE configuration is expected to be loaded at a specific address.
The actual load address cannot be checked at link-time (since it's up to
the user at run-time) but given the assumption of a specific load-address,
4K alignment can be enforced at link-time.

It really comes down to adding reasonable run-time checks for errors that
users may reasonably struggle with.

For PIE, checking for 4K aligment is reasonable because it's an easy
enough misstake to make (since you've got a binary that's was supposed to
handle relocation).

For non-PIE, checking for the exact address at run-time is a little bit more
border-line IMO but I guess also somewhat reasonable.

There are still plenty of cases we can't catch though (loaded at odd addreses,
non-RAM address-ranges etc etc).

Cheers,
Edgar

  reply	other threads:[~2020-09-07 13:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04  9:07 [PATCH v2 0/3] arm64: Large PIE fixes Edgar E. Iglesias
2020-09-04  9:07 ` [PATCH v2 1/3] arm64: Mention 4K aligned load addresses in the PIE Kconfig help Edgar E. Iglesias
2020-09-04 18:42   ` Stephen Warren
2020-09-06 22:16     ` André Przywara
2020-09-07  9:58       ` Edgar E. Iglesias
2020-09-04  9:07 ` [PATCH v2 2/3] arm64: Bail out PIE builds early if load address is not 4K aligned Edgar E. Iglesias
2020-09-04 18:43   ` Stephen Warren
2020-09-07  9:52     ` Edgar E. Iglesias
2020-09-07 12:57       ` Tom Rini
2020-09-07 13:40         ` Edgar E. Iglesias [this message]
2020-09-08 19:02       ` Stephen Warren
2020-09-04  9:07 ` [PATCH v2 3/3] arm64: Add support for larger PIE U-boot Edgar E. Iglesias
2020-09-04 13:04   ` Michal Simek
2020-09-04 13:11     ` Edgar E. Iglesias
2020-09-04 18:45   ` Stephen Warren

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=20200907134006.GZ14249@toto \
    --to=edgar.iglesias@xilinx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox