intvec_64.S 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  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. * Use r33 to hold whether we have already loaded the callee-saves
  606. * into ptregs. We don't want to do it twice in this loop, since
  607. * then we'd clobber whatever changes are made by ptrace, etc.
  608. */
  609. {
  610. movei r33, 0
  611. move r32, sp
  612. }
  613. /* Get base of stack in r32. */
  614. EXTRACT_THREAD_INFO(r32)
  615. .Lretry_work_pending:
  616. /*
  617. * Disable interrupts so as to make sure we don't
  618. * miss an interrupt that sets any of the thread flags (like
  619. * need_resched or sigpending) between sampling and the iret.
  620. * Routines like schedule() or do_signal() may re-enable
  621. * interrupts before returning.
  622. */
  623. IRQ_DISABLE(r20, r21)
  624. TRACE_IRQS_OFF /* Note: clobbers registers r0-r29 */
  625. /* Check to see if there is any work to do before returning to user. */
  626. {
  627. addi r29, r32, THREAD_INFO_FLAGS_OFFSET
  628. moveli r1, hw1_last(_TIF_ALLWORK_MASK)
  629. }
  630. {
  631. ld r29, r29
  632. shl16insli r1, r1, hw0(_TIF_ALLWORK_MASK)
  633. }
  634. and r1, r29, r1
  635. beqzt r1, .Lrestore_all
  636. /*
  637. * Make sure we have all the registers saved for signal
  638. * handling or notify-resume. Call out to C code to figure out
  639. * exactly what we need to do for each flag bit, then if
  640. * necessary, reload the flags and recheck.
  641. */
  642. {
  643. PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
  644. bnez r33, 1f
  645. }
  646. push_extra_callee_saves r0
  647. movei r33, 1
  648. 1: jal do_work_pending
  649. bnez r0, .Lretry_work_pending
  650. /*
  651. * In the NMI case we
  652. * omit the call to single_process_check_nohz, which normally checks
  653. * to see if we should start or stop the scheduler tick, because
  654. * we can't call arbitrary Linux code from an NMI context.
  655. * We always call the homecache TLB deferral code to re-trigger
  656. * the deferral mechanism.
  657. *
  658. * The other chunk of responsibility this code has is to reset the
  659. * interrupt masks appropriately to reset irqs and NMIs. We have
  660. * to call TRACE_IRQS_OFF and TRACE_IRQS_ON to support all the
  661. * lockdep-type stuff, but we can't set ICS until afterwards, since
  662. * ICS can only be used in very tight chunks of code to avoid
  663. * tripping over various assertions that it is off.
  664. */
  665. .Lrestore_all:
  666. PTREGS_PTR(r0, PTREGS_OFFSET_EX1)
  667. {
  668. ld r0, r0
  669. PTREGS_PTR(r32, PTREGS_OFFSET_FLAGS)
  670. }
  671. {
  672. andi r0, r0, SPR_EX_CONTEXT_1_1__PL_MASK
  673. ld r32, r32
  674. }
  675. bnez r0, 1f
  676. j 2f
  677. #if PT_FLAGS_DISABLE_IRQ != 1
  678. # error Assuming PT_FLAGS_DISABLE_IRQ == 1 so we can use blbct below
  679. #endif
  680. 1: blbct r32, 2f
  681. IRQ_DISABLE(r20,r21)
  682. TRACE_IRQS_OFF
  683. movei r0, 1
  684. mtspr INTERRUPT_CRITICAL_SECTION, r0
  685. beqzt r30, .Lrestore_regs
  686. j 3f
  687. 2: TRACE_IRQS_ON
  688. movei r0, 1
  689. mtspr INTERRUPT_CRITICAL_SECTION, r0
  690. IRQ_ENABLE(r20, r21)
  691. beqzt r30, .Lrestore_regs
  692. 3:
  693. /*
  694. * We now commit to returning from this interrupt, since we will be
  695. * doing things like setting EX_CONTEXT SPRs and unwinding the stack
  696. * frame. No calls should be made to any other code after this point.
  697. * This code should only be entered with ICS set.
  698. * r32 must still be set to ptregs.flags.
  699. * We launch loads to each cache line separately first, so we can
  700. * get some parallelism out of the memory subsystem.
  701. * We start zeroing caller-saved registers throughout, since
  702. * that will save some cycles if this turns out to be a syscall.
  703. */
  704. .Lrestore_regs:
  705. FEEDBACK_REENTER(interrupt_return) /* called from elsewhere */
  706. /*
  707. * Rotate so we have one high bit and one low bit to test.
  708. * - low bit says whether to restore all the callee-saved registers,
  709. * or just r30-r33, and r52 up.
  710. * - high bit (i.e. sign bit) says whether to restore all the
  711. * caller-saved registers, or just r0.
  712. */
  713. #if PT_FLAGS_CALLER_SAVES != 2 || PT_FLAGS_RESTORE_REGS != 4
  714. # error Rotate trick does not work :-)
  715. #endif
  716. {
  717. rotli r20, r32, 62
  718. PTREGS_PTR(sp, PTREGS_OFFSET_REG(0))
  719. }
  720. /*
  721. * Load cache lines 0, 4, 6 and 7, in that order, then use
  722. * the last loaded value, which makes it likely that the other
  723. * cache lines have also loaded, at which point we should be
  724. * able to safely read all the remaining words on those cache
  725. * lines without waiting for the memory subsystem.
  726. */
  727. pop_reg r0, sp, PTREGS_OFFSET_REG(30) - PTREGS_OFFSET_REG(0)
  728. pop_reg r30, sp, PTREGS_OFFSET_REG(52) - PTREGS_OFFSET_REG(30)
  729. pop_reg_zero r52, r3, sp, PTREGS_OFFSET_CMPEXCH - PTREGS_OFFSET_REG(52)
  730. pop_reg_zero r21, r27, sp, PTREGS_OFFSET_EX1 - PTREGS_OFFSET_CMPEXCH
  731. pop_reg_zero lr, r2, sp, PTREGS_OFFSET_PC - PTREGS_OFFSET_EX1
  732. {
  733. mtspr CMPEXCH_VALUE, r21
  734. move r4, zero
  735. }
  736. pop_reg r21, sp, PTREGS_OFFSET_REG(31) - PTREGS_OFFSET_PC
  737. {
  738. mtspr SPR_EX_CONTEXT_K_1, lr
  739. andi lr, lr, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */
  740. }
  741. {
  742. mtspr SPR_EX_CONTEXT_K_0, r21
  743. move r5, zero
  744. }
  745. /* Restore callee-saveds that we actually use. */
  746. pop_reg_zero r31, r6
  747. pop_reg_zero r32, r7
  748. pop_reg_zero r33, r8, sp, PTREGS_OFFSET_REG(29) - PTREGS_OFFSET_REG(33)
  749. /*
  750. * If we modified other callee-saveds, restore them now.
  751. * This is rare, but could be via ptrace or signal handler.
  752. */
  753. {
  754. move r9, zero
  755. blbs r20, .Lrestore_callees
  756. }
  757. .Lcontinue_restore_regs:
  758. /* Check if we're returning from a syscall. */
  759. {
  760. move r10, zero
  761. bltzt r20, 1f /* no, so go restore callee-save registers */
  762. }
  763. /*
  764. * Check if we're returning to userspace.
  765. * Note that if we're not, we don't worry about zeroing everything.
  766. */
  767. {
  768. addli sp, sp, PTREGS_OFFSET_LR - PTREGS_OFFSET_REG(29)
  769. bnez lr, .Lkernel_return
  770. }
  771. /*
  772. * On return from syscall, we've restored r0 from pt_regs, but we
  773. * clear the remainder of the caller-saved registers. We could
  774. * restore the syscall arguments, but there's not much point,
  775. * and it ensures user programs aren't trying to use the
  776. * caller-saves if we clear them, as well as avoiding leaking
  777. * kernel pointers into userspace.
  778. */
  779. pop_reg_zero lr, r11, sp, PTREGS_OFFSET_TP - PTREGS_OFFSET_LR
  780. pop_reg_zero tp, r12, sp, PTREGS_OFFSET_SP - PTREGS_OFFSET_TP
  781. {
  782. ld sp, sp
  783. move r13, zero
  784. move r14, zero
  785. }
  786. { move r15, zero; move r16, zero }
  787. { move r17, zero; move r18, zero }
  788. { move r19, zero; move r20, zero }
  789. { move r21, zero; move r22, zero }
  790. { move r23, zero; move r24, zero }
  791. { move r25, zero; move r26, zero }
  792. /* Set r1 to errno if we are returning an error, otherwise zero. */
  793. {
  794. moveli r29, 4096
  795. sub r1, zero, r0
  796. }
  797. {
  798. move r28, zero
  799. cmpltu r29, r1, r29
  800. }
  801. {
  802. mnz r1, r29, r1
  803. move r29, zero
  804. }
  805. iret
  806. /*
  807. * Not a syscall, so restore caller-saved registers.
  808. * First kick off loads for cache lines 1-3, which we're touching
  809. * for the first time here.
  810. */
  811. .align 64
  812. 1: pop_reg r29, sp, PTREGS_OFFSET_REG(21) - PTREGS_OFFSET_REG(29)
  813. pop_reg r21, sp, PTREGS_OFFSET_REG(13) - PTREGS_OFFSET_REG(21)
  814. pop_reg r13, sp, PTREGS_OFFSET_REG(1) - PTREGS_OFFSET_REG(13)
  815. pop_reg r1
  816. pop_reg r2
  817. pop_reg r3
  818. pop_reg r4
  819. pop_reg r5
  820. pop_reg r6
  821. pop_reg r7
  822. pop_reg r8
  823. pop_reg r9
  824. pop_reg r10
  825. pop_reg r11
  826. pop_reg r12, sp, 16
  827. /* r13 already restored above */
  828. pop_reg r14
  829. pop_reg r15
  830. pop_reg r16
  831. pop_reg r17
  832. pop_reg r18
  833. pop_reg r19
  834. pop_reg r20, sp, 16
  835. /* r21 already restored above */
  836. pop_reg r22
  837. pop_reg r23
  838. pop_reg r24
  839. pop_reg r25
  840. pop_reg r26
  841. pop_reg r27
  842. pop_reg r28, sp, PTREGS_OFFSET_LR - PTREGS_OFFSET_REG(28)
  843. /* r29 already restored above */
  844. bnez lr, .Lkernel_return
  845. pop_reg lr, sp, PTREGS_OFFSET_TP - PTREGS_OFFSET_LR
  846. pop_reg tp, sp, PTREGS_OFFSET_SP - PTREGS_OFFSET_TP
  847. ld sp, sp
  848. iret
  849. /*
  850. * We can't restore tp when in kernel mode, since a thread might
  851. * have migrated from another cpu and brought a stale tp value.
  852. */
  853. .Lkernel_return:
  854. pop_reg lr, sp, PTREGS_OFFSET_SP - PTREGS_OFFSET_LR
  855. ld sp, sp
  856. iret
  857. /* Restore callee-saved registers from r34 to r51. */
  858. .Lrestore_callees:
  859. addli sp, sp, PTREGS_OFFSET_REG(34) - PTREGS_OFFSET_REG(29)
  860. pop_reg r34
  861. pop_reg r35
  862. pop_reg r36
  863. pop_reg r37
  864. pop_reg r38
  865. pop_reg r39
  866. pop_reg r40
  867. pop_reg r41
  868. pop_reg r42
  869. pop_reg r43
  870. pop_reg r44
  871. pop_reg r45
  872. pop_reg r46
  873. pop_reg r47
  874. pop_reg r48
  875. pop_reg r49
  876. pop_reg r50
  877. pop_reg r51, sp, PTREGS_OFFSET_REG(29) - PTREGS_OFFSET_REG(51)
  878. j .Lcontinue_restore_regs
  879. STD_ENDPROC(interrupt_return)
  880. /*
  881. * "NMI" interrupts mask ALL interrupts before calling the
  882. * handler, and don't check thread flags, etc., on the way
  883. * back out. In general, the only things we do here for NMIs
  884. * are register save/restore and dataplane kernel-TLB management.
  885. * We don't (for example) deal with start/stop of the sched tick.
  886. */
  887. .pushsection .text.handle_nmi,"ax"
  888. handle_nmi:
  889. finish_interrupt_save handle_nmi
  890. {
  891. jalr r0
  892. PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
  893. }
  894. FEEDBACK_REENTER(handle_nmi)
  895. {
  896. movei r30, 1
  897. move r31, r0
  898. }
  899. j interrupt_return
  900. STD_ENDPROC(handle_nmi)
  901. /*
  902. * Parallel code for syscalls to handle_interrupt.
  903. */
  904. .pushsection .text.handle_syscall,"ax"
  905. handle_syscall:
  906. finish_interrupt_save handle_syscall
  907. /* Enable irqs. */
  908. TRACE_IRQS_ON
  909. IRQ_ENABLE(r20, r21)
  910. /* Bump the counter for syscalls made on this tile. */
  911. moveli r20, hw2_last(irq_stat + IRQ_CPUSTAT_SYSCALL_COUNT_OFFSET)
  912. shl16insli r20, r20, hw1(irq_stat + IRQ_CPUSTAT_SYSCALL_COUNT_OFFSET)
  913. shl16insli r20, r20, hw0(irq_stat + IRQ_CPUSTAT_SYSCALL_COUNT_OFFSET)
  914. add r20, r20, tp
  915. ld4s r21, r20
  916. {
  917. addi r21, r21, 1
  918. move r31, sp
  919. }
  920. {
  921. st4 r20, r21
  922. EXTRACT_THREAD_INFO(r31)
  923. }
  924. /* Trace syscalls, if requested. */
  925. addi r31, r31, THREAD_INFO_FLAGS_OFFSET
  926. ld r30, r31
  927. andi r30, r30, _TIF_SYSCALL_TRACE
  928. {
  929. addi r30, r31, THREAD_INFO_STATUS_OFFSET - THREAD_INFO_FLAGS_OFFSET
  930. beqzt r30, .Lrestore_syscall_regs
  931. }
  932. jal do_syscall_trace
  933. FEEDBACK_REENTER(handle_syscall)
  934. /*
  935. * We always reload our registers from the stack at this
  936. * point. They might be valid, if we didn't build with
  937. * TRACE_IRQFLAGS, and this isn't a dataplane tile, and we're not
  938. * doing syscall tracing, but there are enough cases now that it
  939. * seems simplest just to do the reload unconditionally.
  940. */
  941. .Lrestore_syscall_regs:
  942. {
  943. ld r30, r30
  944. PTREGS_PTR(r11, PTREGS_OFFSET_REG(0))
  945. }
  946. pop_reg r0, r11
  947. pop_reg r1, r11
  948. pop_reg r2, r11
  949. pop_reg r3, r11
  950. pop_reg r4, r11
  951. pop_reg r5, r11, PTREGS_OFFSET_SYSCALL - PTREGS_OFFSET_REG(5)
  952. {
  953. ld TREG_SYSCALL_NR_NAME, r11
  954. moveli r21, __NR_syscalls
  955. }
  956. /* Ensure that the syscall number is within the legal range. */
  957. {
  958. moveli r20, hw2(sys_call_table)
  959. blbs r30, .Lcompat_syscall
  960. }
  961. {
  962. cmpltu r21, TREG_SYSCALL_NR_NAME, r21
  963. shl16insli r20, r20, hw1(sys_call_table)
  964. }
  965. {
  966. blbc r21, .Linvalid_syscall
  967. shl16insli r20, r20, hw0(sys_call_table)
  968. }
  969. .Lload_syscall_pointer:
  970. shl3add r20, TREG_SYSCALL_NR_NAME, r20
  971. ld r20, r20
  972. /* Jump to syscall handler. */
  973. jalr r20
  974. .Lhandle_syscall_link: /* value of "lr" after "jalr r20" above */
  975. /*
  976. * Write our r0 onto the stack so it gets restored instead
  977. * of whatever the user had there before.
  978. * In compat mode, sign-extend r0 before storing it.
  979. */
  980. {
  981. PTREGS_PTR(r29, PTREGS_OFFSET_REG(0))
  982. blbct r30, 1f
  983. }
  984. addxi r0, r0, 0
  985. 1: st r29, r0
  986. .Lsyscall_sigreturn_skip:
  987. FEEDBACK_REENTER(handle_syscall)
  988. /* Do syscall trace again, if requested. */
  989. ld r30, r31
  990. andi r0, r30, _TIF_SYSCALL_TRACE
  991. {
  992. andi r0, r30, _TIF_SINGLESTEP
  993. beqzt r0, 1f
  994. }
  995. jal do_syscall_trace
  996. FEEDBACK_REENTER(handle_syscall)
  997. andi r0, r30, _TIF_SINGLESTEP
  998. 1: beqzt r0, 2f
  999. /* Single stepping -- notify ptrace. */
  1000. {
  1001. movei r0, SIGTRAP
  1002. jal ptrace_notify
  1003. }
  1004. FEEDBACK_REENTER(handle_syscall)
  1005. 2: {
  1006. movei r30, 0 /* not an NMI */
  1007. j .Lresume_userspace /* jump into middle of interrupt_return */
  1008. }
  1009. .Lcompat_syscall:
  1010. /*
  1011. * Load the base of the compat syscall table in r20, and
  1012. * range-check the syscall number (duplicated from 64-bit path).
  1013. * Sign-extend all the user's passed arguments to make them consistent.
  1014. * Also save the original "r(n)" values away in "r(11+n)" in
  1015. * case the syscall table entry wants to validate them.
  1016. */
  1017. moveli r20, hw2(compat_sys_call_table)
  1018. {
  1019. cmpltu r21, TREG_SYSCALL_NR_NAME, r21
  1020. shl16insli r20, r20, hw1(compat_sys_call_table)
  1021. }
  1022. {
  1023. blbc r21, .Linvalid_syscall
  1024. shl16insli r20, r20, hw0(compat_sys_call_table)
  1025. }
  1026. { move r11, r0; addxi r0, r0, 0 }
  1027. { move r12, r1; addxi r1, r1, 0 }
  1028. { move r13, r2; addxi r2, r2, 0 }
  1029. { move r14, r3; addxi r3, r3, 0 }
  1030. { move r15, r4; addxi r4, r4, 0 }
  1031. { move r16, r5; addxi r5, r5, 0 }
  1032. j .Lload_syscall_pointer
  1033. .Linvalid_syscall:
  1034. /* Report an invalid syscall back to the user program */
  1035. {
  1036. PTREGS_PTR(r29, PTREGS_OFFSET_REG(0))
  1037. movei r28, -ENOSYS
  1038. }
  1039. st r29, r28
  1040. {
  1041. movei r30, 0 /* not an NMI */
  1042. j .Lresume_userspace /* jump into middle of interrupt_return */
  1043. }
  1044. STD_ENDPROC(handle_syscall)
  1045. /* Return the address for oprofile to suppress in backtraces. */
  1046. STD_ENTRY_SECTION(handle_syscall_link_address, .text.handle_syscall)
  1047. lnk r0
  1048. {
  1049. addli r0, r0, .Lhandle_syscall_link - .
  1050. jrp lr
  1051. }
  1052. STD_ENDPROC(handle_syscall_link_address)
  1053. STD_ENTRY(ret_from_fork)
  1054. jal sim_notify_fork
  1055. jal schedule_tail
  1056. FEEDBACK_REENTER(ret_from_fork)
  1057. {
  1058. movei r30, 0 /* not an NMI */
  1059. j .Lresume_userspace /* jump into middle of interrupt_return */
  1060. }
  1061. STD_ENDPROC(ret_from_fork)
  1062. /* Various stub interrupt handlers and syscall handlers */
  1063. STD_ENTRY_LOCAL(_kernel_double_fault)
  1064. mfspr r1, SPR_EX_CONTEXT_K_0
  1065. move r2, lr
  1066. move r3, sp
  1067. move r4, r52
  1068. addi sp, sp, -C_ABI_SAVE_AREA_SIZE
  1069. j kernel_double_fault
  1070. STD_ENDPROC(_kernel_double_fault)
  1071. STD_ENTRY_LOCAL(bad_intr)
  1072. mfspr r2, SPR_EX_CONTEXT_K_0
  1073. panic "Unhandled interrupt %#x: PC %#lx"
  1074. STD_ENDPROC(bad_intr)
  1075. /* Put address of pt_regs in reg and jump. */
  1076. #define PTREGS_SYSCALL(x, reg) \
  1077. STD_ENTRY(_##x); \
  1078. { \
  1079. PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \
  1080. j x \
  1081. }; \
  1082. STD_ENDPROC(_##x)
  1083. /*
  1084. * Special-case sigreturn to not write r0 to the stack on return.
  1085. * This is technically more efficient, but it also avoids difficulties
  1086. * in the 64-bit OS when handling 32-bit compat code, since we must not
  1087. * sign-extend r0 for the sigreturn return-value case.
  1088. */
  1089. #define PTREGS_SYSCALL_SIGRETURN(x, reg) \
  1090. STD_ENTRY(_##x); \
  1091. addli lr, lr, .Lsyscall_sigreturn_skip - .Lhandle_syscall_link; \
  1092. { \
  1093. PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \
  1094. j x \
  1095. }; \
  1096. STD_ENDPROC(_##x)
  1097. PTREGS_SYSCALL(sys_execve, r3)
  1098. PTREGS_SYSCALL(sys_sigaltstack, r2)
  1099. PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0)
  1100. #ifdef CONFIG_COMPAT
  1101. PTREGS_SYSCALL(compat_sys_execve, r3)
  1102. PTREGS_SYSCALL(compat_sys_sigaltstack, r2)
  1103. PTREGS_SYSCALL_SIGRETURN(compat_sys_rt_sigreturn, r0)
  1104. #endif
  1105. /* Save additional callee-saves to pt_regs, put address in r4 and jump. */
  1106. STD_ENTRY(_sys_clone)
  1107. push_extra_callee_saves r4
  1108. j sys_clone
  1109. STD_ENDPROC(_sys_clone)
  1110. /* The single-step support may need to read all the registers. */
  1111. int_unalign:
  1112. push_extra_callee_saves r0
  1113. j do_trap
  1114. /* Fill the return address stack with nonzero entries. */
  1115. STD_ENTRY(fill_ra_stack)
  1116. {
  1117. move r0, lr
  1118. jal 1f
  1119. }
  1120. 1: jal 2f
  1121. 2: jal 3f
  1122. 3: jal 4f
  1123. 4: jrp r0
  1124. STD_ENDPROC(fill_ra_stack)
  1125. /* Include .intrpt1 array of interrupt vectors */
  1126. .section ".intrpt1", "ax"
  1127. #define op_handle_perf_interrupt bad_intr
  1128. #define op_handle_aux_perf_interrupt bad_intr
  1129. #ifndef CONFIG_HARDWALL
  1130. #define do_hardwall_trap bad_intr
  1131. #endif
  1132. int_hand INT_MEM_ERROR, MEM_ERROR, do_trap
  1133. int_hand INT_SINGLE_STEP_3, SINGLE_STEP_3, bad_intr
  1134. #if CONFIG_KERNEL_PL == 2
  1135. int_hand INT_SINGLE_STEP_2, SINGLE_STEP_2, gx_singlestep_handle
  1136. int_hand INT_SINGLE_STEP_1, SINGLE_STEP_1, bad_intr
  1137. #else
  1138. int_hand INT_SINGLE_STEP_2, SINGLE_STEP_2, bad_intr
  1139. int_hand INT_SINGLE_STEP_1, SINGLE_STEP_1, gx_singlestep_handle
  1140. #endif
  1141. int_hand INT_SINGLE_STEP_0, SINGLE_STEP_0, bad_intr
  1142. int_hand INT_IDN_COMPLETE, IDN_COMPLETE, bad_intr
  1143. int_hand INT_UDN_COMPLETE, UDN_COMPLETE, bad_intr
  1144. int_hand INT_ITLB_MISS, ITLB_MISS, do_page_fault
  1145. int_hand INT_ILL, ILL, do_trap
  1146. int_hand INT_GPV, GPV, do_trap
  1147. int_hand INT_IDN_ACCESS, IDN_ACCESS, do_trap
  1148. int_hand INT_UDN_ACCESS, UDN_ACCESS, do_trap
  1149. int_hand INT_SWINT_3, SWINT_3, do_trap
  1150. int_hand INT_SWINT_2, SWINT_2, do_trap
  1151. int_hand INT_SWINT_1, SWINT_1, SYSCALL, handle_syscall
  1152. int_hand INT_SWINT_0, SWINT_0, do_trap
  1153. int_hand INT_ILL_TRANS, ILL_TRANS, do_trap
  1154. int_hand INT_UNALIGN_DATA, UNALIGN_DATA, int_unalign
  1155. int_hand INT_DTLB_MISS, DTLB_MISS, do_page_fault
  1156. int_hand INT_DTLB_ACCESS, DTLB_ACCESS, do_page_fault
  1157. int_hand INT_IDN_FIREWALL, IDN_FIREWALL, bad_intr
  1158. int_hand INT_UDN_FIREWALL, UDN_FIREWALL, do_hardwall_trap
  1159. int_hand INT_TILE_TIMER, TILE_TIMER, do_timer_interrupt
  1160. int_hand INT_IDN_TIMER, IDN_TIMER, bad_intr
  1161. int_hand INT_UDN_TIMER, UDN_TIMER, bad_intr
  1162. int_hand INT_IDN_AVAIL, IDN_AVAIL, bad_intr
  1163. int_hand INT_UDN_AVAIL, UDN_AVAIL, bad_intr
  1164. int_hand INT_IPI_3, IPI_3, bad_intr
  1165. #if CONFIG_KERNEL_PL == 2
  1166. int_hand INT_IPI_2, IPI_2, tile_dev_intr
  1167. int_hand INT_IPI_1, IPI_1, bad_intr
  1168. #else
  1169. int_hand INT_IPI_2, IPI_2, bad_intr
  1170. int_hand INT_IPI_1, IPI_1, tile_dev_intr
  1171. #endif
  1172. int_hand INT_IPI_0, IPI_0, bad_intr
  1173. int_hand INT_PERF_COUNT, PERF_COUNT, \
  1174. op_handle_perf_interrupt, handle_nmi
  1175. int_hand INT_AUX_PERF_COUNT, AUX_PERF_COUNT, \
  1176. op_handle_perf_interrupt, handle_nmi
  1177. int_hand INT_INTCTRL_3, INTCTRL_3, bad_intr
  1178. #if CONFIG_KERNEL_PL == 2
  1179. dc_dispatch INT_INTCTRL_2, INTCTRL_2
  1180. int_hand INT_INTCTRL_1, INTCTRL_1, bad_intr
  1181. #else
  1182. int_hand INT_INTCTRL_2, INTCTRL_2, bad_intr
  1183. dc_dispatch INT_INTCTRL_1, INTCTRL_1
  1184. #endif
  1185. int_hand INT_INTCTRL_0, INTCTRL_0, bad_intr
  1186. int_hand INT_MESSAGE_RCV_DWNCL, MESSAGE_RCV_DWNCL, \
  1187. hv_message_intr
  1188. int_hand INT_DEV_INTR_DWNCL, DEV_INTR_DWNCL, bad_intr
  1189. int_hand INT_I_ASID, I_ASID, bad_intr
  1190. int_hand INT_D_ASID, D_ASID, bad_intr
  1191. int_hand INT_DOUBLE_FAULT, DOUBLE_FAULT, do_trap
  1192. /* Synthetic interrupt delivered only by the simulator */
  1193. int_hand INT_BREAKPOINT, BREAKPOINT, do_breakpoint