[U-Boot] [PATCH v2] sunxi: Increase SPL header size to 64 bytes to avoid code corruption

Siarhei Siamashka siarhei.siamashka at gmail.com
Thu Jun 2 16:57:21 CEST 2016


On Mon, 16 May 2016 19:52:33 +0200
Hans de Goede <hdegoede at redhat.com> wrote:

> Hi,
> 
> On 16-05-16 11:56, Bernhard Nortmann wrote:
> > Given that there now are quite a few additional "reserved" entries, and while we're still at SPL_HEADER_VERSION 1, I'd like to renew my request of dedicating one of these fields to the script length - which would enable us to set the U-Boot ${filesize} accordingly.
> >
> > i.e.
> > --- arch-arm-include-asm-arch-sunxi-spl.h
> > +++ arch-arm-include-asm-arch-sunxi-spl.new.h
> > @@ -49,7 +49,8 @@
> >                 uint8_t spl_signature[4];
> >         };
> >         uint32_t fel_script_address;
> > -       uint32_t reserved1[3];
> > +       uint32_t fel_script_length;
> > +       uint32_t reserved1[2];
> >         uint32_t boot_media;            /* written here by the boot ROM */
> >         uint32_t reserved2[5];          /* padding, align to 64 bytes */
> >  };
> >
> >
> > I do not intend to further push my specific use cases, however I still consider the (then somewhat theoretical) ability to do "import -t ${fel_script_addr} ${filesize}" useful. For reference, the previous discussion related to this was somewhere around http://lists.denx.de/pipermail/u-boot/2015-September/227454.html  
> 
> Hmm, given that the boot-rom touches some of these, I wonder if
> we should be putting anything here at all.

Yes, this came as a bit of surprise because this was not clearly
documented anywhere. Still it looks like that's just a single
byte getting modified, albeit at a bit strange location.

BTW, do you remember what I said earlier about not always being in
perfect control?

    http://lists.denx.de/pipermail/u-boot/2015-September/228727.html

This particular issue just serves as a very nice demonstration :-)

Anyway, I think that we are already reasonably well prepared to handle
it. The worst thing that can happen is that the boot ROM in the future
Allwinner SoCs starts patching even more bytes in the header or moves
this boot device id variable to some other address. If/when this
happens, we can always update the SPL header format (do the "major"
version change trick).

> Other then that worry, I see no problem with adding a
> fel_script_length, Siarhei what is your opinion on this ?

I personally have no objections.

-- 
Best regards,
Siarhei Siamashka


More information about the U-Boot mailing list