entry.S 43 KB

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