traps.c 75 KB

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