kernel/arm: add range checking for early page tables
Change-Id: Ibbd367475482eb0cf839314014c8bf68612c5d6a Reviewed-on: https://review.haiku-os.org/c/haiku/+/4891 Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
This commit is contained in:
parent
79ee00628f
commit
d283a8c58a
@ -32,6 +32,7 @@ typedef struct {
|
||||
uint32 phys_pgdir;
|
||||
uint32 vir_pgdir;
|
||||
uint32 next_pagetable;
|
||||
uint32 last_pagetable;
|
||||
|
||||
// The virtual ranges we want to keep in the kernel.
|
||||
uint32 num_virtual_ranges_to_keep;
|
||||
|
@ -346,6 +346,7 @@ arch_mmu_generate_post_efi_page_tables(size_t memoryMapSize,
|
||||
gKernelArgs.arch_args.phys_pgdir = (uint32)sPageDirectory;
|
||||
gKernelArgs.arch_args.vir_pgdir = (uint32)virtPageDirectory;
|
||||
gKernelArgs.arch_args.next_pagetable = (uint32)(sNextPageTable) - (uint32)sPageDirectory;
|
||||
gKernelArgs.arch_args.last_pagetable = (uint32)(sLastPageTable) - (uint32)sPageDirectory;
|
||||
|
||||
TRACE("gKernelArgs.arch_args.phys_pgdir = 0x%08x\n",
|
||||
(uint32_t)gKernelArgs.arch_args.phys_pgdir);
|
||||
@ -353,6 +354,8 @@ arch_mmu_generate_post_efi_page_tables(size_t memoryMapSize,
|
||||
(uint32_t)gKernelArgs.arch_args.vir_pgdir);
|
||||
TRACE("gKernelArgs.arch_args.next_pagetable = 0x%08x\n",
|
||||
(uint32_t)gKernelArgs.arch_args.next_pagetable);
|
||||
TRACE("gKernelArgs.arch_args.last_pagetable = 0x%08x\n",
|
||||
(uint32_t)gKernelArgs.arch_args.last_pagetable);
|
||||
|
||||
#ifdef TRACE_PAGE_DIRECTORY
|
||||
dump_page_dir();
|
||||
|
@ -364,6 +364,9 @@ ARMPagingMethod32Bit::CreateTranslationMap(bool kernel, VMTranslationMap** _map)
|
||||
static void
|
||||
get_free_pgtable(kernel_args* args, phys_addr_t* phys_addr, addr_t* virt_addr)
|
||||
{
|
||||
if (args->arch_args.next_pagetable >= args->arch_args.last_pagetable)
|
||||
panic("ran out of early page tables");
|
||||
|
||||
phys_addr_t phys = args->arch_args.phys_pgdir + args->arch_args.next_pagetable;
|
||||
addr_t virt = args->arch_args.vir_pgdir + args->arch_args.next_pagetable;
|
||||
args->arch_args.next_pagetable += ARM_MMU_L2_COARSE_TABLE_SIZE;
|
||||
|
Loading…
Reference in New Issue
Block a user