x86: fixes 32 bit trap-syscalls
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 16 Jul 2013 00:08:17 +0000 (17:08 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 16 Jul 2013 00:08:17 +0000 (17:08 -0700)
Broken since dd07360f, since our sysenter and trap methods expect their args in
different registers (on 32 bit).

kern/arch/x86/trap.c
kern/arch/x86/trap32.h
kern/arch/x86/trap64.h

index a817365..8c8ae2e 100644 (file)
@@ -274,8 +274,8 @@ static void trap_dispatch(struct hw_trapframe *hw_tf)
                        /* Set up and run the async calls */
                        /* TODO: this is using the wrong reg1 for traps for 32 bit */
                        prep_syscalls(current,
-                                     (struct syscall*)x86_get_sysenter_arg0(hw_tf),
-                                                 (unsigned int)x86_get_sysenter_arg1(hw_tf));
+                                     (struct syscall*)x86_get_systrap_arg0(hw_tf),
+                                                 (unsigned int)x86_get_systrap_arg1(hw_tf));
                        break;
                default:
                        // Unexpected trap: The user process or the kernel has a bug.
index 9d286d0..918d4c3 100644 (file)
@@ -85,6 +85,16 @@ static inline long x86_get_sysenter_arg1(struct hw_trapframe *hw_tf)
        return hw_tf->tf_regs.reg_esi;
 }
 
+static inline long x86_get_systrap_arg0(struct hw_trapframe *hw_tf)
+{
+       return hw_tf->tf_regs.reg_eax;
+}
+
+static inline long x86_get_systrap_arg1(struct hw_trapframe *hw_tf)
+{
+       return hw_tf->tf_regs.reg_edx;
+}
+
 static inline uintptr_t x86_get_stacktop_tss(struct taskstate *tss)
 {
        return tss->ts_esp0;
index 958ad63..9506727 100644 (file)
@@ -94,6 +94,16 @@ static inline long x86_get_sysenter_arg1(struct hw_trapframe *hw_tf)
        return hw_tf->tf_rsi;
 }
 
+static inline long x86_get_systrap_arg0(struct hw_trapframe *hw_tf)
+{
+       return hw_tf->tf_rdi;
+}
+
+static inline long x86_get_systrap_arg1(struct hw_trapframe *hw_tf)
+{
+       return hw_tf->tf_rsi;
+}
+
 static inline uintptr_t x86_get_stacktop_tss(struct taskstate *tss)
 {
        return tss->ts_rsp0;