x86_64, traps: Stop using IST for #SS
[pandora-kernel.git] / arch / x86 / kernel / entry_64.S
index 2fac134..49a0c17 100644 (file)
@@ -404,8 +404,8 @@ GLOBAL(system_call_after_swapgs)
         * and short:
         */
        ENABLE_INTERRUPTS(CLBR_NONE)
-       SAVE_ARGS 8,0
-       movq  %rax,ORIG_RAX-ARGOFFSET(%rsp)
+       SAVE_ARGS 8, 0, rax_enosys=1
+       movq_cfi rax,(ORIG_RAX-ARGOFFSET)
        movq  %rcx,RIP-ARGOFFSET(%rsp)
        CFI_REL_OFFSET rip,RIP-ARGOFFSET
        testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
@@ -417,7 +417,7 @@ system_call_fastpath:
        andl $__SYSCALL_MASK,%eax
        cmpl $__NR_syscall_max,%eax
 #endif
-       ja badsys
+       ja ret_from_sys_call  /* and return regs->ax */
        movq %r10,%rcx
        call *sys_call_table(,%rax,8)  # XXX:    rip relative
        movq %rax,RAX-ARGOFFSET(%rsp)
@@ -476,27 +476,7 @@ sysret_signal:
        FIXUP_TOP_OF_STACK %r11, -ARGOFFSET
        jmp int_check_syscall_exit_work
 
-badsys:
-       movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
-       jmp ret_from_sys_call
-
 #ifdef CONFIG_AUDITSYSCALL
-       /*
-        * Fast path for syscall audit without full syscall trace.
-        * We just call __audit_syscall_entry() directly, and then
-        * jump back to the normal fast path.
-        */
-auditsys:
-       movq %r10,%r9                   /* 6th arg: 4th syscall arg */
-       movq %rdx,%r8                   /* 5th arg: 3rd syscall arg */
-       movq %rsi,%rcx                  /* 4th arg: 2nd syscall arg */
-       movq %rdi,%rdx                  /* 3rd arg: 1st syscall arg */
-       movq %rax,%rsi                  /* 2nd arg: syscall number */
-       movl $AUDIT_ARCH_X86_64,%edi    /* 1st arg: audit arch */
-       call __audit_syscall_entry
-       LOAD_ARGS 0             /* reload call-clobbered registers */
-       jmp system_call_fastpath
-
        /*
         * Return fast path for syscall audit.  Call __audit_syscall_exit()
         * directly and then jump back to the fast path with TIF_SYSCALL_AUDIT
@@ -514,18 +494,25 @@ sysret_audit:
 
        /* Do syscall tracing */
 tracesys:
-#ifdef CONFIG_AUDITSYSCALL
-       testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
-       jz auditsys
-#endif
+       leaq -REST_SKIP(%rsp), %rdi
+       movq $AUDIT_ARCH_X86_64, %rsi
+       call syscall_trace_enter_phase1
+       test %rax, %rax
+       jnz tracesys_phase2             /* if needed, run the slow path */
+       LOAD_ARGS 0                     /* else restore clobbered regs */
+       jmp system_call_fastpath        /*      and return to the fast path */
+
+tracesys_phase2:
        SAVE_REST
-       movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
        FIXUP_TOP_OF_STACK %rdi
-       movq %rsp,%rdi
-       call syscall_trace_enter
+       movq %rsp, %rdi
+       movq $AUDIT_ARCH_X86_64, %rsi
+       movq %rax,%rdx
+       call syscall_trace_enter_phase2
+
        /*
         * Reload arg registers from stack in case ptrace changed them.
-        * We don't reload %rax because syscall_trace_enter() returned
+        * We don't reload %rax because syscall_trace_entry_phase2() returned
         * the value it wants us to use in the table lookup.
         */
        LOAD_ARGS ARGOFFSET, 1
@@ -536,7 +523,7 @@ tracesys:
        andl $__SYSCALL_MASK,%eax
        cmpl $__NR_syscall_max,%eax
 #endif
-       ja   int_ret_from_sys_call      /* RAX(%rsp) set to -ENOSYS above */
+       ja   int_ret_from_sys_call      /* RAX(%rsp) is already set */
        movq %r10,%rcx  /* fixup for C */
        call *sys_call_table(,%rax,8)
        movq %rax,RAX-ARGOFFSET(%rsp)
@@ -841,6 +828,7 @@ ENTRY(native_iret)
        jnz native_irq_return_ldt
 #endif
 
+.global native_irq_return_iret
 native_irq_return_iret:
        iretq
        _ASM_EXTABLE(native_irq_return_iret, bad_iret)
@@ -935,37 +923,6 @@ ENTRY(retint_kernel)
        CFI_ENDPROC
 END(common_interrupt)
 
-       /*
-        * If IRET takes a fault on the espfix stack, then we
-        * end up promoting it to a doublefault.  In that case,
-        * modify the stack to make it look like we just entered
-        * the #GP handler from user space, similar to bad_iret.
-        */
-#ifdef CONFIG_X86_ESPFIX64
-       ALIGN
-__do_double_fault:
-       XCPT_FRAME 1 RDI+8
-       movq RSP(%rdi),%rax             /* Trap on the espfix stack? */
-       sarq $PGDIR_SHIFT,%rax
-       cmpl $ESPFIX_PGD_ENTRY,%eax
-       jne do_double_fault             /* No, just deliver the fault */
-       cmpl $__KERNEL_CS,CS(%rdi)
-       jne do_double_fault
-       movq RIP(%rdi),%rax
-       cmpq $native_irq_return_iret,%rax
-       jne do_double_fault             /* This shouldn't happen... */
-       movq PER_CPU_VAR(kernel_stack),%rax
-       subq $(6*8-KERNEL_STACK_OFFSET),%rax    /* Reset to original stack */
-       movq %rax,RSP(%rdi)
-       movq $0,(%rax)                  /* Missing (lost) #GP error code */
-       movq $general_protection,RIP(%rdi)
-       retq
-       CFI_ENDPROC
-END(__do_double_fault)
-#else
-# define __do_double_fault do_double_fault
-#endif
-
 /*
  * APIC interrupts.
  */
@@ -1137,7 +1094,7 @@ idtentry overflow do_overflow has_error_code=0
 idtentry bounds do_bounds has_error_code=0
 idtentry invalid_op do_invalid_op has_error_code=0
 idtentry device_not_available do_device_not_available has_error_code=0
-idtentry double_fault __do_double_fault has_error_code=1 paranoid=1
+idtentry double_fault do_double_fault has_error_code=1 paranoid=1
 idtentry coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0
 idtentry invalid_TSS do_invalid_TSS has_error_code=1
 idtentry segment_not_present do_segment_not_present has_error_code=1
@@ -1302,7 +1259,7 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
 
 idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
 idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
-idtentry stack_segment do_stack_segment has_error_code=1 paranoid=1
+idtentry stack_segment do_stack_segment has_error_code=1
 #ifdef CONFIG_XEN
 idtentry xen_debug do_debug has_error_code=0
 idtentry xen_int3 do_int3 has_error_code=0