entry_64_compat.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. /*
  2. * Compatibility mode system call entry point for x86-64.
  3. *
  4. * Copyright 2000-2002 Andi Kleen, SuSE Labs.
  5. */
  6. #include "calling.h"
  7. #include <asm/asm-offsets.h>
  8. #include <asm/current.h>
  9. #include <asm/errno.h>
  10. #include <asm/ia32_unistd.h>
  11. #include <asm/thread_info.h>
  12. #include <asm/segment.h>
  13. #include <asm/irqflags.h>
  14. #include <asm/asm.h>
  15. #include <asm/smap.h>
  16. #include <linux/linkage.h>
  17. #include <linux/err.h>
  18. /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
  19. #include <linux/elf-em.h>
  20. #define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE)
  21. #define __AUDIT_ARCH_LE 0x40000000
  22. #ifndef CONFIG_AUDITSYSCALL
  23. # define sysexit_audit ia32_ret_from_sys_call
  24. # define sysretl_audit ia32_ret_from_sys_call
  25. #endif
  26. .section .entry.text, "ax"
  27. #ifdef CONFIG_PARAVIRT
  28. ENTRY(native_usergs_sysret32)
  29. swapgs
  30. sysretl
  31. ENDPROC(native_usergs_sysret32)
  32. #endif
  33. /*
  34. * 32-bit SYSENTER instruction entry.
  35. *
  36. * SYSENTER loads ss, rsp, cs, and rip from previously programmed MSRs.
  37. * IF and VM in rflags are cleared (IOW: interrupts are off).
  38. * SYSENTER does not save anything on the stack,
  39. * and does not save old rip (!!!) and rflags.
  40. *
  41. * Arguments:
  42. * eax system call number
  43. * ebx arg1
  44. * ecx arg2
  45. * edx arg3
  46. * esi arg4
  47. * edi arg5
  48. * ebp user stack
  49. * 0(%ebp) arg6
  50. *
  51. * This is purely a fast path. For anything complicated we use the int 0x80
  52. * path below. We set up a complete hardware stack frame to share code
  53. * with the int 0x80 path.
  54. */
  55. ENTRY(entry_SYSENTER_compat)
  56. /*
  57. * Interrupts are off on entry.
  58. * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
  59. * it is too small to ever cause noticeable irq latency.
  60. */
  61. SWAPGS_UNSAFE_STACK
  62. movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
  63. ENABLE_INTERRUPTS(CLBR_NONE)
  64. /* Zero-extending 32-bit regs, do not remove */
  65. movl %ebp, %ebp
  66. movl %eax, %eax
  67. movl ASM_THREAD_INFO(TI_sysenter_return, %rsp, 0), %r10d
  68. /* Construct struct pt_regs on stack */
  69. pushq $__USER32_DS /* pt_regs->ss */
  70. pushq %rbp /* pt_regs->sp */
  71. pushfq /* pt_regs->flags */
  72. pushq $__USER32_CS /* pt_regs->cs */
  73. pushq %r10 /* pt_regs->ip = thread_info->sysenter_return */
  74. pushq %rax /* pt_regs->orig_ax */
  75. pushq %rdi /* pt_regs->di */
  76. pushq %rsi /* pt_regs->si */
  77. pushq %rdx /* pt_regs->dx */
  78. pushq %rcx /* pt_regs->cx */
  79. pushq $-ENOSYS /* pt_regs->ax */
  80. cld
  81. sub $(10*8), %rsp /* pt_regs->r8-11, bp, bx, r12-15 not saved */
  82. /*
  83. * no need to do an access_ok check here because rbp has been
  84. * 32-bit zero extended
  85. */
  86. ASM_STAC
  87. 1: movl (%rbp), %ebp
  88. _ASM_EXTABLE(1b, ia32_badarg)
  89. ASM_CLAC
  90. /*
  91. * Sysenter doesn't filter flags, so we need to clear NT
  92. * ourselves. To save a few cycles, we can check whether
  93. * NT was set instead of doing an unconditional popfq.
  94. */
  95. testl $X86_EFLAGS_NT, EFLAGS(%rsp)
  96. jnz sysenter_fix_flags
  97. sysenter_flags_fixed:
  98. orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
  99. testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  100. jnz sysenter_tracesys
  101. sysenter_do_call:
  102. /* 32-bit syscall -> 64-bit C ABI argument conversion */
  103. movl %edi, %r8d /* arg5 */
  104. movl %ebp, %r9d /* arg6 */
  105. xchg %ecx, %esi /* rsi:arg2, rcx:arg4 */
  106. movl %ebx, %edi /* arg1 */
  107. movl %edx, %edx /* arg3 (zero extension) */
  108. sysenter_dispatch:
  109. cmpq $(IA32_NR_syscalls-1), %rax
  110. ja 1f
  111. call *ia32_sys_call_table(, %rax, 8)
  112. movq %rax, RAX(%rsp)
  113. 1:
  114. DISABLE_INTERRUPTS(CLBR_NONE)
  115. TRACE_IRQS_OFF
  116. testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  117. jnz sysexit_audit
  118. sysexit_from_sys_call:
  119. /*
  120. * NB: SYSEXIT is not obviously safe for 64-bit kernels -- an
  121. * NMI between STI and SYSEXIT has poorly specified behavior,
  122. * and and NMI followed by an IRQ with usergs is fatal. So
  123. * we just pretend we're using SYSEXIT but we really use
  124. * SYSRETL instead.
  125. *
  126. * This code path is still called 'sysexit' because it pairs
  127. * with 'sysenter' and it uses the SYSENTER calling convention.
  128. */
  129. andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
  130. movl RIP(%rsp), %ecx /* User %eip */
  131. RESTORE_RSI_RDI
  132. xorl %edx, %edx /* Do not leak kernel information */
  133. xorq %r8, %r8
  134. xorq %r9, %r9
  135. xorq %r10, %r10
  136. movl EFLAGS(%rsp), %r11d /* User eflags */
  137. TRACE_IRQS_ON
  138. /*
  139. * SYSRETL works even on Intel CPUs. Use it in preference to SYSEXIT,
  140. * since it avoids a dicey window with interrupts enabled.
  141. */
  142. movl RSP(%rsp), %esp
  143. /*
  144. * USERGS_SYSRET32 does:
  145. * gsbase = user's gs base
  146. * eip = ecx
  147. * rflags = r11
  148. * cs = __USER32_CS
  149. * ss = __USER_DS
  150. *
  151. * The prologue set RIP(%rsp) to VDSO32_SYSENTER_RETURN, which does:
  152. *
  153. * pop %ebp
  154. * pop %edx
  155. * pop %ecx
  156. *
  157. * Therefore, we invoke SYSRETL with EDX and R8-R10 zeroed to
  158. * avoid info leaks. R11 ends up with VDSO32_SYSENTER_RETURN's
  159. * address (already known to user code), and R12-R15 are
  160. * callee-saved and therefore don't contain any interesting
  161. * kernel data.
  162. */
  163. USERGS_SYSRET32
  164. #ifdef CONFIG_AUDITSYSCALL
  165. .macro auditsys_entry_common
  166. /*
  167. * At this point, registers hold syscall args in the 32-bit syscall ABI:
  168. * EAX is syscall number, the 6 args are in EBX,ECX,EDX,ESI,EDI,EBP.
  169. *
  170. * We want to pass them to __audit_syscall_entry(), which is a 64-bit
  171. * C function with 5 parameters, so shuffle them to match what
  172. * the function expects: RDI,RSI,RDX,RCX,R8.
  173. */
  174. movl %esi, %r8d /* arg5 (R8 ) <= 4th syscall arg (ESI) */
  175. xchg %ecx, %edx /* arg4 (RCX) <= 3rd syscall arg (EDX) */
  176. /* arg3 (RDX) <= 2nd syscall arg (ECX) */
  177. movl %ebx, %esi /* arg2 (RSI) <= 1st syscall arg (EBX) */
  178. movl %eax, %edi /* arg1 (RDI) <= syscall number (EAX) */
  179. call __audit_syscall_entry
  180. /*
  181. * We are going to jump back to the syscall dispatch code.
  182. * Prepare syscall args as required by the 64-bit C ABI.
  183. * Registers clobbered by __audit_syscall_entry() are
  184. * loaded from pt_regs on stack:
  185. */
  186. movl ORIG_RAX(%rsp), %eax /* syscall number */
  187. movl %ebx, %edi /* arg1 */
  188. movl RCX(%rsp), %esi /* arg2 */
  189. movl RDX(%rsp), %edx /* arg3 */
  190. movl RSI(%rsp), %ecx /* arg4 */
  191. movl RDI(%rsp), %r8d /* arg5 */
  192. movl %ebp, %r9d /* arg6 */
  193. .endm
  194. .macro auditsys_exit exit
  195. testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  196. jnz ia32_ret_from_sys_call
  197. TRACE_IRQS_ON
  198. ENABLE_INTERRUPTS(CLBR_NONE)
  199. movl %eax, %esi /* second arg, syscall return value */
  200. cmpl $-MAX_ERRNO, %eax /* is it an error ? */
  201. jbe 1f
  202. movslq %eax, %rsi /* if error sign extend to 64 bits */
  203. 1: setbe %al /* 1 if error, 0 if not */
  204. movzbl %al, %edi /* zero-extend that into %edi */
  205. call __audit_syscall_exit
  206. movq RAX(%rsp), %rax /* reload syscall return value */
  207. movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi
  208. DISABLE_INTERRUPTS(CLBR_NONE)
  209. TRACE_IRQS_OFF
  210. testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  211. jz \exit
  212. xorl %eax, %eax /* Do not leak kernel information */
  213. movq %rax, R11(%rsp)
  214. movq %rax, R10(%rsp)
  215. movq %rax, R9(%rsp)
  216. movq %rax, R8(%rsp)
  217. jmp int_with_check
  218. .endm
  219. sysenter_auditsys:
  220. auditsys_entry_common
  221. jmp sysenter_dispatch
  222. sysexit_audit:
  223. auditsys_exit sysexit_from_sys_call
  224. #endif
  225. sysenter_fix_flags:
  226. pushq $(X86_EFLAGS_IF|X86_EFLAGS_FIXED)
  227. popfq
  228. jmp sysenter_flags_fixed
  229. sysenter_tracesys:
  230. #ifdef CONFIG_AUDITSYSCALL
  231. testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  232. jz sysenter_auditsys
  233. #endif
  234. SAVE_EXTRA_REGS
  235. xorl %eax, %eax /* Do not leak kernel information */
  236. movq %rax, R11(%rsp)
  237. movq %rax, R10(%rsp)
  238. movq %rax, R9(%rsp)
  239. movq %rax, R8(%rsp)
  240. movq %rsp, %rdi /* &pt_regs -> arg1 */
  241. call syscall_trace_enter
  242. /* Reload arg registers from stack. (see sysenter_tracesys) */
  243. movl RCX(%rsp), %ecx
  244. movl RDX(%rsp), %edx
  245. movl RSI(%rsp), %esi
  246. movl RDI(%rsp), %edi
  247. movl %eax, %eax /* zero extension */
  248. RESTORE_EXTRA_REGS
  249. jmp sysenter_do_call
  250. ENDPROC(entry_SYSENTER_compat)
  251. /*
  252. * 32-bit SYSCALL instruction entry.
  253. *
  254. * 32-bit SYSCALL saves rip to rcx, clears rflags.RF, then saves rflags to r11,
  255. * then loads new ss, cs, and rip from previously programmed MSRs.
  256. * rflags gets masked by a value from another MSR (so CLD and CLAC
  257. * are not needed). SYSCALL does not save anything on the stack
  258. * and does not change rsp.
  259. *
  260. * Note: rflags saving+masking-with-MSR happens only in Long mode
  261. * (in legacy 32-bit mode, IF, RF and VM bits are cleared and that's it).
  262. * Don't get confused: rflags saving+masking depends on Long Mode Active bit
  263. * (EFER.LMA=1), NOT on bitness of userspace where SYSCALL executes
  264. * or target CS descriptor's L bit (SYSCALL does not read segment descriptors).
  265. *
  266. * Arguments:
  267. * eax system call number
  268. * ecx return address
  269. * ebx arg1
  270. * ebp arg2 (note: not saved in the stack frame, should not be touched)
  271. * edx arg3
  272. * esi arg4
  273. * edi arg5
  274. * esp user stack
  275. * 0(%esp) arg6
  276. *
  277. * This is purely a fast path. For anything complicated we use the int 0x80
  278. * path below. We set up a complete hardware stack frame to share code
  279. * with the int 0x80 path.
  280. */
  281. ENTRY(entry_SYSCALL_compat)
  282. /*
  283. * Interrupts are off on entry.
  284. * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
  285. * it is too small to ever cause noticeable irq latency.
  286. */
  287. SWAPGS_UNSAFE_STACK
  288. movl %esp, %r8d
  289. movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
  290. ENABLE_INTERRUPTS(CLBR_NONE)
  291. /* Zero-extending 32-bit regs, do not remove */
  292. movl %eax, %eax
  293. /* Construct struct pt_regs on stack */
  294. pushq $__USER32_DS /* pt_regs->ss */
  295. pushq %r8 /* pt_regs->sp */
  296. pushq %r11 /* pt_regs->flags */
  297. pushq $__USER32_CS /* pt_regs->cs */
  298. pushq %rcx /* pt_regs->ip */
  299. pushq %rax /* pt_regs->orig_ax */
  300. pushq %rdi /* pt_regs->di */
  301. pushq %rsi /* pt_regs->si */
  302. pushq %rdx /* pt_regs->dx */
  303. pushq %rbp /* pt_regs->cx */
  304. movl %ebp, %ecx
  305. pushq $-ENOSYS /* pt_regs->ax */
  306. sub $(10*8), %rsp /* pt_regs->r8-11, bp, bx, r12-15 not saved */
  307. /*
  308. * No need to do an access_ok check here because r8 has been
  309. * 32-bit zero extended:
  310. */
  311. ASM_STAC
  312. 1: movl (%r8), %ebp
  313. _ASM_EXTABLE(1b, ia32_badarg)
  314. ASM_CLAC
  315. orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
  316. testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  317. jnz cstar_tracesys
  318. cstar_do_call:
  319. /* 32-bit syscall -> 64-bit C ABI argument conversion */
  320. movl %edi, %r8d /* arg5 */
  321. movl %ebp, %r9d /* arg6 */
  322. xchg %ecx, %esi /* rsi:arg2, rcx:arg4 */
  323. movl %ebx, %edi /* arg1 */
  324. movl %edx, %edx /* arg3 (zero extension) */
  325. cstar_dispatch:
  326. cmpq $(IA32_NR_syscalls-1), %rax
  327. ja 1f
  328. call *ia32_sys_call_table(, %rax, 8)
  329. movq %rax, RAX(%rsp)
  330. 1:
  331. movl RCX(%rsp), %ebp
  332. DISABLE_INTERRUPTS(CLBR_NONE)
  333. TRACE_IRQS_OFF
  334. testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  335. jnz sysretl_audit
  336. sysretl_from_sys_call:
  337. andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
  338. RESTORE_RSI_RDI_RDX
  339. movl RIP(%rsp), %ecx
  340. movl EFLAGS(%rsp), %r11d
  341. xorq %r10, %r10
  342. xorq %r9, %r9
  343. xorq %r8, %r8
  344. TRACE_IRQS_ON
  345. movl RSP(%rsp), %esp
  346. /*
  347. * 64-bit->32-bit SYSRET restores eip from ecx,
  348. * eflags from r11 (but RF and VM bits are forced to 0),
  349. * cs and ss are loaded from MSRs.
  350. * (Note: 32-bit->32-bit SYSRET is different: since r11
  351. * does not exist, it merely sets eflags.IF=1).
  352. *
  353. * NB: On AMD CPUs with the X86_BUG_SYSRET_SS_ATTRS bug, the ss
  354. * descriptor is not reinitialized. This means that we must
  355. * avoid SYSRET with SS == NULL, which could happen if we schedule,
  356. * exit the kernel, and re-enter using an interrupt vector. (All
  357. * interrupt entries on x86_64 set SS to NULL.) We prevent that
  358. * from happening by reloading SS in __switch_to.
  359. */
  360. USERGS_SYSRET32
  361. #ifdef CONFIG_AUDITSYSCALL
  362. cstar_auditsys:
  363. auditsys_entry_common
  364. jmp cstar_dispatch
  365. sysretl_audit:
  366. auditsys_exit sysretl_from_sys_call
  367. #endif
  368. cstar_tracesys:
  369. #ifdef CONFIG_AUDITSYSCALL
  370. testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  371. jz cstar_auditsys
  372. #endif
  373. SAVE_EXTRA_REGS
  374. xorl %eax, %eax /* Do not leak kernel information */
  375. movq %rax, R11(%rsp)
  376. movq %rax, R10(%rsp)
  377. movq %rax, R9(%rsp)
  378. movq %rax, R8(%rsp)
  379. movq %rsp, %rdi /* &pt_regs -> arg1 */
  380. call syscall_trace_enter
  381. /* Reload arg registers from stack. (see sysenter_tracesys) */
  382. movl RCX(%rsp), %ecx
  383. movl RDX(%rsp), %edx
  384. movl RSI(%rsp), %esi
  385. movl RDI(%rsp), %edi
  386. movl %eax, %eax /* zero extension */
  387. RESTORE_EXTRA_REGS
  388. jmp cstar_do_call
  389. END(entry_SYSCALL_compat)
  390. ia32_badarg:
  391. ASM_CLAC
  392. movq $-EFAULT, RAX(%rsp)
  393. ia32_ret_from_sys_call:
  394. xorl %eax, %eax /* Do not leak kernel information */
  395. movq %rax, R11(%rsp)
  396. movq %rax, R10(%rsp)
  397. movq %rax, R9(%rsp)
  398. movq %rax, R8(%rsp)
  399. jmp int_ret_from_sys_call
  400. /*
  401. * Emulated IA32 system calls via int 0x80.
  402. *
  403. * Arguments:
  404. * eax system call number
  405. * ebx arg1
  406. * ecx arg2
  407. * edx arg3
  408. * esi arg4
  409. * edi arg5
  410. * ebp arg6 (note: not saved in the stack frame, should not be touched)
  411. *
  412. * Notes:
  413. * Uses the same stack frame as the x86-64 version.
  414. * All registers except eax must be saved (but ptrace may violate that).
  415. * Arguments are zero extended. For system calls that want sign extension and
  416. * take long arguments a wrapper is needed. Most calls can just be called
  417. * directly.
  418. * Assumes it is only called from user space and entered with interrupts off.
  419. */
  420. ENTRY(entry_INT80_compat)
  421. /*
  422. * Interrupts are off on entry.
  423. * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
  424. * it is too small to ever cause noticeable irq latency.
  425. */
  426. PARAVIRT_ADJUST_EXCEPTION_FRAME
  427. SWAPGS
  428. ENABLE_INTERRUPTS(CLBR_NONE)
  429. /* Zero-extending 32-bit regs, do not remove */
  430. movl %eax, %eax
  431. /* Construct struct pt_regs on stack (iret frame is already on stack) */
  432. pushq %rax /* pt_regs->orig_ax */
  433. pushq %rdi /* pt_regs->di */
  434. pushq %rsi /* pt_regs->si */
  435. pushq %rdx /* pt_regs->dx */
  436. pushq %rcx /* pt_regs->cx */
  437. pushq $-ENOSYS /* pt_regs->ax */
  438. pushq $0 /* pt_regs->r8 */
  439. pushq $0 /* pt_regs->r9 */
  440. pushq $0 /* pt_regs->r10 */
  441. pushq $0 /* pt_regs->r11 */
  442. cld
  443. sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
  444. orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
  445. testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  446. jnz ia32_tracesys
  447. ia32_do_call:
  448. /* 32-bit syscall -> 64-bit C ABI argument conversion */
  449. movl %edi, %r8d /* arg5 */
  450. movl %ebp, %r9d /* arg6 */
  451. xchg %ecx, %esi /* rsi:arg2, rcx:arg4 */
  452. movl %ebx, %edi /* arg1 */
  453. movl %edx, %edx /* arg3 (zero extension) */
  454. cmpq $(IA32_NR_syscalls-1), %rax
  455. ja 1f
  456. call *ia32_sys_call_table(, %rax, 8)
  457. movq %rax, RAX(%rsp)
  458. 1:
  459. jmp int_ret_from_sys_call
  460. ia32_tracesys:
  461. SAVE_EXTRA_REGS
  462. movq %rsp, %rdi /* &pt_regs -> arg1 */
  463. call syscall_trace_enter
  464. /*
  465. * Reload arg registers from stack in case ptrace changed them.
  466. * Don't reload %eax because syscall_trace_enter() returned
  467. * the %rax value we should see. But do truncate it to 32 bits.
  468. * If it's -1 to make us punt the syscall, then (u32)-1 is still
  469. * an appropriately invalid value.
  470. */
  471. movl RCX(%rsp), %ecx
  472. movl RDX(%rsp), %edx
  473. movl RSI(%rsp), %esi
  474. movl RDI(%rsp), %edi
  475. movl %eax, %eax /* zero extension */
  476. RESTORE_EXTRA_REGS
  477. jmp ia32_do_call
  478. END(entry_INT80_compat)
  479. .macro PTREGSCALL label, func
  480. ALIGN
  481. GLOBAL(\label)
  482. leaq \func(%rip), %rax
  483. jmp ia32_ptregs_common
  484. .endm
  485. PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn
  486. PTREGSCALL stub32_sigreturn, sys32_sigreturn
  487. PTREGSCALL stub32_fork, sys_fork
  488. PTREGSCALL stub32_vfork, sys_vfork
  489. ALIGN
  490. GLOBAL(stub32_clone)
  491. leaq sys_clone(%rip), %rax
  492. /*
  493. * The 32-bit clone ABI is: clone(..., int tls_val, int *child_tidptr).
  494. * The 64-bit clone ABI is: clone(..., int *child_tidptr, int tls_val).
  495. *
  496. * The native 64-bit kernel's sys_clone() implements the latter,
  497. * so we need to swap arguments here before calling it:
  498. */
  499. xchg %r8, %rcx
  500. jmp ia32_ptregs_common
  501. ALIGN
  502. ia32_ptregs_common:
  503. SAVE_EXTRA_REGS 8
  504. call *%rax
  505. RESTORE_EXTRA_REGS 8
  506. ret
  507. END(ia32_ptregs_common)