ia32entry.S 14.6 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
	/* clobbers %rax */
	.macro  CLEAR_RREGS _r9=rax
L
Linus Torvalds 已提交
34
	xorl 	%eax,%eax
35 36 37 38
	movq	%rax,R11(%rsp)
	movq	%rax,R10(%rsp)
	movq	%\_r9,R9(%rsp)
	movq	%rax,R8(%rsp)
L
Linus Torvalds 已提交
39 40
	.endm

41 42 43
	/*
	 * Reload arg registers from stack in case ptrace changed them.
	 * We don't reload %eax because syscall_trace_enter() returned
44 45 46 47 48 49
	 * the %rax value we should see.  Instead, we just truncate that
	 * value to 32 bits again as we did on entry from user mode.
	 * If it's a new value set by user_regset during entry tracing,
	 * this matches the normal truncation of the user-mode value.
	 * If it's -1 to make us punt the syscall, then (u32)-1 is still
	 * an appropriately invalid value.
50
	 */
51
	.macro LOAD_ARGS32 _r9=0
52
	.if \_r9
53
	movl R9(%rsp),%r9d
54
	.endif
55 56 57 58
	movl RCX(%rsp),%ecx
	movl RDX(%rsp),%edx
	movl RSI(%rsp),%esi
	movl RDI(%rsp),%edi
59
	movl %eax,%eax			/* zero extension */
60 61
	.endm
	
62

63 64 65 66 67 68 69
#ifdef CONFIG_PARAVIRT
ENTRY(native_usergs_sysret32)
	swapgs
	sysretl
ENDPROC(native_usergs_sysret32)
#endif

L
Linus Torvalds 已提交
70 71 72
/*
 * 32bit SYSENTER instruction entry.
 *
73 74 75 76 77
 * 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 已提交
78
 * Arguments:
79 80 81 82 83 84 85 86 87
 * eax  system call number
 * ebx  arg1
 * ecx  arg2
 * edx  arg3
 * esi  arg4
 * edi  arg5
 * ebp  user stack
 * 0(%ebp) arg6
 *
L
Linus Torvalds 已提交
88
 * This is purely a fast path. For anything complicated we use the int 0x80
89
 * path below. We set up a complete hardware stack frame to share code
L
Linus Torvalds 已提交
90
 * with the int 0x80 path.
91
 */
L
Linus Torvalds 已提交
92
ENTRY(ia32_sysenter_target)
93
	/*
94 95 96
	 * 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.
97
	 */
98
	SWAPGS_UNSAFE_STACK
99
	movq	PER_CPU_VAR(cpu_current_top_of_stack), %rsp
100
	ENABLE_INTERRUPTS(CLBR_NONE)
101

102 103 104 105
	/* Zero-extending 32-bit regs, do not remove */
	movl	%ebp, %ebp
	movl	%eax, %eax

106 107 108
	movl	ASM_THREAD_INFO(TI_sysenter_return, %rsp, 0), %r10d

	/* Construct struct pt_regs on stack */
109 110 111 112 113 114 115 116 117 118 119
	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 已提交
120
	cld
121 122
	sub	$(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */

123 124 125 126
	/*
	 * no need to do an access_ok check here because rbp has been
	 * 32bit zero extended
	 */
127
	ASM_STAC
128
1:	movl	(%rbp),%ebp
129
	_ASM_EXTABLE(1b,ia32_badarg)
130
	ASM_CLAC
131 132 133 134 135 136

	/*
	 * 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.
	 */
137
	testl $X86_EFLAGS_NT,EFLAGS(%rsp)
138 139 140
	jnz sysenter_fix_flags
sysenter_flags_fixed:

141 142
	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 已提交
143
	jnz  sysenter_tracesys
144

145
sysenter_do_call:
146 147 148 149 150 151
	/* 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) */
152
sysenter_dispatch:
153 154
	cmpq	$(IA32_NR_syscalls-1),%rax
	ja	1f
L
Linus Torvalds 已提交
155
	call	*ia32_sys_call_table(,%rax,8)
156
	movq	%rax,RAX(%rsp)
157
1:
158
	DISABLE_INTERRUPTS(CLBR_NONE)
159
	TRACE_IRQS_OFF
160
	testl	$_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
161 162
	jnz	sysexit_audit
sysexit_from_sys_call:
163 164 165 166 167 168 169 170 171 172
	/*
	 * 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.
	 */
173
	andl    $~TS_COMPAT,ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
174
	movl	RIP(%rsp),%ecx		/* User %eip */
175
	RESTORE_RSI_RDI
176
	xorl	%edx,%edx		/* avoid info leaks */
177 178 179
	xorq	%r8,%r8
	xorq	%r9,%r9
	xorq	%r10,%r10
180
	movl	EFLAGS(%rsp),%r11d	/* User eflags */
181
	TRACE_IRQS_ON
182 183 184 185 186 187 188

	/*
	 * 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

189
	/*
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
	 * 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.
208
	 */
209
	USERGS_SYSRET32
L
Linus Torvalds 已提交
210

211 212
#ifdef CONFIG_AUDITSYSCALL
	.macro auditsys_entry_common
213 214 215 216 217 218
	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 */
219
	call __audit_syscall_entry
220
	movl ORIG_RAX(%rsp),%eax	/* reload syscall number */
221
	movl %ebx,%edi			/* reload 1st syscall arg */
222 223 224 225
	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 */
226 227
	.endm

228
	.macro auditsys_exit exit
229
	testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
230
	jnz ia32_ret_from_sys_call
231
	TRACE_IRQS_ON
232
	ENABLE_INTERRUPTS(CLBR_NONE)
233
	movl %eax,%esi		/* second arg, syscall return value */
234
	cmpl $-MAX_ERRNO,%eax	/* is it an error ? */
235 236 237
	jbe 1f
	movslq %eax, %rsi	/* if error sign extend to 64 bits */
1:	setbe %al		/* 1 if error, 0 if not */
238
	movzbl %al,%edi		/* zero-extend that into %edi */
239
	call __audit_syscall_exit
240
	movq RAX(%rsp),%rax	/* reload syscall return value */
241
	movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
242
	DISABLE_INTERRUPTS(CLBR_NONE)
243
	TRACE_IRQS_OFF
244
	testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
245
	jz \exit
246
	CLEAR_RREGS
247
	jmp int_with_check
248 249 250 251 252 253 254 255 256 257 258
	.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

259
sysenter_fix_flags:
260 261
	pushq $(X86_EFLAGS_IF|X86_EFLAGS_FIXED)
	popfq
262 263
	jmp sysenter_flags_fixed

264 265
sysenter_tracesys:
#ifdef CONFIG_AUDITSYSCALL
266
	testl	$(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
267 268
	jz	sysenter_auditsys
#endif
269
	SAVE_EXTRA_REGS
L
Linus Torvalds 已提交
270 271 272
	CLEAR_RREGS
	movq	%rsp,%rdi        /* &pt_regs -> arg1 */
	call	syscall_trace_enter
273
	LOAD_ARGS32  /* reload args from stack in case ptrace changed it */
274
	RESTORE_EXTRA_REGS
L
Linus Torvalds 已提交
275
	jmp	sysenter_do_call
276
ENDPROC(ia32_sysenter_target)
L
Linus Torvalds 已提交
277 278 279 280

/*
 * 32bit SYSCALL instruction entry.
 *
281 282 283 284 285 286 287 288 289 290 291 292
 * 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 已提交
293
 * Arguments:
294 295 296 297 298 299 300 301 302 303
 * 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 已提交
304
 * This is purely a fast path. For anything complicated we use the int 0x80
305 306 307
 * path below. We set up a complete hardware stack frame to share code
 * with the int 0x80 path.
 */
L
Linus Torvalds 已提交
308
ENTRY(ia32_cstar_target)
309 310 311 312 313
	/*
	 * 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.
	 */
314
	SWAPGS_UNSAFE_STACK
L
Linus Torvalds 已提交
315
	movl	%esp,%r8d
316
	movq	PER_CPU_VAR(cpu_current_top_of_stack),%rsp
317
	ENABLE_INTERRUPTS(CLBR_NONE)
318

319 320 321
	/* Zero-extending 32-bit regs, do not remove */
	movl	%eax,%eax

322
	/* Construct struct pt_regs on stack */
323 324 325 326 327 328 329 330 331 332
	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 已提交
333
	movl	%ebp,%ecx
334
	pushq	$-ENOSYS		/* pt_regs->ax */
335 336
	sub	$(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */

337 338 339 340
	/*
	 * no need to do an access_ok check here because r8 has been
	 * 32bit zero extended
	 */
341
	ASM_STAC
L
Linus Torvalds 已提交
342
1:	movl	(%r8),%r9d
343
	_ASM_EXTABLE(1b,ia32_badarg)
344
	ASM_CLAC
345 346
	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 已提交
347
	jnz   cstar_tracesys
348

349
cstar_do_call:
350 351 352 353 354 355
	/* 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) */
356
cstar_dispatch:
357 358
	cmpq	$(IA32_NR_syscalls-1),%rax
	ja	1f
L
Linus Torvalds 已提交
359
	call *ia32_sys_call_table(,%rax,8)
360
	movq %rax,RAX(%rsp)
361
1:
362
	DISABLE_INTERRUPTS(CLBR_NONE)
363
	TRACE_IRQS_OFF
364
	testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
365 366
	jnz sysretl_audit
sysretl_from_sys_call:
367
	andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
368
	RESTORE_RSI_RDI_RDX
369 370
	movl RIP(%rsp),%ecx
	movl EFLAGS(%rsp),%r11d
371 372 373
	xorq	%r10,%r10
	xorq	%r9,%r9
	xorq	%r8,%r8
374
	TRACE_IRQS_ON
375
	movl RSP(%rsp),%esp
376 377 378 379 380 381
	/*
	 * 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).
382 383 384 385 386 387 388
	 *
	 * 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.
389
	 */
390
	USERGS_SYSRET32
391

392 393
#ifdef CONFIG_AUDITSYSCALL
cstar_auditsys:
394
	movl %r9d,R9(%rsp)	/* register to be clobbered by call */
395
	auditsys_entry_common
396
	movl R9(%rsp),%r9d	/* reload 6th syscall arg */
397 398 399
	jmp cstar_dispatch

sysretl_audit:
400
	auditsys_exit sysretl_from_sys_call
401 402 403 404
#endif

cstar_tracesys:
#ifdef CONFIG_AUDITSYSCALL
405
	testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
406 407
	jz cstar_auditsys
#endif
408
	xchgl %r9d,%ebp
409
	SAVE_EXTRA_REGS
410
	CLEAR_RREGS r9
L
Linus Torvalds 已提交
411 412
	movq %rsp,%rdi        /* &pt_regs -> arg1 */
	call syscall_trace_enter
413
	LOAD_ARGS32 1	/* reload args from stack in case ptrace changed it */
414
	RESTORE_EXTRA_REGS
415
	xchgl %ebp,%r9d
L
Linus Torvalds 已提交
416
	jmp cstar_do_call
417
END(ia32_cstar_target)
L
Linus Torvalds 已提交
418 419
				
ia32_badarg:
420
	ASM_CLAC
L
Linus Torvalds 已提交
421 422 423
	movq $-EFAULT,%rax
	jmp ia32_sysret

424 425
/*
 * Emulated IA32 system calls via int 0x80.
L
Linus Torvalds 已提交
426
 *
427 428 429 430 431 432 433 434
 * 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 已提交
435 436
 *
 * Notes:
437 438
 * 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 已提交
439 440 441
 * 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.
442 443
 * Assumes it is only called from user space and entered with interrupts off.
 */
L
Linus Torvalds 已提交
444 445

ENTRY(ia32_syscall)
446
	/*
447 448 449
	 * 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.
450
	 */
451 452
	PARAVIRT_ADJUST_EXCEPTION_FRAME
	SWAPGS
453
	ENABLE_INTERRUPTS(CLBR_NONE)
454

455 456 457
	/* Zero-extending 32-bit regs, do not remove */
	movl	%eax,%eax

458
	/* Construct struct pt_regs on stack (iret frame is already on stack) */
459 460 461 462 463 464
	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 已提交
465
	cld
466 467
	sub	$(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */

468 469
	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 已提交
470
	jnz ia32_tracesys
471
ia32_do_call:
472 473 474 475 476 477
	/* 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) */
478 479
	cmpq	$(IA32_NR_syscalls-1),%rax
	ja	1f
L
Linus Torvalds 已提交
480 481
	call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
ia32_sysret:
482
	movq %rax,RAX(%rsp)
483
1:
484
ia32_ret_from_sys_call:
485
	CLEAR_RREGS
486
	jmp int_ret_from_sys_call
L
Linus Torvalds 已提交
487

488 489
ia32_tracesys:
	SAVE_EXTRA_REGS
J
Jan Beulich 已提交
490
	CLEAR_RREGS
L
Linus Torvalds 已提交
491 492
	movq %rsp,%rdi        /* &pt_regs -> arg1 */
	call syscall_trace_enter
493
	LOAD_ARGS32	/* reload args from stack in case ptrace changed it */
494
	RESTORE_EXTRA_REGS
495
	jmp ia32_do_call
496
END(ia32_syscall)
L
Linus Torvalds 已提交
497

498
	.macro PTREGSCALL label, func
499 500
	ALIGN
GLOBAL(\label)
L
Linus Torvalds 已提交
501 502 503 504
	leaq \func(%rip),%rax
	jmp  ia32_ptregs_common	
	.endm

505 506 507 508
	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 已提交
509

510 511 512 513 514 515
	ALIGN
GLOBAL(stub32_clone)
	leaq sys_clone(%rip),%rax
	mov	%r8, %rcx
	jmp  ia32_ptregs_common	

516 517
	ALIGN
ia32_ptregs_common:
518
	SAVE_EXTRA_REGS 8
L
Linus Torvalds 已提交
519
	call *%rax
520 521
	RESTORE_EXTRA_REGS 8
	ret
522
END(ia32_ptregs_common)