entry.S 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822
  1. /* $Id: entry.S,v 1.144 2002/02/09 19:49:30 davem Exp $
  2. * arch/sparc64/kernel/entry.S: Sparc64 trap low-level entry points.
  3. *
  4. * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
  6. * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  7. * Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  8. */
  9. #include <linux/config.h>
  10. #include <linux/errno.h>
  11. #include <asm/head.h>
  12. #include <asm/asi.h>
  13. #include <asm/smp.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/page.h>
  16. #include <asm/signal.h>
  17. #include <asm/pgtable.h>
  18. #include <asm/processor.h>
  19. #include <asm/visasm.h>
  20. #include <asm/estate.h>
  21. #include <asm/auxio.h>
  22. #include <asm/sfafsr.h>
  23. #include <asm/pil.h>
  24. #define curptr g6
  25. #define NR_SYSCALLS 300 /* Each OS is different... */
  26. .text
  27. .align 32
  28. /* This is trivial with the new code... */
  29. .globl do_fpdis
  30. do_fpdis:
  31. sethi %hi(TSTATE_PEF), %g4
  32. rdpr %tstate, %g5
  33. andcc %g5, %g4, %g0
  34. be,pt %xcc, 1f
  35. nop
  36. rd %fprs, %g5
  37. andcc %g5, FPRS_FEF, %g0
  38. be,pt %xcc, 1f
  39. nop
  40. /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
  41. sethi %hi(109f), %g7
  42. ba,pt %xcc, etrap
  43. 109: or %g7, %lo(109b), %g7
  44. add %g0, %g0, %g0
  45. ba,a,pt %xcc, rtrap_clr_l6
  46. 1: TRAP_LOAD_THREAD_REG(%g6, %g1)
  47. ldub [%g6 + TI_FPSAVED], %g5
  48. wr %g0, FPRS_FEF, %fprs
  49. andcc %g5, FPRS_FEF, %g0
  50. be,a,pt %icc, 1f
  51. clr %g7
  52. ldx [%g6 + TI_GSR], %g7
  53. 1: andcc %g5, FPRS_DL, %g0
  54. bne,pn %icc, 2f
  55. fzero %f0
  56. andcc %g5, FPRS_DU, %g0
  57. bne,pn %icc, 1f
  58. fzero %f2
  59. faddd %f0, %f2, %f4
  60. fmuld %f0, %f2, %f6
  61. faddd %f0, %f2, %f8
  62. fmuld %f0, %f2, %f10
  63. faddd %f0, %f2, %f12
  64. fmuld %f0, %f2, %f14
  65. faddd %f0, %f2, %f16
  66. fmuld %f0, %f2, %f18
  67. faddd %f0, %f2, %f20
  68. fmuld %f0, %f2, %f22
  69. faddd %f0, %f2, %f24
  70. fmuld %f0, %f2, %f26
  71. faddd %f0, %f2, %f28
  72. fmuld %f0, %f2, %f30
  73. faddd %f0, %f2, %f32
  74. fmuld %f0, %f2, %f34
  75. faddd %f0, %f2, %f36
  76. fmuld %f0, %f2, %f38
  77. faddd %f0, %f2, %f40
  78. fmuld %f0, %f2, %f42
  79. faddd %f0, %f2, %f44
  80. fmuld %f0, %f2, %f46
  81. faddd %f0, %f2, %f48
  82. fmuld %f0, %f2, %f50
  83. faddd %f0, %f2, %f52
  84. fmuld %f0, %f2, %f54
  85. faddd %f0, %f2, %f56
  86. fmuld %f0, %f2, %f58
  87. b,pt %xcc, fpdis_exit2
  88. faddd %f0, %f2, %f60
  89. 1: mov SECONDARY_CONTEXT, %g3
  90. add %g6, TI_FPREGS + 0x80, %g1
  91. faddd %f0, %f2, %f4
  92. fmuld %f0, %f2, %f6
  93. 661: ldxa [%g3] ASI_DMMU, %g5
  94. .section .sun4v_1insn_patch, "ax"
  95. .word 661b
  96. ldxa [%g3] ASI_MMU, %g5
  97. .previous
  98. sethi %hi(sparc64_kern_sec_context), %g2
  99. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  100. 661: stxa %g2, [%g3] ASI_DMMU
  101. .section .sun4v_1insn_patch, "ax"
  102. .word 661b
  103. stxa %g2, [%g3] ASI_MMU
  104. .previous
  105. membar #Sync
  106. add %g6, TI_FPREGS + 0xc0, %g2
  107. faddd %f0, %f2, %f8
  108. fmuld %f0, %f2, %f10
  109. membar #Sync
  110. ldda [%g1] ASI_BLK_S, %f32
  111. ldda [%g2] ASI_BLK_S, %f48
  112. membar #Sync
  113. faddd %f0, %f2, %f12
  114. fmuld %f0, %f2, %f14
  115. faddd %f0, %f2, %f16
  116. fmuld %f0, %f2, %f18
  117. faddd %f0, %f2, %f20
  118. fmuld %f0, %f2, %f22
  119. faddd %f0, %f2, %f24
  120. fmuld %f0, %f2, %f26
  121. faddd %f0, %f2, %f28
  122. fmuld %f0, %f2, %f30
  123. b,pt %xcc, fpdis_exit
  124. nop
  125. 2: andcc %g5, FPRS_DU, %g0
  126. bne,pt %icc, 3f
  127. fzero %f32
  128. mov SECONDARY_CONTEXT, %g3
  129. fzero %f34
  130. 661: ldxa [%g3] ASI_DMMU, %g5
  131. .section .sun4v_1insn_patch, "ax"
  132. .word 661b
  133. ldxa [%g3] ASI_MMU, %g5
  134. .previous
  135. add %g6, TI_FPREGS, %g1
  136. sethi %hi(sparc64_kern_sec_context), %g2
  137. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  138. 661: stxa %g2, [%g3] ASI_DMMU
  139. .section .sun4v_1insn_patch, "ax"
  140. .word 661b
  141. stxa %g2, [%g3] ASI_MMU
  142. .previous
  143. membar #Sync
  144. add %g6, TI_FPREGS + 0x40, %g2
  145. faddd %f32, %f34, %f36
  146. fmuld %f32, %f34, %f38
  147. membar #Sync
  148. ldda [%g1] ASI_BLK_S, %f0
  149. ldda [%g2] ASI_BLK_S, %f16
  150. membar #Sync
  151. faddd %f32, %f34, %f40
  152. fmuld %f32, %f34, %f42
  153. faddd %f32, %f34, %f44
  154. fmuld %f32, %f34, %f46
  155. faddd %f32, %f34, %f48
  156. fmuld %f32, %f34, %f50
  157. faddd %f32, %f34, %f52
  158. fmuld %f32, %f34, %f54
  159. faddd %f32, %f34, %f56
  160. fmuld %f32, %f34, %f58
  161. faddd %f32, %f34, %f60
  162. fmuld %f32, %f34, %f62
  163. ba,pt %xcc, fpdis_exit
  164. nop
  165. 3: mov SECONDARY_CONTEXT, %g3
  166. add %g6, TI_FPREGS, %g1
  167. 661: ldxa [%g3] ASI_DMMU, %g5
  168. .section .sun4v_1insn_patch, "ax"
  169. .word 661b
  170. ldxa [%g3] ASI_MMU, %g5
  171. .previous
  172. sethi %hi(sparc64_kern_sec_context), %g2
  173. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  174. 661: stxa %g2, [%g3] ASI_DMMU
  175. .section .sun4v_1insn_patch, "ax"
  176. .word 661b
  177. stxa %g2, [%g3] ASI_MMU
  178. .previous
  179. membar #Sync
  180. mov 0x40, %g2
  181. membar #Sync
  182. ldda [%g1] ASI_BLK_S, %f0
  183. ldda [%g1 + %g2] ASI_BLK_S, %f16
  184. add %g1, 0x80, %g1
  185. ldda [%g1] ASI_BLK_S, %f32
  186. ldda [%g1 + %g2] ASI_BLK_S, %f48
  187. membar #Sync
  188. fpdis_exit:
  189. 661: stxa %g5, [%g3] ASI_DMMU
  190. .section .sun4v_1insn_patch, "ax"
  191. .word 661b
  192. stxa %g5, [%g3] ASI_MMU
  193. .previous
  194. membar #Sync
  195. fpdis_exit2:
  196. wr %g7, 0, %gsr
  197. ldx [%g6 + TI_XFSR], %fsr
  198. rdpr %tstate, %g3
  199. or %g3, %g4, %g3 ! anal...
  200. wrpr %g3, %tstate
  201. wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
  202. retry
  203. .align 32
  204. fp_other_bounce:
  205. call do_fpother
  206. add %sp, PTREGS_OFF, %o0
  207. ba,pt %xcc, rtrap
  208. clr %l6
  209. .globl do_fpother_check_fitos
  210. .align 32
  211. do_fpother_check_fitos:
  212. TRAP_LOAD_THREAD_REG(%g6, %g1)
  213. sethi %hi(fp_other_bounce - 4), %g7
  214. or %g7, %lo(fp_other_bounce - 4), %g7
  215. /* NOTE: Need to preserve %g7 until we fully commit
  216. * to the fitos fixup.
  217. */
  218. stx %fsr, [%g6 + TI_XFSR]
  219. rdpr %tstate, %g3
  220. andcc %g3, TSTATE_PRIV, %g0
  221. bne,pn %xcc, do_fptrap_after_fsr
  222. nop
  223. ldx [%g6 + TI_XFSR], %g3
  224. srlx %g3, 14, %g1
  225. and %g1, 7, %g1
  226. cmp %g1, 2 ! Unfinished FP-OP
  227. bne,pn %xcc, do_fptrap_after_fsr
  228. sethi %hi(1 << 23), %g1 ! Inexact
  229. andcc %g3, %g1, %g0
  230. bne,pn %xcc, do_fptrap_after_fsr
  231. rdpr %tpc, %g1
  232. lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
  233. #define FITOS_MASK 0xc1f83fe0
  234. #define FITOS_COMPARE 0x81a01880
  235. sethi %hi(FITOS_MASK), %g1
  236. or %g1, %lo(FITOS_MASK), %g1
  237. and %g3, %g1, %g1
  238. sethi %hi(FITOS_COMPARE), %g2
  239. or %g2, %lo(FITOS_COMPARE), %g2
  240. cmp %g1, %g2
  241. bne,pn %xcc, do_fptrap_after_fsr
  242. nop
  243. std %f62, [%g6 + TI_FPREGS + (62 * 4)]
  244. sethi %hi(fitos_table_1), %g1
  245. and %g3, 0x1f, %g2
  246. or %g1, %lo(fitos_table_1), %g1
  247. sllx %g2, 2, %g2
  248. jmpl %g1 + %g2, %g0
  249. ba,pt %xcc, fitos_emul_continue
  250. fitos_table_1:
  251. fitod %f0, %f62
  252. fitod %f1, %f62
  253. fitod %f2, %f62
  254. fitod %f3, %f62
  255. fitod %f4, %f62
  256. fitod %f5, %f62
  257. fitod %f6, %f62
  258. fitod %f7, %f62
  259. fitod %f8, %f62
  260. fitod %f9, %f62
  261. fitod %f10, %f62
  262. fitod %f11, %f62
  263. fitod %f12, %f62
  264. fitod %f13, %f62
  265. fitod %f14, %f62
  266. fitod %f15, %f62
  267. fitod %f16, %f62
  268. fitod %f17, %f62
  269. fitod %f18, %f62
  270. fitod %f19, %f62
  271. fitod %f20, %f62
  272. fitod %f21, %f62
  273. fitod %f22, %f62
  274. fitod %f23, %f62
  275. fitod %f24, %f62
  276. fitod %f25, %f62
  277. fitod %f26, %f62
  278. fitod %f27, %f62
  279. fitod %f28, %f62
  280. fitod %f29, %f62
  281. fitod %f30, %f62
  282. fitod %f31, %f62
  283. fitos_emul_continue:
  284. sethi %hi(fitos_table_2), %g1
  285. srl %g3, 25, %g2
  286. or %g1, %lo(fitos_table_2), %g1
  287. and %g2, 0x1f, %g2
  288. sllx %g2, 2, %g2
  289. jmpl %g1 + %g2, %g0
  290. ba,pt %xcc, fitos_emul_fini
  291. fitos_table_2:
  292. fdtos %f62, %f0
  293. fdtos %f62, %f1
  294. fdtos %f62, %f2
  295. fdtos %f62, %f3
  296. fdtos %f62, %f4
  297. fdtos %f62, %f5
  298. fdtos %f62, %f6
  299. fdtos %f62, %f7
  300. fdtos %f62, %f8
  301. fdtos %f62, %f9
  302. fdtos %f62, %f10
  303. fdtos %f62, %f11
  304. fdtos %f62, %f12
  305. fdtos %f62, %f13
  306. fdtos %f62, %f14
  307. fdtos %f62, %f15
  308. fdtos %f62, %f16
  309. fdtos %f62, %f17
  310. fdtos %f62, %f18
  311. fdtos %f62, %f19
  312. fdtos %f62, %f20
  313. fdtos %f62, %f21
  314. fdtos %f62, %f22
  315. fdtos %f62, %f23
  316. fdtos %f62, %f24
  317. fdtos %f62, %f25
  318. fdtos %f62, %f26
  319. fdtos %f62, %f27
  320. fdtos %f62, %f28
  321. fdtos %f62, %f29
  322. fdtos %f62, %f30
  323. fdtos %f62, %f31
  324. fitos_emul_fini:
  325. ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
  326. done
  327. .globl do_fptrap
  328. .align 32
  329. do_fptrap:
  330. TRAP_LOAD_THREAD_REG(%g6, %g1)
  331. stx %fsr, [%g6 + TI_XFSR]
  332. do_fptrap_after_fsr:
  333. ldub [%g6 + TI_FPSAVED], %g3
  334. rd %fprs, %g1
  335. or %g3, %g1, %g3
  336. stb %g3, [%g6 + TI_FPSAVED]
  337. rd %gsr, %g3
  338. stx %g3, [%g6 + TI_GSR]
  339. mov SECONDARY_CONTEXT, %g3
  340. 661: ldxa [%g3] ASI_DMMU, %g5
  341. .section .sun4v_1insn_patch, "ax"
  342. .word 661b
  343. ldxa [%g3] ASI_MMU, %g5
  344. .previous
  345. sethi %hi(sparc64_kern_sec_context), %g2
  346. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  347. 661: stxa %g2, [%g3] ASI_DMMU
  348. .section .sun4v_1insn_patch, "ax"
  349. .word 661b
  350. stxa %g2, [%g3] ASI_MMU
  351. .previous
  352. membar #Sync
  353. add %g6, TI_FPREGS, %g2
  354. andcc %g1, FPRS_DL, %g0
  355. be,pn %icc, 4f
  356. mov 0x40, %g3
  357. stda %f0, [%g2] ASI_BLK_S
  358. stda %f16, [%g2 + %g3] ASI_BLK_S
  359. andcc %g1, FPRS_DU, %g0
  360. be,pn %icc, 5f
  361. 4: add %g2, 128, %g2
  362. stda %f32, [%g2] ASI_BLK_S
  363. stda %f48, [%g2 + %g3] ASI_BLK_S
  364. 5: mov SECONDARY_CONTEXT, %g1
  365. membar #Sync
  366. 661: stxa %g5, [%g1] ASI_DMMU
  367. .section .sun4v_1insn_patch, "ax"
  368. .word 661b
  369. stxa %g5, [%g1] ASI_MMU
  370. .previous
  371. membar #Sync
  372. ba,pt %xcc, etrap
  373. wr %g0, 0, %fprs
  374. /* The registers for cross calls will be:
  375. *
  376. * DATA 0: [low 32-bits] Address of function to call, jmp to this
  377. * [high 32-bits] MMU Context Argument 0, place in %g5
  378. * DATA 1: Address Argument 1, place in %g1
  379. * DATA 2: Address Argument 2, place in %g7
  380. *
  381. * With this method we can do most of the cross-call tlb/cache
  382. * flushing very quickly.
  383. */
  384. .text
  385. .align 32
  386. .globl do_ivec
  387. do_ivec:
  388. mov 0x40, %g3
  389. ldxa [%g3 + %g0] ASI_INTR_R, %g3
  390. sethi %hi(KERNBASE), %g4
  391. cmp %g3, %g4
  392. bgeu,pn %xcc, do_ivec_xcall
  393. srlx %g3, 32, %g5
  394. stxa %g0, [%g0] ASI_INTR_RECEIVE
  395. membar #Sync
  396. sethi %hi(ivector_table), %g2
  397. sllx %g3, 3, %g3
  398. or %g2, %lo(ivector_table), %g2
  399. add %g2, %g3, %g3
  400. TRAP_LOAD_IRQ_WORK(%g6, %g1)
  401. lduw [%g6], %g5 /* g5 = irq_work(cpu) */
  402. stw %g5, [%g3 + 0x00] /* bucket->irq_chain = g5 */
  403. stw %g3, [%g6] /* irq_work(cpu) = bucket */
  404. wr %g0, 1 << PIL_DEVICE_IRQ, %set_softint
  405. retry
  406. do_ivec_xcall:
  407. mov 0x50, %g1
  408. ldxa [%g1 + %g0] ASI_INTR_R, %g1
  409. srl %g3, 0, %g3
  410. mov 0x60, %g7
  411. ldxa [%g7 + %g0] ASI_INTR_R, %g7
  412. stxa %g0, [%g0] ASI_INTR_RECEIVE
  413. membar #Sync
  414. ba,pt %xcc, 1f
  415. nop
  416. .align 32
  417. 1: jmpl %g3, %g0
  418. nop
  419. .globl getcc, setcc
  420. getcc:
  421. ldx [%o0 + PT_V9_TSTATE], %o1
  422. srlx %o1, 32, %o1
  423. and %o1, 0xf, %o1
  424. retl
  425. stx %o1, [%o0 + PT_V9_G1]
  426. setcc:
  427. ldx [%o0 + PT_V9_TSTATE], %o1
  428. ldx [%o0 + PT_V9_G1], %o2
  429. or %g0, %ulo(TSTATE_ICC), %o3
  430. sllx %o3, 32, %o3
  431. andn %o1, %o3, %o1
  432. sllx %o2, 32, %o2
  433. and %o2, %o3, %o2
  434. or %o1, %o2, %o1
  435. retl
  436. stx %o1, [%o0 + PT_V9_TSTATE]
  437. .globl utrap_trap
  438. utrap_trap: /* %g3=handler,%g4=level */
  439. TRAP_LOAD_THREAD_REG(%g6, %g1)
  440. ldx [%g6 + TI_UTRAPS], %g1
  441. brnz,pt %g1, invoke_utrap
  442. nop
  443. ba,pt %xcc, etrap
  444. rd %pc, %g7
  445. mov %l4, %o1
  446. call bad_trap
  447. add %sp, PTREGS_OFF, %o0
  448. ba,pt %xcc, rtrap
  449. clr %l6
  450. invoke_utrap:
  451. sllx %g3, 3, %g3
  452. ldx [%g1 + %g3], %g1
  453. save %sp, -128, %sp
  454. rdpr %tstate, %l6
  455. rdpr %cwp, %l7
  456. andn %l6, TSTATE_CWP, %l6
  457. wrpr %l6, %l7, %tstate
  458. rdpr %tpc, %l6
  459. rdpr %tnpc, %l7
  460. wrpr %g1, 0, %tnpc
  461. done
  462. /* We need to carefully read the error status, ACK
  463. * the errors, prevent recursive traps, and pass the
  464. * information on to C code for logging.
  465. *
  466. * We pass the AFAR in as-is, and we encode the status
  467. * information as described in asm-sparc64/sfafsr.h
  468. */
  469. .globl __spitfire_access_error
  470. __spitfire_access_error:
  471. /* Disable ESTATE error reporting so that we do not
  472. * take recursive traps and RED state the processor.
  473. */
  474. stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
  475. membar #Sync
  476. mov UDBE_UE, %g1
  477. ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
  478. /* __spitfire_cee_trap branches here with AFSR in %g4 and
  479. * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
  480. * ESTATE Error Enable register.
  481. */
  482. __spitfire_cee_trap_continue:
  483. ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
  484. rdpr %tt, %g3
  485. and %g3, 0x1ff, %g3 ! Paranoia
  486. sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
  487. or %g4, %g3, %g4
  488. rdpr %tl, %g3
  489. cmp %g3, 1
  490. mov 1, %g3
  491. bleu %xcc, 1f
  492. sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
  493. or %g4, %g3, %g4
  494. /* Read in the UDB error register state, clearing the
  495. * sticky error bits as-needed. We only clear them if
  496. * the UE bit is set. Likewise, __spitfire_cee_trap
  497. * below will only do so if the CE bit is set.
  498. *
  499. * NOTE: UltraSparc-I/II have high and low UDB error
  500. * registers, corresponding to the two UDB units
  501. * present on those chips. UltraSparc-IIi only
  502. * has a single UDB, called "SDB" in the manual.
  503. * For IIi the upper UDB register always reads
  504. * as zero so for our purposes things will just
  505. * work with the checks below.
  506. */
  507. 1: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
  508. and %g3, 0x3ff, %g7 ! Paranoia
  509. sllx %g7, SFSTAT_UDBH_SHIFT, %g7
  510. or %g4, %g7, %g4
  511. andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
  512. be,pn %xcc, 1f
  513. nop
  514. stxa %g3, [%g0] ASI_UDB_ERROR_W
  515. membar #Sync
  516. 1: mov 0x18, %g3
  517. ldxa [%g3] ASI_UDBL_ERROR_R, %g3
  518. and %g3, 0x3ff, %g7 ! Paranoia
  519. sllx %g7, SFSTAT_UDBL_SHIFT, %g7
  520. or %g4, %g7, %g4
  521. andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
  522. be,pn %xcc, 1f
  523. nop
  524. mov 0x18, %g7
  525. stxa %g3, [%g7] ASI_UDB_ERROR_W
  526. membar #Sync
  527. 1: /* Ok, now that we've latched the error state,
  528. * clear the sticky bits in the AFSR.
  529. */
  530. stxa %g4, [%g0] ASI_AFSR
  531. membar #Sync
  532. rdpr %tl, %g2
  533. cmp %g2, 1
  534. rdpr %pil, %g2
  535. bleu,pt %xcc, 1f
  536. wrpr %g0, 15, %pil
  537. ba,pt %xcc, etraptl1
  538. rd %pc, %g7
  539. ba,pt %xcc, 2f
  540. nop
  541. 1: ba,pt %xcc, etrap_irq
  542. rd %pc, %g7
  543. 2: mov %l4, %o1
  544. mov %l5, %o2
  545. call spitfire_access_error
  546. add %sp, PTREGS_OFF, %o0
  547. ba,pt %xcc, rtrap
  548. clr %l6
  549. /* This is the trap handler entry point for ECC correctable
  550. * errors. They are corrected, but we listen for the trap
  551. * so that the event can be logged.
  552. *
  553. * Disrupting errors are either:
  554. * 1) single-bit ECC errors during UDB reads to system
  555. * memory
  556. * 2) data parity errors during write-back events
  557. *
  558. * As far as I can make out from the manual, the CEE trap
  559. * is only for correctable errors during memory read
  560. * accesses by the front-end of the processor.
  561. *
  562. * The code below is only for trap level 1 CEE events,
  563. * as it is the only situation where we can safely record
  564. * and log. For trap level >1 we just clear the CE bit
  565. * in the AFSR and return.
  566. *
  567. * This is just like __spiftire_access_error above, but it
  568. * specifically handles correctable errors. If an
  569. * uncorrectable error is indicated in the AFSR we
  570. * will branch directly above to __spitfire_access_error
  571. * to handle it instead. Uncorrectable therefore takes
  572. * priority over correctable, and the error logging
  573. * C code will notice this case by inspecting the
  574. * trap type.
  575. */
  576. .globl __spitfire_cee_trap
  577. __spitfire_cee_trap:
  578. ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
  579. mov 1, %g3
  580. sllx %g3, SFAFSR_UE_SHIFT, %g3
  581. andcc %g4, %g3, %g0 ! Check for UE
  582. bne,pn %xcc, __spitfire_access_error
  583. nop
  584. /* Ok, in this case we only have a correctable error.
  585. * Indicate we only wish to capture that state in register
  586. * %g1, and we only disable CE error reporting unlike UE
  587. * handling which disables all errors.
  588. */
  589. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
  590. andn %g3, ESTATE_ERR_CE, %g3
  591. stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
  592. membar #Sync
  593. /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
  594. ba,pt %xcc, __spitfire_cee_trap_continue
  595. mov UDBE_CE, %g1
  596. .globl __spitfire_data_access_exception
  597. .globl __spitfire_data_access_exception_tl1
  598. __spitfire_data_access_exception_tl1:
  599. rdpr %pstate, %g4
  600. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  601. mov TLB_SFSR, %g3
  602. mov DMMU_SFAR, %g5
  603. ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
  604. ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
  605. stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
  606. membar #Sync
  607. rdpr %tt, %g3
  608. cmp %g3, 0x80 ! first win spill/fill trap
  609. blu,pn %xcc, 1f
  610. cmp %g3, 0xff ! last win spill/fill trap
  611. bgu,pn %xcc, 1f
  612. nop
  613. ba,pt %xcc, winfix_dax
  614. rdpr %tpc, %g3
  615. 1: sethi %hi(109f), %g7
  616. ba,pt %xcc, etraptl1
  617. 109: or %g7, %lo(109b), %g7
  618. mov %l4, %o1
  619. mov %l5, %o2
  620. call spitfire_data_access_exception_tl1
  621. add %sp, PTREGS_OFF, %o0
  622. ba,pt %xcc, rtrap
  623. clr %l6
  624. __spitfire_data_access_exception:
  625. rdpr %pstate, %g4
  626. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  627. mov TLB_SFSR, %g3
  628. mov DMMU_SFAR, %g5
  629. ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
  630. ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
  631. stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
  632. membar #Sync
  633. sethi %hi(109f), %g7
  634. ba,pt %xcc, etrap
  635. 109: or %g7, %lo(109b), %g7
  636. mov %l4, %o1
  637. mov %l5, %o2
  638. call spitfire_data_access_exception
  639. add %sp, PTREGS_OFF, %o0
  640. ba,pt %xcc, rtrap
  641. clr %l6
  642. .globl __spitfire_insn_access_exception
  643. .globl __spitfire_insn_access_exception_tl1
  644. __spitfire_insn_access_exception_tl1:
  645. rdpr %pstate, %g4
  646. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  647. mov TLB_SFSR, %g3
  648. ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
  649. rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
  650. stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
  651. membar #Sync
  652. sethi %hi(109f), %g7
  653. ba,pt %xcc, etraptl1
  654. 109: or %g7, %lo(109b), %g7
  655. mov %l4, %o1
  656. mov %l5, %o2
  657. call spitfire_insn_access_exception_tl1
  658. add %sp, PTREGS_OFF, %o0
  659. ba,pt %xcc, rtrap
  660. clr %l6
  661. __spitfire_insn_access_exception:
  662. rdpr %pstate, %g4
  663. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  664. mov TLB_SFSR, %g3
  665. ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
  666. rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
  667. stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
  668. membar #Sync
  669. sethi %hi(109f), %g7
  670. ba,pt %xcc, etrap
  671. 109: or %g7, %lo(109b), %g7
  672. mov %l4, %o1
  673. mov %l5, %o2
  674. call spitfire_insn_access_exception
  675. add %sp, PTREGS_OFF, %o0
  676. ba,pt %xcc, rtrap
  677. clr %l6
  678. /* These get patched into the trap table at boot time
  679. * once we know we have a cheetah processor.
  680. */
  681. .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
  682. cheetah_fecc_trap_vector:
  683. membar #Sync
  684. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  685. andn %g1, DCU_DC | DCU_IC, %g1
  686. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  687. membar #Sync
  688. sethi %hi(cheetah_fast_ecc), %g2
  689. jmpl %g2 + %lo(cheetah_fast_ecc), %g0
  690. mov 0, %g1
  691. cheetah_fecc_trap_vector_tl1:
  692. membar #Sync
  693. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  694. andn %g1, DCU_DC | DCU_IC, %g1
  695. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  696. membar #Sync
  697. sethi %hi(cheetah_fast_ecc), %g2
  698. jmpl %g2 + %lo(cheetah_fast_ecc), %g0
  699. mov 1, %g1
  700. .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
  701. cheetah_cee_trap_vector:
  702. membar #Sync
  703. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  704. andn %g1, DCU_IC, %g1
  705. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  706. membar #Sync
  707. sethi %hi(cheetah_cee), %g2
  708. jmpl %g2 + %lo(cheetah_cee), %g0
  709. mov 0, %g1
  710. cheetah_cee_trap_vector_tl1:
  711. membar #Sync
  712. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  713. andn %g1, DCU_IC, %g1
  714. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  715. membar #Sync
  716. sethi %hi(cheetah_cee), %g2
  717. jmpl %g2 + %lo(cheetah_cee), %g0
  718. mov 1, %g1
  719. .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
  720. cheetah_deferred_trap_vector:
  721. membar #Sync
  722. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
  723. andn %g1, DCU_DC | DCU_IC, %g1;
  724. stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
  725. membar #Sync;
  726. sethi %hi(cheetah_deferred_trap), %g2
  727. jmpl %g2 + %lo(cheetah_deferred_trap), %g0
  728. mov 0, %g1
  729. cheetah_deferred_trap_vector_tl1:
  730. membar #Sync;
  731. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
  732. andn %g1, DCU_DC | DCU_IC, %g1;
  733. stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
  734. membar #Sync;
  735. sethi %hi(cheetah_deferred_trap), %g2
  736. jmpl %g2 + %lo(cheetah_deferred_trap), %g0
  737. mov 1, %g1
  738. /* Cheetah+ specific traps. These are for the new I/D cache parity
  739. * error traps. The first argument to cheetah_plus_parity_handler
  740. * is encoded as follows:
  741. *
  742. * Bit0: 0=dcache,1=icache
  743. * Bit1: 0=recoverable,1=unrecoverable
  744. */
  745. .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
  746. cheetah_plus_dcpe_trap_vector:
  747. membar #Sync
  748. sethi %hi(do_cheetah_plus_data_parity), %g7
  749. jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
  750. nop
  751. nop
  752. nop
  753. nop
  754. nop
  755. do_cheetah_plus_data_parity:
  756. rdpr %pil, %g2
  757. wrpr %g0, 15, %pil
  758. ba,pt %xcc, etrap_irq
  759. rd %pc, %g7
  760. mov 0x0, %o0
  761. call cheetah_plus_parity_error
  762. add %sp, PTREGS_OFF, %o1
  763. ba,a,pt %xcc, rtrap_irq
  764. cheetah_plus_dcpe_trap_vector_tl1:
  765. membar #Sync
  766. wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
  767. sethi %hi(do_dcpe_tl1), %g3
  768. jmpl %g3 + %lo(do_dcpe_tl1), %g0
  769. nop
  770. nop
  771. nop
  772. nop
  773. .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
  774. cheetah_plus_icpe_trap_vector:
  775. membar #Sync
  776. sethi %hi(do_cheetah_plus_insn_parity), %g7
  777. jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
  778. nop
  779. nop
  780. nop
  781. nop
  782. nop
  783. do_cheetah_plus_insn_parity:
  784. rdpr %pil, %g2
  785. wrpr %g0, 15, %pil
  786. ba,pt %xcc, etrap_irq
  787. rd %pc, %g7
  788. mov 0x1, %o0
  789. call cheetah_plus_parity_error
  790. add %sp, PTREGS_OFF, %o1
  791. ba,a,pt %xcc, rtrap_irq
  792. cheetah_plus_icpe_trap_vector_tl1:
  793. membar #Sync
  794. wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
  795. sethi %hi(do_icpe_tl1), %g3
  796. jmpl %g3 + %lo(do_icpe_tl1), %g0
  797. nop
  798. nop
  799. nop
  800. nop
  801. /* If we take one of these traps when tl >= 1, then we
  802. * jump to interrupt globals. If some trap level above us
  803. * was also using interrupt globals, we cannot recover.
  804. * We may use all interrupt global registers except %g6.
  805. */
  806. .globl do_dcpe_tl1, do_icpe_tl1
  807. do_dcpe_tl1:
  808. rdpr %tl, %g1 ! Save original trap level
  809. mov 1, %g2 ! Setup TSTATE checking loop
  810. sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
  811. 1: wrpr %g2, %tl ! Set trap level to check
  812. rdpr %tstate, %g4 ! Read TSTATE for this level
  813. andcc %g4, %g3, %g0 ! Interrupt globals in use?
  814. bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
  815. wrpr %g1, %tl ! Restore original trap level
  816. add %g2, 1, %g2 ! Next trap level
  817. cmp %g2, %g1 ! Hit them all yet?
  818. ble,pt %icc, 1b ! Not yet
  819. nop
  820. wrpr %g1, %tl ! Restore original trap level
  821. do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
  822. sethi %hi(dcache_parity_tl1_occurred), %g2
  823. lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
  824. add %g1, 1, %g1
  825. stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
  826. /* Reset D-cache parity */
  827. sethi %hi(1 << 16), %g1 ! D-cache size
  828. mov (1 << 5), %g2 ! D-cache line size
  829. sub %g1, %g2, %g1 ! Move down 1 cacheline
  830. 1: srl %g1, 14, %g3 ! Compute UTAG
  831. membar #Sync
  832. stxa %g3, [%g1] ASI_DCACHE_UTAG
  833. membar #Sync
  834. sub %g2, 8, %g3 ! 64-bit data word within line
  835. 2: membar #Sync
  836. stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
  837. membar #Sync
  838. subcc %g3, 8, %g3 ! Next 64-bit data word
  839. bge,pt %icc, 2b
  840. nop
  841. subcc %g1, %g2, %g1 ! Next cacheline
  842. bge,pt %icc, 1b
  843. nop
  844. ba,pt %xcc, dcpe_icpe_tl1_common
  845. nop
  846. do_dcpe_tl1_fatal:
  847. sethi %hi(1f), %g7
  848. ba,pt %xcc, etraptl1
  849. 1: or %g7, %lo(1b), %g7
  850. mov 0x2, %o0
  851. call cheetah_plus_parity_error
  852. add %sp, PTREGS_OFF, %o1
  853. ba,pt %xcc, rtrap
  854. clr %l6
  855. do_icpe_tl1:
  856. rdpr %tl, %g1 ! Save original trap level
  857. mov 1, %g2 ! Setup TSTATE checking loop
  858. sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
  859. 1: wrpr %g2, %tl ! Set trap level to check
  860. rdpr %tstate, %g4 ! Read TSTATE for this level
  861. andcc %g4, %g3, %g0 ! Interrupt globals in use?
  862. bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
  863. wrpr %g1, %tl ! Restore original trap level
  864. add %g2, 1, %g2 ! Next trap level
  865. cmp %g2, %g1 ! Hit them all yet?
  866. ble,pt %icc, 1b ! Not yet
  867. nop
  868. wrpr %g1, %tl ! Restore original trap level
  869. do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
  870. sethi %hi(icache_parity_tl1_occurred), %g2
  871. lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
  872. add %g1, 1, %g1
  873. stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
  874. /* Flush I-cache */
  875. sethi %hi(1 << 15), %g1 ! I-cache size
  876. mov (1 << 5), %g2 ! I-cache line size
  877. sub %g1, %g2, %g1
  878. 1: or %g1, (2 << 3), %g3
  879. stxa %g0, [%g3] ASI_IC_TAG
  880. membar #Sync
  881. subcc %g1, %g2, %g1
  882. bge,pt %icc, 1b
  883. nop
  884. ba,pt %xcc, dcpe_icpe_tl1_common
  885. nop
  886. do_icpe_tl1_fatal:
  887. sethi %hi(1f), %g7
  888. ba,pt %xcc, etraptl1
  889. 1: or %g7, %lo(1b), %g7
  890. mov 0x3, %o0
  891. call cheetah_plus_parity_error
  892. add %sp, PTREGS_OFF, %o1
  893. ba,pt %xcc, rtrap
  894. clr %l6
  895. dcpe_icpe_tl1_common:
  896. /* Flush D-cache, re-enable D/I caches in DCU and finally
  897. * retry the trapping instruction.
  898. */
  899. sethi %hi(1 << 16), %g1 ! D-cache size
  900. mov (1 << 5), %g2 ! D-cache line size
  901. sub %g1, %g2, %g1
  902. 1: stxa %g0, [%g1] ASI_DCACHE_TAG
  903. membar #Sync
  904. subcc %g1, %g2, %g1
  905. bge,pt %icc, 1b
  906. nop
  907. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  908. or %g1, (DCU_DC | DCU_IC), %g1
  909. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  910. membar #Sync
  911. retry
  912. /* Capture I/D/E-cache state into per-cpu error scoreboard.
  913. *
  914. * %g1: (TL>=0) ? 1 : 0
  915. * %g2: scratch
  916. * %g3: scratch
  917. * %g4: AFSR
  918. * %g5: AFAR
  919. * %g6: unused, will have current thread ptr after etrap
  920. * %g7: scratch
  921. */
  922. __cheetah_log_error:
  923. /* Put "TL1" software bit into AFSR. */
  924. and %g1, 0x1, %g1
  925. sllx %g1, 63, %g2
  926. or %g4, %g2, %g4
  927. /* Get log entry pointer for this cpu at this trap level. */
  928. BRANCH_IF_JALAPENO(g2,g3,50f)
  929. ldxa [%g0] ASI_SAFARI_CONFIG, %g2
  930. srlx %g2, 17, %g2
  931. ba,pt %xcc, 60f
  932. and %g2, 0x3ff, %g2
  933. 50: ldxa [%g0] ASI_JBUS_CONFIG, %g2
  934. srlx %g2, 17, %g2
  935. and %g2, 0x1f, %g2
  936. 60: sllx %g2, 9, %g2
  937. sethi %hi(cheetah_error_log), %g3
  938. ldx [%g3 + %lo(cheetah_error_log)], %g3
  939. brz,pn %g3, 80f
  940. nop
  941. add %g3, %g2, %g3
  942. sllx %g1, 8, %g1
  943. add %g3, %g1, %g1
  944. /* %g1 holds pointer to the top of the logging scoreboard */
  945. ldx [%g1 + 0x0], %g7
  946. cmp %g7, -1
  947. bne,pn %xcc, 80f
  948. nop
  949. stx %g4, [%g1 + 0x0]
  950. stx %g5, [%g1 + 0x8]
  951. add %g1, 0x10, %g1
  952. /* %g1 now points to D-cache logging area */
  953. set 0x3ff8, %g2 /* DC_addr mask */
  954. and %g5, %g2, %g2 /* DC_addr bits of AFAR */
  955. srlx %g5, 12, %g3
  956. or %g3, 1, %g3 /* PHYS tag + valid */
  957. 10: ldxa [%g2] ASI_DCACHE_TAG, %g7
  958. cmp %g3, %g7 /* TAG match? */
  959. bne,pt %xcc, 13f
  960. nop
  961. /* Yep, what we want, capture state. */
  962. stx %g2, [%g1 + 0x20]
  963. stx %g7, [%g1 + 0x28]
  964. /* A membar Sync is required before and after utag access. */
  965. membar #Sync
  966. ldxa [%g2] ASI_DCACHE_UTAG, %g7
  967. membar #Sync
  968. stx %g7, [%g1 + 0x30]
  969. ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
  970. stx %g7, [%g1 + 0x38]
  971. clr %g3
  972. 12: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
  973. stx %g7, [%g1]
  974. add %g3, (1 << 5), %g3
  975. cmp %g3, (4 << 5)
  976. bl,pt %xcc, 12b
  977. add %g1, 0x8, %g1
  978. ba,pt %xcc, 20f
  979. add %g1, 0x20, %g1
  980. 13: sethi %hi(1 << 14), %g7
  981. add %g2, %g7, %g2
  982. srlx %g2, 14, %g7
  983. cmp %g7, 4
  984. bl,pt %xcc, 10b
  985. nop
  986. add %g1, 0x40, %g1
  987. /* %g1 now points to I-cache logging area */
  988. 20: set 0x1fe0, %g2 /* IC_addr mask */
  989. and %g5, %g2, %g2 /* IC_addr bits of AFAR */
  990. sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
  991. srlx %g5, (13 - 8), %g3 /* Make PTAG */
  992. andn %g3, 0xff, %g3 /* Mask off undefined bits */
  993. 21: ldxa [%g2] ASI_IC_TAG, %g7
  994. andn %g7, 0xff, %g7
  995. cmp %g3, %g7
  996. bne,pt %xcc, 23f
  997. nop
  998. /* Yep, what we want, capture state. */
  999. stx %g2, [%g1 + 0x40]
  1000. stx %g7, [%g1 + 0x48]
  1001. add %g2, (1 << 3), %g2
  1002. ldxa [%g2] ASI_IC_TAG, %g7
  1003. add %g2, (1 << 3), %g2
  1004. stx %g7, [%g1 + 0x50]
  1005. ldxa [%g2] ASI_IC_TAG, %g7
  1006. add %g2, (1 << 3), %g2
  1007. stx %g7, [%g1 + 0x60]
  1008. ldxa [%g2] ASI_IC_TAG, %g7
  1009. stx %g7, [%g1 + 0x68]
  1010. sub %g2, (3 << 3), %g2
  1011. ldxa [%g2] ASI_IC_STAG, %g7
  1012. stx %g7, [%g1 + 0x58]
  1013. clr %g3
  1014. srlx %g2, 2, %g2
  1015. 22: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
  1016. stx %g7, [%g1]
  1017. add %g3, (1 << 3), %g3
  1018. cmp %g3, (8 << 3)
  1019. bl,pt %xcc, 22b
  1020. add %g1, 0x8, %g1
  1021. ba,pt %xcc, 30f
  1022. add %g1, 0x30, %g1
  1023. 23: sethi %hi(1 << 14), %g7
  1024. add %g2, %g7, %g2
  1025. srlx %g2, 14, %g7
  1026. cmp %g7, 4
  1027. bl,pt %xcc, 21b
  1028. nop
  1029. add %g1, 0x70, %g1
  1030. /* %g1 now points to E-cache logging area */
  1031. 30: andn %g5, (32 - 1), %g2
  1032. stx %g2, [%g1 + 0x20]
  1033. ldxa [%g2] ASI_EC_TAG_DATA, %g7
  1034. stx %g7, [%g1 + 0x28]
  1035. ldxa [%g2] ASI_EC_R, %g0
  1036. clr %g3
  1037. 31: ldxa [%g3] ASI_EC_DATA, %g7
  1038. stx %g7, [%g1 + %g3]
  1039. add %g3, 0x8, %g3
  1040. cmp %g3, 0x20
  1041. bl,pt %xcc, 31b
  1042. nop
  1043. 80:
  1044. rdpr %tt, %g2
  1045. cmp %g2, 0x70
  1046. be c_fast_ecc
  1047. cmp %g2, 0x63
  1048. be c_cee
  1049. nop
  1050. ba,pt %xcc, c_deferred
  1051. /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
  1052. * in the trap table. That code has done a memory barrier
  1053. * and has disabled both the I-cache and D-cache in the DCU
  1054. * control register. The I-cache is disabled so that we may
  1055. * capture the corrupted cache line, and the D-cache is disabled
  1056. * because corrupt data may have been placed there and we don't
  1057. * want to reference it.
  1058. *
  1059. * %g1 is one if this trap occurred at %tl >= 1.
  1060. *
  1061. * Next, we turn off error reporting so that we don't recurse.
  1062. */
  1063. .globl cheetah_fast_ecc
  1064. cheetah_fast_ecc:
  1065. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1066. andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
  1067. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1068. membar #Sync
  1069. /* Fetch and clear AFSR/AFAR */
  1070. ldxa [%g0] ASI_AFSR, %g4
  1071. ldxa [%g0] ASI_AFAR, %g5
  1072. stxa %g4, [%g0] ASI_AFSR
  1073. membar #Sync
  1074. ba,pt %xcc, __cheetah_log_error
  1075. nop
  1076. c_fast_ecc:
  1077. rdpr %pil, %g2
  1078. wrpr %g0, 15, %pil
  1079. ba,pt %xcc, etrap_irq
  1080. rd %pc, %g7
  1081. mov %l4, %o1
  1082. mov %l5, %o2
  1083. call cheetah_fecc_handler
  1084. add %sp, PTREGS_OFF, %o0
  1085. ba,a,pt %xcc, rtrap_irq
  1086. /* Our caller has disabled I-cache and performed membar Sync. */
  1087. .globl cheetah_cee
  1088. cheetah_cee:
  1089. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1090. andn %g2, ESTATE_ERROR_CEEN, %g2
  1091. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1092. membar #Sync
  1093. /* Fetch and clear AFSR/AFAR */
  1094. ldxa [%g0] ASI_AFSR, %g4
  1095. ldxa [%g0] ASI_AFAR, %g5
  1096. stxa %g4, [%g0] ASI_AFSR
  1097. membar #Sync
  1098. ba,pt %xcc, __cheetah_log_error
  1099. nop
  1100. c_cee:
  1101. rdpr %pil, %g2
  1102. wrpr %g0, 15, %pil
  1103. ba,pt %xcc, etrap_irq
  1104. rd %pc, %g7
  1105. mov %l4, %o1
  1106. mov %l5, %o2
  1107. call cheetah_cee_handler
  1108. add %sp, PTREGS_OFF, %o0
  1109. ba,a,pt %xcc, rtrap_irq
  1110. /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
  1111. .globl cheetah_deferred_trap
  1112. cheetah_deferred_trap:
  1113. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1114. andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
  1115. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1116. membar #Sync
  1117. /* Fetch and clear AFSR/AFAR */
  1118. ldxa [%g0] ASI_AFSR, %g4
  1119. ldxa [%g0] ASI_AFAR, %g5
  1120. stxa %g4, [%g0] ASI_AFSR
  1121. membar #Sync
  1122. ba,pt %xcc, __cheetah_log_error
  1123. nop
  1124. c_deferred:
  1125. rdpr %pil, %g2
  1126. wrpr %g0, 15, %pil
  1127. ba,pt %xcc, etrap_irq
  1128. rd %pc, %g7
  1129. mov %l4, %o1
  1130. mov %l5, %o2
  1131. call cheetah_deferred_handler
  1132. add %sp, PTREGS_OFF, %o0
  1133. ba,a,pt %xcc, rtrap_irq
  1134. .globl __do_privact
  1135. __do_privact:
  1136. mov TLB_SFSR, %g3
  1137. stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
  1138. membar #Sync
  1139. sethi %hi(109f), %g7
  1140. ba,pt %xcc, etrap
  1141. 109: or %g7, %lo(109b), %g7
  1142. call do_privact
  1143. add %sp, PTREGS_OFF, %o0
  1144. ba,pt %xcc, rtrap
  1145. clr %l6
  1146. .globl do_mna
  1147. do_mna:
  1148. rdpr %tl, %g3
  1149. cmp %g3, 1
  1150. /* Setup %g4/%g5 now as they are used in the
  1151. * winfixup code.
  1152. */
  1153. mov TLB_SFSR, %g3
  1154. mov DMMU_SFAR, %g4
  1155. ldxa [%g4] ASI_DMMU, %g4
  1156. ldxa [%g3] ASI_DMMU, %g5
  1157. stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
  1158. membar #Sync
  1159. bgu,pn %icc, winfix_mna
  1160. rdpr %tpc, %g3
  1161. 1: sethi %hi(109f), %g7
  1162. ba,pt %xcc, etrap
  1163. 109: or %g7, %lo(109b), %g7
  1164. mov %l4, %o1
  1165. mov %l5, %o2
  1166. call mem_address_unaligned
  1167. add %sp, PTREGS_OFF, %o0
  1168. ba,pt %xcc, rtrap
  1169. clr %l6
  1170. .globl do_lddfmna
  1171. do_lddfmna:
  1172. sethi %hi(109f), %g7
  1173. mov TLB_SFSR, %g4
  1174. ldxa [%g4] ASI_DMMU, %g5
  1175. stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
  1176. membar #Sync
  1177. mov DMMU_SFAR, %g4
  1178. ldxa [%g4] ASI_DMMU, %g4
  1179. ba,pt %xcc, etrap
  1180. 109: or %g7, %lo(109b), %g7
  1181. mov %l4, %o1
  1182. mov %l5, %o2
  1183. call handle_lddfmna
  1184. add %sp, PTREGS_OFF, %o0
  1185. ba,pt %xcc, rtrap
  1186. clr %l6
  1187. .globl do_stdfmna
  1188. do_stdfmna:
  1189. sethi %hi(109f), %g7
  1190. mov TLB_SFSR, %g4
  1191. ldxa [%g4] ASI_DMMU, %g5
  1192. stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
  1193. membar #Sync
  1194. mov DMMU_SFAR, %g4
  1195. ldxa [%g4] ASI_DMMU, %g4
  1196. ba,pt %xcc, etrap
  1197. 109: or %g7, %lo(109b), %g7
  1198. mov %l4, %o1
  1199. mov %l5, %o2
  1200. call handle_stdfmna
  1201. add %sp, PTREGS_OFF, %o0
  1202. ba,pt %xcc, rtrap
  1203. clr %l6
  1204. .globl breakpoint_trap
  1205. breakpoint_trap:
  1206. call sparc_breakpoint
  1207. add %sp, PTREGS_OFF, %o0
  1208. ba,pt %xcc, rtrap
  1209. nop
  1210. #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
  1211. defined(CONFIG_SOLARIS_EMUL_MODULE)
  1212. /* SunOS uses syscall zero as the 'indirect syscall' it looks
  1213. * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
  1214. * This is complete brain damage.
  1215. */
  1216. .globl sunos_indir
  1217. sunos_indir:
  1218. srl %o0, 0, %o0
  1219. mov %o7, %l4
  1220. cmp %o0, NR_SYSCALLS
  1221. blu,a,pt %icc, 1f
  1222. sll %o0, 0x2, %o0
  1223. sethi %hi(sunos_nosys), %l6
  1224. b,pt %xcc, 2f
  1225. or %l6, %lo(sunos_nosys), %l6
  1226. 1: sethi %hi(sunos_sys_table), %l7
  1227. or %l7, %lo(sunos_sys_table), %l7
  1228. lduw [%l7 + %o0], %l6
  1229. 2: mov %o1, %o0
  1230. mov %o2, %o1
  1231. mov %o3, %o2
  1232. mov %o4, %o3
  1233. mov %o5, %o4
  1234. call %l6
  1235. mov %l4, %o7
  1236. .globl sunos_getpid
  1237. sunos_getpid:
  1238. call sys_getppid
  1239. nop
  1240. call sys_getpid
  1241. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1242. b,pt %xcc, ret_sys_call
  1243. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1244. /* SunOS getuid() returns uid in %o0 and euid in %o1 */
  1245. .globl sunos_getuid
  1246. sunos_getuid:
  1247. call sys32_geteuid16
  1248. nop
  1249. call sys32_getuid16
  1250. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1251. b,pt %xcc, ret_sys_call
  1252. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1253. /* SunOS getgid() returns gid in %o0 and egid in %o1 */
  1254. .globl sunos_getgid
  1255. sunos_getgid:
  1256. call sys32_getegid16
  1257. nop
  1258. call sys32_getgid16
  1259. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1260. b,pt %xcc, ret_sys_call
  1261. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1262. #endif
  1263. /* SunOS's execv() call only specifies the argv argument, the
  1264. * environment settings are the same as the calling processes.
  1265. */
  1266. .globl sunos_execv
  1267. sys_execve:
  1268. sethi %hi(sparc_execve), %g1
  1269. ba,pt %xcc, execve_merge
  1270. or %g1, %lo(sparc_execve), %g1
  1271. #ifdef CONFIG_COMPAT
  1272. .globl sys_execve
  1273. sunos_execv:
  1274. stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
  1275. .globl sys32_execve
  1276. sys32_execve:
  1277. sethi %hi(sparc32_execve), %g1
  1278. or %g1, %lo(sparc32_execve), %g1
  1279. #endif
  1280. execve_merge:
  1281. flushw
  1282. jmpl %g1, %g0
  1283. add %sp, PTREGS_OFF, %o0
  1284. .globl sys_pipe, sys_sigpause, sys_nis_syscall
  1285. .globl sys_rt_sigreturn
  1286. .globl sys_ptrace
  1287. .globl sys_sigaltstack
  1288. .align 32
  1289. sys_pipe: ba,pt %xcc, sparc_pipe
  1290. add %sp, PTREGS_OFF, %o0
  1291. sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
  1292. add %sp, PTREGS_OFF, %o0
  1293. sys_memory_ordering:
  1294. ba,pt %xcc, sparc_memory_ordering
  1295. add %sp, PTREGS_OFF, %o1
  1296. sys_sigaltstack:ba,pt %xcc, do_sigaltstack
  1297. add %i6, STACK_BIAS, %o2
  1298. #ifdef CONFIG_COMPAT
  1299. .globl sys32_sigstack
  1300. sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
  1301. mov %i6, %o2
  1302. .globl sys32_sigaltstack
  1303. sys32_sigaltstack:
  1304. ba,pt %xcc, do_sys32_sigaltstack
  1305. mov %i6, %o2
  1306. #endif
  1307. .align 32
  1308. #ifdef CONFIG_COMPAT
  1309. .globl sys32_sigreturn
  1310. sys32_sigreturn:
  1311. add %sp, PTREGS_OFF, %o0
  1312. call do_sigreturn32
  1313. add %o7, 1f-.-4, %o7
  1314. nop
  1315. #endif
  1316. sys_rt_sigreturn:
  1317. add %sp, PTREGS_OFF, %o0
  1318. call do_rt_sigreturn
  1319. add %o7, 1f-.-4, %o7
  1320. nop
  1321. #ifdef CONFIG_COMPAT
  1322. .globl sys32_rt_sigreturn
  1323. sys32_rt_sigreturn:
  1324. add %sp, PTREGS_OFF, %o0
  1325. call do_rt_sigreturn32
  1326. add %o7, 1f-.-4, %o7
  1327. nop
  1328. #endif
  1329. sys_ptrace: add %sp, PTREGS_OFF, %o0
  1330. call do_ptrace
  1331. add %o7, 1f-.-4, %o7
  1332. nop
  1333. .align 32
  1334. 1: ldx [%curptr + TI_FLAGS], %l5
  1335. andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1336. be,pt %icc, rtrap
  1337. clr %l6
  1338. add %sp, PTREGS_OFF, %o0
  1339. call syscall_trace
  1340. mov 1, %o1
  1341. ba,pt %xcc, rtrap
  1342. clr %l6
  1343. /* This is how fork() was meant to be done, 8 instruction entry.
  1344. *
  1345. * I questioned the following code briefly, let me clear things
  1346. * up so you must not reason on it like I did.
  1347. *
  1348. * Know the fork_kpsr etc. we use in the sparc32 port? We don't
  1349. * need it here because the only piece of window state we copy to
  1350. * the child is the CWP register. Even if the parent sleeps,
  1351. * we are safe because we stuck it into pt_regs of the parent
  1352. * so it will not change.
  1353. *
  1354. * XXX This raises the question, whether we can do the same on
  1355. * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
  1356. * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
  1357. * XXX fork_kwim in UREG_G1 (global registers are considered
  1358. * XXX volatile across a system call in the sparc ABI I think
  1359. * XXX if it isn't we can use regs->y instead, anyone who depends
  1360. * XXX upon the Y register being preserved across a fork deserves
  1361. * XXX to lose).
  1362. *
  1363. * In fact we should take advantage of that fact for other things
  1364. * during system calls...
  1365. */
  1366. .globl sys_fork, sys_vfork, sys_clone, sparc_exit
  1367. .globl ret_from_syscall
  1368. .align 32
  1369. sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
  1370. sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
  1371. or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
  1372. ba,pt %xcc, sys_clone
  1373. sys_fork: clr %o1
  1374. mov SIGCHLD, %o0
  1375. sys_clone: flushw
  1376. movrz %o1, %fp, %o1
  1377. mov 0, %o3
  1378. ba,pt %xcc, sparc_do_fork
  1379. add %sp, PTREGS_OFF, %o2
  1380. ret_from_syscall:
  1381. /* Clear current_thread_info()->new_child, and
  1382. * check performance counter stuff too.
  1383. */
  1384. stb %g0, [%g6 + TI_NEW_CHILD]
  1385. ldx [%g6 + TI_FLAGS], %l0
  1386. call schedule_tail
  1387. mov %g7, %o0
  1388. andcc %l0, _TIF_PERFCTR, %g0
  1389. be,pt %icc, 1f
  1390. nop
  1391. ldx [%g6 + TI_PCR], %o7
  1392. wr %g0, %o7, %pcr
  1393. /* Blackbird errata workaround. See commentary in
  1394. * smp.c:smp_percpu_timer_interrupt() for more
  1395. * information.
  1396. */
  1397. ba,pt %xcc, 99f
  1398. nop
  1399. .align 64
  1400. 99: wr %g0, %g0, %pic
  1401. rd %pic, %g0
  1402. 1: b,pt %xcc, ret_sys_call
  1403. ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
  1404. sparc_exit: rdpr %pstate, %g2
  1405. wrpr %g2, PSTATE_IE, %pstate
  1406. rdpr %otherwin, %g1
  1407. rdpr %cansave, %g3
  1408. add %g3, %g1, %g3
  1409. wrpr %g3, 0x0, %cansave
  1410. wrpr %g0, 0x0, %otherwin
  1411. wrpr %g2, 0x0, %pstate
  1412. ba,pt %xcc, sys_exit
  1413. stb %g0, [%g6 + TI_WSAVED]
  1414. linux_sparc_ni_syscall:
  1415. sethi %hi(sys_ni_syscall), %l7
  1416. b,pt %xcc, 4f
  1417. or %l7, %lo(sys_ni_syscall), %l7
  1418. linux_syscall_trace32:
  1419. add %sp, PTREGS_OFF, %o0
  1420. call syscall_trace
  1421. clr %o1
  1422. srl %i0, 0, %o0
  1423. srl %i4, 0, %o4
  1424. srl %i1, 0, %o1
  1425. srl %i2, 0, %o2
  1426. b,pt %xcc, 2f
  1427. srl %i3, 0, %o3
  1428. linux_syscall_trace:
  1429. add %sp, PTREGS_OFF, %o0
  1430. call syscall_trace
  1431. clr %o1
  1432. mov %i0, %o0
  1433. mov %i1, %o1
  1434. mov %i2, %o2
  1435. mov %i3, %o3
  1436. b,pt %xcc, 2f
  1437. mov %i4, %o4
  1438. /* Linux 32-bit and SunOS system calls enter here... */
  1439. .align 32
  1440. .globl linux_sparc_syscall32
  1441. linux_sparc_syscall32:
  1442. /* Direct access to user regs, much faster. */
  1443. cmp %g1, NR_SYSCALLS ! IEU1 Group
  1444. bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
  1445. srl %i0, 0, %o0 ! IEU0
  1446. sll %g1, 2, %l4 ! IEU0 Group
  1447. srl %i4, 0, %o4 ! IEU1
  1448. lduw [%l7 + %l4], %l7 ! Load
  1449. srl %i1, 0, %o1 ! IEU0 Group
  1450. ldx [%curptr + TI_FLAGS], %l0 ! Load
  1451. srl %i5, 0, %o5 ! IEU1
  1452. srl %i2, 0, %o2 ! IEU0 Group
  1453. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1454. bne,pn %icc, linux_syscall_trace32 ! CTI
  1455. mov %i0, %l5 ! IEU1
  1456. call %l7 ! CTI Group brk forced
  1457. srl %i3, 0, %o3 ! IEU0
  1458. ba,a,pt %xcc, 3f
  1459. /* Linux native and SunOS system calls enter here... */
  1460. .align 32
  1461. .globl linux_sparc_syscall, ret_sys_call
  1462. linux_sparc_syscall:
  1463. /* Direct access to user regs, much faster. */
  1464. cmp %g1, NR_SYSCALLS ! IEU1 Group
  1465. bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
  1466. mov %i0, %o0 ! IEU0
  1467. sll %g1, 2, %l4 ! IEU0 Group
  1468. mov %i1, %o1 ! IEU1
  1469. lduw [%l7 + %l4], %l7 ! Load
  1470. 4: mov %i2, %o2 ! IEU0 Group
  1471. ldx [%curptr + TI_FLAGS], %l0 ! Load
  1472. mov %i3, %o3 ! IEU1
  1473. mov %i4, %o4 ! IEU0 Group
  1474. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1475. bne,pn %icc, linux_syscall_trace ! CTI Group
  1476. mov %i0, %l5 ! IEU0
  1477. 2: call %l7 ! CTI Group brk forced
  1478. mov %i5, %o5 ! IEU0
  1479. nop
  1480. 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1481. ret_sys_call:
  1482. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
  1483. ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
  1484. sra %o0, 0, %o0
  1485. mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
  1486. sllx %g2, 32, %g2
  1487. /* Check if force_successful_syscall_return()
  1488. * was invoked.
  1489. */
  1490. ldub [%curptr + TI_SYS_NOERROR], %l2
  1491. brnz,a,pn %l2, 80f
  1492. stb %g0, [%curptr + TI_SYS_NOERROR]
  1493. cmp %o0, -ERESTART_RESTARTBLOCK
  1494. bgeu,pn %xcc, 1f
  1495. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
  1496. 80:
  1497. /* System call success, clear Carry condition code. */
  1498. andn %g3, %g2, %g3
  1499. stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
  1500. bne,pn %icc, linux_syscall_trace2
  1501. add %l1, 0x4, %l2 ! npc = npc+4
  1502. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1503. ba,pt %xcc, rtrap_clr_l6
  1504. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1505. 1:
  1506. /* System call failure, set Carry condition code.
  1507. * Also, get abs(errno) to return to the process.
  1508. */
  1509. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
  1510. sub %g0, %o0, %o0
  1511. or %g3, %g2, %g3
  1512. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1513. mov 1, %l6
  1514. stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
  1515. bne,pn %icc, linux_syscall_trace2
  1516. add %l1, 0x4, %l2 ! npc = npc+4
  1517. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1518. b,pt %xcc, rtrap
  1519. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1520. linux_syscall_trace2:
  1521. add %sp, PTREGS_OFF, %o0
  1522. call syscall_trace
  1523. mov 1, %o1
  1524. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1525. ba,pt %xcc, rtrap
  1526. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1527. .align 32
  1528. .globl __flushw_user
  1529. __flushw_user:
  1530. rdpr %otherwin, %g1
  1531. brz,pn %g1, 2f
  1532. clr %g2
  1533. 1: save %sp, -128, %sp
  1534. rdpr %otherwin, %g1
  1535. brnz,pt %g1, 1b
  1536. add %g2, 1, %g2
  1537. 1: sub %g2, 1, %g2
  1538. brnz,pt %g2, 1b
  1539. restore %g0, %g0, %g0
  1540. 2: retl
  1541. nop
  1542. #ifdef CONFIG_SMP
  1543. .globl hard_smp_processor_id
  1544. hard_smp_processor_id:
  1545. #endif
  1546. .globl real_hard_smp_processor_id
  1547. real_hard_smp_processor_id:
  1548. __GET_CPUID(%o0)
  1549. retl
  1550. nop
  1551. /* %o0: devhandle
  1552. * %o1: devino
  1553. *
  1554. * returns %o0: sysino
  1555. */
  1556. .globl sun4v_devino_to_sysino
  1557. sun4v_devino_to_sysino:
  1558. mov HV_FAST_INTR_DEVINO2SYSINO, %o5
  1559. ta HV_FAST_TRAP
  1560. retl
  1561. mov %o1, %o0
  1562. /* %o0: sysino
  1563. *
  1564. * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED})
  1565. */
  1566. .globl sun4v_intr_getenabled
  1567. sun4v_intr_getenabled:
  1568. mov HV_FAST_INTR_GETENABLED, %o5
  1569. ta HV_FAST_TRAP
  1570. retl
  1571. mov %o1, %o0
  1572. /* %o0: sysino
  1573. * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
  1574. */
  1575. .globl sun4v_intr_setenabled
  1576. sun4v_intr_setenabled:
  1577. mov HV_FAST_INTR_SETENABLED, %o5
  1578. ta HV_FAST_TRAP
  1579. retl
  1580. nop
  1581. /* %o0: sysino
  1582. *
  1583. * returns %o0: intr_state (HV_INTR_STATE_*)
  1584. */
  1585. .globl sun4v_intr_getstate
  1586. sun4v_intr_getstate:
  1587. mov HV_FAST_INTR_GETSTATE, %o5
  1588. ta HV_FAST_TRAP
  1589. retl
  1590. mov %o1, %o0
  1591. /* %o0: sysino
  1592. * %o1: intr_state (HV_INTR_STATE_*)
  1593. */
  1594. .globl sun4v_intr_setstate
  1595. sun4v_intr_setstate:
  1596. mov HV_FAST_INTR_SETSTATE, %o5
  1597. ta HV_FAST_TRAP
  1598. retl
  1599. nop
  1600. /* %o0: sysino
  1601. *
  1602. * returns %o0: cpuid
  1603. */
  1604. .globl sun4v_intr_gettarget
  1605. sun4v_intr_gettarget:
  1606. mov HV_FAST_INTR_GETTARGET, %o5
  1607. ta HV_FAST_TRAP
  1608. retl
  1609. mov %o1, %o0
  1610. /* %o0: sysino
  1611. * %o1: cpuid
  1612. */
  1613. .globl sun4v_intr_settarget
  1614. sun4v_intr_settarget:
  1615. mov HV_FAST_INTR_SETTARGET, %o5
  1616. ta HV_FAST_TRAP
  1617. retl
  1618. nop
  1619. /* %o0: type
  1620. * %o1: queue paddr
  1621. * %o2: num queue entries
  1622. *
  1623. * returns %o0: status
  1624. */
  1625. .globl sun4v_cpu_qconf
  1626. sun4v_cpu_qconf:
  1627. mov HV_FAST_CPU_QCONF, %o5
  1628. ta HV_FAST_TRAP
  1629. retl
  1630. nop
  1631. /* returns %o0: status
  1632. */
  1633. .globl sun4v_cpu_yield
  1634. sun4v_cpu_yield:
  1635. mov HV_FAST_CPU_YIELD, %o5
  1636. ta HV_FAST_TRAP
  1637. retl
  1638. nop
  1639. /* %o0: num cpus in cpu list
  1640. * %o1: cpu list paddr
  1641. * %o2: mondo block paddr
  1642. *
  1643. * returns %o0: status
  1644. */
  1645. .globl sun4v_cpu_mondo_send
  1646. sun4v_cpu_mondo_send:
  1647. mov HV_FAST_CPU_MONDO_SEND, %o5
  1648. ta HV_FAST_TRAP
  1649. retl
  1650. nop
  1651. /* %o0: CPU ID
  1652. *
  1653. * returns %o0: -status if status non-zero, else
  1654. * %o0: cpu state as HV_CPU_STATE_*
  1655. */
  1656. .globl sun4v_cpu_state
  1657. sun4v_cpu_state:
  1658. mov HV_FAST_CPU_STATE, %o5
  1659. ta HV_FAST_TRAP
  1660. brnz,pn %o0, 1f
  1661. sub %g0, %o0, %o0
  1662. mov %o1, %o0
  1663. 1: retl
  1664. nop