Skip to content

Commit

Permalink
[x86] fix typo in tidy_boot_pg_tables that corrupted the page tables …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
diodesign committed Dec 15, 2015
1 parent af7f9ac commit 80da20a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion platform/x86/asm/start32.s
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions platform/x86/asm/start64.s
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion platform/x86/linker.ld
Expand Up @@ -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);
}
Expand Down

0 comments on commit 80da20a

Please sign in to comment.