regs_load.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include <linux/linkage.h>
  2. #define AX 0
  3. #define BX 1 * 8
  4. #define CX 2 * 8
  5. #define DX 3 * 8
  6. #define SI 4 * 8
  7. #define DI 5 * 8
  8. #define BP 6 * 8
  9. #define SP 7 * 8
  10. #define IP 8 * 8
  11. #define FLAGS 9 * 8
  12. #define CS 10 * 8
  13. #define SS 11 * 8
  14. #define DS 12 * 8
  15. #define ES 13 * 8
  16. #define FS 14 * 8
  17. #define GS 15 * 8
  18. #define R8 16 * 8
  19. #define R9 17 * 8
  20. #define R10 18 * 8
  21. #define R11 19 * 8
  22. #define R12 20 * 8
  23. #define R13 21 * 8
  24. #define R14 22 * 8
  25. #define R15 23 * 8
  26. .text
  27. #ifdef HAVE_ARCH_X86_64_SUPPORT
  28. ENTRY(perf_regs_load)
  29. movq %rax, AX(%rdi)
  30. movq %rbx, BX(%rdi)
  31. movq %rcx, CX(%rdi)
  32. movq %rdx, DX(%rdi)
  33. movq %rsi, SI(%rdi)
  34. movq %rdi, DI(%rdi)
  35. movq %rbp, BP(%rdi)
  36. leaq 8(%rsp), %rax /* exclude this call. */
  37. movq %rax, SP(%rdi)
  38. movq 0(%rsp), %rax
  39. movq %rax, IP(%rdi)
  40. movq $0, FLAGS(%rdi)
  41. movq $0, CS(%rdi)
  42. movq $0, SS(%rdi)
  43. movq $0, DS(%rdi)
  44. movq $0, ES(%rdi)
  45. movq $0, FS(%rdi)
  46. movq $0, GS(%rdi)
  47. movq %r8, R8(%rdi)
  48. movq %r9, R9(%rdi)
  49. movq %r10, R10(%rdi)
  50. movq %r11, R11(%rdi)
  51. movq %r12, R12(%rdi)
  52. movq %r13, R13(%rdi)
  53. movq %r14, R14(%rdi)
  54. movq %r15, R15(%rdi)
  55. ret
  56. ENDPROC(perf_regs_load)
  57. #else
  58. ENTRY(perf_regs_load)
  59. push %edi
  60. movl 8(%esp), %edi
  61. movl %eax, AX(%edi)
  62. movl %ebx, BX(%edi)
  63. movl %ecx, CX(%edi)
  64. movl %edx, DX(%edi)
  65. movl %esi, SI(%edi)
  66. pop %eax
  67. movl %eax, DI(%edi)
  68. movl %ebp, BP(%edi)
  69. leal 4(%esp), %eax /* exclude this call. */
  70. movl %eax, SP(%edi)
  71. movl 0(%esp), %eax
  72. movl %eax, IP(%edi)
  73. movl $0, FLAGS(%edi)
  74. movl $0, CS(%edi)
  75. movl $0, SS(%edi)
  76. movl $0, DS(%edi)
  77. movl $0, ES(%edi)
  78. movl $0, FS(%edi)
  79. movl $0, GS(%edi)
  80. ret
  81. ENDPROC(perf_regs_load)
  82. #endif
  83. /*
  84. * We need to provide note.GNU-stack section, saying that we want
  85. * NOT executable stack. Otherwise the final linking will assume that
  86. * the ELF stack should not be restricted at all and set it RWX.
  87. */
  88. .section .note.GNU-stack,"",@progbits