x86/asm/entry/64: Migrate error and IRQ exit work to C and remove old assembly code
authorAndy Lutomirski <luto@kernel.org>
Fri, 3 Jul 2015 19:44:31 +0000 (12:44 -0700)
committerIngo Molnar <mingo@kernel.org>
Tue, 7 Jul 2015 08:59:08 +0000 (10:59 +0200)
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: paulmck@linux.vnet.ibm.com
Link: http://lkml.kernel.org/r/60e90901eee611e59e958bfdbbe39969b4f88fe5.1435952415.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/entry/entry_64.S
arch/x86/entry/entry_64_compat.S

index 83eb63d31da488e411d73bbe3c855fdd46a20ee9..168ee264c3459696d1dbed2cb9b5e88fac6c409e 100644 (file)
@@ -508,7 +508,16 @@ END(irq_entries_start)
 
        testb   $3, CS(%rsp)
        jz      1f
+
+       /*
+        * IRQ from user mode.  Switch to kernel gsbase and inform context
+        * tracking that we're in kernel mode.
+        */
        SWAPGS
+#ifdef CONFIG_CONTEXT_TRACKING
+       call enter_from_user_mode
+#endif
+
 1:
        /*
         * Save previous stack pointer, optionally switch to interrupt stack.
@@ -547,26 +556,13 @@ ret_from_intr:
 
        testb   $3, CS(%rsp)
        jz      retint_kernel
-       /* Interrupt came from user space */
-GLOBAL(retint_user)
-       GET_THREAD_INFO(%rcx)
 
-       /* %rcx: thread info. Interrupts are off. */
-retint_with_reschedule:
-       movl    $_TIF_WORK_MASK, %edi
-retint_check:
+       /* Interrupt came from user space */
        LOCKDEP_SYS_EXIT_IRQ
-       movl    TI_flags(%rcx), %edx
-       andl    %edi, %edx
-       jnz     retint_careful
-
-retint_swapgs:                                 /* return to user-space */
-       /*
-        * The iretq could re-enable interrupts:
-        */
-       DISABLE_INTERRUPTS(CLBR_ANY)
+GLOBAL(retint_user)
+       mov     %rsp,%rdi
+       call    prepare_exit_to_usermode
        TRACE_IRQS_IRETQ
-
        SWAPGS
        jmp     restore_regs_and_iret
 
@@ -644,35 +640,6 @@ native_irq_return_ldt:
        popq    %rax
        jmp     native_irq_return_iret
 #endif
-
-       /* edi: workmask, edx: work */
-retint_careful:
-       bt      $TIF_NEED_RESCHED, %edx
-       jnc     retint_signal
-       TRACE_IRQS_ON
-       ENABLE_INTERRUPTS(CLBR_NONE)
-       pushq   %rdi
-       SCHEDULE_USER
-       popq    %rdi
-       GET_THREAD_INFO(%rcx)
-       DISABLE_INTERRUPTS(CLBR_NONE)
-       TRACE_IRQS_OFF
-       jmp     retint_check
-
-retint_signal:
-       testl   $_TIF_DO_NOTIFY_MASK, %edx
-       jz      retint_swapgs
-       TRACE_IRQS_ON
-       ENABLE_INTERRUPTS(CLBR_NONE)
-       movq    $-1, ORIG_RAX(%rsp)
-       xorl    %esi, %esi                      /* oldset */
-       movq    %rsp, %rdi                      /* &pt_regs */
-       call    do_notify_resume
-       DISABLE_INTERRUPTS(CLBR_NONE)
-       TRACE_IRQS_OFF
-       GET_THREAD_INFO(%rcx)
-       jmp     retint_with_reschedule
-
 END(common_interrupt)
 
 /*
@@ -1088,7 +1055,12 @@ ENTRY(error_entry)
        SWAPGS
 
 .Lerror_entry_from_usermode_after_swapgs:
+#ifdef CONFIG_CONTEXT_TRACKING
+       call enter_from_user_mode
+#endif
+
 .Lerror_entry_done:
+
        TRACE_IRQS_OFF
        ret
 
index d9bbd316530e40ea62c3c849623eab65601f9c7c..25aca51a6324ef6e5060b99e5b1d347c0f73fc40 100644 (file)
@@ -458,6 +458,11 @@ ia32_badarg:
        DISABLE_INTERRUPTS(CLBR_NONE)
        TRACE_IRQS_OFF
 
+       /* Now finish entering normal kernel mode. */
+#ifdef CONFIG_CONTEXT_TRACKING
+       call enter_from_user_mode
+#endif
+
        /* And exit again. */
        jmp retint_user