144961713Sgirish /* 244961713Sgirish * CDDL HEADER START 344961713Sgirish * 444961713Sgirish * The contents of this file are subject to the terms of the 544961713Sgirish * Common Development and Distribution License (the "License"). 644961713Sgirish * You may not use this file except in compliance with the License. 744961713Sgirish * 844961713Sgirish * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 944961713Sgirish * or http://www.opensolaris.org/os/licensing. 1044961713Sgirish * See the License for the specific language governing permissions 1144961713Sgirish * and limitations under the License. 1244961713Sgirish * 1344961713Sgirish * When distributing Covered Code, include this CDDL HEADER in each 1444961713Sgirish * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1544961713Sgirish * If applicable, add the following below this CDDL HEADER, with the 1644961713Sgirish * fields enclosed by brackets "[]" replaced with your own identifying 1744961713Sgirish * information: Portions Copyright [yyyy] [name of copyright owner] 1844961713Sgirish * 1944961713Sgirish * CDDL HEADER END 2044961713Sgirish */ 2144961713Sgirish /* 22*fb2f18f8Sesaxe * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 2344961713Sgirish * Use is subject to license terms. 2444961713Sgirish */ 2544961713Sgirish 2644961713Sgirish #pragma ident "%Z%%M% %I% %E% SMI" 2744961713Sgirish 2844961713Sgirish #include <sys/types.h> 2944961713Sgirish #include <sys/systm.h> 3044961713Sgirish #include <sys/archsystm.h> 3144961713Sgirish #include <sys/machparam.h> 3244961713Sgirish #include <sys/machsystm.h> 3344961713Sgirish #include <sys/cpu.h> 3444961713Sgirish #include <sys/elf_SPARC.h> 3544961713Sgirish #include <vm/hat_sfmmu.h> 3644961713Sgirish #include <vm/page.h> 37102033aaSdp78419 #include <vm/vm_dep.h> 3844961713Sgirish #include <sys/cpuvar.h> 3944961713Sgirish #include <sys/async.h> 4044961713Sgirish #include <sys/cmn_err.h> 4144961713Sgirish #include <sys/debug.h> 4244961713Sgirish #include <sys/dditypes.h> 4344961713Sgirish #include <sys/sunddi.h> 4444961713Sgirish #include <sys/cpu_module.h> 4544961713Sgirish #include <sys/prom_debug.h> 4644961713Sgirish #include <sys/vmsystm.h> 4744961713Sgirish #include <sys/prom_plat.h> 4844961713Sgirish #include <sys/sysmacros.h> 4944961713Sgirish #include <sys/intreg.h> 5044961713Sgirish #include <sys/machtrap.h> 5144961713Sgirish #include <sys/ontrap.h> 5244961713Sgirish #include <sys/ivintr.h> 5344961713Sgirish #include <sys/atomic.h> 5444961713Sgirish #include <sys/panic.h> 5544961713Sgirish #include <sys/dtrace.h> 5644961713Sgirish #include <sys/simulate.h> 5744961713Sgirish #include <sys/fault.h> 5844961713Sgirish #include <sys/niagara2regs.h> 5944961713Sgirish #include <sys/hsvc.h> 6044961713Sgirish #include <sys/trapstat.h> 6144961713Sgirish 6244961713Sgirish uint_t root_phys_addr_lo_mask = 0xffffffffU; 6344961713Sgirish char cpu_module_name[] = "SUNW,UltraSPARC-T2"; 6444961713Sgirish 6544961713Sgirish /* 6644961713Sgirish * Hypervisor services information for the NIAGARA2 CPU module 6744961713Sgirish */ 6844961713Sgirish static boolean_t niagara2_hsvc_available = B_TRUE; 6944961713Sgirish static uint64_t niagara2_sup_minor; /* Supported minor number */ 7044961713Sgirish static hsvc_info_t niagara2_hsvc = { 7144961713Sgirish HSVC_REV_1, NULL, HSVC_GROUP_NIAGARA2_CPU, NIAGARA2_HSVC_MAJOR, 7244961713Sgirish NIAGARA2_HSVC_MINOR, cpu_module_name 7344961713Sgirish }; 7444961713Sgirish 7544961713Sgirish void 7644961713Sgirish cpu_setup(void) 7744961713Sgirish { 7844961713Sgirish extern int mmu_exported_pagesize_mask; 7944961713Sgirish extern int cpc_has_overflow_intr; 8044961713Sgirish int status; 8144961713Sgirish 8244961713Sgirish /* 8344961713Sgirish * Negotiate the API version for Niagara2 specific hypervisor 8444961713Sgirish * services. 8544961713Sgirish */ 8644961713Sgirish status = hsvc_register(&niagara2_hsvc, &niagara2_sup_minor); 8744961713Sgirish if (status != 0) { 8844961713Sgirish cmn_err(CE_WARN, "%s: cannot negotiate hypervisor services " 8944961713Sgirish "group: 0x%lx major: 0x%lx minor: 0x%lx errno: %d", 9044961713Sgirish niagara2_hsvc.hsvc_modname, niagara2_hsvc.hsvc_group, 9144961713Sgirish niagara2_hsvc.hsvc_major, niagara2_hsvc.hsvc_minor, status); 9244961713Sgirish niagara2_hsvc_available = B_FALSE; 9344961713Sgirish } 9444961713Sgirish 9544961713Sgirish /* 9644961713Sgirish * The setup common to all CPU modules is done in cpu_setup_common 9744961713Sgirish * routine. 9844961713Sgirish */ 9944961713Sgirish cpu_setup_common(NULL); 10044961713Sgirish 10144961713Sgirish cache |= (CACHE_PTAG | CACHE_IOCOHERENT); 10244961713Sgirish 10344961713Sgirish if ((mmu_exported_pagesize_mask & 10444961713Sgirish DEFAULT_SUN4V_MMU_PAGESIZE_MASK) != 10544961713Sgirish DEFAULT_SUN4V_MMU_PAGESIZE_MASK) 10644961713Sgirish cmn_err(CE_PANIC, "machine description" 10744961713Sgirish " does not have required sun4v page sizes" 10844961713Sgirish " 8K, 64K and 4M: MD mask is 0x%x", 10944961713Sgirish mmu_exported_pagesize_mask); 11044961713Sgirish 11144961713Sgirish cpu_hwcap_flags = AV_SPARC_VIS | AV_SPARC_VIS2 | AV_SPARC_ASI_BLK_INIT; 11244961713Sgirish 11344961713Sgirish /* 11444961713Sgirish * Niagara2 supports a 48-bit subset of the full 64-bit virtual 11544961713Sgirish * address space. Virtual addresses between 0x0000800000000000 11644961713Sgirish * and 0xffff.7fff.ffff.ffff inclusive lie within a "VA Hole" 11744961713Sgirish * and must never be mapped. In addition, software must not use 11844961713Sgirish * pages within 4GB of the VA hole as instruction pages to 11944961713Sgirish * avoid problems with prefetching into the VA hole. 12044961713Sgirish */ 12144961713Sgirish hole_start = (caddr_t)((1ull << (va_bits - 1)) - (1ull << 32)); 12244961713Sgirish hole_end = (caddr_t)((0ull - (1ull << (va_bits - 1))) + (1ull << 32)); 12344961713Sgirish 12444961713Sgirish /* 12544961713Sgirish * Niagara2 has a performance counter overflow interrupt 12644961713Sgirish */ 12744961713Sgirish cpc_has_overflow_intr = 1; 128102033aaSdp78419 129102033aaSdp78419 /* 130102033aaSdp78419 * Enable 4M pages for OOB. 131102033aaSdp78419 */ 132102033aaSdp78419 max_uheap_lpsize = MMU_PAGESIZE4M; 133102033aaSdp78419 max_ustack_lpsize = MMU_PAGESIZE4M; 134102033aaSdp78419 max_privmap_lpsize = MMU_PAGESIZE4M; 13544961713Sgirish } 13644961713Sgirish 13744961713Sgirish /* 13844961713Sgirish * Set the magic constants of the implementation. 13944961713Sgirish */ 14044961713Sgirish void 14144961713Sgirish cpu_fiximp(struct cpu_node *cpunode) 14244961713Sgirish { 14344961713Sgirish /* 14444961713Sgirish * The Cache node is optional in MD. Therefore in case "Cache" 14544961713Sgirish * node does not exists in MD, set the default L2 cache associativity, 14644961713Sgirish * size, linesize. 14744961713Sgirish */ 14844961713Sgirish if (cpunode->ecache_size == 0) 14944961713Sgirish cpunode->ecache_size = L2CACHE_SIZE; 15044961713Sgirish if (cpunode->ecache_linesize == 0) 15144961713Sgirish cpunode->ecache_linesize = L2CACHE_LINESIZE; 15244961713Sgirish if (cpunode->ecache_associativity == 0) 15344961713Sgirish cpunode->ecache_associativity = L2CACHE_ASSOCIATIVITY; 15444961713Sgirish } 15544961713Sgirish 15644961713Sgirish static int niagara2_cpucnt; 15744961713Sgirish 15844961713Sgirish void 15944961713Sgirish cpu_init_private(struct cpu *cp) 16044961713Sgirish { 16144961713Sgirish extern int niagara_kstat_init(void); 16244961713Sgirish 16344961713Sgirish /* 164*fb2f18f8Sesaxe * The cpu_ipipe and cpu_fpu fields are initialized based on 165*fb2f18f8Sesaxe * the execution unit sharing information from the MD. They default 166*fb2f18f8Sesaxe * to the virtual CPU id in the absence of such information. 16744961713Sgirish */ 16844961713Sgirish cp->cpu_m.cpu_ipipe = cpunodes[cp->cpu_id].exec_unit_mapping; 16944961713Sgirish if (cp->cpu_m.cpu_ipipe == NO_EU_MAPPING_FOUND) 17044961713Sgirish cp->cpu_m.cpu_ipipe = (id_t)(cp->cpu_id); 17144961713Sgirish 172*fb2f18f8Sesaxe cp->cpu_m.cpu_fpu = cpunodes[cp->cpu_id].fpu_mapping; 173*fb2f18f8Sesaxe if (cp->cpu_m.cpu_fpu == NO_EU_MAPPING_FOUND) 174*fb2f18f8Sesaxe cp->cpu_m.cpu_fpu = (id_t)(cp->cpu_id); 175*fb2f18f8Sesaxe 176*fb2f18f8Sesaxe /* 177*fb2f18f8Sesaxe * Niagara 2 defines the core to be at the FPU level 178*fb2f18f8Sesaxe */ 179*fb2f18f8Sesaxe cp->cpu_m.cpu_core = cp->cpu_m.cpu_fpu; 180*fb2f18f8Sesaxe 18144961713Sgirish ASSERT(MUTEX_HELD(&cpu_lock)); 18244961713Sgirish if ((niagara2_cpucnt++ == 0) && (niagara2_hsvc_available == B_TRUE)) 18344961713Sgirish (void) niagara_kstat_init(); 18444961713Sgirish } 18544961713Sgirish 18644961713Sgirish /*ARGSUSED*/ 18744961713Sgirish void 18844961713Sgirish cpu_uninit_private(struct cpu *cp) 18944961713Sgirish { 19044961713Sgirish extern int niagara_kstat_fini(void); 19144961713Sgirish 19244961713Sgirish ASSERT(MUTEX_HELD(&cpu_lock)); 19344961713Sgirish if ((--niagara2_cpucnt == 0) && (niagara2_hsvc_available == B_TRUE)) 19444961713Sgirish (void) niagara_kstat_fini(); 19544961713Sgirish } 19644961713Sgirish 19744961713Sgirish /* 19844961713Sgirish * On Niagara2, any flush will cause all preceding stores to be 19944961713Sgirish * synchronized wrt the i$, regardless of address or ASI. In fact, 20044961713Sgirish * the address is ignored, so we always flush address 0. 20144961713Sgirish */ 20244961713Sgirish /*ARGSUSED*/ 20344961713Sgirish void 20444961713Sgirish dtrace_flush_sec(uintptr_t addr) 20544961713Sgirish { 20644961713Sgirish doflush(0); 20744961713Sgirish } 20844961713Sgirish 20944961713Sgirish /* 21044961713Sgirish * Trapstat support for Niagara2 processor 21144961713Sgirish * The Niagara2 provides HWTW support for TSB lookup and with HWTW 21244961713Sgirish * enabled no TSB hit information will be available. Therefore setting 21344961713Sgirish * the time spent in TLB miss handler for TSB hits to 0. 21444961713Sgirish */ 21544961713Sgirish int 21644961713Sgirish cpu_trapstat_conf(int cmd) 21744961713Sgirish { 21844961713Sgirish int status = 0; 21944961713Sgirish 22044961713Sgirish switch (cmd) { 22144961713Sgirish case CPU_TSTATCONF_INIT: 22244961713Sgirish case CPU_TSTATCONF_FINI: 22344961713Sgirish case CPU_TSTATCONF_ENABLE: 22444961713Sgirish case CPU_TSTATCONF_DISABLE: 22544961713Sgirish break; 22644961713Sgirish default: 22744961713Sgirish status = EINVAL; 22844961713Sgirish break; 22944961713Sgirish } 23044961713Sgirish return (status); 23144961713Sgirish } 23244961713Sgirish 23344961713Sgirish void 23444961713Sgirish cpu_trapstat_data(void *buf, uint_t tstat_pgszs) 23544961713Sgirish { 23644961713Sgirish tstat_pgszdata_t *tstatp = (tstat_pgszdata_t *)buf; 23744961713Sgirish int i; 23844961713Sgirish 23944961713Sgirish for (i = 0; i < tstat_pgszs; i++, tstatp++) { 24044961713Sgirish tstatp->tpgsz_kernel.tmode_itlb.ttlb_tlb.tmiss_count = 0; 24144961713Sgirish tstatp->tpgsz_kernel.tmode_itlb.ttlb_tlb.tmiss_time = 0; 24244961713Sgirish tstatp->tpgsz_user.tmode_itlb.ttlb_tlb.tmiss_count = 0; 24344961713Sgirish tstatp->tpgsz_user.tmode_itlb.ttlb_tlb.tmiss_time = 0; 24444961713Sgirish tstatp->tpgsz_kernel.tmode_dtlb.ttlb_tlb.tmiss_count = 0; 24544961713Sgirish tstatp->tpgsz_kernel.tmode_dtlb.ttlb_tlb.tmiss_time = 0; 24644961713Sgirish tstatp->tpgsz_user.tmode_dtlb.ttlb_tlb.tmiss_count = 0; 24744961713Sgirish tstatp->tpgsz_user.tmode_dtlb.ttlb_tlb.tmiss_time = 0; 24844961713Sgirish } 24944961713Sgirish } 250102033aaSdp78419 251102033aaSdp78419 /* NI2 L2$ index is pa[32:28]^pa[17:13].pa[19:18]^pa[12:11].pa[10:6] */ 252102033aaSdp78419 uint_t 253102033aaSdp78419 page_pfn_2_color_cpu(pfn_t pfn, uchar_t szc) 254102033aaSdp78419 { 255102033aaSdp78419 uint_t color; 256102033aaSdp78419 257102033aaSdp78419 ASSERT(szc <= TTE256M); 258102033aaSdp78419 259102033aaSdp78419 pfn = PFN_BASE(pfn, szc); 260102033aaSdp78419 color = ((pfn >> 15) ^ pfn) & 0x1f; 261102033aaSdp78419 if (szc >= TTE4M) 262102033aaSdp78419 return (color); 263102033aaSdp78419 264102033aaSdp78419 color = (color << 2) | ((pfn >> 5) & 0x3); 265102033aaSdp78419 266102033aaSdp78419 return (szc <= TTE64K ? color : (color >> 1)); 267102033aaSdp78419 } 268102033aaSdp78419 269102033aaSdp78419 #if TTE256M != 5 270102033aaSdp78419 #error TTE256M is not 5 271102033aaSdp78419 #endif 272102033aaSdp78419 273102033aaSdp78419 uint_t 274102033aaSdp78419 page_get_nsz_color_mask_cpu(uchar_t szc, uint_t mask) 275102033aaSdp78419 { 276102033aaSdp78419 static uint_t ni2_color_masks[5] = {0x63, 0x1e, 0x3e, 0x1f, 0x1f}; 277102033aaSdp78419 ASSERT(szc < TTE256M); 278102033aaSdp78419 279102033aaSdp78419 mask &= ni2_color_masks[szc]; 280102033aaSdp78419 return ((szc == TTE64K || szc == TTE512K) ? (mask >> 1) : mask); 281102033aaSdp78419 } 282102033aaSdp78419 283102033aaSdp78419 uint_t 284102033aaSdp78419 page_get_nsz_color_cpu(uchar_t szc, uint_t color) 285102033aaSdp78419 { 286102033aaSdp78419 ASSERT(szc < TTE256M); 287102033aaSdp78419 return ((szc == TTE64K || szc == TTE512K) ? (color >> 1) : color); 288102033aaSdp78419 } 289102033aaSdp78419 290102033aaSdp78419 uint_t 291102033aaSdp78419 page_get_color_shift_cpu(uchar_t szc, uchar_t nszc) 292102033aaSdp78419 { 293102033aaSdp78419 ASSERT(nszc > szc); 294102033aaSdp78419 ASSERT(nszc <= TTE256M); 295102033aaSdp78419 296102033aaSdp78419 if (szc <= TTE64K) 297102033aaSdp78419 return ((nszc >= TTE4M) ? 2 : ((nszc >= TTE512K) ? 1 : 0)); 298102033aaSdp78419 if (szc == TTE512K) 299102033aaSdp78419 return (1); 300102033aaSdp78419 301102033aaSdp78419 return (0); 302102033aaSdp78419 } 303102033aaSdp78419 304102033aaSdp78419 /*ARGSUSED*/ 305102033aaSdp78419 pfn_t 306102033aaSdp78419 page_next_pfn_for_color_cpu(pfn_t pfn, uchar_t szc, uint_t color, 307102033aaSdp78419 uint_t ceq_mask, uint_t color_mask) 308102033aaSdp78419 { 309102033aaSdp78419 pfn_t pstep = PNUM_SIZE(szc); 310102033aaSdp78419 pfn_t npfn, pfn_ceq_mask, pfn_color; 311102033aaSdp78419 pfn_t tmpmask, mask = (pfn_t)-1; 312102033aaSdp78419 313102033aaSdp78419 ASSERT((color & ~ceq_mask) == 0); 314102033aaSdp78419 315102033aaSdp78419 if (((page_pfn_2_color_cpu(pfn, szc) ^ color) & ceq_mask) == 0) { 316102033aaSdp78419 317102033aaSdp78419 /* we start from the page with correct color */ 318102033aaSdp78419 if (szc >= TTE512K) { 319102033aaSdp78419 if (szc >= TTE4M) { 320102033aaSdp78419 /* page color is PA[32:28] */ 321102033aaSdp78419 pfn_ceq_mask = ceq_mask << 15; 322102033aaSdp78419 } else { 323102033aaSdp78419 /* page color is PA[32:28].PA[19:19] */ 324102033aaSdp78419 pfn_ceq_mask = ((ceq_mask & 1) << 6) | 325102033aaSdp78419 ((ceq_mask >> 1) << 15); 326102033aaSdp78419 } 327102033aaSdp78419 pfn = ADD_MASKED(pfn, pstep, pfn_ceq_mask, mask); 328102033aaSdp78419 return (pfn); 329102033aaSdp78419 } else { 330102033aaSdp78419 /* 331102033aaSdp78419 * We deal 64K or 8K page. Check if we could the 332102033aaSdp78419 * satisfy the request without changing PA[32:28] 333102033aaSdp78419 */ 334102033aaSdp78419 pfn_ceq_mask = ((ceq_mask & 3) << 5) | (ceq_mask >> 2); 335102033aaSdp78419 npfn = ADD_MASKED(pfn, pstep, pfn_ceq_mask, mask); 336102033aaSdp78419 337102033aaSdp78419 if ((((npfn ^ pfn) >> 15) & 0x1f) == 0) 338102033aaSdp78419 return (npfn); 339102033aaSdp78419 340102033aaSdp78419 /* 341102033aaSdp78419 * for next pfn we have to change bits PA[32:28] 342102033aaSdp78419 * set PA[63:28] and PA[19:18] of the next pfn 343102033aaSdp78419 */ 344102033aaSdp78419 npfn = (pfn >> 15) << 15; 345102033aaSdp78419 npfn |= (ceq_mask & color & 3) << 5; 346102033aaSdp78419 pfn_ceq_mask = (szc == TTE8K) ? 0 : 347102033aaSdp78419 (ceq_mask & 0x1c) << 13; 348102033aaSdp78419 npfn = ADD_MASKED(npfn, (1 << 15), pfn_ceq_mask, mask); 349102033aaSdp78419 350102033aaSdp78419 /* 351102033aaSdp78419 * set bits PA[17:13] to match the color 352102033aaSdp78419 */ 353102033aaSdp78419 ceq_mask >>= 2; 354102033aaSdp78419 color = (color >> 2) & ceq_mask; 355102033aaSdp78419 npfn |= ((npfn >> 15) ^ color) & ceq_mask; 356102033aaSdp78419 return (npfn); 357102033aaSdp78419 } 358102033aaSdp78419 } 359102033aaSdp78419 360102033aaSdp78419 /* 361102033aaSdp78419 * we start from the page with incorrect color - rare case 362102033aaSdp78419 */ 363102033aaSdp78419 if (szc >= TTE512K) { 364102033aaSdp78419 if (szc >= TTE4M) { 365102033aaSdp78419 /* page color is in bits PA[32:28] */ 366102033aaSdp78419 npfn = ((pfn >> 20) << 20) | (color << 15); 367102033aaSdp78419 pfn_ceq_mask = (ceq_mask << 15) | 0x7fff; 368102033aaSdp78419 } else { 369102033aaSdp78419 /* try get the right color by changing bit PA[19:19] */ 370102033aaSdp78419 npfn = pfn + pstep; 371102033aaSdp78419 if (((page_pfn_2_color_cpu(npfn, szc) ^ color) & 372102033aaSdp78419 ceq_mask) == 0) 373102033aaSdp78419 return (npfn); 374102033aaSdp78419 375102033aaSdp78419 /* page color is PA[32:28].PA[19:19] */ 376102033aaSdp78419 pfn_ceq_mask = ((ceq_mask & 1) << 6) | 377102033aaSdp78419 ((ceq_mask >> 1) << 15) | (0xff << 7); 378102033aaSdp78419 pfn_color = ((color & 1) << 6) | ((color >> 1) << 15); 379102033aaSdp78419 npfn = ((pfn >> 20) << 20) | pfn_color; 380102033aaSdp78419 } 381102033aaSdp78419 382102033aaSdp78419 while (npfn <= pfn) { 383102033aaSdp78419 npfn = ADD_MASKED(npfn, pstep, pfn_ceq_mask, mask); 384102033aaSdp78419 } 385102033aaSdp78419 return (npfn); 386102033aaSdp78419 } 387102033aaSdp78419 388102033aaSdp78419 /* 389102033aaSdp78419 * We deal 64K or 8K page of incorrect color. 390102033aaSdp78419 * Try correcting color without changing PA[32:28] 391102033aaSdp78419 */ 392102033aaSdp78419 393102033aaSdp78419 pfn_ceq_mask = ((ceq_mask & 3) << 5) | (ceq_mask >> 2); 394102033aaSdp78419 pfn_color = ((color & 3) << 5) | (color >> 2); 395102033aaSdp78419 npfn = (pfn & ~(pfn_t)0x7f); 396102033aaSdp78419 npfn |= (((pfn >> 15) & 0x1f) ^ pfn_color) & pfn_ceq_mask; 397102033aaSdp78419 npfn = (szc == TTE64K) ? (npfn & ~(pfn_t)0x7) : npfn; 398102033aaSdp78419 399102033aaSdp78419 if (((page_pfn_2_color_cpu(npfn, szc) ^ color) & ceq_mask) == 0) { 400102033aaSdp78419 401102033aaSdp78419 /* the color is fixed - find the next page */ 402102033aaSdp78419 while (npfn <= pfn) { 403102033aaSdp78419 npfn = ADD_MASKED(npfn, pstep, pfn_ceq_mask, mask); 404102033aaSdp78419 } 405102033aaSdp78419 if ((((npfn ^ pfn) >> 15) & 0x1f) == 0) 406102033aaSdp78419 return (npfn); 407102033aaSdp78419 } 408102033aaSdp78419 409102033aaSdp78419 /* to fix the color need to touch PA[32:28] */ 410102033aaSdp78419 npfn = (szc == TTE8K) ? ((pfn >> 15) << 15) : 411102033aaSdp78419 (((pfn >> 18) << 18) | ((color & 0x1c) << 13)); 412102033aaSdp78419 tmpmask = (szc == TTE8K) ? 0 : (ceq_mask & 0x1c) << 13; 413102033aaSdp78419 414102033aaSdp78419 while (npfn <= pfn) { 415102033aaSdp78419 npfn = ADD_MASKED(npfn, (1 << 15), tmpmask, mask); 416102033aaSdp78419 } 417102033aaSdp78419 418102033aaSdp78419 /* set bits PA[19:13] to match the color */ 419102033aaSdp78419 npfn |= (((npfn >> 15) & 0x1f) ^ pfn_color) & pfn_ceq_mask; 420102033aaSdp78419 npfn = (szc == TTE64K) ? (npfn & ~(pfn_t)0x7) : npfn; 421102033aaSdp78419 422102033aaSdp78419 ASSERT(((page_pfn_2_color_cpu(npfn, szc) ^ color) & ceq_mask) == 0); 423102033aaSdp78419 424102033aaSdp78419 return (npfn); 425102033aaSdp78419 } 426102033aaSdp78419 427102033aaSdp78419 /* 428102033aaSdp78419 * init page coloring 429102033aaSdp78419 */ 430102033aaSdp78419 void 431102033aaSdp78419 page_coloring_init_cpu() 432102033aaSdp78419 { 433102033aaSdp78419 int i; 434102033aaSdp78419 uint_t colors; 435102033aaSdp78419 436102033aaSdp78419 hw_page_array[0].hp_colors = 1 << 7; 437102033aaSdp78419 hw_page_array[1].hp_colors = 1 << 7; 438102033aaSdp78419 hw_page_array[2].hp_colors = 1 << 6; 439102033aaSdp78419 440102033aaSdp78419 for (i = 3; i < mmu_page_sizes; i++) { 441102033aaSdp78419 hw_page_array[i].hp_colors = 1 << 5; 442102033aaSdp78419 } 443102033aaSdp78419 444102033aaSdp78419 if (colorequiv > 1) { 445102033aaSdp78419 int a = lowbit(colorequiv) - 1; 446102033aaSdp78419 447102033aaSdp78419 if (a > 15) 448102033aaSdp78419 a = 15; 449102033aaSdp78419 450102033aaSdp78419 for (i = 0; i < mmu_page_sizes; i++) { 451102033aaSdp78419 if ((colors = hw_page_array[i].hp_colors) <= 1) { 452102033aaSdp78419 continue; 453102033aaSdp78419 } 454102033aaSdp78419 while ((colors >> a) == 0) 455102033aaSdp78419 a--; 456102033aaSdp78419 colorequivszc[i] = (a << 4); 457102033aaSdp78419 } 458102033aaSdp78419 } 459102033aaSdp78419 } 460