On 7/22/19 8:59 PM, Mark Kettenis wrote:
From: Heinrich Schuchardt <[email protected]>
Date: Sat, 20 Jul 2019 13:23:13 +0200

On 7/20/19 1:59 AM, Jonathan Gray wrote:
On Fri, Jul 19, 2019 at 08:25:45PM +0200, Heinrich Schuchardt wrote:
In GRUB before 2.04 a bug existed which did not allow booting some ARM32
boards if U-Boot did not disable caches, cf.
https://lists.linaro.org/pipermail/cross-distro/2019-July/000933.html

In ExitBootServices() we were disabling the caches by calling
cleanup_before_linux(). This workaround is not needed anymore.

It is required for at least OpenBSD, FreeBSD and NetBSD.
Which are all now forced to carry patches to be able to use U-Boot.

Please, compare function run_loadfile() in files
sys/arch/arm64/stand/efiboot/exec.c and
sys/arch/armv7/stand/efiboot/exec.c of openbsd/src.

On arm64 after loading the kernel you flush the data and instruction
caches. On armv7 you don't. As the UEFI spec requires caches to be
switched on this is bound to fail. You should be good if you flush
caches like you do on arm64.

You can find the relevant code for GRUB in
grub-core/kern/arm/cache.S and
grub-core/kern/arm/cache.c

After GRUB loads the Linux kernel it calls
grub_arch_sync_caches ((void *) linux_addr, linux_size);
in function linux_boot().

Thanks for the pointer.  I added code to OpenBSD's BOOTARM.EFI to
disable the caches and MMU such that the kernel ends up being started
in the same state as before.

That still leaves us with the L2 cache issue though.  A U-Boot with
CONFIG_SYS_L2CACHE_OFF set works, whereas without it doesn't.


I just tested on Wandboard which is an i.MX6 system with a
architecturally defined L2 cache. The operating system is Debian Buster
which has a GRUB 2.02 but where the EFI path has been patched like in
GRUB 2.04.

It will only boot via GRUB if either CONFIG_SYS_L2CACHE_OFF=y or
cleanup_before_linux() is called (in efi_exit_caches()).

As current GRUB calls StartImage() itself the original logic implemented
by Alex not to call cleanup_before_linux() if a payload has called
StartImage() does not work.

@Alex:
Given this finding and the discussion in this thread could you, please,
revisit your review comment in
https://lists.denx.de/pipermail/u-boot/2019-July/377339.html
[RFC 1/1] efi_loader: usage of cleanup_before_linux()

I think short term we should always call cleanup_before_linux() and long
term we should move to a logic switching of only architecturally defined
caches in efi_init_obj_list(), i.e. before loading any EFI binary.

Best regards

Heinrich
_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to