0001
0002 #
0003 # arch/x86_64/setjmp.S
0004 #
0005 # setjmp/longjmp for the x86-64 architecture
0006 #
0007
0008 #
0009 # The jmp_buf is assumed to contain the following, in order:
0010 # %rbx
0011 # %rsp (post-return)
0012 # %rbp
0013 # %r12
0014 # %r13
0015 # %r14
0016 # %r15
0017 # <return address>
0018 #
0019
0020 .text
0021 .align 4
0022 .globl kernel_setjmp
0023 .type kernel_setjmp, @function
0024 kernel_setjmp:
0025 pop %rsi # Return address, and adjust the stack
0026 xorl %eax,%eax # Return value
0027 movq %rbx,(%rdi)
0028 movq %rsp,8(%rdi) # Post-return %rsp!
0029 push %rsi # Make the call/return stack happy
0030 movq %rbp,16(%rdi)
0031 movq %r12,24(%rdi)
0032 movq %r13,32(%rdi)
0033 movq %r14,40(%rdi)
0034 movq %r15,48(%rdi)
0035 movq %rsi,56(%rdi) # Return address
0036 RET
0037
0038 .size kernel_setjmp,.-kernel_setjmp
0039
0040 .text
0041 .align 4
0042 .globl kernel_longjmp
0043 .type kernel_longjmp, @function
0044 kernel_longjmp:
0045 movl %esi,%eax # Return value (int)
0046 movq (%rdi),%rbx
0047 movq 8(%rdi),%rsp
0048 movq 16(%rdi),%rbp
0049 movq 24(%rdi),%r12
0050 movq 32(%rdi),%r13
0051 movq 40(%rdi),%r14
0052 movq 48(%rdi),%r15
0053 jmp *56(%rdi)
0054
0055 .size kernel_longjmp,.-kernel_longjmp