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.
This commit is contained in:
Daniel Bertalan 2023-06-06 12:32:10 +02:00 committed by Jelle Raaijmakers
parent 9359e49383
commit c6c0ce78f5
Notes: sideshowbarker 2024-07-17 02:56:25 +09:00

View file

@ -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;