entry.S 41 KB

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