Kernel: Fix bug in elf loading

We were allocating one extra page
This commit is contained in:
Bananymous 2023-06-12 00:59:19 +03:00
parent eb7ee13f43
commit 4ca99fcb4e
1 changed files with 5 additions and 5 deletions

View File

@ -420,16 +420,16 @@ namespace Kernel
size_t page_start = elf_program_header.p_vaddr / PAGE_SIZE;
size_t page_end = BAN::Math::div_round_up<size_t>(elf_program_header.p_vaddr + elf_program_header.p_memsz, PAGE_SIZE);
size_t page_count = page_end - page_start + 1;
size_t page_count = page_end - page_start;
page_table().lock();
if (!page_table().is_range_free(elf_program_header.p_vaddr, elf_program_header.p_memsz))
if (!page_table().is_range_free(page_start * PAGE_SIZE, page_count * PAGE_SIZE))
{
page_table().debug_dump();
Kernel::panic("vaddr {8H}-{8H} not free",
elf_program_header.p_vaddr,
elf_program_header.p_vaddr + elf_program_header.p_memsz
Kernel::panic("vaddr {8H}-{8H} not free {8H}-{8H}",
page_start * PAGE_SIZE,
page_start * PAGE_SIZE + page_count * PAGE_SIZE
);
}