NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-evbarm/54554: Booting via U-Boot fails due to buffer misalignment



>Number:         54554
>Category:       port-evbarm
>Synopsis:       Booting via U-Boot fails due to buffer misalignment
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-evbarm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 17 14:10:00 +0000 2019
>Originator:     Simon South
>Release:        CURRENT (9.99.11) 2019-09-15 12:10 UTC
>Organization:
>Environment:
NetBSD arm64 9.99.11 NetBSD 9.99.11 (GENERIC64) #8: Mon Sep 16 17:09:14 EDT 2019
>Description:
Booting NetBSD on a PINE64 ROCK64 fails using the current revision of
U-Boot in that project's git repository. NetBSD's EFI bootloader is
unable to open any kernel, with output like the following:

    >> NetBSD/evbarm EFI Boot (aarch64), Revision 1.11 (Thu Sep 12 13:07:08 UTC 2019) (from NetBSD 9.99.11)
    Press return to boot now, any other key for boot prompt
    booting netbsd - starting in 0 seconds.
    open netbsd: Invalid argument
    boot: netbsd: Invalid argument
    booting netbsd.gz - starting in 0 seconds.
    open netbsd.gz: Invalid argument
    boot: netbsd.gz: Invalid argument
    ...

The same OS image boots fine when using an earlier version of U-Boot.

This is due to a recent change to U-Boot, commit f59f0825e8 on 5
September 2019, that updates their implementation of the UEFI
ReadBlocks function so it checks the alignment of the buffer passed to
it against the alignment requested by the underlying device, as
required by the UEFI spec. NetBSD's EFI bootloader makes no effort to
ensure the buffer it passes to this function is correctly aligned,
causing (on at least some systems) attempts to open or read from files
to fail with an "Invalid argument" error as shown above.
>How-To-Repeat:
1. Build a NetBSD release image as usual and write it to a microSD
   card.

2. Build U-Boot, configured for the ROCK64, from the current version
   in the project's git repository (with a second problematic commit,
   899c3b3523, reverted), and write this to the microSD card as well.

3. Place the microSD card in the ROCK64 and attempt to boot it.
>Fix:
Functions in sys/stand/efiboot/efiblock.c that call the UEFI
environment's ReadBlocks function need to be modified to ensure they
always pass a buffer aligned as requested by the device in use.

I've made these changes locally and will attach a patch to this
PR. With the changes applied (and the second problematic U-Boot
commit, noted above, reverted) I can boot NetBSD without issue using
the current revision of U-Boot.



Home | Main Index | Thread Index | Old Index