setjmp_64.S 1002 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #
  2. # arch/x86_64/setjmp.S
  3. #
  4. # setjmp/longjmp for the x86-64 architecture
  5. #
  6. #
  7. # The jmp_buf is assumed to contain the following, in order:
  8. # %rbx
  9. # %rsp (post-return)
  10. # %rbp
  11. # %r12
  12. # %r13
  13. # %r14
  14. # %r15
  15. # <return address>
  16. #
  17. .text
  18. .align 4
  19. .globl kernel_setjmp
  20. .type kernel_setjmp, @function
  21. kernel_setjmp:
  22. pop %rsi # Return address, and adjust the stack
  23. xorl %eax,%eax # Return value
  24. movq %rbx,(%rdi)
  25. movq %rsp,8(%rdi) # Post-return %rsp!
  26. push %rsi # Make the call/return stack happy
  27. movq %rbp,16(%rdi)
  28. movq %r12,24(%rdi)
  29. movq %r13,32(%rdi)
  30. movq %r14,40(%rdi)
  31. movq %r15,48(%rdi)
  32. movq %rsi,56(%rdi) # Return address
  33. ret
  34. .size kernel_setjmp,.-kernel_setjmp
  35. .text
  36. .align 4
  37. .globl kernel_longjmp
  38. .type kernel_longjmp, @function
  39. kernel_longjmp:
  40. movl %esi,%eax # Return value (int)
  41. movq (%rdi),%rbx
  42. movq 8(%rdi),%rsp
  43. movq 16(%rdi),%rbp
  44. movq 24(%rdi),%r12
  45. movq 32(%rdi),%r13
  46. movq 40(%rdi),%r14
  47. movq 48(%rdi),%r15
  48. jmp *56(%rdi)
  49. .size kernel_longjmp,.-kernel_longjmp