traps.c 74 KB

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