]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - arch/x86/kernel/entry_64.S
Merge branch 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / arch / x86 / kernel / entry_64.S
index e0eca007dc0d6e6bc1159fbd26a18ed16023640d..734ebd1d3caabf0e0b058a1f8ed6aa947c1caf95 100644 (file)
@@ -320,7 +320,7 @@ ENDPROC(native_usergs_sysret64)
        movq %rsp, %rsi
 
        leaq -RBP(%rsp),%rdi    /* arg1 for handler */
-       testl $3, CS(%rdi)
+       testl $3, CS-RBP(%rsi)
        je 1f
        SWAPGS
        /*
@@ -330,11 +330,10 @@ ENDPROC(native_usergs_sysret64)
         * moving irq_enter into assembly, which would be too much work)
         */
 1:     incl PER_CPU_VAR(irq_count)
-       jne 2f
-       mov PER_CPU_VAR(irq_stack_ptr),%rsp
+       cmovzq PER_CPU_VAR(irq_stack_ptr),%rsp
        CFI_DEF_CFA_REGISTER    rsi
 
-2:     /* Store previous stack value */
+       /* Store previous stack value */
        pushq %rsi
        CFI_ESCAPE      0x0f /* DW_CFA_def_cfa_expression */, 6, \
                        0x77 /* DW_OP_breg7 */, 0, \
@@ -813,7 +812,7 @@ ret_from_intr:
 
        /* Restore saved previous stack */
        popq %rsi
-       CFI_DEF_CFA_REGISTER    rsi
+       CFI_DEF_CFA rsi,SS+8-RBP        /* reg/off reset after def_cfa_expr */
        leaq ARGOFFSET-RBP(%rsi), %rsp
        CFI_DEF_CFA_REGISTER    rsp
        CFI_ADJUST_CFA_OFFSET   RBP-ARGOFFSET
@@ -1624,11 +1623,12 @@ first_nmi:
         * | pt_regs                 |
         * +-------------------------+
         *
-        * The saved RIP is used to fix up the copied RIP that a nested
-        * NMI may zero out. The original stack frame and the temp storage
+        * The saved stack frame is used to fix up the copied stack frame
+        * that a nested NMI may change to make the interrupted NMI iret jump
+        * to the repeat_nmi. The original stack frame and the temp storage
         * is also used by nested NMIs and can not be trusted on exit.
         */
-       /* Do not pop rdx, nested NMIs will corrupt it */
+       /* Do not pop rdx, nested NMIs will corrupt that part of the stack */
        movq (%rsp), %rdx
        CFI_RESTORE rdx
 
@@ -1641,6 +1641,8 @@ first_nmi:
        .endr
        CFI_DEF_CFA_OFFSET SS+8-RIP
 
+       /* Everything up to here is safe from nested NMIs */
+
        /*
         * If there was a nested NMI, the first NMI's iret will return
         * here. But NMIs are still enabled and we can take another
@@ -1667,9 +1669,8 @@ end_repeat_nmi:
 
        /*
         * Everything below this point can be preempted by a nested
-        * NMI if the first NMI took an exception. Repeated NMIs
-        * caused by an exception and nested NMI will start here, and
-        * can still be preempted by another NMI.
+        * NMI if the first NMI took an exception and reset our iret stack
+        * so that we repeat another NMI.
         */
        pushq_cfi $-1           /* ORIG_RAX: no syscall to restart */
        subq $ORIG_RAX-R15, %rsp