From c6c0ce78f51b52073c912fa81bf6cdc759229443 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Tue, 6 Jun 2023 12:32:10 +0200 Subject: [PATCH] Kernel/aarch64: Account for reserved VideoCore range in the memory map Instead of having a single available memory range that encompasses the whole 0x00000000-0x3EFFFFFF range of physical memory, create a separate reserved entry for the RAM range used by the VideoCore. This fixes a crash that happens when we try to allocate physical pages in the GPU's reserved range. This will eventually be replaced with parsing the data from the device tree, but for now, this should solve some of the recurring CI failures. --- Kernel/Arch/init.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Kernel/Arch/init.cpp b/Kernel/Arch/init.cpp index 1a901a0ae2..755b99bb5c 100644 --- a/Kernel/Arch/init.cpp +++ b/Kernel/Arch/init.cpp @@ -186,14 +186,25 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init([[maybe_unused]] BootInfo con multiboot_framebuffer_type = boot_info.multiboot_framebuffer_type; #elif ARCH(AARCH64) // FIXME: For the aarch64 platforms, we should get the information by parsing a device tree instead of using multiboot. + auto [ram_base, ram_size] = RPi::Mailbox::the().query_lower_arm_memory_range(); + auto [vcmem_base, vcmem_size] = RPi::Mailbox::the().query_videocore_memory_range(); multiboot_memory_map_t mmap[] = { - { sizeof(struct multiboot_mmap_entry) - sizeof(u32), - (u64)0x0, - (u64)0x3F000000, - MULTIBOOT_MEMORY_AVAILABLE } + { + sizeof(struct multiboot_mmap_entry) - sizeof(u32), + (u64)ram_base, + (u64)ram_size, + MULTIBOOT_MEMORY_AVAILABLE, + }, + { + sizeof(struct multiboot_mmap_entry) - sizeof(u32), + (u64)vcmem_base, + (u64)vcmem_size, + MULTIBOOT_MEMORY_RESERVED, + }, + // FIXME: VideoCore only reports the first 1GB of RAM, the rest only shows up in the device tree. }; multiboot_memory_map = mmap; - multiboot_memory_map_count = 1; + multiboot_memory_map_count = 2; multiboot_modules = nullptr; multiboot_modules_count = 0;