entry_64.S 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697
  1. /*
  2. * linux/arch/x86_64/entry.S
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. * Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs
  6. * Copyright (C) 2000 Pavel Machek <pavel@suse.cz>
  7. */
  8. /*
  9. * entry.S contains the system-call and fault low-level handling routines.
  10. *
  11. * Some of this is documented in Documentation/x86/entry_64.txt
  12. *
  13. * NOTE: This code handles signal-recognition, which happens every time
  14. * after an interrupt and after each system call.
  15. *
  16. * Normal syscalls and interrupts don't save a full stack frame, this is
  17. * only done for syscall tracing, signals or fork/exec et.al.
  18. *
  19. * A note on terminology:
  20. * - top of stack: Architecture defined interrupt frame from SS to RIP
  21. * at the top of the kernel process stack.
  22. * - partial stack frame: partially saved registers up to R11.
  23. * - full stack frame: Like partial stack frame, but all register saved.
  24. *
  25. * Some macro usage:
  26. * - CFI macros are used to generate dwarf2 unwind information for better
  27. * backtraces. They don't change any code.
  28. * - SAVE_ALL/RESTORE_ALL - Save/restore all registers
  29. * - SAVE_ARGS/RESTORE_ARGS - Save/restore registers that C functions modify.
  30. * There are unfortunately lots of special cases where some registers
  31. * not touched. The macro is a big mess that should be cleaned up.
  32. * - SAVE_REST/RESTORE_REST - Handle the registers not saved by SAVE_ARGS.
  33. * Gives a full stack frame.
  34. * - ENTRY/END Define functions in the symbol table.
  35. * - FIXUP_TOP_OF_STACK/RESTORE_TOP_OF_STACK - Fix up the hardware stack
  36. * frame that is otherwise undefined after a SYSCALL
  37. * - TRACE_IRQ_* - Trace hard interrupt state for lock debugging.
  38. * - idtentry - Define exception entry points.
  39. */
  40. #include <linux/linkage.h>
  41. #include <asm/segment.h>
  42. #include <asm/cache.h>
  43. #include <asm/errno.h>
  44. #include <asm/dwarf2.h>
  45. #include <asm/calling.h>
  46. #include <asm/asm-offsets.h>
  47. #include <asm/msr.h>
  48. #include <asm/unistd.h>
  49. #include <asm/thread_info.h>
  50. #include <asm/hw_irq.h>
  51. #include <asm/page_types.h>
  52. #include <asm/irqflags.h>
  53. #include <asm/paravirt.h>
  54. #include <asm/percpu.h>
  55. #include <asm/asm.h>
  56. #include <asm/context_tracking.h>
  57. #include <asm/smap.h>
  58. #include <asm/pgtable_types.h>
  59. #include <linux/err.h>
  60. /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
  61. #include <linux/elf-em.h>
  62. #define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
  63. #define __AUDIT_ARCH_64BIT 0x80000000
  64. #define __AUDIT_ARCH_LE 0x40000000
  65. .code64
  66. .section .entry.text, "ax"
  67. #ifndef CONFIG_PREEMPT
  68. #define retint_kernel retint_restore_args
  69. #endif
  70. #ifdef CONFIG_PARAVIRT
  71. ENTRY(native_usergs_sysret64)
  72. swapgs
  73. sysretq
  74. ENDPROC(native_usergs_sysret64)
  75. #endif /* CONFIG_PARAVIRT */
  76. .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
  77. #ifdef CONFIG_TRACE_IRQFLAGS
  78. bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
  79. jnc 1f
  80. TRACE_IRQS_ON
  81. 1:
  82. #endif
  83. .endm
  84. /*
  85. * When dynamic function tracer is enabled it will add a breakpoint
  86. * to all locations that it is about to modify, sync CPUs, update
  87. * all the code, sync CPUs, then remove the breakpoints. In this time
  88. * if lockdep is enabled, it might jump back into the debug handler
  89. * outside the updating of the IST protection. (TRACE_IRQS_ON/OFF).
  90. *
  91. * We need to change the IDT table before calling TRACE_IRQS_ON/OFF to
  92. * make sure the stack pointer does not get reset back to the top
  93. * of the debug stack, and instead just reuses the current stack.
  94. */
  95. #if defined(CONFIG_DYNAMIC_FTRACE) && defined(CONFIG_TRACE_IRQFLAGS)
  96. .macro TRACE_IRQS_OFF_DEBUG
  97. call debug_stack_set_zero
  98. TRACE_IRQS_OFF
  99. call debug_stack_reset
  100. .endm
  101. .macro TRACE_IRQS_ON_DEBUG
  102. call debug_stack_set_zero
  103. TRACE_IRQS_ON
  104. call debug_stack_reset
  105. .endm
  106. .macro TRACE_IRQS_IRETQ_DEBUG offset=ARGOFFSET
  107. bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
  108. jnc 1f
  109. TRACE_IRQS_ON_DEBUG
  110. 1:
  111. .endm
  112. #else
  113. # define TRACE_IRQS_OFF_DEBUG TRACE_IRQS_OFF
  114. # define TRACE_IRQS_ON_DEBUG TRACE_IRQS_ON
  115. # define TRACE_IRQS_IRETQ_DEBUG TRACE_IRQS_IRETQ
  116. #endif
  117. /*
  118. * C code is not supposed to know about undefined top of stack. Every time
  119. * a C function with an pt_regs argument is called from the SYSCALL based
  120. * fast path FIXUP_TOP_OF_STACK is needed.
  121. * RESTORE_TOP_OF_STACK syncs the syscall state after any possible ptregs
  122. * manipulation.
  123. */
  124. /* %rsp:at FRAMEEND */
  125. .macro FIXUP_TOP_OF_STACK tmp offset=0
  126. movq PER_CPU_VAR(old_rsp),\tmp
  127. movq \tmp,RSP+\offset(%rsp)
  128. movq $__USER_DS,SS+\offset(%rsp)
  129. movq $__USER_CS,CS+\offset(%rsp)
  130. movq $-1,RCX+\offset(%rsp)
  131. movq R11+\offset(%rsp),\tmp /* get eflags */
  132. movq \tmp,EFLAGS+\offset(%rsp)
  133. .endm
  134. .macro RESTORE_TOP_OF_STACK tmp offset=0
  135. movq RSP+\offset(%rsp),\tmp
  136. movq \tmp,PER_CPU_VAR(old_rsp)
  137. movq EFLAGS+\offset(%rsp),\tmp
  138. movq \tmp,R11+\offset(%rsp)
  139. .endm
  140. .macro FAKE_STACK_FRAME child_rip
  141. /* push in order ss, rsp, eflags, cs, rip */
  142. xorl %eax, %eax
  143. pushq_cfi $__KERNEL_DS /* ss */
  144. /*CFI_REL_OFFSET ss,0*/
  145. pushq_cfi %rax /* rsp */
  146. CFI_REL_OFFSET rsp,0
  147. pushq_cfi $(X86_EFLAGS_IF|X86_EFLAGS_FIXED) /* eflags - interrupts on */
  148. /*CFI_REL_OFFSET rflags,0*/
  149. pushq_cfi $__KERNEL_CS /* cs */
  150. /*CFI_REL_OFFSET cs,0*/
  151. pushq_cfi \child_rip /* rip */
  152. CFI_REL_OFFSET rip,0
  153. pushq_cfi %rax /* orig rax */
  154. .endm
  155. .macro UNFAKE_STACK_FRAME
  156. addq $8*6, %rsp
  157. CFI_ADJUST_CFA_OFFSET -(6*8)
  158. .endm
  159. /*
  160. * initial frame state for interrupts (and exceptions without error code)
  161. */
  162. .macro EMPTY_FRAME start=1 offset=0
  163. .if \start
  164. CFI_STARTPROC simple
  165. CFI_SIGNAL_FRAME
  166. CFI_DEF_CFA rsp,8+\offset
  167. .else
  168. CFI_DEF_CFA_OFFSET 8+\offset
  169. .endif
  170. .endm
  171. /*
  172. * initial frame state for interrupts (and exceptions without error code)
  173. */
  174. .macro INTR_FRAME start=1 offset=0
  175. EMPTY_FRAME \start, SS+8+\offset-RIP
  176. /*CFI_REL_OFFSET ss, SS+\offset-RIP*/
  177. CFI_REL_OFFSET rsp, RSP+\offset-RIP
  178. /*CFI_REL_OFFSET rflags, EFLAGS+\offset-RIP*/
  179. /*CFI_REL_OFFSET cs, CS+\offset-RIP*/
  180. CFI_REL_OFFSET rip, RIP+\offset-RIP
  181. .endm
  182. /*
  183. * initial frame state for exceptions with error code (and interrupts
  184. * with vector already pushed)
  185. */
  186. .macro XCPT_FRAME start=1 offset=0
  187. INTR_FRAME \start, RIP+\offset-ORIG_RAX
  188. .endm
  189. /*
  190. * frame that enables calling into C.
  191. */
  192. .macro PARTIAL_FRAME start=1 offset=0
  193. XCPT_FRAME \start, ORIG_RAX+\offset-ARGOFFSET
  194. CFI_REL_OFFSET rdi, RDI+\offset-ARGOFFSET
  195. CFI_REL_OFFSET rsi, RSI+\offset-ARGOFFSET
  196. CFI_REL_OFFSET rdx, RDX+\offset-ARGOFFSET
  197. CFI_REL_OFFSET rcx, RCX+\offset-ARGOFFSET
  198. CFI_REL_OFFSET rax, RAX+\offset-ARGOFFSET
  199. CFI_REL_OFFSET r8, R8+\offset-ARGOFFSET
  200. CFI_REL_OFFSET r9, R9+\offset-ARGOFFSET
  201. CFI_REL_OFFSET r10, R10+\offset-ARGOFFSET
  202. CFI_REL_OFFSET r11, R11+\offset-ARGOFFSET
  203. .endm
  204. /*
  205. * frame that enables passing a complete pt_regs to a C function.
  206. */
  207. .macro DEFAULT_FRAME start=1 offset=0
  208. PARTIAL_FRAME \start, R11+\offset-R15
  209. CFI_REL_OFFSET rbx, RBX+\offset
  210. CFI_REL_OFFSET rbp, RBP+\offset
  211. CFI_REL_OFFSET r12, R12+\offset
  212. CFI_REL_OFFSET r13, R13+\offset
  213. CFI_REL_OFFSET r14, R14+\offset
  214. CFI_REL_OFFSET r15, R15+\offset
  215. .endm
  216. /* save partial stack frame */
  217. .macro SAVE_ARGS_IRQ
  218. cld
  219. /* start from rbp in pt_regs and jump over */
  220. movq_cfi rdi, (RDI-RBP)
  221. movq_cfi rsi, (RSI-RBP)
  222. movq_cfi rdx, (RDX-RBP)
  223. movq_cfi rcx, (RCX-RBP)
  224. movq_cfi rax, (RAX-RBP)
  225. movq_cfi r8, (R8-RBP)
  226. movq_cfi r9, (R9-RBP)
  227. movq_cfi r10, (R10-RBP)
  228. movq_cfi r11, (R11-RBP)
  229. /* Save rbp so that we can unwind from get_irq_regs() */
  230. movq_cfi rbp, 0
  231. /* Save previous stack value */
  232. movq %rsp, %rsi
  233. leaq -RBP(%rsp),%rdi /* arg1 for handler */
  234. testl $3, CS-RBP(%rsi)
  235. je 1f
  236. SWAPGS
  237. /*
  238. * irq_count is used to check if a CPU is already on an interrupt stack
  239. * or not. While this is essentially redundant with preempt_count it is
  240. * a little cheaper to use a separate counter in the PDA (short of
  241. * moving irq_enter into assembly, which would be too much work)
  242. */
  243. 1: incl PER_CPU_VAR(irq_count)
  244. cmovzq PER_CPU_VAR(irq_stack_ptr),%rsp
  245. CFI_DEF_CFA_REGISTER rsi
  246. /* Store previous stack value */
  247. pushq %rsi
  248. CFI_ESCAPE 0x0f /* DW_CFA_def_cfa_expression */, 6, \
  249. 0x77 /* DW_OP_breg7 */, 0, \
  250. 0x06 /* DW_OP_deref */, \
  251. 0x08 /* DW_OP_const1u */, SS+8-RBP, \
  252. 0x22 /* DW_OP_plus */
  253. /* We entered an interrupt context - irqs are off: */
  254. TRACE_IRQS_OFF
  255. .endm
  256. ENTRY(save_paranoid)
  257. XCPT_FRAME 1 RDI+8
  258. cld
  259. movq %rdi, RDI+8(%rsp)
  260. movq %rsi, RSI+8(%rsp)
  261. movq_cfi rdx, RDX+8
  262. movq_cfi rcx, RCX+8
  263. movq_cfi rax, RAX+8
  264. movq %r8, R8+8(%rsp)
  265. movq %r9, R9+8(%rsp)
  266. movq %r10, R10+8(%rsp)
  267. movq %r11, R11+8(%rsp)
  268. movq_cfi rbx, RBX+8
  269. movq %rbp, RBP+8(%rsp)
  270. movq %r12, R12+8(%rsp)
  271. movq %r13, R13+8(%rsp)
  272. movq %r14, R14+8(%rsp)
  273. movq %r15, R15+8(%rsp)
  274. movl $1,%ebx
  275. movl $MSR_GS_BASE,%ecx
  276. rdmsr
  277. testl %edx,%edx
  278. js 1f /* negative -> in kernel */
  279. SWAPGS
  280. xorl %ebx,%ebx
  281. 1: ret
  282. CFI_ENDPROC
  283. END(save_paranoid)
  284. /*
  285. * A newly forked process directly context switches into this address.
  286. *
  287. * rdi: prev task we switched from
  288. */
  289. ENTRY(ret_from_fork)
  290. DEFAULT_FRAME
  291. LOCK ; btr $TIF_FORK,TI_flags(%r8)
  292. pushq_cfi $0x0002
  293. popfq_cfi # reset kernel eflags
  294. call schedule_tail # rdi: 'prev' task parameter
  295. GET_THREAD_INFO(%rcx)
  296. RESTORE_REST
  297. testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
  298. jz 1f
  299. testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
  300. jnz int_ret_from_sys_call
  301. RESTORE_TOP_OF_STACK %rdi, -ARGOFFSET
  302. jmp ret_from_sys_call # go to the SYSRET fastpath
  303. 1:
  304. subq $REST_SKIP, %rsp # leave space for volatiles
  305. CFI_ADJUST_CFA_OFFSET REST_SKIP
  306. movq %rbp, %rdi
  307. call *%rbx
  308. movl $0, RAX(%rsp)
  309. RESTORE_REST
  310. jmp int_ret_from_sys_call
  311. CFI_ENDPROC
  312. END(ret_from_fork)
  313. /*
  314. * System call entry. Up to 6 arguments in registers are supported.
  315. *
  316. * SYSCALL does not save anything on the stack and does not change the
  317. * stack pointer. However, it does mask the flags register for us, so
  318. * CLD and CLAC are not needed.
  319. */
  320. /*
  321. * Register setup:
  322. * rax system call number
  323. * rdi arg0
  324. * rcx return address for syscall/sysret, C arg3
  325. * rsi arg1
  326. * rdx arg2
  327. * r10 arg3 (--> moved to rcx for C)
  328. * r8 arg4
  329. * r9 arg5
  330. * r11 eflags for syscall/sysret, temporary for C
  331. * r12-r15,rbp,rbx saved by C code, not touched.
  332. *
  333. * Interrupts are off on entry.
  334. * Only called from user space.
  335. *
  336. * XXX if we had a free scratch register we could save the RSP into the stack frame
  337. * and report it properly in ps. Unfortunately we haven't.
  338. *
  339. * When user can change the frames always force IRET. That is because
  340. * it deals with uncanonical addresses better. SYSRET has trouble
  341. * with them due to bugs in both AMD and Intel CPUs.
  342. */
  343. ENTRY(system_call)
  344. CFI_STARTPROC simple
  345. CFI_SIGNAL_FRAME
  346. CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
  347. CFI_REGISTER rip,rcx
  348. /*CFI_REGISTER rflags,r11*/
  349. SWAPGS_UNSAFE_STACK
  350. /*
  351. * A hypervisor implementation might want to use a label
  352. * after the swapgs, so that it can do the swapgs
  353. * for the guest and jump here on syscall.
  354. */
  355. GLOBAL(system_call_after_swapgs)
  356. movq %rsp,PER_CPU_VAR(old_rsp)
  357. movq PER_CPU_VAR(kernel_stack),%rsp
  358. /*
  359. * No need to follow this irqs off/on section - it's straight
  360. * and short:
  361. */
  362. ENABLE_INTERRUPTS(CLBR_NONE)
  363. SAVE_ARGS 8, 0, rax_enosys=1
  364. movq_cfi rax,(ORIG_RAX-ARGOFFSET)
  365. movq %rcx,RIP-ARGOFFSET(%rsp)
  366. CFI_REL_OFFSET rip,RIP-ARGOFFSET
  367. testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
  368. jnz tracesys
  369. system_call_fastpath:
  370. #if __SYSCALL_MASK == ~0
  371. cmpq $__NR_syscall_max,%rax
  372. #else
  373. andl $__SYSCALL_MASK,%eax
  374. cmpl $__NR_syscall_max,%eax
  375. #endif
  376. ja ret_from_sys_call /* and return regs->ax */
  377. movq %r10,%rcx
  378. call *sys_call_table(,%rax,8) # XXX: rip relative
  379. movq %rax,RAX-ARGOFFSET(%rsp)
  380. /*
  381. * Syscall return path ending with SYSRET (fast path)
  382. * Has incomplete stack frame and undefined top of stack.
  383. */
  384. ret_from_sys_call:
  385. movl $_TIF_ALLWORK_MASK,%edi
  386. /* edi: flagmask */
  387. sysret_check:
  388. LOCKDEP_SYS_EXIT
  389. DISABLE_INTERRUPTS(CLBR_NONE)
  390. TRACE_IRQS_OFF
  391. movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
  392. andl %edi,%edx
  393. jnz sysret_careful
  394. CFI_REMEMBER_STATE
  395. /*
  396. * sysretq will re-enable interrupts:
  397. */
  398. TRACE_IRQS_ON
  399. movq RIP-ARGOFFSET(%rsp),%rcx
  400. CFI_REGISTER rip,rcx
  401. RESTORE_ARGS 1,-ARG_SKIP,0
  402. /*CFI_REGISTER rflags,r11*/
  403. movq PER_CPU_VAR(old_rsp), %rsp
  404. USERGS_SYSRET64
  405. CFI_RESTORE_STATE
  406. /* Handle reschedules */
  407. /* edx: work, edi: workmask */
  408. sysret_careful:
  409. bt $TIF_NEED_RESCHED,%edx
  410. jnc sysret_signal
  411. TRACE_IRQS_ON
  412. ENABLE_INTERRUPTS(CLBR_NONE)
  413. pushq_cfi %rdi
  414. SCHEDULE_USER
  415. popq_cfi %rdi
  416. jmp sysret_check
  417. /* Handle a signal */
  418. sysret_signal:
  419. TRACE_IRQS_ON
  420. ENABLE_INTERRUPTS(CLBR_NONE)
  421. #ifdef CONFIG_AUDITSYSCALL
  422. bt $TIF_SYSCALL_AUDIT,%edx
  423. jc sysret_audit
  424. #endif
  425. /*
  426. * We have a signal, or exit tracing or single-step.
  427. * These all wind up with the iret return path anyway,
  428. * so just join that path right now.
  429. */
  430. FIXUP_TOP_OF_STACK %r11, -ARGOFFSET
  431. jmp int_check_syscall_exit_work
  432. #ifdef CONFIG_AUDITSYSCALL
  433. /*
  434. * Return fast path for syscall audit. Call __audit_syscall_exit()
  435. * directly and then jump back to the fast path with TIF_SYSCALL_AUDIT
  436. * masked off.
  437. */
  438. sysret_audit:
  439. movq RAX-ARGOFFSET(%rsp),%rsi /* second arg, syscall return value */
  440. cmpq $-MAX_ERRNO,%rsi /* is it < -MAX_ERRNO? */
  441. setbe %al /* 1 if so, 0 if not */
  442. movzbl %al,%edi /* zero-extend that into %edi */
  443. call __audit_syscall_exit
  444. movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
  445. jmp sysret_check
  446. #endif /* CONFIG_AUDITSYSCALL */
  447. /* Do syscall tracing */
  448. tracesys:
  449. leaq -REST_SKIP(%rsp), %rdi
  450. movq $AUDIT_ARCH_X86_64, %rsi
  451. call syscall_trace_enter_phase1
  452. test %rax, %rax
  453. jnz tracesys_phase2 /* if needed, run the slow path */
  454. LOAD_ARGS 0 /* else restore clobbered regs */
  455. jmp system_call_fastpath /* and return to the fast path */
  456. tracesys_phase2:
  457. SAVE_REST
  458. FIXUP_TOP_OF_STACK %rdi
  459. movq %rsp, %rdi
  460. movq $AUDIT_ARCH_X86_64, %rsi
  461. movq %rax,%rdx
  462. call syscall_trace_enter_phase2
  463. /*
  464. * Reload arg registers from stack in case ptrace changed them.
  465. * We don't reload %rax because syscall_trace_entry_phase2() returned
  466. * the value it wants us to use in the table lookup.
  467. */
  468. LOAD_ARGS ARGOFFSET, 1
  469. RESTORE_REST
  470. #if __SYSCALL_MASK == ~0
  471. cmpq $__NR_syscall_max,%rax
  472. #else
  473. andl $__SYSCALL_MASK,%eax
  474. cmpl $__NR_syscall_max,%eax
  475. #endif
  476. ja int_ret_from_sys_call /* RAX(%rsp) is already set */
  477. movq %r10,%rcx /* fixup for C */
  478. call *sys_call_table(,%rax,8)
  479. movq %rax,RAX-ARGOFFSET(%rsp)
  480. /* Use IRET because user could have changed frame */
  481. /*
  482. * Syscall return path ending with IRET.
  483. * Has correct top of stack, but partial stack frame.
  484. */
  485. GLOBAL(int_ret_from_sys_call)
  486. DISABLE_INTERRUPTS(CLBR_NONE)
  487. TRACE_IRQS_OFF
  488. movl $_TIF_ALLWORK_MASK,%edi
  489. /* edi: mask to check */
  490. GLOBAL(int_with_check)
  491. LOCKDEP_SYS_EXIT_IRQ
  492. GET_THREAD_INFO(%rcx)
  493. movl TI_flags(%rcx),%edx
  494. andl %edi,%edx
  495. jnz int_careful
  496. andl $~TS_COMPAT,TI_status(%rcx)
  497. jmp retint_swapgs
  498. /* Either reschedule or signal or syscall exit tracking needed. */
  499. /* First do a reschedule test. */
  500. /* edx: work, edi: workmask */
  501. int_careful:
  502. bt $TIF_NEED_RESCHED,%edx
  503. jnc int_very_careful
  504. TRACE_IRQS_ON
  505. ENABLE_INTERRUPTS(CLBR_NONE)
  506. pushq_cfi %rdi
  507. SCHEDULE_USER
  508. popq_cfi %rdi
  509. DISABLE_INTERRUPTS(CLBR_NONE)
  510. TRACE_IRQS_OFF
  511. jmp int_with_check
  512. /* handle signals and tracing -- both require a full stack frame */
  513. int_very_careful:
  514. TRACE_IRQS_ON
  515. ENABLE_INTERRUPTS(CLBR_NONE)
  516. int_check_syscall_exit_work:
  517. SAVE_REST
  518. /* Check for syscall exit trace */
  519. testl $_TIF_WORK_SYSCALL_EXIT,%edx
  520. jz int_signal
  521. pushq_cfi %rdi
  522. leaq 8(%rsp),%rdi # &ptregs -> arg1
  523. call syscall_trace_leave
  524. popq_cfi %rdi
  525. andl $~(_TIF_WORK_SYSCALL_EXIT|_TIF_SYSCALL_EMU),%edi
  526. jmp int_restore_rest
  527. int_signal:
  528. testl $_TIF_DO_NOTIFY_MASK,%edx
  529. jz 1f
  530. movq %rsp,%rdi # &ptregs -> arg1
  531. xorl %esi,%esi # oldset -> arg2
  532. call do_notify_resume
  533. 1: movl $_TIF_WORK_MASK,%edi
  534. int_restore_rest:
  535. RESTORE_REST
  536. DISABLE_INTERRUPTS(CLBR_NONE)
  537. TRACE_IRQS_OFF
  538. jmp int_with_check
  539. CFI_ENDPROC
  540. END(system_call)
  541. .macro FORK_LIKE func
  542. ENTRY(stub_\func)
  543. CFI_STARTPROC
  544. popq %r11 /* save return address */
  545. PARTIAL_FRAME 0
  546. SAVE_REST
  547. pushq %r11 /* put it back on stack */
  548. FIXUP_TOP_OF_STACK %r11, 8
  549. DEFAULT_FRAME 0 8 /* offset 8: return address */
  550. call sys_\func
  551. RESTORE_TOP_OF_STACK %r11, 8
  552. ret $REST_SKIP /* pop extended registers */
  553. CFI_ENDPROC
  554. END(stub_\func)
  555. .endm
  556. .macro FIXED_FRAME label,func
  557. ENTRY(\label)
  558. CFI_STARTPROC
  559. PARTIAL_FRAME 0 8 /* offset 8: return address */
  560. FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
  561. call \func
  562. RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
  563. ret
  564. CFI_ENDPROC
  565. END(\label)
  566. .endm
  567. FORK_LIKE clone
  568. FORK_LIKE fork
  569. FORK_LIKE vfork
  570. FIXED_FRAME stub_iopl, sys_iopl
  571. ENTRY(ptregscall_common)
  572. DEFAULT_FRAME 1 8 /* offset 8: return address */
  573. RESTORE_TOP_OF_STACK %r11, 8
  574. movq_cfi_restore R15+8, r15
  575. movq_cfi_restore R14+8, r14
  576. movq_cfi_restore R13+8, r13
  577. movq_cfi_restore R12+8, r12
  578. movq_cfi_restore RBP+8, rbp
  579. movq_cfi_restore RBX+8, rbx
  580. ret $REST_SKIP /* pop extended registers */
  581. CFI_ENDPROC
  582. END(ptregscall_common)
  583. ENTRY(stub_execve)
  584. CFI_STARTPROC
  585. addq $8, %rsp
  586. PARTIAL_FRAME 0
  587. SAVE_REST
  588. FIXUP_TOP_OF_STACK %r11
  589. call sys_execve
  590. movq %rax,RAX(%rsp)
  591. RESTORE_REST
  592. jmp int_ret_from_sys_call
  593. CFI_ENDPROC
  594. END(stub_execve)
  595. ENTRY(stub_execveat)
  596. CFI_STARTPROC
  597. addq $8, %rsp
  598. PARTIAL_FRAME 0
  599. SAVE_REST
  600. FIXUP_TOP_OF_STACK %r11
  601. call sys_execveat
  602. RESTORE_TOP_OF_STACK %r11
  603. movq %rax,RAX(%rsp)
  604. RESTORE_REST
  605. jmp int_ret_from_sys_call
  606. CFI_ENDPROC
  607. END(stub_execveat)
  608. /*
  609. * sigreturn is special because it needs to restore all registers on return.
  610. * This cannot be done with SYSRET, so use the IRET return path instead.
  611. */
  612. ENTRY(stub_rt_sigreturn)
  613. CFI_STARTPROC
  614. addq $8, %rsp
  615. PARTIAL_FRAME 0
  616. SAVE_REST
  617. FIXUP_TOP_OF_STACK %r11
  618. call sys_rt_sigreturn
  619. movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer
  620. RESTORE_REST
  621. jmp int_ret_from_sys_call
  622. CFI_ENDPROC
  623. END(stub_rt_sigreturn)
  624. #ifdef CONFIG_X86_X32_ABI
  625. ENTRY(stub_x32_rt_sigreturn)
  626. CFI_STARTPROC
  627. addq $8, %rsp
  628. PARTIAL_FRAME 0
  629. SAVE_REST
  630. FIXUP_TOP_OF_STACK %r11
  631. call sys32_x32_rt_sigreturn
  632. movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer
  633. RESTORE_REST
  634. jmp int_ret_from_sys_call
  635. CFI_ENDPROC
  636. END(stub_x32_rt_sigreturn)
  637. ENTRY(stub_x32_execve)
  638. CFI_STARTPROC
  639. addq $8, %rsp
  640. PARTIAL_FRAME 0
  641. SAVE_REST
  642. FIXUP_TOP_OF_STACK %r11
  643. call compat_sys_execve
  644. RESTORE_TOP_OF_STACK %r11
  645. movq %rax,RAX(%rsp)
  646. RESTORE_REST
  647. jmp int_ret_from_sys_call
  648. CFI_ENDPROC
  649. END(stub_x32_execve)
  650. ENTRY(stub_x32_execveat)
  651. CFI_STARTPROC
  652. addq $8, %rsp
  653. PARTIAL_FRAME 0
  654. SAVE_REST
  655. FIXUP_TOP_OF_STACK %r11
  656. call compat_sys_execveat
  657. RESTORE_TOP_OF_STACK %r11
  658. movq %rax,RAX(%rsp)
  659. RESTORE_REST
  660. jmp int_ret_from_sys_call
  661. CFI_ENDPROC
  662. END(stub_x32_execveat)
  663. #endif
  664. /*
  665. * Build the entry stubs and pointer table with some assembler magic.
  666. * We pack 7 stubs into a single 32-byte chunk, which will fit in a
  667. * single cache line on all modern x86 implementations.
  668. */
  669. .section .init.rodata,"a"
  670. ENTRY(interrupt)
  671. .section .entry.text
  672. .p2align 5
  673. .p2align CONFIG_X86_L1_CACHE_SHIFT
  674. ENTRY(irq_entries_start)
  675. INTR_FRAME
  676. vector=FIRST_EXTERNAL_VECTOR
  677. .rept (FIRST_SYSTEM_VECTOR-FIRST_EXTERNAL_VECTOR+6)/7
  678. .balign 32
  679. .rept 7
  680. .if vector < FIRST_SYSTEM_VECTOR
  681. .if vector <> FIRST_EXTERNAL_VECTOR
  682. CFI_ADJUST_CFA_OFFSET -8
  683. .endif
  684. 1: pushq_cfi $(~vector+0x80) /* Note: always in signed byte range */
  685. .if ((vector-FIRST_EXTERNAL_VECTOR)%7) <> 6
  686. jmp 2f
  687. .endif
  688. .previous
  689. .quad 1b
  690. .section .entry.text
  691. vector=vector+1
  692. .endif
  693. .endr
  694. 2: jmp common_interrupt
  695. .endr
  696. CFI_ENDPROC
  697. END(irq_entries_start)
  698. .previous
  699. END(interrupt)
  700. .previous
  701. /*
  702. * Interrupt entry/exit.
  703. *
  704. * Interrupt entry points save only callee clobbered registers in fast path.
  705. *
  706. * Entry runs with interrupts off.
  707. */
  708. /* 0(%rsp): ~(interrupt number) */
  709. .macro interrupt func
  710. /* reserve pt_regs for scratch regs and rbp */
  711. subq $ORIG_RAX-RBP, %rsp
  712. CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
  713. SAVE_ARGS_IRQ
  714. call \func
  715. .endm
  716. /*
  717. * The interrupt stubs push (~vector+0x80) onto the stack and
  718. * then jump to common_interrupt.
  719. */
  720. .p2align CONFIG_X86_L1_CACHE_SHIFT
  721. common_interrupt:
  722. XCPT_FRAME
  723. ASM_CLAC
  724. addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */
  725. interrupt do_IRQ
  726. /* 0(%rsp): old_rsp-ARGOFFSET */
  727. ret_from_intr:
  728. DISABLE_INTERRUPTS(CLBR_NONE)
  729. TRACE_IRQS_OFF
  730. decl PER_CPU_VAR(irq_count)
  731. /* Restore saved previous stack */
  732. popq %rsi
  733. CFI_DEF_CFA rsi,SS+8-RBP /* reg/off reset after def_cfa_expr */
  734. leaq ARGOFFSET-RBP(%rsi), %rsp
  735. CFI_DEF_CFA_REGISTER rsp
  736. CFI_ADJUST_CFA_OFFSET RBP-ARGOFFSET
  737. exit_intr:
  738. GET_THREAD_INFO(%rcx)
  739. testl $3,CS-ARGOFFSET(%rsp)
  740. je retint_kernel
  741. /* Interrupt came from user space */
  742. /*
  743. * Has a correct top of stack, but a partial stack frame
  744. * %rcx: thread info. Interrupts off.
  745. */
  746. retint_with_reschedule:
  747. movl $_TIF_WORK_MASK,%edi
  748. retint_check:
  749. LOCKDEP_SYS_EXIT_IRQ
  750. movl TI_flags(%rcx),%edx
  751. andl %edi,%edx
  752. CFI_REMEMBER_STATE
  753. jnz retint_careful
  754. retint_swapgs: /* return to user-space */
  755. /*
  756. * The iretq could re-enable interrupts:
  757. */
  758. DISABLE_INTERRUPTS(CLBR_ANY)
  759. TRACE_IRQS_IRETQ
  760. SWAPGS
  761. jmp restore_args
  762. retint_restore_args: /* return to kernel space */
  763. DISABLE_INTERRUPTS(CLBR_ANY)
  764. /*
  765. * The iretq could re-enable interrupts:
  766. */
  767. TRACE_IRQS_IRETQ
  768. restore_args:
  769. RESTORE_ARGS 1,8,1
  770. irq_return:
  771. INTERRUPT_RETURN
  772. ENTRY(native_iret)
  773. /*
  774. * Are we returning to a stack segment from the LDT? Note: in
  775. * 64-bit mode SS:RSP on the exception stack is always valid.
  776. */
  777. #ifdef CONFIG_X86_ESPFIX64
  778. testb $4,(SS-RIP)(%rsp)
  779. jnz native_irq_return_ldt
  780. #endif
  781. .global native_irq_return_iret
  782. native_irq_return_iret:
  783. /*
  784. * This may fault. Non-paranoid faults on return to userspace are
  785. * handled by fixup_bad_iret. These include #SS, #GP, and #NP.
  786. * Double-faults due to espfix64 are handled in do_double_fault.
  787. * Other faults here are fatal.
  788. */
  789. iretq
  790. #ifdef CONFIG_X86_ESPFIX64
  791. native_irq_return_ldt:
  792. pushq_cfi %rax
  793. pushq_cfi %rdi
  794. SWAPGS
  795. movq PER_CPU_VAR(espfix_waddr),%rdi
  796. movq %rax,(0*8)(%rdi) /* RAX */
  797. movq (2*8)(%rsp),%rax /* RIP */
  798. movq %rax,(1*8)(%rdi)
  799. movq (3*8)(%rsp),%rax /* CS */
  800. movq %rax,(2*8)(%rdi)
  801. movq (4*8)(%rsp),%rax /* RFLAGS */
  802. movq %rax,(3*8)(%rdi)
  803. movq (6*8)(%rsp),%rax /* SS */
  804. movq %rax,(5*8)(%rdi)
  805. movq (5*8)(%rsp),%rax /* RSP */
  806. movq %rax,(4*8)(%rdi)
  807. andl $0xffff0000,%eax
  808. popq_cfi %rdi
  809. orq PER_CPU_VAR(espfix_stack),%rax
  810. SWAPGS
  811. movq %rax,%rsp
  812. popq_cfi %rax
  813. jmp native_irq_return_iret
  814. #endif
  815. /* edi: workmask, edx: work */
  816. retint_careful:
  817. CFI_RESTORE_STATE
  818. bt $TIF_NEED_RESCHED,%edx
  819. jnc retint_signal
  820. TRACE_IRQS_ON
  821. ENABLE_INTERRUPTS(CLBR_NONE)
  822. pushq_cfi %rdi
  823. SCHEDULE_USER
  824. popq_cfi %rdi
  825. GET_THREAD_INFO(%rcx)
  826. DISABLE_INTERRUPTS(CLBR_NONE)
  827. TRACE_IRQS_OFF
  828. jmp retint_check
  829. retint_signal:
  830. testl $_TIF_DO_NOTIFY_MASK,%edx
  831. jz retint_swapgs
  832. TRACE_IRQS_ON
  833. ENABLE_INTERRUPTS(CLBR_NONE)
  834. SAVE_REST
  835. movq $-1,ORIG_RAX(%rsp)
  836. xorl %esi,%esi # oldset
  837. movq %rsp,%rdi # &pt_regs
  838. call do_notify_resume
  839. RESTORE_REST
  840. DISABLE_INTERRUPTS(CLBR_NONE)
  841. TRACE_IRQS_OFF
  842. GET_THREAD_INFO(%rcx)
  843. jmp retint_with_reschedule
  844. #ifdef CONFIG_PREEMPT
  845. /* Returning to kernel space. Check if we need preemption */
  846. /* rcx: threadinfo. interrupts off. */
  847. ENTRY(retint_kernel)
  848. cmpl $0,PER_CPU_VAR(__preempt_count)
  849. jnz retint_restore_args
  850. bt $9,EFLAGS-ARGOFFSET(%rsp) /* interrupts off? */
  851. jnc retint_restore_args
  852. call preempt_schedule_irq
  853. jmp exit_intr
  854. #endif
  855. CFI_ENDPROC
  856. END(common_interrupt)
  857. /*
  858. * APIC interrupts.
  859. */
  860. .macro apicinterrupt3 num sym do_sym
  861. ENTRY(\sym)
  862. INTR_FRAME
  863. ASM_CLAC
  864. pushq_cfi $~(\num)
  865. .Lcommon_\sym:
  866. interrupt \do_sym
  867. jmp ret_from_intr
  868. CFI_ENDPROC
  869. END(\sym)
  870. .endm
  871. #ifdef CONFIG_TRACING
  872. #define trace(sym) trace_##sym
  873. #define smp_trace(sym) smp_trace_##sym
  874. .macro trace_apicinterrupt num sym
  875. apicinterrupt3 \num trace(\sym) smp_trace(\sym)
  876. .endm
  877. #else
  878. .macro trace_apicinterrupt num sym do_sym
  879. .endm
  880. #endif
  881. .macro apicinterrupt num sym do_sym
  882. apicinterrupt3 \num \sym \do_sym
  883. trace_apicinterrupt \num \sym
  884. .endm
  885. #ifdef CONFIG_SMP
  886. apicinterrupt3 IRQ_MOVE_CLEANUP_VECTOR \
  887. irq_move_cleanup_interrupt smp_irq_move_cleanup_interrupt
  888. apicinterrupt3 REBOOT_VECTOR \
  889. reboot_interrupt smp_reboot_interrupt
  890. #endif
  891. #ifdef CONFIG_X86_UV
  892. apicinterrupt3 UV_BAU_MESSAGE \
  893. uv_bau_message_intr1 uv_bau_message_interrupt
  894. #endif
  895. apicinterrupt LOCAL_TIMER_VECTOR \
  896. apic_timer_interrupt smp_apic_timer_interrupt
  897. apicinterrupt X86_PLATFORM_IPI_VECTOR \
  898. x86_platform_ipi smp_x86_platform_ipi
  899. #ifdef CONFIG_HAVE_KVM
  900. apicinterrupt3 POSTED_INTR_VECTOR \
  901. kvm_posted_intr_ipi smp_kvm_posted_intr_ipi
  902. #endif
  903. #ifdef CONFIG_X86_MCE_THRESHOLD
  904. apicinterrupt THRESHOLD_APIC_VECTOR \
  905. threshold_interrupt smp_threshold_interrupt
  906. #endif
  907. #ifdef CONFIG_X86_THERMAL_VECTOR
  908. apicinterrupt THERMAL_APIC_VECTOR \
  909. thermal_interrupt smp_thermal_interrupt
  910. #endif
  911. #ifdef CONFIG_SMP
  912. apicinterrupt CALL_FUNCTION_SINGLE_VECTOR \
  913. call_function_single_interrupt smp_call_function_single_interrupt
  914. apicinterrupt CALL_FUNCTION_VECTOR \
  915. call_function_interrupt smp_call_function_interrupt
  916. apicinterrupt RESCHEDULE_VECTOR \
  917. reschedule_interrupt smp_reschedule_interrupt
  918. #endif
  919. apicinterrupt ERROR_APIC_VECTOR \
  920. error_interrupt smp_error_interrupt
  921. apicinterrupt SPURIOUS_APIC_VECTOR \
  922. spurious_interrupt smp_spurious_interrupt
  923. #ifdef CONFIG_IRQ_WORK
  924. apicinterrupt IRQ_WORK_VECTOR \
  925. irq_work_interrupt smp_irq_work_interrupt
  926. #endif
  927. /*
  928. * Exception entry points.
  929. */
  930. #define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
  931. .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
  932. ENTRY(\sym)
  933. /* Sanity check */
  934. .if \shift_ist != -1 && \paranoid == 0
  935. .error "using shift_ist requires paranoid=1"
  936. .endif
  937. .if \has_error_code
  938. XCPT_FRAME
  939. .else
  940. INTR_FRAME
  941. .endif
  942. ASM_CLAC
  943. PARAVIRT_ADJUST_EXCEPTION_FRAME
  944. .ifeq \has_error_code
  945. pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
  946. .endif
  947. subq $ORIG_RAX-R15, %rsp
  948. CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
  949. .if \paranoid
  950. call save_paranoid
  951. .else
  952. call error_entry
  953. .endif
  954. DEFAULT_FRAME 0
  955. .if \paranoid
  956. .if \shift_ist != -1
  957. TRACE_IRQS_OFF_DEBUG /* reload IDT in case of recursion */
  958. .else
  959. TRACE_IRQS_OFF
  960. .endif
  961. .endif
  962. movq %rsp,%rdi /* pt_regs pointer */
  963. .if \has_error_code
  964. movq ORIG_RAX(%rsp),%rsi /* get error code */
  965. movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
  966. .else
  967. xorl %esi,%esi /* no error code */
  968. .endif
  969. .if \shift_ist != -1
  970. subq $EXCEPTION_STKSZ, INIT_TSS_IST(\shift_ist)
  971. .endif
  972. call \do_sym
  973. .if \shift_ist != -1
  974. addq $EXCEPTION_STKSZ, INIT_TSS_IST(\shift_ist)
  975. .endif
  976. .if \paranoid
  977. jmp paranoid_exit /* %ebx: no swapgs flag */
  978. .else
  979. jmp error_exit /* %ebx: no swapgs flag */
  980. .endif
  981. CFI_ENDPROC
  982. END(\sym)
  983. .endm
  984. #ifdef CONFIG_TRACING
  985. .macro trace_idtentry sym do_sym has_error_code:req
  986. idtentry trace(\sym) trace(\do_sym) has_error_code=\has_error_code
  987. idtentry \sym \do_sym has_error_code=\has_error_code
  988. .endm
  989. #else
  990. .macro trace_idtentry sym do_sym has_error_code:req
  991. idtentry \sym \do_sym has_error_code=\has_error_code
  992. .endm
  993. #endif
  994. idtentry divide_error do_divide_error has_error_code=0
  995. idtentry overflow do_overflow has_error_code=0
  996. idtentry bounds do_bounds has_error_code=0
  997. idtentry invalid_op do_invalid_op has_error_code=0
  998. idtentry device_not_available do_device_not_available has_error_code=0
  999. idtentry double_fault do_double_fault has_error_code=1 paranoid=1
  1000. idtentry coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0
  1001. idtentry invalid_TSS do_invalid_TSS has_error_code=1
  1002. idtentry segment_not_present do_segment_not_present has_error_code=1
  1003. idtentry spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0
  1004. idtentry coprocessor_error do_coprocessor_error has_error_code=0
  1005. idtentry alignment_check do_alignment_check has_error_code=1
  1006. idtentry simd_coprocessor_error do_simd_coprocessor_error has_error_code=0
  1007. /* Reload gs selector with exception handling */
  1008. /* edi: new selector */
  1009. ENTRY(native_load_gs_index)
  1010. CFI_STARTPROC
  1011. pushfq_cfi
  1012. DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
  1013. SWAPGS
  1014. gs_change:
  1015. movl %edi,%gs
  1016. 2: mfence /* workaround */
  1017. SWAPGS
  1018. popfq_cfi
  1019. ret
  1020. CFI_ENDPROC
  1021. END(native_load_gs_index)
  1022. _ASM_EXTABLE(gs_change,bad_gs)
  1023. .section .fixup,"ax"
  1024. /* running with kernelgs */
  1025. bad_gs:
  1026. SWAPGS /* switch back to user gs */
  1027. xorl %eax,%eax
  1028. movl %eax,%gs
  1029. jmp 2b
  1030. .previous
  1031. /* Call softirq on interrupt stack. Interrupts are off. */
  1032. ENTRY(do_softirq_own_stack)
  1033. CFI_STARTPROC
  1034. pushq_cfi %rbp
  1035. CFI_REL_OFFSET rbp,0
  1036. mov %rsp,%rbp
  1037. CFI_DEF_CFA_REGISTER rbp
  1038. incl PER_CPU_VAR(irq_count)
  1039. cmove PER_CPU_VAR(irq_stack_ptr),%rsp
  1040. push %rbp # backlink for old unwinder
  1041. call __do_softirq
  1042. leaveq
  1043. CFI_RESTORE rbp
  1044. CFI_DEF_CFA_REGISTER rsp
  1045. CFI_ADJUST_CFA_OFFSET -8
  1046. decl PER_CPU_VAR(irq_count)
  1047. ret
  1048. CFI_ENDPROC
  1049. END(do_softirq_own_stack)
  1050. #ifdef CONFIG_XEN
  1051. idtentry xen_hypervisor_callback xen_do_hypervisor_callback has_error_code=0
  1052. /*
  1053. * A note on the "critical region" in our callback handler.
  1054. * We want to avoid stacking callback handlers due to events occurring
  1055. * during handling of the last event. To do this, we keep events disabled
  1056. * until we've done all processing. HOWEVER, we must enable events before
  1057. * popping the stack frame (can't be done atomically) and so it would still
  1058. * be possible to get enough handler activations to overflow the stack.
  1059. * Although unlikely, bugs of that kind are hard to track down, so we'd
  1060. * like to avoid the possibility.
  1061. * So, on entry to the handler we detect whether we interrupted an
  1062. * existing activation in its critical region -- if so, we pop the current
  1063. * activation and restart the handler using the previous one.
  1064. */
  1065. ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
  1066. CFI_STARTPROC
  1067. /*
  1068. * Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
  1069. * see the correct pointer to the pt_regs
  1070. */
  1071. movq %rdi, %rsp # we don't return, adjust the stack frame
  1072. CFI_ENDPROC
  1073. DEFAULT_FRAME
  1074. 11: incl PER_CPU_VAR(irq_count)
  1075. movq %rsp,%rbp
  1076. CFI_DEF_CFA_REGISTER rbp
  1077. cmovzq PER_CPU_VAR(irq_stack_ptr),%rsp
  1078. pushq %rbp # backlink for old unwinder
  1079. call xen_evtchn_do_upcall
  1080. popq %rsp
  1081. CFI_DEF_CFA_REGISTER rsp
  1082. decl PER_CPU_VAR(irq_count)
  1083. jmp error_exit
  1084. CFI_ENDPROC
  1085. END(xen_do_hypervisor_callback)
  1086. /*
  1087. * Hypervisor uses this for application faults while it executes.
  1088. * We get here for two reasons:
  1089. * 1. Fault while reloading DS, ES, FS or GS
  1090. * 2. Fault while executing IRET
  1091. * Category 1 we do not need to fix up as Xen has already reloaded all segment
  1092. * registers that could be reloaded and zeroed the others.
  1093. * Category 2 we fix up by killing the current process. We cannot use the
  1094. * normal Linux return path in this case because if we use the IRET hypercall
  1095. * to pop the stack frame we end up in an infinite loop of failsafe callbacks.
  1096. * We distinguish between categories by comparing each saved segment register
  1097. * with its current contents: any discrepancy means we in category 1.
  1098. */
  1099. ENTRY(xen_failsafe_callback)
  1100. INTR_FRAME 1 (6*8)
  1101. /*CFI_REL_OFFSET gs,GS*/
  1102. /*CFI_REL_OFFSET fs,FS*/
  1103. /*CFI_REL_OFFSET es,ES*/
  1104. /*CFI_REL_OFFSET ds,DS*/
  1105. CFI_REL_OFFSET r11,8
  1106. CFI_REL_OFFSET rcx,0
  1107. movw %ds,%cx
  1108. cmpw %cx,0x10(%rsp)
  1109. CFI_REMEMBER_STATE
  1110. jne 1f
  1111. movw %es,%cx
  1112. cmpw %cx,0x18(%rsp)
  1113. jne 1f
  1114. movw %fs,%cx
  1115. cmpw %cx,0x20(%rsp)
  1116. jne 1f
  1117. movw %gs,%cx
  1118. cmpw %cx,0x28(%rsp)
  1119. jne 1f
  1120. /* All segments match their saved values => Category 2 (Bad IRET). */
  1121. movq (%rsp),%rcx
  1122. CFI_RESTORE rcx
  1123. movq 8(%rsp),%r11
  1124. CFI_RESTORE r11
  1125. addq $0x30,%rsp
  1126. CFI_ADJUST_CFA_OFFSET -0x30
  1127. pushq_cfi $0 /* RIP */
  1128. pushq_cfi %r11
  1129. pushq_cfi %rcx
  1130. jmp general_protection
  1131. CFI_RESTORE_STATE
  1132. 1: /* Segment mismatch => Category 1 (Bad segment). Retry the IRET. */
  1133. movq (%rsp),%rcx
  1134. CFI_RESTORE rcx
  1135. movq 8(%rsp),%r11
  1136. CFI_RESTORE r11
  1137. addq $0x30,%rsp
  1138. CFI_ADJUST_CFA_OFFSET -0x30
  1139. pushq_cfi $-1 /* orig_ax = -1 => not a system call */
  1140. SAVE_ALL
  1141. jmp error_exit
  1142. CFI_ENDPROC
  1143. END(xen_failsafe_callback)
  1144. apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
  1145. xen_hvm_callback_vector xen_evtchn_do_upcall
  1146. #endif /* CONFIG_XEN */
  1147. #if IS_ENABLED(CONFIG_HYPERV)
  1148. apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
  1149. hyperv_callback_vector hyperv_vector_handler
  1150. #endif /* CONFIG_HYPERV */
  1151. idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
  1152. idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
  1153. idtentry stack_segment do_stack_segment has_error_code=1
  1154. #ifdef CONFIG_XEN
  1155. idtentry xen_debug do_debug has_error_code=0
  1156. idtentry xen_int3 do_int3 has_error_code=0
  1157. idtentry xen_stack_segment do_stack_segment has_error_code=1
  1158. #endif
  1159. idtentry general_protection do_general_protection has_error_code=1
  1160. trace_idtentry page_fault do_page_fault has_error_code=1
  1161. #ifdef CONFIG_KVM_GUEST
  1162. idtentry async_page_fault do_async_page_fault has_error_code=1
  1163. #endif
  1164. #ifdef CONFIG_X86_MCE
  1165. idtentry machine_check has_error_code=0 paranoid=1 do_sym=*machine_check_vector(%rip)
  1166. #endif
  1167. /*
  1168. * "Paranoid" exit path from exception stack.
  1169. * Paranoid because this is used by NMIs and cannot take
  1170. * any kernel state for granted.
  1171. * We don't do kernel preemption checks here, because only
  1172. * NMI should be common and it does not enable IRQs and
  1173. * cannot get reschedule ticks.
  1174. *
  1175. * "trace" is 0 for the NMI handler only, because irq-tracing
  1176. * is fundamentally NMI-unsafe. (we cannot change the soft and
  1177. * hard flags at once, atomically)
  1178. */
  1179. /* ebx: no swapgs flag */
  1180. ENTRY(paranoid_exit)
  1181. DEFAULT_FRAME
  1182. DISABLE_INTERRUPTS(CLBR_NONE)
  1183. TRACE_IRQS_OFF_DEBUG
  1184. testl %ebx,%ebx /* swapgs needed? */
  1185. jnz paranoid_restore
  1186. testl $3,CS(%rsp)
  1187. jnz paranoid_userspace
  1188. paranoid_swapgs:
  1189. TRACE_IRQS_IRETQ 0
  1190. SWAPGS_UNSAFE_STACK
  1191. RESTORE_ALL 8
  1192. jmp irq_return
  1193. paranoid_restore:
  1194. TRACE_IRQS_IRETQ_DEBUG 0
  1195. RESTORE_ALL 8
  1196. jmp irq_return
  1197. paranoid_userspace:
  1198. GET_THREAD_INFO(%rcx)
  1199. movl TI_flags(%rcx),%ebx
  1200. andl $_TIF_WORK_MASK,%ebx
  1201. jz paranoid_swapgs
  1202. movq %rsp,%rdi /* &pt_regs */
  1203. call sync_regs
  1204. movq %rax,%rsp /* switch stack for scheduling */
  1205. testl $_TIF_NEED_RESCHED,%ebx
  1206. jnz paranoid_schedule
  1207. movl %ebx,%edx /* arg3: thread flags */
  1208. TRACE_IRQS_ON
  1209. ENABLE_INTERRUPTS(CLBR_NONE)
  1210. xorl %esi,%esi /* arg2: oldset */
  1211. movq %rsp,%rdi /* arg1: &pt_regs */
  1212. call do_notify_resume
  1213. DISABLE_INTERRUPTS(CLBR_NONE)
  1214. TRACE_IRQS_OFF
  1215. jmp paranoid_userspace
  1216. paranoid_schedule:
  1217. TRACE_IRQS_ON
  1218. ENABLE_INTERRUPTS(CLBR_ANY)
  1219. SCHEDULE_USER
  1220. DISABLE_INTERRUPTS(CLBR_ANY)
  1221. TRACE_IRQS_OFF
  1222. jmp paranoid_userspace
  1223. CFI_ENDPROC
  1224. END(paranoid_exit)
  1225. /*
  1226. * Exception entry point. This expects an error code/orig_rax on the stack.
  1227. * returns in "no swapgs flag" in %ebx.
  1228. */
  1229. ENTRY(error_entry)
  1230. XCPT_FRAME
  1231. CFI_ADJUST_CFA_OFFSET 15*8
  1232. /* oldrax contains error code */
  1233. cld
  1234. movq %rdi, RDI+8(%rsp)
  1235. movq %rsi, RSI+8(%rsp)
  1236. movq %rdx, RDX+8(%rsp)
  1237. movq %rcx, RCX+8(%rsp)
  1238. movq %rax, RAX+8(%rsp)
  1239. movq %r8, R8+8(%rsp)
  1240. movq %r9, R9+8(%rsp)
  1241. movq %r10, R10+8(%rsp)
  1242. movq %r11, R11+8(%rsp)
  1243. movq_cfi rbx, RBX+8
  1244. movq %rbp, RBP+8(%rsp)
  1245. movq %r12, R12+8(%rsp)
  1246. movq %r13, R13+8(%rsp)
  1247. movq %r14, R14+8(%rsp)
  1248. movq %r15, R15+8(%rsp)
  1249. xorl %ebx,%ebx
  1250. testl $3,CS+8(%rsp)
  1251. je error_kernelspace
  1252. error_swapgs:
  1253. SWAPGS
  1254. error_sti:
  1255. TRACE_IRQS_OFF
  1256. ret
  1257. /*
  1258. * There are two places in the kernel that can potentially fault with
  1259. * usergs. Handle them here. B stepping K8s sometimes report a
  1260. * truncated RIP for IRET exceptions returning to compat mode. Check
  1261. * for these here too.
  1262. */
  1263. error_kernelspace:
  1264. CFI_REL_OFFSET rcx, RCX+8
  1265. incl %ebx
  1266. leaq native_irq_return_iret(%rip),%rcx
  1267. cmpq %rcx,RIP+8(%rsp)
  1268. je error_bad_iret
  1269. movl %ecx,%eax /* zero extend */
  1270. cmpq %rax,RIP+8(%rsp)
  1271. je bstep_iret
  1272. cmpq $gs_change,RIP+8(%rsp)
  1273. je error_swapgs
  1274. jmp error_sti
  1275. bstep_iret:
  1276. /* Fix truncated RIP */
  1277. movq %rcx,RIP+8(%rsp)
  1278. /* fall through */
  1279. error_bad_iret:
  1280. SWAPGS
  1281. mov %rsp,%rdi
  1282. call fixup_bad_iret
  1283. mov %rax,%rsp
  1284. decl %ebx /* Return to usergs */
  1285. jmp error_sti
  1286. CFI_ENDPROC
  1287. END(error_entry)
  1288. /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
  1289. ENTRY(error_exit)
  1290. DEFAULT_FRAME
  1291. movl %ebx,%eax
  1292. RESTORE_REST
  1293. DISABLE_INTERRUPTS(CLBR_NONE)
  1294. TRACE_IRQS_OFF
  1295. GET_THREAD_INFO(%rcx)
  1296. testl %eax,%eax
  1297. jne retint_kernel
  1298. LOCKDEP_SYS_EXIT_IRQ
  1299. movl TI_flags(%rcx),%edx
  1300. movl $_TIF_WORK_MASK,%edi
  1301. andl %edi,%edx
  1302. jnz retint_careful
  1303. jmp retint_swapgs
  1304. CFI_ENDPROC
  1305. END(error_exit)
  1306. /*
  1307. * Test if a given stack is an NMI stack or not.
  1308. */
  1309. .macro test_in_nmi reg stack nmi_ret normal_ret
  1310. cmpq %\reg, \stack
  1311. ja \normal_ret
  1312. subq $EXCEPTION_STKSZ, %\reg
  1313. cmpq %\reg, \stack
  1314. jb \normal_ret
  1315. jmp \nmi_ret
  1316. .endm
  1317. /* runs on exception stack */
  1318. ENTRY(nmi)
  1319. INTR_FRAME
  1320. PARAVIRT_ADJUST_EXCEPTION_FRAME
  1321. /*
  1322. * We allow breakpoints in NMIs. If a breakpoint occurs, then
  1323. * the iretq it performs will take us out of NMI context.
  1324. * This means that we can have nested NMIs where the next
  1325. * NMI is using the top of the stack of the previous NMI. We
  1326. * can't let it execute because the nested NMI will corrupt the
  1327. * stack of the previous NMI. NMI handlers are not re-entrant
  1328. * anyway.
  1329. *
  1330. * To handle this case we do the following:
  1331. * Check the a special location on the stack that contains
  1332. * a variable that is set when NMIs are executing.
  1333. * The interrupted task's stack is also checked to see if it
  1334. * is an NMI stack.
  1335. * If the variable is not set and the stack is not the NMI
  1336. * stack then:
  1337. * o Set the special variable on the stack
  1338. * o Copy the interrupt frame into a "saved" location on the stack
  1339. * o Copy the interrupt frame into a "copy" location on the stack
  1340. * o Continue processing the NMI
  1341. * If the variable is set or the previous stack is the NMI stack:
  1342. * o Modify the "copy" location to jump to the repeate_nmi
  1343. * o return back to the first NMI
  1344. *
  1345. * Now on exit of the first NMI, we first clear the stack variable
  1346. * The NMI stack will tell any nested NMIs at that point that it is
  1347. * nested. Then we pop the stack normally with iret, and if there was
  1348. * a nested NMI that updated the copy interrupt stack frame, a
  1349. * jump will be made to the repeat_nmi code that will handle the second
  1350. * NMI.
  1351. */
  1352. /* Use %rdx as out temp variable throughout */
  1353. pushq_cfi %rdx
  1354. CFI_REL_OFFSET rdx, 0
  1355. /*
  1356. * If %cs was not the kernel segment, then the NMI triggered in user
  1357. * space, which means it is definitely not nested.
  1358. */
  1359. cmpl $__KERNEL_CS, 16(%rsp)
  1360. jne first_nmi
  1361. /*
  1362. * Check the special variable on the stack to see if NMIs are
  1363. * executing.
  1364. */
  1365. cmpl $1, -8(%rsp)
  1366. je nested_nmi
  1367. /*
  1368. * Now test if the previous stack was an NMI stack.
  1369. * We need the double check. We check the NMI stack to satisfy the
  1370. * race when the first NMI clears the variable before returning.
  1371. * We check the variable because the first NMI could be in a
  1372. * breakpoint routine using a breakpoint stack.
  1373. */
  1374. lea 6*8(%rsp), %rdx
  1375. test_in_nmi rdx, 4*8(%rsp), nested_nmi, first_nmi
  1376. CFI_REMEMBER_STATE
  1377. nested_nmi:
  1378. /*
  1379. * Do nothing if we interrupted the fixup in repeat_nmi.
  1380. * It's about to repeat the NMI handler, so we are fine
  1381. * with ignoring this one.
  1382. */
  1383. movq $repeat_nmi, %rdx
  1384. cmpq 8(%rsp), %rdx
  1385. ja 1f
  1386. movq $end_repeat_nmi, %rdx
  1387. cmpq 8(%rsp), %rdx
  1388. ja nested_nmi_out
  1389. 1:
  1390. /* Set up the interrupted NMIs stack to jump to repeat_nmi */
  1391. leaq -1*8(%rsp), %rdx
  1392. movq %rdx, %rsp
  1393. CFI_ADJUST_CFA_OFFSET 1*8
  1394. leaq -10*8(%rsp), %rdx
  1395. pushq_cfi $__KERNEL_DS
  1396. pushq_cfi %rdx
  1397. pushfq_cfi
  1398. pushq_cfi $__KERNEL_CS
  1399. pushq_cfi $repeat_nmi
  1400. /* Put stack back */
  1401. addq $(6*8), %rsp
  1402. CFI_ADJUST_CFA_OFFSET -6*8
  1403. nested_nmi_out:
  1404. popq_cfi %rdx
  1405. CFI_RESTORE rdx
  1406. /* No need to check faults here */
  1407. INTERRUPT_RETURN
  1408. CFI_RESTORE_STATE
  1409. first_nmi:
  1410. /*
  1411. * Because nested NMIs will use the pushed location that we
  1412. * stored in rdx, we must keep that space available.
  1413. * Here's what our stack frame will look like:
  1414. * +-------------------------+
  1415. * | original SS |
  1416. * | original Return RSP |
  1417. * | original RFLAGS |
  1418. * | original CS |
  1419. * | original RIP |
  1420. * +-------------------------+
  1421. * | temp storage for rdx |
  1422. * +-------------------------+
  1423. * | NMI executing variable |
  1424. * +-------------------------+
  1425. * | copied SS |
  1426. * | copied Return RSP |
  1427. * | copied RFLAGS |
  1428. * | copied CS |
  1429. * | copied RIP |
  1430. * +-------------------------+
  1431. * | Saved SS |
  1432. * | Saved Return RSP |
  1433. * | Saved RFLAGS |
  1434. * | Saved CS |
  1435. * | Saved RIP |
  1436. * +-------------------------+
  1437. * | pt_regs |
  1438. * +-------------------------+
  1439. *
  1440. * The saved stack frame is used to fix up the copied stack frame
  1441. * that a nested NMI may change to make the interrupted NMI iret jump
  1442. * to the repeat_nmi. The original stack frame and the temp storage
  1443. * is also used by nested NMIs and can not be trusted on exit.
  1444. */
  1445. /* Do not pop rdx, nested NMIs will corrupt that part of the stack */
  1446. movq (%rsp), %rdx
  1447. CFI_RESTORE rdx
  1448. /* Set the NMI executing variable on the stack. */
  1449. pushq_cfi $1
  1450. /*
  1451. * Leave room for the "copied" frame
  1452. */
  1453. subq $(5*8), %rsp
  1454. CFI_ADJUST_CFA_OFFSET 5*8
  1455. /* Copy the stack frame to the Saved frame */
  1456. .rept 5
  1457. pushq_cfi 11*8(%rsp)
  1458. .endr
  1459. CFI_DEF_CFA_OFFSET SS+8-RIP
  1460. /* Everything up to here is safe from nested NMIs */
  1461. /*
  1462. * If there was a nested NMI, the first NMI's iret will return
  1463. * here. But NMIs are still enabled and we can take another
  1464. * nested NMI. The nested NMI checks the interrupted RIP to see
  1465. * if it is between repeat_nmi and end_repeat_nmi, and if so
  1466. * it will just return, as we are about to repeat an NMI anyway.
  1467. * This makes it safe to copy to the stack frame that a nested
  1468. * NMI will update.
  1469. */
  1470. repeat_nmi:
  1471. /*
  1472. * Update the stack variable to say we are still in NMI (the update
  1473. * is benign for the non-repeat case, where 1 was pushed just above
  1474. * to this very stack slot).
  1475. */
  1476. movq $1, 10*8(%rsp)
  1477. /* Make another copy, this one may be modified by nested NMIs */
  1478. addq $(10*8), %rsp
  1479. CFI_ADJUST_CFA_OFFSET -10*8
  1480. .rept 5
  1481. pushq_cfi -6*8(%rsp)
  1482. .endr
  1483. subq $(5*8), %rsp
  1484. CFI_DEF_CFA_OFFSET SS+8-RIP
  1485. end_repeat_nmi:
  1486. /*
  1487. * Everything below this point can be preempted by a nested
  1488. * NMI if the first NMI took an exception and reset our iret stack
  1489. * so that we repeat another NMI.
  1490. */
  1491. pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
  1492. subq $ORIG_RAX-R15, %rsp
  1493. CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
  1494. /*
  1495. * Use save_paranoid to handle SWAPGS, but no need to use paranoid_exit
  1496. * as we should not be calling schedule in NMI context.
  1497. * Even with normal interrupts enabled. An NMI should not be
  1498. * setting NEED_RESCHED or anything that normal interrupts and
  1499. * exceptions might do.
  1500. */
  1501. call save_paranoid
  1502. DEFAULT_FRAME 0
  1503. /*
  1504. * Save off the CR2 register. If we take a page fault in the NMI then
  1505. * it could corrupt the CR2 value. If the NMI preempts a page fault
  1506. * handler before it was able to read the CR2 register, and then the
  1507. * NMI itself takes a page fault, the page fault that was preempted
  1508. * will read the information from the NMI page fault and not the
  1509. * origin fault. Save it off and restore it if it changes.
  1510. * Use the r12 callee-saved register.
  1511. */
  1512. movq %cr2, %r12
  1513. /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
  1514. movq %rsp,%rdi
  1515. movq $-1,%rsi
  1516. call do_nmi
  1517. /* Did the NMI take a page fault? Restore cr2 if it did */
  1518. movq %cr2, %rcx
  1519. cmpq %rcx, %r12
  1520. je 1f
  1521. movq %r12, %cr2
  1522. 1:
  1523. testl %ebx,%ebx /* swapgs needed? */
  1524. jnz nmi_restore
  1525. nmi_swapgs:
  1526. SWAPGS_UNSAFE_STACK
  1527. nmi_restore:
  1528. /* Pop the extra iret frame at once */
  1529. RESTORE_ALL 6*8
  1530. /* Clear the NMI executing stack variable */
  1531. movq $0, 5*8(%rsp)
  1532. jmp irq_return
  1533. CFI_ENDPROC
  1534. END(nmi)
  1535. ENTRY(ignore_sysret)
  1536. CFI_STARTPROC
  1537. mov $-ENOSYS,%eax
  1538. sysret
  1539. CFI_ENDPROC
  1540. END(ignore_sysret)