traps.c 74 KB

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