From 80da20a01e6ccc3585098484eeaea25fa8b458cd Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Tue, 15 Dec 2015 11:33:20 +0000 Subject: [PATCH] [x86] fix typo in tidy_boot_pg_tables that corrupted the page tables for the kernel's lower virtual space. oops. also increase the boot stack space because it was crashed into the page tables - do we need a canary to detect that in future? probably. also make sure all text areas are included between __kernel_ro_start/end --- platform/x86/asm/start32.s | 2 +- platform/x86/asm/start64.s | 4 ++-- platform/x86/linker.ld | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/x86/asm/start32.s b/platform/x86/asm/start32.s index f9deaec..89acf87 100644 --- a/platform/x86/asm/start32.s +++ b/platform/x86/asm/start32.s @@ -395,7 +395,7 @@ boot_pt1_table: resb 4096 ; reserve 4KB for a page table aka level 1 page table boot_stack_bottom: - resb 4096 + resb 2 * 4096 ; reserve 2 x 4KB pages for the stack boot_stack_top: ; stash a pointer to the boot PML4 table diff --git a/platform/x86/asm/start64.s b/platform/x86/asm/start64.s index cbe1c34..f4b9b6d 100644 --- a/platform/x86/asm/start64.s +++ b/platform/x86/asm/start64.s @@ -111,7 +111,7 @@ tidy_boot_pg_tables: shr rax, 12 and rax, 0x3ff ; turn start address into table index mov rbx, __kernel_ro_end - shr rax, 12 + shr rbx, 12 and rbx, 0x3ff ; turn end address into table index mov rcx, __kernel_ro_start ; this should be page aligned @@ -128,7 +128,7 @@ tidy_boot_pg_tables: shr rax, 12 and rax, 0x3ff ; turn start address into table index mov rbx, __kernel_rw_end - shr rax, 12 + shr rbx, 12 and rbx, 0x3ff ; turn end address into table index mov rcx, __kernel_rw_start ; this should be page aligned diff --git a/platform/x86/linker.ld b/platform/x86/linker.ld index e1fe414..b841038 100644 --- a/platform/x86/linker.ld +++ b/platform/x86/linker.ld @@ -19,7 +19,7 @@ SECTIONS { __kernel_ro_start = ALIGN(0x1000); KEEP(*(.multiboot_head)) /* keep our multiboot header at the start */ - *(.text) + *(.text*) *(.rodata*) __kernel_ro_end = ALIGN(0x1000); }