traps.c 75 KB

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