1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 * 25 * Assembly code support for the Olympus-C module 26 */ 27 28#pragma ident "%Z%%M% %I% %E% SMI" 29 30#if !defined(lint) 31#include "assym.h" 32#endif /* lint */ 33 34#include <sys/asm_linkage.h> 35#include <sys/mmu.h> 36#include <vm/hat_sfmmu.h> 37#include <sys/machparam.h> 38#include <sys/machcpuvar.h> 39#include <sys/machthread.h> 40#include <sys/machtrap.h> 41#include <sys/privregs.h> 42#include <sys/asm_linkage.h> 43#include <sys/trap.h> 44#include <sys/opl_olympus_regs.h> 45#include <sys/opl_module.h> 46#include <sys/xc_impl.h> 47#include <sys/intreg.h> 48#include <sys/async.h> 49#include <sys/clock.h> 50#include <sys/cmpregs.h> 51 52#ifdef TRAPTRACE 53#include <sys/traptrace.h> 54#endif /* TRAPTRACE */ 55 56/* 57 * Macro that flushes the entire Ecache. 58 * 59 * arg1 = ecache size 60 * arg2 = ecache linesize 61 * arg3 = ecache flush address - Not used for olympus-C 62 */ 63#define ECACHE_FLUSHALL(arg1, arg2, arg3, tmp1) \ 64 mov ASI_L2_CTRL_U2_FLUSH, arg1; \ 65 mov ASI_L2_CTRL_RW_ADDR, arg2; \ 66 stxa arg1, [arg2]ASI_L2_CTRL 67 68/* 69 * SPARC64-VI MMU and Cache operations. 70 */ 71 72#if defined(lint) 73 74/* ARGSUSED */ 75void 76vtag_flushpage(caddr_t vaddr, uint64_t sfmmup) 77{} 78 79#else /* lint */ 80 81 ENTRY_NP(vtag_flushpage) 82 /* 83 * flush page from the tlb 84 * 85 * %o0 = vaddr 86 * %o1 = sfmmup 87 */ 88 rdpr %pstate, %o5 89#ifdef DEBUG 90 PANIC_IF_INTR_DISABLED_PSTR(%o5, opl_di_l3, %g1) 91#endif /* DEBUG */ 92 /* 93 * disable ints 94 */ 95 andn %o5, PSTATE_IE, %o4 96 wrpr %o4, 0, %pstate 97 98 /* 99 * Then, blow out the tlb 100 * Interrupts are disabled to prevent the primary ctx register 101 * from changing underneath us. 102 */ 103 sethi %hi(ksfmmup), %o3 104 ldx [%o3 + %lo(ksfmmup)], %o3 105 cmp %o3, %o1 106 bne,pt %xcc, 1f ! if not kernel as, go to 1 107 sethi %hi(FLUSH_ADDR), %o3 108 /* 109 * For Kernel demaps use primary. type = page implicitly 110 */ 111 stxa %g0, [%o0]ASI_DTLB_DEMAP /* dmmu flush for KCONTEXT */ 112 stxa %g0, [%o0]ASI_ITLB_DEMAP /* immu flush for KCONTEXT */ 113 flush %o3 114 retl 115 wrpr %g0, %o5, %pstate /* enable interrupts */ 1161: 117 /* 118 * User demap. We need to set the primary context properly. 119 * Secondary context cannot be used for SPARC64-VI IMMU. 120 * %o0 = vaddr 121 * %o1 = sfmmup 122 * %o3 = FLUSH_ADDR 123 */ 124 SFMMU_CPU_CNUM(%o1, %g1, %g2) ! %g1 = sfmmu cnum on this CPU 125 126 ldub [%o1 + SFMMU_CEXT], %o4 ! %o4 = sfmmup->sfmmu_cext 127 sll %o4, CTXREG_EXT_SHIFT, %o4 128 or %g1, %o4, %g1 ! %g1 = pgsz | cnum 129 130 wrpr %g0, 1, %tl 131 set MMU_PCONTEXT, %o4 132 or DEMAP_PRIMARY | DEMAP_PAGE_TYPE, %o0, %o0 133 ldxa [%o4]ASI_DMMU, %o2 ! %o2 = save old ctxnum 134 stxa %g1, [%o4]ASI_DMMU ! wr new ctxum 135 136 stxa %g0, [%o0]ASI_DTLB_DEMAP 137 stxa %g0, [%o0]ASI_ITLB_DEMAP 138 stxa %o2, [%o4]ASI_DMMU /* restore old ctxnum */ 139 flush %o3 140 wrpr %g0, 0, %tl 141 142 retl 143 wrpr %g0, %o5, %pstate /* enable interrupts */ 144 SET_SIZE(vtag_flushpage) 145 146#endif /* lint */ 147 148 149#if defined(lint) 150 151void 152vtag_flushall(void) 153{} 154 155#else /* lint */ 156 157 ENTRY_NP2(vtag_flushall, demap_all) 158 /* 159 * flush the tlb 160 */ 161 sethi %hi(FLUSH_ADDR), %o3 162 set DEMAP_ALL_TYPE, %g1 163 stxa %g0, [%g1]ASI_DTLB_DEMAP 164 stxa %g0, [%g1]ASI_ITLB_DEMAP 165 flush %o3 166 retl 167 nop 168 SET_SIZE(demap_all) 169 SET_SIZE(vtag_flushall) 170 171#endif /* lint */ 172 173 174#if defined(lint) 175 176/* ARGSUSED */ 177void 178vtag_flushpage_tl1(uint64_t vaddr, uint64_t sfmmup) 179{} 180 181#else /* lint */ 182 183 ENTRY_NP(vtag_flushpage_tl1) 184 /* 185 * x-trap to flush page from tlb and tsb 186 * 187 * %g1 = vaddr, zero-extended on 32-bit kernel 188 * %g2 = sfmmup 189 * 190 * assumes TSBE_TAG = 0 191 */ 192 srln %g1, MMU_PAGESHIFT, %g1 193 194 sethi %hi(ksfmmup), %g3 195 ldx [%g3 + %lo(ksfmmup)], %g3 196 cmp %g3, %g2 197 bne,pt %xcc, 1f ! if not kernel as, go to 1 198 slln %g1, MMU_PAGESHIFT, %g1 /* g1 = vaddr */ 199 200 /* We need to demap in the kernel context */ 201 or DEMAP_NUCLEUS | DEMAP_PAGE_TYPE, %g1, %g1 202 stxa %g0, [%g1]ASI_DTLB_DEMAP 203 stxa %g0, [%g1]ASI_ITLB_DEMAP 204 retry 2051: 206 /* We need to demap in a user context */ 207 or DEMAP_PRIMARY | DEMAP_PAGE_TYPE, %g1, %g1 208 209 SFMMU_CPU_CNUM(%g2, %g6, %g3) ! %g6 = sfmmu cnum on this CPU 210 211 ldub [%g2 + SFMMU_CEXT], %g4 ! %g4 = sfmmup->cext 212 sll %g4, CTXREG_EXT_SHIFT, %g4 213 or %g6, %g4, %g6 ! %g6 = pgsz | cnum 214 215 set MMU_PCONTEXT, %g4 216 ldxa [%g4]ASI_DMMU, %g5 /* rd old ctxnum */ 217 stxa %g6, [%g4]ASI_DMMU /* wr new ctxum */ 218 stxa %g0, [%g1]ASI_DTLB_DEMAP 219 stxa %g0, [%g1]ASI_ITLB_DEMAP 220 stxa %g5, [%g4]ASI_DMMU /* restore old ctxnum */ 221 retry 222 SET_SIZE(vtag_flushpage_tl1) 223 224#endif /* lint */ 225 226 227#if defined(lint) 228 229/* ARGSUSED */ 230void 231vtag_flush_pgcnt_tl1(uint64_t vaddr, uint64_t sfmmup_pgcnt) 232{} 233 234#else /* lint */ 235 236 ENTRY_NP(vtag_flush_pgcnt_tl1) 237 /* 238 * x-trap to flush pgcnt MMU_PAGESIZE pages from tlb 239 * 240 * %g1 = vaddr, zero-extended on 32-bit kernel 241 * %g2 = <sfmmup58|pgcnt6> 242 * 243 * NOTE: this handler relies on the fact that no 244 * interrupts or traps can occur during the loop 245 * issuing the TLB_DEMAP operations. It is assumed 246 * that interrupts are disabled and this code is 247 * fetching from the kernel locked text address. 248 * 249 * assumes TSBE_TAG = 0 250 */ 251 set SFMMU_PGCNT_MASK, %g4 252 and %g4, %g2, %g3 /* g3 = pgcnt - 1 */ 253 add %g3, 1, %g3 /* g3 = pgcnt */ 254 255 andn %g2, SFMMU_PGCNT_MASK, %g2 /* g2 = sfmmup */ 256 srln %g1, MMU_PAGESHIFT, %g1 257 258 sethi %hi(ksfmmup), %g4 259 ldx [%g4 + %lo(ksfmmup)], %g4 260 cmp %g4, %g2 261 bne,pn %xcc, 1f /* if not kernel as, go to 1 */ 262 slln %g1, MMU_PAGESHIFT, %g1 /* g1 = vaddr */ 263 264 /* We need to demap in the kernel context */ 265 or DEMAP_NUCLEUS | DEMAP_PAGE_TYPE, %g1, %g1 266 set MMU_PAGESIZE, %g2 /* g2 = pgsize */ 267 sethi %hi(FLUSH_ADDR), %g5 2684: 269 stxa %g0, [%g1]ASI_DTLB_DEMAP 270 stxa %g0, [%g1]ASI_ITLB_DEMAP 271 flush %g5 ! flush required by immu 272 273 deccc %g3 /* decr pgcnt */ 274 bnz,pt %icc,4b 275 add %g1, %g2, %g1 /* next page */ 276 retry 2771: 278 /* 279 * We need to demap in a user context 280 * 281 * g2 = sfmmup 282 * g3 = pgcnt 283 */ 284 SFMMU_CPU_CNUM(%g2, %g5, %g6) ! %g5 = sfmmu cnum on this CPU 285 286 or DEMAP_PRIMARY | DEMAP_PAGE_TYPE, %g1, %g1 287 288 ldub [%g2 + SFMMU_CEXT], %g4 ! %g4 = sfmmup->cext 289 sll %g4, CTXREG_EXT_SHIFT, %g4 290 or %g5, %g4, %g5 291 292 set MMU_PCONTEXT, %g4 293 ldxa [%g4]ASI_DMMU, %g6 /* rd old ctxnum */ 294 stxa %g5, [%g4]ASI_DMMU /* wr new ctxum */ 295 296 set MMU_PAGESIZE, %g2 /* g2 = pgsize */ 297 sethi %hi(FLUSH_ADDR), %g5 2983: 299 stxa %g0, [%g1]ASI_DTLB_DEMAP 300 stxa %g0, [%g1]ASI_ITLB_DEMAP 301 flush %g5 ! flush required by immu 302 303 deccc %g3 /* decr pgcnt */ 304 bnz,pt %icc,3b 305 add %g1, %g2, %g1 /* next page */ 306 307 stxa %g6, [%g4]ASI_DMMU /* restore old ctxnum */ 308 retry 309 SET_SIZE(vtag_flush_pgcnt_tl1) 310 311#endif /* lint */ 312 313 314#if defined(lint) 315 316/*ARGSUSED*/ 317void 318vtag_flushall_tl1(uint64_t dummy1, uint64_t dummy2) 319{} 320 321#else /* lint */ 322 323 ENTRY_NP(vtag_flushall_tl1) 324 /* 325 * x-trap to flush tlb 326 */ 327 set DEMAP_ALL_TYPE, %g4 328 stxa %g0, [%g4]ASI_DTLB_DEMAP 329 stxa %g0, [%g4]ASI_ITLB_DEMAP 330 retry 331 SET_SIZE(vtag_flushall_tl1) 332 333#endif /* lint */ 334 335 336/* 337 * VAC (virtual address conflict) does not apply to OPL. 338 * VAC resolution is managed by the Olympus processor hardware. 339 * As a result, all OPL VAC flushing routines are no-ops. 340 */ 341 342#if defined(lint) 343 344/* ARGSUSED */ 345void 346vac_flushpage(pfn_t pfnum, int vcolor) 347{} 348 349#else /* lint */ 350 351 ENTRY(vac_flushpage) 352 retl 353 nop 354 SET_SIZE(vac_flushpage) 355 356#endif /* lint */ 357 358#if defined(lint) 359 360/* ARGSUSED */ 361void 362vac_flushpage_tl1(uint64_t pfnum, uint64_t vcolor) 363{} 364 365#else /* lint */ 366 367 ENTRY_NP(vac_flushpage_tl1) 368 retry 369 SET_SIZE(vac_flushpage_tl1) 370 371#endif /* lint */ 372 373 374#if defined(lint) 375 376/* ARGSUSED */ 377void 378vac_flushcolor(int vcolor, pfn_t pfnum) 379{} 380 381#else /* lint */ 382 383 ENTRY(vac_flushcolor) 384 retl 385 nop 386 SET_SIZE(vac_flushcolor) 387 388#endif /* lint */ 389 390 391 392#if defined(lint) 393 394/* ARGSUSED */ 395void 396vac_flushcolor_tl1(uint64_t vcolor, uint64_t pfnum) 397{} 398 399#else /* lint */ 400 401 ENTRY(vac_flushcolor_tl1) 402 retry 403 SET_SIZE(vac_flushcolor_tl1) 404 405#endif /* lint */ 406 407#if defined(lint) 408 409int 410idsr_busy(void) 411{ 412 return (0); 413} 414 415#else /* lint */ 416 417/* 418 * Determine whether or not the IDSR is busy. 419 * Entry: no arguments 420 * Returns: 1 if busy, 0 otherwise 421 */ 422 ENTRY(idsr_busy) 423 ldxa [%g0]ASI_INTR_DISPATCH_STATUS, %g1 424 clr %o0 425 btst IDSR_BUSY, %g1 426 bz,a,pt %xcc, 1f 427 mov 1, %o0 4281: 429 retl 430 nop 431 SET_SIZE(idsr_busy) 432 433#endif /* lint */ 434 435#if defined(lint) 436 437/* ARGSUSED */ 438void 439init_mondo(xcfunc_t *func, uint64_t arg1, uint64_t arg2) 440{} 441 442/* ARGSUSED */ 443void 444init_mondo_nocheck(xcfunc_t *func, uint64_t arg1, uint64_t arg2) 445{} 446 447#else /* lint */ 448 449 .global _dispatch_status_busy 450_dispatch_status_busy: 451 .asciz "ASI_INTR_DISPATCH_STATUS error: busy" 452 .align 4 453 454/* 455 * Setup interrupt dispatch data registers 456 * Entry: 457 * %o0 - function or inumber to call 458 * %o1, %o2 - arguments (2 uint64_t's) 459 */ 460 .seg "text" 461 462 ENTRY(init_mondo) 463#ifdef DEBUG 464 ! 465 ! IDSR should not be busy at the moment 466 ! 467 ldxa [%g0]ASI_INTR_DISPATCH_STATUS, %g1 468 btst IDSR_BUSY, %g1 469 bz,pt %xcc, 1f 470 nop 471 sethi %hi(_dispatch_status_busy), %o0 472 call panic 473 or %o0, %lo(_dispatch_status_busy), %o0 474#endif /* DEBUG */ 475 476 ALTENTRY(init_mondo_nocheck) 477 ! 478 ! interrupt vector dispatch data reg 0 479 ! 4801: 481 mov IDDR_0, %g1 482 mov IDDR_1, %g2 483 mov IDDR_2, %g3 484 stxa %o0, [%g1]ASI_INTR_DISPATCH 485 486 ! 487 ! interrupt vector dispatch data reg 1 488 ! 489 stxa %o1, [%g2]ASI_INTR_DISPATCH 490 491 ! 492 ! interrupt vector dispatch data reg 2 493 ! 494 stxa %o2, [%g3]ASI_INTR_DISPATCH 495 496 membar #Sync 497 retl 498 nop 499 SET_SIZE(init_mondo_nocheck) 500 SET_SIZE(init_mondo) 501 502#endif /* lint */ 503 504 505#if defined(lint) 506 507/* ARGSUSED */ 508void 509shipit(int upaid, int bn) 510{ return; } 511 512#else /* lint */ 513 514/* 515 * Ship mondo to aid using busy/nack pair bn 516 */ 517 ENTRY_NP(shipit) 518 sll %o0, IDCR_PID_SHIFT, %g1 ! IDCR<23:14> = agent id 519 sll %o1, IDCR_BN_SHIFT, %g2 ! IDCR<28:24> = b/n pair 520 or %g1, IDCR_OFFSET, %g1 ! IDCR<13:0> = 0x70 521 or %g1, %g2, %g1 522 stxa %g0, [%g1]ASI_INTR_DISPATCH ! interrupt vector dispatch 523 membar #Sync 524 retl 525 nop 526 SET_SIZE(shipit) 527 528#endif /* lint */ 529 530 531#if defined(lint) 532 533/* ARGSUSED */ 534void 535flush_instr_mem(caddr_t vaddr, size_t len) 536{} 537 538#else /* lint */ 539 540/* 541 * flush_instr_mem: 542 * Flush 1 page of the I-$ starting at vaddr 543 * %o0 vaddr 544 * %o1 bytes to be flushed 545 * 546 * SPARC64-VI maintains consistency of the on-chip Instruction Cache with 547 * the stores from all processors so that a FLUSH instruction is only needed 548 * to ensure pipeline is consistent. This means a single flush is sufficient at 549 * the end of a sequence of stores that updates the instruction stream to 550 * ensure correct operation. 551 */ 552 553 ENTRY(flush_instr_mem) 554 flush %o0 ! address irrelevent 555 retl 556 nop 557 SET_SIZE(flush_instr_mem) 558 559#endif /* lint */ 560 561 562/* 563 * flush_ecache: 564 * %o0 - 64 bit physical address 565 * %o1 - ecache size 566 * %o2 - ecache linesize 567 */ 568#if defined(lint) 569 570/*ARGSUSED*/ 571void 572flush_ecache(uint64_t physaddr, size_t ecache_size, size_t ecache_linesize) 573{} 574 575#else /* !lint */ 576 577 ENTRY(flush_ecache) 578 579 /* 580 * Flush the entire Ecache. 581 */ 582 ECACHE_FLUSHALL(%o1, %o2, %o0, %o4) 583 retl 584 nop 585 SET_SIZE(flush_ecache) 586 587#endif /* lint */ 588 589#if defined(lint) 590 591/*ARGSUSED*/ 592void 593kdi_flush_idcache(int dcache_size, int dcache_lsize, int icache_size, 594 int icache_lsize) 595{ 596} 597 598#else /* lint */ 599 600 /* 601 * I/D cache flushing is not needed for OPL processors 602 */ 603 ENTRY(kdi_flush_idcache) 604 retl 605 nop 606 SET_SIZE(kdi_flush_idcache) 607 608#endif /* lint */ 609 610#ifdef TRAPTRACE 611/* 612 * Simplified trap trace macro for OPL. Adapted from us3. 613 */ 614#define OPL_TRAPTRACE(ptr, scr1, scr2, label) \ 615 CPU_INDEX(scr1, ptr); \ 616 sll scr1, TRAPTR_SIZE_SHIFT, scr1; \ 617 set trap_trace_ctl, ptr; \ 618 add ptr, scr1, scr1; \ 619 ld [scr1 + TRAPTR_LIMIT], ptr; \ 620 tst ptr; \ 621 be,pn %icc, label/**/1; \ 622 ldx [scr1 + TRAPTR_PBASE], ptr; \ 623 ld [scr1 + TRAPTR_OFFSET], scr1; \ 624 add ptr, scr1, ptr; \ 625 rd %asi, scr2; \ 626 wr %g0, TRAPTR_ASI, %asi; \ 627 rd STICK, scr1; \ 628 stxa scr1, [ptr + TRAP_ENT_TICK]%asi; \ 629 rdpr %tl, scr1; \ 630 stha scr1, [ptr + TRAP_ENT_TL]%asi; \ 631 rdpr %tt, scr1; \ 632 stha scr1, [ptr + TRAP_ENT_TT]%asi; \ 633 rdpr %tpc, scr1; \ 634 stna scr1, [ptr + TRAP_ENT_TPC]%asi; \ 635 rdpr %tstate, scr1; \ 636 stxa scr1, [ptr + TRAP_ENT_TSTATE]%asi; \ 637 stna %sp, [ptr + TRAP_ENT_SP]%asi; \ 638 stna %g0, [ptr + TRAP_ENT_TR]%asi; \ 639 stna %g0, [ptr + TRAP_ENT_F1]%asi; \ 640 stna %g0, [ptr + TRAP_ENT_F2]%asi; \ 641 stna %g0, [ptr + TRAP_ENT_F3]%asi; \ 642 stna %g0, [ptr + TRAP_ENT_F4]%asi; \ 643 wr %g0, scr2, %asi; \ 644 CPU_INDEX(ptr, scr1); \ 645 sll ptr, TRAPTR_SIZE_SHIFT, ptr; \ 646 set trap_trace_ctl, scr1; \ 647 add scr1, ptr, ptr; \ 648 ld [ptr + TRAPTR_OFFSET], scr1; \ 649 ld [ptr + TRAPTR_LIMIT], scr2; \ 650 st scr1, [ptr + TRAPTR_LAST_OFFSET]; \ 651 add scr1, TRAP_ENT_SIZE, scr1; \ 652 sub scr2, TRAP_ENT_SIZE, scr2; \ 653 cmp scr1, scr2; \ 654 movge %icc, 0, scr1; \ 655 st scr1, [ptr + TRAPTR_OFFSET]; \ 656label/**/1: 657#endif /* TRAPTRACE */ 658 659 660 661/* 662 * Macros facilitating error handling. 663 */ 664 665/* 666 * Save alternative global registers reg1, reg2, reg3 667 * to scratchpad registers 1, 2, 3 respectively. 668 */ 669#define OPL_SAVE_GLOBAL(reg1, reg2, reg3) \ 670 stxa reg1, [%g0]ASI_SCRATCHPAD ;\ 671 mov OPL_SCRATCHPAD_SAVE_AG2, reg1 ;\ 672 stxa reg2, [reg1]ASI_SCRATCHPAD ;\ 673 mov OPL_SCRATCHPAD_SAVE_AG3, reg1 ;\ 674 stxa reg3, [reg1]ASI_SCRATCHPAD 675 676/* 677 * Restore alternative global registers reg1, reg2, reg3 678 * from scratchpad registers 1, 2, 3 respectively. 679 */ 680#define OPL_RESTORE_GLOBAL(reg1, reg2, reg3) \ 681 mov OPL_SCRATCHPAD_SAVE_AG3, reg1 ;\ 682 ldxa [reg1]ASI_SCRATCHPAD, reg3 ;\ 683 mov OPL_SCRATCHPAD_SAVE_AG2, reg1 ;\ 684 ldxa [reg1]ASI_SCRATCHPAD, reg2 ;\ 685 ldxa [%g0]ASI_SCRATCHPAD, reg1 686 687/* 688 * Logs value `val' into the member `offset' of a structure 689 * at physical address `pa' 690 */ 691#define LOG_REG(pa, offset, val) \ 692 add pa, offset, pa ;\ 693 stxa val, [pa]ASI_MEM 694 695#define FLUSH_ALL_TLB(tmp1) \ 696 set DEMAP_ALL_TYPE, tmp1 ;\ 697 stxa %g0, [tmp1]ASI_ITLB_DEMAP ;\ 698 stxa %g0, [tmp1]ASI_DTLB_DEMAP ;\ 699 sethi %hi(FLUSH_ADDR), tmp1 ;\ 700 flush tmp1 701 702/* 703 * Extracts the Physaddr to Logging Buffer field of the OPL_SCRATCHPAD_ERRLOG 704 * scratch register by zeroing all other fields. Result is in pa. 705 */ 706#define LOG_ADDR(pa) \ 707 mov OPL_SCRATCHPAD_ERRLOG, pa ;\ 708 ldxa [pa]ASI_SCRATCHPAD, pa ;\ 709 sllx pa, 64-ERRLOG_REG_EIDR_SHIFT, pa ;\ 710 srlx pa, 64-ERRLOG_REG_EIDR_SHIFT+ERRLOG_REG_ERR_SHIFT, pa ;\ 711 sllx pa, ERRLOG_REG_ERR_SHIFT, pa 712 713/* 714 * Advance the per-cpu error log buffer pointer to the next 715 * ERRLOG_SZ entry, making sure that it will modulo (wraparound) 716 * ERRLOG_BUFSIZ boundary. The args logpa, bufmask, tmp are 717 * unused input registers for this macro. 718 * 719 * Algorithm: 720 * 1. logpa = contents of errorlog scratchpad register 721 * 2. bufmask = ERRLOG_BUFSIZ - 1 722 * 3. tmp = logpa & ~(bufmask) (tmp is now logbase) 723 * 4. logpa += ERRLOG_SZ 724 * 5. logpa = logpa & bufmask (get new offset to logbase) 725 * 4. logpa = tmp | logpa 726 * 7. write logpa back into errorlog scratchpad register 727 * 728 * new logpa = (logpa & ~bufmask) | ((logpa + ERRLOG_SZ) & bufmask) 729 * 730 */ 731#define UPDATE_LOGADD(logpa, bufmask, tmp) \ 732 set OPL_SCRATCHPAD_ERRLOG, tmp ;\ 733 ldxa [tmp]ASI_SCRATCHPAD, logpa ;\ 734 set (ERRLOG_BUFSZ-1), bufmask ;\ 735 andn logpa, bufmask, tmp ;\ 736 add logpa, ERRLOG_SZ, logpa ;\ 737 and logpa, bufmask, logpa ;\ 738 or tmp, logpa, logpa ;\ 739 set OPL_SCRATCHPAD_ERRLOG, tmp ;\ 740 stxa logpa, [tmp]ASI_SCRATCHPAD 741 742/* Log error status registers into the log buffer */ 743#define LOG_SYNC_REG(sfsr, sfar, tmp) \ 744 LOG_ADDR(tmp) ;\ 745 LOG_REG(tmp, LOG_SFSR_OFF, sfsr) ;\ 746 LOG_ADDR(tmp) ;\ 747 mov tmp, sfsr ;\ 748 LOG_REG(tmp, LOG_SFAR_OFF, sfar) ;\ 749 rd STICK, sfar ;\ 750 mov sfsr, tmp ;\ 751 LOG_REG(tmp, LOG_STICK_OFF, sfar) ;\ 752 rdpr %tl, tmp ;\ 753 sllx tmp, 32, sfar ;\ 754 rdpr %tt, tmp ;\ 755 or sfar, tmp, sfar ;\ 756 mov sfsr, tmp ;\ 757 LOG_REG(tmp, LOG_TL_OFF, sfar) ;\ 758 set OPL_SCRATCHPAD_ERRLOG, tmp ;\ 759 ldxa [tmp]ASI_SCRATCHPAD, sfar ;\ 760 mov sfsr, tmp ;\ 761 LOG_REG(tmp, LOG_ASI3_OFF, sfar) ;\ 762 rdpr %tpc, sfar ;\ 763 mov sfsr, tmp ;\ 764 LOG_REG(tmp, LOG_TPC_OFF, sfar) ;\ 765 UPDATE_LOGADD(sfsr, sfar, tmp) 766 767#define LOG_UGER_REG(uger, tmp, tmp2) \ 768 LOG_ADDR(tmp) ;\ 769 mov tmp, tmp2 ;\ 770 LOG_REG(tmp2, LOG_UGER_OFF, uger) ;\ 771 mov tmp, uger ;\ 772 rd STICK, tmp2 ;\ 773 LOG_REG(tmp, LOG_STICK_OFF, tmp2) ;\ 774 rdpr %tl, tmp ;\ 775 sllx tmp, 32, tmp2 ;\ 776 rdpr %tt, tmp ;\ 777 or tmp2, tmp, tmp2 ;\ 778 mov uger, tmp ;\ 779 LOG_REG(tmp, LOG_TL_OFF, tmp2) ;\ 780 set OPL_SCRATCHPAD_ERRLOG, tmp2 ;\ 781 ldxa [tmp2]ASI_SCRATCHPAD, tmp2 ;\ 782 mov uger, tmp ;\ 783 LOG_REG(tmp, LOG_ASI3_OFF, tmp2) ;\ 784 rdpr %tstate, tmp2 ;\ 785 mov uger, tmp ;\ 786 LOG_REG(tmp, LOG_TSTATE_OFF, tmp2) ;\ 787 rdpr %tpc, tmp2 ;\ 788 mov uger, tmp ;\ 789 LOG_REG(tmp, LOG_TPC_OFF, tmp2) ;\ 790 UPDATE_LOGADD(uger, tmp, tmp2) 791 792/* 793 * Scrub the STICK_COMPARE register to clear error by updating 794 * it to a reasonable value for interrupt generation. 795 * Ensure that we observe the CPU_ENABLE flag so that we 796 * don't accidentally enable TICK interrupt in STICK_COMPARE 797 * i.e. no clock interrupt will be generated if CPU_ENABLE flag 798 * is off. 799 */ 800#define UPDATE_STICK_COMPARE(tmp1, tmp2) \ 801 CPU_ADDR(tmp1, tmp2) ;\ 802 lduh [tmp1 + CPU_FLAGS], tmp2 ;\ 803 andcc tmp2, CPU_ENABLE, %g0 ;\ 804 set OPL_UGER_STICK_DIFF, tmp2 ;\ 805 rd STICK, tmp1 ;\ 806 add tmp1, tmp2, tmp1 ;\ 807 mov 1, tmp2 ;\ 808 sllx tmp2, TICKINT_DIS_SHFT, tmp2 ;\ 809 or tmp1, tmp2, tmp2 ;\ 810 movnz %xcc, tmp1, tmp2 ;\ 811 wr tmp2, %g0, STICK_COMPARE 812 813/* 814 * Reset registers that may be corrupted by IAUG_CRE error. 815 * To update interrupt handling related registers force the 816 * clock interrupt. 817 */ 818#define IAG_CRE(tmp1, tmp2) \ 819 set OPL_SCRATCHPAD_ERRLOG, tmp1 ;\ 820 ldxa [tmp1]ASI_SCRATCHPAD, tmp1 ;\ 821 srlx tmp1, ERRLOG_REG_EIDR_SHIFT, tmp1 ;\ 822 set ERRLOG_REG_EIDR_MASK, tmp2 ;\ 823 and tmp1, tmp2, tmp1 ;\ 824 stxa tmp1, [%g0]ASI_EIDR ;\ 825 wr %g0, 0, SOFTINT ;\ 826 sethi %hi(hres_last_tick), tmp1 ;\ 827 ldx [tmp1 + %lo(hres_last_tick)], tmp1 ;\ 828 set OPL_UGER_STICK_DIFF, tmp2 ;\ 829 add tmp1, tmp2, tmp1 ;\ 830 wr tmp1, %g0, STICK ;\ 831 UPDATE_STICK_COMPARE(tmp1, tmp2) 832 833 834#define CLEAR_FPREGS(tmp) \ 835 wr %g0, FPRS_FEF, %fprs ;\ 836 wr %g0, %g0, %gsr ;\ 837 sethi %hi(opl_clr_freg), tmp ;\ 838 or tmp, %lo(opl_clr_freg), tmp ;\ 839 ldx [tmp], %fsr ;\ 840 fzero %d0 ;\ 841 fzero %d2 ;\ 842 fzero %d4 ;\ 843 fzero %d6 ;\ 844 fzero %d8 ;\ 845 fzero %d10 ;\ 846 fzero %d12 ;\ 847 fzero %d14 ;\ 848 fzero %d16 ;\ 849 fzero %d18 ;\ 850 fzero %d20 ;\ 851 fzero %d22 ;\ 852 fzero %d24 ;\ 853 fzero %d26 ;\ 854 fzero %d28 ;\ 855 fzero %d30 ;\ 856 fzero %d32 ;\ 857 fzero %d34 ;\ 858 fzero %d36 ;\ 859 fzero %d38 ;\ 860 fzero %d40 ;\ 861 fzero %d42 ;\ 862 fzero %d44 ;\ 863 fzero %d46 ;\ 864 fzero %d48 ;\ 865 fzero %d50 ;\ 866 fzero %d52 ;\ 867 fzero %d54 ;\ 868 fzero %d56 ;\ 869 fzero %d58 ;\ 870 fzero %d60 ;\ 871 fzero %d62 ;\ 872 wr %g0, %g0, %fprs 873 874#define CLEAR_GLOBALS() \ 875 mov %g0, %g1 ;\ 876 mov %g0, %g2 ;\ 877 mov %g0, %g3 ;\ 878 mov %g0, %g4 ;\ 879 mov %g0, %g5 ;\ 880 mov %g0, %g6 ;\ 881 mov %g0, %g7 882 883/* 884 * We do not clear the alternative globals here because they 885 * are scratch registers, i.e. there is no code that reads from 886 * them without write to them firstly. In other words every 887 * read always follows write that makes extra write to the 888 * alternative globals unnecessary. 889 */ 890#define CLEAR_GEN_REGS(tmp1, label) \ 891 set TSTATE_KERN, tmp1 ;\ 892 wrpr %g0, tmp1, %tstate ;\ 893 mov %g0, %y ;\ 894 mov %g0, %asi ;\ 895 mov %g0, %ccr ;\ 896 mov %g0, %l0 ;\ 897 mov %g0, %l1 ;\ 898 mov %g0, %l2 ;\ 899 mov %g0, %l3 ;\ 900 mov %g0, %l4 ;\ 901 mov %g0, %l5 ;\ 902 mov %g0, %l6 ;\ 903 mov %g0, %l7 ;\ 904 mov %g0, %i0 ;\ 905 mov %g0, %i1 ;\ 906 mov %g0, %i2 ;\ 907 mov %g0, %i3 ;\ 908 mov %g0, %i4 ;\ 909 mov %g0, %i5 ;\ 910 mov %g0, %i6 ;\ 911 mov %g0, %i7 ;\ 912 mov %g0, %o1 ;\ 913 mov %g0, %o2 ;\ 914 mov %g0, %o3 ;\ 915 mov %g0, %o4 ;\ 916 mov %g0, %o5 ;\ 917 mov %g0, %o6 ;\ 918 mov %g0, %o7 ;\ 919 mov %g0, %o0 ;\ 920 mov %g0, %g4 ;\ 921 mov %g0, %g5 ;\ 922 mov %g0, %g6 ;\ 923 mov %g0, %g7 ;\ 924 rdpr %tl, tmp1 ;\ 925 cmp tmp1, 1 ;\ 926 be,pt %xcc, label/**/1 ;\ 927 rdpr %pstate, tmp1 ;\ 928 wrpr tmp1, PSTATE_AG|PSTATE_IG, %pstate ;\ 929 CLEAR_GLOBALS() ;\ 930 rdpr %pstate, tmp1 ;\ 931 wrpr tmp1, PSTATE_IG|PSTATE_MG, %pstate ;\ 932 CLEAR_GLOBALS() ;\ 933 rdpr %pstate, tmp1 ;\ 934 wrpr tmp1, PSTATE_MG|PSTATE_AG, %pstate ;\ 935 ba,pt %xcc, label/**/2 ;\ 936 nop ;\ 937label/**/1: ;\ 938 wrpr tmp1, PSTATE_AG, %pstate ;\ 939 CLEAR_GLOBALS() ;\ 940 rdpr %pstate, tmp1 ;\ 941 wrpr tmp1, PSTATE_AG, %pstate ;\ 942label/**/2: 943 944 945/* 946 * Reset all window related registers 947 */ 948#define RESET_WINREG(tmp) \ 949 sethi %hi(nwin_minus_one), tmp ;\ 950 ld [tmp + %lo(nwin_minus_one)], tmp ;\ 951 wrpr %g0, tmp, %cwp ;\ 952 wrpr %g0, tmp, %cleanwin ;\ 953 sub tmp, 1, tmp ;\ 954 wrpr %g0, tmp, %cansave ;\ 955 wrpr %g0, %g0, %canrestore ;\ 956 wrpr %g0, %g0, %otherwin ;\ 957 wrpr %g0, PIL_MAX, %pil ;\ 958 wrpr %g0, WSTATE_KERN, %wstate 959 960 961#define RESET_PREV_TSTATE(tmp1, tmp2, label) \ 962 rdpr %tl, tmp1 ;\ 963 subcc tmp1, 1, tmp1 ;\ 964 bz,pt %xcc, label/**/1 ;\ 965 nop ;\ 966 wrpr tmp1, %g0, %tl ;\ 967 set TSTATE_KERN, tmp2 ;\ 968 wrpr tmp2, %g0, %tstate ;\ 969 wrpr %g0, %g0, %tpc ;\ 970 wrpr %g0, %g0, %tnpc ;\ 971 add tmp1, 1, tmp1 ;\ 972 wrpr tmp1, %g0, %tl ;\ 973label/**/1: 974 975 976/* 977 * %pstate, %pc, %npc are propagated to %tstate, %tpc, %tnpc, 978 * and we reset these regiseter here. 979 */ 980#define RESET_CUR_TSTATE(tmp) \ 981 set TSTATE_KERN, tmp ;\ 982 wrpr %g0, tmp, %tstate ;\ 983 wrpr %g0, 0, %tpc ;\ 984 wrpr %g0, 0, %tnpc ;\ 985 RESET_WINREG(tmp) 986 987/* 988 * In case of urgent errors some MMU registers may be 989 * corrupted, so we set here some reasonable values for 990 * them. Note that resetting MMU registers also reset the context 991 * info, we will need to reset the window registers to prevent 992 * spill/fill that depends on context info for correct behaviour 993 */ 994 995#if !defined(lint) 996#define RESET_MMU_REGS(tmp1, tmp2, tmp3) \ 997 set MMU_PCONTEXT, tmp1 ;\ 998 stxa %g0, [tmp1]ASI_DMMU ;\ 999 set MMU_SCONTEXT, tmp1 ;\ 1000 stxa %g0, [tmp1]ASI_DMMU ;\ 1001 sethi %hi(ktsb_base), tmp1 ;\ 1002 ldx [tmp1 + %lo(ktsb_base)], tmp2 ;\ 1003 mov MMU_TSB, tmp3 ;\ 1004 stxa tmp2, [tmp3]ASI_IMMU ;\ 1005 stxa tmp2, [tmp3]ASI_DMMU ;\ 1006 membar #Sync ;\ 1007 RESET_WINREG(tmp1) 1008 1009#define RESET_TSB_TAGPTR(tmp) \ 1010 set MMU_TAG_ACCESS, tmp ;\ 1011 stxa %g0, [tmp]ASI_IMMU ;\ 1012 stxa %g0, [tmp]ASI_DMMU ;\ 1013 membar #Sync 1014#endif /* lint */ 1015 1016/* 1017 * RESET_TO_PRIV() 1018 * 1019 * In many cases, we need to force the thread into privilege mode because 1020 * privilege mode is only thing in which the system continue to work 1021 * due to undeterminable user mode information that come from register 1022 * corruption. 1023 * 1024 * - opl_uger_ctxt 1025 * If the error is secondary TSB related register parity, we have no idea 1026 * what value is supposed to be for it. 1027 * 1028 * The below three cases %tstate is not accessible until it is overwritten 1029 * with some value, so we have no clue if the thread was running on user mode 1030 * or not 1031 * - opl_uger_pstate 1032 * If the error is %pstate parity, it propagates to %tstate. 1033 * - opl_uger_tstate 1034 * No need to say the reason 1035 * - opl_uger_r 1036 * If the error is %ccr or %asi parity, it propagates to %tstate 1037 * 1038 * For the above four cases, user mode info may not be available for 1039 * sys_trap() and user_trap() to work consistently. So we have to force 1040 * the thread into privilege mode. 1041 * 1042 * Forcing the thread to privilege mode requires forcing 1043 * regular %g7 to be CPU_THREAD. Because if it was running on user mode, 1044 * %g7 will be set in user_trap(). Also since the %sp may be in 1045 * an inconsistent state, we need to do a stack reset and switch to 1046 * something we know i.e. current thread's kernel stack. 1047 * We also reset the window registers and MMU registers just to 1048 * make sure. 1049 * 1050 * To set regular %g7, we need to clear PSTATE_AG bit and need to 1051 * use one local register. Note that we are panicking and will never 1052 * unwind back so it is ok to clobber a local. 1053 * 1054 * If the thread was running in user mode, the %tpc value itself might be 1055 * within the range of OBP addresses. %tpc must be forced to be zero to prevent 1056 * sys_trap() from going to prom_trap() 1057 * 1058 */ 1059#define RESET_TO_PRIV(tmp, tmp1, tmp2, local) \ 1060 RESET_MMU_REGS(tmp, tmp1, tmp2) ;\ 1061 CPU_ADDR(tmp, tmp1) ;\ 1062 ldx [tmp + CPU_THREAD], local ;\ 1063 ldx [local + T_STACK], tmp ;\ 1064 sub tmp, STACK_BIAS, %sp ;\ 1065 rdpr %pstate, tmp ;\ 1066 wrpr tmp, PSTATE_AG, %pstate ;\ 1067 mov local, %g7 ;\ 1068 rdpr %pstate, local ;\ 1069 wrpr local, PSTATE_AG, %pstate ;\ 1070 wrpr %g0, 1, %tl ;\ 1071 set TSTATE_KERN, tmp ;\ 1072 rdpr %cwp, tmp1 ;\ 1073 or tmp, tmp1, tmp ;\ 1074 wrpr tmp, %g0, %tstate ;\ 1075 wrpr %g0, %tpc 1076 1077 1078#if defined(lint) 1079 1080void 1081ce_err(void) 1082{} 1083 1084#else /* lint */ 1085 1086/* 1087 * We normally don't expect CE traps since we disable the 1088 * 0x63 trap reporting at the start of day. There is a 1089 * small window before we disable them, so let check for 1090 * it. Otherwise, panic. 1091 */ 1092 1093 .align 128 1094 ENTRY_NP(ce_err) 1095 mov AFSR_ECR, %g1 1096 ldxa [%g1]ASI_ECR, %g1 1097 andcc %g1, ASI_ECR_RTE_UE | ASI_ECR_RTE_CEDG, %g0 1098 bz,pn %xcc, 1f 1099 nop 1100 retry 11011: 1102 /* 1103 * We did disabled the 0x63 trap reporting. 1104 * This shouldn't happen - panic. 1105 */ 1106 set trap, %g1 1107 rdpr %tt, %g3 1108 sethi %hi(sys_trap), %g5 1109 jmp %g5 + %lo(sys_trap) 1110 sub %g0, 1, %g4 1111 SET_SIZE(ce_err) 1112 1113#endif /* lint */ 1114 1115 1116#if defined(lint) 1117 1118void 1119ce_err_tl1(void) 1120{} 1121 1122#else /* lint */ 1123 1124/* 1125 * We don't use trap for CE detection. 1126 */ 1127 ENTRY_NP(ce_err_tl1) 1128 set trap, %g1 1129 rdpr %tt, %g3 1130 sethi %hi(sys_trap), %g5 1131 jmp %g5 + %lo(sys_trap) 1132 sub %g0, 1, %g4 1133 SET_SIZE(ce_err_tl1) 1134 1135#endif /* lint */ 1136 1137 1138#if defined(lint) 1139 1140void 1141async_err(void) 1142{} 1143 1144#else /* lint */ 1145 1146/* 1147 * async_err is the default handler for IAE/DAE traps. 1148 * For OPL, we patch in the right handler at start of day. 1149 * But if a IAE/DAE trap get generated before the handler 1150 * is patched, panic. 1151 */ 1152 ENTRY_NP(async_err) 1153 set trap, %g1 1154 rdpr %tt, %g3 1155 sethi %hi(sys_trap), %g5 1156 jmp %g5 + %lo(sys_trap) 1157 sub %g0, 1, %g4 1158 SET_SIZE(async_err) 1159 1160#endif /* lint */ 1161 1162#if defined(lint) 1163void 1164opl_sync_trap(void) 1165{} 1166#else /* lint */ 1167 1168 .seg ".data" 1169 .global opl_clr_freg 1170 .global opl_cpu0_err_log 1171 1172 .align 16 1173opl_clr_freg: 1174 .word 0 1175 .align 16 1176 1177 .align MMU_PAGESIZE 1178opl_cpu0_err_log: 1179 .skip MMU_PAGESIZE 1180 1181/* 1182 * Common synchronous error trap handler (tt=0xA, 0x32) 1183 * All TL=0 and TL>0 0xA and 0x32 traps vector to this handler. 1184 * The error handling can be best summarized as follows: 1185 * 0. Do TRAPTRACE if enabled. 1186 * 1. Save globals %g1, %g2 & %g3 onto the scratchpad regs. 1187 * 2. The SFSR register is read and verified as valid by checking 1188 * SFSR.FV bit being set. If the SFSR.FV is not set, the 1189 * error cases cannot be decoded/determined and the SFPAR 1190 * register that contain the physical faultaddr is also 1191 * not valid. Also the SPFAR is only valid for UE/TO/BERR error 1192 * cases. Assuming the SFSR.FV is valid: 1193 * - BERR(bus error)/TO(timeout)/UE case 1194 * If any of these error cases are detected, read the SFPAR 1195 * to get the faultaddress. Generate ereport. 1196 * - TLB Parity case (only recoverable case) 1197 * For DAE, read SFAR for the faultaddress. For IAE, 1198 * use %tpc for faultaddress (SFAR is not valid in IAE) 1199 * Flush all the tlbs. 1200 * Subtract one from the recoverable error count stored in 1201 * the error log scratch register. If the threshold limit 1202 * is reached (zero) - generate ereport. Else 1203 * restore globals and retry (no ereport is generated). 1204 * - TLB Multiple hits 1205 * For DAE, read SFAR for the faultaddress. For IAE, 1206 * use %tpc for faultaddress (SFAR is not valid in IAE). 1207 * Flush all tlbs and generate ereport. 1208 * 3. TL=0 and TL>0 considerations 1209 * - Since both TL=0 & TL>1 traps are made to vector into 1210 * the same handler, the underlying assumption/design here is 1211 * that any nested error condition (if happens) occurs only 1212 * in the handler and the system is assumed to eventually 1213 * Red-mode. With this philosophy in mind, the recoverable 1214 * TLB Parity error case never check the TL level before it 1215 * retry. Note that this is ok for the TL>1 case (assuming we 1216 * don't have a nested error) since we always save the globals 1217 * %g1, %g2 & %g3 whenever we enter this trap handler. 1218 * - Additional TL=0 vs TL>1 handling includes: 1219 * - For UE error occuring under TL>1, special handling 1220 * is added to prevent the unlikely chance of a cpu-lockup 1221 * when a UE was originally detected in user stack and 1222 * the spill trap handler taken from sys_trap() so happened 1223 * to reference the same UE location. Under the above 1224 * condition (TL>1 and UE error), paranoid code is added 1225 * to reset window regs so that spill traps can't happen 1226 * during the unwind back to TL=0 handling. 1227 * Note that we can do that because we are not returning 1228 * back. 1229 * 4. Ereport generation. 1230 * - Ereport generation is performed when we unwind to the TL=0 1231 * handling code via sys_trap(). on_trap()/lofault protection 1232 * will apply there. 1233 * 1234 */ 1235 ENTRY_NP(opl_sync_trap) 1236#ifdef TRAPTRACE 1237 OPL_TRAPTRACE(%g1, %g2, %g3, opl_sync_trap_lb) 1238 rdpr %tt, %g1 1239#endif /* TRAPTRACE */ 1240 cmp %g1, T_INSTR_ERROR 1241 bne,pt %xcc, 0f 1242 mov MMU_SFSR, %g3 1243 ldxa [%g3]ASI_IMMU, %g1 ! IAE trap case tt = 0xa 1244 andcc %g1, SFSR_FV, %g0 1245 bz,a,pn %xcc, 2f ! Branch if SFSR is invalid and 1246 rdpr %tpc, %g2 ! use %tpc for faultaddr instead 1247 1248 sethi %hi(SFSR_UE|SFSR_BERR|SFSR_TO), %g3 1249 andcc %g1, %g3, %g0 ! Check for UE/BERR/TO errors 1250 bz,a,pt %xcc, 1f ! Branch if not UE/BERR/TO and 1251 rdpr %tpc, %g2 ! use %tpc as faultaddr 1252 set OPL_MMU_SFPAR, %g3 ! In the UE/BERR/TO cases, use 1253 ba,pt %xcc, 2f ! SFPAR as faultaddr 1254 ldxa [%g3]ASI_IMMU, %g2 12550: 1256 ldxa [%g3]ASI_DMMU, %g1 ! DAE trap case tt = 0x32 1257 andcc %g1, SFSR_FV, %g0 1258 bnz,pt %xcc, 7f ! branch if SFSR.FV is valid 1259 mov MMU_SFAR, %g2 ! set %g2 to use SFAR 1260 ba,pt %xcc, 2f ! SFSR.FV is not valid, read SFAR 1261 ldxa [%g2]ASI_DMMU, %g2 ! for faultaddr 12627: 1263 sethi %hi(SFSR_UE|SFSR_BERR|SFSR_TO), %g3 1264 andcc %g1, %g3, %g0 ! Check UE/BERR/TO for valid SFPAR 1265 movnz %xcc, OPL_MMU_SFPAR, %g2 ! Use SFPAR instead of SFAR for 1266 ldxa [%g2]ASI_DMMU, %g2 ! faultaddr 12671: 1268 sethi %hi(SFSR_TLB_PRT), %g3 1269 andcc %g1, %g3, %g0 1270 bz,pt %xcc, 8f ! branch for TLB multi-hit check 1271 nop 1272 /* 1273 * This is the TLB parity error case and it is the 1274 * only retryable error case. 1275 * Only %g1, %g2 and %g3 are allowed 1276 */ 1277 FLUSH_ALL_TLB(%g3) 1278 set OPL_SCRATCHPAD_ERRLOG, %g3 1279 ldxa [%g3]ASI_SCRATCHPAD, %g3 ! Read errlog scratchreg 1280 and %g3, ERRLOG_REG_NUMERR_MASK, %g3! Extract the error count 1281 subcc %g3, 1, %g0 ! Subtract one from the count 1282 bz,pn %xcc, 2f ! too many TLB parity errs in a certain 1283 nop ! period, branch to generate ereport 1284 LOG_SYNC_REG(%g1, %g2, %g3) ! Record into the error log 1285 set OPL_SCRATCHPAD_ERRLOG, %g3 1286 ldxa [%g3]ASI_SCRATCHPAD, %g2 1287 sub %g2, 1, %g2 ! decrement error counter by 1 1288 stxa %g2, [%g3]ASI_SCRATCHPAD ! update the errlog scratchreg 1289 OPL_RESTORE_GLOBAL(%g1, %g2, %g3) 1290 retry 12918: 1292 sethi %hi(SFSR_TLB_MUL), %g3 1293 andcc %g1, %g3, %g0 1294 bz,pt %xcc, 2f ! check for the TLB multi-hit errors 1295 nop 1296 FLUSH_ALL_TLB(%g3) 12972: 1298 /* 1299 * non-retryable error handling 1300 * now we can use other registers since 1301 * we will not be returning back 1302 */ 1303 mov %g1, %g5 ! %g5 = SFSR 1304 mov %g2, %g6 ! %g6 = SFPAR or SFAR/tpc 1305 LOG_SYNC_REG(%g1, %g2, %g3) ! Record into the error log 1306 1307 /* 1308 * Special case for UE on user stack. 1309 * There is a possibility that the same error may come back here 1310 * by touching the same UE in spill trap handler taken from 1311 * sys_trap(). It ends up with an infinite loop causing a cpu lockup. 1312 * Conditions for this handling this case are: 1313 * - SFSR_FV is valid and SFSR_UE is set 1314 * - we are at TL > 1 1315 * If the above conditions are true, we force %cansave to be a 1316 * big number to prevent spill trap in sys_trap(). Note that 1317 * we will not be returning back. 1318 */ 1319 rdpr %tt, %g4 ! %g4 == ttype 1320 rdpr %tl, %g1 ! %g1 == tl 1321 cmp %g1, 1 ! Check if TL == 1 1322 be,pt %xcc, 3f ! branch if we came from TL=0 1323 nop 1324 andcc %g5, SFSR_FV, %g0 ! see if SFSR.FV is valid 1325 bz,pn %xcc, 4f ! branch, checking UE is meaningless 1326 sethi %hi(SFSR_UE), %g2 1327 andcc %g5, %g2, %g0 ! check for UE 1328 bz,pt %xcc, 4f ! branch if not UE 1329 nop 1330 RESET_WINREG(%g1) ! reset windows to prevent spills 13314: 1332 RESET_USER_RTT_REGS(%g2, %g3, 5f) 13335: 1334 mov %g5, %g3 ! pass SFSR to the 3rd arg 1335 mov %g6, %g2 ! pass SFAR to the 2nd arg 1336 set opl_cpu_isync_tl1_error, %g1 1337 set opl_cpu_dsync_tl1_error, %g6 1338 cmp %g4, T_INSTR_ERROR 1339 movne %icc, %g6, %g1 1340 ba,pt %icc, 6f 1341 nop 13423: 1343 mov %g5, %g3 ! pass SFSR to the 3rd arg 1344 mov %g6, %g2 ! pass SFAR to the 2nd arg 1345 set opl_cpu_isync_tl0_error, %g1 1346 set opl_cpu_dsync_tl0_error, %g6 1347 cmp %g4, T_INSTR_ERROR 1348 movne %icc, %g6, %g1 13496: 1350 sethi %hi(sys_trap), %g5 1351 jmp %g5 + %lo(sys_trap) 1352 mov PIL_15, %g4 1353 SET_SIZE(opl_sync_trap) 1354#endif /* lint */ 1355 1356#if defined(lint) 1357void 1358opl_uger_trap(void) 1359{} 1360#else /* lint */ 1361/* 1362 * Common Urgent error trap handler (tt=0x40) 1363 * All TL=0 and TL>0 0x40 traps vector to this handler. 1364 * The error handling can be best summarized as follows: 1365 * 1. Read the Urgent error status register (UGERSR) 1366 * Faultaddress is N/A here and it is not collected. 1367 * 2. Check to see if we have a multiple errors case 1368 * If so, we enable WEAK_ED (weak error detection) bit 1369 * to prevent any potential error storms and branch directly 1370 * to generate ereport. (we don't decode/handle individual 1371 * error cases when we get a multiple error situation) 1372 * 3. Now look for the recoverable error cases which include 1373 * IUG_DTLB, IUG_ITLB or COREERR errors. If any of the 1374 * recoverable errors are detected, do the following: 1375 * - Flush all tlbs. 1376 * - Verify that we came from TL=0, if not, generate 1377 * ereport. Note that the reason we don't recover 1378 * at TL>0 is because the AGs might be corrupted or 1379 * inconsistent. We can't save/restore them into 1380 * the scratchpad regs like we did for opl_sync_trap(). 1381 * - Check the INSTEND[5:4] bits in the UGERSR. If the 1382 * value is 0x3 (11b), this error is not recoverable. 1383 * Generate ereport. 1384 * - Subtract one from the recoverable error count stored in 1385 * the error log scratch register. If the threshold limit 1386 * is reached (zero) - generate ereport. 1387 * - If the count is within the limit, update the count 1388 * in the error log register (subtract one). Log the error 1389 * info in the log buffer. Capture traptrace if enabled. 1390 * Retry (no ereport generated) 1391 * 4. The rest of the error cases are unrecoverable and will 1392 * be handled according (flushing regs, etc as required). 1393 * For details on these error cases (UGER_CRE, UGER_CTXT, etc..) 1394 * consult the OPL cpu/mem philosophy doc. 1395 * Ereport will be generated for these errors. 1396 * 5. Ereport generation. 1397 * - Ereport generation for urgent error trap always 1398 * result in a panic when we unwind to the TL=0 handling 1399 * code via sys_trap(). on_trap()/lofault protection do 1400 * not apply there. 1401 */ 1402 ENTRY_NP(opl_uger_trap) 1403 set ASI_UGERSR, %g2 1404 ldxa [%g2]ASI_AFSR, %g1 ! Read the UGERSR reg 1405 1406 set UGESR_MULTI, %g2 1407 andcc %g1, %g2, %g0 ! Check for Multi-errs 1408 bz,pt %xcc, opl_uger_is_recover ! branch if not Multi-errs 1409 nop 1410 set AFSR_ECR, %g2 1411 ldxa [%g2]ASI_AFSR, %g3 ! Enable Weak error 1412 or %g3, ASI_ECR_WEAK_ED, %g3 ! detect mode to prevent 1413 stxa %g3, [%g2]ASI_AFSR ! potential error storms 1414 ba %xcc, opl_uger_panic1 1415 nop 1416 1417opl_uger_is_recover: 1418 set UGESR_CAN_RECOVER, %g2 ! Check for recoverable 1419 andcc %g1, %g2, %g0 ! errors i.e.IUG_DTLB, 1420 bz,pt %xcc, opl_uger_cre ! IUG_ITLB or COREERR 1421 nop 1422 1423 /* 1424 * Fall thru to handle recoverable case 1425 * Need to do the following additional checks to determine 1426 * if this is indeed recoverable. 1427 * 1. Error trap came from TL=0 and 1428 * 2. INSTEND[5:4] bits in UGERSR is not 0x3 1429 * 3. Recoverable error count limit not reached 1430 * 1431 */ 1432 FLUSH_ALL_TLB(%g3) 1433 rdpr %tl, %g3 ! Read TL 1434 cmp %g3, 1 ! Check if we came from TL=0 1435 bne,pt %xcc, opl_uger_panic ! branch if came from TL>0 1436 nop 1437 srlx %g1, 4, %g2 ! shift INSTEND[5:4] -> [1:0] 1438 and %g2, 3, %g2 ! extract the shifted [1:0] bits 1439 cmp %g2, 3 ! check if INSTEND is recoverable 1440 be,pt %xcc, opl_uger_panic ! panic if ([1:0] = 11b) 1441 nop 1442 set OPL_SCRATCHPAD_ERRLOG, %g3 1443 ldxa [%g3]ASI_SCRATCHPAD, %g2 ! Read errlog scratch reg 1444 and %g2, ERRLOG_REG_NUMERR_MASK, %g3! Extract error count and 1445 subcc %g3, 1, %g3 ! subtract one from it 1446 bz,pt %xcc, opl_uger_panic ! If count reached zero, too many 1447 nop ! errors, branch to generate ereport 1448 sub %g2, 1, %g2 ! Subtract one from the count 1449 set OPL_SCRATCHPAD_ERRLOG, %g3 ! and write back the updated 1450 stxa %g2, [%g3]ASI_SCRATCHPAD ! count into the errlog reg 1451 LOG_UGER_REG(%g1, %g2, %g3) ! Log the error info 1452#ifdef TRAPTRACE 1453 OPL_TRAPTRACE(%g1, %g2, %g3, opl_uger_trap_lb) 1454#endif /* TRAPTRACE */ 1455 retry ! retry - no ereport 1456 1457 /* 1458 * Process the rest of the unrecoverable error cases 1459 * All error cases below ultimately branch to either 1460 * opl_uger_panic or opl_uger_panic1. 1461 * opl_uger_panic1 is the same as opl_uger_panic except 1462 * for the additional execution of the RESET_TO_PRIV() 1463 * macro that does a heavy handed reset. Read the 1464 * comments for RESET_TO_PRIV() macro for more info. 1465 */ 1466opl_uger_cre: 1467 set UGESR_IAUG_CRE, %g2 1468 andcc %g1, %g2, %g0 1469 bz,pt %xcc, opl_uger_ctxt 1470 nop 1471 IAG_CRE(%g2, %g3) 1472 set AFSR_ECR, %g2 1473 ldxa [%g2]ASI_AFSR, %g3 1474 or %g3, ASI_ECR_WEAK_ED, %g3 1475 stxa %g3, [%g2]ASI_AFSR 1476 ba %xcc, opl_uger_panic 1477 nop 1478 1479opl_uger_ctxt: 1480 set UGESR_IAUG_TSBCTXT, %g2 1481 andcc %g1, %g2, %g0 1482 bz,pt %xcc, opl_uger_tsbp 1483 nop 1484 RESET_MMU_REGS(%g2, %g3, %g4) 1485 ba %xcc, opl_uger_panic 1486 nop 1487 1488opl_uger_tsbp: 1489 set UGESR_IUG_TSBP, %g2 1490 andcc %g1, %g2, %g0 1491 bz,pt %xcc, opl_uger_pstate 1492 nop 1493 RESET_TSB_TAGPTR(%g2) 1494 1495 /* 1496 * IUG_TSBP error may corrupt MMU registers 1497 * Reset them here. 1498 */ 1499 RESET_MMU_REGS(%g2, %g3, %g4) 1500 ba %xcc, opl_uger_panic 1501 nop 1502 1503opl_uger_pstate: 1504 set UGESR_IUG_PSTATE, %g2 1505 andcc %g1, %g2, %g0 1506 bz,pt %xcc, opl_uger_tstate 1507 nop 1508 RESET_CUR_TSTATE(%g2) 1509 ba %xcc, opl_uger_panic1 1510 nop 1511 1512opl_uger_tstate: 1513 set UGESR_IUG_TSTATE, %g2 1514 andcc %g1, %g2, %g0 1515 bz,pt %xcc, opl_uger_f 1516 nop 1517 RESET_PREV_TSTATE(%g2, %g3, opl_uger_tstate_1) 1518 ba %xcc, opl_uger_panic1 1519 nop 1520 1521opl_uger_f: 1522 set UGESR_IUG_F, %g2 1523 andcc %g1, %g2, %g0 1524 bz,pt %xcc, opl_uger_r 1525 nop 1526 CLEAR_FPREGS(%g2) 1527 ba %xcc, opl_uger_panic 1528 nop 1529 1530opl_uger_r: 1531 set UGESR_IUG_R, %g2 1532 andcc %g1, %g2, %g0 1533 bz,pt %xcc, opl_uger_panic1 1534 nop 1535 CLEAR_GEN_REGS(%g2, opl_uger_r_1) 1536 ba %xcc, opl_uger_panic1 1537 nop 1538 1539opl_uger_panic: 1540 mov %g1, %g2 ! %g2 = arg #1 1541 LOG_UGER_REG(%g1, %g3, %g4) 1542 ba %xcc, opl_uger_panic_cmn 1543 nop 1544 1545opl_uger_panic1: 1546 mov %g1, %g2 ! %g2 = arg #1 1547 LOG_UGER_REG(%g1, %g3, %g4) 1548 RESET_TO_PRIV(%g1, %g3, %g4, %l0) 1549 1550 /* 1551 * Set up the argument for sys_trap. 1552 * %g2 = arg #1 already set above 1553 */ 1554opl_uger_panic_cmn: 1555 RESET_USER_RTT_REGS(%g4, %g5, 1f) 15561: 1557 rdpr %tl, %g3 ! arg #2 1558 set opl_cpu_urgent_error, %g1 ! pc 1559 sethi %hi(sys_trap), %g5 1560 jmp %g5 + %lo(sys_trap) 1561 mov PIL_15, %g4 1562 SET_SIZE(opl_uger_trap) 1563#endif /* lint */ 1564 1565#if defined(lint) 1566 1567void 1568opl_serr_instr(void) 1569{} 1570 1571#else /* lint */ 1572/* 1573 * The actual trap handler for tt=0x0a, and tt=0x32 1574 */ 1575 ENTRY_NP(opl_serr_instr) 1576 OPL_SAVE_GLOBAL(%g1,%g2,%g3) 1577 sethi %hi(opl_sync_trap), %g3 1578 jmp %g3 + %lo(opl_sync_trap) 1579 rdpr %tt, %g1 1580 .align 32 1581 SET_SIZE(opl_serr_instr) 1582 1583#endif /* lint */ 1584 1585#if defined(lint) 1586 1587void 1588opl_ugerr_instr(void) 1589{} 1590 1591#else /* lint */ 1592/* 1593 * The actual trap handler for tt=0x40 1594 */ 1595 ENTRY_NP(opl_ugerr_instr) 1596 sethi %hi(opl_uger_trap), %g3 1597 jmp %g3 + %lo(opl_uger_trap) 1598 nop 1599 .align 32 1600 SET_SIZE(opl_ugerr_instr) 1601 1602#endif /* lint */ 1603 1604#if defined(lint) 1605/* 1606 * Get timestamp (stick). 1607 */ 1608/* ARGSUSED */ 1609void 1610stick_timestamp(int64_t *ts) 1611{ 1612} 1613 1614#else /* lint */ 1615 1616 ENTRY_NP(stick_timestamp) 1617 rd STICK, %g1 ! read stick reg 1618 sllx %g1, 1, %g1 1619 srlx %g1, 1, %g1 ! clear npt bit 1620 1621 retl 1622 stx %g1, [%o0] ! store the timestamp 1623 SET_SIZE(stick_timestamp) 1624 1625#endif /* lint */ 1626 1627 1628#if defined(lint) 1629/* 1630 * Set STICK adjusted by skew. 1631 */ 1632/* ARGSUSED */ 1633void 1634stick_adj(int64_t skew) 1635{ 1636} 1637 1638#else /* lint */ 1639 1640 ENTRY_NP(stick_adj) 1641 rdpr %pstate, %g1 ! save processor state 1642 andn %g1, PSTATE_IE, %g3 1643 ba 1f ! cache align stick adj 1644 wrpr %g0, %g3, %pstate ! turn off interrupts 1645 1646 .align 16 16471: nop 1648 1649 rd STICK, %g4 ! read stick reg 1650 add %g4, %o0, %o1 ! adjust stick with skew 1651 wr %o1, %g0, STICK ! write stick reg 1652 1653 retl 1654 wrpr %g1, %pstate ! restore processor state 1655 SET_SIZE(stick_adj) 1656 1657#endif /* lint */ 1658 1659#if defined(lint) 1660/* 1661 * Debugger-specific stick retrieval 1662 */ 1663/*ARGSUSED*/ 1664int 1665kdi_get_stick(uint64_t *stickp) 1666{ 1667 return (0); 1668} 1669 1670#else /* lint */ 1671 1672 ENTRY_NP(kdi_get_stick) 1673 rd STICK, %g1 1674 stx %g1, [%o0] 1675 retl 1676 mov %g0, %o0 1677 SET_SIZE(kdi_get_stick) 1678 1679#endif /* lint */ 1680 1681#if defined(lint) 1682 1683/*ARGSUSED*/ 1684int 1685dtrace_blksuword32(uintptr_t addr, uint32_t *data, int tryagain) 1686{ return (0); } 1687 1688#else 1689 1690 ENTRY(dtrace_blksuword32) 1691 save %sp, -SA(MINFRAME + 4), %sp 1692 1693 rdpr %pstate, %l1 1694 andn %l1, PSTATE_IE, %l2 ! disable interrupts to 1695 wrpr %g0, %l2, %pstate ! protect our FPU diddling 1696 1697 rd %fprs, %l0 1698 andcc %l0, FPRS_FEF, %g0 1699 bz,a,pt %xcc, 1f ! if the fpu is disabled 1700 wr %g0, FPRS_FEF, %fprs ! ... enable the fpu 1701 1702 st %f0, [%fp + STACK_BIAS - 4] ! save %f0 to the stack 17031: 1704 set 0f, %l5 1705 /* 1706 * We're about to write a block full or either total garbage 1707 * (not kernel data, don't worry) or user floating-point data 1708 * (so it only _looks_ like garbage). 1709 */ 1710 ld [%i1], %f0 ! modify the block 1711 membar #Sync 1712 stn %l5, [THREAD_REG + T_LOFAULT] ! set up the lofault handler 1713 stda %d0, [%i0]ASI_BLK_COMMIT_S ! store the modified block 1714 membar #Sync 1715 flush %i0 ! flush instruction pipeline 1716 stn %g0, [THREAD_REG + T_LOFAULT] ! remove the lofault handler 1717 1718 bz,a,pt %xcc, 1f 1719 wr %g0, %l0, %fprs ! restore %fprs 1720 1721 ld [%fp + STACK_BIAS - 4], %f0 ! restore %f0 17221: 1723 1724 wrpr %g0, %l1, %pstate ! restore interrupts 1725 1726 ret 1727 restore %g0, %g0, %o0 1728 17290: 1730 membar #Sync 1731 stn %g0, [THREAD_REG + T_LOFAULT] ! remove the lofault handler 1732 1733 bz,a,pt %xcc, 1f 1734 wr %g0, %l0, %fprs ! restore %fprs 1735 1736 ld [%fp + STACK_BIAS - 4], %f0 ! restore %f0 17371: 1738 1739 wrpr %g0, %l1, %pstate ! restore interrupts 1740 1741 /* 1742 * If tryagain is set (%i2) we tail-call dtrace_blksuword32_err() 1743 * which deals with watchpoints. Otherwise, just return -1. 1744 */ 1745 brnz,pt %i2, 1f 1746 nop 1747 ret 1748 restore %g0, -1, %o0 17491: 1750 call dtrace_blksuword32_err 1751 restore 1752 1753 SET_SIZE(dtrace_blksuword32) 1754#endif /* lint */ 1755 1756#if defined(lint) 1757/*ARGSUSED*/ 1758void 1759ras_cntr_reset(void *arg) 1760{ 1761} 1762#else 1763 ENTRY_NP(ras_cntr_reset) 1764 set OPL_SCRATCHPAD_ERRLOG, %o1 1765 ldxa [%o1]ASI_SCRATCHPAD, %o0 1766 or %o0, ERRLOG_REG_NUMERR_MASK, %o0 1767 retl 1768 stxa %o0, [%o1]ASI_SCRATCHPAD 1769 SET_SIZE(ras_cntr_reset) 1770#endif /* lint */ 1771 1772#if defined(lint) 1773/* ARGSUSED */ 1774void 1775opl_error_setup(uint64_t cpu_err_log_pa) 1776{ 1777} 1778 1779#else /* lint */ 1780 ENTRY_NP(opl_error_setup) 1781 /* 1782 * Initialize the error log scratchpad register 1783 */ 1784 ldxa [%g0]ASI_EIDR, %o2 1785 sethi %hi(ERRLOG_REG_EIDR_MASK), %o1 1786 or %o1, %lo(ERRLOG_REG_EIDR_MASK), %o1 1787 and %o2, %o1, %o3 1788 sllx %o3, ERRLOG_REG_EIDR_SHIFT, %o2 1789 or %o2, %o0, %o3 1790 or %o3, ERRLOG_REG_NUMERR_MASK, %o0 1791 set OPL_SCRATCHPAD_ERRLOG, %o1 1792 stxa %o0, [%o1]ASI_SCRATCHPAD 1793 /* 1794 * Disable all restrainable error traps 1795 */ 1796 mov AFSR_ECR, %o1 1797 ldxa [%o1]ASI_AFSR, %o0 1798 andn %o0, ASI_ECR_RTE_UE|ASI_ECR_RTE_CEDG, %o0 1799 retl 1800 stxa %o0, [%o1]ASI_AFSR 1801 SET_SIZE(opl_error_setup) 1802#endif /* lint */ 1803 1804#if defined(lint) 1805/* ARGSUSED */ 1806void 1807opl_mpg_enable(void) 1808{ 1809} 1810#else /* lint */ 1811 ENTRY_NP(opl_mpg_enable) 1812 /* 1813 * Enable MMU translating multiple page sizes for 1814 * sITLB and sDTLB. 1815 */ 1816 mov LSU_MCNTL, %o0 1817 ldxa [%o0] ASI_MCNTL, %o1 1818 or %o1, MCNTL_MPG_SITLB | MCNTL_MPG_SDTLB, %o1 1819 retl 1820 stxa %o1, [%o0] ASI_MCNTL 1821 SET_SIZE(opl_mpg_enable) 1822#endif /* lint */ 1823 1824#if defined(lint) 1825/* 1826 * This function is called for each (enabled) CPU. We use it to 1827 * initialize error handling related registers. 1828 */ 1829/*ARGSUSED*/ 1830void 1831cpu_feature_init(void) 1832{} 1833#else /* lint */ 1834 ENTRY(cpu_feature_init) 1835 ! 1836 ! get the device_id and store the device_id 1837 ! in the appropriate cpunodes structure 1838 ! given the cpus index 1839 ! 1840 CPU_INDEX(%o0, %o1) 1841 mulx %o0, CPU_NODE_SIZE, %o0 1842 set cpunodes + DEVICE_ID, %o1 1843 ldxa [%g0] ASI_DEVICE_SERIAL_ID, %o2 1844 stx %o2, [%o0 + %o1] 1845 ! 1846 ! initialize CPU registers 1847 ! 1848 ba opl_cpu_reg_init 1849 nop 1850 SET_SIZE(cpu_feature_init) 1851#endif /* lint */ 1852 1853#if defined(lint) 1854 1855void 1856cpu_cleartickpnt(void) 1857{} 1858 1859#else /* lint */ 1860 /* 1861 * Clear the NPT (non-privileged trap) bit in the %tick/%stick 1862 * registers. In an effort to make the change in the 1863 * tick/stick counter as consistent as possible, we disable 1864 * all interrupts while we're changing the registers. We also 1865 * ensure that the read and write instructions are in the same 1866 * line in the instruction cache. 1867 */ 1868 ENTRY_NP(cpu_clearticknpt) 1869 rdpr %pstate, %g1 /* save processor state */ 1870 andn %g1, PSTATE_IE, %g3 /* turn off */ 1871 wrpr %g0, %g3, %pstate /* interrupts */ 1872 rdpr %tick, %g2 /* get tick register */ 1873 brgez,pn %g2, 1f /* if NPT bit off, we're done */ 1874 mov 1, %g3 /* create mask */ 1875 sllx %g3, 63, %g3 /* for NPT bit */ 1876 ba,a,pt %xcc, 2f 1877 .align 8 /* Ensure rd/wr in same i$ line */ 18782: 1879 rdpr %tick, %g2 /* get tick register */ 1880 wrpr %g3, %g2, %tick /* write tick register, */ 1881 /* clearing NPT bit */ 18821: 1883 rd STICK, %g2 /* get stick register */ 1884 brgez,pn %g2, 3f /* if NPT bit off, we're done */ 1885 mov 1, %g3 /* create mask */ 1886 sllx %g3, 63, %g3 /* for NPT bit */ 1887 ba,a,pt %xcc, 4f 1888 .align 8 /* Ensure rd/wr in same i$ line */ 18894: 1890 rd STICK, %g2 /* get stick register */ 1891 wr %g3, %g2, STICK /* write stick register, */ 1892 /* clearing NPT bit */ 18933: 1894 jmp %g4 + 4 1895 wrpr %g0, %g1, %pstate /* restore processor state */ 1896 1897 SET_SIZE(cpu_clearticknpt) 1898 1899#endif /* lint */ 1900 1901#if defined(lint) 1902 1903void 1904cpu_halt_cpu(void) 1905{} 1906 1907void 1908cpu_smt_pause(void) 1909{} 1910 1911#else /* lint */ 1912 1913 /* 1914 * Halt the current strand with the suspend instruction. 1915 * The compiler/asm currently does not support this suspend 1916 * instruction mnemonic, use byte code for now. 1917 */ 1918 ENTRY_NP(cpu_halt_cpu) 1919 .word 0x81b01040 1920 retl 1921 nop 1922 SET_SIZE(cpu_halt_cpu) 1923 1924 /* 1925 * Pause the current strand with the sleep instruction. 1926 * The compiler/asm currently does not support this sleep 1927 * instruction mnemonic, use byte code for now. 1928 */ 1929 ENTRY_NP(cpu_smt_pause) 1930 .word 0x81b01060 1931 retl 1932 nop 1933 SET_SIZE(cpu_smt_pause) 1934 1935#endif /* lint */ 1936