[U-Boot] [PATCH] arm64: mvebu: fix crash in EFI memory allocation
Baruch Siach
baruch at tkos.co.il
Thu Nov 22 11:42:52 UTC 2018
EFI memory allocation code return values that are not mapped by U-Boot
MMU. This causes a crash when tftp calls efi_set_bootdev(). Fix this
similarly to commit 0797f7f0b7e1 ("ARM: tegra: reserve unmapped RAM so
EFI doesn't use it").
Signed-off-by: Baruch Siach <baruch at tkos.co.il>
---
arch/arm/mach-mvebu/arm64-common.c | 13 ++-----------
arch/arm/mach-mvebu/include/mach/cpu.h | 9 +++++++++
board/Marvell/mvebu_armada-8k/board.c | 17 +++++++++++++++++
3 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/arch/arm/mach-mvebu/arm64-common.c b/arch/arm/mach-mvebu/arm64-common.c
index 47bbf69944ec..b82f33093a2c 100644
--- a/arch/arm/mach-mvebu/arm64-common.c
+++ b/arch/arm/mach-mvebu/arm64-common.c
@@ -17,19 +17,10 @@
DECLARE_GLOBAL_DATA_PTR;
-/*
- * Not all memory is mapped in the MMU. So we need to restrict the
- * memory size so that U-Boot does not try to access it. Also, the
- * internal registers are located at 0xf000.0000 - 0xffff.ffff.
- * Currently only 2GiB are mapped for system memory. This is what
- * we pass to the U-Boot subsystem here.
- */
-#define USABLE_RAM_SIZE 0x80000000
-
ulong board_get_usable_ram_top(ulong total_size)
{
- if (gd->ram_size > USABLE_RAM_SIZE)
- return USABLE_RAM_SIZE;
+ if (gd->ram_size > MVEBU_ARM64_USABLE_RAM_SIZE)
+ return MVEBU_ARM64_USABLE_RAM_SIZE;
return gd->ram_size;
}
diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h
index 85d7dd1610a8..e22a14977859 100644
--- a/arch/arm/mach-mvebu/include/mach/cpu.h
+++ b/arch/arm/mach-mvebu/include/mach/cpu.h
@@ -177,5 +177,14 @@ int mvebu_lcd_register_init(struct mvebu_lcd_info *lcd_info);
*/
u32 get_ref_clk(void);
+/*
+ * Not all memory is mapped in the MMU. So we need to restrict the
+ * memory size so that U-Boot does not try to access it. Also, the
+ * internal registers are located at 0xf000.0000 - 0xffff.ffff.
+ * Currently only 2GiB are mapped for system memory. This is what
+ * we pass to the U-Boot subsystem in board_get_usable_ram_top().
+ */
+#define MVEBU_ARM64_USABLE_RAM_SIZE 0x80000000
+
#endif /* __ASSEMBLY__ */
#endif /* _MVEBU_CPU_H */
diff --git a/board/Marvell/mvebu_armada-8k/board.c b/board/Marvell/mvebu_armada-8k/board.c
index e927e338ea6e..2fffe05c4958 100644
--- a/board/Marvell/mvebu_armada-8k/board.c
+++ b/board/Marvell/mvebu_armada-8k/board.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <dm.h>
#include <i2c.h>
+#include <efi_loader.h>
#include <asm/io.h>
#include <asm/arch/cpu.h>
#include <asm/arch/soc.h>
@@ -154,6 +155,22 @@ int board_init(void)
int board_late_init(void)
{
+ uint64_t unmapped_ram_start = gd->bd->bi_dram[0].start
+ + MVEBU_ARM64_USABLE_RAM_SIZE;
+ uint64_t unmapped_ram_size = gd->bd->bi_dram[0].size
+ - MVEBU_ARM64_USABLE_RAM_SIZE;
+
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+ if (gd->bd->bi_dram[0].size > MVEBU_ARM64_USABLE_RAM_SIZE)
+ efi_add_memory_map(unmapped_ram_start,
+ unmapped_ram_size >> EFI_PAGE_SHIFT,
+ EFI_BOOT_SERVICES_DATA, false);
+ if (gd->bd->bi_dram[1].start)
+ efi_add_memory_map(gd->bd->bi_dram[1].start,
+ gd->bd->bi_dram[1].size >> EFI_PAGE_SHIFT,
+ EFI_BOOT_SERVICES_DATA, false);
+#endif
+
/* Pre-configure the USB ports (overcurrent, VBus) */
board_xhci_config();
--
2.19.1
More information about the U-Boot
mailing list