From b3b4862b79772b6299c3cc1347b1d7cacec0790e Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 8 Mar 2015 11:05:23 +0100 Subject: [PATCH] fix missinterpretation of the page attributes & code cleanups --- arch/x86/kernel/entry.asm | 4 +--- arch/x86/mm/page.c | 15 +-------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index e22ff65..7b27cf9 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -372,12 +372,10 @@ boot_stack: ; These tables do a simple identity paging and will ; be replaced in page_init() by more fine-granular mappings. ALIGN 4096 -global boot_map -boot_map: boot_pgd: DD boot_pgt + 0x107 ; PG_PRESENT | PG_GLOBAL | PG_RW | PG_USER times 1022 DD 0 ; PAGE_MAP_ENTRIES - 2 - DD boot_pgd + 0x303 ; PG_PRESENT | PG_GLOBAL | PG_RW | PG_SELF (self-reference) + DD boot_pgd + 0x303 ; PG_PRESENT | PG_GLOBAL | PG_RW | PG_SELF (self-reference) boot_pgt: times 1024 DD 0 diff --git a/arch/x86/mm/page.c b/arch/x86/mm/page.c index da7165e..2ab5140 100644 --- a/arch/x86/mm/page.c +++ b/arch/x86/mm/page.c @@ -55,9 +55,6 @@ extern const void kernel_start; /** Lock for kernel space page tables */ static spinlock_t kslock = SPINLOCK_INIT; -/** This PGD table is initialized in entry.asm */ -extern size_t* boot_map; - /** A self-reference enables direct access to all page tables */ static size_t* self[PAGE_LEVELS] = { (size_t *) 0xFFC00000, @@ -86,16 +83,6 @@ int page_set_flags(size_t viraddr, uint32_t npages, int flags) return -EINVAL; } -int page_map_bootmap(size_t viraddr, size_t phyaddr, size_t bits) -{ - if (BUILTIN_EXPECT(viraddr >= PAGE_MAP_ENTRIES*PAGE_SIZE, 0)) - return -EINVAL; - - boot_map[PAGE_MAP_ENTRIES + (viraddr >> PAGE_BITS)] = phyaddr | bits | PG_PRESENT; - - return 0; -} - int page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits) { int lvl, ret = -ENOMEM; @@ -130,7 +117,7 @@ int page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits) atomic_int32_inc(¤t_task->user_usage); /* Reference the new table within its parent */ - self[lvl][vpn] = phyaddr | bits | PG_PRESENT; + self[lvl][vpn] = phyaddr | bits | PG_PRESENT | PG_USER | PG_RW; /* Fill new table with zeros */ memset(&self[lvl-1][vpn<