From c4c5e435cc0f0155bff27d077b9e759c6508efc8 Mon Sep 17 00:00:00 2001 From: Tomoki Shirasawa Date: Wed, 24 Feb 2016 20:57:45 +0900 Subject: [PATCH] fix REQ-12 --- arch/x86/kernel/cpu.c | 56 ++++++++++++++++++++++++++++++++++++++++++ kernel/mem.c | 57 +------------------------------------------ 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/arch/x86/kernel/cpu.c b/arch/x86/kernel/cpu.c index d8528c97..c6e66651 100644 --- a/arch/x86/kernel/cpu.c +++ b/arch/x86/kernel/cpu.c @@ -81,6 +81,7 @@ void x86_set_warm_reset(unsigned long ip, char *first_page_va); void x86_init_perfctr(void); int gettime_local_support = 0; +extern int ihk_mc_pt_print_pte(struct page_table *pt, void *virt); extern int kprintf(const char *format, ...); extern int interrupt_from_user(void *); @@ -934,6 +935,61 @@ void int3_handler(struct x86_user_context *regs) set_cputime(0); } +void +unhandled_page_fault(struct thread *thread, void *fault_addr, void *regs) +{ + const uintptr_t address = (uintptr_t)fault_addr; + struct process_vm *vm = thread->vm; + struct vm_range *range; + char found; + unsigned long irqflags; + unsigned long error = ((struct x86_user_context *)regs)->gpr.error; + + irqflags = kprintf_lock(); + dkprintf("[%d] Page fault for 0x%lX\n", + ihk_mc_get_processor_id(), address); + dkprintf("%s for %s access in %s mode (reserved bit %s set), " + "it %s an instruction fetch\n", + (error & PF_PROT ? "protection fault" : "no page found"), + (error & PF_WRITE ? "write" : "read"), + (error & PF_USER ? "user" : "kernel"), + (error & PF_RSVD ? "was" : "wasn't"), + (error & PF_INSTR ? "was" : "wasn't")); + + found = 0; + list_for_each_entry(range, &vm->vm_range_list, list) { + if (range->start <= address && range->end > address) { + found = 1; + dkprintf("address is in range, flag: 0x%X! \n", + range->flag); + ihk_mc_pt_print_pte(vm->address_space->page_table, (void*)address); + break; + } + } + if (!found) { + dkprintf("address is out of range! \n"); + } + + kprintf_unlock(irqflags); + + /* TODO */ + ihk_mc_debug_show_interrupt_context(regs); + + + //dkprintf("now dump a core file\n"); + //coredump(proc, regs); + +#ifdef DEBUG_PRINT_MEM + { + uint64_t *sp = (void *)REGS_GET_STACK_POINTER(regs); + + kprintf("*rsp:%lx,*rsp+8:%lx,*rsp+16:%lx,*rsp+24:%lx,\n", + sp[0], sp[1], sp[2], sp[3]); + } +#endif + + return; +} static void outb(uint8_t v, uint16_t port) { diff --git a/kernel/mem.c b/kernel/mem.c index a06140cf..e072d7bd 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -52,7 +52,7 @@ static struct ihk_page_allocator_desc *pa_allocator; static unsigned long pa_start, pa_end; static struct page *pa_pages; -extern int ihk_mc_pt_print_pte(struct page_table *pt, void *virt); +extern void unhandled_page_fault(struct thread *, void *, void *); extern int interrupt_from_user(void *); struct tlb_flush_entry tlb_flush_vector[IHK_TLB_FLUSH_IRQ_VECTOR_SIZE]; @@ -210,61 +210,6 @@ void coredump(struct thread *thread, void *regs) freecore(&coretable); } -static void unhandled_page_fault(struct thread *thread, void *fault_addr, void *regs) -{ - const uintptr_t address = (uintptr_t)fault_addr; - struct process_vm *vm = thread->vm; - struct vm_range *range; - char found; - unsigned long irqflags; - unsigned long error = ((struct x86_user_context *)regs)->gpr.error; - - irqflags = kprintf_lock(); - dkprintf("[%d] Page fault for 0x%lX\n", - ihk_mc_get_processor_id(), address); - dkprintf("%s for %s access in %s mode (reserved bit %s set), " - "it %s an instruction fetch\n", - (error & PF_PROT ? "protection fault" : "no page found"), - (error & PF_WRITE ? "write" : "read"), - (error & PF_USER ? "user" : "kernel"), - (error & PF_RSVD ? "was" : "wasn't"), - (error & PF_INSTR ? "was" : "wasn't")); - - found = 0; - list_for_each_entry(range, &vm->vm_range_list, list) { - if (range->start <= address && range->end > address) { - found = 1; - dkprintf("address is in range, flag: 0x%X! \n", - range->flag); - ihk_mc_pt_print_pte(vm->address_space->page_table, (void*)address); - break; - } - } - if (!found) { - dkprintf("address is out of range! \n"); - } - - kprintf_unlock(irqflags); - - /* TODO */ - ihk_mc_debug_show_interrupt_context(regs); - - - //dkprintf("now dump a core file\n"); - //coredump(proc, regs); - -#ifdef DEBUG_PRINT_MEM - { - uint64_t *sp = (void *)REGS_GET_STACK_POINTER(regs); - - kprintf("*rsp:%lx,*rsp+8:%lx,*rsp+16:%lx,*rsp+24:%lx,\n", - sp[0], sp[1], sp[2], sp[3]); - } -#endif - - return; -} - void remote_flush_tlb_cpumask(struct process_vm *vm, unsigned long addr, int cpu_id) {