- Update to 3.3-rc2.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / kernel / entry_64.S
index 3fe8239..499ceb5 100644 (file)
@@ -239,21 +239,21 @@ ENDPROC(native_usergs_sysret64)
 /*
  * initial frame state for interrupts (and exceptions without error code)
  */
-       .macro EMPTY_FRAME start=1 offset=0
-       .if \start
+       .macro EMPTY_FRAME offset=0
        CFI_STARTPROC simple
        CFI_SIGNAL_FRAME
-       CFI_DEF_CFA rsp,8+\offset
-       .else
-       CFI_DEF_CFA_OFFSET 8+\offset
-       .endif
+       CFI_DEF_CFA rsp,\offset
        .endm
 
 /*
  * initial frame state for interrupts (and exceptions without error code)
  */
        .macro INTR_FRAME start=1 offset=0
-       EMPTY_FRAME \start, SS+8+\offset-RIP
+       .if \start
+       EMPTY_FRAME SS+8+\offset-RIP
+       .else
+       CFI_DEF_CFA_OFFSET SS+8+\offset-RIP
+       .endif
        /*CFI_REL_OFFSET ss, SS+\offset-RIP*/
        CFI_REL_OFFSET rsp, RSP+\offset-RIP
        /*CFI_REL_OFFSET rflags, EFLAGS+\offset-RIP*/
@@ -267,14 +267,15 @@ ENDPROC(native_usergs_sysret64)
  */
        .macro XCPT_FRAME start=1 offset=0
        INTR_FRAME \start, RIP+\offset-ORIG_RAX
-       /*CFI_REL_OFFSET orig_rax, ORIG_RAX-ORIG_RAX*/
        .endm
 
 /*
  * frame that enables calling into C.
  */
        .macro PARTIAL_FRAME start=1 offset=0
+       .if \start >= 0
        XCPT_FRAME \start, ORIG_RAX+\offset-ARGOFFSET
+       .endif
        CFI_REL_OFFSET rdi, RDI+\offset-ARGOFFSET
        CFI_REL_OFFSET rsi, RSI+\offset-ARGOFFSET
        CFI_REL_OFFSET rdx, RDX+\offset-ARGOFFSET
@@ -290,7 +291,9 @@ ENDPROC(native_usergs_sysret64)
  * frame that enables passing a complete pt_regs to a C function.
  */
        .macro DEFAULT_FRAME start=1 offset=0
+       .if \start >= -1
        PARTIAL_FRAME \start, R11+\offset-R15
+       .endif
        CFI_REL_OFFSET rbx, RBX+\offset
        CFI_REL_OFFSET rbp, RBP+\offset
        CFI_REL_OFFSET r12, R12+\offset
@@ -346,14 +349,14 @@ ENDPROC(native_usergs_sysret64)
        .endm
 
 ENTRY(save_rest)
-       PARTIAL_FRAME 1 REST_SKIP+8
+       CFI_STARTPROC
        movq 5*8+16(%rsp), %r11 /* save return address */
-       movq_cfi rbx, RBX+16
-       movq_cfi rbp, RBP+16
-       movq_cfi r12, R12+16
-       movq_cfi r13, R13+16
-       movq_cfi r14, R14+16
-       movq_cfi r15, R15+16
+       movq %rbx, RBX+16(%rsp)
+       movq %rbp, RBP+16(%rsp)
+       movq %r12, R12+16(%rsp)
+       movq %r13, R13+16(%rsp)
+       movq %r14, R14+16(%rsp)
+       movq %r15, R15+16(%rsp)
        movq %r11, 8(%rsp)      /* return address */
        FIXUP_TOP_OF_STACK %r11, 16
        ret
@@ -363,23 +366,23 @@ END(save_rest)
 /* save complete stack frame */
        .pushsection .kprobes.text, "ax"
 ENTRY(save_paranoid)
-       XCPT_FRAME 1 RDI+8
+       XCPT_FRAME offset=ORIG_RAX-R15+8
        cld
-       movq_cfi rdi, RDI+8
-       movq_cfi rsi, RSI+8
+       movq %rdi, RDI+8(%rsp)
+       movq %rsi, RSI+8(%rsp)
        movq_cfi rdx, RDX+8
        movq_cfi rcx, RCX+8
        movq_cfi rax, RAX+8
-       movq_cfi r8, R8+8
-       movq_cfi r9, R9+8
-       movq_cfi r10, R10+8
-       movq_cfi r11, R11+8
+       movq %r8, R8+8(%rsp)
+       movq %r9, R9+8(%rsp)
+       movq %r10, R10+8(%rsp)
+       movq %r11, R11+8(%rsp)
        movq_cfi rbx, RBX+8
-       movq_cfi rbp, RBP+8
-       movq_cfi r12, R12+8
-       movq_cfi r13, R13+8
-       movq_cfi r14, R14+8
-       movq_cfi r15, R15+8
+       movq %rbp, RBP+8(%rsp)
+       movq %r12, R12+8(%rsp)
+       movq %r13, R13+8(%rsp)
+       movq %r14, R14+8(%rsp)
+       movq %r15, R15+8(%rsp)
        movl $1,%ebx
        movl $MSR_GS_BASE,%ecx
        rdmsr
@@ -676,7 +679,7 @@ ENTRY(\label)
        subq $REST_SKIP, %rsp
        CFI_ADJUST_CFA_OFFSET REST_SKIP
        call save_rest
-       DEFAULT_FRAME 0 8               /* offset 8: return address */
+       DEFAULT_FRAME -2 8              /* offset 8: return address */
        leaq 8(%rsp), \arg      /* pt_regs pointer */
        call \func
        jmp ptregscall_common
@@ -1025,7 +1028,7 @@ ENTRY(\sym)
        subq $ORIG_RAX-R15, %rsp
        CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
        call error_entry
-       DEFAULT_FRAME 0
+       DEFAULT_FRAME -1
        movq %rsp,%rdi          /* pt_regs pointer */
        xorl %esi,%esi          /* no error code */
        call \do_sym
@@ -1042,6 +1045,7 @@ ENTRY(\sym)
        subq $ORIG_RAX-R15, %rsp
        CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
        call save_paranoid
+       DEFAULT_FRAME -1
        TRACE_IRQS_OFF
        movq %rsp,%rdi          /* pt_regs pointer */
        xorl %esi,%esi          /* no error code */
@@ -1060,6 +1064,7 @@ ENTRY(\sym)
        subq $ORIG_RAX-R15, %rsp
        CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
        call save_paranoid
+       DEFAULT_FRAME -1
        TRACE_IRQS_OFF
        movq %rsp,%rdi          /* pt_regs pointer */
        xorl %esi,%esi          /* no error code */
@@ -1078,7 +1083,7 @@ ENTRY(\sym)
        subq $ORIG_RAX-R15, %rsp
        CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
        call error_entry
-       DEFAULT_FRAME 0
+       DEFAULT_FRAME -1
        movq %rsp,%rdi                  /* pt_regs pointer */
        movq ORIG_RAX(%rsp),%rsi        /* get error code */
        movq $-1,ORIG_RAX(%rsp)         /* no syscall to restart */
@@ -1096,7 +1101,7 @@ ENTRY(\sym)
        subq $ORIG_RAX-R15, %rsp
        CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
        call save_paranoid
-       DEFAULT_FRAME 0
+       DEFAULT_FRAME -1
        TRACE_IRQS_OFF
        movq %rsp,%rdi                  /* pt_regs pointer */
        movq ORIG_RAX(%rsp),%rsi        /* get error code */
@@ -1217,6 +1222,40 @@ ENTRY(call_softirq)
        CFI_ENDPROC
 END(call_softirq)
 
+#ifdef CONFIG_STACK_UNWIND
+ENTRY(arch_unwind_init_running)
+       CFI_STARTPROC
+       movq    %r15, R15(%rdi)
+       movq    %r14, R14(%rdi)
+       xchgq   %rsi, %rdx
+       movq    %r13, R13(%rdi)
+       movq    %r12, R12(%rdi)
+       xorl    %eax, %eax
+       movq    %rbp, RBP(%rdi)
+       movq    %rbx, RBX(%rdi)
+       movq    (%rsp), %r9
+       xchgq   %rdx, %rcx
+       movq    %rax, R11(%rdi)
+       movq    %rax, R10(%rdi)
+       movq    %rax, R9(%rdi)
+       movq    %rax, R8(%rdi)
+       movq    %rax, RAX(%rdi)
+       movq    %rax, RCX(%rdi)
+       movq    %rax, RDX(%rdi)
+       movq    %rax, RSI(%rdi)
+       movq    %rax, RDI(%rdi)
+       movq    %rax, ORIG_RAX(%rdi)
+       movq    %r9, RIP(%rdi)
+       leaq    8(%rsp), %r9
+       movq    $__KERNEL_CS, CS(%rdi)
+       movq    %rax, EFLAGS(%rdi)
+       movq    %r9, RSP(%rdi)
+       movq    $__KERNEL_DS, SS(%rdi)
+       jmpq    *%rcx
+       CFI_ENDPROC
+END(arch_unwind_init_running)
+#endif
+
 #ifdef CONFIG_XEN
 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
 
@@ -1406,25 +1445,24 @@ END(paranoid_exit)
  * returns in "no swapgs flag" in %ebx.
  */
 ENTRY(error_entry)
-       XCPT_FRAME
-       CFI_ADJUST_CFA_OFFSET 15*8
+       XCPT_FRAME offset=ORIG_RAX-R15+8
        /* oldrax contains error code */
        cld
-       movq_cfi rdi, RDI+8
-       movq_cfi rsi, RSI+8
-       movq_cfi rdx, RDX+8
-       movq_cfi rcx, RCX+8
-       movq_cfi rax, RAX+8
-       movq_cfi  r8,  R8+8
-       movq_cfi  r9,  R9+8
-       movq_cfi r10, R10+8
-       movq_cfi r11, R11+8
+       movq %rdi, RDI+8(%rsp)
+       movq %rsi, RSI+8(%rsp)
+       movq %rdx, RDX+8(%rsp)
+       movq %rcx, RCX+8(%rsp)
+       movq %rax, RAX+8(%rsp)
+       movq  %r8,  R8+8(%rsp)
+       movq  %r9,  R9+8(%rsp)
+       movq %r10, R10+8(%rsp)
+       movq %r11, R11+8(%rsp)
        movq_cfi rbx, RBX+8
-       movq_cfi rbp, RBP+8
-       movq_cfi r12, R12+8
-       movq_cfi r13, R13+8
-       movq_cfi r14, R14+8
-       movq_cfi r15, R15+8
+       movq %rbp, RBP+8(%rsp)
+       movq %r12, R12+8(%rsp)
+       movq %r13, R13+8(%rsp)
+       movq %r14, R14+8(%rsp)
+       movq %r15, R15+8(%rsp)
        xorl %ebx,%ebx
        testl $3,CS+8(%rsp)
        je error_kernelspace
@@ -1442,6 +1480,7 @@ error_sti:
  * compat mode. Check for these here too.
  */
 error_kernelspace:
+       CFI_REL_OFFSET rcx, RCX+8
        incl %ebx
        leaq irq_return(%rip),%rcx
        cmpq %rcx,RIP+8(%rsp)
@@ -1651,7 +1690,7 @@ restart_nmi:
         * exceptions might do.
         */
        call save_paranoid
-       DEFAULT_FRAME 0
+       DEFAULT_FRAME -1
        /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
        movq %rsp,%rdi
        movq $-1,%rsi