vsyscall-sysenter.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. .globl SYSENTER_RETURN /* Symbol used by sysenter.c */
  46. SYSENTER_RETURN:
  47. pop %ebp
  48. .Lpop_ebp:
  49. pop %edx
  50. .Lpop_edx:
  51. pop %ecx
  52. .Lpop_ecx:
  53. ret
  54. .LEND_vsyscall:
  55. .size __kernel_vsyscall,.-.LSTART_vsyscall
  56. .previous
  57. .section .eh_frame,"a",@progbits
  58. .LSTARTFRAMEDLSI:
  59. .long .LENDCIEDLSI-.LSTARTCIEDLSI
  60. .LSTARTCIEDLSI:
  61. .long 0 /* CIE ID */
  62. .byte 1 /* Version number */
  63. .string "zR" /* NUL-terminated augmentation string */
  64. .uleb128 1 /* Code alignment factor */
  65. .sleb128 -4 /* Data alignment factor */
  66. .byte 8 /* Return address register column */
  67. .uleb128 1 /* Augmentation value length */
  68. .byte 0x1b /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
  69. .byte 0x0c /* DW_CFA_def_cfa */
  70. .uleb128 4
  71. .uleb128 4
  72. .byte 0x88 /* DW_CFA_offset, column 0x8 */
  73. .uleb128 1
  74. .align 4
  75. .LENDCIEDLSI:
  76. .long .LENDFDEDLSI-.LSTARTFDEDLSI /* Length FDE */
  77. .LSTARTFDEDLSI:
  78. .long .LSTARTFDEDLSI-.LSTARTFRAMEDLSI /* CIE pointer */
  79. .long .LSTART_vsyscall-. /* PC-relative start address */
  80. .long .LEND_vsyscall-.LSTART_vsyscall
  81. .uleb128 0
  82. /* What follows are the instructions for the table generation.
  83. We have to record all changes of the stack pointer. */
  84. .byte 0x04 /* DW_CFA_advance_loc4 */
  85. .long .Lpush_ecx-.LSTART_vsyscall
  86. .byte 0x0e /* DW_CFA_def_cfa_offset */
  87. .byte 0x08 /* RA at offset 8 now */
  88. .byte 0x04 /* DW_CFA_advance_loc4 */
  89. .long .Lpush_edx-.Lpush_ecx
  90. .byte 0x0e /* DW_CFA_def_cfa_offset */
  91. .byte 0x0c /* RA at offset 12 now */
  92. .byte 0x04 /* DW_CFA_advance_loc4 */
  93. .long .Lenter_kernel-.Lpush_edx
  94. .byte 0x0e /* DW_CFA_def_cfa_offset */
  95. .byte 0x10 /* RA at offset 16 now */
  96. .byte 0x85, 0x04 /* DW_CFA_offset %ebp -16 */
  97. /* Finally the epilogue. */
  98. .byte 0x04 /* DW_CFA_advance_loc4 */
  99. .long .Lpop_ebp-.Lenter_kernel
  100. .byte 0x0e /* DW_CFA_def_cfa_offset */
  101. .byte 0x0c /* RA at offset 12 now */
  102. .byte 0xc5 /* DW_CFA_restore %ebp */
  103. .byte 0x04 /* DW_CFA_advance_loc4 */
  104. .long .Lpop_edx-.Lpop_ebp
  105. .byte 0x0e /* DW_CFA_def_cfa_offset */
  106. .byte 0x08 /* RA at offset 8 now */
  107. .byte 0x04 /* DW_CFA_advance_loc4 */
  108. .long .Lpop_ecx-.Lpop_edx
  109. .byte 0x0e /* DW_CFA_def_cfa_offset */
  110. .byte 0x04 /* RA at offset 4 now */
  111. .align 4
  112. .LENDFDEDLSI:
  113. .previous
  114. /*
  115. * Get the common code for the sigreturn entry points.
  116. */
  117. #include "vsyscall-sigreturn.S"