entry.S 46 KB

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