U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH V2] mkimage: fit: Do not tail-pad fitImage with external data
Date: Tue, 5 May 2020 20:18:18 +0200	[thread overview]
Message-ID: <8491a801-bfbf-c2e6-0357-78608aa69102@denx.de> (raw)
In-Reply-To: <20200505180648.GZ12564@bill-the-cat>

On 5/5/20 8:06 PM, Tom Rini wrote:
> On Tue, May 05, 2020 at 07:59:24PM +0200, Marek Vasut wrote:
>> On 5/5/20 7:55 PM, Tom Rini wrote:
>>> On Tue, May 05, 2020 at 07:53:42PM +0200, Marek Vasut wrote:
>>>> On 5/5/20 7:50 PM, Tom Rini wrote:
>>>>> On Tue, May 05, 2020 at 06:39:58PM +0200, Marek Vasut wrote:
>>>>>> On 5/5/20 6:37 PM, Alex Kiernan wrote:
>>>>>>> On Tue, May 5, 2020 at 2:28 PM Marek Vasut <marex@denx.de> wrote:
>>>>>>>>
>>>>>>>> On 5/5/20 3:22 PM, Alex Kiernan wrote:
>>>>>>>>> On Mon, May 4, 2020 at 12:28 PM Tom Rini <trini@konsulko.com> wrote:
>>>>>>>>>>
>>>>>>>>>> On Fri, May 01, 2020 at 05:40:25PM +0200, Marek Vasut wrote:
>>>>>>>>>>
>>>>>>>>>>> There is no reason to tail-pad fitImage with external data to 4-bytes,
>>>>>>>>>>> while fitImage without external data does not have any such padding and
>>>>>>>>>>> is often unaligned. DT spec also does not mandate any such padding.
>>>>>>>>>>>
>>>>>>>>>>> Moreover, the tail-pad fills the last few bytes with uninitialized data,
>>>>>>>>>>> which could lead to a potential information leak.
>>>>>>>>>>>
>>>>>>>>>>> $ echo -n xy > /tmp/data ; \
>>>>>>>>>>>       ./tools/mkimage -E -f auto -d /tmp/data /tmp/fitImage ; \
>>>>>>>>>>>       hexdump -vC /tmp/fitImage | tail -n 3
>>>>>>>>>>>
>>>>>>>>>>> before:
>>>>>>>>>>> 00000260  61 2d 6f 66 66 73 65 74  00 64 61 74 61 2d 73 69  |a-offset.data-si|
>>>>>>>>>>> 00000270  7a 65 00 00 78 79 64 64                           |ze..xydd|
>>>>>>>>>>>                    ^^       ^^ ^^
>>>>>>>>>>> after:
>>>>>>>>>>> 00000260  61 2d 6f 66 66 73 65 74  00 64 61 74 61 2d 73 69  |a-offset.data-si|
>>>>>>>>>>> 00000270  7a 65 00 78 79                                    |ze.xy|
>>>>>>>>>>>
>>>>>>>>>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>>>>>>>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>>>>>>>>> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>>>>>>>>>> Cc: Tom Rini <trini@konsulko.com>
>>>>>>>>>>
>>>>>>>>>> Applied to u-boot/master, thanks!
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> This breaks booting on my board (am3352, eMMC boot, FIT u-boot,
>>>>>>>>> CONFIG_SPL_LOAD_FIT). Not got any useful diagnostics - if I boot it
>>>>>>>>> from eMMC I get nothing at all on the console, if I boot over ymodem
>>>>>>>>> it stalls at 420k, before continuing to 460k. My guess is there's some
>>>>>>>>> error going to the console at the 420k mark, but obviously it's lost
>>>>>>>>> in the ymodem... I have two DTBs in the FIT image, 420k would about
>>>>>>>>> align to the point between them.
>>>>>>>>
>>>>>>>> My bet would be on some padding / unaligned access problem that this
>>>>>>>> patch uncovered. Can you take a look ?
>>>>>>>
>>>>>>> Seems plausible. With this change my external data starts at 0x483 and
>>>>>>> everything after it is non-aligned:
>>>>>>
>>>>>> Should the beginning of external data be aligned ?
>>>>>
>>>>> If in U-Boot we revert e8c2d25845c72c7202a628a97d45e31beea40668 does the
>>>>> problem go away?  If so, that's not a fix outright, it means we need to
>>>>> dig back in to the libfdt thread and find the "make this work without
>>>>> killing performance everywhere all the time" option.
>>>>
>>>> Still, my question is, should the beginning of external data be aligned
>>>> ? And if so, to what, 4 bytes like FDT entries OR 8 bytes to cater for
>>>> arm64/rv64 ?
>>>
>>> Is "external data" the kernel in this case?  If so, I swear Linux
>>> mandates 8 byte alignment for arm32 as well.
>>
>> External data can be anything, and if it is supposed to be 8 bytes, we
>> already failed at that since forever.
> 
> I would be entirely unsurprised at things working through a combination
> of luck and co-incidence in our previous padding working out.  So, what
> typically is "external data" in this context?

Anything you can bundle into the fitImage, -E just puts the content at
the end of the fitImage and places a reference into the fitImage itself.

  reply	other threads:[~2020-05-05 18:18 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01 15:40 [PATCH V2] mkimage: fit: Do not tail-pad fitImage with external data Marek Vasut
2020-05-03  2:26 ` Simon Glass
2020-05-04 11:27 ` Tom Rini
2020-05-05 13:22   ` Alex Kiernan
2020-05-05 13:28     ` Marek Vasut
2020-05-05 16:37       ` Alex Kiernan
2020-05-05 16:39         ` Marek Vasut
2020-05-05 17:50           ` Tom Rini
2020-05-05 17:53             ` Marek Vasut
2020-05-05 17:55               ` Tom Rini
2020-05-05 17:59                 ` Marek Vasut
2020-05-05 18:06                   ` Tom Rini
2020-05-05 18:18                     ` Marek Vasut [this message]
2020-05-05 18:41             ` Simon Glass
2020-05-05 21:17               ` Michael Walle
2020-05-06 10:15                 ` Michael Walle
2020-05-06 12:30                 ` Alex Kiernan
2020-05-06 13:48                 ` Tom Rini
2020-05-06 14:17                   ` Marek Vasut
2020-05-06 14:27                     ` Tom Rini
2020-05-06 14:33                       ` Marek Vasut
2020-05-06 14:37                         ` Tom Rini
2020-05-06 14:41                           ` Marek Vasut
2020-05-06 15:43                             ` Alex Kiernan
2020-05-06 15:52                               ` Marek Vasut
2020-05-06 16:04                                 ` Tom Rini
2020-05-06 16:17                                   ` Marek Vasut
2020-05-06 16:33                                     ` Tom Rini
2020-05-06 16:35                                       ` Marek Vasut
2020-05-06 17:02                                         ` Tom Rini
2020-05-06 18:11                                           ` Marek Vasut
2020-05-07 20:46                                           ` Samuel Holland
2020-05-08  1:37                                             ` Marek Vasut
2020-05-08 18:47                                               ` Tom Rini
2020-05-08 19:00                                                 ` Marek Vasut
2020-05-08 19:21                                                   ` Tom Rini
2020-05-10 19:24                                                     ` Marek Vasut
2020-05-11 19:36                                                       ` Tom Rini
2020-05-26 15:53                                                         ` Marek Vasut
2020-05-06 12:43               ` Alex Kiernan

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=8491a801-bfbf-c2e6-0357-78608aa69102@denx.de \
    --to=marex@denx.de \
    --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