17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5c56c1e58Sgirish * Common Development and Distribution License (the "License"). 6c56c1e58Sgirish * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22c56c1e58Sgirish * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/types.h> 297c478bd9Sstevel@tonic-gate #include <sys/systm.h> 307c478bd9Sstevel@tonic-gate #include <sys/archsystm.h> 317c478bd9Sstevel@tonic-gate #include <sys/machparam.h> 327c478bd9Sstevel@tonic-gate #include <sys/machsystm.h> 337c478bd9Sstevel@tonic-gate #include <sys/cpu.h> 347c478bd9Sstevel@tonic-gate #include <sys/elf_SPARC.h> 357c478bd9Sstevel@tonic-gate #include <vm/hat_sfmmu.h> 367c478bd9Sstevel@tonic-gate #include <vm/page.h> 377c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 387c478bd9Sstevel@tonic-gate #include <sys/async.h> 397c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 407c478bd9Sstevel@tonic-gate #include <sys/debug.h> 417c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 427c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 437c478bd9Sstevel@tonic-gate #include <sys/cpu_module.h> 447c478bd9Sstevel@tonic-gate #include <sys/prom_debug.h> 457c478bd9Sstevel@tonic-gate #include <sys/vmsystm.h> 467c478bd9Sstevel@tonic-gate #include <sys/prom_plat.h> 477c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 487c478bd9Sstevel@tonic-gate #include <sys/intreg.h> 497c478bd9Sstevel@tonic-gate #include <sys/machtrap.h> 507c478bd9Sstevel@tonic-gate #include <sys/ontrap.h> 517c478bd9Sstevel@tonic-gate #include <sys/ivintr.h> 527c478bd9Sstevel@tonic-gate #include <sys/atomic.h> 537c478bd9Sstevel@tonic-gate #include <sys/panic.h> 547c478bd9Sstevel@tonic-gate #include <sys/dtrace.h> 557c478bd9Sstevel@tonic-gate #include <sys/simulate.h> 567c478bd9Sstevel@tonic-gate #include <sys/fault.h> 57ce0352ebSgirish #include <sys/niagararegs.h> 58ce0352ebSgirish #include <sys/trapstat.h> 59c56c1e58Sgirish #include <sys/hsvc.h> 607c478bd9Sstevel@tonic-gate 61*1ae08745Sheppo #define NI_MMU_PAGESIZE_MASK ((1 << TTE8K) | (1 << TTE64K) | (1 << TTE4M) \ 62*1ae08745Sheppo | (1 << TTE256M)) 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate uint_t root_phys_addr_lo_mask = 0xffffffffU; 65ce0352ebSgirish static niagara_mmustat_t *cpu_tstat_va; /* VA of mmustat buffer */ 66ce0352ebSgirish static uint64_t cpu_tstat_pa; /* PA of mmustat buffer */ 67c56c1e58Sgirish char cpu_module_name[] = "SUNW,UltraSPARC-T1"; 687c478bd9Sstevel@tonic-gate 69c56c1e58Sgirish /* 70c56c1e58Sgirish * Hypervisor services information for the NIAGARA CPU module 71c56c1e58Sgirish */ 72c56c1e58Sgirish static boolean_t niagara_hsvc_available = B_TRUE; 73c56c1e58Sgirish static uint64_t niagara_sup_minor; /* Supported minor number */ 74c56c1e58Sgirish static hsvc_info_t niagara_hsvc = { 75c56c1e58Sgirish HSVC_REV_1, NULL, HSVC_GROUP_NIAGARA_CPU, 1, 0, cpu_module_name 76c56c1e58Sgirish }; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate void 797c478bd9Sstevel@tonic-gate cpu_setup(void) 807c478bd9Sstevel@tonic-gate { 817c478bd9Sstevel@tonic-gate extern int mmu_exported_pagesize_mask; 827c478bd9Sstevel@tonic-gate extern int cpc_has_overflow_intr; 83c56c1e58Sgirish int status; 84*1ae08745Sheppo char *ni_isa_set[] = { 85*1ae08745Sheppo "sparcv9+vis", 86*1ae08745Sheppo "sparcv9+vis2", 87*1ae08745Sheppo "sparcv8plus+vis", 88*1ae08745Sheppo "sparcv8plus+vis2", 89*1ae08745Sheppo NULL 90*1ae08745Sheppo }; 91c56c1e58Sgirish 92c56c1e58Sgirish /* 93c56c1e58Sgirish * Negotiate the API version for Niagara specific hypervisor 94c56c1e58Sgirish * services. 95c56c1e58Sgirish */ 96c56c1e58Sgirish status = hsvc_register(&niagara_hsvc, &niagara_sup_minor); 97c56c1e58Sgirish if (status != 0) { 98c56c1e58Sgirish cmn_err(CE_WARN, "%s: cannot negotiate hypervisor services " 9980ab886dSwesolows "group: 0x%lx major: 0x%lx minor: 0x%lx errno: %d\n", 100c56c1e58Sgirish niagara_hsvc.hsvc_modname, niagara_hsvc.hsvc_group, 101c56c1e58Sgirish niagara_hsvc.hsvc_major, niagara_hsvc.hsvc_minor, status); 102c56c1e58Sgirish niagara_hsvc_available = B_FALSE; 103c56c1e58Sgirish } 1047c478bd9Sstevel@tonic-gate 105*1ae08745Sheppo /* 106*1ae08745Sheppo * The setup common to all CPU modules is done in cpu_setup_common 107*1ae08745Sheppo * routine. 108*1ae08745Sheppo */ 109*1ae08745Sheppo cpu_setup_common(ni_isa_set); 110*1ae08745Sheppo 1117c478bd9Sstevel@tonic-gate cache |= (CACHE_PTAG | CACHE_IOCOHERENT); 1127c478bd9Sstevel@tonic-gate 113*1ae08745Sheppo if (broken_md_flag) { 1147c478bd9Sstevel@tonic-gate /* 115*1ae08745Sheppo * Turn on the missing bits supported by Niagara CPU in 116*1ae08745Sheppo * MMU pagesize mask returned by MD. 1177c478bd9Sstevel@tonic-gate */ 118*1ae08745Sheppo mmu_exported_pagesize_mask |= NI_MMU_PAGESIZE_MASK; 119*1ae08745Sheppo } else { 120*1ae08745Sheppo if ((mmu_exported_pagesize_mask & 121*1ae08745Sheppo DEFAULT_SUN4V_MMU_PAGESIZE_MASK) != 122*1ae08745Sheppo DEFAULT_SUN4V_MMU_PAGESIZE_MASK) 123*1ae08745Sheppo cmn_err(CE_PANIC, "machine description" 124*1ae08745Sheppo " does not have required sun4v page sizes" 125*1ae08745Sheppo " 8K, 64K and 4M: MD mask is 0x%x", 126*1ae08745Sheppo mmu_exported_pagesize_mask); 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate cpu_hwcap_flags |= AV_SPARC_ASI_BLK_INIT; 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 13207e2e5e8Sgirish * Niagara supports a 48-bit subset of the full 64-bit virtual 13307e2e5e8Sgirish * address space. Virtual addresses between 0x0000800000000000 13407e2e5e8Sgirish * and 0xffff.7fff.ffff.ffff inclusive lie within a "VA Hole" 13507e2e5e8Sgirish * and must never be mapped. In addition, software must not use 13607e2e5e8Sgirish * pages within 4GB of the VA hole as instruction pages to 13707e2e5e8Sgirish * avoid problems with prefetching into the VA hole. 1387c478bd9Sstevel@tonic-gate */ 139*1ae08745Sheppo hole_start = (caddr_t)((1ull << (va_bits - 1)) - (1ull << 32)); 140*1ae08745Sheppo hole_end = (caddr_t)((0ull - (1ull << (va_bits - 1))) + (1ull << 32)); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * Niagara has a performance counter overflow interrupt 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate cpc_has_overflow_intr = 1; 1467c478bd9Sstevel@tonic-gate } 1477c478bd9Sstevel@tonic-gate 148*1ae08745Sheppo #define MB(n) ((n) * 1024 * 1024) 1497c478bd9Sstevel@tonic-gate /* 1507c478bd9Sstevel@tonic-gate * Set the magic constants of the implementation. 1517c478bd9Sstevel@tonic-gate */ 1527c478bd9Sstevel@tonic-gate void 1537c478bd9Sstevel@tonic-gate cpu_fiximp(struct cpu_node *cpunode) 1547c478bd9Sstevel@tonic-gate { 1557c478bd9Sstevel@tonic-gate /* 156*1ae08745Sheppo * The Cache node is optional in MD. Therefore in case "Cache" 157*1ae08745Sheppo * node does not exists in MD, set the default L2 cache associativity, 158*1ae08745Sheppo * size, linesize. 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate if (cpunode->ecache_size == 0) 161*1ae08745Sheppo cpunode->ecache_size = MB(3); 1627c478bd9Sstevel@tonic-gate if (cpunode->ecache_linesize == 0) 1637c478bd9Sstevel@tonic-gate cpunode->ecache_linesize = 64; 1647c478bd9Sstevel@tonic-gate if (cpunode->ecache_associativity == 0) 1657c478bd9Sstevel@tonic-gate cpunode->ecache_associativity = 12; 1667c478bd9Sstevel@tonic-gate } 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate static int niagara_cpucnt; 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate void 1717c478bd9Sstevel@tonic-gate cpu_init_private(struct cpu *cp) 1727c478bd9Sstevel@tonic-gate { 1737c478bd9Sstevel@tonic-gate extern int niagara_kstat_init(void); 1747c478bd9Sstevel@tonic-gate 17570f54eadSesaxe /* 176*1ae08745Sheppo * The cpu_ipipe field is initialized based on the execution 177*1ae08745Sheppo * unit sharing information from the MD. It defaults to the 178*1ae08745Sheppo * virtual CPU id in the absence of such information. 17970f54eadSesaxe */ 180*1ae08745Sheppo cp->cpu_m.cpu_ipipe = cpunodes[cp->cpu_id].exec_unit_mapping; 181*1ae08745Sheppo if (cp->cpu_m.cpu_ipipe == NO_EU_MAPPING_FOUND) 182*1ae08745Sheppo cp->cpu_m.cpu_ipipe = (id_t)(cp->cpu_id); 18370f54eadSesaxe 1847c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&cpu_lock)); 185c56c1e58Sgirish if (niagara_cpucnt++ == 0 && niagara_hsvc_available == B_TRUE) { 1867c478bd9Sstevel@tonic-gate (void) niagara_kstat_init(); 1877c478bd9Sstevel@tonic-gate } 1887c478bd9Sstevel@tonic-gate } 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate void 1917c478bd9Sstevel@tonic-gate cpu_uninit_private(struct cpu *cp) 1927c478bd9Sstevel@tonic-gate { 1937c478bd9Sstevel@tonic-gate extern int niagara_kstat_fini(void); 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&cpu_lock)); 196c56c1e58Sgirish if (--niagara_cpucnt == 0 && niagara_hsvc_available == B_TRUE) { 1977c478bd9Sstevel@tonic-gate (void) niagara_kstat_fini(); 1987c478bd9Sstevel@tonic-gate } 1997c478bd9Sstevel@tonic-gate } 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate /* 2027c478bd9Sstevel@tonic-gate * On Niagara, any flush will cause all preceding stores to be 2037c478bd9Sstevel@tonic-gate * synchronized wrt the i$, regardless of address or ASI. In fact, 2047c478bd9Sstevel@tonic-gate * the address is ignored, so we always flush address 0. 2057c478bd9Sstevel@tonic-gate */ 2067c478bd9Sstevel@tonic-gate void 2077c478bd9Sstevel@tonic-gate dtrace_flush_sec(uintptr_t addr) 2087c478bd9Sstevel@tonic-gate { 2097c478bd9Sstevel@tonic-gate doflush(0); 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #define IS_FLOAT(i) (((i) & 0x1000000) != 0) 2137c478bd9Sstevel@tonic-gate #define IS_IBIT_SET(x) (x & 0x2000) 2147c478bd9Sstevel@tonic-gate #define IS_VIS1(op, op3)(op == 2 && op3 == 0x36) 2157c478bd9Sstevel@tonic-gate #define IS_PARTIAL_OR_SHORT_FLOAT_LD_ST(op, op3, asi) \ 2167c478bd9Sstevel@tonic-gate (op == 3 && (op3 == IOP_V8_LDDFA || \ 2177c478bd9Sstevel@tonic-gate op3 == IOP_V8_STDFA) && asi > ASI_SNFL) 2187c478bd9Sstevel@tonic-gate int 2197c478bd9Sstevel@tonic-gate vis1_partial_support(struct regs *rp, k_siginfo_t *siginfo, uint_t *fault) 2207c478bd9Sstevel@tonic-gate { 2217c478bd9Sstevel@tonic-gate char *badaddr; 2227c478bd9Sstevel@tonic-gate int instr; 2237c478bd9Sstevel@tonic-gate uint_t optype, op3, asi; 2247c478bd9Sstevel@tonic-gate uint_t rd, ignor; 2257c478bd9Sstevel@tonic-gate 226efaef81fSarao if (!USERMODE(rp->r_tstate)) 227efaef81fSarao return (-1); 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate instr = fetch_user_instr((caddr_t)rp->r_pc); 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate rd = (instr >> 25) & 0x1f; 2327c478bd9Sstevel@tonic-gate optype = (instr >> 30) & 0x3; 2337c478bd9Sstevel@tonic-gate op3 = (instr >> 19) & 0x3f; 2347c478bd9Sstevel@tonic-gate ignor = (instr >> 5) & 0xff; 2357c478bd9Sstevel@tonic-gate if (IS_IBIT_SET(instr)) { 2367c478bd9Sstevel@tonic-gate asi = (uint32_t)((rp->r_tstate >> TSTATE_ASI_SHIFT) & 2377c478bd9Sstevel@tonic-gate TSTATE_ASI_MASK); 2387c478bd9Sstevel@tonic-gate } else { 2397c478bd9Sstevel@tonic-gate asi = ignor; 2407c478bd9Sstevel@tonic-gate } 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate if (!IS_VIS1(optype, op3) && 2437c478bd9Sstevel@tonic-gate !IS_PARTIAL_OR_SHORT_FLOAT_LD_ST(optype, op3, asi)) { 2447c478bd9Sstevel@tonic-gate return (-1); 2457c478bd9Sstevel@tonic-gate } 2467c478bd9Sstevel@tonic-gate switch (simulate_unimp(rp, &badaddr)) { 2477c478bd9Sstevel@tonic-gate case SIMU_RETRY: 2487c478bd9Sstevel@tonic-gate break; /* regs are already set up */ 2497c478bd9Sstevel@tonic-gate /*NOTREACHED*/ 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate case SIMU_SUCCESS: 2527c478bd9Sstevel@tonic-gate /* 2537c478bd9Sstevel@tonic-gate * skip the successfully 2547c478bd9Sstevel@tonic-gate * simulated instruction 2557c478bd9Sstevel@tonic-gate */ 2567c478bd9Sstevel@tonic-gate rp->r_pc = rp->r_npc; 2577c478bd9Sstevel@tonic-gate rp->r_npc += 4; 2587c478bd9Sstevel@tonic-gate break; 2597c478bd9Sstevel@tonic-gate /*NOTREACHED*/ 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate case SIMU_FAULT: 2627c478bd9Sstevel@tonic-gate siginfo->si_signo = SIGSEGV; 2637c478bd9Sstevel@tonic-gate siginfo->si_code = SEGV_MAPERR; 2647c478bd9Sstevel@tonic-gate siginfo->si_addr = badaddr; 2657c478bd9Sstevel@tonic-gate *fault = FLTBOUNDS; 2667c478bd9Sstevel@tonic-gate break; 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate case SIMU_DZERO: 2697c478bd9Sstevel@tonic-gate siginfo->si_signo = SIGFPE; 2707c478bd9Sstevel@tonic-gate siginfo->si_code = FPE_INTDIV; 2717c478bd9Sstevel@tonic-gate siginfo->si_addr = (caddr_t)rp->r_pc; 2727c478bd9Sstevel@tonic-gate *fault = FLTIZDIV; 2737c478bd9Sstevel@tonic-gate break; 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate case SIMU_UNALIGN: 2767c478bd9Sstevel@tonic-gate siginfo->si_signo = SIGBUS; 2777c478bd9Sstevel@tonic-gate siginfo->si_code = BUS_ADRALN; 2787c478bd9Sstevel@tonic-gate siginfo->si_addr = badaddr; 2797c478bd9Sstevel@tonic-gate *fault = FLTACCESS; 2807c478bd9Sstevel@tonic-gate break; 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate case SIMU_ILLEGAL: 2837c478bd9Sstevel@tonic-gate default: 2847c478bd9Sstevel@tonic-gate siginfo->si_signo = SIGILL; 2857c478bd9Sstevel@tonic-gate op3 = (instr >> 19) & 0x3F; 2867c478bd9Sstevel@tonic-gate if ((IS_FLOAT(instr) && (op3 == IOP_V8_STQFA) || 2877c478bd9Sstevel@tonic-gate (op3 == IOP_V8_STDFA))) 2887c478bd9Sstevel@tonic-gate siginfo->si_code = ILL_ILLADR; 2897c478bd9Sstevel@tonic-gate else 2907c478bd9Sstevel@tonic-gate siginfo->si_code = ILL_ILLOPC; 2917c478bd9Sstevel@tonic-gate siginfo->si_addr = (caddr_t)rp->r_pc; 2927c478bd9Sstevel@tonic-gate *fault = FLTILL; 2937c478bd9Sstevel@tonic-gate break; 2947c478bd9Sstevel@tonic-gate } 2957c478bd9Sstevel@tonic-gate return (0); 2967c478bd9Sstevel@tonic-gate } 297ce0352ebSgirish 298ce0352ebSgirish /* 299ce0352ebSgirish * Trapstat support for Niagara processor 300ce0352ebSgirish */ 301ce0352ebSgirish int 302ce0352ebSgirish cpu_trapstat_conf(int cmd) 303ce0352ebSgirish { 304ce0352ebSgirish size_t len; 305ce0352ebSgirish uint64_t mmustat_pa, hvret; 306ce0352ebSgirish int status = 0; 307ce0352ebSgirish 308c56c1e58Sgirish if (niagara_hsvc_available == B_FALSE) 309c56c1e58Sgirish return (ENOTSUP); 310c56c1e58Sgirish 311ce0352ebSgirish switch (cmd) { 312ce0352ebSgirish case CPU_TSTATCONF_INIT: 313ce0352ebSgirish ASSERT(cpu_tstat_va == NULL); 314ce0352ebSgirish len = (NCPU+1) * sizeof (niagara_mmustat_t); 315ce0352ebSgirish cpu_tstat_va = contig_mem_alloc_align(len, 316ce0352ebSgirish sizeof (niagara_mmustat_t)); 317ce0352ebSgirish if (cpu_tstat_va == NULL) 318ce0352ebSgirish status = EAGAIN; 319ce0352ebSgirish else { 320ce0352ebSgirish bzero(cpu_tstat_va, len); 321ce0352ebSgirish cpu_tstat_pa = va_to_pa(cpu_tstat_va); 322ce0352ebSgirish } 323ce0352ebSgirish break; 324ce0352ebSgirish 325ce0352ebSgirish case CPU_TSTATCONF_FINI: 326ce0352ebSgirish if (cpu_tstat_va) { 327ce0352ebSgirish len = (NCPU+1) * sizeof (niagara_mmustat_t); 328ce0352ebSgirish contig_mem_free(cpu_tstat_va, len); 329ce0352ebSgirish cpu_tstat_va = NULL; 330ce0352ebSgirish cpu_tstat_pa = 0; 331ce0352ebSgirish } 332ce0352ebSgirish break; 333ce0352ebSgirish 334ce0352ebSgirish case CPU_TSTATCONF_ENABLE: 335ce0352ebSgirish hvret = hv_niagara_mmustat_conf((cpu_tstat_pa + 336ce0352ebSgirish (CPU->cpu_id+1) * sizeof (niagara_mmustat_t)), 337ce0352ebSgirish (uint64_t *)&mmustat_pa); 338ce0352ebSgirish if (hvret != H_EOK) 339ce0352ebSgirish status = EINVAL; 340ce0352ebSgirish break; 341ce0352ebSgirish 342ce0352ebSgirish case CPU_TSTATCONF_DISABLE: 343ce0352ebSgirish hvret = hv_niagara_mmustat_conf(0, (uint64_t *)&mmustat_pa); 344ce0352ebSgirish if (hvret != H_EOK) 345ce0352ebSgirish status = EINVAL; 346ce0352ebSgirish break; 347ce0352ebSgirish 348ce0352ebSgirish default: 349ce0352ebSgirish status = EINVAL; 350ce0352ebSgirish break; 351ce0352ebSgirish } 352ce0352ebSgirish return (status); 353ce0352ebSgirish } 354ce0352ebSgirish 355ce0352ebSgirish void 356ce0352ebSgirish cpu_trapstat_data(void *buf, uint_t tstat_pgszs) 357ce0352ebSgirish { 358ce0352ebSgirish niagara_mmustat_t *mmustatp; 359ce0352ebSgirish tstat_pgszdata_t *tstatp = (tstat_pgszdata_t *)buf; 360ce0352ebSgirish int i, pgcnt; 361ce0352ebSgirish 362ce0352ebSgirish if (cpu_tstat_va == NULL) 363ce0352ebSgirish return; 364ce0352ebSgirish 365ce0352ebSgirish mmustatp = &((niagara_mmustat_t *)cpu_tstat_va)[CPU->cpu_id+1]; 366ce0352ebSgirish if (tstat_pgszs > NIAGARA_MMUSTAT_PGSZS) 367ce0352ebSgirish tstat_pgszs = NIAGARA_MMUSTAT_PGSZS; 368ce0352ebSgirish 369ce0352ebSgirish for (i = 0; i < tstat_pgszs; i++, tstatp++) { 370ce0352ebSgirish tstatp->tpgsz_kernel.tmode_itlb.ttlb_tlb.tmiss_count = 371ce0352ebSgirish mmustatp->kitsb[i].tsbhit_count; 372ce0352ebSgirish tstatp->tpgsz_kernel.tmode_itlb.ttlb_tlb.tmiss_time = 373ce0352ebSgirish mmustatp->kitsb[i].tsbhit_time; 374ce0352ebSgirish tstatp->tpgsz_user.tmode_itlb.ttlb_tlb.tmiss_count = 375ce0352ebSgirish mmustatp->uitsb[i].tsbhit_count; 376ce0352ebSgirish tstatp->tpgsz_user.tmode_itlb.ttlb_tlb.tmiss_time = 377ce0352ebSgirish mmustatp->uitsb[i].tsbhit_time; 378ce0352ebSgirish tstatp->tpgsz_kernel.tmode_dtlb.ttlb_tlb.tmiss_count = 379ce0352ebSgirish mmustatp->kdtsb[i].tsbhit_count; 380ce0352ebSgirish tstatp->tpgsz_kernel.tmode_dtlb.ttlb_tlb.tmiss_time = 381ce0352ebSgirish mmustatp->kdtsb[i].tsbhit_time; 382ce0352ebSgirish tstatp->tpgsz_user.tmode_dtlb.ttlb_tlb.tmiss_count = 383ce0352ebSgirish mmustatp->udtsb[i].tsbhit_count; 384ce0352ebSgirish tstatp->tpgsz_user.tmode_dtlb.ttlb_tlb.tmiss_time = 385ce0352ebSgirish mmustatp->udtsb[i].tsbhit_time; 386ce0352ebSgirish } 387ce0352ebSgirish } 388