traps_64.c 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617
  1. /* arch/sparc64/kernel/traps.c
  2. *
  3. * Copyright (C) 1995,1997,2008,2009 David S. Miller (davem@davemloft.net)
  4. * Copyright (C) 1997,1999,2000 Jakub Jelinek (jakub@redhat.com)
  5. */
  6. /*
  7. * I like traps on v9, :))))
  8. */
  9. #include <linux/module.h>
  10. #include <linux/sched.h>
  11. #include <linux/linkage.h>
  12. #include <linux/kernel.h>
  13. #include <linux/signal.h>
  14. #include <linux/smp.h>
  15. #include <linux/mm.h>
  16. #include <linux/init.h>
  17. #include <linux/kdebug.h>
  18. #include <asm/smp.h>
  19. #include <asm/delay.h>
  20. #include <asm/system.h>
  21. #include <asm/ptrace.h>
  22. #include <asm/oplib.h>
  23. #include <asm/page.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/unistd.h>
  26. #include <asm/uaccess.h>
  27. #include <asm/fpumacro.h>
  28. #include <asm/lsu.h>
  29. #include <asm/dcu.h>
  30. #include <asm/estate.h>
  31. #include <asm/chafsr.h>
  32. #include <asm/sfafsr.h>
  33. #include <asm/psrcompat.h>
  34. #include <asm/processor.h>
  35. #include <asm/timer.h>
  36. #include <asm/head.h>
  37. #include <asm/prom.h>
  38. #include <asm/memctrl.h>
  39. #include "entry.h"
  40. #include "kstack.h"
  41. /* When an irrecoverable trap occurs at tl > 0, the trap entry
  42. * code logs the trap state registers at every level in the trap
  43. * stack. It is found at (pt_regs + sizeof(pt_regs)) and the layout
  44. * is as follows:
  45. */
  46. struct tl1_traplog {
  47. struct {
  48. unsigned long tstate;
  49. unsigned long tpc;
  50. unsigned long tnpc;
  51. unsigned long tt;
  52. } trapstack[4];
  53. unsigned long tl;
  54. };
  55. static void dump_tl1_traplog(struct tl1_traplog *p)
  56. {
  57. int i, limit;
  58. printk(KERN_EMERG "TRAPLOG: Error at trap level 0x%lx, "
  59. "dumping track stack.\n", p->tl);
  60. limit = (tlb_type == hypervisor) ? 2 : 4;
  61. for (i = 0; i < limit; i++) {
  62. printk(KERN_EMERG
  63. "TRAPLOG: Trap level %d TSTATE[%016lx] TPC[%016lx] "
  64. "TNPC[%016lx] TT[%lx]\n",
  65. i + 1,
  66. p->trapstack[i].tstate, p->trapstack[i].tpc,
  67. p->trapstack[i].tnpc, p->trapstack[i].tt);
  68. printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
  69. }
  70. }
  71. void bad_trap(struct pt_regs *regs, long lvl)
  72. {
  73. char buffer[32];
  74. siginfo_t info;
  75. if (notify_die(DIE_TRAP, "bad trap", regs,
  76. 0, lvl, SIGTRAP) == NOTIFY_STOP)
  77. return;
  78. if (lvl < 0x100) {
  79. sprintf(buffer, "Bad hw trap %lx at tl0\n", lvl);
  80. die_if_kernel(buffer, regs);
  81. }
  82. lvl -= 0x100;
  83. if (regs->tstate & TSTATE_PRIV) {
  84. sprintf(buffer, "Kernel bad sw trap %lx", lvl);
  85. die_if_kernel(buffer, regs);
  86. }
  87. if (test_thread_flag(TIF_32BIT)) {
  88. regs->tpc &= 0xffffffff;
  89. regs->tnpc &= 0xffffffff;
  90. }
  91. info.si_signo = SIGILL;
  92. info.si_errno = 0;
  93. info.si_code = ILL_ILLTRP;
  94. info.si_addr = (void __user *)regs->tpc;
  95. info.si_trapno = lvl;
  96. force_sig_info(SIGILL, &info, current);
  97. }
  98. void bad_trap_tl1(struct pt_regs *regs, long lvl)
  99. {
  100. char buffer[32];
  101. if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
  102. 0, lvl, SIGTRAP) == NOTIFY_STOP)
  103. return;
  104. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  105. sprintf (buffer, "Bad trap %lx at tl>0", lvl);
  106. die_if_kernel (buffer, regs);
  107. }
  108. #ifdef CONFIG_DEBUG_BUGVERBOSE
  109. void do_BUG(const char *file, int line)
  110. {
  111. bust_spinlocks(1);
  112. printk("kernel BUG at %s:%d!\n", file, line);
  113. }
  114. EXPORT_SYMBOL(do_BUG);
  115. #endif
  116. static DEFINE_SPINLOCK(dimm_handler_lock);
  117. static dimm_printer_t dimm_handler;
  118. static int sprintf_dimm(int synd_code, unsigned long paddr, char *buf, int buflen)
  119. {
  120. unsigned long flags;
  121. int ret = -ENODEV;
  122. spin_lock_irqsave(&dimm_handler_lock, flags);
  123. if (dimm_handler) {
  124. ret = dimm_handler(synd_code, paddr, buf, buflen);
  125. } else if (tlb_type == spitfire) {
  126. if (prom_getunumber(synd_code, paddr, buf, buflen) == -1)
  127. ret = -EINVAL;
  128. else
  129. ret = 0;
  130. } else
  131. ret = -ENODEV;
  132. spin_unlock_irqrestore(&dimm_handler_lock, flags);
  133. return ret;
  134. }
  135. int register_dimm_printer(dimm_printer_t func)
  136. {
  137. unsigned long flags;
  138. int ret = 0;
  139. spin_lock_irqsave(&dimm_handler_lock, flags);
  140. if (!dimm_handler)
  141. dimm_handler = func;
  142. else
  143. ret = -EEXIST;
  144. spin_unlock_irqrestore(&dimm_handler_lock, flags);
  145. return ret;
  146. }
  147. EXPORT_SYMBOL_GPL(register_dimm_printer);
  148. void unregister_dimm_printer(dimm_printer_t func)
  149. {
  150. unsigned long flags;
  151. spin_lock_irqsave(&dimm_handler_lock, flags);
  152. if (dimm_handler == func)
  153. dimm_handler = NULL;
  154. spin_unlock_irqrestore(&dimm_handler_lock, flags);
  155. }
  156. EXPORT_SYMBOL_GPL(unregister_dimm_printer);
  157. void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar)
  158. {
  159. siginfo_t info;
  160. if (notify_die(DIE_TRAP, "instruction access exception", regs,
  161. 0, 0x8, SIGTRAP) == NOTIFY_STOP)
  162. return;
  163. if (regs->tstate & TSTATE_PRIV) {
  164. printk("spitfire_insn_access_exception: SFSR[%016lx] "
  165. "SFAR[%016lx], going.\n", sfsr, sfar);
  166. die_if_kernel("Iax", regs);
  167. }
  168. if (test_thread_flag(TIF_32BIT)) {
  169. regs->tpc &= 0xffffffff;
  170. regs->tnpc &= 0xffffffff;
  171. }
  172. info.si_signo = SIGSEGV;
  173. info.si_errno = 0;
  174. info.si_code = SEGV_MAPERR;
  175. info.si_addr = (void __user *)regs->tpc;
  176. info.si_trapno = 0;
  177. force_sig_info(SIGSEGV, &info, current);
  178. }
  179. void spitfire_insn_access_exception_tl1(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar)
  180. {
  181. if (notify_die(DIE_TRAP_TL1, "instruction access exception tl1", regs,
  182. 0, 0x8, SIGTRAP) == NOTIFY_STOP)
  183. return;
  184. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  185. spitfire_insn_access_exception(regs, sfsr, sfar);
  186. }
  187. void sun4v_insn_access_exception(struct pt_regs *regs, unsigned long addr, unsigned long type_ctx)
  188. {
  189. unsigned short type = (type_ctx >> 16);
  190. unsigned short ctx = (type_ctx & 0xffff);
  191. siginfo_t info;
  192. if (notify_die(DIE_TRAP, "instruction access exception", regs,
  193. 0, 0x8, SIGTRAP) == NOTIFY_STOP)
  194. return;
  195. if (regs->tstate & TSTATE_PRIV) {
  196. printk("sun4v_insn_access_exception: ADDR[%016lx] "
  197. "CTX[%04x] TYPE[%04x], going.\n",
  198. addr, ctx, type);
  199. die_if_kernel("Iax", regs);
  200. }
  201. if (test_thread_flag(TIF_32BIT)) {
  202. regs->tpc &= 0xffffffff;
  203. regs->tnpc &= 0xffffffff;
  204. }
  205. info.si_signo = SIGSEGV;
  206. info.si_errno = 0;
  207. info.si_code = SEGV_MAPERR;
  208. info.si_addr = (void __user *) addr;
  209. info.si_trapno = 0;
  210. force_sig_info(SIGSEGV, &info, current);
  211. }
  212. void sun4v_insn_access_exception_tl1(struct pt_regs *regs, unsigned long addr, unsigned long type_ctx)
  213. {
  214. if (notify_die(DIE_TRAP_TL1, "instruction access exception tl1", regs,
  215. 0, 0x8, SIGTRAP) == NOTIFY_STOP)
  216. return;
  217. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  218. sun4v_insn_access_exception(regs, addr, type_ctx);
  219. }
  220. void spitfire_data_access_exception(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar)
  221. {
  222. siginfo_t info;
  223. if (notify_die(DIE_TRAP, "data access exception", regs,
  224. 0, 0x30, SIGTRAP) == NOTIFY_STOP)
  225. return;
  226. if (regs->tstate & TSTATE_PRIV) {
  227. /* Test if this comes from uaccess places. */
  228. const struct exception_table_entry *entry;
  229. entry = search_exception_tables(regs->tpc);
  230. if (entry) {
  231. /* Ouch, somebody is trying VM hole tricks on us... */
  232. #ifdef DEBUG_EXCEPTIONS
  233. printk("Exception: PC<%016lx> faddr<UNKNOWN>\n", regs->tpc);
  234. printk("EX_TABLE: insn<%016lx> fixup<%016lx>\n",
  235. regs->tpc, entry->fixup);
  236. #endif
  237. regs->tpc = entry->fixup;
  238. regs->tnpc = regs->tpc + 4;
  239. return;
  240. }
  241. /* Shit... */
  242. printk("spitfire_data_access_exception: SFSR[%016lx] "
  243. "SFAR[%016lx], going.\n", sfsr, sfar);
  244. die_if_kernel("Dax", regs);
  245. }
  246. info.si_signo = SIGSEGV;
  247. info.si_errno = 0;
  248. info.si_code = SEGV_MAPERR;
  249. info.si_addr = (void __user *)sfar;
  250. info.si_trapno = 0;
  251. force_sig_info(SIGSEGV, &info, current);
  252. }
  253. void spitfire_data_access_exception_tl1(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar)
  254. {
  255. if (notify_die(DIE_TRAP_TL1, "data access exception tl1", regs,
  256. 0, 0x30, SIGTRAP) == NOTIFY_STOP)
  257. return;
  258. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  259. spitfire_data_access_exception(regs, sfsr, sfar);
  260. }
  261. void sun4v_data_access_exception(struct pt_regs *regs, unsigned long addr, unsigned long type_ctx)
  262. {
  263. unsigned short type = (type_ctx >> 16);
  264. unsigned short ctx = (type_ctx & 0xffff);
  265. siginfo_t info;
  266. if (notify_die(DIE_TRAP, "data access exception", regs,
  267. 0, 0x8, SIGTRAP) == NOTIFY_STOP)
  268. return;
  269. if (regs->tstate & TSTATE_PRIV) {
  270. /* Test if this comes from uaccess places. */
  271. const struct exception_table_entry *entry;
  272. entry = search_exception_tables(regs->tpc);
  273. if (entry) {
  274. /* Ouch, somebody is trying VM hole tricks on us... */
  275. #ifdef DEBUG_EXCEPTIONS
  276. printk("Exception: PC<%016lx> faddr<UNKNOWN>\n", regs->tpc);
  277. printk("EX_TABLE: insn<%016lx> fixup<%016lx>\n",
  278. regs->tpc, entry->fixup);
  279. #endif
  280. regs->tpc = entry->fixup;
  281. regs->tnpc = regs->tpc + 4;
  282. return;
  283. }
  284. printk("sun4v_data_access_exception: ADDR[%016lx] "
  285. "CTX[%04x] TYPE[%04x], going.\n",
  286. addr, ctx, type);
  287. die_if_kernel("Dax", regs);
  288. }
  289. if (test_thread_flag(TIF_32BIT)) {
  290. regs->tpc &= 0xffffffff;
  291. regs->tnpc &= 0xffffffff;
  292. }
  293. info.si_signo = SIGSEGV;
  294. info.si_errno = 0;
  295. info.si_code = SEGV_MAPERR;
  296. info.si_addr = (void __user *) addr;
  297. info.si_trapno = 0;
  298. force_sig_info(SIGSEGV, &info, current);
  299. }
  300. void sun4v_data_access_exception_tl1(struct pt_regs *regs, unsigned long addr, unsigned long type_ctx)
  301. {
  302. if (notify_die(DIE_TRAP_TL1, "data access exception tl1", regs,
  303. 0, 0x8, SIGTRAP) == NOTIFY_STOP)
  304. return;
  305. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  306. sun4v_data_access_exception(regs, addr, type_ctx);
  307. }
  308. #ifdef CONFIG_PCI
  309. #include "pci_impl.h"
  310. #endif
  311. /* When access exceptions happen, we must do this. */
  312. static void spitfire_clean_and_reenable_l1_caches(void)
  313. {
  314. unsigned long va;
  315. if (tlb_type != spitfire)
  316. BUG();
  317. /* Clean 'em. */
  318. for (va = 0; va < (PAGE_SIZE << 1); va += 32) {
  319. spitfire_put_icache_tag(va, 0x0);
  320. spitfire_put_dcache_tag(va, 0x0);
  321. }
  322. /* Re-enable in LSU. */
  323. __asm__ __volatile__("flush %%g6\n\t"
  324. "membar #Sync\n\t"
  325. "stxa %0, [%%g0] %1\n\t"
  326. "membar #Sync"
  327. : /* no outputs */
  328. : "r" (LSU_CONTROL_IC | LSU_CONTROL_DC |
  329. LSU_CONTROL_IM | LSU_CONTROL_DM),
  330. "i" (ASI_LSU_CONTROL)
  331. : "memory");
  332. }
  333. static void spitfire_enable_estate_errors(void)
  334. {
  335. __asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
  336. "membar #Sync"
  337. : /* no outputs */
  338. : "r" (ESTATE_ERR_ALL),
  339. "i" (ASI_ESTATE_ERROR_EN));
  340. }
  341. static char ecc_syndrome_table[] = {
  342. 0x4c, 0x40, 0x41, 0x48, 0x42, 0x48, 0x48, 0x49,
  343. 0x43, 0x48, 0x48, 0x49, 0x48, 0x49, 0x49, 0x4a,
  344. 0x44, 0x48, 0x48, 0x20, 0x48, 0x39, 0x4b, 0x48,
  345. 0x48, 0x25, 0x31, 0x48, 0x28, 0x48, 0x48, 0x2c,
  346. 0x45, 0x48, 0x48, 0x21, 0x48, 0x3d, 0x04, 0x48,
  347. 0x48, 0x4b, 0x35, 0x48, 0x2d, 0x48, 0x48, 0x29,
  348. 0x48, 0x00, 0x01, 0x48, 0x0a, 0x48, 0x48, 0x4b,
  349. 0x0f, 0x48, 0x48, 0x4b, 0x48, 0x49, 0x49, 0x48,
  350. 0x46, 0x48, 0x48, 0x2a, 0x48, 0x3b, 0x27, 0x48,
  351. 0x48, 0x4b, 0x33, 0x48, 0x22, 0x48, 0x48, 0x2e,
  352. 0x48, 0x19, 0x1d, 0x48, 0x1b, 0x4a, 0x48, 0x4b,
  353. 0x1f, 0x48, 0x4a, 0x4b, 0x48, 0x4b, 0x4b, 0x48,
  354. 0x48, 0x4b, 0x24, 0x48, 0x07, 0x48, 0x48, 0x36,
  355. 0x4b, 0x48, 0x48, 0x3e, 0x48, 0x30, 0x38, 0x48,
  356. 0x49, 0x48, 0x48, 0x4b, 0x48, 0x4b, 0x16, 0x48,
  357. 0x48, 0x12, 0x4b, 0x48, 0x49, 0x48, 0x48, 0x4b,
  358. 0x47, 0x48, 0x48, 0x2f, 0x48, 0x3f, 0x4b, 0x48,
  359. 0x48, 0x06, 0x37, 0x48, 0x23, 0x48, 0x48, 0x2b,
  360. 0x48, 0x05, 0x4b, 0x48, 0x4b, 0x48, 0x48, 0x32,
  361. 0x26, 0x48, 0x48, 0x3a, 0x48, 0x34, 0x3c, 0x48,
  362. 0x48, 0x11, 0x15, 0x48, 0x13, 0x4a, 0x48, 0x4b,
  363. 0x17, 0x48, 0x4a, 0x4b, 0x48, 0x4b, 0x4b, 0x48,
  364. 0x49, 0x48, 0x48, 0x4b, 0x48, 0x4b, 0x1e, 0x48,
  365. 0x48, 0x1a, 0x4b, 0x48, 0x49, 0x48, 0x48, 0x4b,
  366. 0x48, 0x08, 0x0d, 0x48, 0x02, 0x48, 0x48, 0x49,
  367. 0x03, 0x48, 0x48, 0x49, 0x48, 0x4b, 0x4b, 0x48,
  368. 0x49, 0x48, 0x48, 0x49, 0x48, 0x4b, 0x10, 0x48,
  369. 0x48, 0x14, 0x4b, 0x48, 0x4b, 0x48, 0x48, 0x4b,
  370. 0x49, 0x48, 0x48, 0x49, 0x48, 0x4b, 0x18, 0x48,
  371. 0x48, 0x1c, 0x4b, 0x48, 0x4b, 0x48, 0x48, 0x4b,
  372. 0x4a, 0x0c, 0x09, 0x48, 0x0e, 0x48, 0x48, 0x4b,
  373. 0x0b, 0x48, 0x48, 0x4b, 0x48, 0x4b, 0x4b, 0x4a
  374. };
  375. static char *syndrome_unknown = "<Unknown>";
  376. static void spitfire_log_udb_syndrome(unsigned long afar, unsigned long udbh, unsigned long udbl, unsigned long bit)
  377. {
  378. unsigned short scode;
  379. char memmod_str[64], *p;
  380. if (udbl & bit) {
  381. scode = ecc_syndrome_table[udbl & 0xff];
  382. if (sprintf_dimm(scode, afar, memmod_str, sizeof(memmod_str)) < 0)
  383. p = syndrome_unknown;
  384. else
  385. p = memmod_str;
  386. printk(KERN_WARNING "CPU[%d]: UDBL Syndrome[%x] "
  387. "Memory Module \"%s\"\n",
  388. smp_processor_id(), scode, p);
  389. }
  390. if (udbh & bit) {
  391. scode = ecc_syndrome_table[udbh & 0xff];
  392. if (sprintf_dimm(scode, afar, memmod_str, sizeof(memmod_str)) < 0)
  393. p = syndrome_unknown;
  394. else
  395. p = memmod_str;
  396. printk(KERN_WARNING "CPU[%d]: UDBH Syndrome[%x] "
  397. "Memory Module \"%s\"\n",
  398. smp_processor_id(), scode, p);
  399. }
  400. }
  401. static void spitfire_cee_log(unsigned long afsr, unsigned long afar, unsigned long udbh, unsigned long udbl, int tl1, struct pt_regs *regs)
  402. {
  403. printk(KERN_WARNING "CPU[%d]: Correctable ECC Error "
  404. "AFSR[%lx] AFAR[%016lx] UDBL[%lx] UDBH[%lx] TL>1[%d]\n",
  405. smp_processor_id(), afsr, afar, udbl, udbh, tl1);
  406. spitfire_log_udb_syndrome(afar, udbh, udbl, UDBE_CE);
  407. /* We always log it, even if someone is listening for this
  408. * trap.
  409. */
  410. notify_die(DIE_TRAP, "Correctable ECC Error", regs,
  411. 0, TRAP_TYPE_CEE, SIGTRAP);
  412. /* The Correctable ECC Error trap does not disable I/D caches. So
  413. * we only have to restore the ESTATE Error Enable register.
  414. */
  415. spitfire_enable_estate_errors();
  416. }
  417. static void spitfire_ue_log(unsigned long afsr, unsigned long afar, unsigned long udbh, unsigned long udbl, unsigned long tt, int tl1, struct pt_regs *regs)
  418. {
  419. siginfo_t info;
  420. printk(KERN_WARNING "CPU[%d]: Uncorrectable Error AFSR[%lx] "
  421. "AFAR[%lx] UDBL[%lx] UDBH[%ld] TT[%lx] TL>1[%d]\n",
  422. smp_processor_id(), afsr, afar, udbl, udbh, tt, tl1);
  423. /* XXX add more human friendly logging of the error status
  424. * XXX as is implemented for cheetah
  425. */
  426. spitfire_log_udb_syndrome(afar, udbh, udbl, UDBE_UE);
  427. /* We always log it, even if someone is listening for this
  428. * trap.
  429. */
  430. notify_die(DIE_TRAP, "Uncorrectable Error", regs,
  431. 0, tt, SIGTRAP);
  432. if (regs->tstate & TSTATE_PRIV) {
  433. if (tl1)
  434. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  435. die_if_kernel("UE", regs);
  436. }
  437. /* XXX need more intelligent processing here, such as is implemented
  438. * XXX for cheetah errors, in fact if the E-cache still holds the
  439. * XXX line with bad parity this will loop
  440. */
  441. spitfire_clean_and_reenable_l1_caches();
  442. spitfire_enable_estate_errors();
  443. if (test_thread_flag(TIF_32BIT)) {
  444. regs->tpc &= 0xffffffff;
  445. regs->tnpc &= 0xffffffff;
  446. }
  447. info.si_signo = SIGBUS;
  448. info.si_errno = 0;
  449. info.si_code = BUS_OBJERR;
  450. info.si_addr = (void *)0;
  451. info.si_trapno = 0;
  452. force_sig_info(SIGBUS, &info, current);
  453. }
  454. void spitfire_access_error(struct pt_regs *regs, unsigned long status_encoded, unsigned long afar)
  455. {
  456. unsigned long afsr, tt, udbh, udbl;
  457. int tl1;
  458. afsr = (status_encoded & SFSTAT_AFSR_MASK) >> SFSTAT_AFSR_SHIFT;
  459. tt = (status_encoded & SFSTAT_TRAP_TYPE) >> SFSTAT_TRAP_TYPE_SHIFT;
  460. tl1 = (status_encoded & SFSTAT_TL_GT_ONE) ? 1 : 0;
  461. udbl = (status_encoded & SFSTAT_UDBL_MASK) >> SFSTAT_UDBL_SHIFT;
  462. udbh = (status_encoded & SFSTAT_UDBH_MASK) >> SFSTAT_UDBH_SHIFT;
  463. #ifdef CONFIG_PCI
  464. if (tt == TRAP_TYPE_DAE &&
  465. pci_poke_in_progress && pci_poke_cpu == smp_processor_id()) {
  466. spitfire_clean_and_reenable_l1_caches();
  467. spitfire_enable_estate_errors();
  468. pci_poke_faulted = 1;
  469. regs->tnpc = regs->tpc + 4;
  470. return;
  471. }
  472. #endif
  473. if (afsr & SFAFSR_UE)
  474. spitfire_ue_log(afsr, afar, udbh, udbl, tt, tl1, regs);
  475. if (tt == TRAP_TYPE_CEE) {
  476. /* Handle the case where we took a CEE trap, but ACK'd
  477. * only the UE state in the UDB error registers.
  478. */
  479. if (afsr & SFAFSR_UE) {
  480. if (udbh & UDBE_CE) {
  481. __asm__ __volatile__(
  482. "stxa %0, [%1] %2\n\t"
  483. "membar #Sync"
  484. : /* no outputs */
  485. : "r" (udbh & UDBE_CE),
  486. "r" (0x0), "i" (ASI_UDB_ERROR_W));
  487. }
  488. if (udbl & UDBE_CE) {
  489. __asm__ __volatile__(
  490. "stxa %0, [%1] %2\n\t"
  491. "membar #Sync"
  492. : /* no outputs */
  493. : "r" (udbl & UDBE_CE),
  494. "r" (0x18), "i" (ASI_UDB_ERROR_W));
  495. }
  496. }
  497. spitfire_cee_log(afsr, afar, udbh, udbl, tl1, regs);
  498. }
  499. }
  500. int cheetah_pcache_forced_on;
  501. void cheetah_enable_pcache(void)
  502. {
  503. unsigned long dcr;
  504. printk("CHEETAH: Enabling P-Cache on cpu %d.\n",
  505. smp_processor_id());
  506. __asm__ __volatile__("ldxa [%%g0] %1, %0"
  507. : "=r" (dcr)
  508. : "i" (ASI_DCU_CONTROL_REG));
  509. dcr |= (DCU_PE | DCU_HPE | DCU_SPE | DCU_SL);
  510. __asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
  511. "membar #Sync"
  512. : /* no outputs */
  513. : "r" (dcr), "i" (ASI_DCU_CONTROL_REG));
  514. }
  515. /* Cheetah error trap handling. */
  516. static unsigned long ecache_flush_physbase;
  517. static unsigned long ecache_flush_linesize;
  518. static unsigned long ecache_flush_size;
  519. /* This table is ordered in priority of errors and matches the
  520. * AFAR overwrite policy as well.
  521. */
  522. struct afsr_error_table {
  523. unsigned long mask;
  524. const char *name;
  525. };
  526. static const char CHAFSR_PERR_msg[] =
  527. "System interface protocol error";
  528. static const char CHAFSR_IERR_msg[] =
  529. "Internal processor error";
  530. static const char CHAFSR_ISAP_msg[] =
  531. "System request parity error on incoming addresss";
  532. static const char CHAFSR_UCU_msg[] =
  533. "Uncorrectable E-cache ECC error for ifetch/data";
  534. static const char CHAFSR_UCC_msg[] =
  535. "SW Correctable E-cache ECC error for ifetch/data";
  536. static const char CHAFSR_UE_msg[] =
  537. "Uncorrectable system bus data ECC error for read";
  538. static const char CHAFSR_EDU_msg[] =
  539. "Uncorrectable E-cache ECC error for stmerge/blkld";
  540. static const char CHAFSR_EMU_msg[] =
  541. "Uncorrectable system bus MTAG error";
  542. static const char CHAFSR_WDU_msg[] =
  543. "Uncorrectable E-cache ECC error for writeback";
  544. static const char CHAFSR_CPU_msg[] =
  545. "Uncorrectable ECC error for copyout";
  546. static const char CHAFSR_CE_msg[] =
  547. "HW corrected system bus data ECC error for read";
  548. static const char CHAFSR_EDC_msg[] =
  549. "HW corrected E-cache ECC error for stmerge/blkld";
  550. static const char CHAFSR_EMC_msg[] =
  551. "HW corrected system bus MTAG ECC error";
  552. static const char CHAFSR_WDC_msg[] =
  553. "HW corrected E-cache ECC error for writeback";
  554. static const char CHAFSR_CPC_msg[] =
  555. "HW corrected ECC error for copyout";
  556. static const char CHAFSR_TO_msg[] =
  557. "Unmapped error from system bus";
  558. static const char CHAFSR_BERR_msg[] =
  559. "Bus error response from system bus";
  560. static const char CHAFSR_IVC_msg[] =
  561. "HW corrected system bus data ECC error for ivec read";
  562. static const char CHAFSR_IVU_msg[] =
  563. "Uncorrectable system bus data ECC error for ivec read";
  564. static struct afsr_error_table __cheetah_error_table[] = {
  565. { CHAFSR_PERR, CHAFSR_PERR_msg },
  566. { CHAFSR_IERR, CHAFSR_IERR_msg },
  567. { CHAFSR_ISAP, CHAFSR_ISAP_msg },
  568. { CHAFSR_UCU, CHAFSR_UCU_msg },
  569. { CHAFSR_UCC, CHAFSR_UCC_msg },
  570. { CHAFSR_UE, CHAFSR_UE_msg },
  571. { CHAFSR_EDU, CHAFSR_EDU_msg },
  572. { CHAFSR_EMU, CHAFSR_EMU_msg },
  573. { CHAFSR_WDU, CHAFSR_WDU_msg },
  574. { CHAFSR_CPU, CHAFSR_CPU_msg },
  575. { CHAFSR_CE, CHAFSR_CE_msg },
  576. { CHAFSR_EDC, CHAFSR_EDC_msg },
  577. { CHAFSR_EMC, CHAFSR_EMC_msg },
  578. { CHAFSR_WDC, CHAFSR_WDC_msg },
  579. { CHAFSR_CPC, CHAFSR_CPC_msg },
  580. { CHAFSR_TO, CHAFSR_TO_msg },
  581. { CHAFSR_BERR, CHAFSR_BERR_msg },
  582. /* These two do not update the AFAR. */
  583. { CHAFSR_IVC, CHAFSR_IVC_msg },
  584. { CHAFSR_IVU, CHAFSR_IVU_msg },
  585. { 0, NULL },
  586. };
  587. static const char CHPAFSR_DTO_msg[] =
  588. "System bus unmapped error for prefetch/storequeue-read";
  589. static const char CHPAFSR_DBERR_msg[] =
  590. "System bus error for prefetch/storequeue-read";
  591. static const char CHPAFSR_THCE_msg[] =
  592. "Hardware corrected E-cache Tag ECC error";
  593. static const char CHPAFSR_TSCE_msg[] =
  594. "SW handled correctable E-cache Tag ECC error";
  595. static const char CHPAFSR_TUE_msg[] =
  596. "Uncorrectable E-cache Tag ECC error";
  597. static const char CHPAFSR_DUE_msg[] =
  598. "System bus uncorrectable data ECC error due to prefetch/store-fill";
  599. static struct afsr_error_table __cheetah_plus_error_table[] = {
  600. { CHAFSR_PERR, CHAFSR_PERR_msg },
  601. { CHAFSR_IERR, CHAFSR_IERR_msg },
  602. { CHAFSR_ISAP, CHAFSR_ISAP_msg },
  603. { CHAFSR_UCU, CHAFSR_UCU_msg },
  604. { CHAFSR_UCC, CHAFSR_UCC_msg },
  605. { CHAFSR_UE, CHAFSR_UE_msg },
  606. { CHAFSR_EDU, CHAFSR_EDU_msg },
  607. { CHAFSR_EMU, CHAFSR_EMU_msg },
  608. { CHAFSR_WDU, CHAFSR_WDU_msg },
  609. { CHAFSR_CPU, CHAFSR_CPU_msg },
  610. { CHAFSR_CE, CHAFSR_CE_msg },
  611. { CHAFSR_EDC, CHAFSR_EDC_msg },
  612. { CHAFSR_EMC, CHAFSR_EMC_msg },
  613. { CHAFSR_WDC, CHAFSR_WDC_msg },
  614. { CHAFSR_CPC, CHAFSR_CPC_msg },
  615. { CHAFSR_TO, CHAFSR_TO_msg },
  616. { CHAFSR_BERR, CHAFSR_BERR_msg },
  617. { CHPAFSR_DTO, CHPAFSR_DTO_msg },
  618. { CHPAFSR_DBERR, CHPAFSR_DBERR_msg },
  619. { CHPAFSR_THCE, CHPAFSR_THCE_msg },
  620. { CHPAFSR_TSCE, CHPAFSR_TSCE_msg },
  621. { CHPAFSR_TUE, CHPAFSR_TUE_msg },
  622. { CHPAFSR_DUE, CHPAFSR_DUE_msg },
  623. /* These two do not update the AFAR. */
  624. { CHAFSR_IVC, CHAFSR_IVC_msg },
  625. { CHAFSR_IVU, CHAFSR_IVU_msg },
  626. { 0, NULL },
  627. };
  628. static const char JPAFSR_JETO_msg[] =
  629. "System interface protocol error, hw timeout caused";
  630. static const char JPAFSR_SCE_msg[] =
  631. "Parity error on system snoop results";
  632. static const char JPAFSR_JEIC_msg[] =
  633. "System interface protocol error, illegal command detected";
  634. static const char JPAFSR_JEIT_msg[] =
  635. "System interface protocol error, illegal ADTYPE detected";
  636. static const char JPAFSR_OM_msg[] =
  637. "Out of range memory error has occurred";
  638. static const char JPAFSR_ETP_msg[] =
  639. "Parity error on L2 cache tag SRAM";
  640. static const char JPAFSR_UMS_msg[] =
  641. "Error due to unsupported store";
  642. static const char JPAFSR_RUE_msg[] =
  643. "Uncorrectable ECC error from remote cache/memory";
  644. static const char JPAFSR_RCE_msg[] =
  645. "Correctable ECC error from remote cache/memory";
  646. static const char JPAFSR_BP_msg[] =
  647. "JBUS parity error on returned read data";
  648. static const char JPAFSR_WBP_msg[] =
  649. "JBUS parity error on data for writeback or block store";
  650. static const char JPAFSR_FRC_msg[] =
  651. "Foreign read to DRAM incurring correctable ECC error";
  652. static const char JPAFSR_FRU_msg[] =
  653. "Foreign read to DRAM incurring uncorrectable ECC error";
  654. static struct afsr_error_table __jalapeno_error_table[] = {
  655. { JPAFSR_JETO, JPAFSR_JETO_msg },
  656. { JPAFSR_SCE, JPAFSR_SCE_msg },
  657. { JPAFSR_JEIC, JPAFSR_JEIC_msg },
  658. { JPAFSR_JEIT, JPAFSR_JEIT_msg },
  659. { CHAFSR_PERR, CHAFSR_PERR_msg },
  660. { CHAFSR_IERR, CHAFSR_IERR_msg },
  661. { CHAFSR_ISAP, CHAFSR_ISAP_msg },
  662. { CHAFSR_UCU, CHAFSR_UCU_msg },
  663. { CHAFSR_UCC, CHAFSR_UCC_msg },
  664. { CHAFSR_UE, CHAFSR_UE_msg },
  665. { CHAFSR_EDU, CHAFSR_EDU_msg },
  666. { JPAFSR_OM, JPAFSR_OM_msg },
  667. { CHAFSR_WDU, CHAFSR_WDU_msg },
  668. { CHAFSR_CPU, CHAFSR_CPU_msg },
  669. { CHAFSR_CE, CHAFSR_CE_msg },
  670. { CHAFSR_EDC, CHAFSR_EDC_msg },
  671. { JPAFSR_ETP, JPAFSR_ETP_msg },
  672. { CHAFSR_WDC, CHAFSR_WDC_msg },
  673. { CHAFSR_CPC, CHAFSR_CPC_msg },
  674. { CHAFSR_TO, CHAFSR_TO_msg },
  675. { CHAFSR_BERR, CHAFSR_BERR_msg },
  676. { JPAFSR_UMS, JPAFSR_UMS_msg },
  677. { JPAFSR_RUE, JPAFSR_RUE_msg },
  678. { JPAFSR_RCE, JPAFSR_RCE_msg },
  679. { JPAFSR_BP, JPAFSR_BP_msg },
  680. { JPAFSR_WBP, JPAFSR_WBP_msg },
  681. { JPAFSR_FRC, JPAFSR_FRC_msg },
  682. { JPAFSR_FRU, JPAFSR_FRU_msg },
  683. /* These two do not update the AFAR. */
  684. { CHAFSR_IVU, CHAFSR_IVU_msg },
  685. { 0, NULL },
  686. };
  687. static struct afsr_error_table *cheetah_error_table;
  688. static unsigned long cheetah_afsr_errors;
  689. struct cheetah_err_info *cheetah_error_log;
  690. static inline struct cheetah_err_info *cheetah_get_error_log(unsigned long afsr)
  691. {
  692. struct cheetah_err_info *p;
  693. int cpu = smp_processor_id();
  694. if (!cheetah_error_log)
  695. return NULL;
  696. p = cheetah_error_log + (cpu * 2);
  697. if ((afsr & CHAFSR_TL1) != 0UL)
  698. p++;
  699. return p;
  700. }
  701. extern unsigned int tl0_icpe[], tl1_icpe[];
  702. extern unsigned int tl0_dcpe[], tl1_dcpe[];
  703. extern unsigned int tl0_fecc[], tl1_fecc[];
  704. extern unsigned int tl0_cee[], tl1_cee[];
  705. extern unsigned int tl0_iae[], tl1_iae[];
  706. extern unsigned int tl0_dae[], tl1_dae[];
  707. extern unsigned int cheetah_plus_icpe_trap_vector[], cheetah_plus_icpe_trap_vector_tl1[];
  708. extern unsigned int cheetah_plus_dcpe_trap_vector[], cheetah_plus_dcpe_trap_vector_tl1[];
  709. extern unsigned int cheetah_fecc_trap_vector[], cheetah_fecc_trap_vector_tl1[];
  710. extern unsigned int cheetah_cee_trap_vector[], cheetah_cee_trap_vector_tl1[];
  711. extern unsigned int cheetah_deferred_trap_vector[], cheetah_deferred_trap_vector_tl1[];
  712. void __init cheetah_ecache_flush_init(void)
  713. {
  714. unsigned long largest_size, smallest_linesize, order, ver;
  715. int i, sz;
  716. /* Scan all cpu device tree nodes, note two values:
  717. * 1) largest E-cache size
  718. * 2) smallest E-cache line size
  719. */
  720. largest_size = 0UL;
  721. smallest_linesize = ~0UL;
  722. for (i = 0; i < NR_CPUS; i++) {
  723. unsigned long val;
  724. val = cpu_data(i).ecache_size;
  725. if (!val)
  726. continue;
  727. if (val > largest_size)
  728. largest_size = val;
  729. val = cpu_data(i).ecache_line_size;
  730. if (val < smallest_linesize)
  731. smallest_linesize = val;
  732. }
  733. if (largest_size == 0UL || smallest_linesize == ~0UL) {
  734. prom_printf("cheetah_ecache_flush_init: Cannot probe cpu E-cache "
  735. "parameters.\n");
  736. prom_halt();
  737. }
  738. ecache_flush_size = (2 * largest_size);
  739. ecache_flush_linesize = smallest_linesize;
  740. ecache_flush_physbase = find_ecache_flush_span(ecache_flush_size);
  741. if (ecache_flush_physbase == ~0UL) {
  742. prom_printf("cheetah_ecache_flush_init: Cannot find %d byte "
  743. "contiguous physical memory.\n",
  744. ecache_flush_size);
  745. prom_halt();
  746. }
  747. /* Now allocate error trap reporting scoreboard. */
  748. sz = NR_CPUS * (2 * sizeof(struct cheetah_err_info));
  749. for (order = 0; order < MAX_ORDER; order++) {
  750. if ((PAGE_SIZE << order) >= sz)
  751. break;
  752. }
  753. cheetah_error_log = (struct cheetah_err_info *)
  754. __get_free_pages(GFP_KERNEL, order);
  755. if (!cheetah_error_log) {
  756. prom_printf("cheetah_ecache_flush_init: Failed to allocate "
  757. "error logging scoreboard (%d bytes).\n", sz);
  758. prom_halt();
  759. }
  760. memset(cheetah_error_log, 0, PAGE_SIZE << order);
  761. /* Mark all AFSRs as invalid so that the trap handler will
  762. * log new new information there.
  763. */
  764. for (i = 0; i < 2 * NR_CPUS; i++)
  765. cheetah_error_log[i].afsr = CHAFSR_INVALID;
  766. __asm__ ("rdpr %%ver, %0" : "=r" (ver));
  767. if ((ver >> 32) == __JALAPENO_ID ||
  768. (ver >> 32) == __SERRANO_ID) {
  769. cheetah_error_table = &__jalapeno_error_table[0];
  770. cheetah_afsr_errors = JPAFSR_ERRORS;
  771. } else if ((ver >> 32) == 0x003e0015) {
  772. cheetah_error_table = &__cheetah_plus_error_table[0];
  773. cheetah_afsr_errors = CHPAFSR_ERRORS;
  774. } else {
  775. cheetah_error_table = &__cheetah_error_table[0];
  776. cheetah_afsr_errors = CHAFSR_ERRORS;
  777. }
  778. /* Now patch trap tables. */
  779. memcpy(tl0_fecc, cheetah_fecc_trap_vector, (8 * 4));
  780. memcpy(tl1_fecc, cheetah_fecc_trap_vector_tl1, (8 * 4));
  781. memcpy(tl0_cee, cheetah_cee_trap_vector, (8 * 4));
  782. memcpy(tl1_cee, cheetah_cee_trap_vector_tl1, (8 * 4));
  783. memcpy(tl0_iae, cheetah_deferred_trap_vector, (8 * 4));
  784. memcpy(tl1_iae, cheetah_deferred_trap_vector_tl1, (8 * 4));
  785. memcpy(tl0_dae, cheetah_deferred_trap_vector, (8 * 4));
  786. memcpy(tl1_dae, cheetah_deferred_trap_vector_tl1, (8 * 4));
  787. if (tlb_type == cheetah_plus) {
  788. memcpy(tl0_dcpe, cheetah_plus_dcpe_trap_vector, (8 * 4));
  789. memcpy(tl1_dcpe, cheetah_plus_dcpe_trap_vector_tl1, (8 * 4));
  790. memcpy(tl0_icpe, cheetah_plus_icpe_trap_vector, (8 * 4));
  791. memcpy(tl1_icpe, cheetah_plus_icpe_trap_vector_tl1, (8 * 4));
  792. }
  793. flushi(PAGE_OFFSET);
  794. }
  795. static void cheetah_flush_ecache(void)
  796. {
  797. unsigned long flush_base = ecache_flush_physbase;
  798. unsigned long flush_linesize = ecache_flush_linesize;
  799. unsigned long flush_size = ecache_flush_size;
  800. __asm__ __volatile__("1: subcc %0, %4, %0\n\t"
  801. " bne,pt %%xcc, 1b\n\t"
  802. " ldxa [%2 + %0] %3, %%g0\n\t"
  803. : "=&r" (flush_size)
  804. : "0" (flush_size), "r" (flush_base),
  805. "i" (ASI_PHYS_USE_EC), "r" (flush_linesize));
  806. }
  807. static void cheetah_flush_ecache_line(unsigned long physaddr)
  808. {
  809. unsigned long alias;
  810. physaddr &= ~(8UL - 1UL);
  811. physaddr = (ecache_flush_physbase +
  812. (physaddr & ((ecache_flush_size>>1UL) - 1UL)));
  813. alias = physaddr + (ecache_flush_size >> 1UL);
  814. __asm__ __volatile__("ldxa [%0] %2, %%g0\n\t"
  815. "ldxa [%1] %2, %%g0\n\t"
  816. "membar #Sync"
  817. : /* no outputs */
  818. : "r" (physaddr), "r" (alias),
  819. "i" (ASI_PHYS_USE_EC));
  820. }
  821. /* Unfortunately, the diagnostic access to the I-cache tags we need to
  822. * use to clear the thing interferes with I-cache coherency transactions.
  823. *
  824. * So we must only flush the I-cache when it is disabled.
  825. */
  826. static void __cheetah_flush_icache(void)
  827. {
  828. unsigned int icache_size, icache_line_size;
  829. unsigned long addr;
  830. icache_size = local_cpu_data().icache_size;
  831. icache_line_size = local_cpu_data().icache_line_size;
  832. /* Clear the valid bits in all the tags. */
  833. for (addr = 0; addr < icache_size; addr += icache_line_size) {
  834. __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
  835. "membar #Sync"
  836. : /* no outputs */
  837. : "r" (addr | (2 << 3)),
  838. "i" (ASI_IC_TAG));
  839. }
  840. }
  841. static void cheetah_flush_icache(void)
  842. {
  843. unsigned long dcu_save;
  844. /* Save current DCU, disable I-cache. */
  845. __asm__ __volatile__("ldxa [%%g0] %1, %0\n\t"
  846. "or %0, %2, %%g1\n\t"
  847. "stxa %%g1, [%%g0] %1\n\t"
  848. "membar #Sync"
  849. : "=r" (dcu_save)
  850. : "i" (ASI_DCU_CONTROL_REG), "i" (DCU_IC)
  851. : "g1");
  852. __cheetah_flush_icache();
  853. /* Restore DCU register */
  854. __asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
  855. "membar #Sync"
  856. : /* no outputs */
  857. : "r" (dcu_save), "i" (ASI_DCU_CONTROL_REG));
  858. }
  859. static void cheetah_flush_dcache(void)
  860. {
  861. unsigned int dcache_size, dcache_line_size;
  862. unsigned long addr;
  863. dcache_size = local_cpu_data().dcache_size;
  864. dcache_line_size = local_cpu_data().dcache_line_size;
  865. for (addr = 0; addr < dcache_size; addr += dcache_line_size) {
  866. __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
  867. "membar #Sync"
  868. : /* no outputs */
  869. : "r" (addr), "i" (ASI_DCACHE_TAG));
  870. }
  871. }
  872. /* In order to make the even parity correct we must do two things.
  873. * First, we clear DC_data_parity and set DC_utag to an appropriate value.
  874. * Next, we clear out all 32-bytes of data for that line. Data of
  875. * all-zero + tag parity value of zero == correct parity.
  876. */
  877. static void cheetah_plus_zap_dcache_parity(void)
  878. {
  879. unsigned int dcache_size, dcache_line_size;
  880. unsigned long addr;
  881. dcache_size = local_cpu_data().dcache_size;
  882. dcache_line_size = local_cpu_data().dcache_line_size;
  883. for (addr = 0; addr < dcache_size; addr += dcache_line_size) {
  884. unsigned long tag = (addr >> 14);
  885. unsigned long line;
  886. __asm__ __volatile__("membar #Sync\n\t"
  887. "stxa %0, [%1] %2\n\t"
  888. "membar #Sync"
  889. : /* no outputs */
  890. : "r" (tag), "r" (addr),
  891. "i" (ASI_DCACHE_UTAG));
  892. for (line = addr; line < addr + dcache_line_size; line += 8)
  893. __asm__ __volatile__("membar #Sync\n\t"
  894. "stxa %%g0, [%0] %1\n\t"
  895. "membar #Sync"
  896. : /* no outputs */
  897. : "r" (line),
  898. "i" (ASI_DCACHE_DATA));
  899. }
  900. }
  901. /* Conversion tables used to frob Cheetah AFSR syndrome values into
  902. * something palatable to the memory controller driver get_unumber
  903. * routine.
  904. */
  905. #define MT0 137
  906. #define MT1 138
  907. #define MT2 139
  908. #define NONE 254
  909. #define MTC0 140
  910. #define MTC1 141
  911. #define MTC2 142
  912. #define MTC3 143
  913. #define C0 128
  914. #define C1 129
  915. #define C2 130
  916. #define C3 131
  917. #define C4 132
  918. #define C5 133
  919. #define C6 134
  920. #define C7 135
  921. #define C8 136
  922. #define M2 144
  923. #define M3 145
  924. #define M4 146
  925. #define M 147
  926. static unsigned char cheetah_ecc_syntab[] = {
  927. /*00*/NONE, C0, C1, M2, C2, M2, M3, 47, C3, M2, M2, 53, M2, 41, 29, M,
  928. /*01*/C4, M, M, 50, M2, 38, 25, M2, M2, 33, 24, M2, 11, M, M2, 16,
  929. /*02*/C5, M, M, 46, M2, 37, 19, M2, M, 31, 32, M, 7, M2, M2, 10,
  930. /*03*/M2, 40, 13, M2, 59, M, M2, 66, M, M2, M2, 0, M2, 67, 71, M,
  931. /*04*/C6, M, M, 43, M, 36, 18, M, M2, 49, 15, M, 63, M2, M2, 6,
  932. /*05*/M2, 44, 28, M2, M, M2, M2, 52, 68, M2, M2, 62, M2, M3, M3, M4,
  933. /*06*/M2, 26, 106, M2, 64, M, M2, 2, 120, M, M2, M3, M, M3, M3, M4,
  934. /*07*/116, M2, M2, M3, M2, M3, M, M4, M2, 58, 54, M2, M, M4, M4, M3,
  935. /*08*/C7, M2, M, 42, M, 35, 17, M2, M, 45, 14, M2, 21, M2, M2, 5,
  936. /*09*/M, 27, M, M, 99, M, M, 3, 114, M2, M2, 20, M2, M3, M3, M,
  937. /*0a*/M2, 23, 113, M2, 112, M2, M, 51, 95, M, M2, M3, M2, M3, M3, M2,
  938. /*0b*/103, M, M2, M3, M2, M3, M3, M4, M2, 48, M, M, 73, M2, M, M3,
  939. /*0c*/M2, 22, 110, M2, 109, M2, M, 9, 108, M2, M, M3, M2, M3, M3, M,
  940. /*0d*/102, M2, M, M, M2, M3, M3, M, M2, M3, M3, M2, M, M4, M, M3,
  941. /*0e*/98, M, M2, M3, M2, M, M3, M4, M2, M3, M3, M4, M3, M, M, M,
  942. /*0f*/M2, M3, M3, M, M3, M, M, M, 56, M4, M, M3, M4, M, M, M,
  943. /*10*/C8, M, M2, 39, M, 34, 105, M2, M, 30, 104, M, 101, M, M, 4,
  944. /*11*/M, M, 100, M, 83, M, M2, 12, 87, M, M, 57, M2, M, M3, M,
  945. /*12*/M2, 97, 82, M2, 78, M2, M2, 1, 96, M, M, M, M, M, M3, M2,
  946. /*13*/94, M, M2, M3, M2, M, M3, M, M2, M, 79, M, 69, M, M4, M,
  947. /*14*/M2, 93, 92, M, 91, M, M2, 8, 90, M2, M2, M, M, M, M, M4,
  948. /*15*/89, M, M, M3, M2, M3, M3, M, M, M, M3, M2, M3, M2, M, M3,
  949. /*16*/86, M, M2, M3, M2, M, M3, M, M2, M, M3, M, M3, M, M, M3,
  950. /*17*/M, M, M3, M2, M3, M2, M4, M, 60, M, M2, M3, M4, M, M, M2,
  951. /*18*/M2, 88, 85, M2, 84, M, M2, 55, 81, M2, M2, M3, M2, M3, M3, M4,
  952. /*19*/77, M, M, M, M2, M3, M, M, M2, M3, M3, M4, M3, M2, M, M,
  953. /*1a*/74, M, M2, M3, M, M, M3, M, M, M, M3, M, M3, M, M4, M3,
  954. /*1b*/M2, 70, 107, M4, 65, M2, M2, M, 127, M, M, M, M2, M3, M3, M,
  955. /*1c*/80, M2, M2, 72, M, 119, 118, M, M2, 126, 76, M, 125, M, M4, M3,
  956. /*1d*/M2, 115, 124, M, 75, M, M, M3, 61, M, M4, M, M4, M, M, M,
  957. /*1e*/M, 123, 122, M4, 121, M4, M, M3, 117, M2, M2, M3, M4, M3, M, M,
  958. /*1f*/111, M, M, M, M4, M3, M3, M, M, M, M3, M, M3, M2, M, M
  959. };
  960. static unsigned char cheetah_mtag_syntab[] = {
  961. NONE, MTC0,
  962. MTC1, NONE,
  963. MTC2, NONE,
  964. NONE, MT0,
  965. MTC3, NONE,
  966. NONE, MT1,
  967. NONE, MT2,
  968. NONE, NONE
  969. };
  970. /* Return the highest priority error conditon mentioned. */
  971. static inline unsigned long cheetah_get_hipri(unsigned long afsr)
  972. {
  973. unsigned long tmp = 0;
  974. int i;
  975. for (i = 0; cheetah_error_table[i].mask; i++) {
  976. if ((tmp = (afsr & cheetah_error_table[i].mask)) != 0UL)
  977. return tmp;
  978. }
  979. return tmp;
  980. }
  981. static const char *cheetah_get_string(unsigned long bit)
  982. {
  983. int i;
  984. for (i = 0; cheetah_error_table[i].mask; i++) {
  985. if ((bit & cheetah_error_table[i].mask) != 0UL)
  986. return cheetah_error_table[i].name;
  987. }
  988. return "???";
  989. }
  990. static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *info,
  991. unsigned long afsr, unsigned long afar, int recoverable)
  992. {
  993. unsigned long hipri;
  994. char unum[256];
  995. printk("%s" "ERROR(%d): Cheetah error trap taken afsr[%016lx] afar[%016lx] TL1(%d)\n",
  996. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  997. afsr, afar,
  998. (afsr & CHAFSR_TL1) ? 1 : 0);
  999. printk("%s" "ERROR(%d): TPC[%lx] TNPC[%lx] O7[%lx] TSTATE[%lx]\n",
  1000. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1001. regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
  1002. printk("%s" "ERROR(%d): ",
  1003. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
  1004. printk("TPC<%pS>\n", (void *) regs->tpc);
  1005. printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
  1006. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1007. (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
  1008. (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT,
  1009. (afsr & CHAFSR_ME) ? ", Multiple Errors" : "",
  1010. (afsr & CHAFSR_PRIV) ? ", Privileged" : "");
  1011. hipri = cheetah_get_hipri(afsr);
  1012. printk("%s" "ERROR(%d): Highest priority error (%016lx) \"%s\"\n",
  1013. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1014. hipri, cheetah_get_string(hipri));
  1015. /* Try to get unumber if relevant. */
  1016. #define ESYND_ERRORS (CHAFSR_IVC | CHAFSR_IVU | \
  1017. CHAFSR_CPC | CHAFSR_CPU | \
  1018. CHAFSR_UE | CHAFSR_CE | \
  1019. CHAFSR_EDC | CHAFSR_EDU | \
  1020. CHAFSR_UCC | CHAFSR_UCU | \
  1021. CHAFSR_WDU | CHAFSR_WDC)
  1022. #define MSYND_ERRORS (CHAFSR_EMC | CHAFSR_EMU)
  1023. if (afsr & ESYND_ERRORS) {
  1024. int syndrome;
  1025. int ret;
  1026. syndrome = (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT;
  1027. syndrome = cheetah_ecc_syntab[syndrome];
  1028. ret = sprintf_dimm(syndrome, afar, unum, sizeof(unum));
  1029. if (ret != -1)
  1030. printk("%s" "ERROR(%d): AFAR E-syndrome [%s]\n",
  1031. (recoverable ? KERN_WARNING : KERN_CRIT),
  1032. smp_processor_id(), unum);
  1033. } else if (afsr & MSYND_ERRORS) {
  1034. int syndrome;
  1035. int ret;
  1036. syndrome = (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT;
  1037. syndrome = cheetah_mtag_syntab[syndrome];
  1038. ret = sprintf_dimm(syndrome, afar, unum, sizeof(unum));
  1039. if (ret != -1)
  1040. printk("%s" "ERROR(%d): AFAR M-syndrome [%s]\n",
  1041. (recoverable ? KERN_WARNING : KERN_CRIT),
  1042. smp_processor_id(), unum);
  1043. }
  1044. /* Now dump the cache snapshots. */
  1045. printk("%s" "ERROR(%d): D-cache idx[%x] tag[%016llx] utag[%016llx] stag[%016llx]\n",
  1046. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1047. (int) info->dcache_index,
  1048. info->dcache_tag,
  1049. info->dcache_utag,
  1050. info->dcache_stag);
  1051. printk("%s" "ERROR(%d): D-cache data0[%016llx] data1[%016llx] data2[%016llx] data3[%016llx]\n",
  1052. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1053. info->dcache_data[0],
  1054. info->dcache_data[1],
  1055. info->dcache_data[2],
  1056. info->dcache_data[3]);
  1057. printk("%s" "ERROR(%d): I-cache idx[%x] tag[%016llx] utag[%016llx] stag[%016llx] "
  1058. "u[%016llx] l[%016llx]\n",
  1059. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1060. (int) info->icache_index,
  1061. info->icache_tag,
  1062. info->icache_utag,
  1063. info->icache_stag,
  1064. info->icache_upper,
  1065. info->icache_lower);
  1066. printk("%s" "ERROR(%d): I-cache INSN0[%016llx] INSN1[%016llx] INSN2[%016llx] INSN3[%016llx]\n",
  1067. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1068. info->icache_data[0],
  1069. info->icache_data[1],
  1070. info->icache_data[2],
  1071. info->icache_data[3]);
  1072. printk("%s" "ERROR(%d): I-cache INSN4[%016llx] INSN5[%016llx] INSN6[%016llx] INSN7[%016llx]\n",
  1073. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1074. info->icache_data[4],
  1075. info->icache_data[5],
  1076. info->icache_data[6],
  1077. info->icache_data[7]);
  1078. printk("%s" "ERROR(%d): E-cache idx[%x] tag[%016llx]\n",
  1079. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1080. (int) info->ecache_index, info->ecache_tag);
  1081. printk("%s" "ERROR(%d): E-cache data0[%016llx] data1[%016llx] data2[%016llx] data3[%016llx]\n",
  1082. (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
  1083. info->ecache_data[0],
  1084. info->ecache_data[1],
  1085. info->ecache_data[2],
  1086. info->ecache_data[3]);
  1087. afsr = (afsr & ~hipri) & cheetah_afsr_errors;
  1088. while (afsr != 0UL) {
  1089. unsigned long bit = cheetah_get_hipri(afsr);
  1090. printk("%s" "ERROR: Multiple-error (%016lx) \"%s\"\n",
  1091. (recoverable ? KERN_WARNING : KERN_CRIT),
  1092. bit, cheetah_get_string(bit));
  1093. afsr &= ~bit;
  1094. }
  1095. if (!recoverable)
  1096. printk(KERN_CRIT "ERROR: This condition is not recoverable.\n");
  1097. }
  1098. static int cheetah_recheck_errors(struct cheetah_err_info *logp)
  1099. {
  1100. unsigned long afsr, afar;
  1101. int ret = 0;
  1102. __asm__ __volatile__("ldxa [%%g0] %1, %0\n\t"
  1103. : "=r" (afsr)
  1104. : "i" (ASI_AFSR));
  1105. if ((afsr & cheetah_afsr_errors) != 0) {
  1106. if (logp != NULL) {
  1107. __asm__ __volatile__("ldxa [%%g0] %1, %0\n\t"
  1108. : "=r" (afar)
  1109. : "i" (ASI_AFAR));
  1110. logp->afsr = afsr;
  1111. logp->afar = afar;
  1112. }
  1113. ret = 1;
  1114. }
  1115. __asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
  1116. "membar #Sync\n\t"
  1117. : : "r" (afsr), "i" (ASI_AFSR));
  1118. return ret;
  1119. }
  1120. void cheetah_fecc_handler(struct pt_regs *regs, unsigned long afsr, unsigned long afar)
  1121. {
  1122. struct cheetah_err_info local_snapshot, *p;
  1123. int recoverable;
  1124. /* Flush E-cache */
  1125. cheetah_flush_ecache();
  1126. p = cheetah_get_error_log(afsr);
  1127. if (!p) {
  1128. prom_printf("ERROR: Early Fast-ECC error afsr[%016lx] afar[%016lx]\n",
  1129. afsr, afar);
  1130. prom_printf("ERROR: CPU(%d) TPC[%016lx] TNPC[%016lx] TSTATE[%016lx]\n",
  1131. smp_processor_id(), regs->tpc, regs->tnpc, regs->tstate);
  1132. prom_halt();
  1133. }
  1134. /* Grab snapshot of logged error. */
  1135. memcpy(&local_snapshot, p, sizeof(local_snapshot));
  1136. /* If the current trap snapshot does not match what the
  1137. * trap handler passed along into our args, big trouble.
  1138. * In such a case, mark the local copy as invalid.
  1139. *
  1140. * Else, it matches and we mark the afsr in the non-local
  1141. * copy as invalid so we may log new error traps there.
  1142. */
  1143. if (p->afsr != afsr || p->afar != afar)
  1144. local_snapshot.afsr = CHAFSR_INVALID;
  1145. else
  1146. p->afsr = CHAFSR_INVALID;
  1147. cheetah_flush_icache();
  1148. cheetah_flush_dcache();
  1149. /* Re-enable I-cache/D-cache */
  1150. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1151. "or %%g1, %1, %%g1\n\t"
  1152. "stxa %%g1, [%%g0] %0\n\t"
  1153. "membar #Sync"
  1154. : /* no outputs */
  1155. : "i" (ASI_DCU_CONTROL_REG),
  1156. "i" (DCU_DC | DCU_IC)
  1157. : "g1");
  1158. /* Re-enable error reporting */
  1159. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1160. "or %%g1, %1, %%g1\n\t"
  1161. "stxa %%g1, [%%g0] %0\n\t"
  1162. "membar #Sync"
  1163. : /* no outputs */
  1164. : "i" (ASI_ESTATE_ERROR_EN),
  1165. "i" (ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN)
  1166. : "g1");
  1167. /* Decide if we can continue after handling this trap and
  1168. * logging the error.
  1169. */
  1170. recoverable = 1;
  1171. if (afsr & (CHAFSR_PERR | CHAFSR_IERR | CHAFSR_ISAP))
  1172. recoverable = 0;
  1173. /* Re-check AFSR/AFAR. What we are looking for here is whether a new
  1174. * error was logged while we had error reporting traps disabled.
  1175. */
  1176. if (cheetah_recheck_errors(&local_snapshot)) {
  1177. unsigned long new_afsr = local_snapshot.afsr;
  1178. /* If we got a new asynchronous error, die... */
  1179. if (new_afsr & (CHAFSR_EMU | CHAFSR_EDU |
  1180. CHAFSR_WDU | CHAFSR_CPU |
  1181. CHAFSR_IVU | CHAFSR_UE |
  1182. CHAFSR_BERR | CHAFSR_TO))
  1183. recoverable = 0;
  1184. }
  1185. /* Log errors. */
  1186. cheetah_log_errors(regs, &local_snapshot, afsr, afar, recoverable);
  1187. if (!recoverable)
  1188. panic("Irrecoverable Fast-ECC error trap.\n");
  1189. /* Flush E-cache to kick the error trap handlers out. */
  1190. cheetah_flush_ecache();
  1191. }
  1192. /* Try to fix a correctable error by pushing the line out from
  1193. * the E-cache. Recheck error reporting registers to see if the
  1194. * problem is intermittent.
  1195. */
  1196. static int cheetah_fix_ce(unsigned long physaddr)
  1197. {
  1198. unsigned long orig_estate;
  1199. unsigned long alias1, alias2;
  1200. int ret;
  1201. /* Make sure correctable error traps are disabled. */
  1202. __asm__ __volatile__("ldxa [%%g0] %2, %0\n\t"
  1203. "andn %0, %1, %%g1\n\t"
  1204. "stxa %%g1, [%%g0] %2\n\t"
  1205. "membar #Sync"
  1206. : "=&r" (orig_estate)
  1207. : "i" (ESTATE_ERROR_CEEN),
  1208. "i" (ASI_ESTATE_ERROR_EN)
  1209. : "g1");
  1210. /* We calculate alias addresses that will force the
  1211. * cache line in question out of the E-cache. Then
  1212. * we bring it back in with an atomic instruction so
  1213. * that we get it in some modified/exclusive state,
  1214. * then we displace it again to try and get proper ECC
  1215. * pushed back into the system.
  1216. */
  1217. physaddr &= ~(8UL - 1UL);
  1218. alias1 = (ecache_flush_physbase +
  1219. (physaddr & ((ecache_flush_size >> 1) - 1)));
  1220. alias2 = alias1 + (ecache_flush_size >> 1);
  1221. __asm__ __volatile__("ldxa [%0] %3, %%g0\n\t"
  1222. "ldxa [%1] %3, %%g0\n\t"
  1223. "casxa [%2] %3, %%g0, %%g0\n\t"
  1224. "ldxa [%0] %3, %%g0\n\t"
  1225. "ldxa [%1] %3, %%g0\n\t"
  1226. "membar #Sync"
  1227. : /* no outputs */
  1228. : "r" (alias1), "r" (alias2),
  1229. "r" (physaddr), "i" (ASI_PHYS_USE_EC));
  1230. /* Did that trigger another error? */
  1231. if (cheetah_recheck_errors(NULL)) {
  1232. /* Try one more time. */
  1233. __asm__ __volatile__("ldxa [%0] %1, %%g0\n\t"
  1234. "membar #Sync"
  1235. : : "r" (physaddr), "i" (ASI_PHYS_USE_EC));
  1236. if (cheetah_recheck_errors(NULL))
  1237. ret = 2;
  1238. else
  1239. ret = 1;
  1240. } else {
  1241. /* No new error, intermittent problem. */
  1242. ret = 0;
  1243. }
  1244. /* Restore error enables. */
  1245. __asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
  1246. "membar #Sync"
  1247. : : "r" (orig_estate), "i" (ASI_ESTATE_ERROR_EN));
  1248. return ret;
  1249. }
  1250. /* Return non-zero if PADDR is a valid physical memory address. */
  1251. static int cheetah_check_main_memory(unsigned long paddr)
  1252. {
  1253. unsigned long vaddr = PAGE_OFFSET + paddr;
  1254. if (vaddr > (unsigned long) high_memory)
  1255. return 0;
  1256. return kern_addr_valid(vaddr);
  1257. }
  1258. void cheetah_cee_handler(struct pt_regs *regs, unsigned long afsr, unsigned long afar)
  1259. {
  1260. struct cheetah_err_info local_snapshot, *p;
  1261. int recoverable, is_memory;
  1262. p = cheetah_get_error_log(afsr);
  1263. if (!p) {
  1264. prom_printf("ERROR: Early CEE error afsr[%016lx] afar[%016lx]\n",
  1265. afsr, afar);
  1266. prom_printf("ERROR: CPU(%d) TPC[%016lx] TNPC[%016lx] TSTATE[%016lx]\n",
  1267. smp_processor_id(), regs->tpc, regs->tnpc, regs->tstate);
  1268. prom_halt();
  1269. }
  1270. /* Grab snapshot of logged error. */
  1271. memcpy(&local_snapshot, p, sizeof(local_snapshot));
  1272. /* If the current trap snapshot does not match what the
  1273. * trap handler passed along into our args, big trouble.
  1274. * In such a case, mark the local copy as invalid.
  1275. *
  1276. * Else, it matches and we mark the afsr in the non-local
  1277. * copy as invalid so we may log new error traps there.
  1278. */
  1279. if (p->afsr != afsr || p->afar != afar)
  1280. local_snapshot.afsr = CHAFSR_INVALID;
  1281. else
  1282. p->afsr = CHAFSR_INVALID;
  1283. is_memory = cheetah_check_main_memory(afar);
  1284. if (is_memory && (afsr & CHAFSR_CE) != 0UL) {
  1285. /* XXX Might want to log the results of this operation
  1286. * XXX somewhere... -DaveM
  1287. */
  1288. cheetah_fix_ce(afar);
  1289. }
  1290. {
  1291. int flush_all, flush_line;
  1292. flush_all = flush_line = 0;
  1293. if ((afsr & CHAFSR_EDC) != 0UL) {
  1294. if ((afsr & cheetah_afsr_errors) == CHAFSR_EDC)
  1295. flush_line = 1;
  1296. else
  1297. flush_all = 1;
  1298. } else if ((afsr & CHAFSR_CPC) != 0UL) {
  1299. if ((afsr & cheetah_afsr_errors) == CHAFSR_CPC)
  1300. flush_line = 1;
  1301. else
  1302. flush_all = 1;
  1303. }
  1304. /* Trap handler only disabled I-cache, flush it. */
  1305. cheetah_flush_icache();
  1306. /* Re-enable I-cache */
  1307. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1308. "or %%g1, %1, %%g1\n\t"
  1309. "stxa %%g1, [%%g0] %0\n\t"
  1310. "membar #Sync"
  1311. : /* no outputs */
  1312. : "i" (ASI_DCU_CONTROL_REG),
  1313. "i" (DCU_IC)
  1314. : "g1");
  1315. if (flush_all)
  1316. cheetah_flush_ecache();
  1317. else if (flush_line)
  1318. cheetah_flush_ecache_line(afar);
  1319. }
  1320. /* Re-enable error reporting */
  1321. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1322. "or %%g1, %1, %%g1\n\t"
  1323. "stxa %%g1, [%%g0] %0\n\t"
  1324. "membar #Sync"
  1325. : /* no outputs */
  1326. : "i" (ASI_ESTATE_ERROR_EN),
  1327. "i" (ESTATE_ERROR_CEEN)
  1328. : "g1");
  1329. /* Decide if we can continue after handling this trap and
  1330. * logging the error.
  1331. */
  1332. recoverable = 1;
  1333. if (afsr & (CHAFSR_PERR | CHAFSR_IERR | CHAFSR_ISAP))
  1334. recoverable = 0;
  1335. /* Re-check AFSR/AFAR */
  1336. (void) cheetah_recheck_errors(&local_snapshot);
  1337. /* Log errors. */
  1338. cheetah_log_errors(regs, &local_snapshot, afsr, afar, recoverable);
  1339. if (!recoverable)
  1340. panic("Irrecoverable Correctable-ECC error trap.\n");
  1341. }
  1342. void cheetah_deferred_handler(struct pt_regs *regs, unsigned long afsr, unsigned long afar)
  1343. {
  1344. struct cheetah_err_info local_snapshot, *p;
  1345. int recoverable, is_memory;
  1346. #ifdef CONFIG_PCI
  1347. /* Check for the special PCI poke sequence. */
  1348. if (pci_poke_in_progress && pci_poke_cpu == smp_processor_id()) {
  1349. cheetah_flush_icache();
  1350. cheetah_flush_dcache();
  1351. /* Re-enable I-cache/D-cache */
  1352. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1353. "or %%g1, %1, %%g1\n\t"
  1354. "stxa %%g1, [%%g0] %0\n\t"
  1355. "membar #Sync"
  1356. : /* no outputs */
  1357. : "i" (ASI_DCU_CONTROL_REG),
  1358. "i" (DCU_DC | DCU_IC)
  1359. : "g1");
  1360. /* Re-enable error reporting */
  1361. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1362. "or %%g1, %1, %%g1\n\t"
  1363. "stxa %%g1, [%%g0] %0\n\t"
  1364. "membar #Sync"
  1365. : /* no outputs */
  1366. : "i" (ASI_ESTATE_ERROR_EN),
  1367. "i" (ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN)
  1368. : "g1");
  1369. (void) cheetah_recheck_errors(NULL);
  1370. pci_poke_faulted = 1;
  1371. regs->tpc += 4;
  1372. regs->tnpc = regs->tpc + 4;
  1373. return;
  1374. }
  1375. #endif
  1376. p = cheetah_get_error_log(afsr);
  1377. if (!p) {
  1378. prom_printf("ERROR: Early deferred error afsr[%016lx] afar[%016lx]\n",
  1379. afsr, afar);
  1380. prom_printf("ERROR: CPU(%d) TPC[%016lx] TNPC[%016lx] TSTATE[%016lx]\n",
  1381. smp_processor_id(), regs->tpc, regs->tnpc, regs->tstate);
  1382. prom_halt();
  1383. }
  1384. /* Grab snapshot of logged error. */
  1385. memcpy(&local_snapshot, p, sizeof(local_snapshot));
  1386. /* If the current trap snapshot does not match what the
  1387. * trap handler passed along into our args, big trouble.
  1388. * In such a case, mark the local copy as invalid.
  1389. *
  1390. * Else, it matches and we mark the afsr in the non-local
  1391. * copy as invalid so we may log new error traps there.
  1392. */
  1393. if (p->afsr != afsr || p->afar != afar)
  1394. local_snapshot.afsr = CHAFSR_INVALID;
  1395. else
  1396. p->afsr = CHAFSR_INVALID;
  1397. is_memory = cheetah_check_main_memory(afar);
  1398. {
  1399. int flush_all, flush_line;
  1400. flush_all = flush_line = 0;
  1401. if ((afsr & CHAFSR_EDU) != 0UL) {
  1402. if ((afsr & cheetah_afsr_errors) == CHAFSR_EDU)
  1403. flush_line = 1;
  1404. else
  1405. flush_all = 1;
  1406. } else if ((afsr & CHAFSR_BERR) != 0UL) {
  1407. if ((afsr & cheetah_afsr_errors) == CHAFSR_BERR)
  1408. flush_line = 1;
  1409. else
  1410. flush_all = 1;
  1411. }
  1412. cheetah_flush_icache();
  1413. cheetah_flush_dcache();
  1414. /* Re-enable I/D caches */
  1415. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1416. "or %%g1, %1, %%g1\n\t"
  1417. "stxa %%g1, [%%g0] %0\n\t"
  1418. "membar #Sync"
  1419. : /* no outputs */
  1420. : "i" (ASI_DCU_CONTROL_REG),
  1421. "i" (DCU_IC | DCU_DC)
  1422. : "g1");
  1423. if (flush_all)
  1424. cheetah_flush_ecache();
  1425. else if (flush_line)
  1426. cheetah_flush_ecache_line(afar);
  1427. }
  1428. /* Re-enable error reporting */
  1429. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1430. "or %%g1, %1, %%g1\n\t"
  1431. "stxa %%g1, [%%g0] %0\n\t"
  1432. "membar #Sync"
  1433. : /* no outputs */
  1434. : "i" (ASI_ESTATE_ERROR_EN),
  1435. "i" (ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN)
  1436. : "g1");
  1437. /* Decide if we can continue after handling this trap and
  1438. * logging the error.
  1439. */
  1440. recoverable = 1;
  1441. if (afsr & (CHAFSR_PERR | CHAFSR_IERR | CHAFSR_ISAP))
  1442. recoverable = 0;
  1443. /* Re-check AFSR/AFAR. What we are looking for here is whether a new
  1444. * error was logged while we had error reporting traps disabled.
  1445. */
  1446. if (cheetah_recheck_errors(&local_snapshot)) {
  1447. unsigned long new_afsr = local_snapshot.afsr;
  1448. /* If we got a new asynchronous error, die... */
  1449. if (new_afsr & (CHAFSR_EMU | CHAFSR_EDU |
  1450. CHAFSR_WDU | CHAFSR_CPU |
  1451. CHAFSR_IVU | CHAFSR_UE |
  1452. CHAFSR_BERR | CHAFSR_TO))
  1453. recoverable = 0;
  1454. }
  1455. /* Log errors. */
  1456. cheetah_log_errors(regs, &local_snapshot, afsr, afar, recoverable);
  1457. /* "Recoverable" here means we try to yank the page from ever
  1458. * being newly used again. This depends upon a few things:
  1459. * 1) Must be main memory, and AFAR must be valid.
  1460. * 2) If we trapped from user, OK.
  1461. * 3) Else, if we trapped from kernel we must find exception
  1462. * table entry (ie. we have to have been accessing user
  1463. * space).
  1464. *
  1465. * If AFAR is not in main memory, or we trapped from kernel
  1466. * and cannot find an exception table entry, it is unacceptable
  1467. * to try and continue.
  1468. */
  1469. if (recoverable && is_memory) {
  1470. if ((regs->tstate & TSTATE_PRIV) == 0UL) {
  1471. /* OK, usermode access. */
  1472. recoverable = 1;
  1473. } else {
  1474. const struct exception_table_entry *entry;
  1475. entry = search_exception_tables(regs->tpc);
  1476. if (entry) {
  1477. /* OK, kernel access to userspace. */
  1478. recoverable = 1;
  1479. } else {
  1480. /* BAD, privileged state is corrupted. */
  1481. recoverable = 0;
  1482. }
  1483. if (recoverable) {
  1484. if (pfn_valid(afar >> PAGE_SHIFT))
  1485. get_page(pfn_to_page(afar >> PAGE_SHIFT));
  1486. else
  1487. recoverable = 0;
  1488. /* Only perform fixup if we still have a
  1489. * recoverable condition.
  1490. */
  1491. if (recoverable) {
  1492. regs->tpc = entry->fixup;
  1493. regs->tnpc = regs->tpc + 4;
  1494. }
  1495. }
  1496. }
  1497. } else {
  1498. recoverable = 0;
  1499. }
  1500. if (!recoverable)
  1501. panic("Irrecoverable deferred error trap.\n");
  1502. }
  1503. /* Handle a D/I cache parity error trap. TYPE is encoded as:
  1504. *
  1505. * Bit0: 0=dcache,1=icache
  1506. * Bit1: 0=recoverable,1=unrecoverable
  1507. *
  1508. * The hardware has disabled both the I-cache and D-cache in
  1509. * the %dcr register.
  1510. */
  1511. void cheetah_plus_parity_error(int type, struct pt_regs *regs)
  1512. {
  1513. if (type & 0x1)
  1514. __cheetah_flush_icache();
  1515. else
  1516. cheetah_plus_zap_dcache_parity();
  1517. cheetah_flush_dcache();
  1518. /* Re-enable I-cache/D-cache */
  1519. __asm__ __volatile__("ldxa [%%g0] %0, %%g1\n\t"
  1520. "or %%g1, %1, %%g1\n\t"
  1521. "stxa %%g1, [%%g0] %0\n\t"
  1522. "membar #Sync"
  1523. : /* no outputs */
  1524. : "i" (ASI_DCU_CONTROL_REG),
  1525. "i" (DCU_DC | DCU_IC)
  1526. : "g1");
  1527. if (type & 0x2) {
  1528. printk(KERN_EMERG "CPU[%d]: Cheetah+ %c-cache parity error at TPC[%016lx]\n",
  1529. smp_processor_id(),
  1530. (type & 0x1) ? 'I' : 'D',
  1531. regs->tpc);
  1532. printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
  1533. panic("Irrecoverable Cheetah+ parity error.");
  1534. }
  1535. printk(KERN_WARNING "CPU[%d]: Cheetah+ %c-cache parity error at TPC[%016lx]\n",
  1536. smp_processor_id(),
  1537. (type & 0x1) ? 'I' : 'D',
  1538. regs->tpc);
  1539. printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
  1540. }
  1541. struct sun4v_error_entry {
  1542. u64 err_handle;
  1543. u64 err_stick;
  1544. u32 err_type;
  1545. #define SUN4V_ERR_TYPE_UNDEFINED 0
  1546. #define SUN4V_ERR_TYPE_UNCORRECTED_RES 1
  1547. #define SUN4V_ERR_TYPE_PRECISE_NONRES 2
  1548. #define SUN4V_ERR_TYPE_DEFERRED_NONRES 3
  1549. #define SUN4V_ERR_TYPE_WARNING_RES 4
  1550. u32 err_attrs;
  1551. #define SUN4V_ERR_ATTRS_PROCESSOR 0x00000001
  1552. #define SUN4V_ERR_ATTRS_MEMORY 0x00000002
  1553. #define SUN4V_ERR_ATTRS_PIO 0x00000004
  1554. #define SUN4V_ERR_ATTRS_INT_REGISTERS 0x00000008
  1555. #define SUN4V_ERR_ATTRS_FPU_REGISTERS 0x00000010
  1556. #define SUN4V_ERR_ATTRS_USER_MODE 0x01000000
  1557. #define SUN4V_ERR_ATTRS_PRIV_MODE 0x02000000
  1558. #define SUN4V_ERR_ATTRS_RES_QUEUE_FULL 0x80000000
  1559. u64 err_raddr;
  1560. u32 err_size;
  1561. u16 err_cpu;
  1562. u16 err_pad;
  1563. };
  1564. static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
  1565. static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
  1566. static const char *sun4v_err_type_to_str(u32 type)
  1567. {
  1568. switch (type) {
  1569. case SUN4V_ERR_TYPE_UNDEFINED:
  1570. return "undefined";
  1571. case SUN4V_ERR_TYPE_UNCORRECTED_RES:
  1572. return "uncorrected resumable";
  1573. case SUN4V_ERR_TYPE_PRECISE_NONRES:
  1574. return "precise nonresumable";
  1575. case SUN4V_ERR_TYPE_DEFERRED_NONRES:
  1576. return "deferred nonresumable";
  1577. case SUN4V_ERR_TYPE_WARNING_RES:
  1578. return "warning resumable";
  1579. default:
  1580. return "unknown";
  1581. };
  1582. }
  1583. static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent, int cpu, const char *pfx, atomic_t *ocnt)
  1584. {
  1585. int cnt;
  1586. printk("%s: Reporting on cpu %d\n", pfx, cpu);
  1587. printk("%s: err_handle[%llx] err_stick[%llx] err_type[%08x:%s]\n",
  1588. pfx,
  1589. ent->err_handle, ent->err_stick,
  1590. ent->err_type,
  1591. sun4v_err_type_to_str(ent->err_type));
  1592. printk("%s: err_attrs[%08x:%s %s %s %s %s %s %s %s]\n",
  1593. pfx,
  1594. ent->err_attrs,
  1595. ((ent->err_attrs & SUN4V_ERR_ATTRS_PROCESSOR) ?
  1596. "processor" : ""),
  1597. ((ent->err_attrs & SUN4V_ERR_ATTRS_MEMORY) ?
  1598. "memory" : ""),
  1599. ((ent->err_attrs & SUN4V_ERR_ATTRS_PIO) ?
  1600. "pio" : ""),
  1601. ((ent->err_attrs & SUN4V_ERR_ATTRS_INT_REGISTERS) ?
  1602. "integer-regs" : ""),
  1603. ((ent->err_attrs & SUN4V_ERR_ATTRS_FPU_REGISTERS) ?
  1604. "fpu-regs" : ""),
  1605. ((ent->err_attrs & SUN4V_ERR_ATTRS_USER_MODE) ?
  1606. "user" : ""),
  1607. ((ent->err_attrs & SUN4V_ERR_ATTRS_PRIV_MODE) ?
  1608. "privileged" : ""),
  1609. ((ent->err_attrs & SUN4V_ERR_ATTRS_RES_QUEUE_FULL) ?
  1610. "queue-full" : ""));
  1611. printk("%s: err_raddr[%016llx] err_size[%u] err_cpu[%u]\n",
  1612. pfx,
  1613. ent->err_raddr, ent->err_size, ent->err_cpu);
  1614. show_regs(regs);
  1615. if ((cnt = atomic_read(ocnt)) != 0) {
  1616. atomic_set(ocnt, 0);
  1617. wmb();
  1618. printk("%s: Queue overflowed %d times.\n",
  1619. pfx, cnt);
  1620. }
  1621. }
  1622. /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
  1623. * Log the event and clear the first word of the entry.
  1624. */
  1625. void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
  1626. {
  1627. struct sun4v_error_entry *ent, local_copy;
  1628. struct trap_per_cpu *tb;
  1629. unsigned long paddr;
  1630. int cpu;
  1631. cpu = get_cpu();
  1632. tb = &trap_block[cpu];
  1633. paddr = tb->resum_kernel_buf_pa + offset;
  1634. ent = __va(paddr);
  1635. memcpy(&local_copy, ent, sizeof(struct sun4v_error_entry));
  1636. /* We have a local copy now, so release the entry. */
  1637. ent->err_handle = 0;
  1638. wmb();
  1639. put_cpu();
  1640. if (ent->err_type == SUN4V_ERR_TYPE_WARNING_RES) {
  1641. /* If err_type is 0x4, it's a powerdown request. Do
  1642. * not do the usual resumable error log because that
  1643. * makes it look like some abnormal error.
  1644. */
  1645. printk(KERN_INFO "Power down request...\n");
  1646. kill_cad_pid(SIGINT, 1);
  1647. return;
  1648. }
  1649. sun4v_log_error(regs, &local_copy, cpu,
  1650. KERN_ERR "RESUMABLE ERROR",
  1651. &sun4v_resum_oflow_cnt);
  1652. }
  1653. /* If we try to printk() we'll probably make matters worse, by trying
  1654. * to retake locks this cpu already holds or causing more errors. So
  1655. * just bump a counter, and we'll report these counter bumps above.
  1656. */
  1657. void sun4v_resum_overflow(struct pt_regs *regs)
  1658. {
  1659. atomic_inc(&sun4v_resum_oflow_cnt);
  1660. }
  1661. /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
  1662. * Log the event, clear the first word of the entry, and die.
  1663. */
  1664. void sun4v_nonresum_error(struct pt_regs *regs, unsigned long offset)
  1665. {
  1666. struct sun4v_error_entry *ent, local_copy;
  1667. struct trap_per_cpu *tb;
  1668. unsigned long paddr;
  1669. int cpu;
  1670. cpu = get_cpu();
  1671. tb = &trap_block[cpu];
  1672. paddr = tb->nonresum_kernel_buf_pa + offset;
  1673. ent = __va(paddr);
  1674. memcpy(&local_copy, ent, sizeof(struct sun4v_error_entry));
  1675. /* We have a local copy now, so release the entry. */
  1676. ent->err_handle = 0;
  1677. wmb();
  1678. put_cpu();
  1679. #ifdef CONFIG_PCI
  1680. /* Check for the special PCI poke sequence. */
  1681. if (pci_poke_in_progress && pci_poke_cpu == cpu) {
  1682. pci_poke_faulted = 1;
  1683. regs->tpc += 4;
  1684. regs->tnpc = regs->tpc + 4;
  1685. return;
  1686. }
  1687. #endif
  1688. sun4v_log_error(regs, &local_copy, cpu,
  1689. KERN_EMERG "NON-RESUMABLE ERROR",
  1690. &sun4v_nonresum_oflow_cnt);
  1691. panic("Non-resumable error.");
  1692. }
  1693. /* If we try to printk() we'll probably make matters worse, by trying
  1694. * to retake locks this cpu already holds or causing more errors. So
  1695. * just bump a counter, and we'll report these counter bumps above.
  1696. */
  1697. void sun4v_nonresum_overflow(struct pt_regs *regs)
  1698. {
  1699. /* XXX Actually even this can make not that much sense. Perhaps
  1700. * XXX we should just pull the plug and panic directly from here?
  1701. */
  1702. atomic_inc(&sun4v_nonresum_oflow_cnt);
  1703. }
  1704. unsigned long sun4v_err_itlb_vaddr;
  1705. unsigned long sun4v_err_itlb_ctx;
  1706. unsigned long sun4v_err_itlb_pte;
  1707. unsigned long sun4v_err_itlb_error;
  1708. void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
  1709. {
  1710. if (tl > 1)
  1711. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  1712. printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
  1713. regs->tpc, tl);
  1714. printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
  1715. printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
  1716. printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
  1717. (void *) regs->u_regs[UREG_I7]);
  1718. printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
  1719. "pte[%lx] error[%lx]\n",
  1720. sun4v_err_itlb_vaddr, sun4v_err_itlb_ctx,
  1721. sun4v_err_itlb_pte, sun4v_err_itlb_error);
  1722. prom_halt();
  1723. }
  1724. unsigned long sun4v_err_dtlb_vaddr;
  1725. unsigned long sun4v_err_dtlb_ctx;
  1726. unsigned long sun4v_err_dtlb_pte;
  1727. unsigned long sun4v_err_dtlb_error;
  1728. void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
  1729. {
  1730. if (tl > 1)
  1731. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  1732. printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
  1733. regs->tpc, tl);
  1734. printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
  1735. printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
  1736. printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
  1737. (void *) regs->u_regs[UREG_I7]);
  1738. printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
  1739. "pte[%lx] error[%lx]\n",
  1740. sun4v_err_dtlb_vaddr, sun4v_err_dtlb_ctx,
  1741. sun4v_err_dtlb_pte, sun4v_err_dtlb_error);
  1742. prom_halt();
  1743. }
  1744. void hypervisor_tlbop_error(unsigned long err, unsigned long op)
  1745. {
  1746. printk(KERN_CRIT "SUN4V: TLB hv call error %lu for op %lu\n",
  1747. err, op);
  1748. }
  1749. void hypervisor_tlbop_error_xcall(unsigned long err, unsigned long op)
  1750. {
  1751. printk(KERN_CRIT "SUN4V: XCALL TLB hv call error %lu for op %lu\n",
  1752. err, op);
  1753. }
  1754. void do_fpe_common(struct pt_regs *regs)
  1755. {
  1756. if (regs->tstate & TSTATE_PRIV) {
  1757. regs->tpc = regs->tnpc;
  1758. regs->tnpc += 4;
  1759. } else {
  1760. unsigned long fsr = current_thread_info()->xfsr[0];
  1761. siginfo_t info;
  1762. if (test_thread_flag(TIF_32BIT)) {
  1763. regs->tpc &= 0xffffffff;
  1764. regs->tnpc &= 0xffffffff;
  1765. }
  1766. info.si_signo = SIGFPE;
  1767. info.si_errno = 0;
  1768. info.si_addr = (void __user *)regs->tpc;
  1769. info.si_trapno = 0;
  1770. info.si_code = __SI_FAULT;
  1771. if ((fsr & 0x1c000) == (1 << 14)) {
  1772. if (fsr & 0x10)
  1773. info.si_code = FPE_FLTINV;
  1774. else if (fsr & 0x08)
  1775. info.si_code = FPE_FLTOVF;
  1776. else if (fsr & 0x04)
  1777. info.si_code = FPE_FLTUND;
  1778. else if (fsr & 0x02)
  1779. info.si_code = FPE_FLTDIV;
  1780. else if (fsr & 0x01)
  1781. info.si_code = FPE_FLTRES;
  1782. }
  1783. force_sig_info(SIGFPE, &info, current);
  1784. }
  1785. }
  1786. void do_fpieee(struct pt_regs *regs)
  1787. {
  1788. if (notify_die(DIE_TRAP, "fpu exception ieee", regs,
  1789. 0, 0x24, SIGFPE) == NOTIFY_STOP)
  1790. return;
  1791. do_fpe_common(regs);
  1792. }
  1793. extern int do_mathemu(struct pt_regs *, struct fpustate *);
  1794. void do_fpother(struct pt_regs *regs)
  1795. {
  1796. struct fpustate *f = FPUSTATE;
  1797. int ret = 0;
  1798. if (notify_die(DIE_TRAP, "fpu exception other", regs,
  1799. 0, 0x25, SIGFPE) == NOTIFY_STOP)
  1800. return;
  1801. switch ((current_thread_info()->xfsr[0] & 0x1c000)) {
  1802. case (2 << 14): /* unfinished_FPop */
  1803. case (3 << 14): /* unimplemented_FPop */
  1804. ret = do_mathemu(regs, f);
  1805. break;
  1806. }
  1807. if (ret)
  1808. return;
  1809. do_fpe_common(regs);
  1810. }
  1811. void do_tof(struct pt_regs *regs)
  1812. {
  1813. siginfo_t info;
  1814. if (notify_die(DIE_TRAP, "tagged arithmetic overflow", regs,
  1815. 0, 0x26, SIGEMT) == NOTIFY_STOP)
  1816. return;
  1817. if (regs->tstate & TSTATE_PRIV)
  1818. die_if_kernel("Penguin overflow trap from kernel mode", regs);
  1819. if (test_thread_flag(TIF_32BIT)) {
  1820. regs->tpc &= 0xffffffff;
  1821. regs->tnpc &= 0xffffffff;
  1822. }
  1823. info.si_signo = SIGEMT;
  1824. info.si_errno = 0;
  1825. info.si_code = EMT_TAGOVF;
  1826. info.si_addr = (void __user *)regs->tpc;
  1827. info.si_trapno = 0;
  1828. force_sig_info(SIGEMT, &info, current);
  1829. }
  1830. void do_div0(struct pt_regs *regs)
  1831. {
  1832. siginfo_t info;
  1833. if (notify_die(DIE_TRAP, "integer division by zero", regs,
  1834. 0, 0x28, SIGFPE) == NOTIFY_STOP)
  1835. return;
  1836. if (regs->tstate & TSTATE_PRIV)
  1837. die_if_kernel("TL0: Kernel divide by zero.", regs);
  1838. if (test_thread_flag(TIF_32BIT)) {
  1839. regs->tpc &= 0xffffffff;
  1840. regs->tnpc &= 0xffffffff;
  1841. }
  1842. info.si_signo = SIGFPE;
  1843. info.si_errno = 0;
  1844. info.si_code = FPE_INTDIV;
  1845. info.si_addr = (void __user *)regs->tpc;
  1846. info.si_trapno = 0;
  1847. force_sig_info(SIGFPE, &info, current);
  1848. }
  1849. static void instruction_dump(unsigned int *pc)
  1850. {
  1851. int i;
  1852. if ((((unsigned long) pc) & 3))
  1853. return;
  1854. printk("Instruction DUMP:");
  1855. for (i = -3; i < 6; i++)
  1856. printk("%c%08x%c",i?' ':'<',pc[i],i?' ':'>');
  1857. printk("\n");
  1858. }
  1859. static void user_instruction_dump(unsigned int __user *pc)
  1860. {
  1861. int i;
  1862. unsigned int buf[9];
  1863. if ((((unsigned long) pc) & 3))
  1864. return;
  1865. if (copy_from_user(buf, pc - 3, sizeof(buf)))
  1866. return;
  1867. printk("Instruction DUMP:");
  1868. for (i = 0; i < 9; i++)
  1869. printk("%c%08x%c",i==3?' ':'<',buf[i],i==3?' ':'>');
  1870. printk("\n");
  1871. }
  1872. void show_stack(struct task_struct *tsk, unsigned long *_ksp)
  1873. {
  1874. unsigned long fp, thread_base, ksp;
  1875. struct thread_info *tp;
  1876. int count = 0;
  1877. ksp = (unsigned long) _ksp;
  1878. if (!tsk)
  1879. tsk = current;
  1880. tp = task_thread_info(tsk);
  1881. if (ksp == 0UL) {
  1882. if (tsk == current)
  1883. asm("mov %%fp, %0" : "=r" (ksp));
  1884. else
  1885. ksp = tp->ksp;
  1886. }
  1887. if (tp == current_thread_info())
  1888. flushw_all();
  1889. fp = ksp + STACK_BIAS;
  1890. thread_base = (unsigned long) tp;
  1891. printk("Call Trace:\n");
  1892. do {
  1893. struct sparc_stackf *sf;
  1894. struct pt_regs *regs;
  1895. unsigned long pc;
  1896. if (!kstack_valid(tp, fp))
  1897. break;
  1898. sf = (struct sparc_stackf *) fp;
  1899. regs = (struct pt_regs *) (sf + 1);
  1900. if (kstack_is_trap_frame(tp, regs)) {
  1901. if (!(regs->tstate & TSTATE_PRIV))
  1902. break;
  1903. pc = regs->tpc;
  1904. fp = regs->u_regs[UREG_I6] + STACK_BIAS;
  1905. } else {
  1906. pc = sf->callers_pc;
  1907. fp = (unsigned long)sf->fp + STACK_BIAS;
  1908. }
  1909. printk(" [%016lx] %pS\n", pc, (void *) pc);
  1910. } while (++count < 16);
  1911. }
  1912. void dump_stack(void)
  1913. {
  1914. show_stack(current, NULL);
  1915. }
  1916. EXPORT_SYMBOL(dump_stack);
  1917. static inline int is_kernel_stack(struct task_struct *task,
  1918. struct reg_window *rw)
  1919. {
  1920. unsigned long rw_addr = (unsigned long) rw;
  1921. unsigned long thread_base, thread_end;
  1922. if (rw_addr < PAGE_OFFSET) {
  1923. if (task != &init_task)
  1924. return 0;
  1925. }
  1926. thread_base = (unsigned long) task_stack_page(task);
  1927. thread_end = thread_base + sizeof(union thread_union);
  1928. if (rw_addr >= thread_base &&
  1929. rw_addr < thread_end &&
  1930. !(rw_addr & 0x7UL))
  1931. return 1;
  1932. return 0;
  1933. }
  1934. static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
  1935. {
  1936. unsigned long fp = rw->ins[6];
  1937. if (!fp)
  1938. return NULL;
  1939. return (struct reg_window *) (fp + STACK_BIAS);
  1940. }
  1941. void die_if_kernel(char *str, struct pt_regs *regs)
  1942. {
  1943. static int die_counter;
  1944. int count = 0;
  1945. /* Amuse the user. */
  1946. printk(
  1947. " \\|/ ____ \\|/\n"
  1948. " \"@'/ .. \\`@\"\n"
  1949. " /_| \\__/ |_\\\n"
  1950. " \\__U_/\n");
  1951. printk("%s(%d): %s [#%d]\n", current->comm, task_pid_nr(current), str, ++die_counter);
  1952. notify_die(DIE_OOPS, str, regs, 0, 255, SIGSEGV);
  1953. __asm__ __volatile__("flushw");
  1954. show_regs(regs);
  1955. add_taint(TAINT_DIE);
  1956. if (regs->tstate & TSTATE_PRIV) {
  1957. struct reg_window *rw = (struct reg_window *)
  1958. (regs->u_regs[UREG_FP] + STACK_BIAS);
  1959. /* Stop the back trace when we hit userland or we
  1960. * find some badly aligned kernel stack.
  1961. */
  1962. while (rw &&
  1963. count++ < 30&&
  1964. is_kernel_stack(current, rw)) {
  1965. printk("Caller[%016lx]: %pS\n", rw->ins[7],
  1966. (void *) rw->ins[7]);
  1967. rw = kernel_stack_up(rw);
  1968. }
  1969. instruction_dump ((unsigned int *) regs->tpc);
  1970. } else {
  1971. if (test_thread_flag(TIF_32BIT)) {
  1972. regs->tpc &= 0xffffffff;
  1973. regs->tnpc &= 0xffffffff;
  1974. }
  1975. user_instruction_dump ((unsigned int __user *) regs->tpc);
  1976. }
  1977. if (regs->tstate & TSTATE_PRIV)
  1978. do_exit(SIGKILL);
  1979. do_exit(SIGSEGV);
  1980. }
  1981. EXPORT_SYMBOL(die_if_kernel);
  1982. #define VIS_OPCODE_MASK ((0x3 << 30) | (0x3f << 19))
  1983. #define VIS_OPCODE_VAL ((0x2 << 30) | (0x36 << 19))
  1984. extern int handle_popc(u32 insn, struct pt_regs *regs);
  1985. extern int handle_ldf_stq(u32 insn, struct pt_regs *regs);
  1986. void do_illegal_instruction(struct pt_regs *regs)
  1987. {
  1988. unsigned long pc = regs->tpc;
  1989. unsigned long tstate = regs->tstate;
  1990. u32 insn;
  1991. siginfo_t info;
  1992. if (notify_die(DIE_TRAP, "illegal instruction", regs,
  1993. 0, 0x10, SIGILL) == NOTIFY_STOP)
  1994. return;
  1995. if (tstate & TSTATE_PRIV)
  1996. die_if_kernel("Kernel illegal instruction", regs);
  1997. if (test_thread_flag(TIF_32BIT))
  1998. pc = (u32)pc;
  1999. if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
  2000. if ((insn & 0xc1ffc000) == 0x81700000) /* POPC */ {
  2001. if (handle_popc(insn, regs))
  2002. return;
  2003. } else if ((insn & 0xc1580000) == 0xc1100000) /* LDQ/STQ */ {
  2004. if (handle_ldf_stq(insn, regs))
  2005. return;
  2006. } else if (tlb_type == hypervisor) {
  2007. if ((insn & VIS_OPCODE_MASK) == VIS_OPCODE_VAL) {
  2008. if (!vis_emul(regs, insn))
  2009. return;
  2010. } else {
  2011. struct fpustate *f = FPUSTATE;
  2012. /* XXX maybe verify XFSR bits like
  2013. * XXX do_fpother() does?
  2014. */
  2015. if (do_mathemu(regs, f))
  2016. return;
  2017. }
  2018. }
  2019. }
  2020. info.si_signo = SIGILL;
  2021. info.si_errno = 0;
  2022. info.si_code = ILL_ILLOPC;
  2023. info.si_addr = (void __user *)pc;
  2024. info.si_trapno = 0;
  2025. force_sig_info(SIGILL, &info, current);
  2026. }
  2027. extern void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn);
  2028. void mem_address_unaligned(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr)
  2029. {
  2030. siginfo_t info;
  2031. if (notify_die(DIE_TRAP, "memory address unaligned", regs,
  2032. 0, 0x34, SIGSEGV) == NOTIFY_STOP)
  2033. return;
  2034. if (regs->tstate & TSTATE_PRIV) {
  2035. kernel_unaligned_trap(regs, *((unsigned int *)regs->tpc));
  2036. return;
  2037. }
  2038. info.si_signo = SIGBUS;
  2039. info.si_errno = 0;
  2040. info.si_code = BUS_ADRALN;
  2041. info.si_addr = (void __user *)sfar;
  2042. info.si_trapno = 0;
  2043. force_sig_info(SIGBUS, &info, current);
  2044. }
  2045. void sun4v_do_mna(struct pt_regs *regs, unsigned long addr, unsigned long type_ctx)
  2046. {
  2047. siginfo_t info;
  2048. if (notify_die(DIE_TRAP, "memory address unaligned", regs,
  2049. 0, 0x34, SIGSEGV) == NOTIFY_STOP)
  2050. return;
  2051. if (regs->tstate & TSTATE_PRIV) {
  2052. kernel_unaligned_trap(regs, *((unsigned int *)regs->tpc));
  2053. return;
  2054. }
  2055. info.si_signo = SIGBUS;
  2056. info.si_errno = 0;
  2057. info.si_code = BUS_ADRALN;
  2058. info.si_addr = (void __user *) addr;
  2059. info.si_trapno = 0;
  2060. force_sig_info(SIGBUS, &info, current);
  2061. }
  2062. void do_privop(struct pt_regs *regs)
  2063. {
  2064. siginfo_t info;
  2065. if (notify_die(DIE_TRAP, "privileged operation", regs,
  2066. 0, 0x11, SIGILL) == NOTIFY_STOP)
  2067. return;
  2068. if (test_thread_flag(TIF_32BIT)) {
  2069. regs->tpc &= 0xffffffff;
  2070. regs->tnpc &= 0xffffffff;
  2071. }
  2072. info.si_signo = SIGILL;
  2073. info.si_errno = 0;
  2074. info.si_code = ILL_PRVOPC;
  2075. info.si_addr = (void __user *)regs->tpc;
  2076. info.si_trapno = 0;
  2077. force_sig_info(SIGILL, &info, current);
  2078. }
  2079. void do_privact(struct pt_regs *regs)
  2080. {
  2081. do_privop(regs);
  2082. }
  2083. /* Trap level 1 stuff or other traps we should never see... */
  2084. void do_cee(struct pt_regs *regs)
  2085. {
  2086. die_if_kernel("TL0: Cache Error Exception", regs);
  2087. }
  2088. void do_cee_tl1(struct pt_regs *regs)
  2089. {
  2090. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2091. die_if_kernel("TL1: Cache Error Exception", regs);
  2092. }
  2093. void do_dae_tl1(struct pt_regs *regs)
  2094. {
  2095. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2096. die_if_kernel("TL1: Data Access Exception", regs);
  2097. }
  2098. void do_iae_tl1(struct pt_regs *regs)
  2099. {
  2100. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2101. die_if_kernel("TL1: Instruction Access Exception", regs);
  2102. }
  2103. void do_div0_tl1(struct pt_regs *regs)
  2104. {
  2105. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2106. die_if_kernel("TL1: DIV0 Exception", regs);
  2107. }
  2108. void do_fpdis_tl1(struct pt_regs *regs)
  2109. {
  2110. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2111. die_if_kernel("TL1: FPU Disabled", regs);
  2112. }
  2113. void do_fpieee_tl1(struct pt_regs *regs)
  2114. {
  2115. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2116. die_if_kernel("TL1: FPU IEEE Exception", regs);
  2117. }
  2118. void do_fpother_tl1(struct pt_regs *regs)
  2119. {
  2120. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2121. die_if_kernel("TL1: FPU Other Exception", regs);
  2122. }
  2123. void do_ill_tl1(struct pt_regs *regs)
  2124. {
  2125. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2126. die_if_kernel("TL1: Illegal Instruction Exception", regs);
  2127. }
  2128. void do_irq_tl1(struct pt_regs *regs)
  2129. {
  2130. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2131. die_if_kernel("TL1: IRQ Exception", regs);
  2132. }
  2133. void do_lddfmna_tl1(struct pt_regs *regs)
  2134. {
  2135. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2136. die_if_kernel("TL1: LDDF Exception", regs);
  2137. }
  2138. void do_stdfmna_tl1(struct pt_regs *regs)
  2139. {
  2140. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2141. die_if_kernel("TL1: STDF Exception", regs);
  2142. }
  2143. void do_paw(struct pt_regs *regs)
  2144. {
  2145. die_if_kernel("TL0: Phys Watchpoint Exception", regs);
  2146. }
  2147. void do_paw_tl1(struct pt_regs *regs)
  2148. {
  2149. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2150. die_if_kernel("TL1: Phys Watchpoint Exception", regs);
  2151. }
  2152. void do_vaw(struct pt_regs *regs)
  2153. {
  2154. die_if_kernel("TL0: Virt Watchpoint Exception", regs);
  2155. }
  2156. void do_vaw_tl1(struct pt_regs *regs)
  2157. {
  2158. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2159. die_if_kernel("TL1: Virt Watchpoint Exception", regs);
  2160. }
  2161. void do_tof_tl1(struct pt_regs *regs)
  2162. {
  2163. dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
  2164. die_if_kernel("TL1: Tag Overflow Exception", regs);
  2165. }
  2166. void do_getpsr(struct pt_regs *regs)
  2167. {
  2168. regs->u_regs[UREG_I0] = tstate_to_psr(regs->tstate);
  2169. regs->tpc = regs->tnpc;
  2170. regs->tnpc += 4;
  2171. if (test_thread_flag(TIF_32BIT)) {
  2172. regs->tpc &= 0xffffffff;
  2173. regs->tnpc &= 0xffffffff;
  2174. }
  2175. }
  2176. struct trap_per_cpu trap_block[NR_CPUS];
  2177. /* This can get invoked before sched_init() so play it super safe
  2178. * and use hard_smp_processor_id().
  2179. */
  2180. void notrace init_cur_cpu_trap(struct thread_info *t)
  2181. {
  2182. int cpu = hard_smp_processor_id();
  2183. struct trap_per_cpu *p = &trap_block[cpu];
  2184. p->thread = t;
  2185. p->pgd_paddr = 0;
  2186. }
  2187. extern void thread_info_offsets_are_bolixed_dave(void);
  2188. extern void trap_per_cpu_offsets_are_bolixed_dave(void);
  2189. extern void tsb_config_offsets_are_bolixed_dave(void);
  2190. /* Only invoked on boot processor. */
  2191. void __init trap_init(void)
  2192. {
  2193. /* Compile time sanity check. */
  2194. if (TI_TASK != offsetof(struct thread_info, task) ||
  2195. TI_FLAGS != offsetof(struct thread_info, flags) ||
  2196. TI_CPU != offsetof(struct thread_info, cpu) ||
  2197. TI_FPSAVED != offsetof(struct thread_info, fpsaved) ||
  2198. TI_KSP != offsetof(struct thread_info, ksp) ||
  2199. TI_FAULT_ADDR != offsetof(struct thread_info, fault_address) ||
  2200. TI_KREGS != offsetof(struct thread_info, kregs) ||
  2201. TI_UTRAPS != offsetof(struct thread_info, utraps) ||
  2202. TI_EXEC_DOMAIN != offsetof(struct thread_info, exec_domain) ||
  2203. TI_REG_WINDOW != offsetof(struct thread_info, reg_window) ||
  2204. TI_RWIN_SPTRS != offsetof(struct thread_info, rwbuf_stkptrs) ||
  2205. TI_GSR != offsetof(struct thread_info, gsr) ||
  2206. TI_XFSR != offsetof(struct thread_info, xfsr) ||
  2207. TI_USER_CNTD0 != offsetof(struct thread_info, user_cntd0) ||
  2208. TI_USER_CNTD1 != offsetof(struct thread_info, user_cntd1) ||
  2209. TI_KERN_CNTD0 != offsetof(struct thread_info, kernel_cntd0) ||
  2210. TI_KERN_CNTD1 != offsetof(struct thread_info, kernel_cntd1) ||
  2211. TI_PCR != offsetof(struct thread_info, pcr_reg) ||
  2212. TI_PRE_COUNT != offsetof(struct thread_info, preempt_count) ||
  2213. TI_NEW_CHILD != offsetof(struct thread_info, new_child) ||
  2214. TI_SYS_NOERROR != offsetof(struct thread_info, syscall_noerror) ||
  2215. TI_RESTART_BLOCK != offsetof(struct thread_info, restart_block) ||
  2216. TI_KUNA_REGS != offsetof(struct thread_info, kern_una_regs) ||
  2217. TI_KUNA_INSN != offsetof(struct thread_info, kern_una_insn) ||
  2218. TI_FPREGS != offsetof(struct thread_info, fpregs) ||
  2219. (TI_FPREGS & (64 - 1)))
  2220. thread_info_offsets_are_bolixed_dave();
  2221. if (TRAP_PER_CPU_THREAD != offsetof(struct trap_per_cpu, thread) ||
  2222. (TRAP_PER_CPU_PGD_PADDR !=
  2223. offsetof(struct trap_per_cpu, pgd_paddr)) ||
  2224. (TRAP_PER_CPU_CPU_MONDO_PA !=
  2225. offsetof(struct trap_per_cpu, cpu_mondo_pa)) ||
  2226. (TRAP_PER_CPU_DEV_MONDO_PA !=
  2227. offsetof(struct trap_per_cpu, dev_mondo_pa)) ||
  2228. (TRAP_PER_CPU_RESUM_MONDO_PA !=
  2229. offsetof(struct trap_per_cpu, resum_mondo_pa)) ||
  2230. (TRAP_PER_CPU_RESUM_KBUF_PA !=
  2231. offsetof(struct trap_per_cpu, resum_kernel_buf_pa)) ||
  2232. (TRAP_PER_CPU_NONRESUM_MONDO_PA !=
  2233. offsetof(struct trap_per_cpu, nonresum_mondo_pa)) ||
  2234. (TRAP_PER_CPU_NONRESUM_KBUF_PA !=
  2235. offsetof(struct trap_per_cpu, nonresum_kernel_buf_pa)) ||
  2236. (TRAP_PER_CPU_FAULT_INFO !=
  2237. offsetof(struct trap_per_cpu, fault_info)) ||
  2238. (TRAP_PER_CPU_CPU_MONDO_BLOCK_PA !=
  2239. offsetof(struct trap_per_cpu, cpu_mondo_block_pa)) ||
  2240. (TRAP_PER_CPU_CPU_LIST_PA !=
  2241. offsetof(struct trap_per_cpu, cpu_list_pa)) ||
  2242. (TRAP_PER_CPU_TSB_HUGE !=
  2243. offsetof(struct trap_per_cpu, tsb_huge)) ||
  2244. (TRAP_PER_CPU_TSB_HUGE_TEMP !=
  2245. offsetof(struct trap_per_cpu, tsb_huge_temp)) ||
  2246. (TRAP_PER_CPU_IRQ_WORKLIST_PA !=
  2247. offsetof(struct trap_per_cpu, irq_worklist_pa)) ||
  2248. (TRAP_PER_CPU_CPU_MONDO_QMASK !=
  2249. offsetof(struct trap_per_cpu, cpu_mondo_qmask)) ||
  2250. (TRAP_PER_CPU_DEV_MONDO_QMASK !=
  2251. offsetof(struct trap_per_cpu, dev_mondo_qmask)) ||
  2252. (TRAP_PER_CPU_RESUM_QMASK !=
  2253. offsetof(struct trap_per_cpu, resum_qmask)) ||
  2254. (TRAP_PER_CPU_NONRESUM_QMASK !=
  2255. offsetof(struct trap_per_cpu, nonresum_qmask)))
  2256. trap_per_cpu_offsets_are_bolixed_dave();
  2257. if ((TSB_CONFIG_TSB !=
  2258. offsetof(struct tsb_config, tsb)) ||
  2259. (TSB_CONFIG_RSS_LIMIT !=
  2260. offsetof(struct tsb_config, tsb_rss_limit)) ||
  2261. (TSB_CONFIG_NENTRIES !=
  2262. offsetof(struct tsb_config, tsb_nentries)) ||
  2263. (TSB_CONFIG_REG_VAL !=
  2264. offsetof(struct tsb_config, tsb_reg_val)) ||
  2265. (TSB_CONFIG_MAP_VADDR !=
  2266. offsetof(struct tsb_config, tsb_map_vaddr)) ||
  2267. (TSB_CONFIG_MAP_PTE !=
  2268. offsetof(struct tsb_config, tsb_map_pte)))
  2269. tsb_config_offsets_are_bolixed_dave();
  2270. /* Attach to the address space of init_task. On SMP we
  2271. * do this in smp.c:smp_callin for other cpus.
  2272. */
  2273. atomic_inc(&init_mm.mm_count);
  2274. current->active_mm = &init_mm;
  2275. }