traps.c 75 KB

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