entry_32.S 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189
  1. /*
  2. *
  3. * Copyright (C) 1991, 1992 Linus Torvalds
  4. */
  5. /*
  6. * entry.S contains the system-call and fault low-level handling routines.
  7. * This also contains the timer-interrupt handler, as well as all interrupts
  8. * and faults that can result in a task-switch.
  9. *
  10. * NOTE: This code handles signal-recognition, which happens every time
  11. * after a timer-interrupt and after each system call.
  12. *
  13. * I changed all the .align's to 4 (16 byte alignment), as that's faster
  14. * on a 486.
  15. *
  16. * Stack layout in 'syscall_exit':
  17. * ptrace needs to have all regs on the stack.
  18. * if the order here is changed, it needs to be
  19. * updated in fork.c:copy_process, signal.c:do_signal,
  20. * ptrace.c and ptrace.h
  21. *
  22. * 0(%esp) - %ebx
  23. * 4(%esp) - %ecx
  24. * 8(%esp) - %edx
  25. * C(%esp) - %esi
  26. * 10(%esp) - %edi
  27. * 14(%esp) - %ebp
  28. * 18(%esp) - %eax
  29. * 1C(%esp) - %ds
  30. * 20(%esp) - %es
  31. * 24(%esp) - %fs
  32. * 28(%esp) - orig_eax
  33. * 2C(%esp) - %eip
  34. * 30(%esp) - %cs
  35. * 34(%esp) - %eflags
  36. * 38(%esp) - %oldesp
  37. * 3C(%esp) - %oldss
  38. *
  39. * "current" is in register %ebx during any slow entries.
  40. */
  41. #include <linux/linkage.h>
  42. #include <asm/thread_info.h>
  43. #include <asm/irqflags.h>
  44. #include <asm/errno.h>
  45. #include <asm/segment.h>
  46. #include <asm/smp.h>
  47. #include <asm/page.h>
  48. #include <asm/desc.h>
  49. #include <asm/percpu.h>
  50. #include <asm/dwarf2.h>
  51. #include <asm/processor-flags.h>
  52. #include <asm/ftrace.h>
  53. #include <asm/irq_vectors.h>
  54. /*
  55. * We use macros for low-level operations which need to be overridden
  56. * for paravirtualization. The following will never clobber any registers:
  57. * INTERRUPT_RETURN (aka. "iret")
  58. * GET_CR0_INTO_EAX (aka. "movl %cr0, %eax")
  59. * ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit").
  60. *
  61. * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must
  62. * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY).
  63. * Allowing a register to be clobbered can shrink the paravirt replacement
  64. * enough to patch inline, increasing performance.
  65. */
  66. #define nr_syscalls ((syscall_table_size)/4)
  67. #ifdef CONFIG_PREEMPT
  68. #define preempt_stop(clobbers) DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF
  69. #else
  70. #define preempt_stop(clobbers)
  71. #define resume_kernel restore_nocheck
  72. #endif
  73. .macro TRACE_IRQS_IRET
  74. #ifdef CONFIG_TRACE_IRQFLAGS
  75. testl $X86_EFLAGS_IF,PT_EFLAGS(%esp) # interrupts off?
  76. jz 1f
  77. TRACE_IRQS_ON
  78. 1:
  79. #endif
  80. .endm
  81. #ifdef CONFIG_VM86
  82. #define resume_userspace_sig check_userspace
  83. #else
  84. #define resume_userspace_sig resume_userspace
  85. #endif
  86. #define SAVE_ALL \
  87. cld; \
  88. pushl %fs; \
  89. CFI_ADJUST_CFA_OFFSET 4;\
  90. /*CFI_REL_OFFSET fs, 0;*/\
  91. pushl %es; \
  92. CFI_ADJUST_CFA_OFFSET 4;\
  93. /*CFI_REL_OFFSET es, 0;*/\
  94. pushl %ds; \
  95. CFI_ADJUST_CFA_OFFSET 4;\
  96. /*CFI_REL_OFFSET ds, 0;*/\
  97. pushl %eax; \
  98. CFI_ADJUST_CFA_OFFSET 4;\
  99. CFI_REL_OFFSET eax, 0;\
  100. pushl %ebp; \
  101. CFI_ADJUST_CFA_OFFSET 4;\
  102. CFI_REL_OFFSET ebp, 0;\
  103. pushl %edi; \
  104. CFI_ADJUST_CFA_OFFSET 4;\
  105. CFI_REL_OFFSET edi, 0;\
  106. pushl %esi; \
  107. CFI_ADJUST_CFA_OFFSET 4;\
  108. CFI_REL_OFFSET esi, 0;\
  109. pushl %edx; \
  110. CFI_ADJUST_CFA_OFFSET 4;\
  111. CFI_REL_OFFSET edx, 0;\
  112. pushl %ecx; \
  113. CFI_ADJUST_CFA_OFFSET 4;\
  114. CFI_REL_OFFSET ecx, 0;\
  115. pushl %ebx; \
  116. CFI_ADJUST_CFA_OFFSET 4;\
  117. CFI_REL_OFFSET ebx, 0;\
  118. movl $(__USER_DS), %edx; \
  119. movl %edx, %ds; \
  120. movl %edx, %es; \
  121. movl $(__KERNEL_PERCPU), %edx; \
  122. movl %edx, %fs
  123. #define RESTORE_INT_REGS \
  124. popl %ebx; \
  125. CFI_ADJUST_CFA_OFFSET -4;\
  126. CFI_RESTORE ebx;\
  127. popl %ecx; \
  128. CFI_ADJUST_CFA_OFFSET -4;\
  129. CFI_RESTORE ecx;\
  130. popl %edx; \
  131. CFI_ADJUST_CFA_OFFSET -4;\
  132. CFI_RESTORE edx;\
  133. popl %esi; \
  134. CFI_ADJUST_CFA_OFFSET -4;\
  135. CFI_RESTORE esi;\
  136. popl %edi; \
  137. CFI_ADJUST_CFA_OFFSET -4;\
  138. CFI_RESTORE edi;\
  139. popl %ebp; \
  140. CFI_ADJUST_CFA_OFFSET -4;\
  141. CFI_RESTORE ebp;\
  142. popl %eax; \
  143. CFI_ADJUST_CFA_OFFSET -4;\
  144. CFI_RESTORE eax
  145. #define RESTORE_REGS \
  146. RESTORE_INT_REGS; \
  147. 1: popl %ds; \
  148. CFI_ADJUST_CFA_OFFSET -4;\
  149. /*CFI_RESTORE ds;*/\
  150. 2: popl %es; \
  151. CFI_ADJUST_CFA_OFFSET -4;\
  152. /*CFI_RESTORE es;*/\
  153. 3: popl %fs; \
  154. CFI_ADJUST_CFA_OFFSET -4;\
  155. /*CFI_RESTORE fs;*/\
  156. .pushsection .fixup,"ax"; \
  157. 4: movl $0,(%esp); \
  158. jmp 1b; \
  159. 5: movl $0,(%esp); \
  160. jmp 2b; \
  161. 6: movl $0,(%esp); \
  162. jmp 3b; \
  163. .section __ex_table,"a";\
  164. .align 4; \
  165. .long 1b,4b; \
  166. .long 2b,5b; \
  167. .long 3b,6b; \
  168. .popsection
  169. #define RING0_INT_FRAME \
  170. CFI_STARTPROC simple;\
  171. CFI_SIGNAL_FRAME;\
  172. CFI_DEF_CFA esp, 3*4;\
  173. /*CFI_OFFSET cs, -2*4;*/\
  174. CFI_OFFSET eip, -3*4
  175. #define RING0_EC_FRAME \
  176. CFI_STARTPROC simple;\
  177. CFI_SIGNAL_FRAME;\
  178. CFI_DEF_CFA esp, 4*4;\
  179. /*CFI_OFFSET cs, -2*4;*/\
  180. CFI_OFFSET eip, -3*4
  181. #define RING0_PTREGS_FRAME \
  182. CFI_STARTPROC simple;\
  183. CFI_SIGNAL_FRAME;\
  184. CFI_DEF_CFA esp, PT_OLDESP-PT_EBX;\
  185. /*CFI_OFFSET cs, PT_CS-PT_OLDESP;*/\
  186. CFI_OFFSET eip, PT_EIP-PT_OLDESP;\
  187. /*CFI_OFFSET es, PT_ES-PT_OLDESP;*/\
  188. /*CFI_OFFSET ds, PT_DS-PT_OLDESP;*/\
  189. CFI_OFFSET eax, PT_EAX-PT_OLDESP;\
  190. CFI_OFFSET ebp, PT_EBP-PT_OLDESP;\
  191. CFI_OFFSET edi, PT_EDI-PT_OLDESP;\
  192. CFI_OFFSET esi, PT_ESI-PT_OLDESP;\
  193. CFI_OFFSET edx, PT_EDX-PT_OLDESP;\
  194. CFI_OFFSET ecx, PT_ECX-PT_OLDESP;\
  195. CFI_OFFSET ebx, PT_EBX-PT_OLDESP
  196. ENTRY(ret_from_fork)
  197. CFI_STARTPROC
  198. pushl %eax
  199. CFI_ADJUST_CFA_OFFSET 4
  200. call schedule_tail
  201. GET_THREAD_INFO(%ebp)
  202. popl %eax
  203. CFI_ADJUST_CFA_OFFSET -4
  204. pushl $0x0202 # Reset kernel eflags
  205. CFI_ADJUST_CFA_OFFSET 4
  206. popfl
  207. CFI_ADJUST_CFA_OFFSET -4
  208. jmp syscall_exit
  209. CFI_ENDPROC
  210. END(ret_from_fork)
  211. /*
  212. * Return to user mode is not as complex as all this looks,
  213. * but we want the default path for a system call return to
  214. * go as quickly as possible which is why some of this is
  215. * less clear than it otherwise should be.
  216. */
  217. # userspace resumption stub bypassing syscall exit tracing
  218. ALIGN
  219. RING0_PTREGS_FRAME
  220. ret_from_exception:
  221. preempt_stop(CLBR_ANY)
  222. ret_from_intr:
  223. GET_THREAD_INFO(%ebp)
  224. check_userspace:
  225. movl PT_EFLAGS(%esp), %eax # mix EFLAGS and CS
  226. movb PT_CS(%esp), %al
  227. andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax
  228. cmpl $USER_RPL, %eax
  229. jb resume_kernel # not returning to v8086 or userspace
  230. ENTRY(resume_userspace)
  231. LOCKDEP_SYS_EXIT
  232. DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
  233. # setting need_resched or sigpending
  234. # between sampling and the iret
  235. TRACE_IRQS_OFF
  236. movl TI_flags(%ebp), %ecx
  237. andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
  238. # int/exception return?
  239. jne work_pending
  240. jmp restore_all
  241. END(ret_from_exception)
  242. #ifdef CONFIG_PREEMPT
  243. ENTRY(resume_kernel)
  244. DISABLE_INTERRUPTS(CLBR_ANY)
  245. cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ?
  246. jnz restore_nocheck
  247. need_resched:
  248. movl TI_flags(%ebp), %ecx # need_resched set ?
  249. testb $_TIF_NEED_RESCHED, %cl
  250. jz restore_all
  251. testl $X86_EFLAGS_IF,PT_EFLAGS(%esp) # interrupts off (exception path) ?
  252. jz restore_all
  253. call preempt_schedule_irq
  254. jmp need_resched
  255. END(resume_kernel)
  256. #endif
  257. CFI_ENDPROC
  258. /* SYSENTER_RETURN points to after the "sysenter" instruction in
  259. the vsyscall page. See vsyscall-sysentry.S, which defines the symbol. */
  260. # sysenter call handler stub
  261. ENTRY(ia32_sysenter_target)
  262. CFI_STARTPROC simple
  263. CFI_SIGNAL_FRAME
  264. CFI_DEF_CFA esp, 0
  265. CFI_REGISTER esp, ebp
  266. movl TSS_sysenter_sp0(%esp),%esp
  267. sysenter_past_esp:
  268. /*
  269. * Interrupts are disabled here, but we can't trace it until
  270. * enough kernel state to call TRACE_IRQS_OFF can be called - but
  271. * we immediately enable interrupts at that point anyway.
  272. */
  273. pushl $(__USER_DS)
  274. CFI_ADJUST_CFA_OFFSET 4
  275. /*CFI_REL_OFFSET ss, 0*/
  276. pushl %ebp
  277. CFI_ADJUST_CFA_OFFSET 4
  278. CFI_REL_OFFSET esp, 0
  279. pushfl
  280. orl $X86_EFLAGS_IF, (%esp)
  281. CFI_ADJUST_CFA_OFFSET 4
  282. pushl $(__USER_CS)
  283. CFI_ADJUST_CFA_OFFSET 4
  284. /*CFI_REL_OFFSET cs, 0*/
  285. /*
  286. * Push current_thread_info()->sysenter_return to the stack.
  287. * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
  288. * pushed above; +8 corresponds to copy_thread's esp0 setting.
  289. */
  290. pushl (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
  291. CFI_ADJUST_CFA_OFFSET 4
  292. CFI_REL_OFFSET eip, 0
  293. pushl %eax
  294. CFI_ADJUST_CFA_OFFSET 4
  295. SAVE_ALL
  296. ENABLE_INTERRUPTS(CLBR_NONE)
  297. /*
  298. * Load the potential sixth argument from user stack.
  299. * Careful about security.
  300. */
  301. cmpl $__PAGE_OFFSET-3,%ebp
  302. jae syscall_fault
  303. 1: movl (%ebp),%ebp
  304. movl %ebp,PT_EBP(%esp)
  305. .section __ex_table,"a"
  306. .align 4
  307. .long 1b,syscall_fault
  308. .previous
  309. GET_THREAD_INFO(%ebp)
  310. /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
  311. testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
  312. jnz syscall_trace_entry
  313. cmpl $(nr_syscalls), %eax
  314. jae syscall_badsys
  315. call *sys_call_table(,%eax,4)
  316. movl %eax,PT_EAX(%esp)
  317. LOCKDEP_SYS_EXIT
  318. DISABLE_INTERRUPTS(CLBR_ANY)
  319. TRACE_IRQS_OFF
  320. movl TI_flags(%ebp), %ecx
  321. testw $_TIF_ALLWORK_MASK, %cx
  322. jne syscall_exit_work
  323. /* if something modifies registers it must also disable sysexit */
  324. movl PT_EIP(%esp), %edx
  325. movl PT_OLDESP(%esp), %ecx
  326. xorl %ebp,%ebp
  327. TRACE_IRQS_ON
  328. 1: mov PT_FS(%esp), %fs
  329. ENABLE_INTERRUPTS_SYSEXIT
  330. CFI_ENDPROC
  331. .pushsection .fixup,"ax"
  332. 2: movl $0,PT_FS(%esp)
  333. jmp 1b
  334. .section __ex_table,"a"
  335. .align 4
  336. .long 1b,2b
  337. .popsection
  338. ENDPROC(ia32_sysenter_target)
  339. # system call handler stub
  340. ENTRY(system_call)
  341. RING0_INT_FRAME # can't unwind into user space anyway
  342. pushl %eax # save orig_eax
  343. CFI_ADJUST_CFA_OFFSET 4
  344. SAVE_ALL
  345. GET_THREAD_INFO(%ebp)
  346. # system call tracing in operation / emulation
  347. /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
  348. testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
  349. jnz syscall_trace_entry
  350. cmpl $(nr_syscalls), %eax
  351. jae syscall_badsys
  352. syscall_call:
  353. call *sys_call_table(,%eax,4)
  354. movl %eax,PT_EAX(%esp) # store the return value
  355. syscall_exit:
  356. LOCKDEP_SYS_EXIT
  357. DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
  358. # setting need_resched or sigpending
  359. # between sampling and the iret
  360. TRACE_IRQS_OFF
  361. testl $X86_EFLAGS_TF,PT_EFLAGS(%esp) # If tracing set singlestep flag on exit
  362. jz no_singlestep
  363. orl $_TIF_SINGLESTEP,TI_flags(%ebp)
  364. no_singlestep:
  365. movl TI_flags(%ebp), %ecx
  366. testw $_TIF_ALLWORK_MASK, %cx # current->work
  367. jne syscall_exit_work
  368. restore_all:
  369. movl PT_EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
  370. # Warning: PT_OLDSS(%esp) contains the wrong/random values if we
  371. # are returning to the kernel.
  372. # See comments in process.c:copy_thread() for details.
  373. movb PT_OLDSS(%esp), %ah
  374. movb PT_CS(%esp), %al
  375. andl $(X86_EFLAGS_VM | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax
  376. cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax
  377. CFI_REMEMBER_STATE
  378. je ldt_ss # returning to user-space with LDT SS
  379. restore_nocheck:
  380. TRACE_IRQS_IRET
  381. restore_nocheck_notrace:
  382. RESTORE_REGS
  383. addl $4, %esp # skip orig_eax/error_code
  384. CFI_ADJUST_CFA_OFFSET -4
  385. irq_return:
  386. INTERRUPT_RETURN
  387. .section .fixup,"ax"
  388. ENTRY(iret_exc)
  389. pushl $0 # no error code
  390. pushl $do_iret_error
  391. jmp error_code
  392. .previous
  393. .section __ex_table,"a"
  394. .align 4
  395. .long irq_return,iret_exc
  396. .previous
  397. CFI_RESTORE_STATE
  398. ldt_ss:
  399. larl PT_OLDSS(%esp), %eax
  400. jnz restore_nocheck
  401. testl $0x00400000, %eax # returning to 32bit stack?
  402. jnz restore_nocheck # allright, normal return
  403. #ifdef CONFIG_PARAVIRT
  404. /*
  405. * The kernel can't run on a non-flat stack if paravirt mode
  406. * is active. Rather than try to fixup the high bits of
  407. * ESP, bypass this code entirely. This may break DOSemu
  408. * and/or Wine support in a paravirt VM, although the option
  409. * is still available to implement the setting of the high
  410. * 16-bits in the INTERRUPT_RETURN paravirt-op.
  411. */
  412. cmpl $0, pv_info+PARAVIRT_enabled
  413. jne restore_nocheck
  414. #endif
  415. /* If returning to userspace with 16bit stack,
  416. * try to fix the higher word of ESP, as the CPU
  417. * won't restore it.
  418. * This is an "official" bug of all the x86-compatible
  419. * CPUs, which we can try to work around to make
  420. * dosemu and wine happy. */
  421. movl PT_OLDESP(%esp), %eax
  422. movl %esp, %edx
  423. call patch_espfix_desc
  424. pushl $__ESPFIX_SS
  425. CFI_ADJUST_CFA_OFFSET 4
  426. pushl %eax
  427. CFI_ADJUST_CFA_OFFSET 4
  428. DISABLE_INTERRUPTS(CLBR_EAX)
  429. TRACE_IRQS_OFF
  430. lss (%esp), %esp
  431. CFI_ADJUST_CFA_OFFSET -8
  432. jmp restore_nocheck
  433. CFI_ENDPROC
  434. ENDPROC(system_call)
  435. # perform work that needs to be done immediately before resumption
  436. ALIGN
  437. RING0_PTREGS_FRAME # can't unwind into user space anyway
  438. work_pending:
  439. testb $_TIF_NEED_RESCHED, %cl
  440. jz work_notifysig
  441. work_resched:
  442. call schedule
  443. LOCKDEP_SYS_EXIT
  444. DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
  445. # setting need_resched or sigpending
  446. # between sampling and the iret
  447. TRACE_IRQS_OFF
  448. movl TI_flags(%ebp), %ecx
  449. andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
  450. # than syscall tracing?
  451. jz restore_all
  452. testb $_TIF_NEED_RESCHED, %cl
  453. jnz work_resched
  454. work_notifysig: # deal with pending signals and
  455. # notify-resume requests
  456. #ifdef CONFIG_VM86
  457. testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
  458. movl %esp, %eax
  459. jne work_notifysig_v86 # returning to kernel-space or
  460. # vm86-space
  461. xorl %edx, %edx
  462. call do_notify_resume
  463. jmp resume_userspace_sig
  464. ALIGN
  465. work_notifysig_v86:
  466. pushl %ecx # save ti_flags for do_notify_resume
  467. CFI_ADJUST_CFA_OFFSET 4
  468. call save_v86_state # %eax contains pt_regs pointer
  469. popl %ecx
  470. CFI_ADJUST_CFA_OFFSET -4
  471. movl %eax, %esp
  472. #else
  473. movl %esp, %eax
  474. #endif
  475. xorl %edx, %edx
  476. call do_notify_resume
  477. jmp resume_userspace_sig
  478. END(work_pending)
  479. # perform syscall exit tracing
  480. ALIGN
  481. syscall_trace_entry:
  482. movl $-ENOSYS,PT_EAX(%esp)
  483. movl %esp, %eax
  484. xorl %edx,%edx
  485. call do_syscall_trace
  486. cmpl $0, %eax
  487. jne resume_userspace # ret != 0 -> running under PTRACE_SYSEMU,
  488. # so must skip actual syscall
  489. movl PT_ORIG_EAX(%esp), %eax
  490. cmpl $(nr_syscalls), %eax
  491. jnae syscall_call
  492. jmp syscall_exit
  493. END(syscall_trace_entry)
  494. # perform syscall exit tracing
  495. ALIGN
  496. syscall_exit_work:
  497. testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
  498. jz work_pending
  499. TRACE_IRQS_ON
  500. ENABLE_INTERRUPTS(CLBR_ANY) # could let do_syscall_trace() call
  501. # schedule() instead
  502. movl %esp, %eax
  503. movl $1, %edx
  504. call do_syscall_trace
  505. jmp resume_userspace
  506. END(syscall_exit_work)
  507. CFI_ENDPROC
  508. RING0_INT_FRAME # can't unwind into user space anyway
  509. syscall_fault:
  510. GET_THREAD_INFO(%ebp)
  511. movl $-EFAULT,PT_EAX(%esp)
  512. jmp resume_userspace
  513. END(syscall_fault)
  514. syscall_badsys:
  515. movl $-ENOSYS,PT_EAX(%esp)
  516. jmp resume_userspace
  517. END(syscall_badsys)
  518. CFI_ENDPROC
  519. #define FIXUP_ESPFIX_STACK \
  520. /* since we are on a wrong stack, we cant make it a C code :( */ \
  521. PER_CPU(gdt_page, %ebx); \
  522. GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \
  523. addl %esp, %eax; \
  524. pushl $__KERNEL_DS; \
  525. CFI_ADJUST_CFA_OFFSET 4; \
  526. pushl %eax; \
  527. CFI_ADJUST_CFA_OFFSET 4; \
  528. lss (%esp), %esp; \
  529. CFI_ADJUST_CFA_OFFSET -8;
  530. #define UNWIND_ESPFIX_STACK \
  531. movl %ss, %eax; \
  532. /* see if on espfix stack */ \
  533. cmpw $__ESPFIX_SS, %ax; \
  534. jne 27f; \
  535. movl $__KERNEL_DS, %eax; \
  536. movl %eax, %ds; \
  537. movl %eax, %es; \
  538. /* switch to normal stack */ \
  539. FIXUP_ESPFIX_STACK; \
  540. 27:;
  541. /*
  542. * Build the entry stubs and pointer table with
  543. * some assembler magic.
  544. */
  545. .section .rodata,"a"
  546. ENTRY(interrupt)
  547. .text
  548. ENTRY(irq_entries_start)
  549. RING0_INT_FRAME
  550. vector=0
  551. .rept NR_IRQS
  552. ALIGN
  553. .if vector
  554. CFI_ADJUST_CFA_OFFSET -4
  555. .endif
  556. 1: pushl $~(vector)
  557. CFI_ADJUST_CFA_OFFSET 4
  558. jmp common_interrupt
  559. .previous
  560. .long 1b
  561. .text
  562. vector=vector+1
  563. .endr
  564. END(irq_entries_start)
  565. .previous
  566. END(interrupt)
  567. .previous
  568. /*
  569. * the CPU automatically disables interrupts when executing an IRQ vector,
  570. * so IRQ-flags tracing has to follow that:
  571. */
  572. ALIGN
  573. common_interrupt:
  574. SAVE_ALL
  575. TRACE_IRQS_OFF
  576. movl %esp,%eax
  577. call do_IRQ
  578. jmp ret_from_intr
  579. ENDPROC(common_interrupt)
  580. CFI_ENDPROC
  581. #define BUILD_INTERRUPT(name, nr) \
  582. ENTRY(name) \
  583. RING0_INT_FRAME; \
  584. pushl $~(nr); \
  585. CFI_ADJUST_CFA_OFFSET 4; \
  586. SAVE_ALL; \
  587. TRACE_IRQS_OFF \
  588. movl %esp,%eax; \
  589. call smp_##name; \
  590. jmp ret_from_intr; \
  591. CFI_ENDPROC; \
  592. ENDPROC(name)
  593. /* The include is where all of the SMP etc. interrupts come from */
  594. #include "entry_arch.h"
  595. KPROBE_ENTRY(page_fault)
  596. RING0_EC_FRAME
  597. pushl $do_page_fault
  598. CFI_ADJUST_CFA_OFFSET 4
  599. ALIGN
  600. error_code:
  601. /* the function address is in %fs's slot on the stack */
  602. pushl %es
  603. CFI_ADJUST_CFA_OFFSET 4
  604. /*CFI_REL_OFFSET es, 0*/
  605. pushl %ds
  606. CFI_ADJUST_CFA_OFFSET 4
  607. /*CFI_REL_OFFSET ds, 0*/
  608. pushl %eax
  609. CFI_ADJUST_CFA_OFFSET 4
  610. CFI_REL_OFFSET eax, 0
  611. pushl %ebp
  612. CFI_ADJUST_CFA_OFFSET 4
  613. CFI_REL_OFFSET ebp, 0
  614. pushl %edi
  615. CFI_ADJUST_CFA_OFFSET 4
  616. CFI_REL_OFFSET edi, 0
  617. pushl %esi
  618. CFI_ADJUST_CFA_OFFSET 4
  619. CFI_REL_OFFSET esi, 0
  620. pushl %edx
  621. CFI_ADJUST_CFA_OFFSET 4
  622. CFI_REL_OFFSET edx, 0
  623. pushl %ecx
  624. CFI_ADJUST_CFA_OFFSET 4
  625. CFI_REL_OFFSET ecx, 0
  626. pushl %ebx
  627. CFI_ADJUST_CFA_OFFSET 4
  628. CFI_REL_OFFSET ebx, 0
  629. cld
  630. pushl %fs
  631. CFI_ADJUST_CFA_OFFSET 4
  632. /*CFI_REL_OFFSET fs, 0*/
  633. movl $(__KERNEL_PERCPU), %ecx
  634. movl %ecx, %fs
  635. UNWIND_ESPFIX_STACK
  636. popl %ecx
  637. CFI_ADJUST_CFA_OFFSET -4
  638. /*CFI_REGISTER es, ecx*/
  639. movl PT_FS(%esp), %edi # get the function address
  640. movl PT_ORIG_EAX(%esp), %edx # get the error code
  641. movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
  642. mov %ecx, PT_FS(%esp)
  643. /*CFI_REL_OFFSET fs, ES*/
  644. movl $(__USER_DS), %ecx
  645. movl %ecx, %ds
  646. movl %ecx, %es
  647. movl %esp,%eax # pt_regs pointer
  648. call *%edi
  649. jmp ret_from_exception
  650. CFI_ENDPROC
  651. KPROBE_END(page_fault)
  652. ENTRY(coprocessor_error)
  653. RING0_INT_FRAME
  654. pushl $0
  655. CFI_ADJUST_CFA_OFFSET 4
  656. pushl $do_coprocessor_error
  657. CFI_ADJUST_CFA_OFFSET 4
  658. jmp error_code
  659. CFI_ENDPROC
  660. END(coprocessor_error)
  661. ENTRY(simd_coprocessor_error)
  662. RING0_INT_FRAME
  663. pushl $0
  664. CFI_ADJUST_CFA_OFFSET 4
  665. pushl $do_simd_coprocessor_error
  666. CFI_ADJUST_CFA_OFFSET 4
  667. jmp error_code
  668. CFI_ENDPROC
  669. END(simd_coprocessor_error)
  670. ENTRY(device_not_available)
  671. RING0_INT_FRAME
  672. pushl $-1 # mark this as an int
  673. CFI_ADJUST_CFA_OFFSET 4
  674. SAVE_ALL
  675. GET_CR0_INTO_EAX
  676. testl $0x4, %eax # EM (math emulation bit)
  677. jne device_not_available_emulate
  678. preempt_stop(CLBR_ANY)
  679. call math_state_restore
  680. jmp ret_from_exception
  681. device_not_available_emulate:
  682. pushl $0 # temporary storage for ORIG_EIP
  683. CFI_ADJUST_CFA_OFFSET 4
  684. call math_emulate
  685. addl $4, %esp
  686. CFI_ADJUST_CFA_OFFSET -4
  687. jmp ret_from_exception
  688. CFI_ENDPROC
  689. END(device_not_available)
  690. /*
  691. * Debug traps and NMI can happen at the one SYSENTER instruction
  692. * that sets up the real kernel stack. Check here, since we can't
  693. * allow the wrong stack to be used.
  694. *
  695. * "TSS_sysenter_sp0+12" is because the NMI/debug handler will have
  696. * already pushed 3 words if it hits on the sysenter instruction:
  697. * eflags, cs and eip.
  698. *
  699. * We just load the right stack, and push the three (known) values
  700. * by hand onto the new stack - while updating the return eip past
  701. * the instruction that would have done it for sysenter.
  702. */
  703. #define FIX_STACK(offset, ok, label) \
  704. cmpw $__KERNEL_CS,4(%esp); \
  705. jne ok; \
  706. label: \
  707. movl TSS_sysenter_sp0+offset(%esp),%esp; \
  708. CFI_DEF_CFA esp, 0; \
  709. CFI_UNDEFINED eip; \
  710. pushfl; \
  711. CFI_ADJUST_CFA_OFFSET 4; \
  712. pushl $__KERNEL_CS; \
  713. CFI_ADJUST_CFA_OFFSET 4; \
  714. pushl $sysenter_past_esp; \
  715. CFI_ADJUST_CFA_OFFSET 4; \
  716. CFI_REL_OFFSET eip, 0
  717. KPROBE_ENTRY(debug)
  718. RING0_INT_FRAME
  719. cmpl $ia32_sysenter_target,(%esp)
  720. jne debug_stack_correct
  721. FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
  722. debug_stack_correct:
  723. pushl $-1 # mark this as an int
  724. CFI_ADJUST_CFA_OFFSET 4
  725. SAVE_ALL
  726. xorl %edx,%edx # error code 0
  727. movl %esp,%eax # pt_regs pointer
  728. call do_debug
  729. jmp ret_from_exception
  730. CFI_ENDPROC
  731. KPROBE_END(debug)
  732. /*
  733. * NMI is doubly nasty. It can happen _while_ we're handling
  734. * a debug fault, and the debug fault hasn't yet been able to
  735. * clear up the stack. So we first check whether we got an
  736. * NMI on the sysenter entry path, but after that we need to
  737. * check whether we got an NMI on the debug path where the debug
  738. * fault happened on the sysenter path.
  739. */
  740. KPROBE_ENTRY(nmi)
  741. RING0_INT_FRAME
  742. pushl %eax
  743. CFI_ADJUST_CFA_OFFSET 4
  744. movl %ss, %eax
  745. cmpw $__ESPFIX_SS, %ax
  746. popl %eax
  747. CFI_ADJUST_CFA_OFFSET -4
  748. je nmi_espfix_stack
  749. cmpl $ia32_sysenter_target,(%esp)
  750. je nmi_stack_fixup
  751. pushl %eax
  752. CFI_ADJUST_CFA_OFFSET 4
  753. movl %esp,%eax
  754. /* Do not access memory above the end of our stack page,
  755. * it might not exist.
  756. */
  757. andl $(THREAD_SIZE-1),%eax
  758. cmpl $(THREAD_SIZE-20),%eax
  759. popl %eax
  760. CFI_ADJUST_CFA_OFFSET -4
  761. jae nmi_stack_correct
  762. cmpl $ia32_sysenter_target,12(%esp)
  763. je nmi_debug_stack_check
  764. nmi_stack_correct:
  765. /* We have a RING0_INT_FRAME here */
  766. pushl %eax
  767. CFI_ADJUST_CFA_OFFSET 4
  768. SAVE_ALL
  769. xorl %edx,%edx # zero error code
  770. movl %esp,%eax # pt_regs pointer
  771. call do_nmi
  772. jmp restore_nocheck_notrace
  773. CFI_ENDPROC
  774. nmi_stack_fixup:
  775. RING0_INT_FRAME
  776. FIX_STACK(12,nmi_stack_correct, 1)
  777. jmp nmi_stack_correct
  778. nmi_debug_stack_check:
  779. /* We have a RING0_INT_FRAME here */
  780. cmpw $__KERNEL_CS,16(%esp)
  781. jne nmi_stack_correct
  782. cmpl $debug,(%esp)
  783. jb nmi_stack_correct
  784. cmpl $debug_esp_fix_insn,(%esp)
  785. ja nmi_stack_correct
  786. FIX_STACK(24,nmi_stack_correct, 1)
  787. jmp nmi_stack_correct
  788. nmi_espfix_stack:
  789. /* We have a RING0_INT_FRAME here.
  790. *
  791. * create the pointer to lss back
  792. */
  793. pushl %ss
  794. CFI_ADJUST_CFA_OFFSET 4
  795. pushl %esp
  796. CFI_ADJUST_CFA_OFFSET 4
  797. addw $4, (%esp)
  798. /* copy the iret frame of 12 bytes */
  799. .rept 3
  800. pushl 16(%esp)
  801. CFI_ADJUST_CFA_OFFSET 4
  802. .endr
  803. pushl %eax
  804. CFI_ADJUST_CFA_OFFSET 4
  805. SAVE_ALL
  806. FIXUP_ESPFIX_STACK # %eax == %esp
  807. xorl %edx,%edx # zero error code
  808. call do_nmi
  809. RESTORE_REGS
  810. lss 12+4(%esp), %esp # back to espfix stack
  811. CFI_ADJUST_CFA_OFFSET -24
  812. jmp irq_return
  813. CFI_ENDPROC
  814. KPROBE_END(nmi)
  815. #ifdef CONFIG_PARAVIRT
  816. ENTRY(native_iret)
  817. iret
  818. .section __ex_table,"a"
  819. .align 4
  820. .long native_iret, iret_exc
  821. .previous
  822. END(native_iret)
  823. ENTRY(native_irq_enable_sysexit)
  824. sti
  825. sysexit
  826. END(native_irq_enable_sysexit)
  827. #endif
  828. KPROBE_ENTRY(int3)
  829. RING0_INT_FRAME
  830. pushl $-1 # mark this as an int
  831. CFI_ADJUST_CFA_OFFSET 4
  832. SAVE_ALL
  833. xorl %edx,%edx # zero error code
  834. movl %esp,%eax # pt_regs pointer
  835. call do_int3
  836. jmp ret_from_exception
  837. CFI_ENDPROC
  838. KPROBE_END(int3)
  839. ENTRY(overflow)
  840. RING0_INT_FRAME
  841. pushl $0
  842. CFI_ADJUST_CFA_OFFSET 4
  843. pushl $do_overflow
  844. CFI_ADJUST_CFA_OFFSET 4
  845. jmp error_code
  846. CFI_ENDPROC
  847. END(overflow)
  848. ENTRY(bounds)
  849. RING0_INT_FRAME
  850. pushl $0
  851. CFI_ADJUST_CFA_OFFSET 4
  852. pushl $do_bounds
  853. CFI_ADJUST_CFA_OFFSET 4
  854. jmp error_code
  855. CFI_ENDPROC
  856. END(bounds)
  857. ENTRY(invalid_op)
  858. RING0_INT_FRAME
  859. pushl $0
  860. CFI_ADJUST_CFA_OFFSET 4
  861. pushl $do_invalid_op
  862. CFI_ADJUST_CFA_OFFSET 4
  863. jmp error_code
  864. CFI_ENDPROC
  865. END(invalid_op)
  866. ENTRY(coprocessor_segment_overrun)
  867. RING0_INT_FRAME
  868. pushl $0
  869. CFI_ADJUST_CFA_OFFSET 4
  870. pushl $do_coprocessor_segment_overrun
  871. CFI_ADJUST_CFA_OFFSET 4
  872. jmp error_code
  873. CFI_ENDPROC
  874. END(coprocessor_segment_overrun)
  875. ENTRY(invalid_TSS)
  876. RING0_EC_FRAME
  877. pushl $do_invalid_TSS
  878. CFI_ADJUST_CFA_OFFSET 4
  879. jmp error_code
  880. CFI_ENDPROC
  881. END(invalid_TSS)
  882. ENTRY(segment_not_present)
  883. RING0_EC_FRAME
  884. pushl $do_segment_not_present
  885. CFI_ADJUST_CFA_OFFSET 4
  886. jmp error_code
  887. CFI_ENDPROC
  888. END(segment_not_present)
  889. ENTRY(stack_segment)
  890. RING0_EC_FRAME
  891. pushl $do_stack_segment
  892. CFI_ADJUST_CFA_OFFSET 4
  893. jmp error_code
  894. CFI_ENDPROC
  895. END(stack_segment)
  896. KPROBE_ENTRY(general_protection)
  897. RING0_EC_FRAME
  898. pushl $do_general_protection
  899. CFI_ADJUST_CFA_OFFSET 4
  900. jmp error_code
  901. CFI_ENDPROC
  902. KPROBE_END(general_protection)
  903. ENTRY(alignment_check)
  904. RING0_EC_FRAME
  905. pushl $do_alignment_check
  906. CFI_ADJUST_CFA_OFFSET 4
  907. jmp error_code
  908. CFI_ENDPROC
  909. END(alignment_check)
  910. ENTRY(divide_error)
  911. RING0_INT_FRAME
  912. pushl $0 # no error code
  913. CFI_ADJUST_CFA_OFFSET 4
  914. pushl $do_divide_error
  915. CFI_ADJUST_CFA_OFFSET 4
  916. jmp error_code
  917. CFI_ENDPROC
  918. END(divide_error)
  919. #ifdef CONFIG_X86_MCE
  920. ENTRY(machine_check)
  921. RING0_INT_FRAME
  922. pushl $0
  923. CFI_ADJUST_CFA_OFFSET 4
  924. pushl machine_check_vector
  925. CFI_ADJUST_CFA_OFFSET 4
  926. jmp error_code
  927. CFI_ENDPROC
  928. END(machine_check)
  929. #endif
  930. ENTRY(spurious_interrupt_bug)
  931. RING0_INT_FRAME
  932. pushl $0
  933. CFI_ADJUST_CFA_OFFSET 4
  934. pushl $do_spurious_interrupt_bug
  935. CFI_ADJUST_CFA_OFFSET 4
  936. jmp error_code
  937. CFI_ENDPROC
  938. END(spurious_interrupt_bug)
  939. ENTRY(kernel_thread_helper)
  940. pushl $0 # fake return address for unwinder
  941. CFI_STARTPROC
  942. movl %edx,%eax
  943. push %edx
  944. CFI_ADJUST_CFA_OFFSET 4
  945. call *%ebx
  946. push %eax
  947. CFI_ADJUST_CFA_OFFSET 4
  948. call do_exit
  949. CFI_ENDPROC
  950. ENDPROC(kernel_thread_helper)
  951. #ifdef CONFIG_XEN
  952. /* Xen doesn't set %esp to be precisely what the normal sysenter
  953. entrypoint expects, so fix it up before using the normal path. */
  954. ENTRY(xen_sysenter_target)
  955. RING0_INT_FRAME
  956. addl $5*4, %esp /* remove xen-provided frame */
  957. jmp sysenter_past_esp
  958. CFI_ENDPROC
  959. ENTRY(xen_hypervisor_callback)
  960. CFI_STARTPROC
  961. pushl $0
  962. CFI_ADJUST_CFA_OFFSET 4
  963. SAVE_ALL
  964. TRACE_IRQS_OFF
  965. /* Check to see if we got the event in the critical
  966. region in xen_iret_direct, after we've reenabled
  967. events and checked for pending events. This simulates
  968. iret instruction's behaviour where it delivers a
  969. pending interrupt when enabling interrupts. */
  970. movl PT_EIP(%esp),%eax
  971. cmpl $xen_iret_start_crit,%eax
  972. jb 1f
  973. cmpl $xen_iret_end_crit,%eax
  974. jae 1f
  975. jmp xen_iret_crit_fixup
  976. ENTRY(xen_do_upcall)
  977. 1: mov %esp, %eax
  978. call xen_evtchn_do_upcall
  979. jmp ret_from_intr
  980. CFI_ENDPROC
  981. ENDPROC(xen_hypervisor_callback)
  982. # Hypervisor uses this for application faults while it executes.
  983. # We get here for two reasons:
  984. # 1. Fault while reloading DS, ES, FS or GS
  985. # 2. Fault while executing IRET
  986. # Category 1 we fix up by reattempting the load, and zeroing the segment
  987. # register if the load fails.
  988. # Category 2 we fix up by jumping to do_iret_error. We cannot use the
  989. # normal Linux return path in this case because if we use the IRET hypercall
  990. # to pop the stack frame we end up in an infinite loop of failsafe callbacks.
  991. # We distinguish between categories by maintaining a status value in EAX.
  992. ENTRY(xen_failsafe_callback)
  993. CFI_STARTPROC
  994. pushl %eax
  995. CFI_ADJUST_CFA_OFFSET 4
  996. movl $1,%eax
  997. 1: mov 4(%esp),%ds
  998. 2: mov 8(%esp),%es
  999. 3: mov 12(%esp),%fs
  1000. 4: mov 16(%esp),%gs
  1001. testl %eax,%eax
  1002. popl %eax
  1003. CFI_ADJUST_CFA_OFFSET -4
  1004. lea 16(%esp),%esp
  1005. CFI_ADJUST_CFA_OFFSET -16
  1006. jz 5f
  1007. addl $16,%esp
  1008. jmp iret_exc # EAX != 0 => Category 2 (Bad IRET)
  1009. 5: pushl $0 # EAX == 0 => Category 1 (Bad segment)
  1010. CFI_ADJUST_CFA_OFFSET 4
  1011. SAVE_ALL
  1012. jmp ret_from_exception
  1013. CFI_ENDPROC
  1014. .section .fixup,"ax"
  1015. 6: xorl %eax,%eax
  1016. movl %eax,4(%esp)
  1017. jmp 1b
  1018. 7: xorl %eax,%eax
  1019. movl %eax,8(%esp)
  1020. jmp 2b
  1021. 8: xorl %eax,%eax
  1022. movl %eax,12(%esp)
  1023. jmp 3b
  1024. 9: xorl %eax,%eax
  1025. movl %eax,16(%esp)
  1026. jmp 4b
  1027. .previous
  1028. .section __ex_table,"a"
  1029. .align 4
  1030. .long 1b,6b
  1031. .long 2b,7b
  1032. .long 3b,8b
  1033. .long 4b,9b
  1034. .previous
  1035. ENDPROC(xen_failsafe_callback)
  1036. #endif /* CONFIG_XEN */
  1037. #ifdef CONFIG_FTRACE
  1038. #ifdef CONFIG_DYNAMIC_FTRACE
  1039. ENTRY(mcount)
  1040. pushl %eax
  1041. pushl %ecx
  1042. pushl %edx
  1043. movl 0xc(%esp), %eax
  1044. subl $MCOUNT_INSN_SIZE, %eax
  1045. .globl mcount_call
  1046. mcount_call:
  1047. call ftrace_stub
  1048. popl %edx
  1049. popl %ecx
  1050. popl %eax
  1051. ret
  1052. END(mcount)
  1053. ENTRY(ftrace_caller)
  1054. pushl %eax
  1055. pushl %ecx
  1056. pushl %edx
  1057. movl 0xc(%esp), %eax
  1058. movl 0x4(%ebp), %edx
  1059. subl $MCOUNT_INSN_SIZE, %eax
  1060. .globl ftrace_call
  1061. ftrace_call:
  1062. call ftrace_stub
  1063. popl %edx
  1064. popl %ecx
  1065. popl %eax
  1066. .globl ftrace_stub
  1067. ftrace_stub:
  1068. ret
  1069. END(ftrace_caller)
  1070. #else /* ! CONFIG_DYNAMIC_FTRACE */
  1071. ENTRY(mcount)
  1072. cmpl $ftrace_stub, ftrace_trace_function
  1073. jnz trace
  1074. .globl ftrace_stub
  1075. ftrace_stub:
  1076. ret
  1077. /* taken from glibc */
  1078. trace:
  1079. pushl %eax
  1080. pushl %ecx
  1081. pushl %edx
  1082. movl 0xc(%esp), %eax
  1083. movl 0x4(%ebp), %edx
  1084. subl $MCOUNT_INSN_SIZE, %eax
  1085. call *ftrace_trace_function
  1086. popl %edx
  1087. popl %ecx
  1088. popl %eax
  1089. jmp ftrace_stub
  1090. END(mcount)
  1091. #endif /* CONFIG_DYNAMIC_FTRACE */
  1092. #endif /* CONFIG_FTRACE */
  1093. .section .rodata,"a"
  1094. #include "syscall_table_32.S"
  1095. syscall_table_size=(.-sys_call_table)