On Armada 7k/8k only a part of DRAM is mapped in U-Boot's MMU.
arch/arm/mach-mvebu/armada8k/cpu.c maps 0..0x04000000 and
0x05400000..0x85400000 (plus MMIO), and arm64-common.c clamps
board_get_usable_ram_top() to USABLE_RAM_SIZE (2 GiB) with the
comment "Not all memory is mapped in the MMU".  At the same time
a8k_dram_init_banksize() advertises the whole DRAM in bi_dram[],
adding a second bank at 4 GiB whenever more than 3 GiB is populated.

Until commit e1b6822d6522 ("efi_memory: do not add RAM memory to the
memory map") the EFI subsystem bridged that gap: efi_add_known_memory()
reserved everything above gd->ram_top, as introduced by commit
7b78d6438a2b ("efi_loader: Reserve unaccessible memory").  EFI
allocations are now backed by LMB, and LMB does not consider ram_top
by default, so the first efi_allocate_pool() of the boot - from
efi_init_early() -> efi_console_register() -> efi_create_event() -
takes the highest free page and faults:

Tested on a SolidRun MACCHIATObin (Armada 8040): without this change the
abort reproduces both with 4 GiB of DRAM (far 0x13ffff000) and with 8 GiB
(far 0x23ffff000), the faulting address tracking the top of the highest
bank; with it, U-Boot reaches the prompt.

LMB_LIMIT_DMA_BELOW_RAM_TOP, added by commit af4aad1f0a0b ("lmb:
Optionally limit available memory to 4 GiB on limited systems"),
reserves the memory above ram_top and addresses exactly this case.  It
is already enabled for ARCH_BCM283X and ARCH_ROCKCHIP; enable it for
ARCH_MVEBU as well.

Tested on a SolidRun MACCHIATObin (Armada 8040) with 4 GiB of DRAM,
which reproduces the abort above without this change and reaches the
prompt with it.

Fixes: e1b6822d6522 ("efi_memory: do not add RAM memory to the memory map")
Signed-off-by: Bruno Banelli <[email protected]>
---
 lib/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 9e0f0ad7d0..006a536cf0 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1298,7 +1298,7 @@ config SPL_LMB_ARCH_MEM_MAP
 config LMB_LIMIT_DMA_BELOW_RAM_TOP
        bool
        depends on LMB
-       default y if ARCH_BCM283X || ARCH_ROCKCHIP
+       default y if ARCH_BCM283X || ARCH_ROCKCHIP || ARCH_MVEBU
        help
          Some architectures can not DMA above ram_top boundary,
          which is after 4 GiB or 32-bit boundary too. Limit the
-- 
2.43.0

Reply via email to