sysenter.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Code for the vsyscall page. This version uses the sysenter instruction.
  3. *
  4. * NOTE:
  5. * 1) __kernel_vsyscall _must_ be first in this page.
  6. * 2) there are alignment constraints on this stub, see vsyscall-sigreturn.S
  7. * for details.
  8. */
  9. /*
  10. * The caller puts arg2 in %ecx, which gets pushed. The kernel will use
  11. * %ecx itself for arg2. The pushing is because the sysexit instruction
  12. * (found in entry.S) requires that we clobber %ecx with the desired %esp.
  13. * User code might expect that %ecx is unclobbered though, as it would be
  14. * for returning via the iret instruction, so we must push and pop.
  15. *
  16. * The caller puts arg3 in %edx, which the sysexit instruction requires
  17. * for %eip. Thus, exactly as for arg2, we must push and pop.
  18. *
  19. * Arg6 is different. The caller puts arg6 in %ebp. Since the sysenter
  20. * instruction clobbers %esp, the user's %esp won't even survive entry
  21. * into the kernel. We store %esp in %ebp. Code in entry.S must fetch
  22. * arg6 from the stack.
  23. *
  24. * You can not use this vsyscall for the clone() syscall because the
  25. * three dwords on the parent stack do not get copied to the child.
  26. */
  27. .text
  28. .globl __kernel_vsyscall
  29. .type __kernel_vsyscall,@function
  30. __kernel_vsyscall:
  31. .LSTART_vsyscall:
  32. push %ecx
  33. .Lpush_ecx:
  34. push %edx
  35. .Lpush_edx:
  36. push %ebp
  37. .Lenter_kernel:
  38. movl %esp,%ebp
  39. sysenter
  40. /* 7: align return point with nop's to make disassembly easier */
  41. .space 7,0x90
  42. /* 14: System call restart point is here! (SYSENTER_RETURN-2) */
  43. jmp .Lenter_kernel
  44. /* 16: System call normal return point is here! */
  45. VDSO32_SYSENTER_RETURN: /* Symbol used by sysenter.c via vdso32-syms.h */
  46. pop %ebp
  47. .Lpop_ebp:
  48. pop %edx
  49. .Lpop_edx:
  50. pop %ecx
  51. .Lpop_ecx:
  52. ret
  53. .LEND_vsyscall:
  54. .size __kernel_vsyscall,.-.LSTART_vsyscall
  55. .previous
  56. .section .eh_frame,"a",@progbits
  57. .LSTARTFRAMEDLSI:
  58. .long .LENDCIEDLSI-.LSTARTCIEDLSI
  59. .LSTARTCIEDLSI:
  60. .long 0 /* CIE ID */
  61. .byte 1 /* Version number */
  62. .string "zR" /* NUL-terminated augmentation string */
  63. .uleb128 1 /* Code alignment factor */
  64. .sleb128 -4 /* Data alignment factor */
  65. .byte 8 /* Return address register column */
  66. .uleb128 1 /* Augmentation value length */
  67. .byte 0x1b /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
  68. .byte 0x0c /* DW_CFA_def_cfa */
  69. .uleb128 4
  70. .uleb128 4
  71. .byte 0x88 /* DW_CFA_offset, column 0x8 */
  72. .uleb128 1
  73. .align 4
  74. .LENDCIEDLSI:
  75. .long .LENDFDEDLSI-.LSTARTFDEDLSI /* Length FDE */
  76. .LSTARTFDEDLSI:
  77. .long .LSTARTFDEDLSI-.LSTARTFRAMEDLSI /* CIE pointer */
  78. .long .LSTART_vsyscall-. /* PC-relative start address */
  79. .long .LEND_vsyscall-.LSTART_vsyscall
  80. .uleb128 0
  81. /* What follows are the instructions for the table generation.
  82. We have to record all changes of the stack pointer. */
  83. .byte 0x04 /* DW_CFA_advance_loc4 */
  84. .long .Lpush_ecx-.LSTART_vsyscall
  85. .byte 0x0e /* DW_CFA_def_cfa_offset */
  86. .byte 0x08 /* RA at offset 8 now */
  87. .byte 0x04 /* DW_CFA_advance_loc4 */
  88. .long .Lpush_edx-.Lpush_ecx
  89. .byte 0x0e /* DW_CFA_def_cfa_offset */
  90. .byte 0x0c /* RA at offset 12 now */
  91. .byte 0x04 /* DW_CFA_advance_loc4 */
  92. .long .Lenter_kernel-.Lpush_edx
  93. .byte 0x0e /* DW_CFA_def_cfa_offset */
  94. .byte 0x10 /* RA at offset 16 now */
  95. .byte 0x85, 0x04 /* DW_CFA_offset %ebp -16 */
  96. /* Finally the epilogue. */
  97. .byte 0x04 /* DW_CFA_advance_loc4 */
  98. .long .Lpop_ebp-.Lenter_kernel
  99. .byte 0x0e /* DW_CFA_def_cfa_offset */
  100. .byte 0x0c /* RA at offset 12 now */
  101. .byte 0xc5 /* DW_CFA_restore %ebp */
  102. .byte 0x04 /* DW_CFA_advance_loc4 */
  103. .long .Lpop_edx-.Lpop_ebp
  104. .byte 0x0e /* DW_CFA_def_cfa_offset */
  105. .byte 0x08 /* RA at offset 8 now */
  106. .byte 0x04 /* DW_CFA_advance_loc4 */
  107. .long .Lpop_ecx-.Lpop_edx
  108. .byte 0x0e /* DW_CFA_def_cfa_offset */
  109. .byte 0x04 /* RA at offset 4 now */
  110. .align 4
  111. .LENDFDEDLSI:
  112. .previous
  113. /*
  114. * Get the common code for the sigreturn entry points.
  115. */
  116. #include "sigreturn.S"