x86/asm/entry/64: Do not TRACE_IRQS fast SYSRET64 path
[deliverable/linux.git] / arch / x86 / ia32 / ia32entry.S
CommitLineData
1da177e4
LT
1/*
2 * Compatibility mode system call entry point for x86-64.
3 *
4 * Copyright 2000-2002 Andi Kleen, SuSE Labs.
5 */
6
7#include <asm/dwarf2.h>
8#include <asm/calling.h>
e2d5df93 9#include <asm/asm-offsets.h>
1da177e4
LT
10#include <asm/current.h>
11#include <asm/errno.h>
12#include <asm/ia32_unistd.h>
13#include <asm/thread_info.h>
14#include <asm/segment.h>
2601e64d 15#include <asm/irqflags.h>
1ce6f868 16#include <asm/asm.h>
63bcff2a 17#include <asm/smap.h>
1da177e4 18#include <linux/linkage.h>
d7e7528b 19#include <linux/err.h>
1da177e4 20
5cbf1565
RM
21/* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
22#include <linux/elf-em.h>
23#define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE)
24#define __AUDIT_ARCH_LE 0x40000000
25
26#ifndef CONFIG_AUDITSYSCALL
24e35800
JB
27#define sysexit_audit ia32_ret_from_sys_call
28#define sysretl_audit ia32_ret_from_sys_call
5cbf1565
RM
29#endif
30
ea714547
JO
31 .section .entry.text, "ax"
32
f2db9382
DV
33 /* clobbers %rax */
34 .macro CLEAR_RREGS _r9=rax
1da177e4 35 xorl %eax,%eax
f2db9382
DV
36 movq %rax,R11(%rsp)
37 movq %rax,R10(%rsp)
38 movq %\_r9,R9(%rsp)
39 movq %rax,R8(%rsp)
1da177e4
LT
40 .endm
41
d4d67150
RM
42 /*
43 * Reload arg registers from stack in case ptrace changed them.
44 * We don't reload %eax because syscall_trace_enter() returned
eefdca04
RM
45 * the %rax value we should see. Instead, we just truncate that
46 * value to 32 bits again as we did on entry from user mode.
47 * If it's a new value set by user_regset during entry tracing,
48 * this matches the normal truncation of the user-mode value.
49 * If it's -1 to make us punt the syscall, then (u32)-1 is still
50 * an appropriately invalid value.
d4d67150 51 */
f2db9382 52 .macro LOAD_ARGS32 _r9=0
295286a8 53 .if \_r9
f2db9382 54 movl R9(%rsp),%r9d
295286a8 55 .endif
f2db9382
DV
56 movl RCX(%rsp),%ecx
57 movl RDX(%rsp),%edx
58 movl RSI(%rsp),%esi
59 movl RDI(%rsp),%edi
eefdca04 60 movl %eax,%eax /* zero extension */
176df245
AK
61 .endm
62
2765130b
JB
63 .macro CFI_STARTPROC32 simple
64 CFI_STARTPROC \simple
65 CFI_UNDEFINED r8
66 CFI_UNDEFINED r9
67 CFI_UNDEFINED r10
68 CFI_UNDEFINED r11
69 CFI_UNDEFINED r12
70 CFI_UNDEFINED r13
71 CFI_UNDEFINED r14
72 CFI_UNDEFINED r15
73 .endm
74
2be29982
JF
75#ifdef CONFIG_PARAVIRT
76ENTRY(native_usergs_sysret32)
77 swapgs
78 sysretl
79ENDPROC(native_usergs_sysret32)
80
81ENTRY(native_irq_enable_sysexit)
82 swapgs
83 sti
84 sysexit
85ENDPROC(native_irq_enable_sysexit)
86#endif
87
1da177e4
LT
88/*
89 * 32bit SYSENTER instruction entry.
90 *
b87cf63e
DV
91 * SYSENTER loads ss, rsp, cs, and rip from previously programmed MSRs.
92 * IF and VM in rflags are cleared (IOW: interrupts are off).
93 * SYSENTER does not save anything on the stack,
94 * and does not save old rip (!!!) and rflags.
95 *
1da177e4 96 * Arguments:
b87cf63e
DV
97 * eax system call number
98 * ebx arg1
99 * ecx arg2
100 * edx arg3
101 * esi arg4
102 * edi arg5
103 * ebp user stack
104 * 0(%ebp) arg6
105 *
1da177e4 106 * This is purely a fast path. For anything complicated we use the int 0x80
b87cf63e 107 * path below. We set up a complete hardware stack frame to share code
1da177e4 108 * with the int 0x80 path.
b87cf63e 109 */
1da177e4 110ENTRY(ia32_sysenter_target)
2765130b 111 CFI_STARTPROC32 simple
adf14236 112 CFI_SIGNAL_FRAME
7effaa88
JB
113 CFI_DEF_CFA rsp,0
114 CFI_REGISTER rsp,rbp
a232e3d5 115
2601e64d 116 /*
a232e3d5
DV
117 * Interrupts are off on entry.
118 * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
119 * it is too small to ever cause noticeable irq latency.
2601e64d 120 */
a232e3d5
DV
121 SWAPGS_UNSAFE_STACK
122 movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp
66804154 123 ENABLE_INTERRUPTS(CLBR_NONE)
a232e3d5 124
4ee8ec17
DV
125 /* Zero-extending 32-bit regs, do not remove */
126 movl %ebp, %ebp
127 movl %eax, %eax
128
b87cf63e 129 /* Construct iret frame (ss,rsp,rflags,cs,rip) */
60cf637a 130 pushq_cfi $__USER32_DS
7effaa88 131 /*CFI_REL_OFFSET ss,0*/
60cf637a 132 pushq_cfi %rbp
7effaa88 133 CFI_REL_OFFSET rsp,0
60cf637a 134 pushfq_cfi
7effaa88 135 /*CFI_REL_OFFSET rflags,0*/
dca5b52a 136 movl ASM_THREAD_INFO(TI_sysenter_return, %rsp, 3*8), %r10d
7effaa88 137 CFI_REGISTER rip,r10
60cf637a 138 pushq_cfi $__USER32_CS
7effaa88 139 /*CFI_REL_OFFSET cs,0*/
b87cf63e 140 /* Store thread_info->sysenter_return in rip stack slot */
60cf637a 141 pushq_cfi %r10
7effaa88 142 CFI_REL_OFFSET rip,0
b87cf63e 143 /* Store orig_ax */
60cf637a 144 pushq_cfi %rax
b87cf63e 145 /* Construct the rest of "struct pt_regs" */
1da177e4 146 cld
76f5df43
DV
147 ALLOC_PT_GPREGS_ON_STACK
148 SAVE_C_REGS_EXCEPT_R891011
b87cf63e
DV
149 /*
150 * no need to do an access_ok check here because rbp has been
151 * 32bit zero extended
152 */
63bcff2a 153 ASM_STAC
295286a8 1541: movl (%rbp),%ebp
1ce6f868 155 _ASM_EXTABLE(1b,ia32_badarg)
63bcff2a 156 ASM_CLAC
8c7aa698
AL
157
158 /*
159 * Sysenter doesn't filter flags, so we need to clear NT
160 * ourselves. To save a few cycles, we can check whether
161 * NT was set instead of doing an unconditional popfq.
162 */
f2db9382 163 testl $X86_EFLAGS_NT,EFLAGS(%rsp)
8c7aa698
AL
164 jnz sysenter_fix_flags
165sysenter_flags_fixed:
166
dca5b52a
IM
167 orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
168 testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
7effaa88 169 CFI_REMEMBER_STATE
1da177e4 170 jnz sysenter_tracesys
36d001c7 171 cmpq $(IA32_NR_syscalls-1),%rax
67d53ea5 172 ja ia32_badsys
d4d67150 173sysenter_do_call:
14f6e953
DV
174 /* 32bit syscall -> 64bit C ABI argument conversion */
175 movl %edi,%r8d /* arg5 */
176 movl %ebp,%r9d /* arg6 */
177 xchg %ecx,%esi /* rsi:arg2, rcx:arg4 */
178 movl %ebx,%edi /* arg1 */
179 movl %edx,%edx /* arg3 (zero extension) */
5cbf1565 180sysenter_dispatch:
1da177e4 181 call *ia32_sys_call_table(,%rax,8)
f2db9382 182 movq %rax,RAX(%rsp)
66804154 183 DISABLE_INTERRUPTS(CLBR_NONE)
2601e64d 184 TRACE_IRQS_OFF
dca5b52a 185 testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
5cbf1565
RM
186 jnz sysexit_audit
187sysexit_from_sys_call:
dca5b52a 188 andl $~TS_COMPAT,ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
1da177e4 189 /* clear IF, that popfq doesn't enable interrupts early */
f2db9382
DV
190 andl $~0x200,EFLAGS(%rsp)
191 movl RIP(%rsp),%edx /* User %eip */
36197c92 192 CFI_REGISTER rip,rdx
76f5df43 193 RESTORE_RSI_RDI
b87cf63e 194 /* pop everything except ss,rsp,rflags slots */
76f5df43 195 REMOVE_PT_GPREGS_FROM_STACK 3*8
24e35800
JB
196 xorq %r8,%r8
197 xorq %r9,%r9
198 xorq %r10,%r10
199 xorq %r11,%r11
60cf637a 200 popfq_cfi
7effaa88 201 /*CFI_RESTORE rflags*/
60cf637a 202 popq_cfi %rcx /* User %esp */
7effaa88 203 CFI_REGISTER rsp,rcx
2601e64d 204 TRACE_IRQS_ON
b87cf63e
DV
205 /*
206 * 32bit SYSEXIT restores eip from edx, esp from ecx.
207 * cs and ss are loaded from MSRs.
208 */
2be29982 209 ENABLE_INTERRUPTS_SYSEXIT32
1da177e4 210
8c7aa698
AL
211 CFI_RESTORE_STATE
212
5cbf1565
RM
213#ifdef CONFIG_AUDITSYSCALL
214 .macro auditsys_entry_common
b4f0d375
RGB
215 movl %esi,%r8d /* 5th arg: 4th syscall arg */
216 movl %ecx,%r9d /*swap with edx*/
217 movl %edx,%ecx /* 4th arg: 3rd syscall arg */
218 movl %r9d,%edx /* 3rd arg: 2nd syscall arg */
219 movl %ebx,%esi /* 2nd arg: 1st syscall arg */
220 movl %eax,%edi /* 1st arg: syscall number */
b05d8447 221 call __audit_syscall_entry
f2db9382 222 movl RAX(%rsp),%eax /* reload syscall number */
36d001c7 223 cmpq $(IA32_NR_syscalls-1),%rax
5cbf1565
RM
224 ja ia32_badsys
225 movl %ebx,%edi /* reload 1st syscall arg */
f2db9382
DV
226 movl RCX(%rsp),%esi /* reload 2nd syscall arg */
227 movl RDX(%rsp),%edx /* reload 3rd syscall arg */
228 movl RSI(%rsp),%ecx /* reload 4th syscall arg */
229 movl RDI(%rsp),%r8d /* reload 5th syscall arg */
5cbf1565
RM
230 .endm
231
81766741 232 .macro auditsys_exit exit
dca5b52a 233 testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
24e35800 234 jnz ia32_ret_from_sys_call
5cbf1565 235 TRACE_IRQS_ON
40a1ef95 236 ENABLE_INTERRUPTS(CLBR_NONE)
5cbf1565 237 movl %eax,%esi /* second arg, syscall return value */
d7e7528b 238 cmpl $-MAX_ERRNO,%eax /* is it an error ? */
f031cd25
EP
239 jbe 1f
240 movslq %eax, %rsi /* if error sign extend to 64 bits */
2411: setbe %al /* 1 if error, 0 if not */
5cbf1565 242 movzbl %al,%edi /* zero-extend that into %edi */
d7e7528b 243 call __audit_syscall_exit
f2db9382 244 movq RAX(%rsp),%rax /* reload syscall return value */
5cbf1565 245 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
40a1ef95 246 DISABLE_INTERRUPTS(CLBR_NONE)
5cbf1565 247 TRACE_IRQS_OFF
dca5b52a 248 testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
24e35800 249 jz \exit
f2db9382 250 CLEAR_RREGS
24e35800 251 jmp int_with_check
5cbf1565
RM
252 .endm
253
254sysenter_auditsys:
5cbf1565
RM
255 auditsys_entry_common
256 movl %ebp,%r9d /* reload 6th syscall arg */
257 jmp sysenter_dispatch
258
259sysexit_audit:
260 auditsys_exit sysexit_from_sys_call
261#endif
262
8c7aa698
AL
263sysenter_fix_flags:
264 pushq_cfi $(X86_EFLAGS_IF|X86_EFLAGS_FIXED)
265 popfq_cfi
266 jmp sysenter_flags_fixed
267
5cbf1565 268sysenter_tracesys:
5cbf1565 269#ifdef CONFIG_AUDITSYSCALL
dca5b52a 270 testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
5cbf1565
RM
271 jz sysenter_auditsys
272#endif
76f5df43 273 SAVE_EXTRA_REGS
1da177e4 274 CLEAR_RREGS
48ee679a 275 movq $-ENOSYS,RAX(%rsp)/* ptrace can change this for a bad syscall */
1da177e4
LT
276 movq %rsp,%rdi /* &pt_regs -> arg1 */
277 call syscall_trace_enter
f2db9382 278 LOAD_ARGS32 /* reload args from stack in case ptrace changed it */
76f5df43 279 RESTORE_EXTRA_REGS
36d001c7 280 cmpq $(IA32_NR_syscalls-1),%rax
48ee679a 281 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
1da177e4
LT
282 jmp sysenter_do_call
283 CFI_ENDPROC
4b787e0b 284ENDPROC(ia32_sysenter_target)
1da177e4
LT
285
286/*
287 * 32bit SYSCALL instruction entry.
288 *
b87cf63e
DV
289 * 32bit SYSCALL saves rip to rcx, clears rflags.RF, then saves rflags to r11,
290 * then loads new ss, cs, and rip from previously programmed MSRs.
291 * rflags gets masked by a value from another MSR (so CLD and CLAC
292 * are not needed). SYSCALL does not save anything on the stack
293 * and does not change rsp.
294 *
295 * Note: rflags saving+masking-with-MSR happens only in Long mode
296 * (in legacy 32bit mode, IF, RF and VM bits are cleared and that's it).
297 * Don't get confused: rflags saving+masking depends on Long Mode Active bit
298 * (EFER.LMA=1), NOT on bitness of userspace where SYSCALL executes
299 * or target CS descriptor's L bit (SYSCALL does not read segment descriptors).
300 *
1da177e4 301 * Arguments:
b87cf63e
DV
302 * eax system call number
303 * ecx return address
304 * ebx arg1
305 * ebp arg2 (note: not saved in the stack frame, should not be touched)
306 * edx arg3
307 * esi arg4
308 * edi arg5
309 * esp user stack
310 * 0(%esp) arg6
311 *
1da177e4 312 * This is purely a fast path. For anything complicated we use the int 0x80
b87cf63e
DV
313 * path below. We set up a complete hardware stack frame to share code
314 * with the int 0x80 path.
315 */
1da177e4 316ENTRY(ia32_cstar_target)
2765130b 317 CFI_STARTPROC32 simple
adf14236 318 CFI_SIGNAL_FRAME
ef593260 319 CFI_DEF_CFA rsp,0
7effaa88
JB
320 CFI_REGISTER rip,rcx
321 /*CFI_REGISTER rflags,r11*/
a232e3d5
DV
322
323 /*
324 * Interrupts are off on entry.
325 * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
326 * it is too small to ever cause noticeable irq latency.
327 */
457da70e 328 SWAPGS_UNSAFE_STACK
1da177e4 329 movl %esp,%r8d
7effaa88 330 CFI_REGISTER rsp,r8
9af45651 331 movq PER_CPU_VAR(kernel_stack),%rsp
66804154 332 ENABLE_INTERRUPTS(CLBR_NONE)
a232e3d5 333
4ee8ec17
DV
334 /* Zero-extending 32-bit regs, do not remove */
335 movl %eax,%eax
336
ef593260 337 ALLOC_PT_GPREGS_ON_STACK 6*8 /* 6*8: space for orig_ax and iret frame */
76f5df43 338 SAVE_C_REGS_EXCEPT_RCX_R891011
f2db9382
DV
339 movq %rax,ORIG_RAX(%rsp)
340 movq %rcx,RIP(%rsp)
341 CFI_REL_OFFSET rip,RIP
342 movq %rbp,RCX(%rsp) /* this lies slightly to ptrace */
1da177e4 343 movl %ebp,%ecx
f2db9382
DV
344 movq $__USER32_CS,CS(%rsp)
345 movq $__USER32_DS,SS(%rsp)
346 movq %r11,EFLAGS(%rsp)
347 /*CFI_REL_OFFSET rflags,EFLAGS*/
348 movq %r8,RSP(%rsp)
349 CFI_REL_OFFSET rsp,RSP
b87cf63e
DV
350 /* iret stack frame is complete now */
351 /*
352 * no need to do an access_ok check here because r8 has been
353 * 32bit zero extended
354 */
63bcff2a 355 ASM_STAC
1da177e4 3561: movl (%r8),%r9d
a3e859fe 357 _ASM_EXTABLE(1b,ia32_badarg)
63bcff2a 358 ASM_CLAC
dca5b52a
IM
359 orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
360 testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
7effaa88 361 CFI_REMEMBER_STATE
1da177e4 362 jnz cstar_tracesys
36d001c7 363 cmpq $IA32_NR_syscalls-1,%rax
67d53ea5 364 ja ia32_badsys
295286a8 365cstar_do_call:
14f6e953
DV
366 /* 32bit syscall -> 64bit C ABI argument conversion */
367 movl %edi,%r8d /* arg5 */
368 /* r9 already loaded */ /* arg6 */
369 xchg %ecx,%esi /* rsi:arg2, rcx:arg4 */
370 movl %ebx,%edi /* arg1 */
371 movl %edx,%edx /* arg3 (zero extension) */
5cbf1565 372cstar_dispatch:
1da177e4 373 call *ia32_sys_call_table(,%rax,8)
f2db9382 374 movq %rax,RAX(%rsp)
66804154 375 DISABLE_INTERRUPTS(CLBR_NONE)
2601e64d 376 TRACE_IRQS_OFF
dca5b52a 377 testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
5cbf1565
RM
378 jnz sysretl_audit
379sysretl_from_sys_call:
dca5b52a 380 andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
76f5df43 381 RESTORE_RSI_RDI_RDX
f2db9382 382 movl RIP(%rsp),%ecx
7effaa88 383 CFI_REGISTER rip,rcx
f2db9382 384 movl EFLAGS(%rsp),%r11d
7effaa88 385 /*CFI_REGISTER rflags,r11*/
24e35800
JB
386 xorq %r10,%r10
387 xorq %r9,%r9
388 xorq %r8,%r8
2601e64d 389 TRACE_IRQS_ON
f2db9382 390 movl RSP(%rsp),%esp
7effaa88 391 CFI_RESTORE rsp
b87cf63e
DV
392 /*
393 * 64bit->32bit SYSRET restores eip from ecx,
394 * eflags from r11 (but RF and VM bits are forced to 0),
395 * cs and ss are loaded from MSRs.
396 * (Note: 32bit->32bit SYSRET is different: since r11
397 * does not exist, it merely sets eflags.IF=1).
398 */
2be29982 399 USERGS_SYSRET32
b87cf63e 400
5cbf1565
RM
401#ifdef CONFIG_AUDITSYSCALL
402cstar_auditsys:
7effaa88 403 CFI_RESTORE_STATE
f2db9382 404 movl %r9d,R9(%rsp) /* register to be clobbered by call */
5cbf1565 405 auditsys_entry_common
f2db9382 406 movl R9(%rsp),%r9d /* reload 6th syscall arg */
5cbf1565
RM
407 jmp cstar_dispatch
408
409sysretl_audit:
81766741 410 auditsys_exit sysretl_from_sys_call
5cbf1565
RM
411#endif
412
413cstar_tracesys:
414#ifdef CONFIG_AUDITSYSCALL
dca5b52a 415 testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
5cbf1565
RM
416 jz cstar_auditsys
417#endif
ecd744ee 418 xchgl %r9d,%ebp
76f5df43 419 SAVE_EXTRA_REGS
f2db9382 420 CLEAR_RREGS r9
48ee679a 421 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
1da177e4
LT
422 movq %rsp,%rdi /* &pt_regs -> arg1 */
423 call syscall_trace_enter
f2db9382 424 LOAD_ARGS32 1 /* reload args from stack in case ptrace changed it */
76f5df43 425 RESTORE_EXTRA_REGS
ecd744ee 426 xchgl %ebp,%r9d
36d001c7 427 cmpq $(IA32_NR_syscalls-1),%rax
48ee679a 428 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
1da177e4 429 jmp cstar_do_call
4b787e0b 430END(ia32_cstar_target)
1da177e4
LT
431
432ia32_badarg:
63bcff2a 433 ASM_CLAC
1da177e4
LT
434 movq $-EFAULT,%rax
435 jmp ia32_sysret
436 CFI_ENDPROC
437
b87cf63e
DV
438/*
439 * Emulated IA32 system calls via int 0x80.
1da177e4 440 *
b87cf63e
DV
441 * Arguments:
442 * eax system call number
443 * ebx arg1
444 * ecx arg2
445 * edx arg3
446 * esi arg4
447 * edi arg5
448 * ebp arg6 (note: not saved in the stack frame, should not be touched)
1da177e4
LT
449 *
450 * Notes:
b87cf63e
DV
451 * Uses the same stack frame as the x86-64 version.
452 * All registers except eax must be saved (but ptrace may violate that).
1da177e4
LT
453 * Arguments are zero extended. For system calls that want sign extension and
454 * take long arguments a wrapper is needed. Most calls can just be called
455 * directly.
b87cf63e
DV
456 * Assumes it is only called from user space and entered with interrupts off.
457 */
1da177e4
LT
458
459ENTRY(ia32_syscall)
cdc1793e 460 CFI_STARTPROC32 simple
adf14236 461 CFI_SIGNAL_FRAME
a232e3d5
DV
462 CFI_DEF_CFA rsp,5*8
463 /*CFI_REL_OFFSET ss,4*8 */
464 CFI_REL_OFFSET rsp,3*8
465 /*CFI_REL_OFFSET rflags,2*8 */
466 /*CFI_REL_OFFSET cs,1*8 */
467 CFI_REL_OFFSET rip,0*8
468
2601e64d 469 /*
a232e3d5
DV
470 * Interrupts are off on entry.
471 * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
472 * it is too small to ever cause noticeable irq latency.
2601e64d 473 */
a232e3d5
DV
474 PARAVIRT_ADJUST_EXCEPTION_FRAME
475 SWAPGS
66804154 476 ENABLE_INTERRUPTS(CLBR_NONE)
a232e3d5 477
4ee8ec17
DV
478 /* Zero-extending 32-bit regs, do not remove */
479 movl %eax,%eax
480
b87cf63e 481 pushq_cfi %rax /* store orig_ax */
1da177e4
LT
482 cld
483 /* note the registers are not zero extended to the sf.
484 this could be a problem. */
76f5df43
DV
485 ALLOC_PT_GPREGS_ON_STACK
486 SAVE_C_REGS_EXCEPT_R891011
dca5b52a
IM
487 orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
488 testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
1da177e4 489 jnz ia32_tracesys
36d001c7 490 cmpq $(IA32_NR_syscalls-1),%rax
c09249f8
RM
491 ja ia32_badsys
492ia32_do_call:
14f6e953
DV
493 /* 32bit syscall -> 64bit C ABI argument conversion */
494 movl %edi,%r8d /* arg5 */
495 movl %ebp,%r9d /* arg6 */
496 xchg %ecx,%esi /* rsi:arg2, rcx:arg4 */
497 movl %ebx,%edi /* arg1 */
498 movl %edx,%edx /* arg3 (zero extension) */
1da177e4
LT
499 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
500ia32_sysret:
f2db9382 501 movq %rax,RAX(%rsp)
24e35800 502ia32_ret_from_sys_call:
f2db9382 503 CLEAR_RREGS
76f5df43 504 jmp int_ret_from_sys_call
1da177e4 505
76f5df43
DV
506ia32_tracesys:
507 SAVE_EXTRA_REGS
cdc1793e 508 CLEAR_RREGS
8ab32bb8 509 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
1da177e4
LT
510 movq %rsp,%rdi /* &pt_regs -> arg1 */
511 call syscall_trace_enter
f2db9382 512 LOAD_ARGS32 /* reload args from stack in case ptrace changed it */
76f5df43 513 RESTORE_EXTRA_REGS
36d001c7 514 cmpq $(IA32_NR_syscalls-1),%rax
c09249f8
RM
515 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
516 jmp ia32_do_call
4b787e0b 517END(ia32_syscall)
1da177e4
LT
518
519ia32_badsys:
f2db9382 520 movq $0,ORIG_RAX(%rsp)
24e35800
JB
521 movq $-ENOSYS,%rax
522 jmp ia32_sysret
1da177e4 523
1da177e4
LT
524 CFI_ENDPROC
525
d2475b8f 526 .macro PTREGSCALL label, func
f6b2bc84
JB
527 ALIGN
528GLOBAL(\label)
1da177e4 529 leaq \func(%rip),%rax
1da177e4
LT
530 jmp ia32_ptregs_common
531 .endm
532
2765130b 533 CFI_STARTPROC32
7effaa88 534
3fe26fa3
AV
535 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn
536 PTREGSCALL stub32_sigreturn, sys32_sigreturn
537 PTREGSCALL stub32_execve, compat_sys_execve
27d6ec7a 538 PTREGSCALL stub32_execveat, compat_sys_execveat
3fe26fa3
AV
539 PTREGSCALL stub32_fork, sys_fork
540 PTREGSCALL stub32_vfork, sys_vfork
1da177e4 541
1d4b4b29
AV
542 ALIGN
543GLOBAL(stub32_clone)
544 leaq sys_clone(%rip),%rax
545 mov %r8, %rcx
546 jmp ia32_ptregs_common
547
f6b2bc84
JB
548 ALIGN
549ia32_ptregs_common:
2765130b
JB
550 CFI_ENDPROC
551 CFI_STARTPROC32 simple
adf14236 552 CFI_SIGNAL_FRAME
b3ab90b3 553 CFI_DEF_CFA rsp,SIZEOF_PTREGS
f2db9382
DV
554 CFI_REL_OFFSET rax,RAX
555 CFI_REL_OFFSET rcx,RCX
556 CFI_REL_OFFSET rdx,RDX
557 CFI_REL_OFFSET rsi,RSI
558 CFI_REL_OFFSET rdi,RDI
559 CFI_REL_OFFSET rip,RIP
560/* CFI_REL_OFFSET cs,CS*/
561/* CFI_REL_OFFSET rflags,EFLAGS*/
562 CFI_REL_OFFSET rsp,RSP
563/* CFI_REL_OFFSET ss,SS*/
76f5df43 564 SAVE_EXTRA_REGS 8
1da177e4 565 call *%rax
76f5df43
DV
566 RESTORE_EXTRA_REGS 8
567 ret
1da177e4 568 CFI_ENDPROC
4b787e0b 569END(ia32_ptregs_common)
This page took 0.770034 seconds and 5 git commands to generate.