entry_32.S 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  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. CFI_ADJUST_CFA_OFFSET -5*4
  958. jmp sysenter_past_esp
  959. CFI_ENDPROC
  960. ENTRY(xen_hypervisor_callback)
  961. CFI_STARTPROC
  962. pushl $0
  963. CFI_ADJUST_CFA_OFFSET 4
  964. SAVE_ALL
  965. TRACE_IRQS_OFF
  966. /* Check to see if we got the event in the critical
  967. region in xen_iret_direct, after we've reenabled
  968. events and checked for pending events. This simulates
  969. iret instruction's behaviour where it delivers a
  970. pending interrupt when enabling interrupts. */
  971. movl PT_EIP(%esp),%eax
  972. cmpl $xen_iret_start_crit,%eax
  973. jb 1f
  974. cmpl $xen_iret_end_crit,%eax
  975. jae 1f
  976. jmp xen_iret_crit_fixup
  977. ENTRY(xen_do_upcall)
  978. 1: mov %esp, %eax
  979. call xen_evtchn_do_upcall
  980. jmp ret_from_intr
  981. CFI_ENDPROC
  982. ENDPROC(xen_hypervisor_callback)
  983. # Hypervisor uses this for application faults while it executes.
  984. # We get here for two reasons:
  985. # 1. Fault while reloading DS, ES, FS or GS
  986. # 2. Fault while executing IRET
  987. # Category 1 we fix up by reattempting the load, and zeroing the segment
  988. # register if the load fails.
  989. # Category 2 we fix up by jumping to do_iret_error. We cannot use the
  990. # normal Linux return path in this case because if we use the IRET hypercall
  991. # to pop the stack frame we end up in an infinite loop of failsafe callbacks.
  992. # We distinguish between categories by maintaining a status value in EAX.
  993. ENTRY(xen_failsafe_callback)
  994. CFI_STARTPROC
  995. pushl %eax
  996. CFI_ADJUST_CFA_OFFSET 4
  997. movl $1,%eax
  998. 1: mov 4(%esp),%ds
  999. 2: mov 8(%esp),%es
  1000. 3: mov 12(%esp),%fs
  1001. 4: mov 16(%esp),%gs
  1002. testl %eax,%eax
  1003. popl %eax
  1004. CFI_ADJUST_CFA_OFFSET -4
  1005. lea 16(%esp),%esp
  1006. CFI_ADJUST_CFA_OFFSET -16
  1007. jz 5f
  1008. addl $16,%esp
  1009. jmp iret_exc # EAX != 0 => Category 2 (Bad IRET)
  1010. 5: pushl $0 # EAX == 0 => Category 1 (Bad segment)
  1011. CFI_ADJUST_CFA_OFFSET 4
  1012. SAVE_ALL
  1013. jmp ret_from_exception
  1014. CFI_ENDPROC
  1015. .section .fixup,"ax"
  1016. 6: xorl %eax,%eax
  1017. movl %eax,4(%esp)
  1018. jmp 1b
  1019. 7: xorl %eax,%eax
  1020. movl %eax,8(%esp)
  1021. jmp 2b
  1022. 8: xorl %eax,%eax
  1023. movl %eax,12(%esp)
  1024. jmp 3b
  1025. 9: xorl %eax,%eax
  1026. movl %eax,16(%esp)
  1027. jmp 4b
  1028. .previous
  1029. .section __ex_table,"a"
  1030. .align 4
  1031. .long 1b,6b
  1032. .long 2b,7b
  1033. .long 3b,8b
  1034. .long 4b,9b
  1035. .previous
  1036. ENDPROC(xen_failsafe_callback)
  1037. #endif /* CONFIG_XEN */
  1038. #ifdef CONFIG_FTRACE
  1039. #ifdef CONFIG_DYNAMIC_FTRACE
  1040. ENTRY(mcount)
  1041. pushl %eax
  1042. pushl %ecx
  1043. pushl %edx
  1044. movl 0xc(%esp), %eax
  1045. subl $MCOUNT_INSN_SIZE, %eax
  1046. .globl mcount_call
  1047. mcount_call:
  1048. call ftrace_stub
  1049. popl %edx
  1050. popl %ecx
  1051. popl %eax
  1052. ret
  1053. END(mcount)
  1054. ENTRY(ftrace_caller)
  1055. pushl %eax
  1056. pushl %ecx
  1057. pushl %edx
  1058. movl 0xc(%esp), %eax
  1059. movl 0x4(%ebp), %edx
  1060. subl $MCOUNT_INSN_SIZE, %eax
  1061. .globl ftrace_call
  1062. ftrace_call:
  1063. call ftrace_stub
  1064. popl %edx
  1065. popl %ecx
  1066. popl %eax
  1067. .globl ftrace_stub
  1068. ftrace_stub:
  1069. ret
  1070. END(ftrace_caller)
  1071. #else /* ! CONFIG_DYNAMIC_FTRACE */
  1072. ENTRY(mcount)
  1073. cmpl $ftrace_stub, ftrace_trace_function
  1074. jnz trace
  1075. .globl ftrace_stub
  1076. ftrace_stub:
  1077. ret
  1078. /* taken from glibc */
  1079. trace:
  1080. pushl %eax
  1081. pushl %ecx
  1082. pushl %edx
  1083. movl 0xc(%esp), %eax
  1084. movl 0x4(%ebp), %edx
  1085. subl $MCOUNT_INSN_SIZE, %eax
  1086. call *ftrace_trace_function
  1087. popl %edx
  1088. popl %ecx
  1089. popl %eax
  1090. jmp ftrace_stub
  1091. END(mcount)
  1092. #endif /* CONFIG_DYNAMIC_FTRACE */
  1093. #endif /* CONFIG_FTRACE */
  1094. .section .rodata,"a"
  1095. #include "syscall_table_32.S"
  1096. syscall_table_size=(.-sys_call_table)