Date: Tue, 21 Mar 2006 03:31:02 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 93682 for review Message-ID: <200603210331.k2L3V289095817@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93682 Change 93682 by kmacy@kmacy_storage:sun4vtmp on 2006/03/21 03:30:11 avoid stepping on user register implement general case trap handlers don't use %g7 except as PCPU_REG in general trap handlers Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#36 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#36 (text+ko) ==== @@ -211,18 +211,17 @@ .endm .macro tl0_setup type - tl0_split + clr %g3 + mov 0, %g4 + set trap, %g1 ba %xcc, tl0_trap - mov \type, %g1 + mov \type, %g2 .endm /* * Generic trap type. Call trap() with the specified type. */ .macro tl0_gen type - MAGIC_TRAP_ON - MAGIC_TRAP_ON - MAGIC_EXIT tl0_setup \type .align 32 .endm @@ -520,6 +519,8 @@ .macro tl0_pil_entry level, mask #if 1 + wrpr %g0, 1, %tl + wrpr %g0, 1, %gl set \mask, %g1 clr %g2 clr %g3 @@ -573,29 +574,10 @@ INTR_LEVEL(0) .endm - .macro tl0_immu_miss - nop - .align 128 - .endm - - - .macro tl0_spill_bad count - .rept \count - sir - .align 128 - .endr - .endm - - .macro tl0_fill_bad count - .rept \count - sir - .align 128 - .endr - .endm .macro tl0_syscall clr %g3 - mov -1, %g4 + mov 0, %g4 set syscall, %g1 ba %xcc, tl0_trap mov T_SYSCALL, %g2 @@ -927,29 +909,33 @@ ENTRY(utl0) - GET_PCPU_SCRATCH + nop SAVE_GLOBALS(%l7) SAVE_OUTS(%l7) + GET_PCPU_SCRATCH wrpr %g0, PSTATE_KERNEL, %pstate ! enable ints brnz %o1, common_utrap nop call critical_enter nop + wrpr %g0, 0, %pil jmpl %l3, %o7 ! call trap handler mov %l7, %o0 call critical_exit nop b user_rtt nop -common_utrap: +common_utrap: + wrpr %g0, 0, %pil jmpl %l3, %o7 ! call trap handler mov %l7, %o0 - GET_PCB(%g6) + ldx [PCPU_REG + PC_CURPCB], %g6 sub %g6, CCFSZ + SPOFF + TF_SIZEOF, %sp add %sp, REGOFF + SPOFF, %l7 ENTRY(user_rtt) + GET_PCPU_SCRATCH ! pil handling needs to be re-visited wrpr %g0, PIL_TICK, %pil ldx [PCPU(CURTHREAD)], %l0 @@ -966,8 +952,9 @@ ba,a,pt %xcc, user_rtt nop -1: GET_PCB(PCB_REG) - ldx [PCB_REG + PCB_NSAVED], %l1 +1: + ldx [PCPU_REG + PC_CURPCB], %g6 + ldx [%g6 + PCB_NSAVED], %l1 brz,a,pt %l1, 2f nop wrpr %g0, 0, %pil @@ -985,11 +972,9 @@ wrpr %l1, PSTATE_IE, %pstate RESTORE_GLOBALS(%l7) wrpr %g0, 1, %gl - mov %sp, %g6 ! save tf pointer RESTORE_OUTS(%l7) wrpr %g0, 0, %pil ! drop pil to 0 - wrpr %g0, 1, %tl ! raise tl -> 1 before setting pcontext mov MMU_CID_S, %g1 @@ -1005,7 +990,7 @@ ldx [%l7 + TF_TPC], %g1 ldx [%l7 + TF_TNPC], %g2 ldx [%l7 + TF_TSTATE], %l0 - andn %l0, TSTATE_CWP_MASK, %g7 + andn %l0, TSTATE_CWP_MASK, %g6 wrpr %g1, %tpc wrpr %g2, %tnpc @@ -1059,7 +1044,7 @@ brnz %g1, 3f nop ! no trap, use restore directly rdpr %cwp, %g1 - wrpr %g1, %g7, %tstate ! needed by wbuf recovery code + wrpr %g1, %g6, %tstate ! needed by wbuf recovery code ! hand craft the restore to avoid getting to TL > 2 rdpr %wstate, %g1 btst 1, %g1 @@ -1087,16 +1072,17 @@ rdpr %canrestore, %g1 wrpr %g0, %g1, %cleanwin rdpr %cwp, %g1 - wrpr %g1, %g7, %tstate -! MAGIC_TRAP_ON + wrpr %g1, %g6, %tstate +! MAGIC_TRAP_ON retry END(user_rtt) END(utl0) ENTRY(ktl0) + nop + SAVE_GLOBALS(%l7) + SAVE_OUTS(%l7) GET_PCPU_SCRATCH - SAVE_GLOBALS(%l7) - SAVE_OUTS(%l7) ! for the call bug workaround wrpr %g0, PSTATE_KERNEL, %pstate ! enable ints brnz %o1, common_ktrap @@ -1109,7 +1095,7 @@ nop b common_rtt nop -common_ktrap: +common_ktrap: jmpl %l3, %o7 ! call trap handler mov %l7, %o0 @@ -1120,7 +1106,10 @@ ! rdpr %pstate, %l1 wrpr %l1, PSTATE_IE, %pstate + + RESTORE_GLOBALS(%l7) + ! switch to global set 1 wrpr %g0, 1, %gl RESTORE_OUTS(%l7) @@ -1134,23 +1123,29 @@ movg %xcc, %l6, %l0 wrpr %g0, %l0, %pil #endif + GET_PCPU_SCRATCH + /* simulator incorrectly exits if tl != gl */ + ldx [PCPU(CURTHREAD)], %l0 + ldx [%l0 + TD_MD + MD_SAVED_PIL], %l0 + wrpr %g0, %l0, %pil ! ! raise tl ! setup trap regs ! restore to window we originally trapped in ! wrpr %g0, 1, %tl + ldx [%l7 + TF_TPC], %g1 ldx [%l7 + TF_TNPC], %g2 ldx [%l7 + TF_TSTATE], %l0 - andn %l0, TSTATE_CWP_MASK, %g7 + andn %l0, TSTATE_CWP_MASK, %g6 wrpr %g1, %tpc wrpr %g2, %tnpc rdpr %canrestore, %g1 brnz %g1, 3f nop ! can use restore directly rdpr %cwp, %g1 - wrpr %g1, %g7, %tstate ! needed by wbuf recovery code + wrpr %g1, %g6, %tstate ! needed by wbuf recovery code ! avoid going above TL2 fill_64bit_rtt(ASI_N) @@ -1161,7 +1156,7 @@ ! set %tstate to the correct %cwp ! rdpr %cwp, %g1 - wrpr %g1, %g7, %tstate + wrpr %g1, %g6, %tstate retry END(krtt) END(ktl0) @@ -1214,13 +1209,13 @@ ! %l7 trapframe ENTRY(tl0_trap) - MAGIC_TRAP_OFF /* if we're at tl2 we have some extra work to do */ rdpr %tl, %g5 cmp %g5, 2 be,pn %xcc, tl1_trap nop + MAGIC_TRAP_OFF rdpr %tstate, %g5 btst TSTATE_PRIV, %g5 and %g5, TSTATE_CWP_MASK, %g6 @@ -1253,7 +1248,7 @@ mov MMU_CID_P, %l1 sethi %hi(FLUSH_ADDR), %l2 SET_MMU_CONTEXT(%l1, %l0) - flush %l2 ! flush / membar required by immu for + flush %l2 ! flush/membar required by immu for ! consistency guarantee set utl0, %g6 win_saved: @@ -1575,18 +1570,6 @@ * them to the outs. */ ENTRY(fork_trampoline) -#if KTR_COMPILE & KTR_PROC - CATR(KTR_PROC, "fork_trampoline: td=%p (%s) cwp=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURTHREAD)], %g2 - stx %g2, [%g1 + KTR_PARM1] - ldx [%g2 + TD_PROC], %g2 - add %g2, P_COMM, %g2 - stx %g2, [%g1 + KTR_PARM2] - rdpr %cwp, %g2 - stx %g2, [%g1 + KTR_PARM3] -9: -#endif mov %l0, %o0 mov %l1, %o1 call fork_exit
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603210331.k2L3V289095817>