entry.S 43 KB

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