traps_64.c 74 KB

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