traps.c 73 KB

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