vsyscall-sysenter.S 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. .text
  25. .globl __kernel_vsyscall
  26. .type __kernel_vsyscall,@function
  27. __kernel_vsyscall:
  28. .LSTART_vsyscall:
  29. push %ecx
  30. .Lpush_ecx:
  31. push %edx
  32. .Lpush_edx:
  33. push %ebp
  34. .Lenter_kernel:
  35. movl %esp,%ebp
  36. sysenter
  37. /* 7: align return point with nop's to make disassembly easier */
  38. .space 7,0x90
  39. /* 14: System call restart point is here! (SYSENTER_RETURN - 2) */
  40. jmp .Lenter_kernel
  41. /* 16: System call normal return point is here! */
  42. .globl SYSENTER_RETURN /* Symbol used by entry.S. */
  43. SYSENTER_RETURN:
  44. pop %ebp
  45. .Lpop_ebp:
  46. pop %edx
  47. .Lpop_edx:
  48. pop %ecx
  49. .Lpop_ecx:
  50. ret
  51. .LEND_vsyscall:
  52. .size __kernel_vsyscall,.-.LSTART_vsyscall
  53. .previous
  54. .section .eh_frame,"a",@progbits
  55. .LSTARTFRAMEDLSI:
  56. .long .LENDCIEDLSI-.LSTARTCIEDLSI
  57. .LSTARTCIEDLSI:
  58. .long 0 /* CIE ID */
  59. .byte 1 /* Version number */
  60. .string "zR" /* NUL-terminated augmentation string */
  61. .uleb128 1 /* Code alignment factor */
  62. .sleb128 -4 /* Data alignment factor */
  63. .byte 8 /* Return address register column */
  64. .uleb128 1 /* Augmentation value length */
  65. .byte 0x1b /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
  66. .byte 0x0c /* DW_CFA_def_cfa */
  67. .uleb128 4
  68. .uleb128 4
  69. .byte 0x88 /* DW_CFA_offset, column 0x8 */
  70. .uleb128 1
  71. .align 4
  72. .LENDCIEDLSI:
  73. .long .LENDFDEDLSI-.LSTARTFDEDLSI /* Length FDE */
  74. .LSTARTFDEDLSI:
  75. .long .LSTARTFDEDLSI-.LSTARTFRAMEDLSI /* CIE pointer */
  76. .long .LSTART_vsyscall-. /* PC-relative start address */
  77. .long .LEND_vsyscall-.LSTART_vsyscall
  78. .uleb128 0
  79. /* What follows are the instructions for the table generation.
  80. We have to record all changes of the stack pointer. */
  81. .byte 0x04 /* DW_CFA_advance_loc4 */
  82. .long .Lpush_ecx-.LSTART_vsyscall
  83. .byte 0x0e /* DW_CFA_def_cfa_offset */
  84. .byte 0x08 /* RA at offset 8 now */
  85. .byte 0x04 /* DW_CFA_advance_loc4 */
  86. .long .Lpush_edx-.Lpush_ecx
  87. .byte 0x0e /* DW_CFA_def_cfa_offset */
  88. .byte 0x0c /* RA at offset 12 now */
  89. .byte 0x04 /* DW_CFA_advance_loc4 */
  90. .long .Lenter_kernel-.Lpush_edx
  91. .byte 0x0e /* DW_CFA_def_cfa_offset */
  92. .byte 0x10 /* RA at offset 16 now */
  93. .byte 0x85, 0x04 /* DW_CFA_offset %ebp -16 */
  94. /* Finally the epilogue. */
  95. .byte 0x04 /* DW_CFA_advance_loc4 */
  96. .long .Lpop_ebp-.Lenter_kernel
  97. .byte 0x0e /* DW_CFA_def_cfa_offset */
  98. .byte 0x0c /* RA at offset 12 now */
  99. .byte 0xc5 /* DW_CFA_restore %ebp */
  100. .byte 0x04 /* DW_CFA_advance_loc4 */
  101. .long .Lpop_edx-.Lpop_ebp
  102. .byte 0x0e /* DW_CFA_def_cfa_offset */
  103. .byte 0x08 /* RA at offset 8 now */
  104. .byte 0x04 /* DW_CFA_advance_loc4 */
  105. .long .Lpop_ecx-.Lpop_edx
  106. .byte 0x0e /* DW_CFA_def_cfa_offset */
  107. .byte 0x04 /* RA at offset 4 now */
  108. .align 4
  109. .LENDFDEDLSI:
  110. .previous
  111. /*
  112. * Get the common code for the sigreturn entry points.
  113. */
  114. #include "vsyscall-sigreturn.S"