entry_32.S 28 KB

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