traps.c 75 KB

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