entry.S 43 KB

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