traps.c 74 KB

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