sysenter.S 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Code for the vDSO. This version uses the sysenter instruction.
  3. *
  4. * First get the common code for the sigreturn entry points.
  5. * This must come first.
  6. */
  7. #include "sigreturn.S"
  8. /*
  9. * The caller puts arg2 in %ecx, which gets pushed. The kernel will use
  10. * %ecx itself for arg2. The pushing is because the sysexit instruction
  11. * (found in entry.S) requires that we clobber %ecx with the desired %esp.
  12. * User code might expect that %ecx is unclobbered though, as it would be
  13. * for returning via the iret instruction, so we must push and pop.
  14. *
  15. * The caller puts arg3 in %edx, which the sysexit instruction requires
  16. * for %eip. Thus, exactly as for arg2, we must push and pop.
  17. *
  18. * Arg6 is different. The caller puts arg6 in %ebp. Since the sysenter
  19. * instruction clobbers %esp, the user's %esp won't even survive entry
  20. * into the kernel. We store %esp in %ebp. Code in entry.S must fetch
  21. * arg6 from the stack.
  22. *
  23. * You can not use this vsyscall for the clone() syscall because the
  24. * three words on the parent stack do not get copied to the child.
  25. */
  26. .text
  27. .globl __kernel_vsyscall
  28. .type __kernel_vsyscall,@function
  29. ALIGN
  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. int $0x80
  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 0x40 + (.Lpush_ecx-.LSTART_vsyscall) /* DW_CFA_advance_loc */
  84. .byte 0x0e /* DW_CFA_def_cfa_offset */
  85. .byte 0x08 /* RA at offset 8 now */
  86. .byte 0x40 + (.Lpush_edx-.Lpush_ecx) /* DW_CFA_advance_loc */
  87. .byte 0x0e /* DW_CFA_def_cfa_offset */
  88. .byte 0x0c /* RA at offset 12 now */
  89. .byte 0x40 + (.Lenter_kernel-.Lpush_edx) /* DW_CFA_advance_loc */
  90. .byte 0x0e /* DW_CFA_def_cfa_offset */
  91. .byte 0x10 /* RA at offset 16 now */
  92. .byte 0x85, 0x04 /* DW_CFA_offset %ebp -16 */
  93. /* Finally the epilogue. */
  94. .byte 0x40 + (.Lpop_ebp-.Lenter_kernel) /* DW_CFA_advance_loc */
  95. .byte 0x0e /* DW_CFA_def_cfa_offset */
  96. .byte 0x0c /* RA at offset 12 now */
  97. .byte 0xc5 /* DW_CFA_restore %ebp */
  98. .byte 0x40 + (.Lpop_edx-.Lpop_ebp) /* DW_CFA_advance_loc */
  99. .byte 0x0e /* DW_CFA_def_cfa_offset */
  100. .byte 0x08 /* RA at offset 8 now */
  101. .byte 0x40 + (.Lpop_ecx-.Lpop_edx) /* DW_CFA_advance_loc */
  102. .byte 0x0e /* DW_CFA_def_cfa_offset */
  103. .byte 0x04 /* RA at offset 4 now */
  104. .align 4
  105. .LENDFDEDLSI:
  106. .previous
  107. /*
  108. * Emit a symbol with the size of this .eh_frame data,
  109. * to verify it matches the other versions.
  110. */
  111. VDSO32_vsyscall_eh_frame_size = (.LENDFDEDLSI-.LSTARTFRAMEDLSI)