entry.S 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887
  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. /* 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. ldub [%g3 + 0x04], %g4 /* pil */
  507. mov 1, %g2
  508. sllx %g2, %g4, %g2
  509. sllx %g4, 2, %g4
  510. lduw [%g6 + %g4], %g5 /* g5 = irq_work(cpu, pil) */
  511. stw %g5, [%g3 + 0x00] /* bucket->irq_chain = g5 */
  512. stw %g3, [%g6 + %g4] /* irq_work(cpu, pil) = bucket */
  513. wr %g2, 0x0, %set_softint
  514. retry
  515. do_ivec_xcall:
  516. mov 0x50, %g1
  517. ldxa [%g1 + %g0] ASI_INTR_R, %g1
  518. srl %g3, 0, %g3
  519. mov 0x60, %g7
  520. ldxa [%g7 + %g0] ASI_INTR_R, %g7
  521. stxa %g0, [%g0] ASI_INTR_RECEIVE
  522. membar #Sync
  523. ba,pt %xcc, 1f
  524. nop
  525. .align 32
  526. 1: jmpl %g3, %g0
  527. nop
  528. .globl save_alternate_globals
  529. save_alternate_globals: /* %o0 = save_area */
  530. rdpr %pstate, %o5
  531. andn %o5, PSTATE_IE, %o1
  532. wrpr %o1, PSTATE_AG, %pstate
  533. stx %g0, [%o0 + 0x00]
  534. stx %g1, [%o0 + 0x08]
  535. stx %g2, [%o0 + 0x10]
  536. stx %g3, [%o0 + 0x18]
  537. stx %g4, [%o0 + 0x20]
  538. stx %g5, [%o0 + 0x28]
  539. stx %g6, [%o0 + 0x30]
  540. stx %g7, [%o0 + 0x38]
  541. wrpr %o1, PSTATE_IG, %pstate
  542. stx %g0, [%o0 + 0x40]
  543. stx %g1, [%o0 + 0x48]
  544. stx %g2, [%o0 + 0x50]
  545. stx %g3, [%o0 + 0x58]
  546. stx %g4, [%o0 + 0x60]
  547. stx %g5, [%o0 + 0x68]
  548. stx %g6, [%o0 + 0x70]
  549. stx %g7, [%o0 + 0x78]
  550. wrpr %o1, PSTATE_MG, %pstate
  551. stx %g0, [%o0 + 0x80]
  552. stx %g1, [%o0 + 0x88]
  553. stx %g2, [%o0 + 0x90]
  554. stx %g3, [%o0 + 0x98]
  555. stx %g4, [%o0 + 0xa0]
  556. stx %g5, [%o0 + 0xa8]
  557. stx %g6, [%o0 + 0xb0]
  558. stx %g7, [%o0 + 0xb8]
  559. wrpr %o5, 0x0, %pstate
  560. retl
  561. nop
  562. .globl restore_alternate_globals
  563. restore_alternate_globals: /* %o0 = save_area */
  564. rdpr %pstate, %o5
  565. andn %o5, PSTATE_IE, %o1
  566. wrpr %o1, PSTATE_AG, %pstate
  567. ldx [%o0 + 0x00], %g0
  568. ldx [%o0 + 0x08], %g1
  569. ldx [%o0 + 0x10], %g2
  570. ldx [%o0 + 0x18], %g3
  571. ldx [%o0 + 0x20], %g4
  572. ldx [%o0 + 0x28], %g5
  573. ldx [%o0 + 0x30], %g6
  574. ldx [%o0 + 0x38], %g7
  575. wrpr %o1, PSTATE_IG, %pstate
  576. ldx [%o0 + 0x40], %g0
  577. ldx [%o0 + 0x48], %g1
  578. ldx [%o0 + 0x50], %g2
  579. ldx [%o0 + 0x58], %g3
  580. ldx [%o0 + 0x60], %g4
  581. ldx [%o0 + 0x68], %g5
  582. ldx [%o0 + 0x70], %g6
  583. ldx [%o0 + 0x78], %g7
  584. wrpr %o1, PSTATE_MG, %pstate
  585. ldx [%o0 + 0x80], %g0
  586. ldx [%o0 + 0x88], %g1
  587. ldx [%o0 + 0x90], %g2
  588. ldx [%o0 + 0x98], %g3
  589. ldx [%o0 + 0xa0], %g4
  590. ldx [%o0 + 0xa8], %g5
  591. ldx [%o0 + 0xb0], %g6
  592. ldx [%o0 + 0xb8], %g7
  593. wrpr %o5, 0x0, %pstate
  594. retl
  595. nop
  596. .globl getcc, setcc
  597. getcc:
  598. ldx [%o0 + PT_V9_TSTATE], %o1
  599. srlx %o1, 32, %o1
  600. and %o1, 0xf, %o1
  601. retl
  602. stx %o1, [%o0 + PT_V9_G1]
  603. setcc:
  604. ldx [%o0 + PT_V9_TSTATE], %o1
  605. ldx [%o0 + PT_V9_G1], %o2
  606. or %g0, %ulo(TSTATE_ICC), %o3
  607. sllx %o3, 32, %o3
  608. andn %o1, %o3, %o1
  609. sllx %o2, 32, %o2
  610. and %o2, %o3, %o2
  611. or %o1, %o2, %o1
  612. retl
  613. stx %o1, [%o0 + PT_V9_TSTATE]
  614. .globl utrap, utrap_ill
  615. utrap: brz,pn %g1, etrap
  616. nop
  617. save %sp, -128, %sp
  618. rdpr %tstate, %l6
  619. rdpr %cwp, %l7
  620. andn %l6, TSTATE_CWP, %l6
  621. wrpr %l6, %l7, %tstate
  622. rdpr %tpc, %l6
  623. rdpr %tnpc, %l7
  624. wrpr %g1, 0, %tnpc
  625. done
  626. utrap_ill:
  627. call bad_trap
  628. add %sp, PTREGS_OFF, %o0
  629. ba,pt %xcc, rtrap
  630. clr %l6
  631. /* XXX Here is stuff we still need to write... -DaveM XXX */
  632. .globl netbsd_syscall
  633. netbsd_syscall:
  634. retl
  635. nop
  636. /* We need to carefully read the error status, ACK
  637. * the errors, prevent recursive traps, and pass the
  638. * information on to C code for logging.
  639. *
  640. * We pass the AFAR in as-is, and we encode the status
  641. * information as described in asm-sparc64/sfafsr.h
  642. */
  643. .globl __spitfire_access_error
  644. __spitfire_access_error:
  645. /* Disable ESTATE error reporting so that we do not
  646. * take recursive traps and RED state the processor.
  647. */
  648. stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
  649. membar #Sync
  650. mov UDBE_UE, %g1
  651. ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
  652. /* __spitfire_cee_trap branches here with AFSR in %g4 and
  653. * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
  654. * ESTATE Error Enable register.
  655. */
  656. __spitfire_cee_trap_continue:
  657. ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
  658. rdpr %tt, %g3
  659. and %g3, 0x1ff, %g3 ! Paranoia
  660. sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
  661. or %g4, %g3, %g4
  662. rdpr %tl, %g3
  663. cmp %g3, 1
  664. mov 1, %g3
  665. bleu %xcc, 1f
  666. sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
  667. or %g4, %g3, %g4
  668. /* Read in the UDB error register state, clearing the
  669. * sticky error bits as-needed. We only clear them if
  670. * the UE bit is set. Likewise, __spitfire_cee_trap
  671. * below will only do so if the CE bit is set.
  672. *
  673. * NOTE: UltraSparc-I/II have high and low UDB error
  674. * registers, corresponding to the two UDB units
  675. * present on those chips. UltraSparc-IIi only
  676. * has a single UDB, called "SDB" in the manual.
  677. * For IIi the upper UDB register always reads
  678. * as zero so for our purposes things will just
  679. * work with the checks below.
  680. */
  681. 1: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
  682. and %g3, 0x3ff, %g7 ! Paranoia
  683. sllx %g7, SFSTAT_UDBH_SHIFT, %g7
  684. or %g4, %g7, %g4
  685. andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
  686. be,pn %xcc, 1f
  687. nop
  688. stxa %g3, [%g0] ASI_UDB_ERROR_W
  689. membar #Sync
  690. 1: mov 0x18, %g3
  691. ldxa [%g3] ASI_UDBL_ERROR_R, %g3
  692. and %g3, 0x3ff, %g7 ! Paranoia
  693. sllx %g7, SFSTAT_UDBL_SHIFT, %g7
  694. or %g4, %g7, %g4
  695. andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
  696. be,pn %xcc, 1f
  697. nop
  698. mov 0x18, %g7
  699. stxa %g3, [%g7] ASI_UDB_ERROR_W
  700. membar #Sync
  701. 1: /* Ok, now that we've latched the error state,
  702. * clear the sticky bits in the AFSR.
  703. */
  704. stxa %g4, [%g0] ASI_AFSR
  705. membar #Sync
  706. rdpr %tl, %g2
  707. cmp %g2, 1
  708. rdpr %pil, %g2
  709. bleu,pt %xcc, 1f
  710. wrpr %g0, 15, %pil
  711. ba,pt %xcc, etraptl1
  712. rd %pc, %g7
  713. ba,pt %xcc, 2f
  714. nop
  715. 1: ba,pt %xcc, etrap_irq
  716. rd %pc, %g7
  717. 2: mov %l4, %o1
  718. mov %l5, %o2
  719. call spitfire_access_error
  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. * This is just like __spiftire_access_error above, but it
  742. * specifically handles correctable errors. If an
  743. * uncorrectable error is indicated in the AFSR we
  744. * will branch directly above to __spitfire_access_error
  745. * to handle it instead. Uncorrectable therefore takes
  746. * priority over correctable, and the error logging
  747. * C code will notice this case by inspecting the
  748. * trap type.
  749. */
  750. .globl __spitfire_cee_trap
  751. __spitfire_cee_trap:
  752. ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
  753. mov 1, %g3
  754. sllx %g3, SFAFSR_UE_SHIFT, %g3
  755. andcc %g4, %g3, %g0 ! Check for UE
  756. bne,pn %xcc, __spitfire_access_error
  757. nop
  758. /* Ok, in this case we only have a correctable error.
  759. * Indicate we only wish to capture that state in register
  760. * %g1, and we only disable CE error reporting unlike UE
  761. * handling which disables all errors.
  762. */
  763. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
  764. andn %g3, ESTATE_ERR_CE, %g3
  765. stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
  766. membar #Sync
  767. /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
  768. ba,pt %xcc, __spitfire_cee_trap_continue
  769. mov UDBE_CE, %g1
  770. .globl __spitfire_data_access_exception
  771. .globl __spitfire_data_access_exception_tl1
  772. __spitfire_data_access_exception_tl1:
  773. rdpr %pstate, %g4
  774. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  775. mov TLB_SFSR, %g3
  776. mov DMMU_SFAR, %g5
  777. ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
  778. ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
  779. stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
  780. membar #Sync
  781. rdpr %tt, %g3
  782. cmp %g3, 0x80 ! first win spill/fill trap
  783. blu,pn %xcc, 1f
  784. cmp %g3, 0xff ! last win spill/fill trap
  785. bgu,pn %xcc, 1f
  786. nop
  787. ba,pt %xcc, winfix_dax
  788. rdpr %tpc, %g3
  789. 1: sethi %hi(109f), %g7
  790. ba,pt %xcc, etraptl1
  791. 109: or %g7, %lo(109b), %g7
  792. mov %l4, %o1
  793. mov %l5, %o2
  794. call spitfire_data_access_exception_tl1
  795. add %sp, PTREGS_OFF, %o0
  796. ba,pt %xcc, rtrap
  797. clr %l6
  798. __spitfire_data_access_exception:
  799. rdpr %pstate, %g4
  800. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  801. mov TLB_SFSR, %g3
  802. mov DMMU_SFAR, %g5
  803. ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
  804. ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
  805. stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
  806. membar #Sync
  807. sethi %hi(109f), %g7
  808. ba,pt %xcc, etrap
  809. 109: or %g7, %lo(109b), %g7
  810. mov %l4, %o1
  811. mov %l5, %o2
  812. call spitfire_data_access_exception
  813. add %sp, PTREGS_OFF, %o0
  814. ba,pt %xcc, rtrap
  815. clr %l6
  816. .globl __spitfire_insn_access_exception
  817. .globl __spitfire_insn_access_exception_tl1
  818. __spitfire_insn_access_exception_tl1:
  819. rdpr %pstate, %g4
  820. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  821. mov TLB_SFSR, %g3
  822. ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
  823. rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
  824. stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
  825. membar #Sync
  826. sethi %hi(109f), %g7
  827. ba,pt %xcc, etraptl1
  828. 109: or %g7, %lo(109b), %g7
  829. mov %l4, %o1
  830. mov %l5, %o2
  831. call spitfire_insn_access_exception_tl1
  832. add %sp, PTREGS_OFF, %o0
  833. ba,pt %xcc, rtrap
  834. clr %l6
  835. __spitfire_insn_access_exception:
  836. rdpr %pstate, %g4
  837. wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
  838. mov TLB_SFSR, %g3
  839. ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
  840. rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
  841. stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
  842. membar #Sync
  843. sethi %hi(109f), %g7
  844. ba,pt %xcc, etrap
  845. 109: or %g7, %lo(109b), %g7
  846. mov %l4, %o1
  847. mov %l5, %o2
  848. call spitfire_insn_access_exception
  849. add %sp, PTREGS_OFF, %o0
  850. ba,pt %xcc, rtrap
  851. clr %l6
  852. /* These get patched into the trap table at boot time
  853. * once we know we have a cheetah processor.
  854. */
  855. .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
  856. cheetah_fecc_trap_vector:
  857. membar #Sync
  858. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  859. andn %g1, DCU_DC | DCU_IC, %g1
  860. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  861. membar #Sync
  862. sethi %hi(cheetah_fast_ecc), %g2
  863. jmpl %g2 + %lo(cheetah_fast_ecc), %g0
  864. mov 0, %g1
  865. cheetah_fecc_trap_vector_tl1:
  866. membar #Sync
  867. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  868. andn %g1, DCU_DC | DCU_IC, %g1
  869. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  870. membar #Sync
  871. sethi %hi(cheetah_fast_ecc), %g2
  872. jmpl %g2 + %lo(cheetah_fast_ecc), %g0
  873. mov 1, %g1
  874. .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
  875. cheetah_cee_trap_vector:
  876. membar #Sync
  877. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  878. andn %g1, DCU_IC, %g1
  879. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  880. membar #Sync
  881. sethi %hi(cheetah_cee), %g2
  882. jmpl %g2 + %lo(cheetah_cee), %g0
  883. mov 0, %g1
  884. cheetah_cee_trap_vector_tl1:
  885. membar #Sync
  886. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  887. andn %g1, DCU_IC, %g1
  888. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  889. membar #Sync
  890. sethi %hi(cheetah_cee), %g2
  891. jmpl %g2 + %lo(cheetah_cee), %g0
  892. mov 1, %g1
  893. .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
  894. cheetah_deferred_trap_vector:
  895. membar #Sync
  896. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
  897. andn %g1, DCU_DC | DCU_IC, %g1;
  898. stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
  899. membar #Sync;
  900. sethi %hi(cheetah_deferred_trap), %g2
  901. jmpl %g2 + %lo(cheetah_deferred_trap), %g0
  902. mov 0, %g1
  903. cheetah_deferred_trap_vector_tl1:
  904. membar #Sync;
  905. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
  906. andn %g1, DCU_DC | DCU_IC, %g1;
  907. stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
  908. membar #Sync;
  909. sethi %hi(cheetah_deferred_trap), %g2
  910. jmpl %g2 + %lo(cheetah_deferred_trap), %g0
  911. mov 1, %g1
  912. /* Cheetah+ specific traps. These are for the new I/D cache parity
  913. * error traps. The first argument to cheetah_plus_parity_handler
  914. * is encoded as follows:
  915. *
  916. * Bit0: 0=dcache,1=icache
  917. * Bit1: 0=recoverable,1=unrecoverable
  918. */
  919. .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
  920. cheetah_plus_dcpe_trap_vector:
  921. membar #Sync
  922. sethi %hi(do_cheetah_plus_data_parity), %g7
  923. jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
  924. nop
  925. nop
  926. nop
  927. nop
  928. nop
  929. do_cheetah_plus_data_parity:
  930. ba,pt %xcc, etrap
  931. rd %pc, %g7
  932. mov 0x0, %o0
  933. call cheetah_plus_parity_error
  934. add %sp, PTREGS_OFF, %o1
  935. ba,pt %xcc, rtrap
  936. clr %l6
  937. cheetah_plus_dcpe_trap_vector_tl1:
  938. membar #Sync
  939. wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
  940. sethi %hi(do_dcpe_tl1), %g3
  941. jmpl %g3 + %lo(do_dcpe_tl1), %g0
  942. nop
  943. nop
  944. nop
  945. nop
  946. .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
  947. cheetah_plus_icpe_trap_vector:
  948. membar #Sync
  949. sethi %hi(do_cheetah_plus_insn_parity), %g7
  950. jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
  951. nop
  952. nop
  953. nop
  954. nop
  955. nop
  956. do_cheetah_plus_insn_parity:
  957. ba,pt %xcc, etrap
  958. rd %pc, %g7
  959. mov 0x1, %o0
  960. call cheetah_plus_parity_error
  961. add %sp, PTREGS_OFF, %o1
  962. ba,pt %xcc, rtrap
  963. clr %l6
  964. cheetah_plus_icpe_trap_vector_tl1:
  965. membar #Sync
  966. wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
  967. sethi %hi(do_icpe_tl1), %g3
  968. jmpl %g3 + %lo(do_icpe_tl1), %g0
  969. nop
  970. nop
  971. nop
  972. nop
  973. /* If we take one of these traps when tl >= 1, then we
  974. * jump to interrupt globals. If some trap level above us
  975. * was also using interrupt globals, we cannot recover.
  976. * We may use all interrupt global registers except %g6.
  977. */
  978. .globl do_dcpe_tl1, do_icpe_tl1
  979. do_dcpe_tl1:
  980. rdpr %tl, %g1 ! Save original trap level
  981. mov 1, %g2 ! Setup TSTATE checking loop
  982. sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
  983. 1: wrpr %g2, %tl ! Set trap level to check
  984. rdpr %tstate, %g4 ! Read TSTATE for this level
  985. andcc %g4, %g3, %g0 ! Interrupt globals in use?
  986. bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
  987. wrpr %g1, %tl ! Restore original trap level
  988. add %g2, 1, %g2 ! Next trap level
  989. cmp %g2, %g1 ! Hit them all yet?
  990. ble,pt %icc, 1b ! Not yet
  991. nop
  992. wrpr %g1, %tl ! Restore original trap level
  993. do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
  994. /* Reset D-cache parity */
  995. sethi %hi(1 << 16), %g1 ! D-cache size
  996. mov (1 << 5), %g2 ! D-cache line size
  997. sub %g1, %g2, %g1 ! Move down 1 cacheline
  998. 1: srl %g1, 14, %g3 ! Compute UTAG
  999. membar #Sync
  1000. stxa %g3, [%g1] ASI_DCACHE_UTAG
  1001. membar #Sync
  1002. sub %g2, 8, %g3 ! 64-bit data word within line
  1003. 2: membar #Sync
  1004. stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
  1005. membar #Sync
  1006. subcc %g3, 8, %g3 ! Next 64-bit data word
  1007. bge,pt %icc, 2b
  1008. nop
  1009. subcc %g1, %g2, %g1 ! Next cacheline
  1010. bge,pt %icc, 1b
  1011. nop
  1012. ba,pt %xcc, dcpe_icpe_tl1_common
  1013. nop
  1014. do_dcpe_tl1_fatal:
  1015. sethi %hi(1f), %g7
  1016. ba,pt %xcc, etraptl1
  1017. 1: or %g7, %lo(1b), %g7
  1018. mov 0x2, %o0
  1019. call cheetah_plus_parity_error
  1020. add %sp, PTREGS_OFF, %o1
  1021. ba,pt %xcc, rtrap
  1022. clr %l6
  1023. do_icpe_tl1:
  1024. rdpr %tl, %g1 ! Save original trap level
  1025. mov 1, %g2 ! Setup TSTATE checking loop
  1026. sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
  1027. 1: wrpr %g2, %tl ! Set trap level to check
  1028. rdpr %tstate, %g4 ! Read TSTATE for this level
  1029. andcc %g4, %g3, %g0 ! Interrupt globals in use?
  1030. bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
  1031. wrpr %g1, %tl ! Restore original trap level
  1032. add %g2, 1, %g2 ! Next trap level
  1033. cmp %g2, %g1 ! Hit them all yet?
  1034. ble,pt %icc, 1b ! Not yet
  1035. nop
  1036. wrpr %g1, %tl ! Restore original trap level
  1037. do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
  1038. /* Flush I-cache */
  1039. sethi %hi(1 << 15), %g1 ! I-cache size
  1040. mov (1 << 5), %g2 ! I-cache line size
  1041. sub %g1, %g2, %g1
  1042. 1: or %g1, (2 << 3), %g3
  1043. stxa %g0, [%g3] ASI_IC_TAG
  1044. membar #Sync
  1045. subcc %g1, %g2, %g1
  1046. bge,pt %icc, 1b
  1047. nop
  1048. ba,pt %xcc, dcpe_icpe_tl1_common
  1049. nop
  1050. do_icpe_tl1_fatal:
  1051. sethi %hi(1f), %g7
  1052. ba,pt %xcc, etraptl1
  1053. 1: or %g7, %lo(1b), %g7
  1054. mov 0x3, %o0
  1055. call cheetah_plus_parity_error
  1056. add %sp, PTREGS_OFF, %o1
  1057. ba,pt %xcc, rtrap
  1058. clr %l6
  1059. dcpe_icpe_tl1_common:
  1060. /* Flush D-cache, re-enable D/I caches in DCU and finally
  1061. * retry the trapping instruction.
  1062. */
  1063. sethi %hi(1 << 16), %g1 ! D-cache size
  1064. mov (1 << 5), %g2 ! D-cache line size
  1065. sub %g1, %g2, %g1
  1066. 1: stxa %g0, [%g1] ASI_DCACHE_TAG
  1067. membar #Sync
  1068. subcc %g1, %g2, %g1
  1069. bge,pt %icc, 1b
  1070. nop
  1071. ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
  1072. or %g1, (DCU_DC | DCU_IC), %g1
  1073. stxa %g1, [%g0] ASI_DCU_CONTROL_REG
  1074. membar #Sync
  1075. retry
  1076. /* Capture I/D/E-cache state into per-cpu error scoreboard.
  1077. *
  1078. * %g1: (TL>=0) ? 1 : 0
  1079. * %g2: scratch
  1080. * %g3: scratch
  1081. * %g4: AFSR
  1082. * %g5: AFAR
  1083. * %g6: current thread ptr
  1084. * %g7: scratch
  1085. */
  1086. __cheetah_log_error:
  1087. /* Put "TL1" software bit into AFSR. */
  1088. and %g1, 0x1, %g1
  1089. sllx %g1, 63, %g2
  1090. or %g4, %g2, %g4
  1091. /* Get log entry pointer for this cpu at this trap level. */
  1092. BRANCH_IF_JALAPENO(g2,g3,50f)
  1093. ldxa [%g0] ASI_SAFARI_CONFIG, %g2
  1094. srlx %g2, 17, %g2
  1095. ba,pt %xcc, 60f
  1096. and %g2, 0x3ff, %g2
  1097. 50: ldxa [%g0] ASI_JBUS_CONFIG, %g2
  1098. srlx %g2, 17, %g2
  1099. and %g2, 0x1f, %g2
  1100. 60: sllx %g2, 9, %g2
  1101. sethi %hi(cheetah_error_log), %g3
  1102. ldx [%g3 + %lo(cheetah_error_log)], %g3
  1103. brz,pn %g3, 80f
  1104. nop
  1105. add %g3, %g2, %g3
  1106. sllx %g1, 8, %g1
  1107. add %g3, %g1, %g1
  1108. /* %g1 holds pointer to the top of the logging scoreboard */
  1109. ldx [%g1 + 0x0], %g7
  1110. cmp %g7, -1
  1111. bne,pn %xcc, 80f
  1112. nop
  1113. stx %g4, [%g1 + 0x0]
  1114. stx %g5, [%g1 + 0x8]
  1115. add %g1, 0x10, %g1
  1116. /* %g1 now points to D-cache logging area */
  1117. set 0x3ff8, %g2 /* DC_addr mask */
  1118. and %g5, %g2, %g2 /* DC_addr bits of AFAR */
  1119. srlx %g5, 12, %g3
  1120. or %g3, 1, %g3 /* PHYS tag + valid */
  1121. 10: ldxa [%g2] ASI_DCACHE_TAG, %g7
  1122. cmp %g3, %g7 /* TAG match? */
  1123. bne,pt %xcc, 13f
  1124. nop
  1125. /* Yep, what we want, capture state. */
  1126. stx %g2, [%g1 + 0x20]
  1127. stx %g7, [%g1 + 0x28]
  1128. /* A membar Sync is required before and after utag access. */
  1129. membar #Sync
  1130. ldxa [%g2] ASI_DCACHE_UTAG, %g7
  1131. membar #Sync
  1132. stx %g7, [%g1 + 0x30]
  1133. ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
  1134. stx %g7, [%g1 + 0x38]
  1135. clr %g3
  1136. 12: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
  1137. stx %g7, [%g1]
  1138. add %g3, (1 << 5), %g3
  1139. cmp %g3, (4 << 5)
  1140. bl,pt %xcc, 12b
  1141. add %g1, 0x8, %g1
  1142. ba,pt %xcc, 20f
  1143. add %g1, 0x20, %g1
  1144. 13: sethi %hi(1 << 14), %g7
  1145. add %g2, %g7, %g2
  1146. srlx %g2, 14, %g7
  1147. cmp %g7, 4
  1148. bl,pt %xcc, 10b
  1149. nop
  1150. add %g1, 0x40, %g1
  1151. /* %g1 now points to I-cache logging area */
  1152. 20: set 0x1fe0, %g2 /* IC_addr mask */
  1153. and %g5, %g2, %g2 /* IC_addr bits of AFAR */
  1154. sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
  1155. srlx %g5, (13 - 8), %g3 /* Make PTAG */
  1156. andn %g3, 0xff, %g3 /* Mask off undefined bits */
  1157. 21: ldxa [%g2] ASI_IC_TAG, %g7
  1158. andn %g7, 0xff, %g7
  1159. cmp %g3, %g7
  1160. bne,pt %xcc, 23f
  1161. nop
  1162. /* Yep, what we want, capture state. */
  1163. stx %g2, [%g1 + 0x40]
  1164. stx %g7, [%g1 + 0x48]
  1165. add %g2, (1 << 3), %g2
  1166. ldxa [%g2] ASI_IC_TAG, %g7
  1167. add %g2, (1 << 3), %g2
  1168. stx %g7, [%g1 + 0x50]
  1169. ldxa [%g2] ASI_IC_TAG, %g7
  1170. add %g2, (1 << 3), %g2
  1171. stx %g7, [%g1 + 0x60]
  1172. ldxa [%g2] ASI_IC_TAG, %g7
  1173. stx %g7, [%g1 + 0x68]
  1174. sub %g2, (3 << 3), %g2
  1175. ldxa [%g2] ASI_IC_STAG, %g7
  1176. stx %g7, [%g1 + 0x58]
  1177. clr %g3
  1178. srlx %g2, 2, %g2
  1179. 22: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
  1180. stx %g7, [%g1]
  1181. add %g3, (1 << 3), %g3
  1182. cmp %g3, (8 << 3)
  1183. bl,pt %xcc, 22b
  1184. add %g1, 0x8, %g1
  1185. ba,pt %xcc, 30f
  1186. add %g1, 0x30, %g1
  1187. 23: sethi %hi(1 << 14), %g7
  1188. add %g2, %g7, %g2
  1189. srlx %g2, 14, %g7
  1190. cmp %g7, 4
  1191. bl,pt %xcc, 21b
  1192. nop
  1193. add %g1, 0x70, %g1
  1194. /* %g1 now points to E-cache logging area */
  1195. 30: andn %g5, (32 - 1), %g2
  1196. stx %g2, [%g1 + 0x20]
  1197. ldxa [%g2] ASI_EC_TAG_DATA, %g7
  1198. stx %g7, [%g1 + 0x28]
  1199. ldxa [%g2] ASI_EC_R, %g0
  1200. clr %g3
  1201. 31: ldxa [%g3] ASI_EC_DATA, %g7
  1202. stx %g7, [%g1 + %g3]
  1203. add %g3, 0x8, %g3
  1204. cmp %g3, 0x20
  1205. bl,pt %xcc, 31b
  1206. nop
  1207. 80:
  1208. rdpr %tt, %g2
  1209. cmp %g2, 0x70
  1210. be c_fast_ecc
  1211. cmp %g2, 0x63
  1212. be c_cee
  1213. nop
  1214. ba,pt %xcc, c_deferred
  1215. /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
  1216. * in the trap table. That code has done a memory barrier
  1217. * and has disabled both the I-cache and D-cache in the DCU
  1218. * control register. The I-cache is disabled so that we may
  1219. * capture the corrupted cache line, and the D-cache is disabled
  1220. * because corrupt data may have been placed there and we don't
  1221. * want to reference it.
  1222. *
  1223. * %g1 is one if this trap occurred at %tl >= 1.
  1224. *
  1225. * Next, we turn off error reporting so that we don't recurse.
  1226. */
  1227. .globl cheetah_fast_ecc
  1228. cheetah_fast_ecc:
  1229. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1230. andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
  1231. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1232. membar #Sync
  1233. /* Fetch and clear AFSR/AFAR */
  1234. ldxa [%g0] ASI_AFSR, %g4
  1235. ldxa [%g0] ASI_AFAR, %g5
  1236. stxa %g4, [%g0] ASI_AFSR
  1237. membar #Sync
  1238. ba,pt %xcc, __cheetah_log_error
  1239. nop
  1240. c_fast_ecc:
  1241. rdpr %pil, %g2
  1242. wrpr %g0, 15, %pil
  1243. ba,pt %xcc, etrap_irq
  1244. rd %pc, %g7
  1245. mov %l4, %o1
  1246. mov %l5, %o2
  1247. call cheetah_fecc_handler
  1248. add %sp, PTREGS_OFF, %o0
  1249. ba,a,pt %xcc, rtrap_irq
  1250. /* Our caller has disabled I-cache and performed membar Sync. */
  1251. .globl cheetah_cee
  1252. cheetah_cee:
  1253. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1254. andn %g2, ESTATE_ERROR_CEEN, %g2
  1255. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1256. membar #Sync
  1257. /* Fetch and clear AFSR/AFAR */
  1258. ldxa [%g0] ASI_AFSR, %g4
  1259. ldxa [%g0] ASI_AFAR, %g5
  1260. stxa %g4, [%g0] ASI_AFSR
  1261. membar #Sync
  1262. ba,pt %xcc, __cheetah_log_error
  1263. nop
  1264. c_cee:
  1265. rdpr %pil, %g2
  1266. wrpr %g0, 15, %pil
  1267. ba,pt %xcc, etrap_irq
  1268. rd %pc, %g7
  1269. mov %l4, %o1
  1270. mov %l5, %o2
  1271. call cheetah_cee_handler
  1272. add %sp, PTREGS_OFF, %o0
  1273. ba,a,pt %xcc, rtrap_irq
  1274. /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
  1275. .globl cheetah_deferred_trap
  1276. cheetah_deferred_trap:
  1277. ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
  1278. andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
  1279. stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
  1280. membar #Sync
  1281. /* Fetch and clear AFSR/AFAR */
  1282. ldxa [%g0] ASI_AFSR, %g4
  1283. ldxa [%g0] ASI_AFAR, %g5
  1284. stxa %g4, [%g0] ASI_AFSR
  1285. membar #Sync
  1286. ba,pt %xcc, __cheetah_log_error
  1287. nop
  1288. c_deferred:
  1289. rdpr %pil, %g2
  1290. wrpr %g0, 15, %pil
  1291. ba,pt %xcc, etrap_irq
  1292. rd %pc, %g7
  1293. mov %l4, %o1
  1294. mov %l5, %o2
  1295. call cheetah_deferred_handler
  1296. add %sp, PTREGS_OFF, %o0
  1297. ba,a,pt %xcc, rtrap_irq
  1298. .globl __do_privact
  1299. __do_privact:
  1300. mov TLB_SFSR, %g3
  1301. stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
  1302. membar #Sync
  1303. sethi %hi(109f), %g7
  1304. ba,pt %xcc, etrap
  1305. 109: or %g7, %lo(109b), %g7
  1306. call do_privact
  1307. add %sp, PTREGS_OFF, %o0
  1308. ba,pt %xcc, rtrap
  1309. clr %l6
  1310. .globl do_mna
  1311. do_mna:
  1312. rdpr %tl, %g3
  1313. cmp %g3, 1
  1314. /* Setup %g4/%g5 now as they are used in the
  1315. * winfixup code.
  1316. */
  1317. mov TLB_SFSR, %g3
  1318. mov DMMU_SFAR, %g4
  1319. ldxa [%g4] ASI_DMMU, %g4
  1320. ldxa [%g3] ASI_DMMU, %g5
  1321. stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
  1322. membar #Sync
  1323. bgu,pn %icc, winfix_mna
  1324. rdpr %tpc, %g3
  1325. 1: sethi %hi(109f), %g7
  1326. ba,pt %xcc, etrap
  1327. 109: or %g7, %lo(109b), %g7
  1328. mov %l4, %o1
  1329. mov %l5, %o2
  1330. call mem_address_unaligned
  1331. add %sp, PTREGS_OFF, %o0
  1332. ba,pt %xcc, rtrap
  1333. clr %l6
  1334. .globl do_lddfmna
  1335. do_lddfmna:
  1336. sethi %hi(109f), %g7
  1337. mov TLB_SFSR, %g4
  1338. ldxa [%g4] ASI_DMMU, %g5
  1339. stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
  1340. membar #Sync
  1341. mov DMMU_SFAR, %g4
  1342. ldxa [%g4] ASI_DMMU, %g4
  1343. ba,pt %xcc, etrap
  1344. 109: or %g7, %lo(109b), %g7
  1345. mov %l4, %o1
  1346. mov %l5, %o2
  1347. call handle_lddfmna
  1348. add %sp, PTREGS_OFF, %o0
  1349. ba,pt %xcc, rtrap
  1350. clr %l6
  1351. .globl do_stdfmna
  1352. do_stdfmna:
  1353. sethi %hi(109f), %g7
  1354. mov TLB_SFSR, %g4
  1355. ldxa [%g4] ASI_DMMU, %g5
  1356. stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
  1357. membar #Sync
  1358. mov DMMU_SFAR, %g4
  1359. ldxa [%g4] ASI_DMMU, %g4
  1360. ba,pt %xcc, etrap
  1361. 109: or %g7, %lo(109b), %g7
  1362. mov %l4, %o1
  1363. mov %l5, %o2
  1364. call handle_stdfmna
  1365. add %sp, PTREGS_OFF, %o0
  1366. ba,pt %xcc, rtrap
  1367. clr %l6
  1368. .globl breakpoint_trap
  1369. breakpoint_trap:
  1370. call sparc_breakpoint
  1371. add %sp, PTREGS_OFF, %o0
  1372. ba,pt %xcc, rtrap
  1373. nop
  1374. #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
  1375. defined(CONFIG_SOLARIS_EMUL_MODULE)
  1376. /* SunOS uses syscall zero as the 'indirect syscall' it looks
  1377. * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
  1378. * This is complete brain damage.
  1379. */
  1380. .globl sunos_indir
  1381. sunos_indir:
  1382. srl %o0, 0, %o0
  1383. mov %o7, %l4
  1384. cmp %o0, NR_SYSCALLS
  1385. blu,a,pt %icc, 1f
  1386. sll %o0, 0x2, %o0
  1387. sethi %hi(sunos_nosys), %l6
  1388. b,pt %xcc, 2f
  1389. or %l6, %lo(sunos_nosys), %l6
  1390. 1: sethi %hi(sunos_sys_table), %l7
  1391. or %l7, %lo(sunos_sys_table), %l7
  1392. lduw [%l7 + %o0], %l6
  1393. 2: mov %o1, %o0
  1394. mov %o2, %o1
  1395. mov %o3, %o2
  1396. mov %o4, %o3
  1397. mov %o5, %o4
  1398. call %l6
  1399. mov %l4, %o7
  1400. .globl sunos_getpid
  1401. sunos_getpid:
  1402. call sys_getppid
  1403. nop
  1404. call sys_getpid
  1405. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1406. b,pt %xcc, ret_sys_call
  1407. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1408. /* SunOS getuid() returns uid in %o0 and euid in %o1 */
  1409. .globl sunos_getuid
  1410. sunos_getuid:
  1411. call sys32_geteuid16
  1412. nop
  1413. call sys32_getuid16
  1414. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1415. b,pt %xcc, ret_sys_call
  1416. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1417. /* SunOS getgid() returns gid in %o0 and egid in %o1 */
  1418. .globl sunos_getgid
  1419. sunos_getgid:
  1420. call sys32_getegid16
  1421. nop
  1422. call sys32_getgid16
  1423. stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
  1424. b,pt %xcc, ret_sys_call
  1425. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1426. #endif
  1427. /* SunOS's execv() call only specifies the argv argument, the
  1428. * environment settings are the same as the calling processes.
  1429. */
  1430. .globl sunos_execv
  1431. sys_execve:
  1432. sethi %hi(sparc_execve), %g1
  1433. ba,pt %xcc, execve_merge
  1434. or %g1, %lo(sparc_execve), %g1
  1435. #ifdef CONFIG_COMPAT
  1436. .globl sys_execve
  1437. sunos_execv:
  1438. stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
  1439. .globl sys32_execve
  1440. sys32_execve:
  1441. sethi %hi(sparc32_execve), %g1
  1442. or %g1, %lo(sparc32_execve), %g1
  1443. #endif
  1444. execve_merge:
  1445. flushw
  1446. jmpl %g1, %g0
  1447. add %sp, PTREGS_OFF, %o0
  1448. .globl sys_pipe, sys_sigpause, sys_nis_syscall
  1449. .globl sys_sigsuspend, sys_rt_sigsuspend
  1450. .globl sys_rt_sigreturn
  1451. .globl sys_ptrace
  1452. .globl sys_sigaltstack
  1453. .align 32
  1454. sys_pipe: ba,pt %xcc, sparc_pipe
  1455. add %sp, PTREGS_OFF, %o0
  1456. sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
  1457. add %sp, PTREGS_OFF, %o0
  1458. sys_memory_ordering:
  1459. ba,pt %xcc, sparc_memory_ordering
  1460. add %sp, PTREGS_OFF, %o1
  1461. sys_sigaltstack:ba,pt %xcc, do_sigaltstack
  1462. add %i6, STACK_BIAS, %o2
  1463. #ifdef CONFIG_COMPAT
  1464. .globl sys32_sigstack
  1465. sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
  1466. mov %i6, %o2
  1467. .globl sys32_sigaltstack
  1468. sys32_sigaltstack:
  1469. ba,pt %xcc, do_sys32_sigaltstack
  1470. mov %i6, %o2
  1471. #endif
  1472. .align 32
  1473. sys_sigsuspend: add %sp, PTREGS_OFF, %o0
  1474. call do_sigsuspend
  1475. add %o7, 1f-.-4, %o7
  1476. nop
  1477. sys_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
  1478. add %sp, PTREGS_OFF, %o2
  1479. call do_rt_sigsuspend
  1480. add %o7, 1f-.-4, %o7
  1481. nop
  1482. #ifdef CONFIG_COMPAT
  1483. .globl sys32_rt_sigsuspend
  1484. sys32_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
  1485. srl %o0, 0, %o0
  1486. add %sp, PTREGS_OFF, %o2
  1487. call do_rt_sigsuspend32
  1488. add %o7, 1f-.-4, %o7
  1489. #endif
  1490. /* NOTE: %o0 has a correct value already */
  1491. sys_sigpause: add %sp, PTREGS_OFF, %o1
  1492. call do_sigpause
  1493. add %o7, 1f-.-4, %o7
  1494. nop
  1495. #ifdef CONFIG_COMPAT
  1496. .globl sys32_sigreturn
  1497. sys32_sigreturn:
  1498. add %sp, PTREGS_OFF, %o0
  1499. call do_sigreturn32
  1500. add %o7, 1f-.-4, %o7
  1501. nop
  1502. #endif
  1503. sys_rt_sigreturn:
  1504. add %sp, PTREGS_OFF, %o0
  1505. call do_rt_sigreturn
  1506. add %o7, 1f-.-4, %o7
  1507. nop
  1508. #ifdef CONFIG_COMPAT
  1509. .globl sys32_rt_sigreturn
  1510. sys32_rt_sigreturn:
  1511. add %sp, PTREGS_OFF, %o0
  1512. call do_rt_sigreturn32
  1513. add %o7, 1f-.-4, %o7
  1514. nop
  1515. #endif
  1516. sys_ptrace: add %sp, PTREGS_OFF, %o0
  1517. call do_ptrace
  1518. add %o7, 1f-.-4, %o7
  1519. nop
  1520. .align 32
  1521. 1: ldx [%curptr + TI_FLAGS], %l5
  1522. andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1523. be,pt %icc, rtrap
  1524. clr %l6
  1525. add %sp, PTREGS_OFF, %o0
  1526. call syscall_trace
  1527. mov 1, %o1
  1528. ba,pt %xcc, rtrap
  1529. clr %l6
  1530. /* This is how fork() was meant to be done, 8 instruction entry.
  1531. *
  1532. * I questioned the following code briefly, let me clear things
  1533. * up so you must not reason on it like I did.
  1534. *
  1535. * Know the fork_kpsr etc. we use in the sparc32 port? We don't
  1536. * need it here because the only piece of window state we copy to
  1537. * the child is the CWP register. Even if the parent sleeps,
  1538. * we are safe because we stuck it into pt_regs of the parent
  1539. * so it will not change.
  1540. *
  1541. * XXX This raises the question, whether we can do the same on
  1542. * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
  1543. * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
  1544. * XXX fork_kwim in UREG_G1 (global registers are considered
  1545. * XXX volatile across a system call in the sparc ABI I think
  1546. * XXX if it isn't we can use regs->y instead, anyone who depends
  1547. * XXX upon the Y register being preserved across a fork deserves
  1548. * XXX to lose).
  1549. *
  1550. * In fact we should take advantage of that fact for other things
  1551. * during system calls...
  1552. */
  1553. .globl sys_fork, sys_vfork, sys_clone, sparc_exit
  1554. .globl ret_from_syscall
  1555. .align 32
  1556. sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
  1557. sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
  1558. or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
  1559. ba,pt %xcc, sys_clone
  1560. sys_fork: clr %o1
  1561. mov SIGCHLD, %o0
  1562. sys_clone: flushw
  1563. movrz %o1, %fp, %o1
  1564. mov 0, %o3
  1565. ba,pt %xcc, sparc_do_fork
  1566. add %sp, PTREGS_OFF, %o2
  1567. ret_from_syscall:
  1568. /* Clear current_thread_info()->new_child, and
  1569. * check performance counter stuff too.
  1570. */
  1571. stb %g0, [%g6 + TI_NEW_CHILD]
  1572. ldx [%g6 + TI_FLAGS], %l0
  1573. call schedule_tail
  1574. mov %g7, %o0
  1575. andcc %l0, _TIF_PERFCTR, %g0
  1576. be,pt %icc, 1f
  1577. nop
  1578. ldx [%g6 + TI_PCR], %o7
  1579. wr %g0, %o7, %pcr
  1580. /* Blackbird errata workaround. See commentary in
  1581. * smp.c:smp_percpu_timer_interrupt() for more
  1582. * information.
  1583. */
  1584. ba,pt %xcc, 99f
  1585. nop
  1586. .align 64
  1587. 99: wr %g0, %g0, %pic
  1588. rd %pic, %g0
  1589. 1: b,pt %xcc, ret_sys_call
  1590. ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
  1591. sparc_exit: wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate
  1592. rdpr %otherwin, %g1
  1593. rdpr %cansave, %g3
  1594. add %g3, %g1, %g3
  1595. wrpr %g3, 0x0, %cansave
  1596. wrpr %g0, 0x0, %otherwin
  1597. wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV | PSTATE_IE), %pstate
  1598. ba,pt %xcc, sys_exit
  1599. stb %g0, [%g6 + TI_WSAVED]
  1600. linux_sparc_ni_syscall:
  1601. sethi %hi(sys_ni_syscall), %l7
  1602. b,pt %xcc, 4f
  1603. or %l7, %lo(sys_ni_syscall), %l7
  1604. linux_syscall_trace32:
  1605. add %sp, PTREGS_OFF, %o0
  1606. call syscall_trace
  1607. clr %o1
  1608. srl %i0, 0, %o0
  1609. srl %i4, 0, %o4
  1610. srl %i1, 0, %o1
  1611. srl %i2, 0, %o2
  1612. b,pt %xcc, 2f
  1613. srl %i3, 0, %o3
  1614. linux_syscall_trace:
  1615. add %sp, PTREGS_OFF, %o0
  1616. call syscall_trace
  1617. clr %o1
  1618. mov %i0, %o0
  1619. mov %i1, %o1
  1620. mov %i2, %o2
  1621. mov %i3, %o3
  1622. b,pt %xcc, 2f
  1623. mov %i4, %o4
  1624. /* Linux 32-bit and SunOS system calls enter here... */
  1625. .align 32
  1626. .globl linux_sparc_syscall32
  1627. linux_sparc_syscall32:
  1628. /* Direct access to user regs, much faster. */
  1629. cmp %g1, NR_SYSCALLS ! IEU1 Group
  1630. bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
  1631. srl %i0, 0, %o0 ! IEU0
  1632. sll %g1, 2, %l4 ! IEU0 Group
  1633. srl %i4, 0, %o4 ! IEU1
  1634. lduw [%l7 + %l4], %l7 ! Load
  1635. srl %i1, 0, %o1 ! IEU0 Group
  1636. ldx [%curptr + TI_FLAGS], %l0 ! Load
  1637. srl %i5, 0, %o5 ! IEU1
  1638. srl %i2, 0, %o2 ! IEU0 Group
  1639. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1640. bne,pn %icc, linux_syscall_trace32 ! CTI
  1641. mov %i0, %l5 ! IEU1
  1642. call %l7 ! CTI Group brk forced
  1643. srl %i3, 0, %o3 ! IEU0
  1644. ba,a,pt %xcc, 3f
  1645. /* Linux native and SunOS system calls enter here... */
  1646. .align 32
  1647. .globl linux_sparc_syscall, ret_sys_call
  1648. linux_sparc_syscall:
  1649. /* Direct access to user regs, much faster. */
  1650. cmp %g1, NR_SYSCALLS ! IEU1 Group
  1651. bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
  1652. mov %i0, %o0 ! IEU0
  1653. sll %g1, 2, %l4 ! IEU0 Group
  1654. mov %i1, %o1 ! IEU1
  1655. lduw [%l7 + %l4], %l7 ! Load
  1656. 4: mov %i2, %o2 ! IEU0 Group
  1657. ldx [%curptr + TI_FLAGS], %l0 ! Load
  1658. mov %i3, %o3 ! IEU1
  1659. mov %i4, %o4 ! IEU0 Group
  1660. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
  1661. bne,pn %icc, linux_syscall_trace ! CTI Group
  1662. mov %i0, %l5 ! IEU0
  1663. 2: call %l7 ! CTI Group brk forced
  1664. mov %i5, %o5 ! IEU0
  1665. nop
  1666. 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1667. ret_sys_call:
  1668. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
  1669. ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
  1670. sra %o0, 0, %o0
  1671. mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
  1672. sllx %g2, 32, %g2
  1673. /* Check if force_successful_syscall_return()
  1674. * was invoked.
  1675. */
  1676. ldub [%curptr + TI_SYS_NOERROR], %l0
  1677. brz,pt %l0, 1f
  1678. nop
  1679. ba,pt %xcc, 80f
  1680. stb %g0, [%curptr + TI_SYS_NOERROR]
  1681. 1:
  1682. cmp %o0, -ERESTART_RESTARTBLOCK
  1683. bgeu,pn %xcc, 1f
  1684. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
  1685. 80:
  1686. /* System call success, clear Carry condition code. */
  1687. andn %g3, %g2, %g3
  1688. stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
  1689. bne,pn %icc, linux_syscall_trace2
  1690. add %l1, 0x4, %l2 ! npc = npc+4
  1691. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1692. ba,pt %xcc, rtrap_clr_l6
  1693. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1694. 1:
  1695. /* System call failure, set Carry condition code.
  1696. * Also, get abs(errno) to return to the process.
  1697. */
  1698. andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
  1699. sub %g0, %o0, %o0
  1700. or %g3, %g2, %g3
  1701. stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
  1702. mov 1, %l6
  1703. stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
  1704. bne,pn %icc, linux_syscall_trace2
  1705. add %l1, 0x4, %l2 ! npc = npc+4
  1706. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1707. b,pt %xcc, rtrap
  1708. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1709. linux_syscall_trace2:
  1710. add %sp, PTREGS_OFF, %o0
  1711. call syscall_trace
  1712. mov 1, %o1
  1713. stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
  1714. ba,pt %xcc, rtrap
  1715. stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
  1716. .align 32
  1717. .globl __flushw_user
  1718. __flushw_user:
  1719. rdpr %otherwin, %g1
  1720. brz,pn %g1, 2f
  1721. clr %g2
  1722. 1: save %sp, -128, %sp
  1723. rdpr %otherwin, %g1
  1724. brnz,pt %g1, 1b
  1725. add %g2, 1, %g2
  1726. 1: sub %g2, 1, %g2
  1727. brnz,pt %g2, 1b
  1728. restore %g0, %g0, %g0
  1729. 2: retl
  1730. nop