Fixed kernel page fault on x86 port
authorKevin Klues <klueska@ros-dev.(none)>
Tue, 23 Mar 2010 02:26:44 +0000 (19:26 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:37 +0000 (17:35 -0700)
On sysenter, we now push zeros for esp and ss
onto the stack.  Thus, examining these fields
does not cause a page fault anymore.

kern/arch/i686/trap.c
kern/arch/i686/trap.h
kern/arch/i686/trapentry.S

index 8915ca8..7cbed53 100644 (file)
@@ -156,6 +156,8 @@ print_trapframe(trapframe_t *tf)
        spin_lock_irqsave(&ptf_lock);
        cprintf("TRAP frame at %p on core %d\n", tf, core_id());
        print_regs(&tf->tf_regs);
+       cprintf("  gs   0x----%04x\n", tf->tf_gs);
+       cprintf("  fs   0x----%04x\n", tf->tf_fs);
        cprintf("  es   0x----%04x\n", tf->tf_es);
        cprintf("  ds   0x----%04x\n", tf->tf_ds);
        cprintf("  trap 0x%08x %s\n", tf->tf_trapno, trapname(tf->tf_trapno));
@@ -184,6 +186,7 @@ trap_dispatch(trapframe_t *tf)
                        assert(tf->tf_cs != GD_KT);
                        // syscall code wants an edible reference for current
                        proc_incref(current, 1);
+print_trapframe(tf);
                        tf->tf_regs.reg_eax =
                                syscall(current, tf->tf_regs.reg_eax, tf->tf_regs.reg_edx,
                                        tf->tf_regs.reg_ecx, tf->tf_regs.reg_ebx,
index 5a6227b..9a77295 100644 (file)
@@ -110,8 +110,4 @@ static inline void set_errno(trapframe_t* tf, uint32_t errno)
 
 #endif /* !__ASSEMBLER__ */
 
-// Must equal 'sizeof(trapframe_t)'.
-// A static_assert in kern/trap.c checks this.
-#define SIZEOF_STRUCT_TRAPFRAME        0x44
-
 #endif /* !ROS_INC_ARCH_TRAP_H */
index 8c31530..424876a 100644 (file)
@@ -238,6 +238,8 @@ _allirqs:
 sysenter_handler:
        sti                                             # enable interrupts (things are sane here)
        cld
+       pushl $0                                # esp
+       pushl $0                                # ss
        pushfl                                  # save the eflags
        pushl $0                                # these zeros keep the trapframe looking the same
        pushl $0                                # as when we receive a trap or interrupt