From 090e4148b8596674fde96e52842740556ad9750d Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sat, 15 Feb 2025 22:18:49 +0100 Subject: [PATCH] core: Reserve physical page 0 In the kernel's early stages we access physical memory identity-mapped, so it's not very good for us to allocate that frame and then try to use it. --- core/src/pmm.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/pmm.zig b/core/src/pmm.zig index 6d0fd5a..3a195b9 100644 --- a/core/src/pmm.zig +++ b/core/src/pmm.zig @@ -99,5 +99,8 @@ pub fn initializeFrameAllocator(tag: *easyboot.multiboot_tag_mmap_t) !FrameAlloc const frames_to_lock = try std.math.divCeil(usize, bitmap_size, platform.PAGE_SIZE); try lockFrames(&allocator, @intFromPtr(bitmap_base_address), frames_to_lock); + // Avoid causing trouble. + try lockFrame(&allocator, 0); + return allocator; }