3 * Copyright (C) 1991, 1992 Linus Torvalds
7 * entry.S contains the system-call and fault low-level handling routines.
8 * This also contains the timer-interrupt handler, as well as all interrupts
9 * and faults that can result in a task-switch.
11 * NOTE: This code handles signal-recognition, which happens every time
12 * after a timer-interrupt and after each system call.
14 * I changed all the .align's to 4 (16 byte alignment), as that's faster
17 * Stack layout in 'syscall_exit':
18 * ptrace needs to have all regs on the stack.
19 * if the order here is changed, it needs to be
20 * updated in fork.c:copy_process, signal.c:do_signal,
21 * ptrace.c and ptrace.h
40 * "current" is in register %ebx during any slow entries.
43 #include <linux/linkage.h>
44 #include <asm/thread_info.h>
45 #include <asm/irqflags.h>
46 #include <asm/errno.h>
47 #include <asm/segment.h>
51 #include <asm/percpu.h>
52 #include <asm/dwarf2.h>
53 #include <asm/processor-flags.h>
54 #include <asm/ftrace.h>
55 #include <asm/irq_vectors.h>
57 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
58 #include <linux/elf-em.h>
59 #define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE)
60 #define __AUDIT_ARCH_LE 0x40000000
62 #ifndef CONFIG_AUDITSYSCALL
63 #define sysenter_audit syscall_trace_entry
64 #define sysexit_audit syscall_exit_work
68 * We use macros for low-level operations which need to be overridden
69 * for paravirtualization. The following will never clobber any registers:
70 * INTERRUPT_RETURN (aka. "iret")
71 * GET_CR0_INTO_EAX (aka. "movl %cr0, %eax")
72 * ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit").
74 * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must
75 * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY).
76 * Allowing a register to be clobbered can shrink the paravirt replacement
77 * enough to patch inline, increasing performance.
80 #define nr_syscalls ((syscall_table_size)/4)
83 #define preempt_stop(clobbers) DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF
85 #define preempt_stop(clobbers)
86 #define resume_kernel restore_nocheck
89 .macro TRACE_IRQS_IRET
90 #ifdef CONFIG_TRACE_IRQFLAGS
91 testl $X86_EFLAGS_IF,PT_EFLAGS(%esp) # interrupts off?
99 #define resume_userspace_sig check_userspace
101 #define resume_userspace_sig resume_userspace
107 CFI_ADJUST_CFA_OFFSET 4;\
108 /*CFI_REL_OFFSET fs, 0;*/\
110 CFI_ADJUST_CFA_OFFSET 4;\
111 /*CFI_REL_OFFSET es, 0;*/\
113 CFI_ADJUST_CFA_OFFSET 4;\
114 /*CFI_REL_OFFSET ds, 0;*/\
116 CFI_ADJUST_CFA_OFFSET 4;\
117 CFI_REL_OFFSET eax, 0;\
119 CFI_ADJUST_CFA_OFFSET 4;\
120 CFI_REL_OFFSET ebp, 0;\
122 CFI_ADJUST_CFA_OFFSET 4;\
123 CFI_REL_OFFSET edi, 0;\
125 CFI_ADJUST_CFA_OFFSET 4;\
126 CFI_REL_OFFSET esi, 0;\
128 CFI_ADJUST_CFA_OFFSET 4;\
129 CFI_REL_OFFSET edx, 0;\
131 CFI_ADJUST_CFA_OFFSET 4;\
132 CFI_REL_OFFSET ecx, 0;\
134 CFI_ADJUST_CFA_OFFSET 4;\
135 CFI_REL_OFFSET ebx, 0;\
136 movl $(__USER_DS), %edx; \
139 movl $(__KERNEL_PERCPU), %edx; \
142 #define RESTORE_INT_REGS \
144 CFI_ADJUST_CFA_OFFSET -4;\
147 CFI_ADJUST_CFA_OFFSET -4;\
150 CFI_ADJUST_CFA_OFFSET -4;\
153 CFI_ADJUST_CFA_OFFSET -4;\
156 CFI_ADJUST_CFA_OFFSET -4;\
159 CFI_ADJUST_CFA_OFFSET -4;\
162 CFI_ADJUST_CFA_OFFSET -4;\
165 #define RESTORE_REGS \
168 CFI_ADJUST_CFA_OFFSET -4;\
171 CFI_ADJUST_CFA_OFFSET -4;\
174 CFI_ADJUST_CFA_OFFSET -4;\
176 .pushsection .fixup,"ax"; \
183 .section __ex_table,"a";\
190 #define RING0_INT_FRAME \
191 CFI_STARTPROC simple;\
193 CFI_DEF_CFA esp, 3*4;\
194 /*CFI_OFFSET cs, -2*4;*/\
197 #define RING0_EC_FRAME \
198 CFI_STARTPROC simple;\
200 CFI_DEF_CFA esp, 4*4;\
201 /*CFI_OFFSET cs, -2*4;*/\
204 #define RING0_PTREGS_FRAME \
205 CFI_STARTPROC simple;\
207 CFI_DEF_CFA esp, PT_OLDESP-PT_EBX;\
208 /*CFI_OFFSET cs, PT_CS-PT_OLDESP;*/\
209 CFI_OFFSET eip, PT_EIP-PT_OLDESP;\
210 /*CFI_OFFSET es, PT_ES-PT_OLDESP;*/\
211 /*CFI_OFFSET ds, PT_DS-PT_OLDESP;*/\
212 CFI_OFFSET eax, PT_EAX-PT_OLDESP;\
213 CFI_OFFSET ebp, PT_EBP-PT_OLDESP;\
214 CFI_OFFSET edi, PT_EDI-PT_OLDESP;\
215 CFI_OFFSET esi, PT_ESI-PT_OLDESP;\
216 CFI_OFFSET edx, PT_EDX-PT_OLDESP;\
217 CFI_OFFSET ecx, PT_ECX-PT_OLDESP;\
218 CFI_OFFSET ebx, PT_EBX-PT_OLDESP
223 CFI_ADJUST_CFA_OFFSET 4
225 GET_THREAD_INFO(%ebp)
227 CFI_ADJUST_CFA_OFFSET -4
228 pushl $0x0202 # Reset kernel eflags
229 CFI_ADJUST_CFA_OFFSET 4
231 CFI_ADJUST_CFA_OFFSET -4
237 * Return to user mode is not as complex as all this looks,
238 * but we want the default path for a system call return to
239 * go as quickly as possible which is why some of this is
240 * less clear than it otherwise should be.
243 # userspace resumption stub bypassing syscall exit tracing
247 preempt_stop(CLBR_ANY)
249 GET_THREAD_INFO(%ebp)
251 movl PT_EFLAGS(%esp), %eax # mix EFLAGS and CS
252 movb PT_CS(%esp), %al
253 andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax
255 jb resume_kernel # not returning to v8086 or userspace
257 ENTRY(resume_userspace)
259 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
260 # setting need_resched or sigpending
261 # between sampling and the iret
263 movl TI_flags(%ebp), %ecx
264 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
265 # int/exception return?
268 END(ret_from_exception)
270 #ifdef CONFIG_PREEMPT
272 DISABLE_INTERRUPTS(CLBR_ANY)
273 cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ?
276 movl TI_flags(%ebp), %ecx # need_resched set ?
277 testb $_TIF_NEED_RESCHED, %cl
279 testl $X86_EFLAGS_IF,PT_EFLAGS(%esp) # interrupts off (exception path) ?
281 call preempt_schedule_irq
287 /* SYSENTER_RETURN points to after the "sysenter" instruction in
288 the vsyscall page. See vsyscall-sysentry.S, which defines the symbol. */
290 # sysenter call handler stub
291 ENTRY(ia32_sysenter_target)
295 CFI_REGISTER esp, ebp
296 movl TSS_sysenter_sp0(%esp),%esp
299 * Interrupts are disabled here, but we can't trace it until
300 * enough kernel state to call TRACE_IRQS_OFF can be called - but
301 * we immediately enable interrupts at that point anyway.
304 CFI_ADJUST_CFA_OFFSET 4
305 /*CFI_REL_OFFSET ss, 0*/
307 CFI_ADJUST_CFA_OFFSET 4
308 CFI_REL_OFFSET esp, 0
310 orl $X86_EFLAGS_IF, (%esp)
311 CFI_ADJUST_CFA_OFFSET 4
313 CFI_ADJUST_CFA_OFFSET 4
314 /*CFI_REL_OFFSET cs, 0*/
316 * Push current_thread_info()->sysenter_return to the stack.
317 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
318 * pushed above; +8 corresponds to copy_thread's esp0 setting.
320 pushl (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
321 CFI_ADJUST_CFA_OFFSET 4
322 CFI_REL_OFFSET eip, 0
325 CFI_ADJUST_CFA_OFFSET 4
327 ENABLE_INTERRUPTS(CLBR_NONE)
330 * Load the potential sixth argument from user stack.
331 * Careful about security.
333 cmpl $__PAGE_OFFSET-3,%ebp
336 movl %ebp,PT_EBP(%esp)
337 .section __ex_table,"a"
339 .long 1b,syscall_fault
342 GET_THREAD_INFO(%ebp)
344 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
345 testw $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
348 cmpl $(nr_syscalls), %eax
350 call *sys_call_table(,%eax,4)
351 movl %eax,PT_EAX(%esp)
353 DISABLE_INTERRUPTS(CLBR_ANY)
355 movl TI_flags(%ebp), %ecx
356 testw $_TIF_ALLWORK_MASK, %cx
359 /* if something modifies registers it must also disable sysexit */
360 movl PT_EIP(%esp), %edx
361 movl PT_OLDESP(%esp), %ecx
364 1: mov PT_FS(%esp), %fs
365 ENABLE_INTERRUPTS_SYSEXIT
367 #ifdef CONFIG_AUDITSYSCALL
369 testw $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
370 jnz syscall_trace_entry
372 CFI_ADJUST_CFA_OFFSET -4
373 /* %esi already in 8(%esp) 6th arg: 4th syscall arg */
374 /* %edx already in 4(%esp) 5th arg: 3rd syscall arg */
375 /* %ecx already in 0(%esp) 4th arg: 2nd syscall arg */
376 movl %ebx,%ecx /* 3rd arg: 1st syscall arg */
377 movl %eax,%edx /* 2nd arg: syscall number */
378 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
379 call audit_syscall_entry
381 CFI_ADJUST_CFA_OFFSET 4
382 movl PT_EAX(%esp),%eax /* reload syscall number */
386 testw $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %cx
387 jne syscall_exit_work
389 ENABLE_INTERRUPTS(CLBR_ANY)
390 movl %eax,%edx /* second arg, syscall return value */
391 cmpl $0,%eax /* is it < 0? */
392 setl %al /* 1 if so, 0 if not */
393 movzbl %al,%eax /* zero-extend that */
394 inc %eax /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */
395 call audit_syscall_exit
396 DISABLE_INTERRUPTS(CLBR_ANY)
398 movl TI_flags(%ebp), %ecx
399 testw $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %cx
400 jne syscall_exit_work
401 movl PT_EAX(%esp),%eax /* reload syscall return value */
406 .pushsection .fixup,"ax"
407 2: movl $0,PT_FS(%esp)
409 .section __ex_table,"a"
413 ENDPROC(ia32_sysenter_target)
415 # system call handler stub
417 RING0_INT_FRAME # can't unwind into user space anyway
418 pushl %eax # save orig_eax
419 CFI_ADJUST_CFA_OFFSET 4
421 GET_THREAD_INFO(%ebp)
422 # system call tracing in operation / emulation
423 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
424 testw $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
425 jnz syscall_trace_entry
426 cmpl $(nr_syscalls), %eax
429 call *sys_call_table(,%eax,4)
430 movl %eax,PT_EAX(%esp) # store the return value
433 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
434 # setting need_resched or sigpending
435 # between sampling and the iret
437 movl TI_flags(%ebp), %ecx
438 testw $_TIF_ALLWORK_MASK, %cx # current->work
439 jne syscall_exit_work
442 movl PT_EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
443 # Warning: PT_OLDSS(%esp) contains the wrong/random values if we
444 # are returning to the kernel.
445 # See comments in process.c:copy_thread() for details.
446 movb PT_OLDSS(%esp), %ah
447 movb PT_CS(%esp), %al
448 andl $(X86_EFLAGS_VM | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax
449 cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax
451 je ldt_ss # returning to user-space with LDT SS
454 restore_nocheck_notrace:
456 addl $4, %esp # skip orig_eax/error_code
457 CFI_ADJUST_CFA_OFFSET -4
462 pushl $0 # no error code
466 .section __ex_table,"a"
468 .long irq_return,iret_exc
473 larl PT_OLDSS(%esp), %eax
475 testl $0x00400000, %eax # returning to 32bit stack?
476 jnz restore_nocheck # allright, normal return
478 #ifdef CONFIG_PARAVIRT
480 * The kernel can't run on a non-flat stack if paravirt mode
481 * is active. Rather than try to fixup the high bits of
482 * ESP, bypass this code entirely. This may break DOSemu
483 * and/or Wine support in a paravirt VM, although the option
484 * is still available to implement the setting of the high
485 * 16-bits in the INTERRUPT_RETURN paravirt-op.
487 cmpl $0, pv_info+PARAVIRT_enabled
491 /* If returning to userspace with 16bit stack,
492 * try to fix the higher word of ESP, as the CPU
494 * This is an "official" bug of all the x86-compatible
495 * CPUs, which we can try to work around to make
496 * dosemu and wine happy. */
497 movl PT_OLDESP(%esp), %eax
499 call patch_espfix_desc
501 CFI_ADJUST_CFA_OFFSET 4
503 CFI_ADJUST_CFA_OFFSET 4
504 DISABLE_INTERRUPTS(CLBR_EAX)
507 CFI_ADJUST_CFA_OFFSET -8
512 # perform work that needs to be done immediately before resumption
514 RING0_PTREGS_FRAME # can't unwind into user space anyway
516 testb $_TIF_NEED_RESCHED, %cl
521 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
522 # setting need_resched or sigpending
523 # between sampling and the iret
525 movl TI_flags(%ebp), %ecx
526 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
527 # than syscall tracing?
529 testb $_TIF_NEED_RESCHED, %cl
532 work_notifysig: # deal with pending signals and
533 # notify-resume requests
535 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
537 jne work_notifysig_v86 # returning to kernel-space or
540 call do_notify_resume
541 jmp resume_userspace_sig
545 pushl %ecx # save ti_flags for do_notify_resume
546 CFI_ADJUST_CFA_OFFSET 4
547 call save_v86_state # %eax contains pt_regs pointer
549 CFI_ADJUST_CFA_OFFSET -4
555 call do_notify_resume
556 jmp resume_userspace_sig
559 # perform syscall exit tracing
562 movl $-ENOSYS,PT_EAX(%esp)
564 call syscall_trace_enter
565 /* What it returned is what we'll actually use. */
566 cmpl $(nr_syscalls), %eax
569 END(syscall_trace_entry)
571 # perform syscall exit tracing
574 testb $_TIF_WORK_SYSCALL_EXIT, %cl
577 ENABLE_INTERRUPTS(CLBR_ANY) # could let syscall_trace_leave() call
580 call syscall_trace_leave
582 END(syscall_exit_work)
585 RING0_INT_FRAME # can't unwind into user space anyway
587 GET_THREAD_INFO(%ebp)
588 movl $-EFAULT,PT_EAX(%esp)
593 movl $-ENOSYS,PT_EAX(%esp)
598 #define FIXUP_ESPFIX_STACK \
599 /* since we are on a wrong stack, we cant make it a C code :( */ \
600 PER_CPU(gdt_page, %ebx); \
601 GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \
603 pushl $__KERNEL_DS; \
604 CFI_ADJUST_CFA_OFFSET 4; \
606 CFI_ADJUST_CFA_OFFSET 4; \
608 CFI_ADJUST_CFA_OFFSET -8;
609 #define UNWIND_ESPFIX_STACK \
611 /* see if on espfix stack */ \
612 cmpw $__ESPFIX_SS, %ax; \
614 movl $__KERNEL_DS, %eax; \
617 /* switch to normal stack */ \
618 FIXUP_ESPFIX_STACK; \
622 * Build the entry stubs and pointer table with
623 * some assembler magic.
629 ENTRY(irq_entries_start)
635 CFI_ADJUST_CFA_OFFSET -4
638 CFI_ADJUST_CFA_OFFSET 4
645 END(irq_entries_start)
652 * the CPU automatically disables interrupts when executing an IRQ vector,
653 * so IRQ-flags tracing has to follow that:
662 ENDPROC(common_interrupt)
665 #define BUILD_INTERRUPT(name, nr) \
669 CFI_ADJUST_CFA_OFFSET 4; \
678 /* The include is where all of the SMP etc. interrupts come from */
679 #include "entry_arch.h"
681 KPROBE_ENTRY(page_fault)
684 CFI_ADJUST_CFA_OFFSET 4
687 /* the function address is in %fs's slot on the stack */
689 CFI_ADJUST_CFA_OFFSET 4
690 /*CFI_REL_OFFSET es, 0*/
692 CFI_ADJUST_CFA_OFFSET 4
693 /*CFI_REL_OFFSET ds, 0*/
695 CFI_ADJUST_CFA_OFFSET 4
696 CFI_REL_OFFSET eax, 0
698 CFI_ADJUST_CFA_OFFSET 4
699 CFI_REL_OFFSET ebp, 0
701 CFI_ADJUST_CFA_OFFSET 4
702 CFI_REL_OFFSET edi, 0
704 CFI_ADJUST_CFA_OFFSET 4
705 CFI_REL_OFFSET esi, 0
707 CFI_ADJUST_CFA_OFFSET 4
708 CFI_REL_OFFSET edx, 0
710 CFI_ADJUST_CFA_OFFSET 4
711 CFI_REL_OFFSET ecx, 0
713 CFI_ADJUST_CFA_OFFSET 4
714 CFI_REL_OFFSET ebx, 0
717 CFI_ADJUST_CFA_OFFSET 4
718 /*CFI_REL_OFFSET fs, 0*/
719 movl $(__KERNEL_PERCPU), %ecx
723 CFI_ADJUST_CFA_OFFSET -4
724 /*CFI_REGISTER es, ecx*/
725 movl PT_FS(%esp), %edi # get the function address
726 movl PT_ORIG_EAX(%esp), %edx # get the error code
727 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
728 mov %ecx, PT_FS(%esp)
729 /*CFI_REL_OFFSET fs, ES*/
730 movl $(__USER_DS), %ecx
734 movl %esp,%eax # pt_regs pointer
736 jmp ret_from_exception
738 KPROBE_END(page_fault)
740 ENTRY(coprocessor_error)
743 CFI_ADJUST_CFA_OFFSET 4
744 pushl $do_coprocessor_error
745 CFI_ADJUST_CFA_OFFSET 4
748 END(coprocessor_error)
750 ENTRY(simd_coprocessor_error)
753 CFI_ADJUST_CFA_OFFSET 4
754 pushl $do_simd_coprocessor_error
755 CFI_ADJUST_CFA_OFFSET 4
758 END(simd_coprocessor_error)
760 ENTRY(device_not_available)
762 pushl $-1 # mark this as an int
763 CFI_ADJUST_CFA_OFFSET 4
764 pushl $do_device_not_available
765 CFI_ADJUST_CFA_OFFSET 4
768 END(device_not_available)
771 * Debug traps and NMI can happen at the one SYSENTER instruction
772 * that sets up the real kernel stack. Check here, since we can't
773 * allow the wrong stack to be used.
775 * "TSS_sysenter_sp0+12" is because the NMI/debug handler will have
776 * already pushed 3 words if it hits on the sysenter instruction:
777 * eflags, cs and eip.
779 * We just load the right stack, and push the three (known) values
780 * by hand onto the new stack - while updating the return eip past
781 * the instruction that would have done it for sysenter.
783 #define FIX_STACK(offset, ok, label) \
784 cmpw $__KERNEL_CS,4(%esp); \
787 movl TSS_sysenter_sp0+offset(%esp),%esp; \
788 CFI_DEF_CFA esp, 0; \
791 CFI_ADJUST_CFA_OFFSET 4; \
792 pushl $__KERNEL_CS; \
793 CFI_ADJUST_CFA_OFFSET 4; \
794 pushl $sysenter_past_esp; \
795 CFI_ADJUST_CFA_OFFSET 4; \
796 CFI_REL_OFFSET eip, 0
800 cmpl $ia32_sysenter_target,(%esp)
801 jne debug_stack_correct
802 FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
804 pushl $-1 # mark this as an int
805 CFI_ADJUST_CFA_OFFSET 4
808 xorl %edx,%edx # error code 0
809 movl %esp,%eax # pt_regs pointer
811 jmp ret_from_exception
816 * NMI is doubly nasty. It can happen _while_ we're handling
817 * a debug fault, and the debug fault hasn't yet been able to
818 * clear up the stack. So we first check whether we got an
819 * NMI on the sysenter entry path, but after that we need to
820 * check whether we got an NMI on the debug path where the debug
821 * fault happened on the sysenter path.
826 CFI_ADJUST_CFA_OFFSET 4
828 cmpw $__ESPFIX_SS, %ax
830 CFI_ADJUST_CFA_OFFSET -4
832 cmpl $ia32_sysenter_target,(%esp)
835 CFI_ADJUST_CFA_OFFSET 4
837 /* Do not access memory above the end of our stack page,
838 * it might not exist.
840 andl $(THREAD_SIZE-1),%eax
841 cmpl $(THREAD_SIZE-20),%eax
843 CFI_ADJUST_CFA_OFFSET -4
844 jae nmi_stack_correct
845 cmpl $ia32_sysenter_target,12(%esp)
846 je nmi_debug_stack_check
848 /* We have a RING0_INT_FRAME here */
850 CFI_ADJUST_CFA_OFFSET 4
853 xorl %edx,%edx # zero error code
854 movl %esp,%eax # pt_regs pointer
856 jmp restore_nocheck_notrace
861 FIX_STACK(12,nmi_stack_correct, 1)
862 jmp nmi_stack_correct
864 nmi_debug_stack_check:
865 /* We have a RING0_INT_FRAME here */
866 cmpw $__KERNEL_CS,16(%esp)
867 jne nmi_stack_correct
870 cmpl $debug_esp_fix_insn,(%esp)
872 FIX_STACK(24,nmi_stack_correct, 1)
873 jmp nmi_stack_correct
876 /* We have a RING0_INT_FRAME here.
878 * create the pointer to lss back
881 CFI_ADJUST_CFA_OFFSET 4
883 CFI_ADJUST_CFA_OFFSET 4
885 /* copy the iret frame of 12 bytes */
888 CFI_ADJUST_CFA_OFFSET 4
891 CFI_ADJUST_CFA_OFFSET 4
894 FIXUP_ESPFIX_STACK # %eax == %esp
895 xorl %edx,%edx # zero error code
898 lss 12+4(%esp), %esp # back to espfix stack
899 CFI_ADJUST_CFA_OFFSET -24
904 #ifdef CONFIG_PARAVIRT
907 .section __ex_table,"a"
909 .long native_iret, iret_exc
913 ENTRY(native_irq_enable_sysexit)
916 END(native_irq_enable_sysexit)
921 pushl $-1 # mark this as an int
922 CFI_ADJUST_CFA_OFFSET 4
925 xorl %edx,%edx # zero error code
926 movl %esp,%eax # pt_regs pointer
928 jmp ret_from_exception
935 CFI_ADJUST_CFA_OFFSET 4
937 CFI_ADJUST_CFA_OFFSET 4
945 CFI_ADJUST_CFA_OFFSET 4
947 CFI_ADJUST_CFA_OFFSET 4
955 CFI_ADJUST_CFA_OFFSET 4
957 CFI_ADJUST_CFA_OFFSET 4
962 ENTRY(coprocessor_segment_overrun)
965 CFI_ADJUST_CFA_OFFSET 4
966 pushl $do_coprocessor_segment_overrun
967 CFI_ADJUST_CFA_OFFSET 4
970 END(coprocessor_segment_overrun)
974 pushl $do_invalid_TSS
975 CFI_ADJUST_CFA_OFFSET 4
980 ENTRY(segment_not_present)
982 pushl $do_segment_not_present
983 CFI_ADJUST_CFA_OFFSET 4
986 END(segment_not_present)
990 pushl $do_stack_segment
991 CFI_ADJUST_CFA_OFFSET 4
996 KPROBE_ENTRY(general_protection)
998 pushl $do_general_protection
999 CFI_ADJUST_CFA_OFFSET 4
1002 KPROBE_END(general_protection)
1004 ENTRY(alignment_check)
1006 pushl $do_alignment_check
1007 CFI_ADJUST_CFA_OFFSET 4
1010 END(alignment_check)
1014 pushl $0 # no error code
1015 CFI_ADJUST_CFA_OFFSET 4
1016 pushl $do_divide_error
1017 CFI_ADJUST_CFA_OFFSET 4
1022 #ifdef CONFIG_X86_MCE
1023 ENTRY(machine_check)
1026 CFI_ADJUST_CFA_OFFSET 4
1027 pushl $do_machine_check
1028 CFI_ADJUST_CFA_OFFSET 4
1034 ENTRY(spurious_interrupt_bug)
1037 CFI_ADJUST_CFA_OFFSET 4
1038 pushl $do_spurious_interrupt_bug
1039 CFI_ADJUST_CFA_OFFSET 4
1042 END(spurious_interrupt_bug)
1044 ENTRY(kernel_thread_helper)
1045 pushl $0 # fake return address for unwinder
1049 CFI_ADJUST_CFA_OFFSET 4
1052 CFI_ADJUST_CFA_OFFSET 4
1055 ENDPROC(kernel_thread_helper)
1058 /* Xen doesn't set %esp to be precisely what the normal sysenter
1059 entrypoint expects, so fix it up before using the normal path. */
1060 ENTRY(xen_sysenter_target)
1062 addl $5*4, %esp /* remove xen-provided frame */
1063 CFI_ADJUST_CFA_OFFSET -5*4
1064 jmp sysenter_past_esp
1067 ENTRY(xen_hypervisor_callback)
1070 CFI_ADJUST_CFA_OFFSET 4
1074 /* Check to see if we got the event in the critical
1075 region in xen_iret_direct, after we've reenabled
1076 events and checked for pending events. This simulates
1077 iret instruction's behaviour where it delivers a
1078 pending interrupt when enabling interrupts. */
1079 movl PT_EIP(%esp),%eax
1080 cmpl $xen_iret_start_crit,%eax
1082 cmpl $xen_iret_end_crit,%eax
1085 jmp xen_iret_crit_fixup
1087 ENTRY(xen_do_upcall)
1089 call xen_evtchn_do_upcall
1092 ENDPROC(xen_hypervisor_callback)
1094 # Hypervisor uses this for application faults while it executes.
1095 # We get here for two reasons:
1096 # 1. Fault while reloading DS, ES, FS or GS
1097 # 2. Fault while executing IRET
1098 # Category 1 we fix up by reattempting the load, and zeroing the segment
1099 # register if the load fails.
1100 # Category 2 we fix up by jumping to do_iret_error. We cannot use the
1101 # normal Linux return path in this case because if we use the IRET hypercall
1102 # to pop the stack frame we end up in an infinite loop of failsafe callbacks.
1103 # We distinguish between categories by maintaining a status value in EAX.
1104 ENTRY(xen_failsafe_callback)
1107 CFI_ADJUST_CFA_OFFSET 4
1115 CFI_ADJUST_CFA_OFFSET -4
1117 CFI_ADJUST_CFA_OFFSET -16
1120 jmp iret_exc # EAX != 0 => Category 2 (Bad IRET)
1121 5: pushl $0 # EAX == 0 => Category 1 (Bad segment)
1122 CFI_ADJUST_CFA_OFFSET 4
1124 jmp ret_from_exception
1127 .section .fixup,"ax"
1141 .section __ex_table,"a"
1148 ENDPROC(xen_failsafe_callback)
1150 #endif /* CONFIG_XEN */
1152 #ifdef CONFIG_FTRACE
1153 #ifdef CONFIG_DYNAMIC_FTRACE
1159 movl 0xc(%esp), %eax
1160 subl $MCOUNT_INSN_SIZE, %eax
1173 ENTRY(ftrace_caller)
1177 movl 0xc(%esp), %eax
1178 movl 0x4(%ebp), %edx
1179 subl $MCOUNT_INSN_SIZE, %eax
1194 #else /* ! CONFIG_DYNAMIC_FTRACE */
1197 cmpl $ftrace_stub, ftrace_trace_function
1203 /* taken from glibc */
1208 movl 0xc(%esp), %eax
1209 movl 0x4(%ebp), %edx
1210 subl $MCOUNT_INSN_SIZE, %eax
1212 call *ftrace_trace_function
1220 #endif /* CONFIG_DYNAMIC_FTRACE */
1221 #endif /* CONFIG_FTRACE */
1223 .section .rodata,"a"
1224 #include "syscall_table_32.S"
1226 syscall_table_size=(.-sys_call_table)