From d5f60ef542ac10677f64ed53bd64730bbbfe2a0b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 9 Jan 2014 15:20:22 +0100 Subject: [PATCH] fixed two smaller bugs and some compiler warnings --- arch/x86/include/asm/page.h | 5 +++-- arch/x86/kernel/apic.c | 2 +- arch/x86/kernel/entry64.asm | 4 ++-- arch/x86/mm/page64.c | 8 +++----- include/metalsvm/tasks_types.h | 2 +- mm/vma.c | 2 +- newlib/examples/memtest.c | 1 + script.gdb | 1 + 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h index 5e0c06f4..d521c9e3 100644 --- a/arch/x86/include/asm/page.h +++ b/arch/x86/include/asm/page.h @@ -127,6 +127,7 @@ /** @brief A single entry in a page map */ typedef size_t page_entry_t; + /** @brief General page map structure * * This page map structure is a general type for all indirecton levels. @@ -241,13 +242,13 @@ page_map_t* get_boot_page_map(void); /** @brief Setup a new page directory for a new user-level task * * @param task Pointer to the task-specific task_t structure - * @param copy If true: PGD will be a copy of the kernel's address space PGD + * @param copy If true: copy userspace pages and tables * * @return * - counter of allocated page tables * - -ENOMEM (-12) on failure */ -int create_page_map(struct task* task, int copy); +int copy_page_map(struct task* task, int copy); /** @brief Delete all page map structures of the current task * diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 2d8d6da2..3ceb9d5f 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -724,8 +724,8 @@ static int apic_probe(void) } } #endif -#endif found_mp: +#endif if (!apic_mp) goto no_mp; diff --git a/arch/x86/kernel/entry64.asm b/arch/x86/kernel/entry64.asm index eb82bce0..f9bb2c5e 100644 --- a/arch/x86/kernel/entry64.asm +++ b/arch/x86/kernel/entry64.asm @@ -343,12 +343,12 @@ init_paging: ; Enable longmode (compatibility mode) mov ecx, 0xC0000080 rdmsr - or eax, 1 << 8 ; IA32_EFER.LME = 1 + or eax, (1 << 8) | (1 << 11) ; IA32_EFER.LME = 1, IA32_EFER.NXE = 1 wrmsr ; Enable paging mov eax, cr0 - or eax, 1 << 31 | 1 << 0 ; Set the PG-bit, which is the 31nd bit, and the PE-bit, which is the 0th bit. + or eax, (1 << 31) | (1 << 0) ; Set the PG-bit, which is the 31nd bit, and the PE-bit, which is the 0th bit. mov cr0, eax ; Jump to 64-bit longmode diff --git a/arch/x86/mm/page64.c b/arch/x86/mm/page64.c index a4793a6b..93c88504 100644 --- a/arch/x86/mm/page64.c +++ b/arch/x86/mm/page64.c @@ -236,7 +236,7 @@ void page_stats(size_t from, size_t to, int reset) stats[i]++; } for (i=0; i<1; i++) { // IA-32e / PAE bits - if (*entry & (1 << 63-i)) + if (*entry & (1 << (63-i))) stats[i+PAGE_BITS]++; } } @@ -322,7 +322,7 @@ int copy_page_map(task_t* new_task, int copy) if (BUILTIN_EXPECT(!new, 0)) return -ENOMEM; - phyaddr = virt_to_phys(new); + phyaddr = virt_to_phys((size_t) new); // lock tables spinlock_lock(&kslock); @@ -378,15 +378,13 @@ int drop_page_map(void) // lock tables spinlock_irqsave_lock(&task->page_lock); - int ret = page_iterate(0, PAGE_MAP_PGT, NULL, cb); // TODO: check boundaries + page_iterate(0, PAGE_MAP_PGT, NULL, cb); // TODO: check boundaries pfree(task->page_map, PAGE_SIZE); // unlock tables spinlock_irqsave_unlock(&task->page_lock); - kprintf("drop_page_map: finished\n"); // TODO: remove - return 0; } diff --git a/include/metalsvm/tasks_types.h b/include/metalsvm/tasks_types.h index 0d692e30..3db73d88 100644 --- a/include/metalsvm/tasks_types.h +++ b/include/metalsvm/tasks_types.h @@ -36,6 +36,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -62,7 +63,6 @@ extern "C" { #define TASK_L2 (1 << 3) typedef int (*entry_point_t)(void*); -typedef struct page_map page_map_t; /** @brief The task_t structure */ typedef struct task { diff --git a/mm/vma.c b/mm/vma.c index b77d49cb..365d49e0 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -298,7 +298,7 @@ int drop_vma_list() spinlock_lock(&task->vma_lock); - while (vma = task->vma_list) { + while ((vma = task->vma_list)) { task->vma_list = vma->next; kfree(vma); } diff --git a/newlib/examples/memtest.c b/newlib/examples/memtest.c index 2a12e8b1..7730711f 100644 --- a/newlib/examples/memtest.c +++ b/newlib/examples/memtest.c @@ -74,6 +74,7 @@ int main(int argc, char** argv) } // allocate... + int i; for (i = 0; i < chunks; i++) { test[i] = malloc(size); if (test[i]) diff --git a/script.gdb b/script.gdb index 2805212e..c756b457 100644 --- a/script.gdb +++ b/script.gdb @@ -9,6 +9,7 @@ target remote localhost:1234 # Debugging 64bit code set architecture i386:x86-64 +#break main # Debugging userspace #add-symbol-file newlib/examples/memtest.sym 0x40200000