11772Sjl139090 /* 21772Sjl139090 * CDDL HEADER START 31772Sjl139090 * 41772Sjl139090 * The contents of this file are subject to the terms of the 51772Sjl139090 * Common Development and Distribution License (the "License"). 61772Sjl139090 * You may not use this file except in compliance with the License. 71772Sjl139090 * 81772Sjl139090 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91772Sjl139090 * or http://www.opensolaris.org/os/licensing. 101772Sjl139090 * See the License for the specific language governing permissions 111772Sjl139090 * and limitations under the License. 121772Sjl139090 * 131772Sjl139090 * When distributing Covered Code, include this CDDL HEADER in each 141772Sjl139090 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151772Sjl139090 * If applicable, add the following below this CDDL HEADER, with the 161772Sjl139090 * fields enclosed by brackets "[]" replaced with your own identifying 171772Sjl139090 * information: Portions Copyright [yyyy] [name of copyright owner] 181772Sjl139090 * 191772Sjl139090 * CDDL HEADER END 201772Sjl139090 */ 211772Sjl139090 /* 221772Sjl139090 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 231772Sjl139090 * Use is subject to license terms. 241772Sjl139090 */ 251772Sjl139090 261772Sjl139090 #pragma ident "%Z%%M% %I% %E% SMI" 271772Sjl139090 281772Sjl139090 #include <sys/types.h> 291772Sjl139090 #include <sys/systm.h> 301772Sjl139090 #include <sys/ddi.h> 311772Sjl139090 #include <sys/sysmacros.h> 321772Sjl139090 #include <sys/archsystm.h> 331772Sjl139090 #include <sys/vmsystm.h> 341772Sjl139090 #include <sys/machparam.h> 351772Sjl139090 #include <sys/machsystm.h> 361772Sjl139090 #include <sys/machthread.h> 371772Sjl139090 #include <sys/cpu.h> 381772Sjl139090 #include <sys/cmp.h> 391772Sjl139090 #include <sys/elf_SPARC.h> 401772Sjl139090 #include <vm/vm_dep.h> 411772Sjl139090 #include <vm/hat_sfmmu.h> 421772Sjl139090 #include <vm/seg_kpm.h> 431772Sjl139090 #include <sys/cpuvar.h> 441772Sjl139090 #include <sys/opl_olympus_regs.h> 451772Sjl139090 #include <sys/opl_module.h> 461772Sjl139090 #include <sys/async.h> 471772Sjl139090 #include <sys/cmn_err.h> 481772Sjl139090 #include <sys/debug.h> 491772Sjl139090 #include <sys/dditypes.h> 501772Sjl139090 #include <sys/cpu_module.h> 511772Sjl139090 #include <sys/sysmacros.h> 521772Sjl139090 #include <sys/intreg.h> 531772Sjl139090 #include <sys/clock.h> 541772Sjl139090 #include <sys/platform_module.h> 551772Sjl139090 #include <sys/ontrap.h> 561772Sjl139090 #include <sys/panic.h> 571772Sjl139090 #include <sys/memlist.h> 581772Sjl139090 #include <sys/ndifm.h> 591772Sjl139090 #include <sys/ddifm.h> 601772Sjl139090 #include <sys/fm/protocol.h> 611772Sjl139090 #include <sys/fm/util.h> 621772Sjl139090 #include <sys/fm/cpu/SPARC64-VI.h> 631772Sjl139090 #include <sys/dtrace.h> 641772Sjl139090 #include <sys/watchpoint.h> 651772Sjl139090 #include <sys/promif.h> 661772Sjl139090 671772Sjl139090 /* 681772Sjl139090 * Internal functions. 691772Sjl139090 */ 701772Sjl139090 static int cpu_sync_log_err(void *flt); 711772Sjl139090 static void cpu_payload_add_aflt(struct async_flt *, nvlist_t *, nvlist_t *); 721772Sjl139090 static void opl_cpu_sync_error(struct regs *, ulong_t, ulong_t, uint_t, uint_t); 731772Sjl139090 static int cpu_flt_in_memory(opl_async_flt_t *, uint64_t); 741772Sjl139090 751772Sjl139090 /* 761772Sjl139090 * Error counters resetting interval. 771772Sjl139090 */ 781772Sjl139090 static int opl_async_check_interval = 60; /* 1 min */ 791772Sjl139090 802241Shuah uint_t cpu_impl_dual_pgsz = 1; 811772Sjl139090 821772Sjl139090 /* 831772Sjl139090 * PA[22:0] represent Displacement in Jupiter 841772Sjl139090 * configuration space. 851772Sjl139090 */ 861772Sjl139090 uint_t root_phys_addr_lo_mask = 0x7fffffu; 871772Sjl139090 881772Sjl139090 /* 891772Sjl139090 * set in /etc/system to control logging of user BERR/TO's 901772Sjl139090 */ 911772Sjl139090 int cpu_berr_to_verbose = 0; 921772Sjl139090 931772Sjl139090 static int min_ecache_size; 941772Sjl139090 static uint_t priv_hcl_1; 951772Sjl139090 static uint_t priv_hcl_2; 961772Sjl139090 static uint_t priv_hcl_4; 971772Sjl139090 static uint_t priv_hcl_8; 981772Sjl139090 991772Sjl139090 /* 1001772Sjl139090 * Olympus error log 1011772Sjl139090 */ 1021772Sjl139090 static opl_errlog_t *opl_err_log; 1031772Sjl139090 1041772Sjl139090 /* 1051772Sjl139090 * UE is classified into four classes (MEM, CHANNEL, CPU, PATH). 1061772Sjl139090 * No any other ecc_type_info insertion is allowed in between the following 1071772Sjl139090 * four UE classess. 1081772Sjl139090 */ 1091772Sjl139090 ecc_type_to_info_t ecc_type_to_info[] = { 1101772Sjl139090 SFSR_UE, "UE ", (OPL_ECC_SYNC_TRAP), OPL_CPU_SYNC_UE, 1111772Sjl139090 "Uncorrectable ECC", FM_EREPORT_PAYLOAD_SYNC, 1121772Sjl139090 FM_EREPORT_CPU_UE_MEM, 1131772Sjl139090 SFSR_UE, "UE ", (OPL_ECC_SYNC_TRAP), OPL_CPU_SYNC_UE, 1141772Sjl139090 "Uncorrectable ECC", FM_EREPORT_PAYLOAD_SYNC, 1151772Sjl139090 FM_EREPORT_CPU_UE_CHANNEL, 1161772Sjl139090 SFSR_UE, "UE ", (OPL_ECC_SYNC_TRAP), OPL_CPU_SYNC_UE, 1171772Sjl139090 "Uncorrectable ECC", FM_EREPORT_PAYLOAD_SYNC, 1181772Sjl139090 FM_EREPORT_CPU_UE_CPU, 1191772Sjl139090 SFSR_UE, "UE ", (OPL_ECC_SYNC_TRAP), OPL_CPU_SYNC_UE, 1201772Sjl139090 "Uncorrectable ECC", FM_EREPORT_PAYLOAD_SYNC, 1211772Sjl139090 FM_EREPORT_CPU_UE_PATH, 1221772Sjl139090 SFSR_BERR, "BERR ", (OPL_ECC_SYNC_TRAP), OPL_CPU_SYNC_OTHERS, 1231772Sjl139090 "Bus Error", FM_EREPORT_PAYLOAD_SYNC, 1241772Sjl139090 FM_EREPORT_CPU_BERR, 1251772Sjl139090 SFSR_TO, "TO ", (OPL_ECC_SYNC_TRAP), OPL_CPU_SYNC_OTHERS, 1261772Sjl139090 "Bus Timeout", FM_EREPORT_PAYLOAD_SYNC, 1271772Sjl139090 FM_EREPORT_CPU_BTO, 1281772Sjl139090 SFSR_TLB_MUL, "TLB_MUL ", (OPL_ECC_SYNC_TRAP), OPL_CPU_SYNC_OTHERS, 1291772Sjl139090 "TLB MultiHit", FM_EREPORT_PAYLOAD_SYNC, 1301772Sjl139090 FM_EREPORT_CPU_MTLB, 1311772Sjl139090 SFSR_TLB_PRT, "TLB_PRT ", (OPL_ECC_SYNC_TRAP), OPL_CPU_SYNC_OTHERS, 1321772Sjl139090 "TLB Parity", FM_EREPORT_PAYLOAD_SYNC, 1331772Sjl139090 FM_EREPORT_CPU_TLBP, 1341772Sjl139090 1351772Sjl139090 UGESR_IAUG_CRE, "IAUG_CRE", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1361772Sjl139090 "IAUG CRE", FM_EREPORT_PAYLOAD_URGENT, 1371772Sjl139090 FM_EREPORT_CPU_CRE, 1381772Sjl139090 UGESR_IAUG_TSBCTXT, "IAUG_TSBCTXT", 1391772Sjl139090 OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1401772Sjl139090 "IAUG TSBCTXT", FM_EREPORT_PAYLOAD_URGENT, 1411772Sjl139090 FM_EREPORT_CPU_TSBCTX, 1421772Sjl139090 UGESR_IUG_TSBP, "IUG_TSBP", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1431772Sjl139090 "IUG TSBP", FM_EREPORT_PAYLOAD_URGENT, 1441772Sjl139090 FM_EREPORT_CPU_TSBP, 1451772Sjl139090 UGESR_IUG_PSTATE, "IUG_PSTATE", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1461772Sjl139090 "IUG PSTATE", FM_EREPORT_PAYLOAD_URGENT, 1471772Sjl139090 FM_EREPORT_CPU_PSTATE, 1481772Sjl139090 UGESR_IUG_TSTATE, "IUG_TSTATE", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1491772Sjl139090 "IUG TSTATE", FM_EREPORT_PAYLOAD_URGENT, 1501772Sjl139090 FM_EREPORT_CPU_TSTATE, 1511772Sjl139090 UGESR_IUG_F, "IUG_F", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1521772Sjl139090 "IUG FREG", FM_EREPORT_PAYLOAD_URGENT, 1531772Sjl139090 FM_EREPORT_CPU_IUG_F, 1541772Sjl139090 UGESR_IUG_R, "IUG_R", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1551772Sjl139090 "IUG RREG", FM_EREPORT_PAYLOAD_URGENT, 1561772Sjl139090 FM_EREPORT_CPU_IUG_R, 1571772Sjl139090 UGESR_AUG_SDC, "AUG_SDC", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1581772Sjl139090 "AUG SDC", FM_EREPORT_PAYLOAD_URGENT, 1591772Sjl139090 FM_EREPORT_CPU_SDC, 1601772Sjl139090 UGESR_IUG_WDT, "IUG_WDT", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1611772Sjl139090 "IUG WDT", FM_EREPORT_PAYLOAD_URGENT, 1621772Sjl139090 FM_EREPORT_CPU_WDT, 1631772Sjl139090 UGESR_IUG_DTLB, "IUG_DTLB", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1641772Sjl139090 "IUG DTLB", FM_EREPORT_PAYLOAD_URGENT, 1651772Sjl139090 FM_EREPORT_CPU_DTLB, 1661772Sjl139090 UGESR_IUG_ITLB, "IUG_ITLB", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1671772Sjl139090 "IUG ITLB", FM_EREPORT_PAYLOAD_URGENT, 1681772Sjl139090 FM_EREPORT_CPU_ITLB, 1691772Sjl139090 UGESR_IUG_COREERR, "IUG_COREERR", 1701772Sjl139090 OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1711772Sjl139090 "IUG COREERR", FM_EREPORT_PAYLOAD_URGENT, 1721772Sjl139090 FM_EREPORT_CPU_CORE, 1731772Sjl139090 UGESR_MULTI_DAE, "MULTI_DAE", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1741772Sjl139090 "MULTI DAE", FM_EREPORT_PAYLOAD_URGENT, 1751772Sjl139090 FM_EREPORT_CPU_DAE, 1761772Sjl139090 UGESR_MULTI_IAE, "MULTI_IAE", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1771772Sjl139090 "MULTI IAE", FM_EREPORT_PAYLOAD_URGENT, 1781772Sjl139090 FM_EREPORT_CPU_IAE, 1791772Sjl139090 UGESR_MULTI_UGE, "MULTI_UGE", OPL_ECC_URGENT_TRAP, OPL_CPU_URGENT, 1801772Sjl139090 "MULTI UGE", FM_EREPORT_PAYLOAD_URGENT, 1811772Sjl139090 FM_EREPORT_CPU_UGE, 1821772Sjl139090 0, NULL, 0, 0, 1831772Sjl139090 NULL, 0, 0, 1841772Sjl139090 }; 1851772Sjl139090 1861772Sjl139090 int (*p2get_mem_info)(int synd_code, uint64_t paddr, 1871772Sjl139090 uint64_t *mem_sizep, uint64_t *seg_sizep, uint64_t *bank_sizep, 1881772Sjl139090 int *segsp, int *banksp, int *mcidp); 1891772Sjl139090 1901772Sjl139090 1911772Sjl139090 /* 1921772Sjl139090 * Setup trap handlers for 0xA, 0x32, 0x40 trap types. 1931772Sjl139090 */ 1941772Sjl139090 void 1951772Sjl139090 cpu_init_trap(void) 1961772Sjl139090 { 1971772Sjl139090 OPL_SET_TRAP(tt0_iae, opl_serr_instr); 1981772Sjl139090 OPL_SET_TRAP(tt1_iae, opl_serr_instr); 1991772Sjl139090 OPL_SET_TRAP(tt0_dae, opl_serr_instr); 2001772Sjl139090 OPL_SET_TRAP(tt1_dae, opl_serr_instr); 2011772Sjl139090 OPL_SET_TRAP(tt0_asdat, opl_ugerr_instr); 2021772Sjl139090 OPL_SET_TRAP(tt1_asdat, opl_ugerr_instr); 2031772Sjl139090 } 2041772Sjl139090 2051772Sjl139090 static int 2061772Sjl139090 getintprop(pnode_t node, char *name, int deflt) 2071772Sjl139090 { 2081772Sjl139090 int value; 2091772Sjl139090 2101772Sjl139090 switch (prom_getproplen(node, name)) { 2111772Sjl139090 case sizeof (int): 2121772Sjl139090 (void) prom_getprop(node, name, (caddr_t)&value); 2131772Sjl139090 break; 2141772Sjl139090 2151772Sjl139090 default: 2161772Sjl139090 value = deflt; 2171772Sjl139090 break; 2181772Sjl139090 } 2191772Sjl139090 2201772Sjl139090 return (value); 2211772Sjl139090 } 2221772Sjl139090 2231772Sjl139090 /* 2241772Sjl139090 * Set the magic constants of the implementation. 2251772Sjl139090 */ 2261772Sjl139090 /*ARGSUSED*/ 2271772Sjl139090 void 2281772Sjl139090 cpu_fiximp(pnode_t dnode) 2291772Sjl139090 { 2301772Sjl139090 int i, a; 2311772Sjl139090 extern int vac_size, vac_shift; 2321772Sjl139090 extern uint_t vac_mask; 2331772Sjl139090 2341772Sjl139090 static struct { 2351772Sjl139090 char *name; 2361772Sjl139090 int *var; 2371772Sjl139090 int defval; 2381772Sjl139090 } prop[] = { 2391772Sjl139090 "l1-dcache-size", &dcache_size, OPL_DCACHE_SIZE, 2401772Sjl139090 "l1-dcache-line-size", &dcache_linesize, OPL_DCACHE_LSIZE, 2411772Sjl139090 "l1-icache-size", &icache_size, OPL_ICACHE_SIZE, 2421772Sjl139090 "l1-icache-line-size", &icache_linesize, OPL_ICACHE_LSIZE, 2431772Sjl139090 "l2-cache-size", &ecache_size, OPL_ECACHE_SIZE, 2441772Sjl139090 "l2-cache-line-size", &ecache_alignsize, OPL_ECACHE_LSIZE, 2451772Sjl139090 "l2-cache-associativity", &ecache_associativity, OPL_ECACHE_NWAY 2461772Sjl139090 }; 2471772Sjl139090 2481772Sjl139090 for (i = 0; i < sizeof (prop) / sizeof (prop[0]); i++) 2491772Sjl139090 *prop[i].var = getintprop(dnode, prop[i].name, prop[i].defval); 2501772Sjl139090 2511772Sjl139090 ecache_setsize = ecache_size / ecache_associativity; 2521772Sjl139090 2531772Sjl139090 vac_size = OPL_VAC_SIZE; 2541772Sjl139090 vac_mask = MMU_PAGEMASK & (vac_size - 1); 2551772Sjl139090 i = 0; a = vac_size; 2561772Sjl139090 while (a >>= 1) 2571772Sjl139090 ++i; 2581772Sjl139090 vac_shift = i; 2591772Sjl139090 shm_alignment = vac_size; 2601772Sjl139090 vac = 1; 2611772Sjl139090 } 2621772Sjl139090 2632149Shyw #ifdef OLYMPUS_C_REV_B_ERRATA_XCALL 2642149Shyw /* 2652149Shyw * Quick and dirty way to redefine locally in 2662149Shyw * OPL the value of IDSR_BN_SETS to 31 instead 2672149Shyw * of the standard 32 value. This is to workaround 2682149Shyw * REV_B of Olympus_c processor's problem in handling 2692149Shyw * more than 31 xcall broadcast. 2702149Shyw */ 2712149Shyw #undef IDSR_BN_SETS 2722149Shyw #define IDSR_BN_SETS 31 2732149Shyw #endif /* OLYMPUS_C_REV_B_ERRATA_XCALL */ 2742149Shyw 2751772Sjl139090 void 2761772Sjl139090 send_mondo_set(cpuset_t set) 2771772Sjl139090 { 2781772Sjl139090 int lo, busy, nack, shipped = 0; 2791772Sjl139090 uint16_t i, cpuids[IDSR_BN_SETS]; 2801772Sjl139090 uint64_t idsr, nackmask = 0, busymask, curnack, curbusy; 2811772Sjl139090 uint64_t starttick, endtick, tick, lasttick; 2821772Sjl139090 #if (NCPU > IDSR_BN_SETS) 2831772Sjl139090 int index = 0; 2841772Sjl139090 int ncpuids = 0; 2851772Sjl139090 #endif 2861888Shyw #ifdef OLYMPUS_C_REV_A_ERRATA_XCALL 2871772Sjl139090 int bn_sets = IDSR_BN_SETS; 2881772Sjl139090 uint64_t ver; 2891772Sjl139090 2901772Sjl139090 ASSERT(NCPU > bn_sets); 2911772Sjl139090 #endif 2921772Sjl139090 2931772Sjl139090 ASSERT(!CPUSET_ISNULL(set)); 2941772Sjl139090 starttick = lasttick = gettick(); 2951772Sjl139090 2961888Shyw #ifdef OLYMPUS_C_REV_A_ERRATA_XCALL 2971772Sjl139090 ver = ultra_getver(); 2981772Sjl139090 if (((ULTRA_VER_IMPL(ver)) == OLYMPUS_C_IMPL) && 2991772Sjl139090 ((OLYMPUS_REV_MASK(ver)) == OLYMPUS_C_A)) 3001772Sjl139090 bn_sets = 1; 3011772Sjl139090 #endif 3021772Sjl139090 3031772Sjl139090 #if (NCPU <= IDSR_BN_SETS) 3041772Sjl139090 for (i = 0; i < NCPU; i++) 3051772Sjl139090 if (CPU_IN_SET(set, i)) { 3061772Sjl139090 shipit(i, shipped); 3071772Sjl139090 nackmask |= IDSR_NACK_BIT(shipped); 3081772Sjl139090 cpuids[shipped++] = i; 3091772Sjl139090 CPUSET_DEL(set, i); 3101772Sjl139090 if (CPUSET_ISNULL(set)) 3111772Sjl139090 break; 3121772Sjl139090 } 3131772Sjl139090 CPU_STATS_ADDQ(CPU, sys, xcalls, shipped); 3141772Sjl139090 #else 3151772Sjl139090 for (i = 0; i < NCPU; i++) 3161772Sjl139090 if (CPU_IN_SET(set, i)) { 3171772Sjl139090 ncpuids++; 3181772Sjl139090 3191772Sjl139090 /* 3201772Sjl139090 * Ship only to the first (IDSR_BN_SETS) CPUs. If we 3211772Sjl139090 * find we have shipped to more than (IDSR_BN_SETS) 3221772Sjl139090 * CPUs, set "index" to the highest numbered CPU in 3231772Sjl139090 * the set so we can ship to other CPUs a bit later on. 3241772Sjl139090 */ 3251888Shyw #ifdef OLYMPUS_C_REV_A_ERRATA_XCALL 3261772Sjl139090 if (shipped < bn_sets) { 3271772Sjl139090 #else 3281772Sjl139090 if (shipped < IDSR_BN_SETS) { 3291772Sjl139090 #endif 3301772Sjl139090 shipit(i, shipped); 3311772Sjl139090 nackmask |= IDSR_NACK_BIT(shipped); 3321772Sjl139090 cpuids[shipped++] = i; 3331772Sjl139090 CPUSET_DEL(set, i); 3341772Sjl139090 if (CPUSET_ISNULL(set)) 3351772Sjl139090 break; 3361772Sjl139090 } else 3371772Sjl139090 index = (int)i; 3381772Sjl139090 } 3391772Sjl139090 3401772Sjl139090 CPU_STATS_ADDQ(CPU, sys, xcalls, ncpuids); 3411772Sjl139090 #endif 3421772Sjl139090 3431772Sjl139090 busymask = IDSR_NACK_TO_BUSY(nackmask); 3441772Sjl139090 busy = nack = 0; 3451772Sjl139090 endtick = starttick + xc_tick_limit; 3461772Sjl139090 for (;;) { 3471772Sjl139090 idsr = getidsr(); 3481772Sjl139090 #if (NCPU <= IDSR_BN_SETS) 3491772Sjl139090 if (idsr == 0) 3501772Sjl139090 break; 3511772Sjl139090 #else 3521772Sjl139090 if (idsr == 0 && shipped == ncpuids) 3531772Sjl139090 break; 3541772Sjl139090 #endif 3551772Sjl139090 tick = gettick(); 3561772Sjl139090 /* 3571772Sjl139090 * If there is a big jump between the current tick 3581772Sjl139090 * count and lasttick, we have probably hit a break 3591772Sjl139090 * point. Adjust endtick accordingly to avoid panic. 3601772Sjl139090 */ 3611772Sjl139090 if (tick > (lasttick + xc_tick_jump_limit)) 3621772Sjl139090 endtick += (tick - lasttick); 3631772Sjl139090 lasttick = tick; 3641772Sjl139090 if (tick > endtick) { 3651772Sjl139090 if (panic_quiesce) 3661772Sjl139090 return; 3671772Sjl139090 cmn_err(CE_CONT, "send mondo timeout " 3681772Sjl139090 "[%d NACK %d BUSY]\nIDSR 0x%" 3691772Sjl139090 "" PRIx64 " cpuids:", nack, busy, idsr); 3701888Shyw #ifdef OLYMPUS_C_REV_A_ERRATA_XCALL 3711772Sjl139090 for (i = 0; i < bn_sets; i++) { 3721772Sjl139090 #else 3731772Sjl139090 for (i = 0; i < IDSR_BN_SETS; i++) { 3741772Sjl139090 #endif 3751772Sjl139090 if (idsr & (IDSR_NACK_BIT(i) | 3761772Sjl139090 IDSR_BUSY_BIT(i))) { 3771772Sjl139090 cmn_err(CE_CONT, " 0x%x", 3781772Sjl139090 cpuids[i]); 3791772Sjl139090 } 3801772Sjl139090 } 3811772Sjl139090 cmn_err(CE_CONT, "\n"); 3821772Sjl139090 cmn_err(CE_PANIC, "send_mondo_set: timeout"); 3831772Sjl139090 } 3841772Sjl139090 curnack = idsr & nackmask; 3851772Sjl139090 curbusy = idsr & busymask; 3861888Shyw 3871888Shyw #ifdef OLYMPUS_C_REV_B_ERRATA_XCALL 3881888Shyw /* 3891888Shyw * Only proceed to send more xcalls if all the 3901888Shyw * cpus in the previous IDSR_BN_SETS were completed. 3911888Shyw */ 3921888Shyw if (curbusy) { 3931888Shyw busy++; 3941888Shyw continue; 3951888Shyw } 3961888Shyw #endif /* OLYMPUS_C_REV_B_ERRATA_XCALL */ 3971888Shyw 3981772Sjl139090 #if (NCPU > IDSR_BN_SETS) 3991772Sjl139090 if (shipped < ncpuids) { 4001772Sjl139090 uint64_t cpus_left; 4011772Sjl139090 uint16_t next = (uint16_t)index; 4021772Sjl139090 4031772Sjl139090 cpus_left = ~(IDSR_NACK_TO_BUSY(curnack) | curbusy) & 4041772Sjl139090 busymask; 4051772Sjl139090 4061772Sjl139090 if (cpus_left) { 4071772Sjl139090 do { 4081772Sjl139090 /* 4091772Sjl139090 * Sequence through and ship to the 4101772Sjl139090 * remainder of the CPUs in the system 4111772Sjl139090 * (e.g. other than the first 4121772Sjl139090 * (IDSR_BN_SETS)) in reverse order. 4131772Sjl139090 */ 4141772Sjl139090 lo = lowbit(cpus_left) - 1; 4151772Sjl139090 i = IDSR_BUSY_IDX(lo); 4161772Sjl139090 shipit(next, i); 4171772Sjl139090 shipped++; 4181772Sjl139090 cpuids[i] = next; 4191772Sjl139090 4201772Sjl139090 /* 4211772Sjl139090 * If we've processed all the CPUs, 4221772Sjl139090 * exit the loop now and save 4231772Sjl139090 * instructions. 4241772Sjl139090 */ 4251772Sjl139090 if (shipped == ncpuids) 4261772Sjl139090 break; 4271772Sjl139090 4281772Sjl139090 for ((index = ((int)next - 1)); 4291772Sjl139090 index >= 0; index--) 4301772Sjl139090 if (CPU_IN_SET(set, index)) { 4311772Sjl139090 next = (uint16_t)index; 4321772Sjl139090 break; 4331772Sjl139090 } 4341772Sjl139090 4351772Sjl139090 cpus_left &= ~(1ull << lo); 4361772Sjl139090 } while (cpus_left); 4371772Sjl139090 continue; 4381772Sjl139090 } 4391772Sjl139090 } 4401772Sjl139090 #endif 4411888Shyw #ifndef OLYMPUS_C_REV_B_ERRATA_XCALL 4421772Sjl139090 if (curbusy) { 4431772Sjl139090 busy++; 4441772Sjl139090 continue; 4451772Sjl139090 } 4461888Shyw #endif /* OLYMPUS_C_REV_B_ERRATA_XCALL */ 4471772Sjl139090 #ifdef SEND_MONDO_STATS 4481772Sjl139090 { 4491772Sjl139090 int n = gettick() - starttick; 4501772Sjl139090 if (n < 8192) 4511772Sjl139090 x_nack_stimes[n >> 7]++; 4521772Sjl139090 } 4531772Sjl139090 #endif 4541772Sjl139090 while (gettick() < (tick + sys_clock_mhz)) 4551772Sjl139090 ; 4561772Sjl139090 do { 4571772Sjl139090 lo = lowbit(curnack) - 1; 4581772Sjl139090 i = IDSR_NACK_IDX(lo); 4591772Sjl139090 shipit(cpuids[i], i); 4601772Sjl139090 curnack &= ~(1ull << lo); 4611772Sjl139090 } while (curnack); 4621772Sjl139090 nack++; 4631772Sjl139090 busy = 0; 4641772Sjl139090 } 4651772Sjl139090 #ifdef SEND_MONDO_STATS 4661772Sjl139090 { 4671772Sjl139090 int n = gettick() - starttick; 4681772Sjl139090 if (n < 8192) 4691772Sjl139090 x_set_stimes[n >> 7]++; 4701772Sjl139090 else 4711772Sjl139090 x_set_ltimes[(n >> 13) & 0xf]++; 4721772Sjl139090 } 4731772Sjl139090 x_set_cpus[shipped]++; 4741772Sjl139090 #endif 4751772Sjl139090 } 4761772Sjl139090 4771772Sjl139090 /* 4781772Sjl139090 * Cpu private initialization. 4791772Sjl139090 */ 4801772Sjl139090 void 4811772Sjl139090 cpu_init_private(struct cpu *cp) 4821772Sjl139090 { 4831772Sjl139090 if (!(IS_OLYMPUS_C(cpunodes[cp->cpu_id].implementation))) { 4841772Sjl139090 cmn_err(CE_PANIC, "CPU%d Impl %d: Only SPARC64-VI is supported", 4851772Sjl139090 cp->cpu_id, cpunodes[cp->cpu_id].implementation); 4861772Sjl139090 } 4871772Sjl139090 4881772Sjl139090 adjust_hw_copy_limits(cpunodes[cp->cpu_id].ecache_size); 4891772Sjl139090 } 4901772Sjl139090 4911772Sjl139090 void 4921772Sjl139090 cpu_setup(void) 4931772Sjl139090 { 4941772Sjl139090 extern int at_flags; 4951772Sjl139090 extern int disable_delay_tlb_flush, delay_tlb_flush; 4961772Sjl139090 extern int cpc_has_overflow_intr; 4971772Sjl139090 extern int disable_text_largepages; 4981772Sjl139090 extern int use_text_pgsz4m; 4991772Sjl139090 uint64_t cpu0_log; 5001772Sjl139090 extern uint64_t opl_cpu0_err_log; 5011772Sjl139090 5021772Sjl139090 /* 5031772Sjl139090 * Initialize Error log Scratch register for error handling. 5041772Sjl139090 */ 5051772Sjl139090 5061772Sjl139090 cpu0_log = va_to_pa(&opl_cpu0_err_log); 5071772Sjl139090 opl_error_setup(cpu0_log); 5081772Sjl139090 5091772Sjl139090 /* 5101772Sjl139090 * Enable MMU translating multiple page sizes for 5111772Sjl139090 * sITLB and sDTLB. 5121772Sjl139090 */ 5131772Sjl139090 opl_mpg_enable(); 5141772Sjl139090 5151772Sjl139090 /* 5161772Sjl139090 * Setup chip-specific trap handlers. 5171772Sjl139090 */ 5181772Sjl139090 cpu_init_trap(); 5191772Sjl139090 5201772Sjl139090 cache |= (CACHE_VAC | CACHE_PTAG | CACHE_IOCOHERENT); 5211772Sjl139090 5221772Sjl139090 at_flags = EF_SPARC_32PLUS | EF_SPARC_SUN_US1 | EF_SPARC_SUN_US3; 5231772Sjl139090 5241772Sjl139090 /* 5251772Sjl139090 * Due to the number of entries in the fully-associative tlb 5261772Sjl139090 * this may have to be tuned lower than in spitfire. 5271772Sjl139090 */ 5281772Sjl139090 pp_slots = MIN(8, MAXPP_SLOTS); 5291772Sjl139090 5301772Sjl139090 /* 5311772Sjl139090 * Block stores do not invalidate all pages of the d$, pagecopy 5321772Sjl139090 * et. al. need virtual translations with virtual coloring taken 5331772Sjl139090 * into consideration. prefetch/ldd will pollute the d$ on the 5341772Sjl139090 * load side. 5351772Sjl139090 */ 5361772Sjl139090 pp_consistent_coloring = PPAGE_STORE_VCOLORING | PPAGE_LOADS_POLLUTE; 5371772Sjl139090 5381772Sjl139090 if (use_page_coloring) { 5391772Sjl139090 do_pg_coloring = 1; 5401772Sjl139090 if (use_virtual_coloring) 5411772Sjl139090 do_virtual_coloring = 1; 5421772Sjl139090 } 5431772Sjl139090 5441772Sjl139090 isa_list = 5451772Sjl139090 "sparcv9+vis2 sparcv9+vis sparcv9 " 5461772Sjl139090 "sparcv8plus+vis2 sparcv8plus+vis sparcv8plus " 5471772Sjl139090 "sparcv8 sparcv8-fsmuld sparcv7 sparc"; 5481772Sjl139090 5491772Sjl139090 cpu_hwcap_flags = AV_SPARC_VIS | AV_SPARC_VIS2; 5501772Sjl139090 5511772Sjl139090 /* 5521772Sjl139090 * On SPARC64-VI, there's no hole in the virtual address space 5531772Sjl139090 */ 5541772Sjl139090 hole_start = hole_end = 0; 5551772Sjl139090 5561772Sjl139090 /* 5571772Sjl139090 * The kpm mapping window. 5581772Sjl139090 * kpm_size: 5591772Sjl139090 * The size of a single kpm range. 5601772Sjl139090 * The overall size will be: kpm_size * vac_colors. 5611772Sjl139090 * kpm_vbase: 5621772Sjl139090 * The virtual start address of the kpm range within the kernel 5631772Sjl139090 * virtual address space. kpm_vbase has to be kpm_size aligned. 5641772Sjl139090 */ 5651772Sjl139090 kpm_size = (size_t)(128ull * 1024 * 1024 * 1024 * 1024); /* 128TB */ 5661772Sjl139090 kpm_size_shift = 47; 5671772Sjl139090 kpm_vbase = (caddr_t)0x8000000000000000ull; /* 8EB */ 5681772Sjl139090 kpm_smallpages = 1; 5691772Sjl139090 5701772Sjl139090 /* 5711772Sjl139090 * The traptrace code uses either %tick or %stick for 5721772Sjl139090 * timestamping. We have %stick so we can use it. 5731772Sjl139090 */ 5741772Sjl139090 traptrace_use_stick = 1; 5751772Sjl139090 5761772Sjl139090 /* 5771772Sjl139090 * SPARC64-VI has a performance counter overflow interrupt 5781772Sjl139090 */ 5791772Sjl139090 cpc_has_overflow_intr = 1; 5801772Sjl139090 5811772Sjl139090 /* 5821772Sjl139090 * Use SPARC64-VI flush-all support 5831772Sjl139090 */ 5841772Sjl139090 if (!disable_delay_tlb_flush) 5851772Sjl139090 delay_tlb_flush = 1; 5861772Sjl139090 5871772Sjl139090 /* 5881772Sjl139090 * Declare that this architecture/cpu combination does not support 5891772Sjl139090 * fpRAS. 5901772Sjl139090 */ 5911772Sjl139090 fpras_implemented = 0; 5921772Sjl139090 5931772Sjl139090 /* 5941772Sjl139090 * Enable 4M pages to be used for mapping user text by default. Don't 5951772Sjl139090 * use large pages for initialized data segments since we may not know 5961772Sjl139090 * at exec() time what should be the preferred large page size for DTLB 5971772Sjl139090 * programming. 5981772Sjl139090 */ 5991772Sjl139090 use_text_pgsz4m = 1; 6001772Sjl139090 disable_text_largepages = (1 << TTE64K) | (1 << TTE512K) | 6011772Sjl139090 (1 << TTE32M) | (1 << TTE256M); 6021772Sjl139090 } 6031772Sjl139090 6041772Sjl139090 /* 6051772Sjl139090 * Called by setcpudelay 6061772Sjl139090 */ 6071772Sjl139090 void 6081772Sjl139090 cpu_init_tick_freq(void) 6091772Sjl139090 { 6101772Sjl139090 /* 6111772Sjl139090 * For SPARC64-VI we want to use the system clock rate as 6121772Sjl139090 * the basis for low level timing, due to support of mixed 6131772Sjl139090 * speed CPUs and power managment. 6141772Sjl139090 */ 6151772Sjl139090 if (system_clock_freq == 0) 6161772Sjl139090 cmn_err(CE_PANIC, "setcpudelay: invalid system_clock_freq"); 6171772Sjl139090 6181772Sjl139090 sys_tick_freq = system_clock_freq; 6191772Sjl139090 } 6201772Sjl139090 6211772Sjl139090 #ifdef SEND_MONDO_STATS 6221772Sjl139090 uint32_t x_one_stimes[64]; 6231772Sjl139090 uint32_t x_one_ltimes[16]; 6241772Sjl139090 uint32_t x_set_stimes[64]; 6251772Sjl139090 uint32_t x_set_ltimes[16]; 6261772Sjl139090 uint32_t x_set_cpus[NCPU]; 6271772Sjl139090 uint32_t x_nack_stimes[64]; 6281772Sjl139090 #endif 6291772Sjl139090 6301772Sjl139090 /* 6311772Sjl139090 * Note: A version of this function is used by the debugger via the KDI, 6321772Sjl139090 * and must be kept in sync with this version. Any changes made to this 6331772Sjl139090 * function to support new chips or to accomodate errata must also be included 6341772Sjl139090 * in the KDI-specific version. See us3_kdi.c. 6351772Sjl139090 */ 6361772Sjl139090 void 6371772Sjl139090 send_one_mondo(int cpuid) 6381772Sjl139090 { 6391772Sjl139090 int busy, nack; 6401772Sjl139090 uint64_t idsr, starttick, endtick, tick, lasttick; 6411772Sjl139090 uint64_t busymask; 6421772Sjl139090 6431772Sjl139090 CPU_STATS_ADDQ(CPU, sys, xcalls, 1); 6441772Sjl139090 starttick = lasttick = gettick(); 6451772Sjl139090 shipit(cpuid, 0); 6461772Sjl139090 endtick = starttick + xc_tick_limit; 6471772Sjl139090 busy = nack = 0; 6481772Sjl139090 busymask = IDSR_BUSY; 6491772Sjl139090 for (;;) { 6501772Sjl139090 idsr = getidsr(); 6511772Sjl139090 if (idsr == 0) 6521772Sjl139090 break; 6531772Sjl139090 6541772Sjl139090 tick = gettick(); 6551772Sjl139090 /* 6561772Sjl139090 * If there is a big jump between the current tick 6571772Sjl139090 * count and lasttick, we have probably hit a break 6581772Sjl139090 * point. Adjust endtick accordingly to avoid panic. 6591772Sjl139090 */ 6601772Sjl139090 if (tick > (lasttick + xc_tick_jump_limit)) 6611772Sjl139090 endtick += (tick - lasttick); 6621772Sjl139090 lasttick = tick; 6631772Sjl139090 if (tick > endtick) { 6641772Sjl139090 if (panic_quiesce) 6651772Sjl139090 return; 6661772Sjl139090 cmn_err(CE_PANIC, "send mondo timeout " 6671772Sjl139090 "(target 0x%x) [%d NACK %d BUSY]", 6681772Sjl139090 cpuid, nack, busy); 6691772Sjl139090 } 6701772Sjl139090 6711772Sjl139090 if (idsr & busymask) { 6721772Sjl139090 busy++; 6731772Sjl139090 continue; 6741772Sjl139090 } 6751772Sjl139090 drv_usecwait(1); 6761772Sjl139090 shipit(cpuid, 0); 6771772Sjl139090 nack++; 6781772Sjl139090 busy = 0; 6791772Sjl139090 } 6801772Sjl139090 #ifdef SEND_MONDO_STATS 6811772Sjl139090 { 6821772Sjl139090 int n = gettick() - starttick; 6831772Sjl139090 if (n < 8192) 6841772Sjl139090 x_one_stimes[n >> 7]++; 6851772Sjl139090 else 6861772Sjl139090 x_one_ltimes[(n >> 13) & 0xf]++; 6871772Sjl139090 } 6881772Sjl139090 #endif 6891772Sjl139090 } 6901772Sjl139090 6911772Sjl139090 /* 6921772Sjl139090 * init_mmu_page_sizes is set to one after the bootup time initialization 6931772Sjl139090 * via mmu_init_mmu_page_sizes, to indicate that mmu_page_sizes has a 6941772Sjl139090 * valid value. 6951772Sjl139090 * 6961772Sjl139090 * mmu_disable_ism_large_pages and mmu_disable_large_pages are the mmu-specific 6971772Sjl139090 * versions of disable_ism_large_pages and disable_large_pages, and feed back 6981772Sjl139090 * into those two hat variables at hat initialization time. 6991772Sjl139090 * 7001772Sjl139090 */ 7011772Sjl139090 int init_mmu_page_sizes = 0; 7021772Sjl139090 static int mmu_disable_ism_large_pages = ((1 << TTE64K) | 7031772Sjl139090 (1 << TTE512K) | (1 << TTE256M)); 704*2368Sjimand static int mmu_disable_auto_large_pages = ((1 << TTE64K) | 705*2368Sjimand (1 << TTE512K) | (1 << TTE4M) | (1 << TTE256M)); 7061772Sjl139090 static int mmu_disable_large_pages = 0; 7071772Sjl139090 7081772Sjl139090 /* 7091772Sjl139090 * Re-initialize mmu_page_sizes and friends, for SPARC64-VI mmu support. 7101772Sjl139090 * Called during very early bootup from check_cpus_set(). 7111772Sjl139090 * Can be called to verify that mmu_page_sizes are set up correctly. 7121772Sjl139090 * 7131772Sjl139090 * Set Olympus defaults. We do not use the function parameter. 7141772Sjl139090 */ 7151772Sjl139090 /*ARGSUSED*/ 7161772Sjl139090 int 7171772Sjl139090 mmu_init_mmu_page_sizes(int32_t not_used) 7181772Sjl139090 { 7191772Sjl139090 if (!init_mmu_page_sizes) { 7201772Sjl139090 mmu_page_sizes = MMU_PAGE_SIZES; 7211772Sjl139090 mmu_hashcnt = MAX_HASHCNT; 7221772Sjl139090 mmu_ism_pagesize = MMU_PAGESIZE32M; 723*2368Sjimand auto_lpg_maxszc = TTE32M; 7241772Sjl139090 mmu_exported_pagesize_mask = (1 << TTE8K) | 7251772Sjl139090 (1 << TTE64K) | (1 << TTE512K) | (1 << TTE4M) | 7261772Sjl139090 (1 << TTE32M) | (1 << TTE256M); 7271772Sjl139090 init_mmu_page_sizes = 1; 7281772Sjl139090 return (0); 7291772Sjl139090 } 7301772Sjl139090 return (1); 7311772Sjl139090 } 7321772Sjl139090 7331772Sjl139090 /* SPARC64-VI worst case DTLB parameters */ 7341772Sjl139090 #ifndef LOCKED_DTLB_ENTRIES 7351772Sjl139090 #define LOCKED_DTLB_ENTRIES 5 /* 2 user TSBs, 2 nucleus, + OBP */ 7361772Sjl139090 #endif 7371772Sjl139090 #define TOTAL_DTLB_ENTRIES 32 7381772Sjl139090 #define AVAIL_32M_ENTRIES 0 7391772Sjl139090 #define AVAIL_256M_ENTRIES 0 7401772Sjl139090 #define AVAIL_DTLB_ENTRIES (TOTAL_DTLB_ENTRIES - LOCKED_DTLB_ENTRIES) 7411772Sjl139090 static uint64_t ttecnt_threshold[MMU_PAGE_SIZES] = { 7421772Sjl139090 AVAIL_DTLB_ENTRIES, AVAIL_DTLB_ENTRIES, 7431772Sjl139090 AVAIL_DTLB_ENTRIES, AVAIL_DTLB_ENTRIES, 7441772Sjl139090 AVAIL_DTLB_ENTRIES, AVAIL_DTLB_ENTRIES}; 7451772Sjl139090 7461772Sjl139090 /* 7471772Sjl139090 * The function returns the mmu-specific values for the 748*2368Sjimand * hat's disable_large_pages, disable_ism_large_pages, and 749*2368Sjimand * disable_auto_large_pages variables. 7501772Sjl139090 */ 7511772Sjl139090 int 7521772Sjl139090 mmu_large_pages_disabled(uint_t flag) 7531772Sjl139090 { 7541772Sjl139090 int pages_disable = 0; 7551772Sjl139090 7561772Sjl139090 if (flag == HAT_LOAD) { 7571772Sjl139090 pages_disable = mmu_disable_large_pages; 7581772Sjl139090 } else if (flag == HAT_LOAD_SHARE) { 7591772Sjl139090 pages_disable = mmu_disable_ism_large_pages; 760*2368Sjimand } else if (flag == HAT_LOAD_AUTOLPG) { 761*2368Sjimand pages_disable = mmu_disable_auto_large_pages; 7621772Sjl139090 } 7631772Sjl139090 return (pages_disable); 7641772Sjl139090 } 7651772Sjl139090 7661772Sjl139090 /* 7671772Sjl139090 * mmu_init_large_pages is called with the desired ism_pagesize parameter. 7681772Sjl139090 * It may be called from set_platform_defaults, if some value other than 32M 7691772Sjl139090 * is desired. mmu_ism_pagesize is the tunable. If it has a bad value, 7701772Sjl139090 * then only warn, since it would be bad form to panic due to a user typo. 7711772Sjl139090 * 7721772Sjl139090 * The function re-initializes the mmu_disable_ism_large_pages variable. 7731772Sjl139090 */ 7741772Sjl139090 void 7751772Sjl139090 mmu_init_large_pages(size_t ism_pagesize) 7761772Sjl139090 { 7771772Sjl139090 switch (ism_pagesize) { 7781772Sjl139090 case MMU_PAGESIZE4M: 7791772Sjl139090 mmu_disable_ism_large_pages = ((1 << TTE64K) | 7801772Sjl139090 (1 << TTE512K) | (1 << TTE32M) | (1 << TTE256M)); 781*2368Sjimand mmu_disable_auto_large_pages = ((1 << TTE64K) | 782*2368Sjimand (1 << TTE512K) | (1 << TTE32M) | (1 << TTE256M)); 783*2368Sjimand auto_lpg_maxszc = TTE4M; 7841772Sjl139090 break; 7851772Sjl139090 case MMU_PAGESIZE32M: 7861772Sjl139090 mmu_disable_ism_large_pages = ((1 << TTE64K) | 7871772Sjl139090 (1 << TTE512K) | (1 << TTE256M)); 788*2368Sjimand mmu_disable_auto_large_pages = ((1 << TTE64K) | 789*2368Sjimand (1 << TTE512K) | (1 << TTE4M) | (1 << TTE256M)); 790*2368Sjimand auto_lpg_maxszc = TTE32M; 7911772Sjl139090 break; 7921772Sjl139090 case MMU_PAGESIZE256M: 7931772Sjl139090 mmu_disable_ism_large_pages = ((1 << TTE64K) | 7941772Sjl139090 (1 << TTE512K) | (1 << TTE32M)); 795*2368Sjimand mmu_disable_auto_large_pages = ((1 << TTE64K) | 796*2368Sjimand (1 << TTE512K) | (1 << TTE4M) | (1 << TTE32M)); 797*2368Sjimand auto_lpg_maxszc = TTE256M; 7981772Sjl139090 break; 7991772Sjl139090 default: 8001772Sjl139090 cmn_err(CE_WARN, "Unrecognized mmu_ism_pagesize value 0x%lx", 8011772Sjl139090 ism_pagesize); 8021772Sjl139090 break; 8031772Sjl139090 } 8041772Sjl139090 } 8051772Sjl139090 8061772Sjl139090 /*ARGSUSED*/ 8071772Sjl139090 uint_t 8081772Sjl139090 mmu_preferred_pgsz(struct hat *hat, caddr_t addr, size_t len) 8091772Sjl139090 { 8101772Sjl139090 sfmmu_t *sfmmup = (sfmmu_t *)hat; 8111772Sjl139090 uint_t pgsz0, pgsz1; 8121772Sjl139090 uint_t szc, maxszc = mmu_page_sizes - 1; 8131772Sjl139090 size_t pgsz; 814*2368Sjimand extern int disable_auto_large_pages; 8151772Sjl139090 8161772Sjl139090 pgsz0 = (uint_t)sfmmup->sfmmu_pgsz[0]; 8171772Sjl139090 pgsz1 = (uint_t)sfmmup->sfmmu_pgsz[1]; 8181772Sjl139090 8191772Sjl139090 /* 8201772Sjl139090 * If either of the TLBs are reprogrammed, choose 8211772Sjl139090 * the largest mapping size as the preferred size, 8221772Sjl139090 * if it fits the size and alignment constraints. 8231772Sjl139090 * Else return the largest mapping size that fits, 8241772Sjl139090 * if neither TLB is reprogrammed. 8251772Sjl139090 */ 8261772Sjl139090 if (pgsz0 > TTE8K || pgsz1 > TTE8K) { 8271772Sjl139090 if (pgsz1 > pgsz0) { /* First try pgsz1 */ 8281772Sjl139090 pgsz = hw_page_array[pgsz1].hp_size; 8291772Sjl139090 if ((len >= pgsz) && IS_P2ALIGNED(addr, pgsz)) 8301772Sjl139090 return (pgsz1); 8311772Sjl139090 } 8321772Sjl139090 if (pgsz0 > TTE8K) { /* Then try pgsz0, if !TTE8K */ 8331772Sjl139090 pgsz = hw_page_array[pgsz0].hp_size; 8341772Sjl139090 if ((len >= pgsz) && IS_P2ALIGNED(addr, pgsz)) 8351772Sjl139090 return (pgsz0); 8361772Sjl139090 } 8371772Sjl139090 } else { /* Otherwise pick best fit if neither TLB is reprogrammed. */ 8381772Sjl139090 for (szc = maxszc; szc > TTE8K; szc--) { 839*2368Sjimand if (disable_auto_large_pages & (1 << szc)) 8401772Sjl139090 continue; 8411772Sjl139090 8421772Sjl139090 pgsz = hw_page_array[szc].hp_size; 8431772Sjl139090 if ((len >= pgsz) && IS_P2ALIGNED(addr, pgsz)) 8441772Sjl139090 return (szc); 8451772Sjl139090 } 8461772Sjl139090 } 8471772Sjl139090 return (TTE8K); 8481772Sjl139090 } 8491772Sjl139090 8501772Sjl139090 /* 8511772Sjl139090 * Function to reprogram the TLBs when page sizes used 8521772Sjl139090 * by a process change significantly. 8531772Sjl139090 */ 8541772Sjl139090 void 8552272Sjimand mmu_setup_page_sizes(struct hat *hat, uint64_t *ttecnt, uint8_t *tmp_pgsz) 8561772Sjl139090 { 8571772Sjl139090 uint8_t pgsz0, pgsz1; 8581772Sjl139090 8591772Sjl139090 /* 8601772Sjl139090 * Don't program 2nd dtlb for kernel and ism hat 8611772Sjl139090 */ 8622272Sjimand ASSERT(hat->sfmmu_ismhat == NULL); 8632272Sjimand ASSERT(hat != ksfmmup); 8641772Sjl139090 8651772Sjl139090 /* 8661772Sjl139090 * hat->sfmmu_pgsz[] is an array whose elements 8671772Sjl139090 * contain a sorted order of page sizes. Element 8681772Sjl139090 * 0 is the most commonly used page size, followed 8691772Sjl139090 * by element 1, and so on. 8701772Sjl139090 * 8711772Sjl139090 * ttecnt[] is an array of per-page-size page counts 8721772Sjl139090 * mapped into the process. 8731772Sjl139090 * 8741772Sjl139090 * If the HAT's choice for page sizes is unsuitable, 8751772Sjl139090 * we can override it here. The new values written 8761772Sjl139090 * to the array will be handed back to us later to 8771772Sjl139090 * do the actual programming of the TLB hardware. 8781772Sjl139090 * 8791772Sjl139090 */ 8802272Sjimand pgsz0 = (uint8_t)MIN(tmp_pgsz[0], tmp_pgsz[1]); 8812272Sjimand pgsz1 = (uint8_t)MAX(tmp_pgsz[0], tmp_pgsz[1]); 8821772Sjl139090 8831772Sjl139090 /* 8841772Sjl139090 * This implements PAGESIZE programming of the sTLB 8851772Sjl139090 * if large TTE counts don't exceed the thresholds. 8861772Sjl139090 */ 8871772Sjl139090 if (ttecnt[pgsz0] < ttecnt_threshold[pgsz0]) 8881772Sjl139090 pgsz0 = page_szc(MMU_PAGESIZE); 8891772Sjl139090 if (ttecnt[pgsz1] < ttecnt_threshold[pgsz1]) 8901772Sjl139090 pgsz1 = page_szc(MMU_PAGESIZE); 8912272Sjimand tmp_pgsz[0] = pgsz0; 8922272Sjimand tmp_pgsz[1] = pgsz1; 8931772Sjl139090 /* otherwise, accept what the HAT chose for us */ 8941772Sjl139090 } 8951772Sjl139090 8961772Sjl139090 /* 8971772Sjl139090 * The HAT calls this function when an MMU context is allocated so that we 8981772Sjl139090 * can reprogram the large TLBs appropriately for the new process using 8991772Sjl139090 * the context. 9001772Sjl139090 * 9011772Sjl139090 * The caller must hold the HAT lock. 9021772Sjl139090 */ 9031772Sjl139090 void 9041772Sjl139090 mmu_set_ctx_page_sizes(struct hat *hat) 9051772Sjl139090 { 9061772Sjl139090 uint8_t pgsz0, pgsz1; 9071772Sjl139090 uint8_t new_cext; 9081772Sjl139090 9091772Sjl139090 ASSERT(sfmmu_hat_lock_held(hat)); 9101772Sjl139090 /* 9111772Sjl139090 * Don't program 2nd dtlb for kernel and ism hat 9121772Sjl139090 */ 9131772Sjl139090 if (hat->sfmmu_ismhat || hat == ksfmmup) 9141772Sjl139090 return; 9151772Sjl139090 9161772Sjl139090 /* 9171772Sjl139090 * If supported, reprogram the TLBs to a larger pagesize. 9181772Sjl139090 */ 9191772Sjl139090 pgsz0 = hat->sfmmu_pgsz[0]; 9201772Sjl139090 pgsz1 = hat->sfmmu_pgsz[1]; 9211772Sjl139090 ASSERT(pgsz0 < mmu_page_sizes); 9221772Sjl139090 ASSERT(pgsz1 < mmu_page_sizes); 9231772Sjl139090 new_cext = TAGACCEXT_MKSZPAIR(pgsz1, pgsz0); 9241772Sjl139090 if (hat->sfmmu_cext != new_cext) { 9252241Shuah #ifdef DEBUG 9262241Shuah int i; 9272241Shuah /* 9282241Shuah * assert cnum should be invalid, this is because pagesize 9292241Shuah * can only be changed after a proc's ctxs are invalidated. 9302241Shuah */ 9312241Shuah for (i = 0; i < max_mmu_ctxdoms; i++) { 9322241Shuah ASSERT(hat->sfmmu_ctxs[i].cnum == INVALID_CONTEXT); 9332241Shuah } 9342241Shuah #endif /* DEBUG */ 9351772Sjl139090 hat->sfmmu_cext = new_cext; 9361772Sjl139090 } 9371772Sjl139090 /* 9381772Sjl139090 * sfmmu_setctx_sec() will take care of the 9391772Sjl139090 * rest of the dirty work for us. 9401772Sjl139090 */ 9411772Sjl139090 } 9421772Sjl139090 9431772Sjl139090 /* 9442272Sjimand * This function assumes that there are either four or six supported page 9452272Sjimand * sizes and at most two programmable TLBs, so we need to decide which 9462272Sjimand * page sizes are most important and then adjust the TLB page sizes 9472272Sjimand * accordingly (if supported). 9482272Sjimand * 9492272Sjimand * If these assumptions change, this function will need to be 9502272Sjimand * updated to support whatever the new limits are. 9512272Sjimand */ 9522272Sjimand void 9532272Sjimand mmu_check_page_sizes(sfmmu_t *sfmmup, uint64_t *ttecnt) 9542272Sjimand { 9552272Sjimand uint64_t sortcnt[MMU_PAGE_SIZES]; 9562272Sjimand uint8_t tmp_pgsz[MMU_PAGE_SIZES]; 9572272Sjimand uint8_t i, j, max; 9582272Sjimand uint16_t oldval, newval; 9592272Sjimand 9602272Sjimand /* 9612272Sjimand * We only consider reprogramming the TLBs if one or more of 9622272Sjimand * the two most used page sizes changes and we're using 9632272Sjimand * large pages in this process. 9642272Sjimand */ 9652272Sjimand if (sfmmup->sfmmu_flags & HAT_LGPG_FLAGS) { 9662272Sjimand /* Sort page sizes. */ 9672272Sjimand for (i = 0; i < mmu_page_sizes; i++) { 9682272Sjimand sortcnt[i] = ttecnt[i]; 9692272Sjimand } 9702272Sjimand for (j = 0; j < mmu_page_sizes; j++) { 9712272Sjimand for (i = mmu_page_sizes - 1, max = 0; i > 0; i--) { 9722272Sjimand if (sortcnt[i] > sortcnt[max]) 9732272Sjimand max = i; 9742272Sjimand } 9752272Sjimand tmp_pgsz[j] = max; 9762272Sjimand sortcnt[max] = 0; 9772272Sjimand } 9782272Sjimand 9792272Sjimand oldval = sfmmup->sfmmu_pgsz[0] << 8 | sfmmup->sfmmu_pgsz[1]; 9802272Sjimand 9812272Sjimand mmu_setup_page_sizes(sfmmup, ttecnt, tmp_pgsz); 9822272Sjimand 9832272Sjimand /* Check 2 largest values after the sort. */ 9842272Sjimand newval = tmp_pgsz[0] << 8 | tmp_pgsz[1]; 9852272Sjimand if (newval != oldval) { 9862272Sjimand sfmmu_reprog_pgsz_arr(sfmmup, tmp_pgsz); 9872272Sjimand } 9882272Sjimand } 9892272Sjimand } 9902272Sjimand 9912272Sjimand /* 9921772Sjl139090 * Return processor specific async error structure 9931772Sjl139090 * size used. 9941772Sjl139090 */ 9951772Sjl139090 int 9961772Sjl139090 cpu_aflt_size(void) 9971772Sjl139090 { 9981772Sjl139090 return (sizeof (opl_async_flt_t)); 9991772Sjl139090 } 10001772Sjl139090 10011772Sjl139090 /* 10021772Sjl139090 * The cpu_sync_log_err() function is called via the [uc]e_drain() function to 10031772Sjl139090 * post-process CPU events that are dequeued. As such, it can be invoked 10041772Sjl139090 * from softint context, from AST processing in the trap() flow, or from the 10051772Sjl139090 * panic flow. We decode the CPU-specific data, and take appropriate actions. 10061772Sjl139090 * Historically this entry point was used to log the actual cmn_err(9F) text; 10071772Sjl139090 * now with FMA it is used to prepare 'flt' to be converted into an ereport. 10081772Sjl139090 * With FMA this function now also returns a flag which indicates to the 10091772Sjl139090 * caller whether the ereport should be posted (1) or suppressed (0). 10101772Sjl139090 */ 10111772Sjl139090 /*ARGSUSED*/ 10121772Sjl139090 static int 10131772Sjl139090 cpu_sync_log_err(void *flt) 10141772Sjl139090 { 10151772Sjl139090 opl_async_flt_t *opl_flt = (opl_async_flt_t *)flt; 10161772Sjl139090 struct async_flt *aflt = (struct async_flt *)flt; 10171772Sjl139090 10181772Sjl139090 /* 10191772Sjl139090 * No extra processing of urgent error events. 10201772Sjl139090 * Always generate ereports for these events. 10211772Sjl139090 */ 10221772Sjl139090 if (aflt->flt_status == OPL_ECC_URGENT_TRAP) 10231772Sjl139090 return (1); 10241772Sjl139090 10251772Sjl139090 /* 10261772Sjl139090 * Additional processing for synchronous errors. 10271772Sjl139090 */ 10281772Sjl139090 switch (opl_flt->flt_type) { 10291772Sjl139090 case OPL_CPU_INV_SFSR: 10301772Sjl139090 return (1); 10311772Sjl139090 10321772Sjl139090 case OPL_CPU_SYNC_UE: 10331772Sjl139090 /* 10341772Sjl139090 * The validity: SFSR_MK_UE bit has been checked 10351772Sjl139090 * in opl_cpu_sync_error() 10361772Sjl139090 * No more check is required. 10371772Sjl139090 * 10381772Sjl139090 * opl_flt->flt_eid_mod and flt_eid_sid have been set by H/W, 10391772Sjl139090 * and they have been retrieved in cpu_queue_events() 10401772Sjl139090 */ 10411772Sjl139090 10421772Sjl139090 if (opl_flt->flt_eid_mod == OPL_ERRID_MEM) { 10431772Sjl139090 ASSERT(aflt->flt_in_memory); 10441772Sjl139090 /* 10451772Sjl139090 * We want to skip logging only if ALL the following 10461772Sjl139090 * conditions are true: 10471772Sjl139090 * 10481772Sjl139090 * 1. We are not panicing already. 10491772Sjl139090 * 2. The error is a memory error. 10501772Sjl139090 * 3. There is only one error. 10511772Sjl139090 * 4. The error is on a retired page. 10521772Sjl139090 * 5. The error occurred under on_trap 10531772Sjl139090 * protection AFLT_PROT_EC 10541772Sjl139090 */ 10551772Sjl139090 if (!panicstr && aflt->flt_prot == AFLT_PROT_EC && 10561772Sjl139090 page_retire_check(aflt->flt_addr, NULL) == 0) { 10571772Sjl139090 /* 10581772Sjl139090 * Do not log an error from 10591772Sjl139090 * the retired page 10601772Sjl139090 */ 10611772Sjl139090 softcall(ecc_page_zero, (void *)aflt->flt_addr); 10621772Sjl139090 return (0); 10631772Sjl139090 } 10641772Sjl139090 if (!panicstr) 10651772Sjl139090 cpu_page_retire(opl_flt); 10661772Sjl139090 } 10671772Sjl139090 return (1); 10681772Sjl139090 10691772Sjl139090 case OPL_CPU_SYNC_OTHERS: 10701772Sjl139090 /* 10711772Sjl139090 * For the following error cases, the processor HW does 10721772Sjl139090 * not set the flt_eid_mod/flt_eid_sid. Instead, SW will attempt 10731772Sjl139090 * to assign appropriate values here to reflect what we 10741772Sjl139090 * think is the most likely cause of the problem w.r.t to 10751772Sjl139090 * the particular error event. For Buserr and timeout 10761772Sjl139090 * error event, we will assign OPL_ERRID_CHANNEL as the 10771772Sjl139090 * most likely reason. For TLB parity or multiple hit 10781772Sjl139090 * error events, we will assign the reason as 10791772Sjl139090 * OPL_ERRID_CPU (cpu related problem) and set the 10801772Sjl139090 * flt_eid_sid to point to the cpuid. 10811772Sjl139090 */ 10821772Sjl139090 10831772Sjl139090 if (opl_flt->flt_bit & (SFSR_BERR|SFSR_TO)) { 10841772Sjl139090 /* 10851772Sjl139090 * flt_eid_sid will not be used for this case. 10861772Sjl139090 */ 10871772Sjl139090 opl_flt->flt_eid_mod = OPL_ERRID_CHANNEL; 10881772Sjl139090 } 10891772Sjl139090 if (opl_flt->flt_bit & (SFSR_TLB_MUL|SFSR_TLB_PRT)) { 10901772Sjl139090 opl_flt->flt_eid_mod = OPL_ERRID_CPU; 10911772Sjl139090 opl_flt->flt_eid_sid = aflt->flt_inst; 10921772Sjl139090 } 10931772Sjl139090 10941772Sjl139090 /* 10951772Sjl139090 * In case of no effective error bit 10961772Sjl139090 */ 10971772Sjl139090 if ((opl_flt->flt_bit & SFSR_ERRS) == 0) { 10981772Sjl139090 opl_flt->flt_eid_mod = OPL_ERRID_CPU; 10991772Sjl139090 opl_flt->flt_eid_sid = aflt->flt_inst; 11001772Sjl139090 } 11011772Sjl139090 break; 11021772Sjl139090 11031772Sjl139090 default: 11041772Sjl139090 return (1); 11051772Sjl139090 } 11061772Sjl139090 return (1); 11071772Sjl139090 } 11081772Sjl139090 11091772Sjl139090 /* 11101772Sjl139090 * Retire the bad page that may contain the flushed error. 11111772Sjl139090 */ 11121772Sjl139090 void 11131772Sjl139090 cpu_page_retire(opl_async_flt_t *opl_flt) 11141772Sjl139090 { 11151772Sjl139090 struct async_flt *aflt = (struct async_flt *)opl_flt; 11161772Sjl139090 (void) page_retire(aflt->flt_addr, PR_UE); 11171772Sjl139090 } 11181772Sjl139090 11191772Sjl139090 /* 11201772Sjl139090 * Invoked by error_init() early in startup and therefore before 11211772Sjl139090 * startup_errorq() is called to drain any error Q - 11221772Sjl139090 * 11231772Sjl139090 * startup() 11241772Sjl139090 * startup_end() 11251772Sjl139090 * error_init() 11261772Sjl139090 * cpu_error_init() 11271772Sjl139090 * errorq_init() 11281772Sjl139090 * errorq_drain() 11291772Sjl139090 * start_other_cpus() 11301772Sjl139090 * 11311772Sjl139090 * The purpose of this routine is to create error-related taskqs. Taskqs 11321772Sjl139090 * are used for this purpose because cpu_lock can't be grabbed from interrupt 11331772Sjl139090 * context. 11341772Sjl139090 * 11351772Sjl139090 */ 11361772Sjl139090 /*ARGSUSED*/ 11371772Sjl139090 void 11381772Sjl139090 cpu_error_init(int items) 11391772Sjl139090 { 11401772Sjl139090 opl_err_log = (opl_errlog_t *) 11411772Sjl139090 kmem_alloc(ERRLOG_ALLOC_SZ, KM_SLEEP); 11421772Sjl139090 if ((uint64_t)opl_err_log & MMU_PAGEOFFSET) 11431772Sjl139090 cmn_err(CE_PANIC, "The base address of the error log " 11441772Sjl139090 "is not page aligned"); 11451772Sjl139090 } 11461772Sjl139090 11471772Sjl139090 /* 11481772Sjl139090 * We route all errors through a single switch statement. 11491772Sjl139090 */ 11501772Sjl139090 void 11511772Sjl139090 cpu_ue_log_err(struct async_flt *aflt) 11521772Sjl139090 { 11531772Sjl139090 switch (aflt->flt_class) { 11541772Sjl139090 case CPU_FAULT: 11551772Sjl139090 if (cpu_sync_log_err(aflt)) 11561772Sjl139090 cpu_ereport_post(aflt); 11571772Sjl139090 break; 11581772Sjl139090 11591772Sjl139090 case BUS_FAULT: 11601772Sjl139090 bus_async_log_err(aflt); 11611772Sjl139090 break; 11621772Sjl139090 11631772Sjl139090 default: 11641772Sjl139090 cmn_err(CE_WARN, "discarding async error %p with invalid " 11651772Sjl139090 "fault class (0x%x)", (void *)aflt, aflt->flt_class); 11661772Sjl139090 return; 11671772Sjl139090 } 11681772Sjl139090 } 11691772Sjl139090 11701772Sjl139090 /* 11711772Sjl139090 * Routine for panic hook callback from panic_idle(). 11721772Sjl139090 * 11731772Sjl139090 * Nothing to do here. 11741772Sjl139090 */ 11751772Sjl139090 void 11761772Sjl139090 cpu_async_panic_callb(void) 11771772Sjl139090 { 11781772Sjl139090 } 11791772Sjl139090 11801772Sjl139090 /* 11811772Sjl139090 * Routine to return a string identifying the physical name 11821772Sjl139090 * associated with a memory/cache error. 11831772Sjl139090 */ 11841772Sjl139090 /*ARGSUSED*/ 11851772Sjl139090 int 11861772Sjl139090 cpu_get_mem_unum(int synd_status, ushort_t flt_synd, uint64_t flt_stat, 11871772Sjl139090 uint64_t flt_addr, int flt_bus_id, int flt_in_memory, 11881772Sjl139090 ushort_t flt_status, char *buf, int buflen, int *lenp) 11891772Sjl139090 { 11901772Sjl139090 int synd_code; 11911772Sjl139090 int ret; 11921772Sjl139090 11931772Sjl139090 /* 11941772Sjl139090 * An AFSR of -1 defaults to a memory syndrome. 11951772Sjl139090 */ 11961772Sjl139090 synd_code = (int)flt_synd; 11971772Sjl139090 11981772Sjl139090 if (&plat_get_mem_unum) { 11991772Sjl139090 if ((ret = plat_get_mem_unum(synd_code, flt_addr, flt_bus_id, 12001772Sjl139090 flt_in_memory, flt_status, buf, buflen, lenp)) != 0) { 12011772Sjl139090 buf[0] = '\0'; 12021772Sjl139090 *lenp = 0; 12031772Sjl139090 } 12041772Sjl139090 return (ret); 12051772Sjl139090 } 12061772Sjl139090 buf[0] = '\0'; 12071772Sjl139090 *lenp = 0; 12081772Sjl139090 return (ENOTSUP); 12091772Sjl139090 } 12101772Sjl139090 12111772Sjl139090 /* 12121772Sjl139090 * Wrapper for cpu_get_mem_unum() routine that takes an 12131772Sjl139090 * async_flt struct rather than explicit arguments. 12141772Sjl139090 */ 12151772Sjl139090 int 12161772Sjl139090 cpu_get_mem_unum_aflt(int synd_status, struct async_flt *aflt, 12171772Sjl139090 char *buf, int buflen, int *lenp) 12181772Sjl139090 { 12191772Sjl139090 /* 12201772Sjl139090 * We always pass -1 so that cpu_get_mem_unum will interpret this as a 12211772Sjl139090 * memory error. 12221772Sjl139090 */ 12231772Sjl139090 return (cpu_get_mem_unum(synd_status, aflt->flt_synd, 12241772Sjl139090 (uint64_t)-1, 12251772Sjl139090 aflt->flt_addr, aflt->flt_bus_id, aflt->flt_in_memory, 12261772Sjl139090 aflt->flt_status, buf, buflen, lenp)); 12271772Sjl139090 } 12281772Sjl139090 12291772Sjl139090 /* 12301772Sjl139090 * This routine is a more generic interface to cpu_get_mem_unum() 12311772Sjl139090 * that may be used by other modules (e.g. mm). 12321772Sjl139090 */ 12331772Sjl139090 /*ARGSUSED*/ 12341772Sjl139090 int 12351772Sjl139090 cpu_get_mem_name(uint64_t synd, uint64_t *afsr, uint64_t afar, 12361772Sjl139090 char *buf, int buflen, int *lenp) 12371772Sjl139090 { 12381772Sjl139090 int synd_status, flt_in_memory, ret; 12391772Sjl139090 ushort_t flt_status = 0; 12401772Sjl139090 char unum[UNUM_NAMLEN]; 12411772Sjl139090 12421772Sjl139090 /* 12431772Sjl139090 * Check for an invalid address. 12441772Sjl139090 */ 12451772Sjl139090 if (afar == (uint64_t)-1) 12461772Sjl139090 return (ENXIO); 12471772Sjl139090 12481772Sjl139090 if (synd == (uint64_t)-1) 12491772Sjl139090 synd_status = AFLT_STAT_INVALID; 12501772Sjl139090 else 12511772Sjl139090 synd_status = AFLT_STAT_VALID; 12521772Sjl139090 12531772Sjl139090 flt_in_memory = (*afsr & SFSR_MEMORY) && 12541772Sjl139090 pf_is_memory(afar >> MMU_PAGESHIFT); 12551772Sjl139090 12561772Sjl139090 ret = cpu_get_mem_unum(synd_status, (ushort_t)synd, *afsr, afar, 12571772Sjl139090 CPU->cpu_id, flt_in_memory, flt_status, unum, 12581772Sjl139090 UNUM_NAMLEN, lenp); 12591772Sjl139090 if (ret != 0) 12601772Sjl139090 return (ret); 12611772Sjl139090 12621772Sjl139090 if (*lenp >= buflen) 12631772Sjl139090 return (ENAMETOOLONG); 12641772Sjl139090 12651772Sjl139090 (void) strncpy(buf, unum, buflen); 12661772Sjl139090 12671772Sjl139090 return (0); 12681772Sjl139090 } 12691772Sjl139090 12701772Sjl139090 /* 12711772Sjl139090 * Routine to return memory information associated 12721772Sjl139090 * with a physical address and syndrome. 12731772Sjl139090 */ 12741772Sjl139090 /*ARGSUSED*/ 12751772Sjl139090 int 12761772Sjl139090 cpu_get_mem_info(uint64_t synd, uint64_t afar, 12771772Sjl139090 uint64_t *mem_sizep, uint64_t *seg_sizep, uint64_t *bank_sizep, 12781772Sjl139090 int *segsp, int *banksp, int *mcidp) 12791772Sjl139090 { 12801772Sjl139090 int synd_code = (int)synd; 12811772Sjl139090 12821772Sjl139090 if (afar == (uint64_t)-1) 12831772Sjl139090 return (ENXIO); 12841772Sjl139090 12851772Sjl139090 if (p2get_mem_info != NULL) 12861772Sjl139090 return ((p2get_mem_info)(synd_code, afar, 12871772Sjl139090 mem_sizep, seg_sizep, bank_sizep, 12881772Sjl139090 segsp, banksp, mcidp)); 12891772Sjl139090 else 12901772Sjl139090 return (ENOTSUP); 12911772Sjl139090 } 12921772Sjl139090 12931772Sjl139090 /* 12941772Sjl139090 * Routine to return a string identifying the physical 12951772Sjl139090 * name associated with a cpuid. 12961772Sjl139090 */ 12971772Sjl139090 int 12981772Sjl139090 cpu_get_cpu_unum(int cpuid, char *buf, int buflen, int *lenp) 12991772Sjl139090 { 13001772Sjl139090 int ret; 13011772Sjl139090 char unum[UNUM_NAMLEN]; 13021772Sjl139090 13031772Sjl139090 if (&plat_get_cpu_unum) { 13041772Sjl139090 if ((ret = plat_get_cpu_unum(cpuid, unum, UNUM_NAMLEN, lenp)) 13051772Sjl139090 != 0) 13061772Sjl139090 return (ret); 13071772Sjl139090 } else { 13081772Sjl139090 return (ENOTSUP); 13091772Sjl139090 } 13101772Sjl139090 13111772Sjl139090 if (*lenp >= buflen) 13121772Sjl139090 return (ENAMETOOLONG); 13131772Sjl139090 13141772Sjl139090 (void) strncpy(buf, unum, *lenp); 13151772Sjl139090 13161772Sjl139090 return (0); 13171772Sjl139090 } 13181772Sjl139090 13191772Sjl139090 /* 13201772Sjl139090 * This routine exports the name buffer size. 13211772Sjl139090 */ 13221772Sjl139090 size_t 13231772Sjl139090 cpu_get_name_bufsize() 13241772Sjl139090 { 13251772Sjl139090 return (UNUM_NAMLEN); 13261772Sjl139090 } 13271772Sjl139090 13281772Sjl139090 /* 13291772Sjl139090 * Flush the entire ecache by ASI_L2_CNTL.U2_FLUSH 13301772Sjl139090 */ 13311772Sjl139090 void 13321772Sjl139090 cpu_flush_ecache(void) 13331772Sjl139090 { 13341772Sjl139090 flush_ecache(ecache_flushaddr, cpunodes[CPU->cpu_id].ecache_size, 13351772Sjl139090 cpunodes[CPU->cpu_id].ecache_linesize); 13361772Sjl139090 } 13371772Sjl139090 13381772Sjl139090 static uint8_t 13391772Sjl139090 flt_to_trap_type(struct async_flt *aflt) 13401772Sjl139090 { 13411772Sjl139090 if (aflt->flt_status & OPL_ECC_ISYNC_TRAP) 13421772Sjl139090 return (TRAP_TYPE_ECC_I); 13431772Sjl139090 if (aflt->flt_status & OPL_ECC_DSYNC_TRAP) 13441772Sjl139090 return (TRAP_TYPE_ECC_D); 13451772Sjl139090 if (aflt->flt_status & OPL_ECC_URGENT_TRAP) 13461772Sjl139090 return (TRAP_TYPE_URGENT); 13471772Sjl139090 return (-1); 13481772Sjl139090 } 13491772Sjl139090 13501772Sjl139090 /* 13511772Sjl139090 * Encode the data saved in the opl_async_flt_t struct into 13521772Sjl139090 * the FM ereport payload. 13531772Sjl139090 */ 13541772Sjl139090 /* ARGSUSED */ 13551772Sjl139090 static void 13561772Sjl139090 cpu_payload_add_aflt(struct async_flt *aflt, nvlist_t *payload, 13571772Sjl139090 nvlist_t *resource) 13581772Sjl139090 { 13591772Sjl139090 opl_async_flt_t *opl_flt = (opl_async_flt_t *)aflt; 13601772Sjl139090 char unum[UNUM_NAMLEN]; 13611772Sjl139090 char sbuf[21]; /* sizeof (UINT64_MAX) + '\0' */ 13621772Sjl139090 int len; 13631772Sjl139090 13641772Sjl139090 13651772Sjl139090 if (aflt->flt_payload & FM_EREPORT_PAYLOAD_FLAG_SFSR) { 13661772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_SFSR, 13671772Sjl139090 DATA_TYPE_UINT64, aflt->flt_stat, NULL); 13681772Sjl139090 } 13691772Sjl139090 if (aflt->flt_payload & FM_EREPORT_PAYLOAD_FLAG_SFAR) { 13701772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_SFAR, 13711772Sjl139090 DATA_TYPE_UINT64, aflt->flt_addr, NULL); 13721772Sjl139090 } 13731772Sjl139090 if (aflt->flt_payload & FM_EREPORT_PAYLOAD_FLAG_UGESR) { 13741772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_UGESR, 13751772Sjl139090 DATA_TYPE_UINT64, aflt->flt_stat, NULL); 13761772Sjl139090 } 13771772Sjl139090 if (aflt->flt_payload & FM_EREPORT_PAYLOAD_FLAG_PC) { 13781772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_PC, 13791772Sjl139090 DATA_TYPE_UINT64, (uint64_t)aflt->flt_pc, NULL); 13801772Sjl139090 } 13811772Sjl139090 if (aflt->flt_payload & FM_EREPORT_PAYLOAD_FLAG_TL) { 13821772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_TL, 13831772Sjl139090 DATA_TYPE_UINT8, (uint8_t)aflt->flt_tl, NULL); 13841772Sjl139090 } 13851772Sjl139090 if (aflt->flt_payload & FM_EREPORT_PAYLOAD_FLAG_TT) { 13861772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_TT, 13871772Sjl139090 DATA_TYPE_UINT8, flt_to_trap_type(aflt), NULL); 13881772Sjl139090 } 13891772Sjl139090 if (aflt->flt_payload & FM_EREPORT_PAYLOAD_FLAG_PRIV) { 13901772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_PRIV, 13911772Sjl139090 DATA_TYPE_BOOLEAN_VALUE, 13921772Sjl139090 (aflt->flt_priv ? B_TRUE : B_FALSE), NULL); 13931772Sjl139090 } 13941772Sjl139090 if (aflt->flt_payload & FM_EREPORT_PAYLOAD_FLAG_FLT_STATUS) { 13951772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_FLT_STATUS, 13961772Sjl139090 DATA_TYPE_UINT64, (uint64_t)aflt->flt_status, NULL); 13971772Sjl139090 } 13981772Sjl139090 13991772Sjl139090 switch (opl_flt->flt_eid_mod) { 14001772Sjl139090 case OPL_ERRID_CPU: 14011772Sjl139090 (void) snprintf(sbuf, sizeof (sbuf), "%llX", 14021772Sjl139090 (u_longlong_t)cpunodes[opl_flt->flt_eid_sid].device_id); 14031772Sjl139090 (void) fm_fmri_cpu_set(resource, FM_CPU_SCHEME_VERSION, 14041772Sjl139090 NULL, opl_flt->flt_eid_sid, 14051772Sjl139090 (uint8_t *)&cpunodes[opl_flt->flt_eid_sid].version, 14061772Sjl139090 sbuf); 14071772Sjl139090 fm_payload_set(payload, 14081772Sjl139090 FM_EREPORT_PAYLOAD_NAME_RESOURCE, 14091772Sjl139090 DATA_TYPE_NVLIST, resource, NULL); 14101772Sjl139090 break; 14111772Sjl139090 14121772Sjl139090 case OPL_ERRID_CHANNEL: 14131772Sjl139090 /* 14141772Sjl139090 * No resource is created but the cpumem DE will find 14151772Sjl139090 * the defective path by retreiving EID from SFSR which is 14161772Sjl139090 * included in the payload. 14171772Sjl139090 */ 14181772Sjl139090 break; 14191772Sjl139090 14201772Sjl139090 case OPL_ERRID_MEM: 14211772Sjl139090 (void) cpu_get_mem_unum_aflt(0, aflt, unum, UNUM_NAMLEN, &len); 14221772Sjl139090 (void) fm_fmri_mem_set(resource, FM_MEM_SCHEME_VERSION, 14231772Sjl139090 NULL, unum, NULL, (uint64_t)-1); 14241772Sjl139090 fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_RESOURCE, 14251772Sjl139090 DATA_TYPE_NVLIST, resource, NULL); 14261772Sjl139090 break; 14271772Sjl139090 14281772Sjl139090 case OPL_ERRID_PATH: 14291772Sjl139090 /* 14301772Sjl139090 * No resource is created but the cpumem DE will find 14311772Sjl139090 * the defective path by retreiving EID from SFSR which is 14321772Sjl139090 * included in the payload. 14331772Sjl139090 */ 14341772Sjl139090 break; 14351772Sjl139090 } 14361772Sjl139090 } 14371772Sjl139090 14381772Sjl139090 /* 14391772Sjl139090 * Returns whether fault address is valid for this error bit and 14401772Sjl139090 * whether the address is "in memory" (i.e. pf_is_memory returns 1). 14411772Sjl139090 */ 14421772Sjl139090 /*ARGSUSED*/ 14431772Sjl139090 static int 14441772Sjl139090 cpu_flt_in_memory(opl_async_flt_t *opl_flt, uint64_t t_afsr_bit) 14451772Sjl139090 { 14461772Sjl139090 struct async_flt *aflt = (struct async_flt *)opl_flt; 14471772Sjl139090 14481772Sjl139090 if (aflt->flt_status & (OPL_ECC_SYNC_TRAP)) { 14491772Sjl139090 return ((t_afsr_bit & SFSR_MEMORY) && 14501772Sjl139090 pf_is_memory(aflt->flt_addr >> MMU_PAGESHIFT)); 14511772Sjl139090 } 14521772Sjl139090 return (0); 14531772Sjl139090 } 14541772Sjl139090 14551772Sjl139090 /* 14561772Sjl139090 * In OPL SCF does the stick synchronization. 14571772Sjl139090 */ 14581772Sjl139090 void 14591772Sjl139090 sticksync_slave(void) 14601772Sjl139090 { 14611772Sjl139090 } 14621772Sjl139090 14631772Sjl139090 /* 14641772Sjl139090 * In OPL SCF does the stick synchronization. 14651772Sjl139090 */ 14661772Sjl139090 void 14671772Sjl139090 sticksync_master(void) 14681772Sjl139090 { 14691772Sjl139090 } 14701772Sjl139090 14711772Sjl139090 /* 14721772Sjl139090 * Cpu private unitialization. OPL cpus do not use the private area. 14731772Sjl139090 */ 14741772Sjl139090 void 14751772Sjl139090 cpu_uninit_private(struct cpu *cp) 14761772Sjl139090 { 14771772Sjl139090 cmp_delete_cpu(cp->cpu_id); 14781772Sjl139090 } 14791772Sjl139090 14801772Sjl139090 /* 14811772Sjl139090 * Always flush an entire cache. 14821772Sjl139090 */ 14831772Sjl139090 void 14841772Sjl139090 cpu_error_ecache_flush(void) 14851772Sjl139090 { 14861772Sjl139090 cpu_flush_ecache(); 14871772Sjl139090 } 14881772Sjl139090 14891772Sjl139090 void 14901772Sjl139090 cpu_ereport_post(struct async_flt *aflt) 14911772Sjl139090 { 14921772Sjl139090 char *cpu_type, buf[FM_MAX_CLASS]; 14931772Sjl139090 nv_alloc_t *nva = NULL; 14941772Sjl139090 nvlist_t *ereport, *detector, *resource; 14951772Sjl139090 errorq_elem_t *eqep; 14961772Sjl139090 char sbuf[21]; /* sizeof (UINT64_MAX) + '\0' */ 14971772Sjl139090 14981772Sjl139090 if (aflt->flt_panic || panicstr) { 14991772Sjl139090 eqep = errorq_reserve(ereport_errorq); 15001772Sjl139090 if (eqep == NULL) 15011772Sjl139090 return; 15021772Sjl139090 ereport = errorq_elem_nvl(ereport_errorq, eqep); 15031772Sjl139090 nva = errorq_elem_nva(ereport_errorq, eqep); 15041772Sjl139090 } else { 15051772Sjl139090 ereport = fm_nvlist_create(nva); 15061772Sjl139090 } 15071772Sjl139090 15081772Sjl139090 /* 15091772Sjl139090 * Create the scheme "cpu" FMRI. 15101772Sjl139090 */ 15111772Sjl139090 detector = fm_nvlist_create(nva); 15121772Sjl139090 resource = fm_nvlist_create(nva); 15131772Sjl139090 switch (cpunodes[aflt->flt_inst].implementation) { 15141772Sjl139090 case OLYMPUS_C_IMPL: 15151772Sjl139090 cpu_type = FM_EREPORT_CPU_SPARC64_VI; 15161772Sjl139090 break; 15171772Sjl139090 default: 15181772Sjl139090 cpu_type = FM_EREPORT_CPU_UNSUPPORTED; 15191772Sjl139090 break; 15201772Sjl139090 } 15211772Sjl139090 (void) snprintf(sbuf, sizeof (sbuf), "%llX", 15221772Sjl139090 (u_longlong_t)cpunodes[aflt->flt_inst].device_id); 15231772Sjl139090 (void) fm_fmri_cpu_set(detector, FM_CPU_SCHEME_VERSION, NULL, 15241772Sjl139090 aflt->flt_inst, (uint8_t *)&cpunodes[aflt->flt_inst].version, 15251772Sjl139090 sbuf); 15261772Sjl139090 15271772Sjl139090 /* 15281772Sjl139090 * Encode all the common data into the ereport. 15291772Sjl139090 */ 15301772Sjl139090 (void) snprintf(buf, FM_MAX_CLASS, "%s.%s.%s", 15311772Sjl139090 FM_ERROR_CPU, cpu_type, aflt->flt_erpt_class); 15321772Sjl139090 15331772Sjl139090 fm_ereport_set(ereport, FM_EREPORT_VERSION, buf, 15341772Sjl139090 fm_ena_generate(aflt->flt_id, FM_ENA_FMT1), detector, NULL); 15351772Sjl139090 15361772Sjl139090 /* 15371772Sjl139090 * Encode the error specific data that was saved in 15381772Sjl139090 * the async_flt structure into the ereport. 15391772Sjl139090 */ 15401772Sjl139090 cpu_payload_add_aflt(aflt, ereport, resource); 15411772Sjl139090 15421772Sjl139090 if (aflt->flt_panic || panicstr) { 15431772Sjl139090 errorq_commit(ereport_errorq, eqep, ERRORQ_SYNC); 15441772Sjl139090 } else { 15451772Sjl139090 (void) fm_ereport_post(ereport, EVCH_TRYHARD); 15461772Sjl139090 fm_nvlist_destroy(ereport, FM_NVA_FREE); 15471772Sjl139090 fm_nvlist_destroy(detector, FM_NVA_FREE); 15481772Sjl139090 fm_nvlist_destroy(resource, FM_NVA_FREE); 15491772Sjl139090 } 15501772Sjl139090 } 15511772Sjl139090 15521772Sjl139090 void 15531772Sjl139090 cpu_run_bus_error_handlers(struct async_flt *aflt, int expected) 15541772Sjl139090 { 15551772Sjl139090 int status; 15561772Sjl139090 ddi_fm_error_t de; 15571772Sjl139090 15581772Sjl139090 bzero(&de, sizeof (ddi_fm_error_t)); 15591772Sjl139090 15601772Sjl139090 de.fme_version = DDI_FME_VERSION; 15611772Sjl139090 de.fme_ena = fm_ena_generate(aflt->flt_id, FM_ENA_FMT1); 15621772Sjl139090 de.fme_flag = expected; 15631772Sjl139090 de.fme_bus_specific = (void *)aflt->flt_addr; 15641772Sjl139090 status = ndi_fm_handler_dispatch(ddi_root_node(), NULL, &de); 15651772Sjl139090 if ((aflt->flt_prot == AFLT_PROT_NONE) && (status == DDI_FM_FATAL)) 15661772Sjl139090 aflt->flt_panic = 1; 15671772Sjl139090 } 15681772Sjl139090 15691772Sjl139090 void 15701772Sjl139090 cpu_errorq_dispatch(char *error_class, void *payload, size_t payload_sz, 15711772Sjl139090 errorq_t *eqp, uint_t flag) 15721772Sjl139090 { 15731772Sjl139090 struct async_flt *aflt = (struct async_flt *)payload; 15741772Sjl139090 15751772Sjl139090 aflt->flt_erpt_class = error_class; 15761772Sjl139090 errorq_dispatch(eqp, payload, payload_sz, flag); 15771772Sjl139090 } 15781772Sjl139090 15791772Sjl139090 void 15801772Sjl139090 adjust_hw_copy_limits(int ecache_size) 15811772Sjl139090 { 15821772Sjl139090 /* 15831772Sjl139090 * Set hw copy limits. 15841772Sjl139090 * 15851772Sjl139090 * /etc/system will be parsed later and can override one or more 15861772Sjl139090 * of these settings. 15871772Sjl139090 * 15881772Sjl139090 * At this time, ecache size seems only mildly relevant. 15891772Sjl139090 * We seem to run into issues with the d-cache and stalls 15901772Sjl139090 * we see on misses. 15911772Sjl139090 * 15921772Sjl139090 * Cycle measurement indicates that 2 byte aligned copies fare 15931772Sjl139090 * little better than doing things with VIS at around 512 bytes. 15941772Sjl139090 * 4 byte aligned shows promise until around 1024 bytes. 8 Byte 15951772Sjl139090 * aligned is faster whenever the source and destination data 15961772Sjl139090 * in cache and the total size is less than 2 Kbytes. The 2K 15971772Sjl139090 * limit seems to be driven by the 2K write cache. 15981772Sjl139090 * When more than 2K of copies are done in non-VIS mode, stores 15991772Sjl139090 * backup in the write cache. In VIS mode, the write cache is 16001772Sjl139090 * bypassed, allowing faster cache-line writes aligned on cache 16011772Sjl139090 * boundaries. 16021772Sjl139090 * 16031772Sjl139090 * In addition, in non-VIS mode, there is no prefetching, so 16041772Sjl139090 * for larger copies, the advantage of prefetching to avoid even 16051772Sjl139090 * occasional cache misses is enough to justify using the VIS code. 16061772Sjl139090 * 16071772Sjl139090 * During testing, it was discovered that netbench ran 3% slower 16081772Sjl139090 * when hw_copy_limit_8 was 2K or larger. Apparently for server 16091772Sjl139090 * applications, data is only used once (copied to the output 16101772Sjl139090 * buffer, then copied by the network device off the system). Using 16111772Sjl139090 * the VIS copy saves more L2 cache state. Network copies are 16121772Sjl139090 * around 1.3K to 1.5K in size for historical reasons. 16131772Sjl139090 * 16141772Sjl139090 * Therefore, a limit of 1K bytes will be used for the 8 byte 16151772Sjl139090 * aligned copy even for large caches and 8 MB ecache. The 16161772Sjl139090 * infrastructure to allow different limits for different sized 16171772Sjl139090 * caches is kept to allow further tuning in later releases. 16181772Sjl139090 */ 16191772Sjl139090 16201772Sjl139090 if (min_ecache_size == 0 && use_hw_bcopy) { 16211772Sjl139090 /* 16221772Sjl139090 * First time through - should be before /etc/system 16231772Sjl139090 * is read. 16241772Sjl139090 * Could skip the checks for zero but this lets us 16251772Sjl139090 * preserve any debugger rewrites. 16261772Sjl139090 */ 16271772Sjl139090 if (hw_copy_limit_1 == 0) { 16281772Sjl139090 hw_copy_limit_1 = VIS_COPY_THRESHOLD; 16291772Sjl139090 priv_hcl_1 = hw_copy_limit_1; 16301772Sjl139090 } 16311772Sjl139090 if (hw_copy_limit_2 == 0) { 16321772Sjl139090 hw_copy_limit_2 = 2 * VIS_COPY_THRESHOLD; 16331772Sjl139090 priv_hcl_2 = hw_copy_limit_2; 16341772Sjl139090 } 16351772Sjl139090 if (hw_copy_limit_4 == 0) { 16361772Sjl139090 hw_copy_limit_4 = 4 * VIS_COPY_THRESHOLD; 16371772Sjl139090 priv_hcl_4 = hw_copy_limit_4; 16381772Sjl139090 } 16391772Sjl139090 if (hw_copy_limit_8 == 0) { 16401772Sjl139090 hw_copy_limit_8 = 4 * VIS_COPY_THRESHOLD; 16411772Sjl139090 priv_hcl_8 = hw_copy_limit_8; 16421772Sjl139090 } 16431772Sjl139090 min_ecache_size = ecache_size; 16441772Sjl139090 } else { 16451772Sjl139090 /* 16461772Sjl139090 * MP initialization. Called *after* /etc/system has 16471772Sjl139090 * been parsed. One CPU has already been initialized. 16481772Sjl139090 * Need to cater for /etc/system having scragged one 16491772Sjl139090 * of our values. 16501772Sjl139090 */ 16511772Sjl139090 if (ecache_size == min_ecache_size) { 16521772Sjl139090 /* 16531772Sjl139090 * Same size ecache. We do nothing unless we 16541772Sjl139090 * have a pessimistic ecache setting. In that 16551772Sjl139090 * case we become more optimistic (if the cache is 16561772Sjl139090 * large enough). 16571772Sjl139090 */ 16581772Sjl139090 if (hw_copy_limit_8 == 4 * VIS_COPY_THRESHOLD) { 16591772Sjl139090 /* 16601772Sjl139090 * Need to adjust hw_copy_limit* from our 16611772Sjl139090 * pessimistic uniprocessor value to a more 16621772Sjl139090 * optimistic UP value *iff* it hasn't been 16631772Sjl139090 * reset. 16641772Sjl139090 */ 16651772Sjl139090 if ((ecache_size > 1048576) && 16661772Sjl139090 (priv_hcl_8 == hw_copy_limit_8)) { 16671772Sjl139090 if (ecache_size <= 2097152) 16681772Sjl139090 hw_copy_limit_8 = 4 * 16691772Sjl139090 VIS_COPY_THRESHOLD; 16701772Sjl139090 else if (ecache_size <= 4194304) 16711772Sjl139090 hw_copy_limit_8 = 4 * 16721772Sjl139090 VIS_COPY_THRESHOLD; 16731772Sjl139090 else 16741772Sjl139090 hw_copy_limit_8 = 4 * 16751772Sjl139090 VIS_COPY_THRESHOLD; 16761772Sjl139090 priv_hcl_8 = hw_copy_limit_8; 16771772Sjl139090 } 16781772Sjl139090 } 16791772Sjl139090 } else if (ecache_size < min_ecache_size) { 16801772Sjl139090 /* 16811772Sjl139090 * A different ecache size. Can this even happen? 16821772Sjl139090 */ 16831772Sjl139090 if (priv_hcl_8 == hw_copy_limit_8) { 16841772Sjl139090 /* 16851772Sjl139090 * The previous value that we set 16861772Sjl139090 * is unchanged (i.e., it hasn't been 16871772Sjl139090 * scragged by /etc/system). Rewrite it. 16881772Sjl139090 */ 16891772Sjl139090 if (ecache_size <= 1048576) 16901772Sjl139090 hw_copy_limit_8 = 8 * 16911772Sjl139090 VIS_COPY_THRESHOLD; 16921772Sjl139090 else if (ecache_size <= 2097152) 16931772Sjl139090 hw_copy_limit_8 = 8 * 16941772Sjl139090 VIS_COPY_THRESHOLD; 16951772Sjl139090 else if (ecache_size <= 4194304) 16961772Sjl139090 hw_copy_limit_8 = 8 * 16971772Sjl139090 VIS_COPY_THRESHOLD; 16981772Sjl139090 else 16991772Sjl139090 hw_copy_limit_8 = 10 * 17001772Sjl139090 VIS_COPY_THRESHOLD; 17011772Sjl139090 priv_hcl_8 = hw_copy_limit_8; 17021772Sjl139090 min_ecache_size = ecache_size; 17031772Sjl139090 } 17041772Sjl139090 } 17051772Sjl139090 } 17061772Sjl139090 } 17071772Sjl139090 17081772Sjl139090 #define VIS_BLOCKSIZE 64 17091772Sjl139090 17101772Sjl139090 int 17111772Sjl139090 dtrace_blksuword32_err(uintptr_t addr, uint32_t *data) 17121772Sjl139090 { 17131772Sjl139090 int ret, watched; 17141772Sjl139090 17151772Sjl139090 watched = watch_disable_addr((void *)addr, VIS_BLOCKSIZE, S_WRITE); 17161772Sjl139090 ret = dtrace_blksuword32(addr, data, 0); 17171772Sjl139090 if (watched) 17181772Sjl139090 watch_enable_addr((void *)addr, VIS_BLOCKSIZE, S_WRITE); 17191772Sjl139090 17201772Sjl139090 return (ret); 17211772Sjl139090 } 17221772Sjl139090 17231772Sjl139090 void 17241772Sjl139090 opl_cpu_reg_init() 17251772Sjl139090 { 17261772Sjl139090 uint64_t this_cpu_log; 17271772Sjl139090 17281772Sjl139090 /* 17291772Sjl139090 * We do not need to re-initialize cpu0 registers. 17301772Sjl139090 */ 17311772Sjl139090 if (cpu[getprocessorid()] == &cpu0) 17321772Sjl139090 return; 17331772Sjl139090 17341772Sjl139090 /* 17351772Sjl139090 * Initialize Error log Scratch register for error handling. 17361772Sjl139090 */ 17371772Sjl139090 17381772Sjl139090 this_cpu_log = va_to_pa((void*)(((uint64_t)opl_err_log) + 17391772Sjl139090 ERRLOG_BUFSZ * (getprocessorid()))); 17401772Sjl139090 opl_error_setup(this_cpu_log); 17411772Sjl139090 17421772Sjl139090 /* 17431772Sjl139090 * Enable MMU translating multiple page sizes for 17441772Sjl139090 * sITLB and sDTLB. 17451772Sjl139090 */ 17461772Sjl139090 opl_mpg_enable(); 17471772Sjl139090 } 17481772Sjl139090 17491772Sjl139090 /* 17501772Sjl139090 * Queue one event in ue_queue based on ecc_type_to_info entry. 17511772Sjl139090 */ 17521772Sjl139090 static void 17531772Sjl139090 cpu_queue_one_event(opl_async_flt_t *opl_flt, char *reason, 17541772Sjl139090 ecc_type_to_info_t *eccp) 17551772Sjl139090 { 17561772Sjl139090 struct async_flt *aflt = (struct async_flt *)opl_flt; 17571772Sjl139090 17581772Sjl139090 if (reason && 17591772Sjl139090 strlen(reason) + strlen(eccp->ec_reason) < MAX_REASON_STRING) { 17601772Sjl139090 (void) strcat(reason, eccp->ec_reason); 17611772Sjl139090 } 17621772Sjl139090 17631772Sjl139090 opl_flt->flt_bit = eccp->ec_afsr_bit; 17641772Sjl139090 opl_flt->flt_type = eccp->ec_flt_type; 17651772Sjl139090 aflt->flt_in_memory = cpu_flt_in_memory(opl_flt, opl_flt->flt_bit); 17661772Sjl139090 aflt->flt_payload = eccp->ec_err_payload; 17671772Sjl139090 17681772Sjl139090 ASSERT(aflt->flt_status & (OPL_ECC_SYNC_TRAP|OPL_ECC_URGENT_TRAP)); 17691772Sjl139090 cpu_errorq_dispatch(eccp->ec_err_class, 17701772Sjl139090 (void *)opl_flt, sizeof (opl_async_flt_t), 17711772Sjl139090 ue_queue, 17721772Sjl139090 aflt->flt_panic); 17731772Sjl139090 } 17741772Sjl139090 17751772Sjl139090 /* 17761772Sjl139090 * Queue events on async event queue one event per error bit. 17771772Sjl139090 * Return number of events queued. 17781772Sjl139090 */ 17791772Sjl139090 int 17801772Sjl139090 cpu_queue_events(opl_async_flt_t *opl_flt, char *reason, uint64_t t_afsr_errs) 17811772Sjl139090 { 17821772Sjl139090 struct async_flt *aflt = (struct async_flt *)opl_flt; 17831772Sjl139090 ecc_type_to_info_t *eccp; 17841772Sjl139090 int nevents = 0; 17851772Sjl139090 17861772Sjl139090 /* 17871772Sjl139090 * Queue expected errors, error bit and fault type must must match 17881772Sjl139090 * in the ecc_type_to_info table. 17891772Sjl139090 */ 17901772Sjl139090 for (eccp = ecc_type_to_info; t_afsr_errs != 0 && eccp->ec_desc != NULL; 17911772Sjl139090 eccp++) { 17921772Sjl139090 if ((eccp->ec_afsr_bit & t_afsr_errs) != 0 && 17931772Sjl139090 (eccp->ec_flags & aflt->flt_status) != 0) { 17941772Sjl139090 /* 17951772Sjl139090 * UE error event can be further 17961772Sjl139090 * classified/breakdown into finer granularity 17971772Sjl139090 * based on the flt_eid_mod value set by HW. We do 17981772Sjl139090 * special handling here so that we can report UE 17991772Sjl139090 * error in finer granularity as ue_mem, 18001772Sjl139090 * ue_channel, ue_cpu or ue_path. 18011772Sjl139090 */ 18021772Sjl139090 if (eccp->ec_flt_type == OPL_CPU_SYNC_UE) { 18031772Sjl139090 opl_flt->flt_eid_mod = 18041772Sjl139090 (aflt->flt_stat & SFSR_EID_MOD) 18051772Sjl139090 >> SFSR_EID_MOD_SHIFT; 18061772Sjl139090 opl_flt->flt_eid_sid = 18071772Sjl139090 (aflt->flt_stat & SFSR_EID_SID) 18081772Sjl139090 >> SFSR_EID_SID_SHIFT; 18091772Sjl139090 /* 18101772Sjl139090 * Need to advance eccp pointer by flt_eid_mod 18111772Sjl139090 * so that we get an appropriate ecc pointer 18121772Sjl139090 * 18131772Sjl139090 * EID # of advances 18141772Sjl139090 * ---------------------------------- 18151772Sjl139090 * OPL_ERRID_MEM 0 18161772Sjl139090 * OPL_ERRID_CHANNEL 1 18171772Sjl139090 * OPL_ERRID_CPU 2 18181772Sjl139090 * OPL_ERRID_PATH 3 18191772Sjl139090 */ 18201772Sjl139090 eccp += opl_flt->flt_eid_mod; 18211772Sjl139090 } 18221772Sjl139090 cpu_queue_one_event(opl_flt, reason, eccp); 18231772Sjl139090 t_afsr_errs &= ~eccp->ec_afsr_bit; 18241772Sjl139090 nevents++; 18251772Sjl139090 } 18261772Sjl139090 } 18271772Sjl139090 18281772Sjl139090 return (nevents); 18291772Sjl139090 } 18301772Sjl139090 18311772Sjl139090 /* 18321772Sjl139090 * Sync. error wrapper functions. 18331772Sjl139090 * We use these functions in order to transfer here from the 18341772Sjl139090 * nucleus trap handler information about trap type (data or 18351772Sjl139090 * instruction) and trap level (0 or above 0). This way we 18361772Sjl139090 * get rid of using SFSR's reserved bits. 18371772Sjl139090 */ 18381772Sjl139090 18391772Sjl139090 #define OPL_SYNC_TL0 0 18401772Sjl139090 #define OPL_SYNC_TL1 1 18411772Sjl139090 #define OPL_ISYNC_ERR 0 18421772Sjl139090 #define OPL_DSYNC_ERR 1 18431772Sjl139090 18441772Sjl139090 void 18451772Sjl139090 opl_cpu_isync_tl0_error(struct regs *rp, ulong_t p_sfar, ulong_t p_sfsr) 18461772Sjl139090 { 18471772Sjl139090 uint64_t t_sfar = p_sfar; 18481772Sjl139090 uint64_t t_sfsr = p_sfsr; 18491772Sjl139090 18501772Sjl139090 opl_cpu_sync_error(rp, t_sfar, t_sfsr, 18511772Sjl139090 OPL_SYNC_TL0, OPL_ISYNC_ERR); 18521772Sjl139090 } 18531772Sjl139090 18541772Sjl139090 void 18551772Sjl139090 opl_cpu_isync_tl1_error(struct regs *rp, ulong_t p_sfar, ulong_t p_sfsr) 18561772Sjl139090 { 18571772Sjl139090 uint64_t t_sfar = p_sfar; 18581772Sjl139090 uint64_t t_sfsr = p_sfsr; 18591772Sjl139090 18601772Sjl139090 opl_cpu_sync_error(rp, t_sfar, t_sfsr, 18611772Sjl139090 OPL_SYNC_TL1, OPL_ISYNC_ERR); 18621772Sjl139090 } 18631772Sjl139090 18641772Sjl139090 void 18651772Sjl139090 opl_cpu_dsync_tl0_error(struct regs *rp, ulong_t p_sfar, ulong_t p_sfsr) 18661772Sjl139090 { 18671772Sjl139090 uint64_t t_sfar = p_sfar; 18681772Sjl139090 uint64_t t_sfsr = p_sfsr; 18691772Sjl139090 18701772Sjl139090 opl_cpu_sync_error(rp, t_sfar, t_sfsr, 18711772Sjl139090 OPL_SYNC_TL0, OPL_DSYNC_ERR); 18721772Sjl139090 } 18731772Sjl139090 18741772Sjl139090 void 18751772Sjl139090 opl_cpu_dsync_tl1_error(struct regs *rp, ulong_t p_sfar, ulong_t p_sfsr) 18761772Sjl139090 { 18771772Sjl139090 uint64_t t_sfar = p_sfar; 18781772Sjl139090 uint64_t t_sfsr = p_sfsr; 18791772Sjl139090 18801772Sjl139090 opl_cpu_sync_error(rp, t_sfar, t_sfsr, 18811772Sjl139090 OPL_SYNC_TL1, OPL_DSYNC_ERR); 18821772Sjl139090 } 18831772Sjl139090 18841772Sjl139090 /* 18851772Sjl139090 * The fj sync err handler transfers control here for UE, BERR, TO, TLB_MUL 18861772Sjl139090 * and TLB_PRT. 18871772Sjl139090 * This function is designed based on cpu_deferred_error(). 18881772Sjl139090 */ 18891772Sjl139090 18901772Sjl139090 static void 18911772Sjl139090 opl_cpu_sync_error(struct regs *rp, ulong_t t_sfar, ulong_t t_sfsr, 18921772Sjl139090 uint_t tl, uint_t derr) 18931772Sjl139090 { 18941772Sjl139090 opl_async_flt_t opl_flt; 18951772Sjl139090 struct async_flt *aflt; 18961772Sjl139090 int trampolined = 0; 18971772Sjl139090 char pr_reason[MAX_REASON_STRING]; 18981772Sjl139090 uint64_t log_sfsr; 18991772Sjl139090 int expected = DDI_FM_ERR_UNEXPECTED; 19001772Sjl139090 ddi_acc_hdl_t *hp; 19011772Sjl139090 19021772Sjl139090 /* 19031772Sjl139090 * We need to look at p_flag to determine if the thread detected an 19041772Sjl139090 * error while dumping core. We can't grab p_lock here, but it's ok 19051772Sjl139090 * because we just need a consistent snapshot and we know that everyone 19061772Sjl139090 * else will store a consistent set of bits while holding p_lock. We 19071772Sjl139090 * don't have to worry about a race because SDOCORE is set once prior 19081772Sjl139090 * to doing i/o from the process's address space and is never cleared. 19091772Sjl139090 */ 19101772Sjl139090 uint_t pflag = ttoproc(curthread)->p_flag; 19111772Sjl139090 19121772Sjl139090 pr_reason[0] = '\0'; 19131772Sjl139090 19141772Sjl139090 /* 19151772Sjl139090 * handle the specific error 19161772Sjl139090 */ 19171772Sjl139090 bzero(&opl_flt, sizeof (opl_async_flt_t)); 19181772Sjl139090 aflt = (struct async_flt *)&opl_flt; 19191772Sjl139090 aflt->flt_id = gethrtime_waitfree(); 19201772Sjl139090 aflt->flt_bus_id = getprocessorid(); 19211772Sjl139090 aflt->flt_inst = CPU->cpu_id; 19221772Sjl139090 aflt->flt_stat = t_sfsr; 19231772Sjl139090 aflt->flt_addr = t_sfar; 19241772Sjl139090 aflt->flt_pc = (caddr_t)rp->r_pc; 19251772Sjl139090 aflt->flt_prot = (uchar_t)AFLT_PROT_NONE; 19261772Sjl139090 aflt->flt_class = (uchar_t)CPU_FAULT; 19271772Sjl139090 aflt->flt_priv = (uchar_t) 19281772Sjl139090 (tl == 1 ? 1 : ((rp->r_tstate & TSTATE_PRIV) ? 1 : 0)); 19291772Sjl139090 aflt->flt_tl = (uchar_t)tl; 19301772Sjl139090 aflt->flt_panic = (uchar_t)(tl != 0 || aft_testfatal != 0 || 19311772Sjl139090 (t_sfsr & (SFSR_TLB_MUL|SFSR_TLB_PRT)) != 0); 19321772Sjl139090 aflt->flt_core = (pflag & SDOCORE) ? 1 : 0; 19331772Sjl139090 aflt->flt_status = (derr) ? OPL_ECC_DSYNC_TRAP : OPL_ECC_ISYNC_TRAP; 19341772Sjl139090 19351772Sjl139090 /* 19361772Sjl139090 * If SFSR.FV is not set, both SFSR and SFAR/SFPAR values are uncertain. 19371772Sjl139090 * So, clear all error bits to avoid mis-handling and force the system 19381772Sjl139090 * panicked. 19391772Sjl139090 * We skip all the procedures below down to the panic message call. 19401772Sjl139090 */ 19411772Sjl139090 if (!(t_sfsr & SFSR_FV)) { 19421772Sjl139090 opl_flt.flt_type = OPL_CPU_INV_SFSR; 19431772Sjl139090 aflt->flt_panic = 1; 19441772Sjl139090 aflt->flt_payload = FM_EREPORT_PAYLOAD_SYNC; 19451772Sjl139090 cpu_errorq_dispatch(FM_EREPORT_CPU_INV_SFSR, 19461772Sjl139090 (void *)&opl_flt, sizeof (opl_async_flt_t), ue_queue, 19471772Sjl139090 aflt->flt_panic); 19481772Sjl139090 fm_panic("%sErrors(s)", "invalid SFSR"); 19491772Sjl139090 } 19501772Sjl139090 19511772Sjl139090 /* 19521772Sjl139090 * If either UE and MK bit is off, this is not valid UE error. 19531772Sjl139090 * If it is not valid UE error, clear UE & MK_UE bits to prevent 19541772Sjl139090 * mis-handling below. 19551772Sjl139090 * aflt->flt_stat keeps the original bits as a reference. 19561772Sjl139090 */ 19571772Sjl139090 if ((t_sfsr & (SFSR_MK_UE|SFSR_UE)) != 19581772Sjl139090 (SFSR_MK_UE|SFSR_UE)) { 19591772Sjl139090 t_sfsr &= ~(SFSR_MK_UE|SFSR_UE); 19601772Sjl139090 } 19611772Sjl139090 19621772Sjl139090 /* 19631772Sjl139090 * If the trap occurred in privileged mode at TL=0, we need to check to 19641772Sjl139090 * see if we were executing in the kernel under on_trap() or t_lofault 19651772Sjl139090 * protection. If so, modify the saved registers so that we return 19661772Sjl139090 * from the trap to the appropriate trampoline routine. 19671772Sjl139090 */ 19681772Sjl139090 if (!aflt->flt_panic && aflt->flt_priv && tl == 0) { 19691772Sjl139090 if (curthread->t_ontrap != NULL) { 19701772Sjl139090 on_trap_data_t *otp = curthread->t_ontrap; 19711772Sjl139090 19721772Sjl139090 if (otp->ot_prot & OT_DATA_EC) { 19731772Sjl139090 aflt->flt_prot = (uchar_t)AFLT_PROT_EC; 19741772Sjl139090 otp->ot_trap |= (ushort_t)OT_DATA_EC; 19751772Sjl139090 rp->r_pc = otp->ot_trampoline; 19761772Sjl139090 rp->r_npc = rp->r_pc + 4; 19771772Sjl139090 trampolined = 1; 19781772Sjl139090 } 19791772Sjl139090 19801772Sjl139090 if ((t_sfsr & (SFSR_TO | SFSR_BERR)) && 19811772Sjl139090 (otp->ot_prot & OT_DATA_ACCESS)) { 19821772Sjl139090 aflt->flt_prot = (uchar_t)AFLT_PROT_ACCESS; 19831772Sjl139090 otp->ot_trap |= (ushort_t)OT_DATA_ACCESS; 19841772Sjl139090 rp->r_pc = otp->ot_trampoline; 19851772Sjl139090 rp->r_npc = rp->r_pc + 4; 19861772Sjl139090 trampolined = 1; 19871772Sjl139090 /* 19881772Sjl139090 * for peeks and caut_gets errors are expected 19891772Sjl139090 */ 19901772Sjl139090 hp = (ddi_acc_hdl_t *)otp->ot_handle; 19911772Sjl139090 if (!hp) 19921772Sjl139090 expected = DDI_FM_ERR_PEEK; 19931772Sjl139090 else if (hp->ah_acc.devacc_attr_access == 19941772Sjl139090 DDI_CAUTIOUS_ACC) 19951772Sjl139090 expected = DDI_FM_ERR_EXPECTED; 19961772Sjl139090 } 19971772Sjl139090 19981772Sjl139090 } else if (curthread->t_lofault) { 19991772Sjl139090 aflt->flt_prot = AFLT_PROT_COPY; 20001772Sjl139090 rp->r_g1 = EFAULT; 20011772Sjl139090 rp->r_pc = curthread->t_lofault; 20021772Sjl139090 rp->r_npc = rp->r_pc + 4; 20031772Sjl139090 trampolined = 1; 20041772Sjl139090 } 20051772Sjl139090 } 20061772Sjl139090 20071772Sjl139090 /* 20081772Sjl139090 * If we're in user mode or we're doing a protected copy, we either 20091772Sjl139090 * want the ASTON code below to send a signal to the user process 20101772Sjl139090 * or we want to panic if aft_panic is set. 20111772Sjl139090 * 20121772Sjl139090 * If we're in privileged mode and we're not doing a copy, then we 20131772Sjl139090 * need to check if we've trampolined. If we haven't trampolined, 20141772Sjl139090 * we should panic. 20151772Sjl139090 */ 20161772Sjl139090 if (!aflt->flt_priv || aflt->flt_prot == AFLT_PROT_COPY) { 20171772Sjl139090 if (t_sfsr & (SFSR_ERRS & ~(SFSR_BERR | SFSR_TO))) 20181772Sjl139090 aflt->flt_panic |= aft_panic; 20191772Sjl139090 } else if (!trampolined) { 20201772Sjl139090 aflt->flt_panic = 1; 20211772Sjl139090 } 20221772Sjl139090 20231772Sjl139090 /* 20241772Sjl139090 * If we've trampolined due to a privileged TO or BERR, or if an 20251772Sjl139090 * unprivileged TO or BERR occurred, we don't want to enqueue an 20261772Sjl139090 * event for that TO or BERR. Queue all other events (if any) besides 20271772Sjl139090 * the TO/BERR. 20281772Sjl139090 */ 20291772Sjl139090 log_sfsr = t_sfsr; 20301772Sjl139090 if (trampolined) { 20311772Sjl139090 log_sfsr &= ~(SFSR_TO | SFSR_BERR); 20321772Sjl139090 } else if (!aflt->flt_priv) { 20331772Sjl139090 /* 20341772Sjl139090 * User mode, suppress messages if 20351772Sjl139090 * cpu_berr_to_verbose is not set. 20361772Sjl139090 */ 20371772Sjl139090 if (!cpu_berr_to_verbose) 20381772Sjl139090 log_sfsr &= ~(SFSR_TO | SFSR_BERR); 20391772Sjl139090 } 20401772Sjl139090 20411772Sjl139090 if (((log_sfsr & SFSR_ERRS) && 20421772Sjl139090 (cpu_queue_events(&opl_flt, pr_reason, t_sfsr) == 0)) || 20431772Sjl139090 ((t_sfsr & SFSR_ERRS) == 0)) { 20441772Sjl139090 opl_flt.flt_type = OPL_CPU_INV_SFSR; 20451772Sjl139090 aflt->flt_payload = FM_EREPORT_PAYLOAD_SYNC; 20461772Sjl139090 cpu_errorq_dispatch(FM_EREPORT_CPU_INV_SFSR, 20471772Sjl139090 (void *)&opl_flt, sizeof (opl_async_flt_t), ue_queue, 20481772Sjl139090 aflt->flt_panic); 20491772Sjl139090 } 20501772Sjl139090 20511772Sjl139090 if (t_sfsr & (SFSR_UE|SFSR_TO|SFSR_BERR)) { 20521772Sjl139090 cpu_run_bus_error_handlers(aflt, expected); 20531772Sjl139090 } 20541772Sjl139090 20551772Sjl139090 /* 20561772Sjl139090 * Panic here if aflt->flt_panic has been set. Enqueued errors will 20571772Sjl139090 * be logged as part of the panic flow. 20581772Sjl139090 */ 20591772Sjl139090 if (aflt->flt_panic) { 20601772Sjl139090 if (pr_reason[0] == 0) 20611772Sjl139090 strcpy(pr_reason, "invalid SFSR "); 20621772Sjl139090 20631772Sjl139090 fm_panic("%sErrors(s)", pr_reason); 20641772Sjl139090 } 20651772Sjl139090 20661772Sjl139090 /* 20671772Sjl139090 * If we queued an error and we are going to return from the trap and 20681772Sjl139090 * the error was in user mode or inside of a copy routine, set AST flag 20691772Sjl139090 * so the queue will be drained before returning to user mode. The 20701772Sjl139090 * AST processing will also act on our failure policy. 20711772Sjl139090 */ 20721772Sjl139090 if (!aflt->flt_priv || aflt->flt_prot == AFLT_PROT_COPY) { 20731772Sjl139090 int pcb_flag = 0; 20741772Sjl139090 20751772Sjl139090 if (t_sfsr & (SFSR_ERRS & 20761772Sjl139090 ~(SFSR_BERR | SFSR_TO))) 20771772Sjl139090 pcb_flag |= ASYNC_HWERR; 20781772Sjl139090 20791772Sjl139090 if (t_sfsr & SFSR_BERR) 20801772Sjl139090 pcb_flag |= ASYNC_BERR; 20811772Sjl139090 20821772Sjl139090 if (t_sfsr & SFSR_TO) 20831772Sjl139090 pcb_flag |= ASYNC_BTO; 20841772Sjl139090 20851772Sjl139090 ttolwp(curthread)->lwp_pcb.pcb_flags |= pcb_flag; 20861772Sjl139090 aston(curthread); 20871772Sjl139090 } 20881772Sjl139090 } 20891772Sjl139090 20901772Sjl139090 /*ARGSUSED*/ 20911772Sjl139090 void 20921772Sjl139090 opl_cpu_urgent_error(struct regs *rp, ulong_t p_ugesr, ulong_t tl) 20931772Sjl139090 { 20941772Sjl139090 opl_async_flt_t opl_flt; 20951772Sjl139090 struct async_flt *aflt; 20961772Sjl139090 char pr_reason[MAX_REASON_STRING]; 20971772Sjl139090 20981772Sjl139090 /* normalize tl */ 20991772Sjl139090 tl = (tl >= 2 ? 1 : 0); 21001772Sjl139090 pr_reason[0] = '\0'; 21011772Sjl139090 21021772Sjl139090 bzero(&opl_flt, sizeof (opl_async_flt_t)); 21031772Sjl139090 aflt = (struct async_flt *)&opl_flt; 21041772Sjl139090 aflt->flt_id = gethrtime_waitfree(); 21051772Sjl139090 aflt->flt_bus_id = getprocessorid(); 21061772Sjl139090 aflt->flt_inst = CPU->cpu_id; 21071772Sjl139090 aflt->flt_stat = p_ugesr; 21081772Sjl139090 aflt->flt_pc = (caddr_t)rp->r_pc; 21091772Sjl139090 aflt->flt_class = (uchar_t)CPU_FAULT; 21101772Sjl139090 aflt->flt_tl = tl; 21111772Sjl139090 aflt->flt_priv = (uchar_t) 21121772Sjl139090 (tl == 1 ? 1 : ((rp->r_tstate & TSTATE_PRIV) ? 1 : 0)); 21131772Sjl139090 aflt->flt_status = OPL_ECC_URGENT_TRAP; 21141772Sjl139090 aflt->flt_panic = 1; 21151772Sjl139090 /* 21161772Sjl139090 * HW does not set mod/sid in case of urgent error. 21171772Sjl139090 * So we have to set it here. 21181772Sjl139090 */ 21191772Sjl139090 opl_flt.flt_eid_mod = OPL_ERRID_CPU; 21201772Sjl139090 opl_flt.flt_eid_sid = aflt->flt_inst; 21211772Sjl139090 21221772Sjl139090 if (cpu_queue_events(&opl_flt, pr_reason, p_ugesr) == 0) { 21231772Sjl139090 opl_flt.flt_type = OPL_CPU_INV_UGESR; 21241772Sjl139090 aflt->flt_payload = FM_EREPORT_PAYLOAD_URGENT; 21251772Sjl139090 cpu_errorq_dispatch(FM_EREPORT_CPU_INV_URG, 21261772Sjl139090 (void *)&opl_flt, sizeof (opl_async_flt_t), 21271772Sjl139090 ue_queue, aflt->flt_panic); 21281772Sjl139090 } 21291772Sjl139090 21301772Sjl139090 fm_panic("Urgent Error"); 21311772Sjl139090 } 21321772Sjl139090 21331772Sjl139090 /* 21341772Sjl139090 * Initialization error counters resetting. 21351772Sjl139090 */ 21361772Sjl139090 /* ARGSUSED */ 21371772Sjl139090 static void 21381772Sjl139090 opl_ras_online(void *arg, cpu_t *cp, cyc_handler_t *hdlr, cyc_time_t *when) 21391772Sjl139090 { 21401772Sjl139090 hdlr->cyh_func = (cyc_func_t)ras_cntr_reset; 21411772Sjl139090 hdlr->cyh_level = CY_LOW_LEVEL; 21421772Sjl139090 hdlr->cyh_arg = (void *)(uintptr_t)cp->cpu_id; 21431772Sjl139090 21441772Sjl139090 when->cyt_when = cp->cpu_id * (((hrtime_t)NANOSEC * 10)/ NCPU); 21451772Sjl139090 when->cyt_interval = (hrtime_t)NANOSEC * opl_async_check_interval; 21461772Sjl139090 } 21471772Sjl139090 21481772Sjl139090 void 21491772Sjl139090 cpu_mp_init(void) 21501772Sjl139090 { 21511772Sjl139090 cyc_omni_handler_t hdlr; 21521772Sjl139090 21531772Sjl139090 hdlr.cyo_online = opl_ras_online; 21541772Sjl139090 hdlr.cyo_offline = NULL; 21551772Sjl139090 hdlr.cyo_arg = NULL; 21561772Sjl139090 mutex_enter(&cpu_lock); 21571772Sjl139090 (void) cyclic_add_omni(&hdlr); 21581772Sjl139090 mutex_exit(&cpu_lock); 21591772Sjl139090 } 21601772Sjl139090 21611772Sjl139090 /*ARGSUSED*/ 21621772Sjl139090 void 21631772Sjl139090 mmu_init_kernel_pgsz(struct hat *hat) 21641772Sjl139090 { 21651772Sjl139090 } 21661772Sjl139090 21671772Sjl139090 size_t 21681772Sjl139090 mmu_get_kernel_lpsize(size_t lpsize) 21691772Sjl139090 { 21701772Sjl139090 uint_t tte; 21711772Sjl139090 21721772Sjl139090 if (lpsize == 0) { 21731772Sjl139090 /* no setting for segkmem_lpsize in /etc/system: use default */ 21741772Sjl139090 return (MMU_PAGESIZE4M); 21751772Sjl139090 } 21761772Sjl139090 21771772Sjl139090 for (tte = TTE8K; tte <= TTE4M; tte++) { 21781772Sjl139090 if (lpsize == TTEBYTES(tte)) 21791772Sjl139090 return (lpsize); 21801772Sjl139090 } 21811772Sjl139090 21821772Sjl139090 return (TTEBYTES(TTE8K)); 21831772Sjl139090 } 21841772Sjl139090 21851772Sjl139090 /* 21861772Sjl139090 * The following are functions that are unused in 21871772Sjl139090 * OPL cpu module. They are defined here to resolve 21881772Sjl139090 * dependencies in the "unix" module. 21891772Sjl139090 * Unused functions that should never be called in 21901772Sjl139090 * OPL are coded with ASSERT(0). 21911772Sjl139090 */ 21921772Sjl139090 21931772Sjl139090 void 21941772Sjl139090 cpu_disable_errors(void) 21951772Sjl139090 {} 21961772Sjl139090 21971772Sjl139090 void 21981772Sjl139090 cpu_enable_errors(void) 21991772Sjl139090 { ASSERT(0); } 22001772Sjl139090 22011772Sjl139090 /*ARGSUSED*/ 22021772Sjl139090 void 22031772Sjl139090 cpu_ce_scrub_mem_err(struct async_flt *ecc, boolean_t t) 22041772Sjl139090 { ASSERT(0); } 22051772Sjl139090 22061772Sjl139090 /*ARGSUSED*/ 22071772Sjl139090 void 22081772Sjl139090 cpu_faulted_enter(struct cpu *cp) 22091772Sjl139090 {} 22101772Sjl139090 22111772Sjl139090 /*ARGSUSED*/ 22121772Sjl139090 void 22131772Sjl139090 cpu_faulted_exit(struct cpu *cp) 22141772Sjl139090 {} 22151772Sjl139090 22161772Sjl139090 /*ARGSUSED*/ 22171772Sjl139090 void 22181772Sjl139090 cpu_check_allcpus(struct async_flt *aflt) 22191772Sjl139090 {} 22201772Sjl139090 22211772Sjl139090 /*ARGSUSED*/ 22221772Sjl139090 void 22231772Sjl139090 cpu_ce_log_err(struct async_flt *aflt, errorq_elem_t *t) 22241772Sjl139090 { ASSERT(0); } 22251772Sjl139090 22261772Sjl139090 /*ARGSUSED*/ 22271772Sjl139090 void 22281772Sjl139090 cpu_check_ce(int flag, uint64_t pa, caddr_t va, uint_t psz) 22291772Sjl139090 { ASSERT(0); } 22301772Sjl139090 22311772Sjl139090 /*ARGSUSED*/ 22321772Sjl139090 void 22331772Sjl139090 cpu_ce_count_unum(struct async_flt *ecc, int len, char *unum) 22341772Sjl139090 { ASSERT(0); } 22351772Sjl139090 22361772Sjl139090 /*ARGSUSED*/ 22371772Sjl139090 void 22381772Sjl139090 cpu_busy_ecache_scrub(struct cpu *cp) 22391772Sjl139090 {} 22401772Sjl139090 22411772Sjl139090 /*ARGSUSED*/ 22421772Sjl139090 void 22431772Sjl139090 cpu_idle_ecache_scrub(struct cpu *cp) 22441772Sjl139090 {} 22451772Sjl139090 22461772Sjl139090 /* ARGSUSED */ 22471772Sjl139090 void 22481772Sjl139090 cpu_change_speed(uint64_t divisor, uint64_t arg2) 22491772Sjl139090 { ASSERT(0); } 22501772Sjl139090 22511772Sjl139090 void 22521772Sjl139090 cpu_init_cache_scrub(void) 22531772Sjl139090 {} 22541772Sjl139090 22551772Sjl139090 /* ARGSUSED */ 22561772Sjl139090 int 22571772Sjl139090 cpu_get_mem_sid(char *unum, char *buf, int buflen, int *lenp) 22581772Sjl139090 { 22592214Sav145390 if (&plat_get_mem_sid) { 22602214Sav145390 return (plat_get_mem_sid(unum, buf, buflen, lenp)); 22612214Sav145390 } else { 22622214Sav145390 return (ENOTSUP); 22632214Sav145390 } 22641772Sjl139090 } 22651772Sjl139090 22661772Sjl139090 /* ARGSUSED */ 22671772Sjl139090 int 22681772Sjl139090 cpu_get_mem_addr(char *unum, char *sid, uint64_t offset, uint64_t *addrp) 22691772Sjl139090 { 22702214Sav145390 if (&plat_get_mem_addr) { 22712214Sav145390 return (plat_get_mem_addr(unum, sid, offset, addrp)); 22722214Sav145390 } else { 22732214Sav145390 return (ENOTSUP); 22742214Sav145390 } 22751772Sjl139090 } 22761772Sjl139090 22771772Sjl139090 /* ARGSUSED */ 22781772Sjl139090 int 22791772Sjl139090 cpu_get_mem_offset(uint64_t flt_addr, uint64_t *offp) 22801772Sjl139090 { 22812214Sav145390 if (&plat_get_mem_offset) { 22822214Sav145390 return (plat_get_mem_offset(flt_addr, offp)); 22832214Sav145390 } else { 22842214Sav145390 return (ENOTSUP); 22852214Sav145390 } 22861772Sjl139090 } 22871772Sjl139090 22881772Sjl139090 /*ARGSUSED*/ 22891772Sjl139090 void 22901772Sjl139090 itlb_rd_entry(uint_t entry, tte_t *tte, uint64_t *va_tag) 22911772Sjl139090 { ASSERT(0); } 22921772Sjl139090 22931772Sjl139090 /*ARGSUSED*/ 22941772Sjl139090 void 22951772Sjl139090 dtlb_rd_entry(uint_t entry, tte_t *tte, uint64_t *va_tag) 22961772Sjl139090 { ASSERT(0); } 22972203Shyw 22982203Shyw /*ARGSUSED*/ 22992203Shyw void 23002203Shyw read_ecc_data(struct async_flt *aflt, short verbose, short ce_err) 23012203Shyw { ASSERT(0); } 23022203Shyw 23032203Shyw /*ARGSUSED*/ 23042203Shyw int 23052203Shyw ce_scrub_xdiag_recirc(struct async_flt *aflt, errorq_t *eqp, 23062203Shyw errorq_elem_t *eqep, size_t afltoffset) 23072203Shyw { 23082203Shyw ASSERT(0); 23092203Shyw return (0); 23102203Shyw } 23112203Shyw 23122203Shyw /*ARGSUSED*/ 23132203Shyw char * 23142203Shyw flt_to_error_type(struct async_flt *aflt) 23152203Shyw { 23162203Shyw ASSERT(0); 23172203Shyw return (NULL); 23182203Shyw } 2319