Skip to content

Commit

Permalink
Kernel: Actually set physical base pointer correctly in prekernel stage
Browse files Browse the repository at this point in the history
I did a mistake and set the kernel_physical_base value to be just on
the actual linked kernel ELF start offset, while this value should
represent together with KERNEL_MAPPING_BASE the actual higher-half load
address.

By changing this value, we resolve a bug in which disabling KASLR
doesn't work and will cause the prekernel to hang on this statement:
```c++
VERIFY(kernel_load_base >= kernel_mapping_base + 0x200000);
```
  • Loading branch information
supercomputer7 authored and timschumi committed May 22, 2024
1 parent 899c38d commit 3ba5dae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Kernel/Prekernel/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ extern "C" [[noreturn]] void init()
halt();
__builtin_memcpy(kernel_program_headers, kernel_image + kernel_elf_header.e_phoff, sizeof(Elf_Phdr) * kernel_elf_header.e_phnum);

FlatPtr kernel_physical_base = (FlatPtr)kernel_image;
FlatPtr kernel_physical_base = (FlatPtr)0x200000;
FlatPtr default_kernel_load_base = KERNEL_MAPPING_BASE + kernel_physical_base;

FlatPtr kernel_load_base = default_kernel_load_base;
Expand Down Expand Up @@ -153,7 +153,7 @@ extern "C" [[noreturn]] void init()
FlatPtr kernel_mapping_base = kernel_load_base & ~(FlatPtr)0x3fffffff;

VERIFY(kernel_load_base % 0x1000 == 0);
VERIFY(kernel_load_base >= kernel_mapping_base + 0x200000);
VERIFY(kernel_load_base >= kernel_mapping_base + kernel_physical_base);

int pdpt_flags = 0x3;

Expand Down

0 comments on commit 3ba5dae

Please sign in to comment.