blob: 98d5358e4041a7e144ec566f7db19ff054cedbcc [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Ingo Molnar54ad7262015-06-05 13:02:28 +02003 * Compatibility mode system call entry point for x86-64.
4 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Copyright 2000-2002 Andi Kleen, SuSE Labs.
Ingo Molnar54ad7262015-06-05 13:02:28 +02006 */
Ingo Molnard36f9472015-06-03 18:29:26 +02007#include "calling.h"
Sam Ravnborge2d5df92005-09-09 21:28:48 +02008#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <asm/current.h>
10#include <asm/errno.h>
Ingo Molnar54ad7262015-06-05 13:02:28 +020011#include <asm/ia32_unistd.h>
12#include <asm/thread_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/segment.h>
Ingo Molnar2601e642006-07-03 00:24:45 -070014#include <asm/irqflags.h>
H. Peter Anvin1ce6f862012-04-20 12:19:50 -070015#include <asm/asm.h>
H. Peter Anvin63bcff22012-09-21 12:43:12 -070016#include <asm/smap.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/linkage.h>
Eric Parisd7e75282012-01-03 14:23:06 -050018#include <linux/err.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Jiri Olsaea714542011-03-07 19:10:39 +010020 .section .entry.text, "ax"
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022/*
Andy Lutomirskifda57b22016-03-09 19:00:35 -080023 * 32-bit SYSENTER entry.
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 *
Andy Lutomirskifda57b22016-03-09 19:00:35 -080025 * 32-bit system calls through the vDSO's __kernel_vsyscall enter here
26 * on 64-bit kernels running on Intel CPUs.
27 *
28 * The SYSENTER instruction, in principle, should *only* occur in the
29 * vDSO. In practice, a small number of Android devices were shipped
30 * with a copy of Bionic that inlined a SYSENTER instruction. This
31 * never happened in any of Google's Bionic versions -- it only happened
32 * in a narrow range of Intel-provided versions.
33 *
34 * SYSENTER loads SS, RSP, CS, and RIP from previously programmed MSRs.
35 * IF and VM in RFLAGS are cleared (IOW: interrupts are off).
Denys Vlasenkob87cf632015-02-26 14:40:32 -080036 * SYSENTER does not save anything on the stack,
Andy Lutomirskifda57b22016-03-09 19:00:35 -080037 * and does not save old RIP (!!!), RSP, or RFLAGS.
Denys Vlasenkob87cf632015-02-26 14:40:32 -080038 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 * Arguments:
Denys Vlasenkob87cf632015-02-26 14:40:32 -080040 * eax system call number
41 * ebx arg1
42 * ecx arg2
43 * edx arg3
44 * esi arg4
45 * edi arg5
46 * ebp user stack
47 * 0(%ebp) arg6
Denys Vlasenkob87cf632015-02-26 14:40:32 -080048 */
Ingo Molnar4c8cd0c2015-06-08 08:33:56 +020049ENTRY(entry_SYSENTER_compat)
Andy Lutomirskib611acf2015-10-05 17:47:55 -070050 /* Interrupts are off on entry. */
Andy Lutomirski1a797972017-12-04 15:07:12 +010051 SWAPGS
Dave Hansen8a093172017-12-04 15:07:35 +010052
53 /* We are about to clobber %rsp anyway, clobbering here is OK */
54 SWITCH_TO_KERNEL_CR3 scratch_reg=%rsp
55
Denys Vlasenko3a232082015-04-24 17:31:35 +020056 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
Denys Vlasenkoa232e3d2015-03-27 11:36:20 +010057
Andy Lutomirskia474e672015-10-05 17:48:11 -070058 /*
59 * User tracing code (ptrace or signal handlers) might assume that
60 * the saved RAX contains a 32-bit number when we're invoking a 32-bit
61 * syscall. Just in case the high bits are nonzero, zero-extend
62 * the syscall number. (This could almost certainly be deleted
63 * with no ill effects.)
64 */
Denys Vlasenko4ee8ec12015-03-27 11:36:21 +010065 movl %eax, %eax
66
Denys Vlasenko4c9c0e92015-03-31 19:00:04 +020067 /* Construct struct pt_regs on stack */
Ingo Molnar131484c2015-05-28 12:21:47 +020068 pushq $__USER32_DS /* pt_regs->ss */
Andy Lutomirski30bfa7b2015-12-16 23:18:48 -080069 pushq %rbp /* pt_regs->sp (stashed in bp) */
Andy Lutomirskib611acf2015-10-05 17:47:55 -070070
71 /*
72 * Push flags. This is nasty. First, interrupts are currently
73 * off, but we need pt_regs->flags to have IF set. Second, even
74 * if TF was set when SYSENTER started, it's clear by now. We fix
75 * that later using TIF_SINGLESTEP.
76 */
77 pushfq /* pt_regs->flags (except IF = 0) */
78 orl $X86_EFLAGS_IF, (%rsp) /* Fix saved flags */
Ingo Molnar131484c2015-05-28 12:21:47 +020079 pushq $__USER32_CS /* pt_regs->cs */
Denys Vlasenko778843f2016-05-02 16:56:50 +020080 pushq $0 /* pt_regs->ip = 0 (placeholder) */
Ingo Molnar131484c2015-05-28 12:21:47 +020081 pushq %rax /* pt_regs->orig_ax */
82 pushq %rdi /* pt_regs->di */
83 pushq %rsi /* pt_regs->si */
84 pushq %rdx /* pt_regs->dx */
Andy Lutomirski30bfa7b2015-12-16 23:18:48 -080085 pushq %rcx /* pt_regs->cx */
Ingo Molnar131484c2015-05-28 12:21:47 +020086 pushq $-ENOSYS /* pt_regs->ax */
Denys Vlasenko778843f2016-05-02 16:56:50 +020087 pushq $0 /* pt_regs->r8 = 0 */
88 pushq $0 /* pt_regs->r9 = 0 */
89 pushq $0 /* pt_regs->r10 = 0 */
90 pushq $0 /* pt_regs->r11 = 0 */
Andy Lutomirskia474e672015-10-05 17:48:11 -070091 pushq %rbx /* pt_regs->rbx */
Andy Lutomirski30bfa7b2015-12-16 23:18:48 -080092 pushq %rbp /* pt_regs->rbp (will be overwritten) */
Denys Vlasenko778843f2016-05-02 16:56:50 +020093 pushq $0 /* pt_regs->r12 = 0 */
94 pushq $0 /* pt_regs->r13 = 0 */
95 pushq $0 /* pt_regs->r14 = 0 */
96 pushq $0 /* pt_regs->r15 = 0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 cld
Denys Vlasenko4c9c0e92015-03-31 19:00:04 +020098
Denys Vlasenkob87cf632015-02-26 14:40:32 -080099 /*
Andy Lutomirskie7860412016-03-09 19:00:25 -0800100 * SYSENTER doesn't filter flags, so we need to clear NT and AC
Andy Lutomirski8c7aa692014-10-01 11:49:04 -0700101 * ourselves. To save a few cycles, we can check whether
Andy Lutomirskie7860412016-03-09 19:00:25 -0800102 * either was set instead of doing an unconditional popfq.
Andy Lutomirskib611acf2015-10-05 17:47:55 -0700103 * This needs to happen before enabling interrupts so that
104 * we don't get preempted with NT set.
Borislav Petkov374a3a32015-10-09 19:08:59 +0200105 *
Andy Lutomirskif2b37572016-03-09 19:00:30 -0800106 * If TF is set, we will single-step all the way to here -- do_debug
107 * will ignore all the traps. (Yes, this is slow, but so is
108 * single-stepping in general. This allows us to avoid having
109 * a more complicated code to handle the case where a user program
110 * forces us to single-step through the SYSENTER entry code.)
111 *
Borislav Petkovf74acf02015-12-12 11:27:57 +0100112 * NB.: .Lsysenter_fix_flags is a label with the code under it moved
Borislav Petkov374a3a32015-10-09 19:08:59 +0200113 * out-of-line as an optimization: NT is unlikely to be set in the
114 * majority of the cases and instead of polluting the I$ unnecessarily,
115 * we're keeping that code behind a branch which will predict as
116 * not-taken and therefore its instructions won't be fetched.
Andy Lutomirski8c7aa692014-10-01 11:49:04 -0700117 */
Andy Lutomirskif2b37572016-03-09 19:00:30 -0800118 testl $X86_EFLAGS_NT|X86_EFLAGS_AC|X86_EFLAGS_TF, EFLAGS(%rsp)
Borislav Petkovf74acf02015-12-12 11:27:57 +0100119 jnz .Lsysenter_fix_flags
120.Lsysenter_flags_fixed:
Andy Lutomirski8c7aa692014-10-01 11:49:04 -0700121
Andy Lutomirskia474e672015-10-05 17:48:11 -0700122 /*
123 * User mode is traced as though IRQs are on, and SYSENTER
124 * turned them off.
125 */
126 TRACE_IRQS_OFF
Andy Lutomirskie62a2542015-10-05 17:48:02 -0700127
Andy Lutomirskia474e672015-10-05 17:48:11 -0700128 movq %rsp, %rdi
129 call do_fast_syscall_32
Boris Ostrovsky91e2eea2015-11-19 16:55:45 -0500130 /* XEN PV guests always use IRET path */
131 ALTERNATIVE "testl %eax, %eax; jz .Lsyscall_32_done", \
132 "jmp .Lsyscall_32_done", X86_FEATURE_XENPV
Andy Lutomirski7841b402015-10-05 17:48:12 -0700133 jmp sysret32_from_system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Borislav Petkovf74acf02015-12-12 11:27:57 +0100135.Lsysenter_fix_flags:
Andy Lutomirskib611acf2015-10-05 17:47:55 -0700136 pushq $X86_EFLAGS_FIXED
Ingo Molnar131484c2015-05-28 12:21:47 +0200137 popfq
Borislav Petkovf74acf02015-12-12 11:27:57 +0100138 jmp .Lsysenter_flags_fixed
Andy Lutomirskif2b37572016-03-09 19:00:30 -0800139GLOBAL(__end_entry_SYSENTER_compat)
Ingo Molnar4c8cd0c2015-06-08 08:33:56 +0200140ENDPROC(entry_SYSENTER_compat)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142/*
Andy Lutomirskifda57b22016-03-09 19:00:35 -0800143 * 32-bit SYSCALL entry.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 *
Andy Lutomirskifda57b22016-03-09 19:00:35 -0800145 * 32-bit system calls through the vDSO's __kernel_vsyscall enter here
146 * on 64-bit kernels running on AMD CPUs.
Denys Vlasenkob87cf632015-02-26 14:40:32 -0800147 *
Andy Lutomirskifda57b22016-03-09 19:00:35 -0800148 * The SYSCALL instruction, in principle, should *only* occur in the
149 * vDSO. In practice, it appears that this really is the case.
150 * As evidence:
151 *
152 * - The calling convention for SYSCALL has changed several times without
153 * anyone noticing.
154 *
155 * - Prior to the in-kernel X86_BUG_SYSRET_SS_ATTRS fixup, anything
156 * user task that did SYSCALL without immediately reloading SS
157 * would randomly crash.
158 *
159 * - Most programmers do not directly target AMD CPUs, and the 32-bit
160 * SYSCALL instruction does not exist on Intel CPUs. Even on AMD
161 * CPUs, Linux disables the SYSCALL instruction on 32-bit kernels
162 * because the SYSCALL instruction in legacy/native 32-bit mode (as
163 * opposed to compat mode) is sufficiently poorly designed as to be
164 * essentially unusable.
165 *
166 * 32-bit SYSCALL saves RIP to RCX, clears RFLAGS.RF, then saves
167 * RFLAGS to R11, then loads new SS, CS, and RIP from previously
168 * programmed MSRs. RFLAGS gets masked by a value from another MSR
169 * (so CLD and CLAC are not needed). SYSCALL does not save anything on
170 * the stack and does not change RSP.
171 *
172 * Note: RFLAGS saving+masking-with-MSR happens only in Long mode
Ingo Molnar54ad7262015-06-05 13:02:28 +0200173 * (in legacy 32-bit mode, IF, RF and VM bits are cleared and that's it).
Andy Lutomirskifda57b22016-03-09 19:00:35 -0800174 * Don't get confused: RFLAGS saving+masking depends on Long Mode Active bit
Denys Vlasenkob87cf632015-02-26 14:40:32 -0800175 * (EFER.LMA=1), NOT on bitness of userspace where SYSCALL executes
176 * or target CS descriptor's L bit (SYSCALL does not read segment descriptors).
177 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 * Arguments:
Denys Vlasenkob87cf632015-02-26 14:40:32 -0800179 * eax system call number
180 * ecx return address
181 * ebx arg1
182 * ebp arg2 (note: not saved in the stack frame, should not be touched)
183 * edx arg3
184 * esi arg4
185 * edi arg5
186 * esp user stack
187 * 0(%esp) arg6
Denys Vlasenkob87cf632015-02-26 14:40:32 -0800188 */
Ingo Molnar2cd23552015-06-08 08:28:07 +0200189ENTRY(entry_SYSCALL_compat)
Andy Lutomirskia474e672015-10-05 17:48:11 -0700190 /* Interrupts are off on entry. */
Andy Lutomirski8a9949b2017-08-07 20:59:21 -0700191 swapgs
Andy Lutomirskie62a2542015-10-05 17:48:02 -0700192
Thomas Gleixnerd7732ba2018-01-03 19:52:04 +0100193 /* Stash user ESP */
Ingo Molnar54ad7262015-06-05 13:02:28 +0200194 movl %esp, %r8d
Thomas Gleixnerd7732ba2018-01-03 19:52:04 +0100195
196 /* Use %rsp as scratch reg. User ESP is stashed in r8 */
197 SWITCH_TO_KERNEL_CR3 scratch_reg=%rsp
198
199 /* Switch to the kernel stack */
Ingo Molnar54ad7262015-06-05 13:02:28 +0200200 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
Denys Vlasenkoa232e3d2015-03-27 11:36:20 +0100201
Denys Vlasenko4c9c0e92015-03-31 19:00:04 +0200202 /* Construct struct pt_regs on stack */
Ingo Molnar131484c2015-05-28 12:21:47 +0200203 pushq $__USER32_DS /* pt_regs->ss */
204 pushq %r8 /* pt_regs->sp */
205 pushq %r11 /* pt_regs->flags */
206 pushq $__USER32_CS /* pt_regs->cs */
207 pushq %rcx /* pt_regs->ip */
Andy Lutomirski8a9949b2017-08-07 20:59:21 -0700208GLOBAL(entry_SYSCALL_compat_after_hwframe)
209 movl %eax, %eax /* discard orig_ax high bits */
Ingo Molnar131484c2015-05-28 12:21:47 +0200210 pushq %rax /* pt_regs->orig_ax */
211 pushq %rdi /* pt_regs->di */
212 pushq %rsi /* pt_regs->si */
213 pushq %rdx /* pt_regs->dx */
Andy Lutomirski30bfa7b2015-12-16 23:18:48 -0800214 pushq %rbp /* pt_regs->cx (stashed in bp) */
Ingo Molnar131484c2015-05-28 12:21:47 +0200215 pushq $-ENOSYS /* pt_regs->ax */
Denys Vlasenko778843f2016-05-02 16:56:50 +0200216 pushq $0 /* pt_regs->r8 = 0 */
217 pushq $0 /* pt_regs->r9 = 0 */
218 pushq $0 /* pt_regs->r10 = 0 */
219 pushq $0 /* pt_regs->r11 = 0 */
Andy Lutomirskia474e672015-10-05 17:48:11 -0700220 pushq %rbx /* pt_regs->rbx */
Andy Lutomirski30bfa7b2015-12-16 23:18:48 -0800221 pushq %rbp /* pt_regs->rbp (will be overwritten) */
Denys Vlasenko778843f2016-05-02 16:56:50 +0200222 pushq $0 /* pt_regs->r12 = 0 */
223 pushq $0 /* pt_regs->r13 = 0 */
224 pushq $0 /* pt_regs->r14 = 0 */
225 pushq $0 /* pt_regs->r15 = 0 */
Denys Vlasenko4c9c0e92015-03-31 19:00:04 +0200226
Andy Lutomirskia474e672015-10-05 17:48:11 -0700227 /*
228 * User mode is traced as though IRQs are on, and SYSENTER
229 * turned them off.
230 */
231 TRACE_IRQS_OFF
232
233 movq %rsp, %rdi
234 call do_fast_syscall_32
Boris Ostrovsky91e2eea2015-11-19 16:55:45 -0500235 /* XEN PV guests always use IRET path */
236 ALTERNATIVE "testl %eax, %eax; jz .Lsyscall_32_done", \
237 "jmp .Lsyscall_32_done", X86_FEATURE_XENPV
Andy Lutomirski7841b402015-10-05 17:48:12 -0700238
239 /* Opportunistic SYSRET */
240sysret32_from_system_call:
241 TRACE_IRQS_ON /* User mode traces as IRQs on. */
242 movq RBX(%rsp), %rbx /* pt_regs->rbx */
243 movq RBP(%rsp), %rbp /* pt_regs->rbp */
244 movq EFLAGS(%rsp), %r11 /* pt_regs->flags (in r11) */
245 movq RIP(%rsp), %rcx /* pt_regs->ip (in rcx) */
246 addq $RAX, %rsp /* Skip r8-r15 */
247 popq %rax /* pt_regs->rax */
248 popq %rdx /* Skip pt_regs->cx */
249 popq %rdx /* pt_regs->dx */
250 popq %rsi /* pt_regs->si */
251 popq %rdi /* pt_regs->di */
252
253 /*
254 * USERGS_SYSRET32 does:
255 * GSBASE = user's GS base
256 * EIP = ECX
257 * RFLAGS = R11
258 * CS = __USER32_CS
259 * SS = __USER_DS
260 *
261 * ECX will not match pt_regs->cx, but we're returning to a vDSO
262 * trampoline that will fix up RCX, so this is okay.
263 *
264 * R12-R15 are callee-saved, so they contain whatever was in them
265 * when the system call started, which is already known to user
266 * code. We zero R8-R10 to avoid info leaks.
267 */
Dave Hansen8a093172017-12-04 15:07:35 +0100268 movq RSP-ORIG_RAX(%rsp), %rsp
269
270 /*
271 * The original userspace %rsp (RSP-ORIG_RAX(%rsp)) is stored
272 * on the process stack which is not mapped to userspace and
273 * not readable after we SWITCH_TO_USER_CR3. Delay the CR3
274 * switch until after after the last reference to the process
275 * stack.
276 *
Peter Zijlstra6fd166a2017-12-04 15:07:59 +0100277 * %r8/%r9 are zeroed before the sysret, thus safe to clobber.
Dave Hansen8a093172017-12-04 15:07:35 +0100278 */
Peter Zijlstra6fd166a2017-12-04 15:07:59 +0100279 SWITCH_TO_USER_CR3_NOSTACK scratch_reg=%r8 scratch_reg2=%r9
Dave Hansen8a093172017-12-04 15:07:35 +0100280
Andy Lutomirski7841b402015-10-05 17:48:12 -0700281 xorq %r8, %r8
282 xorq %r9, %r9
283 xorq %r10, %r10
Boris Ostrovsky75ef8212015-11-19 16:55:47 -0500284 swapgs
285 sysretl
Ingo Molnar2cd23552015-06-08 08:28:07 +0200286END(entry_SYSCALL_compat)
Ingo Molnar54ad7262015-06-05 13:02:28 +0200287
Denys Vlasenkob87cf632015-02-26 14:40:32 -0800288/*
Andy Lutomirskifda57b22016-03-09 19:00:35 -0800289 * 32-bit legacy system call entry.
290 *
291 * 32-bit x86 Linux system calls traditionally used the INT $0x80
292 * instruction. INT $0x80 lands here.
293 *
294 * This entry point can be used by 32-bit and 64-bit programs to perform
295 * 32-bit system calls. Instances of INT $0x80 can be found inline in
296 * various programs and libraries. It is also used by the vDSO's
297 * __kernel_vsyscall fallback for hardware that doesn't support a faster
298 * entry method. Restarted 32-bit system calls also fall back to INT
299 * $0x80 regardless of what instruction was originally used to do the
300 * system call.
301 *
302 * This is considered a slow path. It is not used by most libc
303 * implementations on modern hardware except during process startup.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 *
Denys Vlasenkob87cf632015-02-26 14:40:32 -0800305 * Arguments:
306 * eax system call number
307 * ebx arg1
308 * ecx arg2
309 * edx arg3
310 * esi arg4
311 * edi arg5
Andy Lutomirskifda57b22016-03-09 19:00:35 -0800312 * ebp arg6
Denys Vlasenkob87cf632015-02-26 14:40:32 -0800313 */
Ingo Molnar2cd23552015-06-08 08:28:07 +0200314ENTRY(entry_INT80_compat)
Denys Vlasenkoa232e3d2015-03-27 11:36:20 +0100315 /*
316 * Interrupts are off on entry.
Denys Vlasenkoa232e3d2015-03-27 11:36:20 +0100317 */
Andy Lutomirski3d44d512016-02-24 12:18:49 -0800318 ASM_CLAC /* Do this early to minimize exposure */
Jeremy Fitzhardinge66804152008-06-25 00:19:29 -0400319 SWAPGS
Denys Vlasenkoa232e3d2015-03-27 11:36:20 +0100320
Andy Lutomirskiee08c6b2015-10-05 17:48:09 -0700321 /*
322 * User tracing code (ptrace or signal handlers) might assume that
323 * the saved RAX contains a 32-bit number when we're invoking a 32-bit
324 * syscall. Just in case the high bits are nonzero, zero-extend
325 * the syscall number. (This could almost certainly be deleted
326 * with no ill effects.)
327 */
Ingo Molnar54ad7262015-06-05 13:02:28 +0200328 movl %eax, %eax
Denys Vlasenko4ee8ec12015-03-27 11:36:21 +0100329
Ingo Molnar131484c2015-05-28 12:21:47 +0200330 pushq %rax /* pt_regs->orig_ax */
Andy Lutomirski7f2590a2017-12-04 15:07:23 +0100331
332 /* switch to thread stack expects orig_ax to be pushed */
333 call switch_to_thread_stack
334
Ingo Molnar131484c2015-05-28 12:21:47 +0200335 pushq %rdi /* pt_regs->di */
336 pushq %rsi /* pt_regs->si */
337 pushq %rdx /* pt_regs->dx */
338 pushq %rcx /* pt_regs->cx */
339 pushq $-ENOSYS /* pt_regs->ax */
Denys Vlasenko778843f2016-05-02 16:56:50 +0200340 pushq $0 /* pt_regs->r8 = 0 */
341 pushq $0 /* pt_regs->r9 = 0 */
342 pushq $0 /* pt_regs->r10 = 0 */
343 pushq $0 /* pt_regs->r11 = 0 */
Andy Lutomirski8169aff2015-10-05 17:48:05 -0700344 pushq %rbx /* pt_regs->rbx */
345 pushq %rbp /* pt_regs->rbp */
346 pushq %r12 /* pt_regs->r12 */
347 pushq %r13 /* pt_regs->r13 */
348 pushq %r14 /* pt_regs->r14 */
349 pushq %r15 /* pt_regs->r15 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 cld
Denys Vlasenko4c9c0e92015-03-31 19:00:04 +0200351
Denys Vlasenko73cbf682015-06-02 21:04:02 +0200352 /*
Andy Lutomirskiee08c6b2015-10-05 17:48:09 -0700353 * User mode is traced as though IRQs are on, and the interrupt
354 * gate turned them off.
Denys Vlasenko73cbf682015-06-02 21:04:02 +0200355 */
Andy Lutomirskiee08c6b2015-10-05 17:48:09 -0700356 TRACE_IRQS_OFF
357
358 movq %rsp, %rdi
Andy Lutomirskia798f092016-03-09 13:24:32 -0800359 call do_int80_syscall_32
Andy Lutomirskia474e672015-10-05 17:48:11 -0700360.Lsyscall_32_done:
Andy Lutomirskiee08c6b2015-10-05 17:48:09 -0700361
362 /* Go back to user mode. */
363 TRACE_IRQS_ON
Andy Lutomirski8a055d72017-11-02 00:59:00 -0700364 jmp swapgs_restore_regs_and_return_to_usermode
Ingo Molnar2cd23552015-06-08 08:28:07 +0200365END(entry_INT80_compat)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
Jiri Slaby49993482017-08-24 10:06:24 +0200367ENTRY(stub32_clone)
Denys Vlasenko5cdc6832015-06-03 15:58:49 +0200368 /*
Denys Vlasenko7a5a9822015-06-03 15:58:50 +0200369 * The 32-bit clone ABI is: clone(..., int tls_val, int *child_tidptr).
370 * The 64-bit clone ABI is: clone(..., int *child_tidptr, int tls_val).
371 *
372 * The native 64-bit kernel's sys_clone() implements the latter,
373 * so we need to swap arguments here before calling it:
Denys Vlasenko5cdc6832015-06-03 15:58:49 +0200374 */
Denys Vlasenko7a5a9822015-06-03 15:58:50 +0200375 xchg %r8, %rcx
Andy Lutomirski8169aff2015-10-05 17:48:05 -0700376 jmp sys_clone
Jiri Slaby49993482017-08-24 10:06:24 +0200377ENDPROC(stub32_clone)