Nico Huber has submitted this change. ( https://review.coreboot.org/c/coreboot/+/80364?usp=email )
Change subject: mainboard/qemu-aarch64: Get top of memory from device-tree blob ......................................................................
mainboard/qemu-aarch64: Get top of memory from device-tree blob
Trying to probe RAM space to figure out top of memory causes an exception on AArch64 virtual machines with recent versions of QEMU, but we temporarily enable exception handlers for that and use it to help detect if a RAM address is usable or not. However, QEMU docs recommend reading device information from the device-tree blob it provides us at the start of RAM.
A previous commit adds a library function to parse device-tree blob that QEMU provides us. Use it to determine top of memory in AArch64 QEMU virtual machines, but still fall back to the RAM probing approach as a last-ditch effort.
Change-Id: I4cc888b57cf98e0797ce7f9ddfa2eb34d14cd9c1 Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/80364 Reviewed-by: Maximilian Brune maximilian.brune@9elements.com Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Julius Werner jwerner@chromium.org Reviewed-by: Nico Huber nico.h@gmx.de --- M src/mainboard/emulation/qemu-aarch64/Kconfig M src/mainboard/emulation/qemu-aarch64/cbmem.c M src/mainboard/emulation/qemu-aarch64/memlayout.ld 3 files changed, 10 insertions(+), 0 deletions(-)
Approvals: Julius Werner: Looks good to me, approved Maximilian Brune: Looks good to me, but someone else must approve Nico Huber: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/src/mainboard/emulation/qemu-aarch64/Kconfig b/src/mainboard/emulation/qemu-aarch64/Kconfig index af689ba..42f9110 100644 --- a/src/mainboard/emulation/qemu-aarch64/Kconfig +++ b/src/mainboard/emulation/qemu-aarch64/Kconfig @@ -11,6 +11,7 @@ select ARCH_VERSTAGE_ARMV8_64 select ARCH_ROMSTAGE_ARMV8_64 select ARCH_RAMSTAGE_ARMV8_64 + select FLATTENED_DEVICE_TREE select ARM64_USE_ARCH_TIMER select BOARD_ROMSIZE_KB_16384 select BOOTBLOCK_CUSTOM diff --git a/src/mainboard/emulation/qemu-aarch64/cbmem.c b/src/mainboard/emulation/qemu-aarch64/cbmem.c index 389ff4e..4cdd44f 100644 --- a/src/mainboard/emulation/qemu-aarch64/cbmem.c +++ b/src/mainboard/emulation/qemu-aarch64/cbmem.c @@ -3,8 +3,16 @@ #include <cbmem.h> #include <ramdetect.h> #include <symbols.h> +#include <device_tree.h>
+DECLARE_REGION(fdt) uintptr_t cbmem_top_chipset(void) { + uint64_t top; + + top = fdt_get_memory_top((void *)_fdt); + if (top) + return MIN(top, (uint64_t)4 * GiB - 1); + return (uintptr_t)_dram + (probe_ramsize((uintptr_t)_dram, CONFIG_DRAM_SIZE_MB) * MiB); } diff --git a/src/mainboard/emulation/qemu-aarch64/memlayout.ld b/src/mainboard/emulation/qemu-aarch64/memlayout.ld index 9c1bb19..d27c015 100644 --- a/src/mainboard/emulation/qemu-aarch64/memlayout.ld +++ b/src/mainboard/emulation/qemu-aarch64/memlayout.ld @@ -18,6 +18,7 @@
BL31(0xe000000, 0x1000000) DRAM_START(0x40000000) + REGION(fdt, 0x40000000, 1M, 8) BOOTBLOCK(0x60010000, 64K) STACK(0x60020000, 54K) CBFS_MCACHE(0x6002D800, 8K)