setjmp_64.S 1.0 KB

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