entry_64_compat.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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. .endm
  193. .macro auditsys_exit exit
  194. testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  195. jnz ia32_ret_from_sys_call
  196. TRACE_IRQS_ON
  197. ENABLE_INTERRUPTS(CLBR_NONE)
  198. movl %eax, %esi /* second arg, syscall return value */
  199. cmpl $-MAX_ERRNO, %eax /* is it an error ? */
  200. jbe 1f
  201. movslq %eax, %rsi /* if error sign extend to 64 bits */
  202. 1: setbe %al /* 1 if error, 0 if not */
  203. movzbl %al, %edi /* zero-extend that into %edi */
  204. call __audit_syscall_exit
  205. movq RAX(%rsp), %rax /* reload syscall return value */
  206. movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi
  207. DISABLE_INTERRUPTS(CLBR_NONE)
  208. TRACE_IRQS_OFF
  209. testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  210. jz \exit
  211. xorl %eax, %eax /* Do not leak kernel information */
  212. movq %rax, R11(%rsp)
  213. movq %rax, R10(%rsp)
  214. movq %rax, R9(%rsp)
  215. movq %rax, R8(%rsp)
  216. jmp int_with_check
  217. .endm
  218. sysenter_auditsys:
  219. auditsys_entry_common
  220. movl %ebp, %r9d /* reload 6th syscall arg */
  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), %r9d
  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. /* r9 already loaded */ /* 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. DISABLE_INTERRUPTS(CLBR_NONE)
  332. TRACE_IRQS_OFF
  333. testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  334. jnz sysretl_audit
  335. sysretl_from_sys_call:
  336. andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
  337. RESTORE_RSI_RDI_RDX
  338. movl RIP(%rsp), %ecx
  339. movl EFLAGS(%rsp), %r11d
  340. xorq %r10, %r10
  341. xorq %r9, %r9
  342. xorq %r8, %r8
  343. TRACE_IRQS_ON
  344. movl RSP(%rsp), %esp
  345. /*
  346. * 64-bit->32-bit SYSRET restores eip from ecx,
  347. * eflags from r11 (but RF and VM bits are forced to 0),
  348. * cs and ss are loaded from MSRs.
  349. * (Note: 32-bit->32-bit SYSRET is different: since r11
  350. * does not exist, it merely sets eflags.IF=1).
  351. *
  352. * NB: On AMD CPUs with the X86_BUG_SYSRET_SS_ATTRS bug, the ss
  353. * descriptor is not reinitialized. This means that we must
  354. * avoid SYSRET with SS == NULL, which could happen if we schedule,
  355. * exit the kernel, and re-enter using an interrupt vector. (All
  356. * interrupt entries on x86_64 set SS to NULL.) We prevent that
  357. * from happening by reloading SS in __switch_to.
  358. */
  359. USERGS_SYSRET32
  360. #ifdef CONFIG_AUDITSYSCALL
  361. cstar_auditsys:
  362. movl %r9d, R9(%rsp) /* register to be clobbered by call */
  363. auditsys_entry_common
  364. movl R9(%rsp), %r9d /* reload 6th syscall arg */
  365. jmp cstar_dispatch
  366. sysretl_audit:
  367. auditsys_exit sysretl_from_sys_call
  368. #endif
  369. cstar_tracesys:
  370. #ifdef CONFIG_AUDITSYSCALL
  371. testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  372. jz cstar_auditsys
  373. #endif
  374. xchgl %r9d, %ebp
  375. SAVE_EXTRA_REGS
  376. xorl %eax, %eax /* Do not leak kernel information */
  377. movq %rax, R11(%rsp)
  378. movq %rax, R10(%rsp)
  379. movq %r9, R9(%rsp)
  380. movq %rax, R8(%rsp)
  381. movq %rsp, %rdi /* &pt_regs -> arg1 */
  382. call syscall_trace_enter
  383. movl R9(%rsp), %r9d
  384. /* Reload arg registers from stack. (see sysenter_tracesys) */
  385. movl RCX(%rsp), %ecx
  386. movl RDX(%rsp), %edx
  387. movl RSI(%rsp), %esi
  388. movl RDI(%rsp), %edi
  389. movl %eax, %eax /* zero extension */
  390. RESTORE_EXTRA_REGS
  391. xchgl %ebp, %r9d
  392. jmp cstar_do_call
  393. END(entry_SYSCALL_compat)
  394. ia32_badarg:
  395. ASM_CLAC
  396. movq $-EFAULT, RAX(%rsp)
  397. ia32_ret_from_sys_call:
  398. xorl %eax, %eax /* Do not leak kernel information */
  399. movq %rax, R11(%rsp)
  400. movq %rax, R10(%rsp)
  401. movq %rax, R9(%rsp)
  402. movq %rax, R8(%rsp)
  403. jmp int_ret_from_sys_call
  404. /*
  405. * Emulated IA32 system calls via int 0x80.
  406. *
  407. * Arguments:
  408. * eax system call number
  409. * ebx arg1
  410. * ecx arg2
  411. * edx arg3
  412. * esi arg4
  413. * edi arg5
  414. * ebp arg6 (note: not saved in the stack frame, should not be touched)
  415. *
  416. * Notes:
  417. * Uses the same stack frame as the x86-64 version.
  418. * All registers except eax must be saved (but ptrace may violate that).
  419. * Arguments are zero extended. For system calls that want sign extension and
  420. * take long arguments a wrapper is needed. Most calls can just be called
  421. * directly.
  422. * Assumes it is only called from user space and entered with interrupts off.
  423. */
  424. ENTRY(entry_INT80_compat)
  425. /*
  426. * Interrupts are off on entry.
  427. * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
  428. * it is too small to ever cause noticeable irq latency.
  429. */
  430. PARAVIRT_ADJUST_EXCEPTION_FRAME
  431. SWAPGS
  432. ENABLE_INTERRUPTS(CLBR_NONE)
  433. /* Zero-extending 32-bit regs, do not remove */
  434. movl %eax, %eax
  435. /* Construct struct pt_regs on stack (iret frame is already on stack) */
  436. pushq %rax /* pt_regs->orig_ax */
  437. pushq %rdi /* pt_regs->di */
  438. pushq %rsi /* pt_regs->si */
  439. pushq %rdx /* pt_regs->dx */
  440. pushq %rcx /* pt_regs->cx */
  441. pushq $-ENOSYS /* pt_regs->ax */
  442. pushq $0 /* pt_regs->r8 */
  443. pushq $0 /* pt_regs->r9 */
  444. pushq $0 /* pt_regs->r10 */
  445. pushq $0 /* pt_regs->r11 */
  446. cld
  447. sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
  448. orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
  449. testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
  450. jnz ia32_tracesys
  451. ia32_do_call:
  452. /* 32-bit syscall -> 64-bit C ABI argument conversion */
  453. movl %edi, %r8d /* arg5 */
  454. movl %ebp, %r9d /* arg6 */
  455. xchg %ecx, %esi /* rsi:arg2, rcx:arg4 */
  456. movl %ebx, %edi /* arg1 */
  457. movl %edx, %edx /* arg3 (zero extension) */
  458. cmpq $(IA32_NR_syscalls-1), %rax
  459. ja 1f
  460. call *ia32_sys_call_table(, %rax, 8)
  461. movq %rax, RAX(%rsp)
  462. 1:
  463. jmp int_ret_from_sys_call
  464. ia32_tracesys:
  465. SAVE_EXTRA_REGS
  466. movq %rsp, %rdi /* &pt_regs -> arg1 */
  467. call syscall_trace_enter
  468. /*
  469. * Reload arg registers from stack in case ptrace changed them.
  470. * Don't reload %eax because syscall_trace_enter() returned
  471. * the %rax value we should see. But do truncate it to 32 bits.
  472. * If it's -1 to make us punt the syscall, then (u32)-1 is still
  473. * an appropriately invalid value.
  474. */
  475. movl RCX(%rsp), %ecx
  476. movl RDX(%rsp), %edx
  477. movl RSI(%rsp), %esi
  478. movl RDI(%rsp), %edi
  479. movl %eax, %eax /* zero extension */
  480. RESTORE_EXTRA_REGS
  481. jmp ia32_do_call
  482. END(entry_INT80_compat)
  483. .macro PTREGSCALL label, func
  484. ALIGN
  485. GLOBAL(\label)
  486. leaq \func(%rip), %rax
  487. jmp ia32_ptregs_common
  488. .endm
  489. PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn
  490. PTREGSCALL stub32_sigreturn, sys32_sigreturn
  491. PTREGSCALL stub32_fork, sys_fork
  492. PTREGSCALL stub32_vfork, sys_vfork
  493. ALIGN
  494. GLOBAL(stub32_clone)
  495. leaq sys_clone(%rip), %rax
  496. /*
  497. * The 32-bit clone ABI is: clone(..., int tls_val, int *child_tidptr).
  498. * The 64-bit clone ABI is: clone(..., int *child_tidptr, int tls_val).
  499. *
  500. * The native 64-bit kernel's sys_clone() implements the latter,
  501. * so we need to swap arguments here before calling it:
  502. */
  503. xchg %r8, %rcx
  504. jmp ia32_ptregs_common
  505. ALIGN
  506. ia32_ptregs_common:
  507. SAVE_EXTRA_REGS 8
  508. call *%rax
  509. RESTORE_EXTRA_REGS 8
  510. ret
  511. END(ia32_ptregs_common)