Date: Sat, 11 Mar 2006 07:54:27 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 93133 for review Message-ID: <200603110754.k2B7sRBc074085@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93133 Change 93133 by kmacy@kmacy_storage:sun4v_work on 2006/03/11 07:53:27 revise register usage for consistency and integration with utrap Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#25 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#25 (text+ko) ==== @@ -198,7 +198,6 @@ .endm .macro tl0_split - GET_PCB(PCB_REG); /* load PCPU and PCB pointers */ .endm .macro tl0_setup type @@ -517,10 +516,11 @@ END(tl0_sfsr_trap) .macro tl0_pil_entry level, mask - tl0_split - set \mask, %g2 + set \mask, %g1 + clr %g2 + clr %g3 ba %xcc, tl0_intr - mov \level, %g1 + mov \level, %g4 .align 32 .endm @@ -968,7 +968,7 @@ ldx [%l7 + TF_TPC], %g1 ldx [%l7 + TF_TNPC], %g2 ldx [%l7 + TF_TSTATE], %l0 - andn %l0, TSTATE_CWP_MASK, %g4 + andn %l0, TSTATE_CWP_MASK, %g7 wrpr %g1, %tpc wrpr %g2, %tnpc @@ -987,14 +987,14 @@ rdpr %canrestore, %g1 brnz %g1, 3f - nop ! no trap, use restore directly + nop ! no trap, use restore directly rdpr %cwp, %g1 wrpr %g1, %g7, %tstate ! needed by wbuf recovery code ! hand craft the restore to avoid getting to TL > 2 rdpr %wstate, %g1 btst 1, %g1 beq 4f - nop + nop .global rtt_fill_start rtt_fill_start: #if 0 @@ -1027,22 +1027,26 @@ SAVE_OUTS(%l7) ! for the call bug workaround wrpr %g0, PSTATE_KERNEL, %pstate ! enable ints ! MAGIC_TRAP_OFF - #if 0 + + brnz %o1, common_ktrap + nop call critical_enter nop - #endif - stx %l4, [%l7 + TF_TYPE] ! save trap type - stx %l5, [%l7 + TF_TAR] ! save mem info jmpl %l3, %o7 ! call trap handler mov %l7, %o0 - #if 0 call critical_exit nop - #endif + b common_rtt +common_ktrap: + nop + stx %o1, [%l7 + TF_TYPE] ! save trap type + stx %o2, [%l7 + TF_TAR] ! save mem info + jmpl %l3, %o7 ! call trap handler + mov %l7, %o0 + ! MAGIC_TRAP_ON ENTRY(krtt) MAGIC_TRAP_ON - GET_PCPU_SCRATCH common_rtt: ! ! restore globals and outs @@ -1072,14 +1076,14 @@ ldx [%l7 + TF_TPC], %g1 ldx [%l7 + TF_TNPC], %g2 ldx [%l7 + TF_TSTATE], %l0 - andn %l0, TSTATE_CWP_MASK, %g4 + andn %l0, TSTATE_CWP_MASK, %g7 wrpr %g1, %tpc wrpr %g2, %tnpc rdpr %canrestore, %g1 brnz %g1, 3f nop ! can use restore directly rdpr %cwp, %g1 - wrpr %g1, %g4, %tstate ! needed by wbuf recovery code + wrpr %g1, %g7, %tstate ! needed by wbuf recovery code ! avoid going above TL2 fill_64bit_rtt(ASI_N) @@ -1090,7 +1094,7 @@ ! set %tstate to the correct %cwp ! rdpr %cwp, %g1 - wrpr %g1, %g4, %tstate + wrpr %g1, %g7, %tstate MAGIC_TRAP_OFF retry END(krtt) @@ -1100,13 +1104,14 @@ ! ! ENTRY(tl0_ktrap) - set ktl0, %g4 + GET_PCPU_SCRATCH + set ktl0, %g6 save %sp, -(CCFSZ + TF_SIZEOF), %sp - mov %g2, %l3 ! set trap/interrupt for tl0 - or %g1, T_KERNEL, %l4 ! pil/trap type - mov %g6, %l5 ! fault info if set + mov %g1, %l3 ! set trap/interrupt for tl0 + or %g2, T_KERNEL, %o1 ! trap type + mov %g3, %o2 ! fault info if set ! if the kwbuf is full we need to save to the stack now ld [PCPU_REG + PC_KWBUF_FULL], %o0 @@ -1122,29 +1127,35 @@ ! register convention: - ! %g1=level %g2=mask + ! %g2=level %g1=mask ENTRY(tl0_intr) - wrpr %g1, 0, %pil - wr %g2, 0, %clear_softint - SET(intr_handlers, %g5, %g4) - sllx %g1, IH_SHIFT, %g5 - ldx [%g4 + %g5], %g2 ! pointer to interrupt handler - + wrpr %g4, 0, %pil + wr %g1, 0, %clear_softint + SET(intr_handlers, %g7, %g6) + sllx %g4, IH_SHIFT, %g7 + ldx [%g6 + %g7], %g1 ! pointer to interrupt handler - ! assumes %g3 - %g5 are free - ! %g1 == pil that we came in on - ! %g2 == interrupt handler - ! %g7 == PCPU - ! %g3-%g5 temporaries + ! %g1 pc of trap handler + ! %g2, %g3 args of trap handler + ! %g4 desired pil + ! %g5, %g6 temps + ! %g7 saved + + ! %l0, %l1 temps + ! %l3 saved %g1 + ! %l4 flags + ! %l5 memory fault info + ! %l6 %pil for priv traps + ! %l7 trapframe + ENTRY(tl0_trap) - GET_PCPU_SCRATCH - rdpr %tstate, %g3 - btst TSTATE_PRIV, %g3 - and %g3, TSTATE_CWP_MASK, %g4 + rdpr %tstate, %g5 + btst TSTATE_PRIV, %g5 + and %g5, TSTATE_CWP_MASK, %g6 bnz,pn %xcc, tl0_ktrap - wrpr %g0, %g4, %cwp + wrpr %g0, %g6, %cwp ENTRY(tl0_utrap) MAGIC_TRAP_ON;MAGIC_TRAP_ON;MAGIC_EXIT @@ -1162,11 +1173,22 @@ ! ! setup pil ! - brlz,pt %g1, 1f + brlz,pt %g4, 1f + nop +#ifdef PMAP_DEBUG + rdpr %pil, %l0 + cmp %g4, %l0 + bge,pt %xcc, 0f nop - wrpr %g0, %g1, %pil + MAGIC_TRAP_ON + MAGIC_TRAP_ON + MAGIC_EXIT +0: +#endif + + wrpr %g0, %g4, %pil 1: - wrpr %g0, %g4, %tnpc + wrpr %g0, %g6, %tnpc rdpr %cwp, %l0 set TSTATE_KERNEL, %l1 wrpr %l1, %l0, %tstate @@ -1219,7 +1241,8 @@ tsb_miss_null_deref: MAGIC_TRAP_ON;MAGIC_TRAP_ON;MAGIC_EXIT ! give up 3: -#endif +#endif +tsb_miss_compute_hash_addr: sethi %hi(PAGE_SIZE), %g7 sub %g7, 1, %g7 ! %g7==PAGE_MASK @@ -1284,63 +1307,82 @@ 4: ! not found ! we need to jump to tl0_trap to drop us back down to tl0 ! and take us to trap(...) to service the fault - +#ifdef PMAP_DEBUG + rdpr %tl, %g4 + cmp %g4, 1 + be,pt %xcc, 15f + nop + MAGIC_TRAP_ON;MAGIC_TRAP_ON;MAGIC_EXIT +15: +#if 0 + srlx %g6, TTARGET_CTX_SHIFT, %g4 ! recover context + brnz %g4, 16f + nop + MAGIC_TRAP_ON;MAGIC_TRAP_ON;MAGIC_EXIT +#endif +16: +#endif srlx %g6, TTARGET_CTX_SHIFT, %g4 ! recover context - or %g4, %g7, %g6 - mov T_DATA_MISS, %g1 - sethi %hi(trap), %g2 + sethi %hi(trap), %g1 + mov T_DATA_MISS, %g2 + or %g4, %g7, %g3 + mov -1, %g4 ba %xcc, tl0_trap - or %g2, %lo(trap), %g2 + or %g1, %lo(trap), %g1 + tsb_miss_found: 5: !found ! %g1 == abs index %g2 == THE pointer %g3 == flags ! %g4 == tag %g5 == data %g7 == PAGE_MASK ! %g3 <- TSB RA %g6 <- TSB size, TTE RA + srlx %g6, TTARGET_CTX_SHIFT, %g6 + or %g7, %g6, %g6 ! save context and fault addr + ! will break when ctxbits > 13 + sethi %hi(PAGE_SIZE), %g7 + sub %g7, 1, %g7 ! %g7==PAGE_MASK - sethi %hi(PAGE_SIZE), %g7 - srlx %g6, TTARGET_CTX_SHIFT, %g6 - sub %g7, 1, %g7 ! %g7==PAGE_MASK - - andcc %g5, %g3, %g0 ! already set - bnz,pt %xcc, 7f + andcc %g5, %g3, %g0 ! already set + bnz,pt %xcc, 7f nop - andcc %g3, VTD_REF, %g0 ! TSB miss - bnz,pt %xcc, 6f + andcc %g3, VTD_REF, %g0 ! TSB miss + bnz,pt %xcc, 6f or %g5, %g3, %g5 ! add ref/mod bit unconditionally - andcc %g5, VTD_SW_W, %g0 ! write enabled? - bz,pn %xcc, prot_fault_trap ! write to read only page + andcc %g5, VTD_SW_W, %g0 ! write enabled? + bz,pn %xcc, prot_fault_trap ! write to read only page or %g5, %g3, %g5 ! add ref/mod bit unconditionally 6: - stx %g5, [%g2 + 8] ! set ref/mod bit + stx %g5, [%g2 + 8] ! set ref/mod bit 7: - cmp %g6, %g0 ! kernel context? - be,pn %xcc, 8f + andcc %g6, %g7, %g0 ! kernel context? + bz,pn %xcc, 8f nop GET_TSB_SCRATCH_USER(%g3) ! %g3 == TSB (RA) ba,pt %xcc, 9f - and %g3, %g7, %g6 ! size of TSB in pages + and %g3, %g7, %g2 ! size of TSB in pages 8: GET_TSB_SCRATCH_KERNEL(%g3) ! %g3 == TSB (RA) - and %g3, %g7, %g6 ! size of TSB in pages + and %g3, %g7, %g2 ! size of TSB in pages 9: - andn %g3, %g7, %g3 ! TSB real address - sllx %g6, (PAGE_SHIFT - TTE_SHIFT), %g6 ! nttes - subx %g6, 1, %g6 ! TSB_MASK - and %g6, %g1, %g6 ! masked index - sllx %g6, TTE_SHIFT, %g6 ! masked byte offset - add %g6, %g3, %g6 ! TTE RA - mov 8, %g7 + andn %g3, %g7, %g3 ! TSB real address + sllx %g2, (PAGE_SHIFT - TTE_SHIFT), %g2 ! nttes + subx %g2, 1, %g2 ! TSB_MASK + and %g2, %g1, %g2 ! masked index + sllx %g2, TTE_SHIFT, %g2 ! masked byte offset + add %g2, %g3, %g2 ! TTE RA + mov 8, %g7 #ifdef PMAP_DEBUG - ldda [%g6]ASI_LDTD_REAL, %g2 - cmp %g3, %g5 - bne,pt %xcc, 10f + mov %g2, %g1 + ldda [%g2]ASI_LDTD_REAL, %g2 + cmp %g3, %g5 + bne,pt %xcc, 10f nop - MAGIC_TRAP_ON;MAGIC_TRAP_ON;MAGIC_EXIT ! die if all we're doing + MAGIC_TRAP_ON;MAGIC_TRAP_ON;MAGIC_EXIT ! die if all we're doing ! is storing same data -10: +10: + mov %g1, %g2 #endif - stxa %g4, [%g6]ASI_REAL ! store tag - stxa %g5, [%g6 + %g7]ASI_REAL ! store data + stxa %g4, [%g2]ASI_REAL ! store tag + stxa %g5, [%g2 + %g7]ASI_REAL ! store data MAGIC_TRAP_OFF ! XXX the following intstruction should be replaced with a @@ -1348,15 +1390,15 @@ ontario_demap_errata_patch: andcc %g5, VTD_W, %g0 bnz,pn %xcc, demap_begin - mov MMFSA_D_CTX, %g2 + nop retry -demap_begin: - GET_MMFSA_SCRATCH(%g1) ! XXX this isn't re-entrant - mov MMFSA_D_ADDR, %g3 +demap_begin: + sethi %hi(PAGE_MASK), %g1 + sub %g1, 1, %g1 + and %g6, %g1, %g2 + andn %g6, %g1, %g3 mov %o0, %g5 mov %o1, %g6 - ldxa [%g1 + %g2]ASI_REAL, %g2 !%g2 == context - ldxa [%g1 + %g3]ASI_REAL, %g3 !%g3 == fault addr mov %o2, %g7 mov MAP_DTLB, %o2 mov %g3, %o0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603110754.k2B7sRBc074085>