From: John Hodge Date: Mon, 26 Sep 2011 05:07:19 +0000 (+0800) Subject: Kernel/x86_64 - Debugging iret->CPL3 crash X-Git-Tag: rel0.11~58 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=58c7107eb0a5ae254c135f2eaa6263751f1ebe67;p=tpg%2Facess2.git Kernel/x86_64 - Debugging iret->CPL3 crash --- diff --git a/Kernel/arch/x86_64/desctab.asm b/Kernel/arch/x86_64/desctab.asm index 694672c7..739b219f 100644 --- a/Kernel/arch/x86_64/desctab.asm +++ b/Kernel/arch/x86_64/desctab.asm @@ -374,6 +374,7 @@ SchedulerIRQ: pop gs POP_GPR add rsp, 2*8 ; Dummy error code and IRQ num +; xchg bx, bx iretq [extern ci_offsetof_tThread_KernelStack] @@ -416,6 +417,10 @@ SyscallStub: pop r11 pop rcx pop rsp ; Change back to user stack + ; TODO: Determine if user is 64 or 32 bit + +; xchg bx, bx + db 0x48 ; REX, nasm doesn't have a sysretq opcode sysret [section .data] diff --git a/Kernel/arch/x86_64/mm_virt.c b/Kernel/arch/x86_64/mm_virt.c index a34c6ad2..1640586b 100644 --- a/Kernel/arch/x86_64/mm_virt.c +++ b/Kernel/arch/x86_64/mm_virt.c @@ -90,11 +90,11 @@ void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs) { // TODO: Implement Copy-on-Write #if 1 - if( PAGEMAPLVL4(Addr>39) & PF_PRESENT - && PAGEDIRPTR(Addr>>30) & PF_PRESENT - && PAGEDIR(Addr>>21) & PF_PRESENT - && PAGETABLE(Addr>>12) & PF_PRESENT - && PAGETABLE(Addr>>12) & PF_COW ) + if( PAGEMAPLVL4(Addr>>39) & PF_PRESENT + && PAGEDIRPTR (Addr>>30) & PF_PRESENT + && PAGEDIR (Addr>>21) & PF_PRESENT + && PAGETABLE (Addr>>12) & PF_PRESENT + && PAGETABLE (Addr>>12) & PF_COW ) { tPAddr paddr; if(MM_GetRefCount( PAGETABLE(Addr>>12) & PADDR_MASK ) == 1)