ia32entry.S 15.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6
/*
 * Compatibility mode system call entry point for x86-64. 
 * 		
 * Copyright 2000-2002 Andi Kleen, SuSE Labs.
 */		 

7
#include "calling.h"
8
#include <asm/asm-offsets.h>
L
Linus Torvalds 已提交
9 10 11 12 13
#include <asm/current.h>
#include <asm/errno.h>
#include <asm/ia32_unistd.h>	
#include <asm/thread_info.h>	
#include <asm/segment.h>
14
#include <asm/irqflags.h>
15
#include <asm/asm.h>
16
#include <asm/smap.h>
L
Linus Torvalds 已提交
17
#include <linux/linkage.h>
18
#include <linux/err.h>
L
Linus Torvalds 已提交
19

20 21 22 23 24 25
/* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */
#include <linux/elf-em.h>
#define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE)
#define __AUDIT_ARCH_LE	   0x40000000

#ifndef CONFIG_AUDITSYSCALL
26 27
#define sysexit_audit ia32_ret_from_sys_call
#define sysretl_audit ia32_ret_from_sys_call
28 29
#endif

J
Jiri Olsa 已提交
30 31
	.section .entry.text, "ax"

32 33 34 35 36 37 38
#ifdef CONFIG_PARAVIRT
ENTRY(native_usergs_sysret32)
	swapgs
	sysretl
ENDPROC(native_usergs_sysret32)
#endif

L
Linus Torvalds 已提交
39 40 41
/*
 * 32bit SYSENTER instruction entry.
 *
42 43 44 45 46
 * SYSENTER loads ss, rsp, cs, and rip from previously programmed MSRs.
 * IF and VM in rflags are cleared (IOW: interrupts are off).
 * SYSENTER does not save anything on the stack,
 * and does not save old rip (!!!) and rflags.
 *
L
Linus Torvalds 已提交
47
 * Arguments:
48 49 50 51 52 53 54 55 56
 * eax  system call number
 * ebx  arg1
 * ecx  arg2
 * edx  arg3
 * esi  arg4
 * edi  arg5
 * ebp  user stack
 * 0(%ebp) arg6
 *
L
Linus Torvalds 已提交
57
 * This is purely a fast path. For anything complicated we use the int 0x80
58
 * path below. We set up a complete hardware stack frame to share code
L
Linus Torvalds 已提交
59
 * with the int 0x80 path.
60
 */
L
Linus Torvalds 已提交
61
ENTRY(ia32_sysenter_target)
62
	/*
63 64 65
	 * Interrupts are off on entry.
	 * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
	 * it is too small to ever cause noticeable irq latency.
66
	 */
67
	SWAPGS_UNSAFE_STACK
68
	movq	PER_CPU_VAR(cpu_current_top_of_stack), %rsp
69
	ENABLE_INTERRUPTS(CLBR_NONE)
70

71 72 73 74
	/* Zero-extending 32-bit regs, do not remove */
	movl	%ebp, %ebp
	movl	%eax, %eax

75 76 77
	movl	ASM_THREAD_INFO(TI_sysenter_return, %rsp, 0), %r10d

	/* Construct struct pt_regs on stack */
78 79 80 81 82 83 84 85 86 87 88
	pushq	$__USER32_DS		/* pt_regs->ss */
	pushq	%rbp			/* pt_regs->sp */
	pushfq				/* pt_regs->flags */
	pushq	$__USER32_CS		/* pt_regs->cs */
	pushq	%r10 /* pt_regs->ip = thread_info->sysenter_return */
	pushq	%rax			/* pt_regs->orig_ax */
	pushq	%rdi			/* pt_regs->di */
	pushq	%rsi			/* pt_regs->si */
	pushq	%rdx			/* pt_regs->dx */
	pushq	%rcx			/* pt_regs->cx */
	pushq	$-ENOSYS		/* pt_regs->ax */
L
Linus Torvalds 已提交
89
	cld
90 91
	sub	$(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */

92 93 94 95
	/*
	 * no need to do an access_ok check here because rbp has been
	 * 32bit zero extended
	 */
96
	ASM_STAC
97
1:	movl	(%rbp),%ebp
98
	_ASM_EXTABLE(1b,ia32_badarg)
99
	ASM_CLAC
100 101 102 103 104 105

	/*
	 * Sysenter doesn't filter flags, so we need to clear NT
	 * ourselves.  To save a few cycles, we can check whether
	 * NT was set instead of doing an unconditional popfq.
	 */
106
	testl $X86_EFLAGS_NT,EFLAGS(%rsp)
107 108 109
	jnz sysenter_fix_flags
sysenter_flags_fixed:

110 111
	orl     $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
	testl   $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
L
Linus Torvalds 已提交
112
	jnz  sysenter_tracesys
113

114
sysenter_do_call:
115 116 117 118 119 120
	/* 32bit syscall -> 64bit C ABI argument conversion */
	movl	%edi,%r8d	/* arg5 */
	movl	%ebp,%r9d	/* arg6 */
	xchg	%ecx,%esi	/* rsi:arg2, rcx:arg4 */
	movl	%ebx,%edi	/* arg1 */
	movl	%edx,%edx	/* arg3 (zero extension) */
121
sysenter_dispatch:
122 123
	cmpq	$(IA32_NR_syscalls-1),%rax
	ja	1f
L
Linus Torvalds 已提交
124
	call	*ia32_sys_call_table(,%rax,8)
125
	movq	%rax,RAX(%rsp)
126
1:
127
	DISABLE_INTERRUPTS(CLBR_NONE)
128
	TRACE_IRQS_OFF
129
	testl	$_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
130 131
	jnz	sysexit_audit
sysexit_from_sys_call:
132 133 134 135 136 137 138 139 140 141
	/*
	 * NB: SYSEXIT is not obviously safe for 64-bit kernels -- an
	 * NMI between STI and SYSEXIT has poorly specified behavior,
	 * and and NMI followed by an IRQ with usergs is fatal.  So
	 * we just pretend we're using SYSEXIT but we really use
	 * SYSRETL instead.
	 *
	 * This code path is still called 'sysexit' because it pairs
	 * with 'sysenter' and it uses the SYSENTER calling convention.
	 */
142
	andl    $~TS_COMPAT,ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
143
	movl	RIP(%rsp),%ecx		/* User %eip */
144
	RESTORE_RSI_RDI
145
	xorl	%edx,%edx		/* avoid info leaks */
146 147 148
	xorq	%r8,%r8
	xorq	%r9,%r9
	xorq	%r10,%r10
149
	movl	EFLAGS(%rsp),%r11d	/* User eflags */
150
	TRACE_IRQS_ON
151 152 153 154 155 156 157

	/*
	 * SYSRETL works even on Intel CPUs.  Use it in preference to SYSEXIT,
	 * since it avoids a dicey window with interrupts enabled.
	 */
	movl	RSP(%rsp),%esp

158
	/*
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
	 * USERGS_SYSRET32 does:
	 *  gsbase = user's gs base
	 *  eip = ecx
	 *  rflags = r11
	 *  cs = __USER32_CS
	 *  ss = __USER_DS
	 *
	 * The prologue set RIP(%rsp) to VDSO32_SYSENTER_RETURN, which does:
	 *
	 *  pop %ebp
	 *  pop %edx
	 *  pop %ecx
	 *
	 * Therefore, we invoke SYSRETL with EDX and R8-R10 zeroed to
	 * avoid info leaks.  R11 ends up with VDSO32_SYSENTER_RETURN's
	 * address (already known to user code), and R12-R15 are
	 * callee-saved and therefore don't contain any interesting
	 * kernel data.
177
	 */
178
	USERGS_SYSRET32
L
Linus Torvalds 已提交
179

180 181
#ifdef CONFIG_AUDITSYSCALL
	.macro auditsys_entry_common
182 183 184 185 186 187
	movl %esi,%r8d			/* 5th arg: 4th syscall arg */
	movl %ecx,%r9d			/*swap with edx*/
	movl %edx,%ecx			/* 4th arg: 3rd syscall arg */
	movl %r9d,%edx			/* 3rd arg: 2nd syscall arg */
	movl %ebx,%esi			/* 2nd arg: 1st syscall arg */
	movl %eax,%edi			/* 1st arg: syscall number */
188
	call __audit_syscall_entry
189
	movl ORIG_RAX(%rsp),%eax	/* reload syscall number */
190
	movl %ebx,%edi			/* reload 1st syscall arg */
191 192 193 194
	movl RCX(%rsp),%esi	/* reload 2nd syscall arg */
	movl RDX(%rsp),%edx	/* reload 3rd syscall arg */
	movl RSI(%rsp),%ecx	/* reload 4th syscall arg */
	movl RDI(%rsp),%r8d	/* reload 5th syscall arg */
195 196
	.endm

197
	.macro auditsys_exit exit
198
	testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
199
	jnz ia32_ret_from_sys_call
200
	TRACE_IRQS_ON
201
	ENABLE_INTERRUPTS(CLBR_NONE)
202
	movl %eax,%esi		/* second arg, syscall return value */
203
	cmpl $-MAX_ERRNO,%eax	/* is it an error ? */
204 205 206
	jbe 1f
	movslq %eax, %rsi	/* if error sign extend to 64 bits */
1:	setbe %al		/* 1 if error, 0 if not */
207
	movzbl %al,%edi		/* zero-extend that into %edi */
208
	call __audit_syscall_exit
209
	movq RAX(%rsp),%rax	/* reload syscall return value */
210
	movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
211
	DISABLE_INTERRUPTS(CLBR_NONE)
212
	TRACE_IRQS_OFF
213
	testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
214
	jz \exit
215 216 217 218 219
	xorl	%eax, %eax	/* do not leak kernel information */
	movq	%rax, R11(%rsp)
	movq	%rax, R10(%rsp)
	movq	%rax, R9(%rsp)
	movq	%rax, R8(%rsp)
220
	jmp int_with_check
221 222 223 224 225 226 227 228 229 230 231
	.endm

sysenter_auditsys:
	auditsys_entry_common
	movl %ebp,%r9d			/* reload 6th syscall arg */
	jmp sysenter_dispatch

sysexit_audit:
	auditsys_exit sysexit_from_sys_call
#endif

232
sysenter_fix_flags:
233 234
	pushq $(X86_EFLAGS_IF|X86_EFLAGS_FIXED)
	popfq
235 236
	jmp sysenter_flags_fixed

237 238
sysenter_tracesys:
#ifdef CONFIG_AUDITSYSCALL
239
	testl	$(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
240 241
	jz	sysenter_auditsys
#endif
242
	SAVE_EXTRA_REGS
243 244 245 246 247
	xorl	%eax, %eax	/* do not leak kernel information */
	movq	%rax, R11(%rsp)
	movq	%rax, R10(%rsp)
	movq	%rax, R9(%rsp)
	movq	%rax, R8(%rsp)
L
Linus Torvalds 已提交
248 249
	movq	%rsp,%rdi        /* &pt_regs -> arg1 */
	call	syscall_trace_enter
250 251 252 253 254 255 256 257

	/* Reload arg registers from stack. (see sysenter_tracesys) */
	movl	RCX(%rsp), %ecx
	movl	RDX(%rsp), %edx
	movl	RSI(%rsp), %esi
	movl	RDI(%rsp), %edi
	movl	%eax, %eax	/* zero extension */

258
	RESTORE_EXTRA_REGS
L
Linus Torvalds 已提交
259
	jmp	sysenter_do_call
260
ENDPROC(ia32_sysenter_target)
L
Linus Torvalds 已提交
261 262 263 264

/*
 * 32bit SYSCALL instruction entry.
 *
265 266 267 268 269 270 271 272 273 274 275 276
 * 32bit SYSCALL saves rip to rcx, clears rflags.RF, then saves rflags to r11,
 * then loads new ss, cs, and rip from previously programmed MSRs.
 * rflags gets masked by a value from another MSR (so CLD and CLAC
 * are not needed). SYSCALL does not save anything on the stack
 * and does not change rsp.
 *
 * Note: rflags saving+masking-with-MSR happens only in Long mode
 * (in legacy 32bit mode, IF, RF and VM bits are cleared and that's it).
 * Don't get confused: rflags saving+masking depends on Long Mode Active bit
 * (EFER.LMA=1), NOT on bitness of userspace where SYSCALL executes
 * or target CS descriptor's L bit (SYSCALL does not read segment descriptors).
 *
L
Linus Torvalds 已提交
277
 * Arguments:
278 279 280 281 282 283 284 285 286 287
 * eax  system call number
 * ecx  return address
 * ebx  arg1
 * ebp  arg2	(note: not saved in the stack frame, should not be touched)
 * edx  arg3
 * esi  arg4
 * edi  arg5
 * esp  user stack
 * 0(%esp) arg6
 *
L
Linus Torvalds 已提交
288
 * This is purely a fast path. For anything complicated we use the int 0x80
289 290 291
 * path below. We set up a complete hardware stack frame to share code
 * with the int 0x80 path.
 */
L
Linus Torvalds 已提交
292
ENTRY(ia32_cstar_target)
293 294 295 296 297
	/*
	 * Interrupts are off on entry.
	 * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
	 * it is too small to ever cause noticeable irq latency.
	 */
298
	SWAPGS_UNSAFE_STACK
L
Linus Torvalds 已提交
299
	movl	%esp,%r8d
300
	movq	PER_CPU_VAR(cpu_current_top_of_stack),%rsp
301
	ENABLE_INTERRUPTS(CLBR_NONE)
302

303 304 305
	/* Zero-extending 32-bit regs, do not remove */
	movl	%eax,%eax

306
	/* Construct struct pt_regs on stack */
307 308 309 310 311 312 313 314 315 316
	pushq	$__USER32_DS		/* pt_regs->ss */
	pushq	%r8			/* pt_regs->sp */
	pushq	%r11			/* pt_regs->flags */
	pushq	$__USER32_CS		/* pt_regs->cs */
	pushq	%rcx			/* pt_regs->ip */
	pushq	%rax			/* pt_regs->orig_ax */
	pushq	%rdi			/* pt_regs->di */
	pushq	%rsi			/* pt_regs->si */
	pushq	%rdx			/* pt_regs->dx */
	pushq	%rbp			/* pt_regs->cx */
L
Linus Torvalds 已提交
317
	movl	%ebp,%ecx
318
	pushq	$-ENOSYS		/* pt_regs->ax */
319 320
	sub	$(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */

321 322 323 324
	/*
	 * no need to do an access_ok check here because r8 has been
	 * 32bit zero extended
	 */
325
	ASM_STAC
L
Linus Torvalds 已提交
326
1:	movl	(%r8),%r9d
327
	_ASM_EXTABLE(1b,ia32_badarg)
328
	ASM_CLAC
329 330
	orl     $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
	testl   $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
L
Linus Torvalds 已提交
331
	jnz   cstar_tracesys
332

333
cstar_do_call:
334 335 336 337 338 339
	/* 32bit syscall -> 64bit C ABI argument conversion */
	movl	%edi,%r8d	/* arg5 */
	/* r9 already loaded */	/* arg6 */
	xchg	%ecx,%esi	/* rsi:arg2, rcx:arg4 */
	movl	%ebx,%edi	/* arg1 */
	movl	%edx,%edx	/* arg3 (zero extension) */
340
cstar_dispatch:
341 342
	cmpq	$(IA32_NR_syscalls-1),%rax
	ja	1f
L
Linus Torvalds 已提交
343
	call *ia32_sys_call_table(,%rax,8)
344
	movq %rax,RAX(%rsp)
345
1:
346
	DISABLE_INTERRUPTS(CLBR_NONE)
347
	TRACE_IRQS_OFF
348
	testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
349 350
	jnz sysretl_audit
sysretl_from_sys_call:
351
	andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
352
	RESTORE_RSI_RDI_RDX
353 354
	movl RIP(%rsp),%ecx
	movl EFLAGS(%rsp),%r11d
355 356 357
	xorq	%r10,%r10
	xorq	%r9,%r9
	xorq	%r8,%r8
358
	TRACE_IRQS_ON
359
	movl RSP(%rsp),%esp
360 361 362 363 364 365
	/*
	 * 64bit->32bit SYSRET restores eip from ecx,
	 * eflags from r11 (but RF and VM bits are forced to 0),
	 * cs and ss are loaded from MSRs.
	 * (Note: 32bit->32bit SYSRET is different: since r11
	 * does not exist, it merely sets eflags.IF=1).
366 367 368 369 370 371 372
	 *
	 * NB: On AMD CPUs with the X86_BUG_SYSRET_SS_ATTRS bug, the ss
	 * descriptor is not reinitialized.  This means that we must
	 * avoid SYSRET with SS == NULL, which could happen if we schedule,
	 * exit the kernel, and re-enter using an interrupt vector.  (All
	 * interrupt entries on x86_64 set SS to NULL.)  We prevent that
	 * from happening by reloading SS in __switch_to.
373
	 */
374
	USERGS_SYSRET32
375

376 377
#ifdef CONFIG_AUDITSYSCALL
cstar_auditsys:
378
	movl %r9d,R9(%rsp)	/* register to be clobbered by call */
379
	auditsys_entry_common
380
	movl R9(%rsp),%r9d	/* reload 6th syscall arg */
381 382 383
	jmp cstar_dispatch

sysretl_audit:
384
	auditsys_exit sysretl_from_sys_call
385 386 387 388
#endif

cstar_tracesys:
#ifdef CONFIG_AUDITSYSCALL
389
	testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
390 391
	jz cstar_auditsys
#endif
392
	xchgl %r9d,%ebp
393
	SAVE_EXTRA_REGS
394 395 396 397 398
	xorl	%eax, %eax	/* do not leak kernel information */
	movq	%rax, R11(%rsp)
	movq	%rax, R10(%rsp)
	movq	%r9,  R9(%rsp)
	movq	%rax, R8(%rsp)
L
Linus Torvalds 已提交
399 400
	movq %rsp,%rdi        /* &pt_regs -> arg1 */
	call syscall_trace_enter
401 402 403 404 405 406 407 408 409
	movl	R9(%rsp),%r9d

	/* Reload arg registers from stack. (see sysenter_tracesys) */
	movl	RCX(%rsp), %ecx
	movl	RDX(%rsp), %edx
	movl	RSI(%rsp), %esi
	movl	RDI(%rsp), %edi
	movl	%eax, %eax	/* zero extension */

410
	RESTORE_EXTRA_REGS
411
	xchgl %ebp,%r9d
L
Linus Torvalds 已提交
412
	jmp cstar_do_call
413
END(ia32_cstar_target)
L
Linus Torvalds 已提交
414 415
				
ia32_badarg:
416
	ASM_CLAC
L
Linus Torvalds 已提交
417 418 419
	movq $-EFAULT,%rax
	jmp ia32_sysret

420
ia32_ret_from_sys_call:
421 422 423 424 425
	xorl	%eax, %eax	/* do not leak kernel information */
	movq	%rax, R11(%rsp)
	movq	%rax, R10(%rsp)
	movq	%rax, R9(%rsp)
	movq	%rax, R8(%rsp)
426 427
	jmp int_ret_from_sys_call

428 429
/*
 * Emulated IA32 system calls via int 0x80.
L
Linus Torvalds 已提交
430
 *
431 432 433 434 435 436 437 438
 * Arguments:
 * eax  system call number
 * ebx  arg1
 * ecx  arg2
 * edx  arg3
 * esi  arg4
 * edi  arg5
 * ebp  arg6	(note: not saved in the stack frame, should not be touched)
L
Linus Torvalds 已提交
439 440
 *
 * Notes:
441 442
 * Uses the same stack frame as the x86-64 version.
 * All registers except eax must be saved (but ptrace may violate that).
L
Linus Torvalds 已提交
443 444 445
 * Arguments are zero extended. For system calls that want sign extension and
 * take long arguments a wrapper is needed. Most calls can just be called
 * directly.
446 447
 * Assumes it is only called from user space and entered with interrupts off.
 */
L
Linus Torvalds 已提交
448 449

ENTRY(ia32_syscall)
450
	/*
451 452 453
	 * Interrupts are off on entry.
	 * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
	 * it is too small to ever cause noticeable irq latency.
454
	 */
455 456
	PARAVIRT_ADJUST_EXCEPTION_FRAME
	SWAPGS
457
	ENABLE_INTERRUPTS(CLBR_NONE)
458

459 460 461
	/* Zero-extending 32-bit regs, do not remove */
	movl	%eax,%eax

462
	/* Construct struct pt_regs on stack (iret frame is already on stack) */
463 464 465 466 467 468
	pushq	%rax			/* pt_regs->orig_ax */
	pushq	%rdi			/* pt_regs->di */
	pushq	%rsi			/* pt_regs->si */
	pushq	%rdx			/* pt_regs->dx */
	pushq	%rcx			/* pt_regs->cx */
	pushq	$-ENOSYS		/* pt_regs->ax */
469 470 471 472
	pushq	$0			/* pt_regs->r8 */
	pushq	$0			/* pt_regs->r9 */
	pushq	$0			/* pt_regs->r10 */
	pushq	$0			/* pt_regs->r11 */
L
Linus Torvalds 已提交
473
	cld
474
	sub	$(6*8),%rsp /* pt_regs->bp,bx,r12-15 not saved */
475

476 477
	orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
	testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
L
Linus Torvalds 已提交
478
	jnz ia32_tracesys
479
ia32_do_call:
480 481 482 483 484 485
	/* 32bit syscall -> 64bit C ABI argument conversion */
	movl %edi,%r8d	/* arg5 */
	movl %ebp,%r9d	/* arg6 */
	xchg %ecx,%esi	/* rsi:arg2, rcx:arg4 */
	movl %ebx,%edi	/* arg1 */
	movl %edx,%edx	/* arg3 (zero extension) */
486 487
	cmpq	$(IA32_NR_syscalls-1),%rax
	ja	1f
L
Linus Torvalds 已提交
488 489
	call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
ia32_sysret:
490
	movq %rax,RAX(%rsp)
491
1:
492
	jmp int_ret_from_sys_call
L
Linus Torvalds 已提交
493

494 495
ia32_tracesys:
	SAVE_EXTRA_REGS
L
Linus Torvalds 已提交
496 497
	movq %rsp,%rdi        /* &pt_regs -> arg1 */
	call syscall_trace_enter
498 499 500 501 502 503 504 505 506 507 508 509
	/*
	 * Reload arg registers from stack in case ptrace changed them.
	 * Don't reload %eax because syscall_trace_enter() returned
	 * the %rax value we should see.  But do truncate it to 32 bits.
	 * If it's -1 to make us punt the syscall, then (u32)-1 is still
	 * an appropriately invalid value.
	 */
	movl	RCX(%rsp), %ecx
	movl	RDX(%rsp), %edx
	movl	RSI(%rsp), %esi
	movl	RDI(%rsp), %edi
	movl	%eax, %eax	/* zero extension */
510
	RESTORE_EXTRA_REGS
511
	jmp ia32_do_call
512
END(ia32_syscall)
L
Linus Torvalds 已提交
513

514
	.macro PTREGSCALL label, func
515 516
	ALIGN
GLOBAL(\label)
L
Linus Torvalds 已提交
517 518 519 520
	leaq \func(%rip),%rax
	jmp  ia32_ptregs_common	
	.endm

521 522 523 524
	PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn
	PTREGSCALL stub32_sigreturn, sys32_sigreturn
	PTREGSCALL stub32_fork, sys_fork
	PTREGSCALL stub32_vfork, sys_vfork
L
Linus Torvalds 已提交
525

526 527 528 529 530 531
	ALIGN
GLOBAL(stub32_clone)
	leaq sys_clone(%rip),%rax
	mov	%r8, %rcx
	jmp  ia32_ptregs_common	

532 533
	ALIGN
ia32_ptregs_common:
534
	SAVE_EXTRA_REGS 8
L
Linus Torvalds 已提交
535
	call *%rax
536 537
	RESTORE_EXTRA_REGS 8
	ret
538
END(ia32_ptregs_common)