regs_load.S 1.9 KB

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