entry.S 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697
  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. stx %fsr, [%g6 + TI_XFSR]
  330. do_fptrap_after_fsr:
  331. ldub [%g6 + TI_FPSAVED], %g3
  332. rd %fprs, %g1
  333. or %g3, %g1, %g3
  334. stb %g3, [%g6 + TI_FPSAVED]
  335. rd %gsr, %g3
  336. stx %g3, [%g6 + TI_GSR]
  337. mov SECONDARY_CONTEXT, %g3
  338. 661: ldxa [%g3] ASI_DMMU, %g5
  339. .section .sun4v_1insn_patch, "ax"
  340. .word 661b
  341. ldxa [%g3] ASI_MMU, %g5
  342. .previous
  343. sethi %hi(sparc64_kern_sec_context), %g2
  344. ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
  345. 661: stxa %g2, [%g3] ASI_DMMU
  346. .section .sun4v_1insn_patch, "ax"
  347. .word 661b
  348. stxa %g2, [%g3] ASI_MMU
  349. .previous
  350. membar #Sync
  351. add %g6, TI_FPREGS, %g2
  352. andcc %g1, FPRS_DL, %g0
  353. be,pn %icc, 4f
  354. mov 0x40, %g3
  355. stda %f0, [%g2] ASI_BLK_S
  356. stda %f16, [%g2 + %g3] ASI_BLK_S
  357. andcc %g1, FPRS_DU, %g0
  358. be,pn %icc, 5f
  359. 4: add %g2, 128, %g2
  360. stda %f32, [%g2] ASI_BLK_S
  361. stda %f48, [%g2 + %g3] ASI_BLK_S
  362. 5: mov SECONDARY_CONTEXT, %g1
  363. membar #Sync
  364. 661: stxa %g5, [%g1] ASI_DMMU
  365. .section .sun4v_1insn_patch, "ax"
  366. .word 661b
  367. stxa %g5, [%g1] ASI_MMU
  368. .previous
  369. membar #Sync
  370. ba,pt %xcc, etrap
  371. wr %g0, 0, %fprs
  372. /* The registers for cross calls will be:
  373. *
  374. * DATA 0: [low 32-bits] Address of function to call, jmp to this
  375. * [high 32-bits] MMU Context Argument 0, place in %g5
  376. * DATA 1: Address Argument 1, place in %g1
  377. * DATA 2: Address Argument 2, place in %g7
  378. *
  379. * With this method we can do most of the cross-call tlb/cache
  380. * flushing very quickly.
  381. */
  382. .text
  383. .align 32
  384. .globl do_ivec
  385. do_ivec:
  386. mov 0x40, %g3
  387. ldxa [%g3 + %g0] ASI_INTR_R, %g3
  388. sethi %hi(KERNBASE), %g4
  389. cmp %g3, %g4
  390. bgeu,pn %xcc, do_ivec_xcall
  391. srlx %g3, 32, %g5
  392. stxa %g0, [%g0] ASI_INTR_RECEIVE
  393. membar #Sync
  394. sethi %hi(ivector_table), %g2
  395. sllx %g3, 5, %g3
  396. or %g2, %lo(ivector_table), %g2
  397. add %g2, %g3, %g3
  398. ldub [%g3 + 0x04], %g4 /* pil */
  399. mov 1, %g2
  400. sllx %g2, %g4, %g2
  401. sllx %g4, 2, %g4
  402. TRAP_LOAD_IRQ_WORK(%g6, %g1)
  403. lduw [%g6 + %g4], %g5 /* g5 = irq_work(cpu, pil) */
  404. stw %g5, [%g3 + 0x00] /* bucket->irq_chain = g5 */
  405. stw %g3, [%g6 + %g4] /* irq_work(cpu, pil) = bucket */
  406. wr %g2, 0x0, %set_softint
  407. retry
  408. do_ivec_xcall:
  409. mov 0x50, %g1
  410. ldxa [%g1 + %g0] ASI_INTR_R, %g1
  411. srl %g3, 0, %g3
  412. mov 0x60, %g7
  413. ldxa [%g7 + %g0] ASI_INTR_R, %g7
  414. stxa %g0, [%g0] ASI_INTR_RECEIVE
  415. membar #Sync
  416. ba,pt %xcc, 1f
  417. nop
  418. .align 32
  419. 1: jmpl %g3, %g0
  420. nop
  421. .globl getcc, setcc
  422. getcc:
  423. ldx [%o0 + PT_V9_TSTATE], %o1
  424. srlx %o1, 32, %o1
  425. and %o1, 0xf, %o1
  426. retl
  427. stx %o1, [%o0 + PT_V9_G1]
  428. setcc:
  429. ldx [%o0 + PT_V9_TSTATE], %o1
  430. ldx [%o0 + PT_V9_G1], %o2
  431. or %g0, %ulo(TSTATE_ICC), %o3
  432. sllx %o3, 32, %o3
  433. andn %o1, %o3, %o1
  434. sllx %o2, 32, %o2
  435. and %o2, %o3, %o2
  436. or %o1, %o2, %o1
  437. retl
  438. stx %o1, [%o0 + PT_V9_TSTATE]
  439. .globl utrap_trap
  440. utrap_trap: /* %g3=handler,%g4=level */
  441. TRAP_LOAD_THREAD_REG(%g6, %g1)
  442. ldx [%g6 + TI_UTRAPS], %g1
  443. brnz,pt %g1, invoke_utrap
  444. nop
  445. ba,pt %xcc, etrap
  446. rd %pc, %g7
  447. mov %l4, %o1
  448. call bad_trap
  449. add %sp, PTREGS_OFF, %o0
  450. ba,pt %xcc, rtrap
  451. clr %l6
  452. invoke_utrap:
  453. sllx %g3, 3, %g3
  454. ldx [%g1 + %g3], %g1
  455. save %sp, -128, %sp
  456. rdpr %tstate, %l6
  457. rdpr %cwp, %l7
  458. andn %l6, TSTATE_CWP, %l6
  459. wrpr %l6, %l7, %tstate
  460. rdpr %tpc, %l6
  461. rdpr %tnpc, %l7
  462. wrpr %g1, 0, %tnpc
  463. done
  464. /* We need to carefully read the error status, ACK
  465. * the errors, prevent recursive traps, and pass the
  466. * information on to C code for logging.
  467. *
  468. * We pass the AFAR in as-is, and we encode the status
  469. * information as described in asm-sparc64/sfafsr.h
  470. */
  471. .globl __spitfire_access_error
  472. __spitfire_access_error:
  473. /* Disable ESTATE error reporting so that we do not
  474. * take recursive traps and RED state the processor.
  475. */
  476. stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
  477. membar #Sync
  478. mov UDBE_UE, %g1
  479. ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
  480. /* __spitfire_cee_trap branches here with AFSR in %g4 and
  481. * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
  482. * ESTATE Error Enable register.
  483. */
  484. __spitfire_cee_trap_continue:
  485. ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
  486. rdpr %tt, %g3
  487. and %g3, 0x1ff, %g3 ! Paranoia
  488. sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
  489. or %g4, %g3, %g4
  490. rdpr %tl, %g3
  491. cmp %g3, 1
  492. mov 1, %g3
  493. bleu %xcc, 1f
  494. sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
  495. or %g4, %g3, %g4
  496. /* Read in the UDB error register state, clearing the
  497. * sticky error bits as-needed. We only clear them if
  498. * the UE bit is set. Likewise, __spitfire_cee_trap
  499. * below will only do so if the CE bit is set.
  500. *
  501. * NOTE: UltraSparc-I/II have high and low UDB error
  502. * registers, corresponding to the two UDB units
  503. * present on those chips. UltraSparc-IIi only
  504. * has a single UDB, called "SDB" in the manual.
  505. * For IIi the upper UDB register always reads
  506. * as zero so for our purposes things will just
  507. * work with the checks below.
  508. */
  509. 1: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
  510. and %g3, 0x3ff, %g7 ! Paranoia
  511. sllx %g7, SFSTAT_UDBH_SHIFT, %g7
  512. or %g4, %g7, %g4
  513. andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
  514. be,pn %xcc, 1f
  515. nop
  516. stxa %g3, [%g0] ASI_UDB_ERROR_W
  517. membar #Sync
  518. 1: mov 0x18, %g3
  519. ldxa [%g3] ASI_UDBL_ERROR_R, %g3
  520. and %g3, 0x3ff, %g7 ! Paranoia
  521. sllx %g7, SFSTAT_UDBL_SHIFT, %g7
  522. or %g4, %g7, %g4
  523. andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
  524. be,pn %xcc, 1f
  525. nop
  526. mov 0x18, %g7
  527. stxa %g3, [%g7] ASI_UDB_ERROR_W
  528. membar #Sync
  529. 1: /* Ok, now that we've latched the error state,
  530. * clear the sticky bits in the AFSR.
  531. */
  532. stxa %g4, [%g0] ASI_AFSR
  533. membar #Sync
  534. rdpr %tl, %g2
  535. cmp %g2, 1
  536. rdpr %pil, %g2
  537. bleu,pt %xcc, 1f
  538. wrpr %g0, 15, %pil
  539. ba,pt %xcc, etraptl1
  540. rd %pc, %g7
  541. ba,pt %xcc, 2f
  542. nop
  543. 1: ba,pt %xcc, etrap_irq
  544. rd %pc, %g7
  545. 2: mov %l4, %o1
  546. mov %l5, %o2
  547. call spitfire_access_error
  548. add %sp, PTREGS_OFF, %o0
  549. ba,pt %xcc, rtrap
  550. clr %l6
  551. /* This is the trap handler entry point for ECC correctable
  552. * errors. They are corrected, but we listen for the trap
  553. * so that the event can be logged.
  554. *
  555. * Disrupting errors are either:
  556. * 1) single-bit ECC errors during UDB reads to system
  557. * memory
  558. * 2) data parity errors during write-back events
  559. *
  560. * As far as I can make out from the manual, the CEE trap
  561. * is only for correctable errors during memory read
  562. * accesses by the front-end of the processor.
  563. *
  564. * The code below is only for trap level 1 CEE events,
  565. * as it is the only situation where we can safely record
  566. * and log. For trap level >1 we just clear the CE bit
  567. * in the AFSR and return.
  568. *
  569. * This is just like __spiftire_access_error above, but it
  570. * specifically handles correctable errors. If an
  571. * uncorrectable error is indicated in the AFSR we
  572. * will branch directly above to __spitfire_access_error
  573. * to handle it instead. Uncorrectable therefore takes
  574. * priority over correctable, and the error logging
  575. * C code will notice this case by inspecting the
  576. * trap type.
  577. */
  578. .globl __spitfire_cee_trap
  579. __spitfire_cee_trap:
  580. ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
  581. mov 1, %g3
  582. sllx %g3, SFAFSR_UE_SHIFT, %g3
  583. andcc %g4, %g3, %g0 ! Check for UE
  584. bne,pn %xcc, __spitfire_access_error
  585. nop
  586. /* Ok, in this case we only have a correctable error.
  587. * Indicate we only wish to capture that state in register
  588. * %g1, and we only disable CE error reporting unlike UE
  589. * handling which disables all errors.
  590. */
  591. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
  592. andn %g3, ESTATE_ERR_CE, %g3
  593. stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
  594. membar #Sync
  595. /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
  596. ba,pt %xcc, __spitfire_cee_trap_continue
  597. mov UDBE_CE, %g1
  598. .globl __spitfire_data_access_exception
  599. .globl __spitfire_data_access_exception_tl1
  600. __spitfire_data_access_exception_tl1:
  601. rdpr %pstate, %g4
  602. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  603. mov TLB_SFSR, %g3
  604. mov DMMU_SFAR, %g5
  605. ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
  606. ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
  607. stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
  608. membar #Sync
  609. rdpr %tt, %g3
  610. cmp %g3, 0x80 ! first win spill/fill trap
  611. blu,pn %xcc, 1f
  612. cmp %g3, 0xff ! last win spill/fill trap
  613. bgu,pn %xcc, 1f
  614. nop
  615. ba,pt %xcc, winfix_dax
  616. rdpr %tpc, %g3
  617. 1: sethi %hi(109f), %g7
  618. ba,pt %xcc, etraptl1
  619. 109: or %g7, %lo(109b), %g7
  620. mov %l4, %o1
  621. mov %l5, %o2
  622. call spitfire_data_access_exception_tl1
  623. add %sp, PTREGS_OFF, %o0
  624. ba,pt %xcc, rtrap
  625. clr %l6
  626. __spitfire_data_access_exception:
  627. rdpr %pstate, %g4
  628. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  629. mov TLB_SFSR, %g3
  630. mov DMMU_SFAR, %g5
  631. ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
  632. ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
  633. stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
  634. membar #Sync
  635. sethi %hi(109f), %g7
  636. ba,pt %xcc, etrap
  637. 109: or %g7, %lo(109b), %g7
  638. mov %l4, %o1
  639. mov %l5, %o2
  640. call spitfire_data_access_exception
  641. add %sp, PTREGS_OFF, %o0
  642. ba,pt %xcc, rtrap
  643. clr %l6
  644. .globl __spitfire_insn_access_exception
  645. .globl __spitfire_insn_access_exception_tl1
  646. __spitfire_insn_access_exception_tl1:
  647. rdpr %pstate, %g4
  648. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  649. mov TLB_SFSR, %g3
  650. ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
  651. rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
  652. stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
  653. membar #Sync
  654. sethi %hi(109f), %g7
  655. ba,pt %xcc, etraptl1
  656. 109: or %g7, %lo(109b), %g7
  657. mov %l4, %o1
  658. mov %l5, %o2
  659. call spitfire_insn_access_exception_tl1
  660. add %sp, PTREGS_OFF, %o0
  661. ba,pt %xcc, rtrap
  662. clr %l6
  663. __spitfire_insn_access_exception:
  664. rdpr %pstate, %g4
  665. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  666. mov TLB_SFSR, %g3
  667. ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
  668. rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
  669. stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
  670. membar #Sync
  671. sethi %hi(109f), %g7
  672. ba,pt %xcc, etrap
  673. 109: or %g7, %lo(109b), %g7
  674. mov %l4, %o1
  675. mov %l5, %o2
  676. call spitfire_insn_access_exception
  677. add %sp, PTREGS_OFF, %o0
  678. ba,pt %xcc, rtrap
  679. clr %l6
  680. /* These get patched into the trap table at boot time
  681. * once we know we have a cheetah processor.
  682. */
  683. .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
  684. cheetah_fecc_trap_vector:
  685. membar #Sync
  686. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  687. andn %g1, DCU_DC | DCU_IC, %g1
  688. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  689. membar #Sync
  690. sethi %hi(cheetah_fast_ecc), %g2
  691. jmpl %g2 + %lo(cheetah_fast_ecc), %g0
  692. mov 0, %g1
  693. cheetah_fecc_trap_vector_tl1:
  694. membar #Sync
  695. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  696. andn %g1, DCU_DC | DCU_IC, %g1
  697. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  698. membar #Sync
  699. sethi %hi(cheetah_fast_ecc), %g2
  700. jmpl %g2 + %lo(cheetah_fast_ecc), %g0
  701. mov 1, %g1
  702. .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
  703. cheetah_cee_trap_vector:
  704. membar #Sync
  705. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  706. andn %g1, DCU_IC, %g1
  707. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  708. membar #Sync
  709. sethi %hi(cheetah_cee), %g2
  710. jmpl %g2 + %lo(cheetah_cee), %g0
  711. mov 0, %g1
  712. cheetah_cee_trap_vector_tl1:
  713. membar #Sync
  714. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  715. andn %g1, DCU_IC, %g1
  716. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  717. membar #Sync
  718. sethi %hi(cheetah_cee), %g2
  719. jmpl %g2 + %lo(cheetah_cee), %g0
  720. mov 1, %g1
  721. .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
  722. cheetah_deferred_trap_vector:
  723. membar #Sync
  724. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
  725. andn %g1, DCU_DC | DCU_IC, %g1;
  726. stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
  727. membar #Sync;
  728. sethi %hi(cheetah_deferred_trap), %g2
  729. jmpl %g2 + %lo(cheetah_deferred_trap), %g0
  730. mov 0, %g1
  731. cheetah_deferred_trap_vector_tl1:
  732. membar #Sync;
  733. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
  734. andn %g1, DCU_DC | DCU_IC, %g1;
  735. stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
  736. membar #Sync;
  737. sethi %hi(cheetah_deferred_trap), %g2
  738. jmpl %g2 + %lo(cheetah_deferred_trap), %g0
  739. mov 1, %g1
  740. /* Cheetah+ specific traps. These are for the new I/D cache parity
  741. * error traps. The first argument to cheetah_plus_parity_handler
  742. * is encoded as follows:
  743. *
  744. * Bit0: 0=dcache,1=icache
  745. * Bit1: 0=recoverable,1=unrecoverable
  746. */
  747. .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
  748. cheetah_plus_dcpe_trap_vector:
  749. membar #Sync
  750. sethi %hi(do_cheetah_plus_data_parity), %g7
  751. jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
  752. nop
  753. nop
  754. nop
  755. nop
  756. nop
  757. do_cheetah_plus_data_parity:
  758. rdpr %pil, %g2
  759. wrpr %g0, 15, %pil
  760. ba,pt %xcc, etrap_irq
  761. rd %pc, %g7
  762. mov 0x0, %o0
  763. call cheetah_plus_parity_error
  764. add %sp, PTREGS_OFF, %o1
  765. ba,a,pt %xcc, rtrap_irq
  766. cheetah_plus_dcpe_trap_vector_tl1:
  767. membar #Sync
  768. wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
  769. sethi %hi(do_dcpe_tl1), %g3
  770. jmpl %g3 + %lo(do_dcpe_tl1), %g0
  771. nop
  772. nop
  773. nop
  774. nop
  775. .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
  776. cheetah_plus_icpe_trap_vector:
  777. membar #Sync
  778. sethi %hi(do_cheetah_plus_insn_parity), %g7
  779. jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
  780. nop
  781. nop
  782. nop
  783. nop
  784. nop
  785. do_cheetah_plus_insn_parity:
  786. rdpr %pil, %g2
  787. wrpr %g0, 15, %pil
  788. ba,pt %xcc, etrap_irq
  789. rd %pc, %g7
  790. mov 0x1, %o0
  791. call cheetah_plus_parity_error
  792. add %sp, PTREGS_OFF, %o1
  793. ba,a,pt %xcc, rtrap_irq
  794. cheetah_plus_icpe_trap_vector_tl1:
  795. membar #Sync
  796. wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
  797. sethi %hi(do_icpe_tl1), %g3
  798. jmpl %g3 + %lo(do_icpe_tl1), %g0
  799. nop
  800. nop
  801. nop
  802. nop
  803. /* If we take one of these traps when tl >= 1, then we
  804. * jump to interrupt globals. If some trap level above us
  805. * was also using interrupt globals, we cannot recover.
  806. * We may use all interrupt global registers except %g6.
  807. */
  808. .globl do_dcpe_tl1, do_icpe_tl1
  809. do_dcpe_tl1:
  810. rdpr %tl, %g1 ! Save original trap level
  811. mov 1, %g2 ! Setup TSTATE checking loop
  812. sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
  813. 1: wrpr %g2, %tl ! Set trap level to check
  814. rdpr %tstate, %g4 ! Read TSTATE for this level
  815. andcc %g4, %g3, %g0 ! Interrupt globals in use?
  816. bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
  817. wrpr %g1, %tl ! Restore original trap level
  818. add %g2, 1, %g2 ! Next trap level
  819. cmp %g2, %g1 ! Hit them all yet?
  820. ble,pt %icc, 1b ! Not yet
  821. nop
  822. wrpr %g1, %tl ! Restore original trap level
  823. do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
  824. sethi %hi(dcache_parity_tl1_occurred), %g2
  825. lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
  826. add %g1, 1, %g1
  827. stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
  828. /* Reset D-cache parity */
  829. sethi %hi(1 << 16), %g1 ! D-cache size
  830. mov (1 << 5), %g2 ! D-cache line size
  831. sub %g1, %g2, %g1 ! Move down 1 cacheline
  832. 1: srl %g1, 14, %g3 ! Compute UTAG
  833. membar #Sync
  834. stxa %g3, [%g1] ASI_DCACHE_UTAG
  835. membar #Sync
  836. sub %g2, 8, %g3 ! 64-bit data word within line
  837. 2: membar #Sync
  838. stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
  839. membar #Sync
  840. subcc %g3, 8, %g3 ! Next 64-bit data word
  841. bge,pt %icc, 2b
  842. nop
  843. subcc %g1, %g2, %g1 ! Next cacheline
  844. bge,pt %icc, 1b
  845. nop
  846. ba,pt %xcc, dcpe_icpe_tl1_common
  847. nop
  848. do_dcpe_tl1_fatal:
  849. sethi %hi(1f), %g7
  850. ba,pt %xcc, etraptl1
  851. 1: or %g7, %lo(1b), %g7
  852. mov 0x2, %o0
  853. call cheetah_plus_parity_error
  854. add %sp, PTREGS_OFF, %o1
  855. ba,pt %xcc, rtrap
  856. clr %l6
  857. do_icpe_tl1:
  858. rdpr %tl, %g1 ! Save original trap level
  859. mov 1, %g2 ! Setup TSTATE checking loop
  860. sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
  861. 1: wrpr %g2, %tl ! Set trap level to check
  862. rdpr %tstate, %g4 ! Read TSTATE for this level
  863. andcc %g4, %g3, %g0 ! Interrupt globals in use?
  864. bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
  865. wrpr %g1, %tl ! Restore original trap level
  866. add %g2, 1, %g2 ! Next trap level
  867. cmp %g2, %g1 ! Hit them all yet?
  868. ble,pt %icc, 1b ! Not yet
  869. nop
  870. wrpr %g1, %tl ! Restore original trap level
  871. do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
  872. sethi %hi(icache_parity_tl1_occurred), %g2
  873. lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
  874. add %g1, 1, %g1
  875. stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
  876. /* Flush I-cache */
  877. sethi %hi(1 << 15), %g1 ! I-cache size
  878. mov (1 << 5), %g2 ! I-cache line size
  879. sub %g1, %g2, %g1
  880. 1: or %g1, (2 << 3), %g3
  881. stxa %g0, [%g3] ASI_IC_TAG
  882. membar #Sync
  883. subcc %g1, %g2, %g1
  884. bge,pt %icc, 1b
  885. nop
  886. ba,pt %xcc, dcpe_icpe_tl1_common
  887. nop
  888. do_icpe_tl1_fatal:
  889. sethi %hi(1f), %g7
  890. ba,pt %xcc, etraptl1
  891. 1: or %g7, %lo(1b), %g7
  892. mov 0x3, %o0
  893. call cheetah_plus_parity_error
  894. add %sp, PTREGS_OFF, %o1
  895. ba,pt %xcc, rtrap
  896. clr %l6
  897. dcpe_icpe_tl1_common:
  898. /* Flush D-cache, re-enable D/I caches in DCU and finally
  899. * retry the trapping instruction.
  900. */
  901. sethi %hi(1 << 16), %g1 ! D-cache size
  902. mov (1 << 5), %g2 ! D-cache line size
  903. sub %g1, %g2, %g1
  904. 1: stxa %g0, [%g1] ASI_DCACHE_TAG
  905. membar #Sync
  906. subcc %g1, %g2, %g1
  907. bge,pt %icc, 1b
  908. nop
  909. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  910. or %g1, (DCU_DC | DCU_IC), %g1
  911. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  912. membar #Sync
  913. retry
  914. /* Capture I/D/E-cache state into per-cpu error scoreboard.
  915. *
  916. * %g1: (TL>=0) ? 1 : 0
  917. * %g2: scratch
  918. * %g3: scratch
  919. * %g4: AFSR
  920. * %g5: AFAR
  921. * %g6: unused, will have current thread ptr after etrap
  922. * %g7: scratch
  923. */
  924. __cheetah_log_error:
  925. /* Put "TL1" software bit into AFSR. */
  926. and %g1, 0x1, %g1
  927. sllx %g1, 63, %g2
  928. or %g4, %g2, %g4
  929. /* Get log entry pointer for this cpu at this trap level. */
  930. BRANCH_IF_JALAPENO(g2,g3,50f)
  931. ldxa [%g0] ASI_SAFARI_CONFIG, %g2
  932. srlx %g2, 17, %g2
  933. ba,pt %xcc, 60f
  934. and %g2, 0x3ff, %g2
  935. 50: ldxa [%g0] ASI_JBUS_CONFIG, %g2
  936. srlx %g2, 17, %g2
  937. and %g2, 0x1f, %g2
  938. 60: sllx %g2, 9, %g2
  939. sethi %hi(cheetah_error_log), %g3
  940. ldx [%g3 + %lo(cheetah_error_log)], %g3
  941. brz,pn %g3, 80f
  942. nop
  943. add %g3, %g2, %g3
  944. sllx %g1, 8, %g1
  945. add %g3, %g1, %g1
  946. /* %g1 holds pointer to the top of the logging scoreboard */
  947. ldx [%g1 + 0x0], %g7
  948. cmp %g7, -1
  949. bne,pn %xcc, 80f
  950. nop
  951. stx %g4, [%g1 + 0x0]
  952. stx %g5, [%g1 + 0x8]
  953. add %g1, 0x10, %g1
  954. /* %g1 now points to D-cache logging area */
  955. set 0x3ff8, %g2 /* DC_addr mask */
  956. and %g5, %g2, %g2 /* DC_addr bits of AFAR */
  957. srlx %g5, 12, %g3
  958. or %g3, 1, %g3 /* PHYS tag + valid */
  959. 10: ldxa [%g2] ASI_DCACHE_TAG, %g7
  960. cmp %g3, %g7 /* TAG match? */
  961. bne,pt %xcc, 13f
  962. nop
  963. /* Yep, what we want, capture state. */
  964. stx %g2, [%g1 + 0x20]
  965. stx %g7, [%g1 + 0x28]
  966. /* A membar Sync is required before and after utag access. */
  967. membar #Sync
  968. ldxa [%g2] ASI_DCACHE_UTAG, %g7
  969. membar #Sync
  970. stx %g7, [%g1 + 0x30]
  971. ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
  972. stx %g7, [%g1 + 0x38]
  973. clr %g3
  974. 12: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
  975. stx %g7, [%g1]
  976. add %g3, (1 << 5), %g3
  977. cmp %g3, (4 << 5)
  978. bl,pt %xcc, 12b
  979. add %g1, 0x8, %g1
  980. ba,pt %xcc, 20f
  981. add %g1, 0x20, %g1
  982. 13: sethi %hi(1 << 14), %g7
  983. add %g2, %g7, %g2
  984. srlx %g2, 14, %g7
  985. cmp %g7, 4
  986. bl,pt %xcc, 10b
  987. nop
  988. add %g1, 0x40, %g1
  989. /* %g1 now points to I-cache logging area */
  990. 20: set 0x1fe0, %g2 /* IC_addr mask */
  991. and %g5, %g2, %g2 /* IC_addr bits of AFAR */
  992. sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
  993. srlx %g5, (13 - 8), %g3 /* Make PTAG */
  994. andn %g3, 0xff, %g3 /* Mask off undefined bits */
  995. 21: ldxa [%g2] ASI_IC_TAG, %g7
  996. andn %g7, 0xff, %g7
  997. cmp %g3, %g7
  998. bne,pt %xcc, 23f
  999. nop
  1000. /* Yep, what we want, capture state. */
  1001. stx %g2, [%g1 + 0x40]
  1002. stx %g7, [%g1 + 0x48]
  1003. add %g2, (1 << 3), %g2
  1004. ldxa [%g2] ASI_IC_TAG, %g7
  1005. add %g2, (1 << 3), %g2
  1006. stx %g7, [%g1 + 0x50]
  1007. ldxa [%g2] ASI_IC_TAG, %g7
  1008. add %g2, (1 << 3), %g2
  1009. stx %g7, [%g1 + 0x60]
  1010. ldxa [%g2] ASI_IC_TAG, %g7
  1011. stx %g7, [%g1 + 0x68]
  1012. sub %g2, (3 << 3), %g2
  1013. ldxa [%g2] ASI_IC_STAG, %g7
  1014. stx %g7, [%g1 + 0x58]
  1015. clr %g3
  1016. srlx %g2, 2, %g2
  1017. 22: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
  1018. stx %g7, [%g1]
  1019. add %g3, (1 << 3), %g3
  1020. cmp %g3, (8 << 3)
  1021. bl,pt %xcc, 22b
  1022. add %g1, 0x8, %g1
  1023. ba,pt %xcc, 30f
  1024. add %g1, 0x30, %g1
  1025. 23: sethi %hi(1 << 14), %g7
  1026. add %g2, %g7, %g2
  1027. srlx %g2, 14, %g7
  1028. cmp %g7, 4
  1029. bl,pt %xcc, 21b
  1030. nop
  1031. add %g1, 0x70, %g1
  1032. /* %g1 now points to E-cache logging area */
  1033. 30: andn %g5, (32 - 1), %g2
  1034. stx %g2, [%g1 + 0x20]
  1035. ldxa [%g2] ASI_EC_TAG_DATA, %g7
  1036. stx %g7, [%g1 + 0x28]
  1037. ldxa [%g2] ASI_EC_R, %g0
  1038. clr %g3
  1039. 31: ldxa [%g3] ASI_EC_DATA, %g7
  1040. stx %g7, [%g1 + %g3]
  1041. add %g3, 0x8, %g3
  1042. cmp %g3, 0x20
  1043. bl,pt %xcc, 31b
  1044. nop
  1045. 80:
  1046. rdpr %tt, %g2
  1047. cmp %g2, 0x70
  1048. be c_fast_ecc
  1049. cmp %g2, 0x63
  1050. be c_cee
  1051. nop
  1052. ba,pt %xcc, c_deferred
  1053. /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
  1054. * in the trap table. That code has done a memory barrier
  1055. * and has disabled both the I-cache and D-cache in the DCU
  1056. * control register. The I-cache is disabled so that we may
  1057. * capture the corrupted cache line, and the D-cache is disabled
  1058. * because corrupt data may have been placed there and we don't
  1059. * want to reference it.
  1060. *
  1061. * %g1 is one if this trap occurred at %tl >= 1.
  1062. *
  1063. * Next, we turn off error reporting so that we don't recurse.
  1064. */
  1065. .globl cheetah_fast_ecc
  1066. cheetah_fast_ecc:
  1067. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1068. andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
  1069. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1070. membar #Sync
  1071. /* Fetch and clear AFSR/AFAR */
  1072. ldxa [%g0] ASI_AFSR, %g4
  1073. ldxa [%g0] ASI_AFAR, %g5
  1074. stxa %g4, [%g0] ASI_AFSR
  1075. membar #Sync
  1076. ba,pt %xcc, __cheetah_log_error
  1077. nop
  1078. c_fast_ecc:
  1079. rdpr %pil, %g2
  1080. wrpr %g0, 15, %pil
  1081. ba,pt %xcc, etrap_irq
  1082. rd %pc, %g7
  1083. mov %l4, %o1
  1084. mov %l5, %o2
  1085. call cheetah_fecc_handler
  1086. add %sp, PTREGS_OFF, %o0
  1087. ba,a,pt %xcc, rtrap_irq
  1088. /* Our caller has disabled I-cache and performed membar Sync. */
  1089. .globl cheetah_cee
  1090. cheetah_cee:
  1091. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1092. andn %g2, ESTATE_ERROR_CEEN, %g2
  1093. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1094. membar #Sync
  1095. /* Fetch and clear AFSR/AFAR */
  1096. ldxa [%g0] ASI_AFSR, %g4
  1097. ldxa [%g0] ASI_AFAR, %g5
  1098. stxa %g4, [%g0] ASI_AFSR
  1099. membar #Sync
  1100. ba,pt %xcc, __cheetah_log_error
  1101. nop
  1102. c_cee:
  1103. rdpr %pil, %g2
  1104. wrpr %g0, 15, %pil
  1105. ba,pt %xcc, etrap_irq
  1106. rd %pc, %g7
  1107. mov %l4, %o1
  1108. mov %l5, %o2
  1109. call cheetah_cee_handler
  1110. add %sp, PTREGS_OFF, %o0
  1111. ba,a,pt %xcc, rtrap_irq
  1112. /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
  1113. .globl cheetah_deferred_trap
  1114. cheetah_deferred_trap:
  1115. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1116. andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
  1117. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1118. membar #Sync
  1119. /* Fetch and clear AFSR/AFAR */
  1120. ldxa [%g0] ASI_AFSR, %g4
  1121. ldxa [%g0] ASI_AFAR, %g5
  1122. stxa %g4, [%g0] ASI_AFSR
  1123. membar #Sync
  1124. ba,pt %xcc, __cheetah_log_error
  1125. nop
  1126. c_deferred:
  1127. rdpr %pil, %g2
  1128. wrpr %g0, 15, %pil
  1129. ba,pt %xcc, etrap_irq
  1130. rd %pc, %g7
  1131. mov %l4, %o1
  1132. mov %l5, %o2
  1133. call cheetah_deferred_handler
  1134. add %sp, PTREGS_OFF, %o0
  1135. ba,a,pt %xcc, rtrap_irq
  1136. .globl __do_privact
  1137. __do_privact:
  1138. mov TLB_SFSR, %g3
  1139. stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
  1140. membar #Sync
  1141. sethi %hi(109f), %g7
  1142. ba,pt %xcc, etrap
  1143. 109: or %g7, %lo(109b), %g7
  1144. call do_privact
  1145. add %sp, PTREGS_OFF, %o0
  1146. ba,pt %xcc, rtrap
  1147. clr %l6
  1148. .globl do_mna
  1149. do_mna:
  1150. rdpr %tl, %g3
  1151. cmp %g3, 1
  1152. /* Setup %g4/%g5 now as they are used in the
  1153. * winfixup code.
  1154. */
  1155. mov TLB_SFSR, %g3
  1156. mov DMMU_SFAR, %g4
  1157. ldxa [%g4] ASI_DMMU, %g4
  1158. ldxa [%g3] ASI_DMMU, %g5
  1159. stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
  1160. membar #Sync
  1161. bgu,pn %icc, winfix_mna
  1162. rdpr %tpc, %g3
  1163. 1: sethi %hi(109f), %g7
  1164. ba,pt %xcc, etrap
  1165. 109: or %g7, %lo(109b), %g7
  1166. mov %l4, %o1
  1167. mov %l5, %o2
  1168. call mem_address_unaligned
  1169. add %sp, PTREGS_OFF, %o0
  1170. ba,pt %xcc, rtrap
  1171. clr %l6
  1172. .globl do_lddfmna
  1173. do_lddfmna:
  1174. sethi %hi(109f), %g7
  1175. mov TLB_SFSR, %g4
  1176. ldxa [%g4] ASI_DMMU, %g5
  1177. stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
  1178. membar #Sync
  1179. mov DMMU_SFAR, %g4
  1180. ldxa [%g4] ASI_DMMU, %g4
  1181. ba,pt %xcc, etrap
  1182. 109: or %g7, %lo(109b), %g7
  1183. mov %l4, %o1
  1184. mov %l5, %o2
  1185. call handle_lddfmna
  1186. add %sp, PTREGS_OFF, %o0
  1187. ba,pt %xcc, rtrap
  1188. clr %l6
  1189. .globl do_stdfmna
  1190. do_stdfmna:
  1191. sethi %hi(109f), %g7
  1192. mov TLB_SFSR, %g4
  1193. ldxa [%g4] ASI_DMMU, %g5
  1194. stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
  1195. membar #Sync
  1196. mov DMMU_SFAR, %g4
  1197. ldxa [%g4] ASI_DMMU, %g4
  1198. ba,pt %xcc, etrap
  1199. 109: or %g7, %lo(109b), %g7
  1200. mov %l4, %o1
  1201. mov %l5, %o2
  1202. call handle_stdfmna
  1203. add %sp, PTREGS_OFF, %o0
  1204. ba,pt %xcc, rtrap
  1205. clr %l6
  1206. .globl breakpoint_trap
  1207. breakpoint_trap:
  1208. call sparc_breakpoint
  1209. add %sp, PTREGS_OFF, %o0
  1210. ba,pt %xcc, rtrap
  1211. nop
  1212. #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
  1213. defined(CONFIG_SOLARIS_EMUL_MODULE)
  1214. /* SunOS uses syscall zero as the 'indirect syscall' it looks
  1215. * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
  1216. * This is complete brain damage.
  1217. */
  1218. .globl sunos_indir
  1219. sunos_indir:
  1220. srl %o0, 0, %o0
  1221. mov %o7, %l4
  1222. cmp %o0, NR_SYSCALLS
  1223. blu,a,pt %icc, 1f
  1224. sll %o0, 0x2, %o0
  1225. sethi %hi(sunos_nosys), %l6
  1226. b,pt %xcc, 2f
  1227. or %l6, %lo(sunos_nosys), %l6
  1228. 1: sethi %hi(sunos_sys_table), %l7
  1229. or %l7, %lo(sunos_sys_table), %l7
  1230. lduw [%l7 + %o0], %l6
  1231. 2: mov %o1, %o0
  1232. mov %o2, %o1
  1233. mov %o3, %o2
  1234. mov %o4, %o3
  1235. mov %o5, %o4
  1236. call %l6
  1237. mov %l4, %o7
  1238. .globl sunos_getpid
  1239. sunos_getpid:
  1240. call sys_getppid
  1241. nop
  1242. call sys_getpid
  1243. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1244. b,pt %xcc, ret_sys_call
  1245. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1246. /* SunOS getuid() returns uid in %o0 and euid in %o1 */
  1247. .globl sunos_getuid
  1248. sunos_getuid:
  1249. call sys32_geteuid16
  1250. nop
  1251. call sys32_getuid16
  1252. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1253. b,pt %xcc, ret_sys_call
  1254. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1255. /* SunOS getgid() returns gid in %o0 and egid in %o1 */
  1256. .globl sunos_getgid
  1257. sunos_getgid:
  1258. call sys32_getegid16
  1259. nop
  1260. call sys32_getgid16
  1261. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1262. b,pt %xcc, ret_sys_call
  1263. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1264. #endif
  1265. /* SunOS's execv() call only specifies the argv argument, the
  1266. * environment settings are the same as the calling processes.
  1267. */
  1268. .globl sunos_execv
  1269. sys_execve:
  1270. sethi %hi(sparc_execve), %g1
  1271. ba,pt %xcc, execve_merge
  1272. or %g1, %lo(sparc_execve), %g1
  1273. #ifdef CONFIG_COMPAT
  1274. .globl sys_execve
  1275. sunos_execv:
  1276. stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
  1277. .globl sys32_execve
  1278. sys32_execve:
  1279. sethi %hi(sparc32_execve), %g1
  1280. or %g1, %lo(sparc32_execve), %g1
  1281. #endif
  1282. execve_merge:
  1283. flushw
  1284. jmpl %g1, %g0
  1285. add %sp, PTREGS_OFF, %o0
  1286. .globl sys_pipe, sys_sigpause, sys_nis_syscall
  1287. .globl sys_rt_sigreturn
  1288. .globl sys_ptrace
  1289. .globl sys_sigaltstack
  1290. .align 32
  1291. sys_pipe: ba,pt %xcc, sparc_pipe
  1292. add %sp, PTREGS_OFF, %o0
  1293. sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
  1294. add %sp, PTREGS_OFF, %o0
  1295. sys_memory_ordering:
  1296. ba,pt %xcc, sparc_memory_ordering
  1297. add %sp, PTREGS_OFF, %o1
  1298. sys_sigaltstack:ba,pt %xcc, do_sigaltstack
  1299. add %i6, STACK_BIAS, %o2
  1300. #ifdef CONFIG_COMPAT
  1301. .globl sys32_sigstack
  1302. sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
  1303. mov %i6, %o2
  1304. .globl sys32_sigaltstack
  1305. sys32_sigaltstack:
  1306. ba,pt %xcc, do_sys32_sigaltstack
  1307. mov %i6, %o2
  1308. #endif
  1309. .align 32
  1310. #ifdef CONFIG_COMPAT
  1311. .globl sys32_sigreturn
  1312. sys32_sigreturn:
  1313. add %sp, PTREGS_OFF, %o0
  1314. call do_sigreturn32
  1315. add %o7, 1f-.-4, %o7
  1316. nop
  1317. #endif
  1318. sys_rt_sigreturn:
  1319. add %sp, PTREGS_OFF, %o0
  1320. call do_rt_sigreturn
  1321. add %o7, 1f-.-4, %o7
  1322. nop
  1323. #ifdef CONFIG_COMPAT
  1324. .globl sys32_rt_sigreturn
  1325. sys32_rt_sigreturn:
  1326. add %sp, PTREGS_OFF, %o0
  1327. call do_rt_sigreturn32
  1328. add %o7, 1f-.-4, %o7
  1329. nop
  1330. #endif
  1331. sys_ptrace: add %sp, PTREGS_OFF, %o0
  1332. call do_ptrace
  1333. add %o7, 1f-.-4, %o7
  1334. nop
  1335. .align 32
  1336. 1: ldx [%curptr + TI_FLAGS], %l5
  1337. andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1338. be,pt %icc, rtrap
  1339. clr %l6
  1340. add %sp, PTREGS_OFF, %o0
  1341. call syscall_trace
  1342. mov 1, %o1
  1343. ba,pt %xcc, rtrap
  1344. clr %l6
  1345. /* This is how fork() was meant to be done, 8 instruction entry.
  1346. *
  1347. * I questioned the following code briefly, let me clear things
  1348. * up so you must not reason on it like I did.
  1349. *
  1350. * Know the fork_kpsr etc. we use in the sparc32 port? We don't
  1351. * need it here because the only piece of window state we copy to
  1352. * the child is the CWP register. Even if the parent sleeps,
  1353. * we are safe because we stuck it into pt_regs of the parent
  1354. * so it will not change.
  1355. *
  1356. * XXX This raises the question, whether we can do the same on
  1357. * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
  1358. * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
  1359. * XXX fork_kwim in UREG_G1 (global registers are considered
  1360. * XXX volatile across a system call in the sparc ABI I think
  1361. * XXX if it isn't we can use regs->y instead, anyone who depends
  1362. * XXX upon the Y register being preserved across a fork deserves
  1363. * XXX to lose).
  1364. *
  1365. * In fact we should take advantage of that fact for other things
  1366. * during system calls...
  1367. */
  1368. .globl sys_fork, sys_vfork, sys_clone, sparc_exit
  1369. .globl ret_from_syscall
  1370. .align 32
  1371. sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
  1372. sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
  1373. or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
  1374. ba,pt %xcc, sys_clone
  1375. sys_fork: clr %o1
  1376. mov SIGCHLD, %o0
  1377. sys_clone: flushw
  1378. movrz %o1, %fp, %o1
  1379. mov 0, %o3
  1380. ba,pt %xcc, sparc_do_fork
  1381. add %sp, PTREGS_OFF, %o2
  1382. ret_from_syscall:
  1383. /* Clear current_thread_info()->new_child, and
  1384. * check performance counter stuff too.
  1385. */
  1386. stb %g0, [%g6 + TI_NEW_CHILD]
  1387. ldx [%g6 + TI_FLAGS], %l0
  1388. call schedule_tail
  1389. mov %g7, %o0
  1390. andcc %l0, _TIF_PERFCTR, %g0
  1391. be,pt %icc, 1f
  1392. nop
  1393. ldx [%g6 + TI_PCR], %o7
  1394. wr %g0, %o7, %pcr
  1395. /* Blackbird errata workaround. See commentary in
  1396. * smp.c:smp_percpu_timer_interrupt() for more
  1397. * information.
  1398. */
  1399. ba,pt %xcc, 99f
  1400. nop
  1401. .align 64
  1402. 99: wr %g0, %g0, %pic
  1403. rd %pic, %g0
  1404. 1: b,pt %xcc, ret_sys_call
  1405. ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
  1406. sparc_exit: rdpr %pstate, %g2
  1407. wrpr %g2, PSTATE_IE, %pstate
  1408. rdpr %otherwin, %g1
  1409. rdpr %cansave, %g3
  1410. add %g3, %g1, %g3
  1411. wrpr %g3, 0x0, %cansave
  1412. wrpr %g0, 0x0, %otherwin
  1413. wrpr %g2, 0x0, %pstate
  1414. ba,pt %xcc, sys_exit
  1415. stb %g0, [%g6 + TI_WSAVED]
  1416. linux_sparc_ni_syscall:
  1417. sethi %hi(sys_ni_syscall), %l7
  1418. b,pt %xcc, 4f
  1419. or %l7, %lo(sys_ni_syscall), %l7
  1420. linux_syscall_trace32:
  1421. add %sp, PTREGS_OFF, %o0
  1422. call syscall_trace
  1423. clr %o1
  1424. srl %i0, 0, %o0
  1425. srl %i4, 0, %o4
  1426. srl %i1, 0, %o1
  1427. srl %i2, 0, %o2
  1428. b,pt %xcc, 2f
  1429. srl %i3, 0, %o3
  1430. linux_syscall_trace:
  1431. add %sp, PTREGS_OFF, %o0
  1432. call syscall_trace
  1433. clr %o1
  1434. mov %i0, %o0
  1435. mov %i1, %o1
  1436. mov %i2, %o2
  1437. mov %i3, %o3
  1438. b,pt %xcc, 2f
  1439. mov %i4, %o4
  1440. /* Linux 32-bit and SunOS system calls enter here... */
  1441. .align 32
  1442. .globl linux_sparc_syscall32
  1443. linux_sparc_syscall32:
  1444. /* Direct access to user regs, much faster. */
  1445. cmp %g1, NR_SYSCALLS ! IEU1 Group
  1446. bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
  1447. srl %i0, 0, %o0 ! IEU0
  1448. sll %g1, 2, %l4 ! IEU0 Group
  1449. srl %i4, 0, %o4 ! IEU1
  1450. lduw [%l7 + %l4], %l7 ! Load
  1451. srl %i1, 0, %o1 ! IEU0 Group
  1452. ldx [%curptr + TI_FLAGS], %l0 ! Load
  1453. srl %i5, 0, %o5 ! IEU1
  1454. srl %i2, 0, %o2 ! IEU0 Group
  1455. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1456. bne,pn %icc, linux_syscall_trace32 ! CTI
  1457. mov %i0, %l5 ! IEU1
  1458. call %l7 ! CTI Group brk forced
  1459. srl %i3, 0, %o3 ! IEU0
  1460. ba,a,pt %xcc, 3f
  1461. /* Linux native and SunOS system calls enter here... */
  1462. .align 32
  1463. .globl linux_sparc_syscall, ret_sys_call
  1464. linux_sparc_syscall:
  1465. /* Direct access to user regs, much faster. */
  1466. cmp %g1, NR_SYSCALLS ! IEU1 Group
  1467. bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
  1468. mov %i0, %o0 ! IEU0
  1469. sll %g1, 2, %l4 ! IEU0 Group
  1470. mov %i1, %o1 ! IEU1
  1471. lduw [%l7 + %l4], %l7 ! Load
  1472. 4: mov %i2, %o2 ! IEU0 Group
  1473. ldx [%curptr + TI_FLAGS], %l0 ! Load
  1474. mov %i3, %o3 ! IEU1
  1475. mov %i4, %o4 ! IEU0 Group
  1476. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1477. bne,pn %icc, linux_syscall_trace ! CTI Group
  1478. mov %i0, %l5 ! IEU0
  1479. 2: call %l7 ! CTI Group brk forced
  1480. mov %i5, %o5 ! IEU0
  1481. nop
  1482. 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1483. ret_sys_call:
  1484. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
  1485. ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
  1486. sra %o0, 0, %o0
  1487. mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
  1488. sllx %g2, 32, %g2
  1489. /* Check if force_successful_syscall_return()
  1490. * was invoked.
  1491. */
  1492. ldub [%curptr + TI_SYS_NOERROR], %l2
  1493. brnz,a,pn %l2, 80f
  1494. stb %g0, [%curptr + TI_SYS_NOERROR]
  1495. cmp %o0, -ERESTART_RESTARTBLOCK
  1496. bgeu,pn %xcc, 1f
  1497. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
  1498. 80:
  1499. /* System call success, clear Carry condition code. */
  1500. andn %g3, %g2, %g3
  1501. stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
  1502. bne,pn %icc, linux_syscall_trace2
  1503. add %l1, 0x4, %l2 ! npc = npc+4
  1504. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1505. ba,pt %xcc, rtrap_clr_l6
  1506. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1507. 1:
  1508. /* System call failure, set Carry condition code.
  1509. * Also, get abs(errno) to return to the process.
  1510. */
  1511. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
  1512. sub %g0, %o0, %o0
  1513. or %g3, %g2, %g3
  1514. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1515. mov 1, %l6
  1516. stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
  1517. bne,pn %icc, linux_syscall_trace2
  1518. add %l1, 0x4, %l2 ! npc = npc+4
  1519. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1520. b,pt %xcc, rtrap
  1521. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1522. linux_syscall_trace2:
  1523. add %sp, PTREGS_OFF, %o0
  1524. call syscall_trace
  1525. mov 1, %o1
  1526. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1527. ba,pt %xcc, rtrap
  1528. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1529. .align 32
  1530. .globl __flushw_user
  1531. __flushw_user:
  1532. rdpr %otherwin, %g1
  1533. brz,pn %g1, 2f
  1534. clr %g2
  1535. 1: save %sp, -128, %sp
  1536. rdpr %otherwin, %g1
  1537. brnz,pt %g1, 1b
  1538. add %g2, 1, %g2
  1539. 1: sub %g2, 1, %g2
  1540. brnz,pt %g2, 1b
  1541. restore %g0, %g0, %g0
  1542. 2: retl
  1543. nop
  1544. #ifdef CONFIG_SMP
  1545. .globl hard_smp_processor_id
  1546. hard_smp_processor_id:
  1547. __GET_CPUID(%o0)
  1548. retl
  1549. nop
  1550. #endif