entry.S 46 KB

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