| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Sam Ravnborg | e2d5df9 | 2005-09-09 21:28:48 +0200 | [diff] [blame] | 9 | #include <asm/asm-offsets.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 15 | #include <asm/irqflags.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/linkage.h> | 
| Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 17 | #include <linux/err.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 |  | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 19 | /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */ | 
 | 20 | #include <linux/elf-em.h> | 
 | 21 | #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE) | 
 | 22 | #define __AUDIT_ARCH_LE	   0x40000000 | 
 | 23 |  | 
 | 24 | #ifndef CONFIG_AUDITSYSCALL | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 25 | #define sysexit_audit ia32_ret_from_sys_call | 
 | 26 | #define sysretl_audit ia32_ret_from_sys_call | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 27 | #endif | 
 | 28 |  | 
| Jiri Olsa | ea71454 | 2011-03-07 19:10:39 +0100 | [diff] [blame] | 29 | 	.section .entry.text, "ax" | 
 | 30 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | 	.macro IA32_ARG_FIXUP noebp=0 | 
 | 32 | 	movl	%edi,%r8d | 
 | 33 | 	.if \noebp | 
 | 34 | 	.else | 
 | 35 | 	movl	%ebp,%r9d | 
 | 36 | 	.endif | 
 | 37 | 	xchg	%ecx,%esi | 
 | 38 | 	movl	%ebx,%edi | 
 | 39 | 	movl	%edx,%edx	/* zero extension */ | 
 | 40 | 	.endm  | 
 | 41 |  | 
 | 42 | 	/* clobbers %eax */	 | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 43 | 	.macro  CLEAR_RREGS offset=0, _r9=rax | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | 	xorl 	%eax,%eax | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 45 | 	movq	%rax,\offset+R11(%rsp) | 
 | 46 | 	movq	%rax,\offset+R10(%rsp) | 
 | 47 | 	movq	%\_r9,\offset+R9(%rsp) | 
 | 48 | 	movq	%rax,\offset+R8(%rsp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | 	.endm | 
 | 50 |  | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 51 | 	/* | 
 | 52 | 	 * Reload arg registers from stack in case ptrace changed them. | 
 | 53 | 	 * We don't reload %eax because syscall_trace_enter() returned | 
| Roland McGrath | eefdca0 | 2010-09-14 12:22:58 -0700 | [diff] [blame] | 54 | 	 * the %rax value we should see.  Instead, we just truncate that | 
 | 55 | 	 * value to 32 bits again as we did on entry from user mode. | 
 | 56 | 	 * If it's a new value set by user_regset during entry tracing, | 
 | 57 | 	 * this matches the normal truncation of the user-mode value. | 
 | 58 | 	 * If it's -1 to make us punt the syscall, then (u32)-1 is still | 
 | 59 | 	 * an appropriately invalid value. | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 60 | 	 */ | 
| Jan Beulich | 295286a | 2008-08-29 13:21:11 +0100 | [diff] [blame] | 61 | 	.macro LOAD_ARGS32 offset, _r9=0 | 
 | 62 | 	.if \_r9 | 
| Andi Kleen | 176df24 | 2007-09-21 16:16:18 +0200 | [diff] [blame] | 63 | 	movl \offset+16(%rsp),%r9d | 
| Jan Beulich | 295286a | 2008-08-29 13:21:11 +0100 | [diff] [blame] | 64 | 	.endif | 
| Andi Kleen | 176df24 | 2007-09-21 16:16:18 +0200 | [diff] [blame] | 65 | 	movl \offset+40(%rsp),%ecx | 
 | 66 | 	movl \offset+48(%rsp),%edx | 
 | 67 | 	movl \offset+56(%rsp),%esi | 
 | 68 | 	movl \offset+64(%rsp),%edi | 
| Roland McGrath | eefdca0 | 2010-09-14 12:22:58 -0700 | [diff] [blame] | 69 | 	movl %eax,%eax			/* zero extension */ | 
| Andi Kleen | 176df24 | 2007-09-21 16:16:18 +0200 | [diff] [blame] | 70 | 	.endm | 
 | 71 | 	 | 
| Jan Beulich | 2765130 | 2006-01-11 22:41:59 +0100 | [diff] [blame] | 72 | 	.macro CFI_STARTPROC32 simple | 
 | 73 | 	CFI_STARTPROC	\simple | 
 | 74 | 	CFI_UNDEFINED	r8 | 
 | 75 | 	CFI_UNDEFINED	r9 | 
 | 76 | 	CFI_UNDEFINED	r10 | 
 | 77 | 	CFI_UNDEFINED	r11 | 
 | 78 | 	CFI_UNDEFINED	r12 | 
 | 79 | 	CFI_UNDEFINED	r13 | 
 | 80 | 	CFI_UNDEFINED	r14 | 
 | 81 | 	CFI_UNDEFINED	r15 | 
 | 82 | 	.endm | 
 | 83 |  | 
| Jeremy Fitzhardinge | 2be2998 | 2008-06-25 00:19:28 -0400 | [diff] [blame] | 84 | #ifdef CONFIG_PARAVIRT | 
 | 85 | ENTRY(native_usergs_sysret32) | 
 | 86 | 	swapgs | 
 | 87 | 	sysretl | 
 | 88 | ENDPROC(native_usergs_sysret32) | 
 | 89 |  | 
 | 90 | ENTRY(native_irq_enable_sysexit) | 
 | 91 | 	swapgs | 
 | 92 | 	sti | 
 | 93 | 	sysexit | 
 | 94 | ENDPROC(native_irq_enable_sysexit) | 
 | 95 | #endif | 
 | 96 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | /* | 
 | 98 |  * 32bit SYSENTER instruction entry. | 
 | 99 |  * | 
 | 100 |  * Arguments: | 
 | 101 |  * %eax	System call number. | 
 | 102 |  * %ebx Arg1 | 
 | 103 |  * %ecx Arg2 | 
 | 104 |  * %edx Arg3 | 
 | 105 |  * %esi Arg4 | 
 | 106 |  * %edi Arg5 | 
 | 107 |  * %ebp user stack | 
 | 108 |  * 0(%ebp) Arg6	 | 
 | 109 |  * 	 | 
 | 110 |  * Interrupts off. | 
 | 111 |  *	 | 
 | 112 |  * This is purely a fast path. For anything complicated we use the int 0x80 | 
 | 113 |  * path below.	Set up a complete hardware stack frame to share code | 
 | 114 |  * with the int 0x80 path. | 
 | 115 |  */ 	 | 
 | 116 | ENTRY(ia32_sysenter_target) | 
| Jan Beulich | 2765130 | 2006-01-11 22:41:59 +0100 | [diff] [blame] | 117 | 	CFI_STARTPROC32	simple | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 118 | 	CFI_SIGNAL_FRAME | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 119 | 	CFI_DEF_CFA	rsp,0 | 
 | 120 | 	CFI_REGISTER	rsp,rbp | 
| Jeremy Fitzhardinge | 457da70 | 2008-06-26 07:28:51 -0700 | [diff] [blame] | 121 | 	SWAPGS_UNSAFE_STACK | 
| Brian Gerst | 9af4565 | 2009-01-19 00:38:58 +0900 | [diff] [blame] | 122 | 	movq	PER_CPU_VAR(kernel_stack), %rsp | 
 | 123 | 	addq	$(KERNEL_STACK_OFFSET),%rsp | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 124 | 	/* | 
 | 125 | 	 * No need to follow this irqs on/off section: the syscall | 
 | 126 | 	 * disabled irqs, here we enable it straight after entry: | 
 | 127 | 	 */ | 
| Jeremy Fitzhardinge | 6680415 | 2008-06-25 00:19:29 -0400 | [diff] [blame] | 128 | 	ENABLE_INTERRUPTS(CLBR_NONE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 |  	movl	%ebp,%ebp		/* zero extension */ | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 130 | 	pushq_cfi $__USER32_DS | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 131 | 	/*CFI_REL_OFFSET ss,0*/ | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 132 | 	pushq_cfi %rbp | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 133 | 	CFI_REL_OFFSET rsp,0 | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 134 | 	pushfq_cfi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 135 | 	/*CFI_REL_OFFSET rflags,0*/ | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 136 | 	movl	TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 137 | 	CFI_REGISTER rip,r10 | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 138 | 	pushq_cfi $__USER32_CS | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 139 | 	/*CFI_REL_OFFSET cs,0*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | 	movl	%eax, %eax | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 141 | 	pushq_cfi %r10 | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 142 | 	CFI_REL_OFFSET rip,0 | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 143 | 	pushq_cfi %rax | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | 	cld | 
| Borislav Petkov | cac0e0a | 2011-05-31 22:21:52 +0200 | [diff] [blame] | 145 | 	SAVE_ARGS 0,1,0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 |  	/* no need to do an access_ok check here because rbp has been | 
 | 147 |  	   32bit zero extended */  | 
| Jan Beulich | 295286a | 2008-08-29 13:21:11 +0100 | [diff] [blame] | 148 | 1:	movl	(%rbp),%ebp | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 |  	.section __ex_table,"a" | 
 | 150 |  	.quad 1b,ia32_badarg | 
 | 151 |  	.previous	 | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 152 | 	orl     $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
 | 153 | 	testl   $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 154 | 	CFI_REMEMBER_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | 	jnz  sysenter_tracesys | 
| H. Peter Anvin | 36d001c | 2010-09-14 12:42:41 -0700 | [diff] [blame] | 156 | 	cmpq	$(IA32_NR_syscalls-1),%rax | 
| Andi Kleen | 67d53ea | 2006-04-07 19:50:31 +0200 | [diff] [blame] | 157 | 	ja	ia32_badsys | 
| Roland McGrath | d4d6715 | 2008-07-09 02:38:07 -0700 | [diff] [blame] | 158 | sysenter_do_call: | 
| Jan Beulich | 295286a | 2008-08-29 13:21:11 +0100 | [diff] [blame] | 159 | 	IA32_ARG_FIXUP | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 160 | sysenter_dispatch: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | 	call	*ia32_sys_call_table(,%rax,8) | 
 | 162 | 	movq	%rax,RAX-ARGOFFSET(%rsp) | 
| Jeremy Fitzhardinge | 6680415 | 2008-06-25 00:19:29 -0400 | [diff] [blame] | 163 | 	DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 164 | 	TRACE_IRQS_OFF | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 165 | 	testl	$_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 166 | 	jnz	sysexit_audit | 
 | 167 | sysexit_from_sys_call: | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 168 | 	andl    $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | 	/* clear IF, that popfq doesn't enable interrupts early */ | 
 | 170 | 	andl  $~0x200,EFLAGS-R11(%rsp)  | 
| Roland McGrath | 36197c9 | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 171 | 	movl	RIP-R11(%rsp),%edx		/* User %eip */ | 
 | 172 | 	CFI_REGISTER rip,rdx | 
| Borislav Petkov | 838feb4 | 2011-05-31 22:21:53 +0200 | [diff] [blame] | 173 | 	RESTORE_ARGS 0,24,0,0,0,0 | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 174 | 	xorq	%r8,%r8 | 
 | 175 | 	xorq	%r9,%r9 | 
 | 176 | 	xorq	%r10,%r10 | 
 | 177 | 	xorq	%r11,%r11 | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 178 | 	popfq_cfi | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 179 | 	/*CFI_RESTORE rflags*/ | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 180 | 	popq_cfi %rcx				/* User %esp */ | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 181 | 	CFI_REGISTER rsp,rcx | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 182 | 	TRACE_IRQS_ON | 
| Jeremy Fitzhardinge | 2be2998 | 2008-06-25 00:19:28 -0400 | [diff] [blame] | 183 | 	ENABLE_INTERRUPTS_SYSEXIT32 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 |  | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 185 | #ifdef CONFIG_AUDITSYSCALL | 
 | 186 | 	.macro auditsys_entry_common | 
 | 187 | 	movl %esi,%r9d			/* 6th arg: 4th syscall arg */ | 
 | 188 | 	movl %edx,%r8d			/* 5th arg: 3rd syscall arg */ | 
 | 189 | 	/* (already in %ecx)		   4th arg: 2nd syscall arg */ | 
 | 190 | 	movl %ebx,%edx			/* 3rd arg: 1st syscall arg */ | 
 | 191 | 	movl %eax,%esi			/* 2nd arg: syscall number */ | 
 | 192 | 	movl $AUDIT_ARCH_I386,%edi	/* 1st arg: audit arch */ | 
| Eric Paris | b05d844 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 193 | 	call __audit_syscall_entry | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 194 | 	movl RAX-ARGOFFSET(%rsp),%eax	/* reload syscall number */ | 
| H. Peter Anvin | 36d001c | 2010-09-14 12:42:41 -0700 | [diff] [blame] | 195 | 	cmpq $(IA32_NR_syscalls-1),%rax | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 196 | 	ja ia32_badsys | 
 | 197 | 	movl %ebx,%edi			/* reload 1st syscall arg */ | 
 | 198 | 	movl RCX-ARGOFFSET(%rsp),%esi	/* reload 2nd syscall arg */ | 
 | 199 | 	movl RDX-ARGOFFSET(%rsp),%edx	/* reload 3rd syscall arg */ | 
 | 200 | 	movl RSI-ARGOFFSET(%rsp),%ecx	/* reload 4th syscall arg */ | 
 | 201 | 	movl RDI-ARGOFFSET(%rsp),%r8d	/* reload 5th syscall arg */ | 
 | 202 | 	.endm | 
 | 203 |  | 
| Jan Beulich | 8176674 | 2009-10-26 15:20:29 +0000 | [diff] [blame] | 204 | 	.macro auditsys_exit exit | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 205 | 	testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 206 | 	jnz ia32_ret_from_sys_call | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 207 | 	TRACE_IRQS_ON | 
 | 208 | 	sti | 
 | 209 | 	movl %eax,%esi		/* second arg, syscall return value */ | 
| Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 210 | 	cmpl $-MAX_ERRNO,%eax	/* is it an error ? */ | 
| Eric Paris | f031cd2 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 211 | 	jbe 1f | 
 | 212 | 	movslq %eax, %rsi	/* if error sign extend to 64 bits */ | 
 | 213 | 1:	setbe %al		/* 1 if error, 0 if not */ | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 214 | 	movzbl %al,%edi		/* zero-extend that into %edi */ | 
| Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 215 | 	call __audit_syscall_exit | 
 | 216 | 	movq RAX-ARGOFFSET(%rsp),%rax	/* reload syscall return value */ | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 217 | 	movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi | 
 | 218 | 	cli | 
 | 219 | 	TRACE_IRQS_OFF | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 220 | 	testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 221 | 	jz \exit | 
 | 222 | 	CLEAR_RREGS -ARGOFFSET | 
 | 223 | 	jmp int_with_check | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 224 | 	.endm | 
 | 225 |  | 
 | 226 | sysenter_auditsys: | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 227 | 	CFI_RESTORE_STATE | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 228 | 	auditsys_entry_common | 
 | 229 | 	movl %ebp,%r9d			/* reload 6th syscall arg */ | 
 | 230 | 	jmp sysenter_dispatch | 
 | 231 |  | 
 | 232 | sysexit_audit: | 
 | 233 | 	auditsys_exit sysexit_from_sys_call | 
 | 234 | #endif | 
 | 235 |  | 
 | 236 | sysenter_tracesys: | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 237 | #ifdef CONFIG_AUDITSYSCALL | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 238 | 	testl	$(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 239 | 	jz	sysenter_auditsys | 
 | 240 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | 	SAVE_REST | 
 | 242 | 	CLEAR_RREGS | 
| Roland McGrath | 48ee679 | 2008-03-18 18:23:50 -0700 | [diff] [blame] | 243 | 	movq	$-ENOSYS,RAX(%rsp)/* ptrace can change this for a bad syscall */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | 	movq	%rsp,%rdi        /* &pt_regs -> arg1 */ | 
 | 245 | 	call	syscall_trace_enter | 
| Andi Kleen | 176df24 | 2007-09-21 16:16:18 +0200 | [diff] [blame] | 246 | 	LOAD_ARGS32 ARGOFFSET  /* reload args from stack in case ptrace changed it */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | 	RESTORE_REST | 
| H. Peter Anvin | 36d001c | 2010-09-14 12:42:41 -0700 | [diff] [blame] | 248 | 	cmpq	$(IA32_NR_syscalls-1),%rax | 
| Roland McGrath | 48ee679 | 2008-03-18 18:23:50 -0700 | [diff] [blame] | 249 | 	ja	int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | 	jmp	sysenter_do_call | 
 | 251 | 	CFI_ENDPROC | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 252 | ENDPROC(ia32_sysenter_target) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 |  | 
 | 254 | /* | 
 | 255 |  * 32bit SYSCALL instruction entry. | 
 | 256 |  * | 
 | 257 |  * Arguments: | 
 | 258 |  * %eax	System call number. | 
 | 259 |  * %ebx Arg1 | 
 | 260 |  * %ecx return EIP  | 
 | 261 |  * %edx Arg3 | 
 | 262 |  * %esi Arg4 | 
 | 263 |  * %edi Arg5 | 
 | 264 |  * %ebp Arg2    [note: not saved in the stack frame, should not be touched] | 
 | 265 |  * %esp user stack  | 
 | 266 |  * 0(%esp) Arg6 | 
 | 267 |  * 	 | 
 | 268 |  * Interrupts off. | 
 | 269 |  *	 | 
 | 270 |  * This is purely a fast path. For anything complicated we use the int 0x80 | 
 | 271 |  * path below.	Set up a complete hardware stack frame to share code | 
 | 272 |  * with the int 0x80 path.	 | 
 | 273 |  */ 	 | 
 | 274 | ENTRY(ia32_cstar_target) | 
| Jan Beulich | 2765130 | 2006-01-11 22:41:59 +0100 | [diff] [blame] | 275 | 	CFI_STARTPROC32	simple | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 276 | 	CFI_SIGNAL_FRAME | 
| Brian Gerst | 9af4565 | 2009-01-19 00:38:58 +0900 | [diff] [blame] | 277 | 	CFI_DEF_CFA	rsp,KERNEL_STACK_OFFSET | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 278 | 	CFI_REGISTER	rip,rcx | 
 | 279 | 	/*CFI_REGISTER	rflags,r11*/ | 
| Jeremy Fitzhardinge | 457da70 | 2008-06-26 07:28:51 -0700 | [diff] [blame] | 280 | 	SWAPGS_UNSAFE_STACK | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | 	movl	%esp,%r8d | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 282 | 	CFI_REGISTER	rsp,r8 | 
| Brian Gerst | 9af4565 | 2009-01-19 00:38:58 +0900 | [diff] [blame] | 283 | 	movq	PER_CPU_VAR(kernel_stack),%rsp | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 284 | 	/* | 
 | 285 | 	 * No need to follow this irqs on/off section: the syscall | 
 | 286 | 	 * disabled irqs and here we enable it straight after entry: | 
 | 287 | 	 */ | 
| Jeremy Fitzhardinge | 6680415 | 2008-06-25 00:19:29 -0400 | [diff] [blame] | 288 | 	ENABLE_INTERRUPTS(CLBR_NONE) | 
| Borislav Petkov | cac0e0a | 2011-05-31 22:21:52 +0200 | [diff] [blame] | 289 | 	SAVE_ARGS 8,0,0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | 	movl 	%eax,%eax	/* zero extension */ | 
 | 291 | 	movq	%rax,ORIG_RAX-ARGOFFSET(%rsp) | 
 | 292 | 	movq	%rcx,RIP-ARGOFFSET(%rsp) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 293 | 	CFI_REL_OFFSET rip,RIP-ARGOFFSET | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | 	movq	%rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */ | 
 | 295 | 	movl	%ebp,%ecx | 
 | 296 | 	movq	$__USER32_CS,CS-ARGOFFSET(%rsp) | 
 | 297 | 	movq	$__USER32_DS,SS-ARGOFFSET(%rsp) | 
 | 298 | 	movq	%r11,EFLAGS-ARGOFFSET(%rsp) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 299 | 	/*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | 	movq	%r8,RSP-ARGOFFSET(%rsp)	 | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 301 | 	CFI_REL_OFFSET rsp,RSP-ARGOFFSET | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | 	/* no need to do an access_ok check here because r8 has been | 
 | 303 | 	   32bit zero extended */  | 
 | 304 | 	/* hardware stack frame is complete now */	 | 
 | 305 | 1:	movl	(%r8),%r9d | 
 | 306 | 	.section __ex_table,"a" | 
 | 307 | 	.quad 1b,ia32_badarg | 
 | 308 | 	.previous	 | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 309 | 	orl     $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
 | 310 | 	testl   $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 311 | 	CFI_REMEMBER_STATE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | 	jnz   cstar_tracesys | 
| H. Peter Anvin | 36d001c | 2010-09-14 12:42:41 -0700 | [diff] [blame] | 313 | 	cmpq $IA32_NR_syscalls-1,%rax | 
| Andi Kleen | 67d53ea | 2006-04-07 19:50:31 +0200 | [diff] [blame] | 314 | 	ja  ia32_badsys | 
| Jan Beulich | 295286a | 2008-08-29 13:21:11 +0100 | [diff] [blame] | 315 | cstar_do_call: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | 	IA32_ARG_FIXUP 1 | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 317 | cstar_dispatch: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | 	call *ia32_sys_call_table(,%rax,8) | 
 | 319 | 	movq %rax,RAX-ARGOFFSET(%rsp) | 
| Jeremy Fitzhardinge | 6680415 | 2008-06-25 00:19:29 -0400 | [diff] [blame] | 320 | 	DISABLE_INTERRUPTS(CLBR_NONE) | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 321 | 	TRACE_IRQS_OFF | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 322 | 	testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 323 | 	jnz sysretl_audit | 
 | 324 | sysretl_from_sys_call: | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 325 | 	andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Borislav Petkov | 838feb4 | 2011-05-31 22:21:53 +0200 | [diff] [blame] | 326 | 	RESTORE_ARGS 0,-ARG_SKIP,0,0,0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | 	movl RIP-ARGOFFSET(%rsp),%ecx | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 328 | 	CFI_REGISTER rip,rcx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | 	movl EFLAGS-ARGOFFSET(%rsp),%r11d	 | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 330 | 	/*CFI_REGISTER rflags,r11*/ | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 331 | 	xorq	%r10,%r10 | 
 | 332 | 	xorq	%r9,%r9 | 
 | 333 | 	xorq	%r8,%r8 | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 334 | 	TRACE_IRQS_ON | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | 	movl RSP-ARGOFFSET(%rsp),%esp | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 336 | 	CFI_RESTORE rsp | 
| Jeremy Fitzhardinge | 2be2998 | 2008-06-25 00:19:28 -0400 | [diff] [blame] | 337 | 	USERGS_SYSRET32 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | 	 | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 339 | #ifdef CONFIG_AUDITSYSCALL | 
 | 340 | cstar_auditsys: | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 341 | 	CFI_RESTORE_STATE | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 342 | 	movl %r9d,R9-ARGOFFSET(%rsp)	/* register to be clobbered by call */ | 
 | 343 | 	auditsys_entry_common | 
 | 344 | 	movl R9-ARGOFFSET(%rsp),%r9d	/* reload 6th syscall arg */ | 
 | 345 | 	jmp cstar_dispatch | 
 | 346 |  | 
 | 347 | sysretl_audit: | 
| Jan Beulich | 8176674 | 2009-10-26 15:20:29 +0000 | [diff] [blame] | 348 | 	auditsys_exit sysretl_from_sys_call | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 349 | #endif | 
 | 350 |  | 
 | 351 | cstar_tracesys: | 
 | 352 | #ifdef CONFIG_AUDITSYSCALL | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 353 | 	testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Roland McGrath | 5cbf156 | 2008-06-24 01:13:31 -0700 | [diff] [blame] | 354 | 	jz cstar_auditsys | 
 | 355 | #endif | 
| Chuck Ebbert | ecd744e | 2007-11-07 10:48:39 -0500 | [diff] [blame] | 356 | 	xchgl %r9d,%ebp | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | 	SAVE_REST | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 358 | 	CLEAR_RREGS 0, r9 | 
| Roland McGrath | 48ee679 | 2008-03-18 18:23:50 -0700 | [diff] [blame] | 359 | 	movq $-ENOSYS,RAX(%rsp)	/* ptrace can change this for a bad syscall */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | 	movq %rsp,%rdi        /* &pt_regs -> arg1 */ | 
 | 361 | 	call syscall_trace_enter | 
| Jan Beulich | 295286a | 2008-08-29 13:21:11 +0100 | [diff] [blame] | 362 | 	LOAD_ARGS32 ARGOFFSET, 1  /* reload args from stack in case ptrace changed it */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | 	RESTORE_REST | 
| Chuck Ebbert | ecd744e | 2007-11-07 10:48:39 -0500 | [diff] [blame] | 364 | 	xchgl %ebp,%r9d | 
| H. Peter Anvin | 36d001c | 2010-09-14 12:42:41 -0700 | [diff] [blame] | 365 | 	cmpq $(IA32_NR_syscalls-1),%rax | 
| Roland McGrath | 48ee679 | 2008-03-18 18:23:50 -0700 | [diff] [blame] | 366 | 	ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | 	jmp cstar_do_call | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 368 | END(ia32_cstar_target) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | 				 | 
 | 370 | ia32_badarg: | 
 | 371 | 	movq $-EFAULT,%rax | 
 | 372 | 	jmp ia32_sysret | 
 | 373 | 	CFI_ENDPROC | 
 | 374 |  | 
 | 375 | /*  | 
 | 376 |  * Emulated IA32 system calls via int 0x80.  | 
 | 377 |  * | 
 | 378 |  * Arguments:	  | 
 | 379 |  * %eax	System call number. | 
 | 380 |  * %ebx Arg1 | 
 | 381 |  * %ecx Arg2 | 
 | 382 |  * %edx Arg3 | 
 | 383 |  * %esi Arg4 | 
 | 384 |  * %edi Arg5 | 
 | 385 |  * %ebp Arg6    [note: not saved in the stack frame, should not be touched] | 
 | 386 |  * | 
 | 387 |  * Notes: | 
 | 388 |  * Uses the same stack frame as the x86-64 version.	 | 
 | 389 |  * All registers except %eax must be saved (but ptrace may violate that) | 
 | 390 |  * Arguments are zero extended. For system calls that want sign extension and | 
 | 391 |  * take long arguments a wrapper is needed. Most calls can just be called | 
 | 392 |  * directly. | 
 | 393 |  * Assumes it is only called from user space and entered with interrupts off.	 | 
 | 394 |  */ 				 | 
 | 395 |  | 
 | 396 | ENTRY(ia32_syscall) | 
| Jan Beulich | cdc1793 | 2007-07-21 17:10:20 +0200 | [diff] [blame] | 397 | 	CFI_STARTPROC32	simple | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 398 | 	CFI_SIGNAL_FRAME | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 399 | 	CFI_DEF_CFA	rsp,SS+8-RIP | 
 | 400 | 	/*CFI_REL_OFFSET	ss,SS-RIP*/ | 
 | 401 | 	CFI_REL_OFFSET	rsp,RSP-RIP | 
 | 402 | 	/*CFI_REL_OFFSET	rflags,EFLAGS-RIP*/ | 
 | 403 | 	/*CFI_REL_OFFSET	cs,CS-RIP*/ | 
 | 404 | 	CFI_REL_OFFSET	rip,RIP-RIP | 
| Jeremy Fitzhardinge | 360c044 | 2008-07-08 15:06:28 -0700 | [diff] [blame] | 405 | 	PARAVIRT_ADJUST_EXCEPTION_FRAME | 
| Jeremy Fitzhardinge | 6680415 | 2008-06-25 00:19:29 -0400 | [diff] [blame] | 406 | 	SWAPGS | 
| Ingo Molnar | 2601e64 | 2006-07-03 00:24:45 -0700 | [diff] [blame] | 407 | 	/* | 
 | 408 | 	 * No need to follow this irqs on/off section: the syscall | 
 | 409 | 	 * disabled irqs and here we enable it straight after entry: | 
 | 410 | 	 */ | 
| Jeremy Fitzhardinge | 6680415 | 2008-06-25 00:19:29 -0400 | [diff] [blame] | 411 | 	ENABLE_INTERRUPTS(CLBR_NONE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | 	movl %eax,%eax | 
| Jan Beulich | 60cf637 | 2011-02-28 15:54:40 +0000 | [diff] [blame] | 413 | 	pushq_cfi %rax | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | 	cld | 
 | 415 | 	/* note the registers are not zero extended to the sf. | 
 | 416 | 	   this could be a problem. */ | 
| Borislav Petkov | cac0e0a | 2011-05-31 22:21:52 +0200 | [diff] [blame] | 417 | 	SAVE_ARGS 0,1,0 | 
| Jan Beulich | 46db09d | 2011-11-29 11:17:45 +0000 | [diff] [blame] | 418 | 	orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
 | 419 | 	testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | 	jnz ia32_tracesys | 
| H. Peter Anvin | 36d001c | 2010-09-14 12:42:41 -0700 | [diff] [blame] | 421 | 	cmpq $(IA32_NR_syscalls-1),%rax | 
| Roland McGrath | c09249f | 2009-02-06 18:15:18 -0800 | [diff] [blame] | 422 | 	ja ia32_badsys | 
 | 423 | ia32_do_call: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | 	IA32_ARG_FIXUP | 
 | 425 | 	call *ia32_sys_call_table(,%rax,8) # xxx: rip relative | 
 | 426 | ia32_sysret: | 
 | 427 | 	movq %rax,RAX-ARGOFFSET(%rsp) | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 428 | ia32_ret_from_sys_call: | 
 | 429 | 	CLEAR_RREGS -ARGOFFSET | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | 	jmp int_ret_from_sys_call  | 
 | 431 |  | 
 | 432 | ia32_tracesys:			  | 
 | 433 | 	SAVE_REST | 
| Jan Beulich | cdc1793 | 2007-07-21 17:10:20 +0200 | [diff] [blame] | 434 | 	CLEAR_RREGS | 
| Roland McGrath | 8ab32bb | 2008-03-16 21:57:41 -0700 | [diff] [blame] | 435 | 	movq $-ENOSYS,RAX(%rsp)	/* ptrace can change this for a bad syscall */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | 	movq %rsp,%rdi        /* &pt_regs -> arg1 */ | 
 | 437 | 	call syscall_trace_enter | 
| Andi Kleen | 176df24 | 2007-09-21 16:16:18 +0200 | [diff] [blame] | 438 | 	LOAD_ARGS32 ARGOFFSET  /* reload args from stack in case ptrace changed it */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | 	RESTORE_REST | 
| H. Peter Anvin | 36d001c | 2010-09-14 12:42:41 -0700 | [diff] [blame] | 440 | 	cmpq $(IA32_NR_syscalls-1),%rax | 
| Roland McGrath | c09249f | 2009-02-06 18:15:18 -0800 | [diff] [blame] | 441 | 	ja  int_ret_from_sys_call	/* ia32_tracesys has set RAX(%rsp) */ | 
 | 442 | 	jmp ia32_do_call | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 443 | END(ia32_syscall) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 |  | 
 | 445 | ia32_badsys: | 
 | 446 | 	movq $0,ORIG_RAX-ARGOFFSET(%rsp) | 
| Jan Beulich | 24e3580 | 2009-09-30 11:22:11 +0100 | [diff] [blame] | 447 | 	movq $-ENOSYS,%rax | 
 | 448 | 	jmp ia32_sysret | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | 	CFI_ENDPROC | 
 | 451 | 	 | 
 | 452 | 	.macro PTREGSCALL label, func, arg | 
| Jan Beulich | f6b2bc8 | 2011-11-29 11:24:10 +0000 | [diff] [blame] | 453 | 	ALIGN | 
 | 454 | GLOBAL(\label) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | 	leaq \func(%rip),%rax | 
 | 456 | 	leaq -ARGOFFSET+8(%rsp),\arg	/* 8 for return address */ | 
 | 457 | 	jmp  ia32_ptregs_common	 | 
 | 458 | 	.endm | 
 | 459 |  | 
| Jan Beulich | 2765130 | 2006-01-11 22:41:59 +0100 | [diff] [blame] | 460 | 	CFI_STARTPROC32 | 
| Jan Beulich | 7effaa8 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 461 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | 	PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi | 
 | 463 | 	PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi | 
 | 464 | 	PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | 	PTREGSCALL stub32_execve, sys32_execve, %rcx | 
 | 466 | 	PTREGSCALL stub32_fork, sys_fork, %rdi | 
 | 467 | 	PTREGSCALL stub32_clone, sys32_clone, %rdx | 
 | 468 | 	PTREGSCALL stub32_vfork, sys_vfork, %rdi | 
 | 469 | 	PTREGSCALL stub32_iopl, sys_iopl, %rsi | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 |  | 
| Jan Beulich | f6b2bc8 | 2011-11-29 11:24:10 +0000 | [diff] [blame] | 471 | 	ALIGN | 
 | 472 | ia32_ptregs_common: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | 	popq %r11 | 
| Jan Beulich | 2765130 | 2006-01-11 22:41:59 +0100 | [diff] [blame] | 474 | 	CFI_ENDPROC | 
 | 475 | 	CFI_STARTPROC32	simple | 
| Jan Beulich | adf1423 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 476 | 	CFI_SIGNAL_FRAME | 
| Jan Beulich | 2765130 | 2006-01-11 22:41:59 +0100 | [diff] [blame] | 477 | 	CFI_DEF_CFA	rsp,SS+8-ARGOFFSET | 
 | 478 | 	CFI_REL_OFFSET	rax,RAX-ARGOFFSET | 
 | 479 | 	CFI_REL_OFFSET	rcx,RCX-ARGOFFSET | 
 | 480 | 	CFI_REL_OFFSET	rdx,RDX-ARGOFFSET | 
 | 481 | 	CFI_REL_OFFSET	rsi,RSI-ARGOFFSET | 
 | 482 | 	CFI_REL_OFFSET	rdi,RDI-ARGOFFSET | 
 | 483 | 	CFI_REL_OFFSET	rip,RIP-ARGOFFSET | 
 | 484 | /*	CFI_REL_OFFSET	cs,CS-ARGOFFSET*/ | 
 | 485 | /*	CFI_REL_OFFSET	rflags,EFLAGS-ARGOFFSET*/ | 
 | 486 | 	CFI_REL_OFFSET	rsp,RSP-ARGOFFSET | 
 | 487 | /*	CFI_REL_OFFSET	ss,SS-ARGOFFSET*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | 	SAVE_REST | 
 | 489 | 	call *%rax | 
 | 490 | 	RESTORE_REST | 
 | 491 | 	jmp  ia32_sysret	/* misbalances the return cache */ | 
 | 492 | 	CFI_ENDPROC | 
| Jan Beulich | 4b787e0 | 2006-06-26 13:56:55 +0200 | [diff] [blame] | 493 | END(ia32_ptregs_common) |