intvec_64.S 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. /*
  2. * Copyright 2011 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. *
  14. * Linux interrupt vectors.
  15. */
  16. #include <linux/linkage.h>
  17. #include <linux/errno.h>
  18. #include <linux/unistd.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/thread_info.h>
  21. #include <asm/irqflags.h>
  22. #include <asm/asm-offsets.h>
  23. #include <asm/types.h>
  24. #include <asm/signal.h>
  25. #include <hv/hypervisor.h>
  26. #include <arch/abi.h>
  27. #include <arch/interrupts.h>
  28. #include <arch/spr_def.h>
  29. #ifdef CONFIG_PREEMPT
  30. # error "No support for kernel preemption currently"
  31. #endif
  32. #define PTREGS_PTR(reg, ptreg) addli reg, sp, C_ABI_SAVE_AREA_SIZE + (ptreg)
  33. #define PTREGS_OFFSET_SYSCALL PTREGS_OFFSET_REG(TREG_SYSCALL_NR)
  34. .macro push_reg reg, ptr=sp, delta=-8
  35. {
  36. st \ptr, \reg
  37. addli \ptr, \ptr, \delta
  38. }
  39. .endm
  40. .macro pop_reg reg, ptr=sp, delta=8
  41. {
  42. ld \reg, \ptr
  43. addli \ptr, \ptr, \delta
  44. }
  45. .endm
  46. .macro pop_reg_zero reg, zreg, ptr=sp, delta=8
  47. {
  48. move \zreg, zero
  49. ld \reg, \ptr
  50. addi \ptr, \ptr, \delta
  51. }
  52. .endm
  53. .macro push_extra_callee_saves reg
  54. PTREGS_PTR(\reg, PTREGS_OFFSET_REG(51))
  55. push_reg r51, \reg
  56. push_reg r50, \reg
  57. push_reg r49, \reg
  58. push_reg r48, \reg
  59. push_reg r47, \reg
  60. push_reg r46, \reg
  61. push_reg r45, \reg
  62. push_reg r44, \reg
  63. push_reg r43, \reg
  64. push_reg r42, \reg
  65. push_reg r41, \reg
  66. push_reg r40, \reg
  67. push_reg r39, \reg
  68. push_reg r38, \reg
  69. push_reg r37, \reg
  70. push_reg r36, \reg
  71. push_reg r35, \reg
  72. push_reg r34, \reg, PTREGS_OFFSET_BASE - PTREGS_OFFSET_REG(34)
  73. .endm
  74. .macro panic str
  75. .pushsection .rodata, "a"
  76. 1:
  77. .asciz "\str"
  78. .popsection
  79. {
  80. moveli r0, hw2_last(1b)
  81. }
  82. {
  83. shl16insli r0, r0, hw1(1b)
  84. }
  85. {
  86. shl16insli r0, r0, hw0(1b)
  87. jal panic
  88. }
  89. .endm
  90. #ifdef __COLLECT_LINKER_FEEDBACK__
  91. .pushsection .text.intvec_feedback,"ax"
  92. intvec_feedback:
  93. .popsection
  94. #endif
  95. /*
  96. * Default interrupt handler.
  97. *
  98. * vecnum is where we'll put this code.
  99. * c_routine is the C routine we'll call.
  100. *
  101. * The C routine is passed two arguments:
  102. * - A pointer to the pt_regs state.
  103. * - The interrupt vector number.
  104. *
  105. * The "processing" argument specifies the code for processing
  106. * the interrupt. Defaults to "handle_interrupt".
  107. */
  108. .macro int_hand vecnum, vecname, c_routine, processing=handle_interrupt
  109. .org (\vecnum << 8)
  110. intvec_\vecname:
  111. /* Temporarily save a register so we have somewhere to work. */
  112. mtspr SPR_SYSTEM_SAVE_K_1, r0
  113. mfspr r0, SPR_EX_CONTEXT_K_1
  114. andi r0, r0, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */
  115. .ifc \vecnum, INT_DOUBLE_FAULT
  116. /*
  117. * For double-faults from user-space, fall through to the normal
  118. * register save and stack setup path. Otherwise, it's the
  119. * hypervisor giving us one last chance to dump diagnostics, and we
  120. * branch to the kernel_double_fault routine to do so.
  121. */
  122. beqz r0, 1f
  123. j _kernel_double_fault
  124. 1:
  125. .else
  126. /*
  127. * If we're coming from user-space, then set sp to the top of
  128. * the kernel stack. Otherwise, assume sp is already valid.
  129. */
  130. {
  131. bnez r0, 0f
  132. move r0, sp
  133. }
  134. .endif
  135. .ifc \c_routine, do_page_fault
  136. /*
  137. * The page_fault handler may be downcalled directly by the
  138. * hypervisor even when Linux is running and has ICS set.
  139. *
  140. * In this case the contents of EX_CONTEXT_K_1 reflect the
  141. * previous fault and can't be relied on to choose whether or
  142. * not to reinitialize the stack pointer. So we add a test
  143. * to see whether SYSTEM_SAVE_K_2 has the high bit set,
  144. * and if so we don't reinitialize sp, since we must be coming
  145. * from Linux. (In fact the precise case is !(val & ~1),
  146. * but any Linux PC has to have the high bit set.)
  147. *
  148. * Note that the hypervisor *always* sets SYSTEM_SAVE_K_2 for
  149. * any path that turns into a downcall to one of our TLB handlers.
  150. *
  151. * FIXME: if we end up never using this path, perhaps we should
  152. * prevent the hypervisor from generating downcalls in this case.
  153. * The advantage of getting a downcall is we can panic in Linux.
  154. */
  155. mfspr r0, SPR_SYSTEM_SAVE_K_2
  156. {
  157. bltz r0, 0f /* high bit in S_S_1_2 is for a PC to use */
  158. move r0, sp
  159. }
  160. .endif
  161. /*
  162. * SYSTEM_SAVE_K_0 holds the cpu number in the low bits, and
  163. * the current stack top in the higher bits. So we recover
  164. * our stack top by just masking off the low bits, then
  165. * point sp at the top aligned address on the actual stack page.
  166. */
  167. mfspr r0, SPR_SYSTEM_SAVE_K_0
  168. mm r0, zero, LOG2_THREAD_SIZE, 63
  169. 0:
  170. /*
  171. * Align the stack mod 64 so we can properly predict what
  172. * cache lines we need to write-hint to reduce memory fetch
  173. * latency as we enter the kernel. The layout of memory is
  174. * as follows, with cache line 0 at the lowest VA, and cache
  175. * line 8 just below the r0 value this "andi" computes.
  176. * Note that we never write to cache line 8, and we skip
  177. * cache lines 1-3 for syscalls.
  178. *
  179. * cache line 8: ptregs padding (two words)
  180. * cache line 7: sp, lr, pc, ex1, faultnum, orig_r0, flags, cmpexch
  181. * cache line 6: r46...r53 (tp)
  182. * cache line 5: r38...r45
  183. * cache line 4: r30...r37
  184. * cache line 3: r22...r29
  185. * cache line 2: r14...r21
  186. * cache line 1: r6...r13
  187. * cache line 0: 2 x frame, r0..r5
  188. */
  189. andi r0, r0, -64
  190. /*
  191. * Push the first four registers on the stack, so that we can set
  192. * them to vector-unique values before we jump to the common code.
  193. *
  194. * Registers are pushed on the stack as a struct pt_regs,
  195. * with the sp initially just above the struct, and when we're
  196. * done, sp points to the base of the struct, minus
  197. * C_ABI_SAVE_AREA_SIZE, so we can directly jal to C code.
  198. *
  199. * This routine saves just the first four registers, plus the
  200. * stack context so we can do proper backtracing right away,
  201. * and defers to handle_interrupt to save the rest.
  202. * The backtracer needs pc, ex1, lr, sp, r52, and faultnum.
  203. */
  204. addli r0, r0, PTREGS_OFFSET_LR - (PTREGS_SIZE + KSTK_PTREGS_GAP)
  205. wh64 r0 /* cache line 7 */
  206. {
  207. st r0, lr
  208. addli r0, r0, PTREGS_OFFSET_SP - PTREGS_OFFSET_LR
  209. }
  210. {
  211. st r0, sp
  212. addli sp, r0, PTREGS_OFFSET_REG(52) - PTREGS_OFFSET_SP
  213. }
  214. wh64 sp /* cache line 6 */
  215. {
  216. st sp, r52
  217. addli sp, sp, PTREGS_OFFSET_REG(1) - PTREGS_OFFSET_REG(52)
  218. }
  219. wh64 sp /* cache line 0 */
  220. {
  221. st sp, r1
  222. addli sp, sp, PTREGS_OFFSET_REG(2) - PTREGS_OFFSET_REG(1)
  223. }
  224. {
  225. st sp, r2
  226. addli sp, sp, PTREGS_OFFSET_REG(3) - PTREGS_OFFSET_REG(2)
  227. }
  228. {
  229. st sp, r3
  230. addli sp, sp, PTREGS_OFFSET_PC - PTREGS_OFFSET_REG(3)
  231. }
  232. mfspr r0, SPR_EX_CONTEXT_K_0
  233. .ifc \processing,handle_syscall
  234. /*
  235. * Bump the saved PC by one bundle so that when we return, we won't
  236. * execute the same swint instruction again. We need to do this while
  237. * we're in the critical section.
  238. */
  239. addi r0, r0, 8
  240. .endif
  241. {
  242. st sp, r0
  243. addli sp, sp, PTREGS_OFFSET_EX1 - PTREGS_OFFSET_PC
  244. }
  245. mfspr r0, SPR_EX_CONTEXT_K_1
  246. {
  247. st sp, r0
  248. addi sp, sp, PTREGS_OFFSET_FAULTNUM - PTREGS_OFFSET_EX1
  249. /*
  250. * Use r0 for syscalls so it's a temporary; use r1 for interrupts
  251. * so that it gets passed through unchanged to the handler routine.
  252. * Note that the .if conditional confusingly spans bundles.
  253. */
  254. .ifc \processing,handle_syscall
  255. movei r0, \vecnum
  256. }
  257. {
  258. st sp, r0
  259. .else
  260. movei r1, \vecnum
  261. }
  262. {
  263. st sp, r1
  264. .endif
  265. addli sp, sp, PTREGS_OFFSET_REG(0) - PTREGS_OFFSET_FAULTNUM
  266. }
  267. mfspr r0, SPR_SYSTEM_SAVE_K_1 /* Original r0 */
  268. {
  269. st sp, r0
  270. addi sp, sp, -PTREGS_OFFSET_REG(0) - 8
  271. }
  272. {
  273. st sp, zero /* write zero into "Next SP" frame pointer */
  274. addi sp, sp, -8 /* leave SP pointing at bottom of frame */
  275. }
  276. .ifc \processing,handle_syscall
  277. j handle_syscall
  278. .else
  279. /* Capture per-interrupt SPR context to registers. */
  280. .ifc \c_routine, do_page_fault
  281. mfspr r2, SPR_SYSTEM_SAVE_K_3 /* address of page fault */
  282. mfspr r3, SPR_SYSTEM_SAVE_K_2 /* info about page fault */
  283. .else
  284. .ifc \vecnum, INT_ILL_TRANS
  285. mfspr r2, ILL_TRANS_REASON
  286. .else
  287. .ifc \vecnum, INT_DOUBLE_FAULT
  288. mfspr r2, SPR_SYSTEM_SAVE_K_2 /* double fault info from HV */
  289. .else
  290. .ifc \c_routine, do_trap
  291. mfspr r2, GPV_REASON
  292. .else
  293. .ifc \c_routine, op_handle_perf_interrupt
  294. mfspr r2, PERF_COUNT_STS
  295. #if CHIP_HAS_AUX_PERF_COUNTERS()
  296. .else
  297. .ifc \c_routine, op_handle_aux_perf_interrupt
  298. mfspr r2, AUX_PERF_COUNT_STS
  299. .endif
  300. #endif
  301. .endif
  302. .endif
  303. .endif
  304. .endif
  305. .endif
  306. /* Put function pointer in r0 */
  307. moveli r0, hw2_last(\c_routine)
  308. shl16insli r0, r0, hw1(\c_routine)
  309. {
  310. shl16insli r0, r0, hw0(\c_routine)
  311. j \processing
  312. }
  313. .endif
  314. ENDPROC(intvec_\vecname)
  315. #ifdef __COLLECT_LINKER_FEEDBACK__
  316. .pushsection .text.intvec_feedback,"ax"
  317. .org (\vecnum << 5)
  318. FEEDBACK_ENTER_EXPLICIT(intvec_\vecname, .intrpt1, 1 << 8)
  319. jrp lr
  320. .popsection
  321. #endif
  322. .endm
  323. /*
  324. * Save the rest of the registers that we didn't save in the actual
  325. * vector itself. We can't use r0-r10 inclusive here.
  326. */
  327. .macro finish_interrupt_save, function
  328. /* If it's a syscall, save a proper orig_r0, otherwise just zero. */
  329. PTREGS_PTR(r52, PTREGS_OFFSET_ORIG_R0)
  330. {
  331. .ifc \function,handle_syscall
  332. st r52, r0
  333. .else
  334. st r52, zero
  335. .endif
  336. PTREGS_PTR(r52, PTREGS_OFFSET_TP)
  337. }
  338. st r52, tp
  339. {
  340. mfspr tp, CMPEXCH_VALUE
  341. PTREGS_PTR(r52, PTREGS_OFFSET_CMPEXCH)
  342. }
  343. /*
  344. * For ordinary syscalls, we save neither caller- nor callee-
  345. * save registers, since the syscall invoker doesn't expect the
  346. * caller-saves to be saved, and the called kernel functions will
  347. * take care of saving the callee-saves for us.
  348. *
  349. * For interrupts we save just the caller-save registers. Saving
  350. * them is required (since the "caller" can't save them). Again,
  351. * the called kernel functions will restore the callee-save
  352. * registers for us appropriately.
  353. *
  354. * On return, we normally restore nothing special for syscalls,
  355. * and just the caller-save registers for interrupts.
  356. *
  357. * However, there are some important caveats to all this:
  358. *
  359. * - We always save a few callee-save registers to give us
  360. * some scratchpad registers to carry across function calls.
  361. *
  362. * - fork/vfork/etc require us to save all the callee-save
  363. * registers, which we do in PTREGS_SYSCALL_ALL_REGS, below.
  364. *
  365. * - We always save r0..r5 and r10 for syscalls, since we need
  366. * to reload them a bit later for the actual kernel call, and
  367. * since we might need them for -ERESTARTNOINTR, etc.
  368. *
  369. * - Before invoking a signal handler, we save the unsaved
  370. * callee-save registers so they are visible to the
  371. * signal handler or any ptracer.
  372. *
  373. * - If the unsaved callee-save registers are modified, we set
  374. * a bit in pt_regs so we know to reload them from pt_regs
  375. * and not just rely on the kernel function unwinding.
  376. * (Done for ptrace register writes and SA_SIGINFO handler.)
  377. */
  378. {
  379. st r52, tp
  380. PTREGS_PTR(r52, PTREGS_OFFSET_REG(33))
  381. }
  382. wh64 r52 /* cache line 4 */
  383. push_reg r33, r52
  384. push_reg r32, r52
  385. push_reg r31, r52
  386. .ifc \function,handle_syscall
  387. push_reg r30, r52, PTREGS_OFFSET_SYSCALL - PTREGS_OFFSET_REG(30)
  388. push_reg TREG_SYSCALL_NR_NAME, r52, \
  389. PTREGS_OFFSET_REG(5) - PTREGS_OFFSET_SYSCALL
  390. .else
  391. push_reg r30, r52, PTREGS_OFFSET_REG(29) - PTREGS_OFFSET_REG(30)
  392. wh64 r52 /* cache line 3 */
  393. push_reg r29, r52
  394. push_reg r28, r52
  395. push_reg r27, r52
  396. push_reg r26, r52
  397. push_reg r25, r52
  398. push_reg r24, r52
  399. push_reg r23, r52
  400. push_reg r22, r52
  401. wh64 r52 /* cache line 2 */
  402. push_reg r21, r52
  403. push_reg r20, r52
  404. push_reg r19, r52
  405. push_reg r18, r52
  406. push_reg r17, r52
  407. push_reg r16, r52
  408. push_reg r15, r52
  409. push_reg r14, r52
  410. wh64 r52 /* cache line 1 */
  411. push_reg r13, r52
  412. push_reg r12, r52
  413. push_reg r11, r52
  414. push_reg r10, r52
  415. push_reg r9, r52
  416. push_reg r8, r52
  417. push_reg r7, r52
  418. push_reg r6, r52
  419. .endif
  420. push_reg r5, r52
  421. st r52, r4
  422. /* Load tp with our per-cpu offset. */
  423. #ifdef CONFIG_SMP
  424. {
  425. mfspr r20, SPR_SYSTEM_SAVE_K_0
  426. moveli r21, hw2_last(__per_cpu_offset)
  427. }
  428. {
  429. shl16insli r21, r21, hw1(__per_cpu_offset)
  430. bfextu r20, r20, 0, LOG2_THREAD_SIZE-1
  431. }
  432. shl16insli r21, r21, hw0(__per_cpu_offset)
  433. shl3add r20, r20, r21
  434. ld tp, r20
  435. #else
  436. move tp, zero
  437. #endif
  438. /*
  439. * If we will be returning to the kernel, we will need to
  440. * reset the interrupt masks to the state they had before.
  441. * Set DISABLE_IRQ in flags iff we came from PL1 with irqs disabled.
  442. */
  443. mfspr r32, SPR_EX_CONTEXT_K_1
  444. {
  445. andi r32, r32, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */
  446. PTREGS_PTR(r21, PTREGS_OFFSET_FLAGS)
  447. }
  448. beqzt r32, 1f /* zero if from user space */
  449. IRQS_DISABLED(r32) /* zero if irqs enabled */
  450. #if PT_FLAGS_DISABLE_IRQ != 1
  451. # error Value of IRQS_DISABLED used to set PT_FLAGS_DISABLE_IRQ; fix
  452. #endif
  453. 1:
  454. .ifnc \function,handle_syscall
  455. /* Record the fact that we saved the caller-save registers above. */
  456. ori r32, r32, PT_FLAGS_CALLER_SAVES
  457. .endif
  458. st r21, r32
  459. #ifdef __COLLECT_LINKER_FEEDBACK__
  460. /*
  461. * Notify the feedback routines that we were in the
  462. * appropriate fixed interrupt vector area. Note that we
  463. * still have ICS set at this point, so we can't invoke any
  464. * atomic operations or we will panic. The feedback
  465. * routines internally preserve r0..r10 and r30 up.
  466. */
  467. .ifnc \function,handle_syscall
  468. shli r20, r1, 5
  469. .else
  470. moveli r20, INT_SWINT_1 << 5
  471. .endif
  472. moveli r21, hw2_last(intvec_feedback)
  473. shl16insli r21, r21, hw1(intvec_feedback)
  474. shl16insli r21, r21, hw0(intvec_feedback)
  475. add r20, r20, r21
  476. jalr r20
  477. /* And now notify the feedback routines that we are here. */
  478. FEEDBACK_ENTER(\function)
  479. #endif
  480. /*
  481. * we've captured enough state to the stack (including in
  482. * particular our EX_CONTEXT state) that we can now release
  483. * the interrupt critical section and replace it with our
  484. * standard "interrupts disabled" mask value. This allows
  485. * synchronous interrupts (and profile interrupts) to punch
  486. * through from this point onwards.
  487. */
  488. .ifc \function,handle_nmi
  489. IRQ_DISABLE_ALL(r20)
  490. .else
  491. IRQ_DISABLE(r20, r21)
  492. .endif
  493. mtspr INTERRUPT_CRITICAL_SECTION, zero
  494. /*
  495. * Prepare the first 256 stack bytes to be rapidly accessible
  496. * without having to fetch the background data.
  497. */
  498. addi r52, sp, -64
  499. {
  500. wh64 r52
  501. addi r52, r52, -64
  502. }
  503. {
  504. wh64 r52
  505. addi r52, r52, -64
  506. }
  507. {
  508. wh64 r52
  509. addi r52, r52, -64
  510. }
  511. wh64 r52
  512. #ifdef CONFIG_TRACE_IRQFLAGS
  513. .ifnc \function,handle_nmi
  514. /*
  515. * We finally have enough state set up to notify the irq
  516. * tracing code that irqs were disabled on entry to the handler.
  517. * The TRACE_IRQS_OFF call clobbers registers r0-r29.
  518. * For syscalls, we already have the register state saved away
  519. * on the stack, so we don't bother to do any register saves here,
  520. * and later we pop the registers back off the kernel stack.
  521. * For interrupt handlers, save r0-r3 in callee-saved registers.
  522. */
  523. .ifnc \function,handle_syscall
  524. { move r30, r0; move r31, r1 }
  525. { move r32, r2; move r33, r3 }
  526. .endif
  527. TRACE_IRQS_OFF
  528. .ifnc \function,handle_syscall
  529. { move r0, r30; move r1, r31 }
  530. { move r2, r32; move r3, r33 }
  531. .endif
  532. .endif
  533. #endif
  534. .endm
  535. /*
  536. * Redispatch a downcall.
  537. */
  538. .macro dc_dispatch vecnum, vecname
  539. .org (\vecnum << 8)
  540. intvec_\vecname:
  541. j hv_downcall_dispatch
  542. ENDPROC(intvec_\vecname)
  543. .endm
  544. /*
  545. * Common code for most interrupts. The C function we're eventually
  546. * going to is in r0, and the faultnum is in r1; the original
  547. * values for those registers are on the stack.
  548. */
  549. .pushsection .text.handle_interrupt,"ax"
  550. handle_interrupt:
  551. finish_interrupt_save handle_interrupt
  552. /* Jump to the C routine; it should enable irqs as soon as possible. */
  553. {
  554. jalr r0
  555. PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
  556. }
  557. FEEDBACK_REENTER(handle_interrupt)
  558. {
  559. movei r30, 0 /* not an NMI */
  560. j interrupt_return
  561. }
  562. STD_ENDPROC(handle_interrupt)
  563. /*
  564. * This routine takes a boolean in r30 indicating if this is an NMI.
  565. * If so, we also expect a boolean in r31 indicating whether to
  566. * re-enable the oprofile interrupts.
  567. *
  568. * Note that .Lresume_userspace is jumped to directly in several
  569. * places, and we need to make sure r30 is set correctly in those
  570. * callers as well.
  571. */
  572. STD_ENTRY(interrupt_return)
  573. /* If we're resuming to kernel space, don't check thread flags. */
  574. {
  575. bnez r30, .Lrestore_all /* NMIs don't special-case user-space */
  576. PTREGS_PTR(r29, PTREGS_OFFSET_EX1)
  577. }
  578. ld r29, r29
  579. andi r29, r29, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */
  580. {
  581. beqzt r29, .Lresume_userspace
  582. PTREGS_PTR(r29, PTREGS_OFFSET_PC)
  583. }
  584. /* If we're resuming to _cpu_idle_nap, bump PC forward by 8. */
  585. moveli r27, hw2_last(_cpu_idle_nap)
  586. {
  587. ld r28, r29
  588. shl16insli r27, r27, hw1(_cpu_idle_nap)
  589. }
  590. {
  591. shl16insli r27, r27, hw0(_cpu_idle_nap)
  592. }
  593. {
  594. cmpeq r27, r27, r28
  595. }
  596. {
  597. blbc r27, .Lrestore_all
  598. addi r28, r28, 8
  599. }
  600. st r29, r28
  601. j .Lrestore_all
  602. .Lresume_userspace:
  603. FEEDBACK_REENTER(interrupt_return)
  604. /*
  605. * Disable interrupts so as to make sure we don't
  606. * miss an interrupt that sets any of the thread flags (like
  607. * need_resched or sigpending) between sampling and the iret.
  608. * Routines like schedule() or do_signal() may re-enable
  609. * interrupts before returning.
  610. */
  611. IRQ_DISABLE(r20, r21)
  612. TRACE_IRQS_OFF /* Note: clobbers registers r0-r29 */
  613. /* Get base of stack in r32; note r30/31 are used as arguments here. */
  614. GET_THREAD_INFO(r32)
  615. /* Check to see if there is any work to do before returning to user. */
  616. {
  617. addi r29, r32, THREAD_INFO_FLAGS_OFFSET
  618. moveli r1, hw1_last(_TIF_ALLWORK_MASK)
  619. }
  620. {
  621. ld r29, r29
  622. shl16insli r1, r1, hw0(_TIF_ALLWORK_MASK)
  623. }
  624. and r1, r29, r1
  625. beqzt r1, .Lrestore_all
  626. /*
  627. * Make sure we have all the registers saved for signal
  628. * handling or single-step. Call out to C code to figure out
  629. * exactly what we need to do for each flag bit, then if
  630. * necessary, reload the flags and recheck.
  631. */
  632. push_extra_callee_saves r0
  633. {
  634. PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
  635. jal do_work_pending
  636. }
  637. bnez r0, .Lresume_userspace
  638. /*
  639. * In the NMI case we
  640. * omit the call to single_process_check_nohz, which normally checks
  641. * to see if we should start or stop the scheduler tick, because
  642. * we can't call arbitrary Linux code from an NMI context.
  643. * We always call the homecache TLB deferral code to re-trigger
  644. * the deferral mechanism.
  645. *
  646. * The other chunk of responsibility this code has is to reset the
  647. * interrupt masks appropriately to reset irqs and NMIs. We have
  648. * to call TRACE_IRQS_OFF and TRACE_IRQS_ON to support all the
  649. * lockdep-type stuff, but we can't set ICS until afterwards, since
  650. * ICS can only be used in very tight chunks of code to avoid
  651. * tripping over various assertions that it is off.
  652. */
  653. .Lrestore_all:
  654. PTREGS_PTR(r0, PTREGS_OFFSET_EX1)
  655. {
  656. ld r0, r0
  657. PTREGS_PTR(r32, PTREGS_OFFSET_FLAGS)
  658. }
  659. {
  660. andi r0, r0, SPR_EX_CONTEXT_1_1__PL_MASK
  661. ld r32, r32
  662. }
  663. bnez r0, 1f
  664. j 2f
  665. #if PT_FLAGS_DISABLE_IRQ != 1
  666. # error Assuming PT_FLAGS_DISABLE_IRQ == 1 so we can use blbct below
  667. #endif
  668. 1: blbct r32, 2f
  669. IRQ_DISABLE(r20,r21)
  670. TRACE_IRQS_OFF
  671. movei r0, 1
  672. mtspr INTERRUPT_CRITICAL_SECTION, r0
  673. beqzt r30, .Lrestore_regs
  674. j 3f
  675. 2: TRACE_IRQS_ON
  676. movei r0, 1
  677. mtspr INTERRUPT_CRITICAL_SECTION, r0
  678. IRQ_ENABLE(r20, r21)
  679. beqzt r30, .Lrestore_regs
  680. 3:
  681. /*
  682. * We now commit to returning from this interrupt, since we will be
  683. * doing things like setting EX_CONTEXT SPRs and unwinding the stack
  684. * frame. No calls should be made to any other code after this point.
  685. * This code should only be entered with ICS set.
  686. * r32 must still be set to ptregs.flags.
  687. * We launch loads to each cache line separately first, so we can
  688. * get some parallelism out of the memory subsystem.
  689. * We start zeroing caller-saved registers throughout, since
  690. * that will save some cycles if this turns out to be a syscall.
  691. */
  692. .Lrestore_regs:
  693. FEEDBACK_REENTER(interrupt_return) /* called from elsewhere */
  694. /*
  695. * Rotate so we have one high bit and one low bit to test.
  696. * - low bit says whether to restore all the callee-saved registers,
  697. * or just r30-r33, and r52 up.
  698. * - high bit (i.e. sign bit) says whether to restore all the
  699. * caller-saved registers, or just r0.
  700. */
  701. #if PT_FLAGS_CALLER_SAVES != 2 || PT_FLAGS_RESTORE_REGS != 4
  702. # error Rotate trick does not work :-)
  703. #endif
  704. {
  705. rotli r20, r32, 62
  706. PTREGS_PTR(sp, PTREGS_OFFSET_REG(0))
  707. }
  708. /*
  709. * Load cache lines 0, 4, 6 and 7, in that order, then use
  710. * the last loaded value, which makes it likely that the other
  711. * cache lines have also loaded, at which point we should be
  712. * able to safely read all the remaining words on those cache
  713. * lines without waiting for the memory subsystem.
  714. */
  715. pop_reg r0, sp, PTREGS_OFFSET_REG(30) - PTREGS_OFFSET_REG(0)
  716. pop_reg r30, sp, PTREGS_OFFSET_REG(52) - PTREGS_OFFSET_REG(30)
  717. pop_reg_zero r52, r3, sp, PTREGS_OFFSET_CMPEXCH - PTREGS_OFFSET_REG(52)
  718. pop_reg_zero r21, r27, sp, PTREGS_OFFSET_EX1 - PTREGS_OFFSET_CMPEXCH
  719. pop_reg_zero lr, r2, sp, PTREGS_OFFSET_PC - PTREGS_OFFSET_EX1
  720. {
  721. mtspr CMPEXCH_VALUE, r21
  722. move r4, zero
  723. }
  724. pop_reg r21, sp, PTREGS_OFFSET_REG(31) - PTREGS_OFFSET_PC
  725. {
  726. mtspr SPR_EX_CONTEXT_K_1, lr
  727. andi lr, lr, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */
  728. }
  729. {
  730. mtspr SPR_EX_CONTEXT_K_0, r21
  731. move r5, zero
  732. }
  733. /* Restore callee-saveds that we actually use. */
  734. pop_reg_zero r31, r6
  735. pop_reg_zero r32, r7
  736. pop_reg_zero r33, r8, sp, PTREGS_OFFSET_REG(29) - PTREGS_OFFSET_REG(33)
  737. /*
  738. * If we modified other callee-saveds, restore them now.
  739. * This is rare, but could be via ptrace or signal handler.
  740. */
  741. {
  742. move r9, zero
  743. blbs r20, .Lrestore_callees
  744. }
  745. .Lcontinue_restore_regs:
  746. /* Check if we're returning from a syscall. */
  747. {
  748. move r10, zero
  749. bltzt r20, 1f /* no, so go restore callee-save registers */
  750. }
  751. /*
  752. * Check if we're returning to userspace.
  753. * Note that if we're not, we don't worry about zeroing everything.
  754. */
  755. {
  756. addli sp, sp, PTREGS_OFFSET_LR - PTREGS_OFFSET_REG(29)
  757. bnez lr, .Lkernel_return
  758. }
  759. /*
  760. * On return from syscall, we've restored r0 from pt_regs, but we
  761. * clear the remainder of the caller-saved registers. We could
  762. * restore the syscall arguments, but there's not much point,
  763. * and it ensures user programs aren't trying to use the
  764. * caller-saves if we clear them, as well as avoiding leaking
  765. * kernel pointers into userspace.
  766. */
  767. pop_reg_zero lr, r11, sp, PTREGS_OFFSET_TP - PTREGS_OFFSET_LR
  768. pop_reg_zero tp, r12, sp, PTREGS_OFFSET_SP - PTREGS_OFFSET_TP
  769. {
  770. ld sp, sp
  771. move r13, zero
  772. move r14, zero
  773. }
  774. { move r15, zero; move r16, zero }
  775. { move r17, zero; move r18, zero }
  776. { move r19, zero; move r20, zero }
  777. { move r21, zero; move r22, zero }
  778. { move r23, zero; move r24, zero }
  779. { move r25, zero; move r26, zero }
  780. /* Set r1 to errno if we are returning an error, otherwise zero. */
  781. {
  782. moveli r29, 4096
  783. sub r1, zero, r0
  784. }
  785. {
  786. move r28, zero
  787. cmpltu r29, r1, r29
  788. }
  789. {
  790. mnz r1, r29, r1
  791. move r29, zero
  792. }
  793. iret
  794. /*
  795. * Not a syscall, so restore caller-saved registers.
  796. * First kick off loads for cache lines 1-3, which we're touching
  797. * for the first time here.
  798. */
  799. .align 64
  800. 1: pop_reg r29, sp, PTREGS_OFFSET_REG(21) - PTREGS_OFFSET_REG(29)
  801. pop_reg r21, sp, PTREGS_OFFSET_REG(13) - PTREGS_OFFSET_REG(21)
  802. pop_reg r13, sp, PTREGS_OFFSET_REG(1) - PTREGS_OFFSET_REG(13)
  803. pop_reg r1
  804. pop_reg r2
  805. pop_reg r3
  806. pop_reg r4
  807. pop_reg r5
  808. pop_reg r6
  809. pop_reg r7
  810. pop_reg r8
  811. pop_reg r9
  812. pop_reg r10
  813. pop_reg r11
  814. pop_reg r12, sp, 16
  815. /* r13 already restored above */
  816. pop_reg r14
  817. pop_reg r15
  818. pop_reg r16
  819. pop_reg r17
  820. pop_reg r18
  821. pop_reg r19
  822. pop_reg r20, sp, 16
  823. /* r21 already restored above */
  824. pop_reg r22
  825. pop_reg r23
  826. pop_reg r24
  827. pop_reg r25
  828. pop_reg r26
  829. pop_reg r27
  830. pop_reg r28, sp, PTREGS_OFFSET_LR - PTREGS_OFFSET_REG(28)
  831. /* r29 already restored above */
  832. bnez lr, .Lkernel_return
  833. pop_reg lr, sp, PTREGS_OFFSET_TP - PTREGS_OFFSET_LR
  834. pop_reg tp, sp, PTREGS_OFFSET_SP - PTREGS_OFFSET_TP
  835. ld sp, sp
  836. iret
  837. /*
  838. * We can't restore tp when in kernel mode, since a thread might
  839. * have migrated from another cpu and brought a stale tp value.
  840. */
  841. .Lkernel_return:
  842. pop_reg lr, sp, PTREGS_OFFSET_SP - PTREGS_OFFSET_LR
  843. ld sp, sp
  844. iret
  845. /* Restore callee-saved registers from r34 to r51. */
  846. .Lrestore_callees:
  847. addli sp, sp, PTREGS_OFFSET_REG(34) - PTREGS_OFFSET_REG(29)
  848. pop_reg r34
  849. pop_reg r35
  850. pop_reg r36
  851. pop_reg r37
  852. pop_reg r38
  853. pop_reg r39
  854. pop_reg r40
  855. pop_reg r41
  856. pop_reg r42
  857. pop_reg r43
  858. pop_reg r44
  859. pop_reg r45
  860. pop_reg r46
  861. pop_reg r47
  862. pop_reg r48
  863. pop_reg r49
  864. pop_reg r50
  865. pop_reg r51, sp, PTREGS_OFFSET_REG(29) - PTREGS_OFFSET_REG(51)
  866. j .Lcontinue_restore_regs
  867. STD_ENDPROC(interrupt_return)
  868. /*
  869. * "NMI" interrupts mask ALL interrupts before calling the
  870. * handler, and don't check thread flags, etc., on the way
  871. * back out. In general, the only things we do here for NMIs
  872. * are register save/restore and dataplane kernel-TLB management.
  873. * We don't (for example) deal with start/stop of the sched tick.
  874. */
  875. .pushsection .text.handle_nmi,"ax"
  876. handle_nmi:
  877. finish_interrupt_save handle_nmi
  878. {
  879. jalr r0
  880. PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
  881. }
  882. FEEDBACK_REENTER(handle_nmi)
  883. {
  884. movei r30, 1
  885. move r31, r0
  886. }
  887. j interrupt_return
  888. STD_ENDPROC(handle_nmi)
  889. /*
  890. * Parallel code for syscalls to handle_interrupt.
  891. */
  892. .pushsection .text.handle_syscall,"ax"
  893. handle_syscall:
  894. finish_interrupt_save handle_syscall
  895. /* Enable irqs. */
  896. TRACE_IRQS_ON
  897. IRQ_ENABLE(r20, r21)
  898. /* Bump the counter for syscalls made on this tile. */
  899. moveli r20, hw2_last(irq_stat + IRQ_CPUSTAT_SYSCALL_COUNT_OFFSET)
  900. shl16insli r20, r20, hw1(irq_stat + IRQ_CPUSTAT_SYSCALL_COUNT_OFFSET)
  901. shl16insli r20, r20, hw0(irq_stat + IRQ_CPUSTAT_SYSCALL_COUNT_OFFSET)
  902. add r20, r20, tp
  903. ld4s r21, r20
  904. addi r21, r21, 1
  905. st4 r20, r21
  906. /* Trace syscalls, if requested. */
  907. GET_THREAD_INFO(r31)
  908. addi r31, r31, THREAD_INFO_FLAGS_OFFSET
  909. ld r30, r31
  910. andi r30, r30, _TIF_SYSCALL_TRACE
  911. {
  912. addi r30, r31, THREAD_INFO_STATUS_OFFSET - THREAD_INFO_FLAGS_OFFSET
  913. beqzt r30, .Lrestore_syscall_regs
  914. }
  915. jal do_syscall_trace
  916. FEEDBACK_REENTER(handle_syscall)
  917. /*
  918. * We always reload our registers from the stack at this
  919. * point. They might be valid, if we didn't build with
  920. * TRACE_IRQFLAGS, and this isn't a dataplane tile, and we're not
  921. * doing syscall tracing, but there are enough cases now that it
  922. * seems simplest just to do the reload unconditionally.
  923. */
  924. .Lrestore_syscall_regs:
  925. {
  926. ld r30, r30
  927. PTREGS_PTR(r11, PTREGS_OFFSET_REG(0))
  928. }
  929. pop_reg r0, r11
  930. pop_reg r1, r11
  931. pop_reg r2, r11
  932. pop_reg r3, r11
  933. pop_reg r4, r11
  934. pop_reg r5, r11, PTREGS_OFFSET_SYSCALL - PTREGS_OFFSET_REG(5)
  935. {
  936. ld TREG_SYSCALL_NR_NAME, r11
  937. moveli r21, __NR_syscalls
  938. }
  939. /* Ensure that the syscall number is within the legal range. */
  940. {
  941. moveli r20, hw2(sys_call_table)
  942. blbs r30, .Lcompat_syscall
  943. }
  944. {
  945. cmpltu r21, TREG_SYSCALL_NR_NAME, r21
  946. shl16insli r20, r20, hw1(sys_call_table)
  947. }
  948. {
  949. blbc r21, .Linvalid_syscall
  950. shl16insli r20, r20, hw0(sys_call_table)
  951. }
  952. .Lload_syscall_pointer:
  953. shl3add r20, TREG_SYSCALL_NR_NAME, r20
  954. ld r20, r20
  955. /* Jump to syscall handler. */
  956. jalr r20
  957. .Lhandle_syscall_link: /* value of "lr" after "jalr r20" above */
  958. /*
  959. * Write our r0 onto the stack so it gets restored instead
  960. * of whatever the user had there before.
  961. * In compat mode, sign-extend r0 before storing it.
  962. */
  963. {
  964. PTREGS_PTR(r29, PTREGS_OFFSET_REG(0))
  965. blbct r30, 1f
  966. }
  967. addxi r0, r0, 0
  968. 1: st r29, r0
  969. .Lsyscall_sigreturn_skip:
  970. FEEDBACK_REENTER(handle_syscall)
  971. /* Do syscall trace again, if requested. */
  972. ld r30, r31
  973. andi r0, r30, _TIF_SYSCALL_TRACE
  974. {
  975. andi r0, r30, _TIF_SINGLESTEP
  976. beqzt r0, 1f
  977. }
  978. jal do_syscall_trace
  979. FEEDBACK_REENTER(handle_syscall)
  980. andi r0, r30, _TIF_SINGLESTEP
  981. 1: beqzt r0, 2f
  982. /* Single stepping -- notify ptrace. */
  983. {
  984. movei r0, SIGTRAP
  985. jal ptrace_notify
  986. }
  987. FEEDBACK_REENTER(handle_syscall)
  988. 2: {
  989. movei r30, 0 /* not an NMI */
  990. j .Lresume_userspace /* jump into middle of interrupt_return */
  991. }
  992. .Lcompat_syscall:
  993. /*
  994. * Load the base of the compat syscall table in r20, and
  995. * range-check the syscall number (duplicated from 64-bit path).
  996. * Sign-extend all the user's passed arguments to make them consistent.
  997. * Also save the original "r(n)" values away in "r(11+n)" in
  998. * case the syscall table entry wants to validate them.
  999. */
  1000. moveli r20, hw2(compat_sys_call_table)
  1001. {
  1002. cmpltu r21, TREG_SYSCALL_NR_NAME, r21
  1003. shl16insli r20, r20, hw1(compat_sys_call_table)
  1004. }
  1005. {
  1006. blbc r21, .Linvalid_syscall
  1007. shl16insli r20, r20, hw0(compat_sys_call_table)
  1008. }
  1009. { move r11, r0; addxi r0, r0, 0 }
  1010. { move r12, r1; addxi r1, r1, 0 }
  1011. { move r13, r2; addxi r2, r2, 0 }
  1012. { move r14, r3; addxi r3, r3, 0 }
  1013. { move r15, r4; addxi r4, r4, 0 }
  1014. { move r16, r5; addxi r5, r5, 0 }
  1015. j .Lload_syscall_pointer
  1016. .Linvalid_syscall:
  1017. /* Report an invalid syscall back to the user program */
  1018. {
  1019. PTREGS_PTR(r29, PTREGS_OFFSET_REG(0))
  1020. movei r28, -ENOSYS
  1021. }
  1022. st r29, r28
  1023. {
  1024. movei r30, 0 /* not an NMI */
  1025. j .Lresume_userspace /* jump into middle of interrupt_return */
  1026. }
  1027. STD_ENDPROC(handle_syscall)
  1028. /* Return the address for oprofile to suppress in backtraces. */
  1029. STD_ENTRY_SECTION(handle_syscall_link_address, .text.handle_syscall)
  1030. lnk r0
  1031. {
  1032. addli r0, r0, .Lhandle_syscall_link - .
  1033. jrp lr
  1034. }
  1035. STD_ENDPROC(handle_syscall_link_address)
  1036. STD_ENTRY(ret_from_fork)
  1037. jal sim_notify_fork
  1038. jal schedule_tail
  1039. FEEDBACK_REENTER(ret_from_fork)
  1040. {
  1041. movei r30, 0 /* not an NMI */
  1042. j .Lresume_userspace /* jump into middle of interrupt_return */
  1043. }
  1044. STD_ENDPROC(ret_from_fork)
  1045. /* Various stub interrupt handlers and syscall handlers */
  1046. STD_ENTRY_LOCAL(_kernel_double_fault)
  1047. mfspr r1, SPR_EX_CONTEXT_K_0
  1048. move r2, lr
  1049. move r3, sp
  1050. move r4, r52
  1051. addi sp, sp, -C_ABI_SAVE_AREA_SIZE
  1052. j kernel_double_fault
  1053. STD_ENDPROC(_kernel_double_fault)
  1054. STD_ENTRY_LOCAL(bad_intr)
  1055. mfspr r2, SPR_EX_CONTEXT_K_0
  1056. panic "Unhandled interrupt %#x: PC %#lx"
  1057. STD_ENDPROC(bad_intr)
  1058. /* Put address of pt_regs in reg and jump. */
  1059. #define PTREGS_SYSCALL(x, reg) \
  1060. STD_ENTRY(_##x); \
  1061. { \
  1062. PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \
  1063. j x \
  1064. }; \
  1065. STD_ENDPROC(_##x)
  1066. /*
  1067. * Special-case sigreturn to not write r0 to the stack on return.
  1068. * This is technically more efficient, but it also avoids difficulties
  1069. * in the 64-bit OS when handling 32-bit compat code, since we must not
  1070. * sign-extend r0 for the sigreturn return-value case.
  1071. */
  1072. #define PTREGS_SYSCALL_SIGRETURN(x, reg) \
  1073. STD_ENTRY(_##x); \
  1074. addli lr, lr, .Lsyscall_sigreturn_skip - .Lhandle_syscall_link; \
  1075. { \
  1076. PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \
  1077. j x \
  1078. }; \
  1079. STD_ENDPROC(_##x)
  1080. PTREGS_SYSCALL(sys_execve, r3)
  1081. PTREGS_SYSCALL(sys_sigaltstack, r2)
  1082. PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0)
  1083. #ifdef CONFIG_COMPAT
  1084. PTREGS_SYSCALL(compat_sys_execve, r3)
  1085. PTREGS_SYSCALL(compat_sys_sigaltstack, r2)
  1086. PTREGS_SYSCALL_SIGRETURN(compat_sys_rt_sigreturn, r0)
  1087. #endif
  1088. /* Save additional callee-saves to pt_regs, put address in r4 and jump. */
  1089. STD_ENTRY(_sys_clone)
  1090. push_extra_callee_saves r4
  1091. j sys_clone
  1092. STD_ENDPROC(_sys_clone)
  1093. /* The single-step support may need to read all the registers. */
  1094. int_unalign:
  1095. push_extra_callee_saves r0
  1096. j do_trap
  1097. /* Fill the return address stack with nonzero entries. */
  1098. STD_ENTRY(fill_ra_stack)
  1099. {
  1100. move r0, lr
  1101. jal 1f
  1102. }
  1103. 1: jal 2f
  1104. 2: jal 3f
  1105. 3: jal 4f
  1106. 4: jrp r0
  1107. STD_ENDPROC(fill_ra_stack)
  1108. /* Include .intrpt1 array of interrupt vectors */
  1109. .section ".intrpt1", "ax"
  1110. #define op_handle_perf_interrupt bad_intr
  1111. #define op_handle_aux_perf_interrupt bad_intr
  1112. #ifndef CONFIG_HARDWALL
  1113. #define do_hardwall_trap bad_intr
  1114. #endif
  1115. int_hand INT_MEM_ERROR, MEM_ERROR, do_trap
  1116. int_hand INT_SINGLE_STEP_3, SINGLE_STEP_3, bad_intr
  1117. #if CONFIG_KERNEL_PL == 2
  1118. int_hand INT_SINGLE_STEP_2, SINGLE_STEP_2, gx_singlestep_handle
  1119. int_hand INT_SINGLE_STEP_1, SINGLE_STEP_1, bad_intr
  1120. #else
  1121. int_hand INT_SINGLE_STEP_2, SINGLE_STEP_2, bad_intr
  1122. int_hand INT_SINGLE_STEP_1, SINGLE_STEP_1, gx_singlestep_handle
  1123. #endif
  1124. int_hand INT_SINGLE_STEP_0, SINGLE_STEP_0, bad_intr
  1125. int_hand INT_IDN_COMPLETE, IDN_COMPLETE, bad_intr
  1126. int_hand INT_UDN_COMPLETE, UDN_COMPLETE, bad_intr
  1127. int_hand INT_ITLB_MISS, ITLB_MISS, do_page_fault
  1128. int_hand INT_ILL, ILL, do_trap
  1129. int_hand INT_GPV, GPV, do_trap
  1130. int_hand INT_IDN_ACCESS, IDN_ACCESS, do_trap
  1131. int_hand INT_UDN_ACCESS, UDN_ACCESS, do_trap
  1132. int_hand INT_SWINT_3, SWINT_3, do_trap
  1133. int_hand INT_SWINT_2, SWINT_2, do_trap
  1134. int_hand INT_SWINT_1, SWINT_1, SYSCALL, handle_syscall
  1135. int_hand INT_SWINT_0, SWINT_0, do_trap
  1136. int_hand INT_ILL_TRANS, ILL_TRANS, do_trap
  1137. int_hand INT_UNALIGN_DATA, UNALIGN_DATA, int_unalign
  1138. int_hand INT_DTLB_MISS, DTLB_MISS, do_page_fault
  1139. int_hand INT_DTLB_ACCESS, DTLB_ACCESS, do_page_fault
  1140. int_hand INT_IDN_FIREWALL, IDN_FIREWALL, bad_intr
  1141. int_hand INT_UDN_FIREWALL, UDN_FIREWALL, do_hardwall_trap
  1142. int_hand INT_TILE_TIMER, TILE_TIMER, do_timer_interrupt
  1143. int_hand INT_IDN_TIMER, IDN_TIMER, bad_intr
  1144. int_hand INT_UDN_TIMER, UDN_TIMER, bad_intr
  1145. int_hand INT_IDN_AVAIL, IDN_AVAIL, bad_intr
  1146. int_hand INT_UDN_AVAIL, UDN_AVAIL, bad_intr
  1147. int_hand INT_IPI_3, IPI_3, bad_intr
  1148. #if CONFIG_KERNEL_PL == 2
  1149. int_hand INT_IPI_2, IPI_2, tile_dev_intr
  1150. int_hand INT_IPI_1, IPI_1, bad_intr
  1151. #else
  1152. int_hand INT_IPI_2, IPI_2, bad_intr
  1153. int_hand INT_IPI_1, IPI_1, tile_dev_intr
  1154. #endif
  1155. int_hand INT_IPI_0, IPI_0, bad_intr
  1156. int_hand INT_PERF_COUNT, PERF_COUNT, \
  1157. op_handle_perf_interrupt, handle_nmi
  1158. int_hand INT_AUX_PERF_COUNT, AUX_PERF_COUNT, \
  1159. op_handle_perf_interrupt, handle_nmi
  1160. int_hand INT_INTCTRL_3, INTCTRL_3, bad_intr
  1161. #if CONFIG_KERNEL_PL == 2
  1162. dc_dispatch INT_INTCTRL_2, INTCTRL_2
  1163. int_hand INT_INTCTRL_1, INTCTRL_1, bad_intr
  1164. #else
  1165. int_hand INT_INTCTRL_2, INTCTRL_2, bad_intr
  1166. dc_dispatch INT_INTCTRL_1, INTCTRL_1
  1167. #endif
  1168. int_hand INT_INTCTRL_0, INTCTRL_0, bad_intr
  1169. int_hand INT_MESSAGE_RCV_DWNCL, MESSAGE_RCV_DWNCL, \
  1170. hv_message_intr
  1171. int_hand INT_DEV_INTR_DWNCL, DEV_INTR_DWNCL, bad_intr
  1172. int_hand INT_I_ASID, I_ASID, bad_intr
  1173. int_hand INT_D_ASID, D_ASID, bad_intr
  1174. int_hand INT_DOUBLE_FAULT, DOUBLE_FAULT, do_trap
  1175. /* Synthetic interrupt delivered only by the simulator */
  1176. int_hand INT_BREAKPOINT, BREAKPOINT, do_breakpoint