x86/entry/64: Reorder idtentries
[sfrench/cifs-2.6.git] / arch / x86 / entry / entry_64.S
index eead1e2bebd5c12f1bda7539760ae728b268a09b..e62061e02b21c59c17021238d25d46f9d371ec56 100644 (file)
@@ -167,15 +167,11 @@ SYM_INNER_LABEL(entry_SYSCALL_64_after_hwframe, SYM_L_GLOBAL)
 
        PUSH_AND_CLEAR_REGS rax=$-ENOSYS
 
-       TRACE_IRQS_OFF
-
        /* IRQs are off. */
        movq    %rax, %rdi
        movq    %rsp, %rsi
        call    do_syscall_64           /* returns with IRQs disabled */
 
-       TRACE_IRQS_ON                   /* return enables interrupts */
-
        /*
         * Try to use SYSRET instead of IRET if we're returning to
         * a completely clean 64-bit userspace context.  If we're not,
@@ -279,6 +275,7 @@ SYM_CODE_END(entry_SYSCALL_64)
  * %rdi: prev task
  * %rsi: next task
  */
+.pushsection .text, "ax"
 SYM_FUNC_START(__switch_to_asm)
        /*
         * Save callee-saved registers
@@ -321,6 +318,7 @@ SYM_FUNC_START(__switch_to_asm)
 
        jmp     __switch_to
 SYM_FUNC_END(__switch_to_asm)
+.popsection
 
 /*
  * A newly forked process directly context switches into this address.
@@ -329,6 +327,7 @@ SYM_FUNC_END(__switch_to_asm)
  * rbx: kernel thread func (NULL for user thread)
  * r12: kernel thread arg
  */
+.pushsection .text, "ax"
 SYM_CODE_START(ret_from_fork)
        UNWIND_HINT_EMPTY
        movq    %rax, %rdi
@@ -341,7 +340,6 @@ SYM_CODE_START(ret_from_fork)
        UNWIND_HINT_REGS
        movq    %rsp, %rdi
        call    syscall_return_slowpath /* returns with IRQs disabled */
-       TRACE_IRQS_ON                   /* user mode is traced as IRQS on */
        jmp     swapgs_restore_regs_and_return_to_usermode
 
 1:
@@ -357,6 +355,7 @@ SYM_CODE_START(ret_from_fork)
        movq    $0, RAX(%rsp)
        jmp     2b
 SYM_CODE_END(ret_from_fork)
+.popsection
 
 /*
  * Build the entry stubs with some assembler magic.
@@ -618,7 +617,6 @@ ret_from_intr:
 .Lretint_user:
        mov     %rsp,%rdi
        call    prepare_exit_to_usermode
-       TRACE_IRQS_ON
 
 SYM_INNER_LABEL(swapgs_restore_regs_and_return_to_usermode, SYM_L_GLOBAL)
 #ifdef CONFIG_DEBUG_ENTRY
@@ -798,7 +796,6 @@ _ASM_NOKPROBE(common_interrupt)
 SYM_CODE_START(\sym)
        UNWIND_HINT_IRET_REGS
        pushq   $~(\num)
-.Lcommon_\sym:
        call    interrupt_entry
        UNWIND_HINT_REGS indirect=1
        call    \do_sym /* rdi points to pt_regs */
@@ -890,12 +887,14 @@ apicinterrupt IRQ_WORK_VECTOR                     irq_work_interrupt              smp_irq_work_interrupt
        TRACE_IRQS_OFF
        .endif
 
+#ifdef CONFIG_CONTEXT_TRACKING
        .if \paranoid == 0
        testb   $3, CS(%rsp)
        jz      .Lfrom_kernel_no_context_tracking_\@
        CALL_enter_from_user_mode
 .Lfrom_kernel_no_context_tracking_\@:
        .endif
+#endif
 
        movq    %rsp, %rdi                      /* pt_regs pointer */
 
@@ -1021,47 +1020,60 @@ _ASM_NOKPROBE(\sym)
 SYM_CODE_END(\sym)
 .endm
 
+
 idtentry divide_error                  do_divide_error                 has_error_code=0
 idtentry overflow                      do_overflow                     has_error_code=0
+idtentry int3                          do_int3                         has_error_code=0        create_gap=1
 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=2 read_cr2=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
+idtentry stack_segment                 do_stack_segment                has_error_code=1
+idtentry general_protection            do_general_protection           has_error_code=1
 idtentry spurious_interrupt_bug                do_spurious_interrupt_bug       has_error_code=0
 idtentry coprocessor_error             do_coprocessor_error            has_error_code=0
 idtentry alignment_check               do_alignment_check              has_error_code=1
 idtentry simd_coprocessor_error                do_simd_coprocessor_error       has_error_code=0
 
+idtentry page_fault            do_page_fault           has_error_code=1        read_cr2=1
 
-       /*
-        * Reload gs selector with exception handling
-        * edi:  new selector
-        */
-SYM_FUNC_START(native_load_gs_index)
+#ifdef CONFIG_X86_MCE
+idtentry machine_check         do_mce                  has_error_code=0 paranoid=1
+#endif
+idtentry debug                 do_debug                has_error_code=0 paranoid=1 shift_ist=IST_INDEX_DB ist_offset=DB_STACK_OFFSET
+idtentry double_fault          do_double_fault         has_error_code=1 paranoid=2 read_cr2=1
+
+#ifdef CONFIG_XEN_PV
+idtentry hypervisor_callback   xen_do_hypervisor_callback      has_error_code=0
+idtentry xennmi                        do_nmi                          has_error_code=0
+idtentry xendebug              do_debug                        has_error_code=0
+#endif
+
+/*
+ * Reload gs selector with exception handling
+ * edi:  new selector
+ *
+ * Is in entry.text as it shouldn't be instrumented.
+ */
+SYM_FUNC_START(asm_load_gs_index)
        FRAME_BEGIN
-       pushfq
-       DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
-       TRACE_IRQS_OFF
-       SWAPGS
+       swapgs
 .Lgs_change:
        movl    %edi, %gs
 2:     ALTERNATIVE "", "mfence", X86_BUG_SWAPGS_FENCE
-       SWAPGS
-       TRACE_IRQS_FLAGS (%rsp)
-       popfq
+       swapgs
        FRAME_END
        ret
-SYM_FUNC_END(native_load_gs_index)
-EXPORT_SYMBOL(native_load_gs_index)
+SYM_FUNC_END(asm_load_gs_index)
+EXPORT_SYMBOL(asm_load_gs_index)
 
        _ASM_EXTABLE(.Lgs_change, .Lbad_gs)
        .section .fixup, "ax"
        /* running with kernelgs */
 SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs)
-       SWAPGS                                  /* switch back to user gs */
+       swapgs                                  /* switch back to user gs */
 .macro ZAP_GS
        /* This can't be a string because the preprocessor needs to see it. */
        movl $__USER_DS, %eax
@@ -1075,6 +1087,7 @@ SYM_CODE_END(.Lbad_gs)
        .previous
 
 /* Call softirq on interrupt stack. Interrupts are off. */
+.pushsection .text, "ax"
 SYM_FUNC_START(do_softirq_own_stack)
        pushq   %rbp
        mov     %rsp, %rbp
@@ -1084,10 +1097,9 @@ SYM_FUNC_START(do_softirq_own_stack)
        leaveq
        ret
 SYM_FUNC_END(do_softirq_own_stack)
+.popsection
 
 #ifdef CONFIG_XEN_PV
-idtentry hypervisor_callback xen_do_hypervisor_callback has_error_code=0
-
 /*
  * A note on the "critical region" in our callback handler.
  * We want to avoid stacking callback handlers due to events occurring
@@ -1190,22 +1202,6 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
        acrn_hv_callback_vector acrn_hv_vector_handler
 #endif
 
-idtentry debug                 do_debug                has_error_code=0        paranoid=1 shift_ist=IST_INDEX_DB ist_offset=DB_STACK_OFFSET
-idtentry int3                  do_int3                 has_error_code=0        create_gap=1
-idtentry stack_segment         do_stack_segment        has_error_code=1
-
-#ifdef CONFIG_XEN_PV
-idtentry xennmi                        do_nmi                  has_error_code=0
-idtentry xendebug              do_debug                has_error_code=0
-#endif
-
-idtentry general_protection    do_general_protection   has_error_code=1
-idtentry page_fault            do_page_fault           has_error_code=1        read_cr2=1
-
-#ifdef CONFIG_X86_MCE
-idtentry machine_check         do_mce                  has_error_code=0        paranoid=1
-#endif
-
 /*
  * Save all registers in pt_regs, and switch gs if needed.
  * Use slow, but surefire "are we in kernel?" check.
@@ -1335,7 +1331,6 @@ SYM_CODE_START_LOCAL(error_entry)
         */
        SWAPGS
        FENCE_SWAPGS_USER_ENTRY
-       SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
        jmp .Lerror_entry_done
 
 .Lbstep_iret:
@@ -1728,6 +1723,7 @@ SYM_CODE_START(ignore_sysret)
 SYM_CODE_END(ignore_sysret)
 #endif
 
+.pushsection .text, "ax"
 SYM_CODE_START(rewind_stack_do_exit)
        UNWIND_HINT_FUNC
        /* Prevent any naive code from trying to unwind to our caller. */
@@ -1739,3 +1735,4 @@ SYM_CODE_START(rewind_stack_do_exit)
 
        call    do_exit
 SYM_CODE_END(rewind_stack_do_exit)
+.popsection