Index: sys/arch/sparc64/sparc64/locore.s =================================================================== RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/locore.s,v retrieving revision 1.376 diff -u -r1.376 locore.s --- sys/arch/sparc64/sparc64/locore.s 24 Oct 2014 15:51:16 -0000 1.376 +++ sys/arch/sparc64/sparc64/locore.s 26 Oct 2014 18:11:50 -0000 @@ -355,6 +355,83 @@ #define CLRTT #endif + /* handle clean window trap when trap level = 0 */ + .macro CLEANWIN0 + rdpr %cleanwin, %o7 + inc %o7 ! This handler is in-lined and cannot fault +#ifdef DEBUG + set 0xbadcafe, %l0 ! DEBUG -- compiler should not rely on zero-ed registers. +#else + clr %l0 +#endif + wrpr %g0, %o7, %cleanwin ! Nucleus (trap&IRQ) code does not need clean windows + + mov %l0,%l1; mov %l0,%l2 ! Clear out %l0-%l8 and %o0-%o8 and inc %cleanwin and done + mov %l0,%l3; mov %l0,%l4 +#if 0 +#ifdef DIAGNOSTIC + !! + !! Check the sp redzone + !! + !! Since we can't spill the current window, we'll just keep + !! track of the frame pointer. Problems occur when the routine + !! allocates and uses stack storage. + !! +! rdpr %wstate, %l5 ! User stack? +! cmp %l5, WSTATE_KERN +! bne,pt %icc, 7f + sethi %hi(CPCB), %l5 + LDPTR [%l5 + %lo(CPCB)], %l5 ! If pcb < fp < pcb+sizeof(pcb) + inc PCB_SIZE, %l5 ! then we have a stack overflow + btst %fp, 1 ! 64-bit stack? + sub %fp, %l5, %l7 + bnz,a,pt %icc, 1f + inc BIAS, %l7 ! Remove BIAS +1: + cmp %l7, PCB_SIZE + blu %xcc, cleanwin_overflow +#endif +#endif + mov %l0, %l5 + mov %l0, %l6; mov %l0, %l7; mov %l0, %o0; mov %l0, %o1 + + mov %l0, %o2; mov %l0, %o3; mov %l0, %o4; mov %l0, %o5; + mov %l0, %o6; mov %l0, %o7 + CLRTT + retry; nop; NOTREACHED; TA32 + .endm + + /* handle clean window trap when trap level = 1 */ + .macro CLEANWIN1 + clr %l0 +#ifdef DEBUG + set 0xbadbeef, %l0 ! DEBUG +#endif + mov %l0, %l1; mov %l0, %l2 + rdpr %cleanwin, %o7 ! This handler is in-lined and cannot fault + inc %o7; mov %l0, %l3 ! Nucleus (trap&IRQ) code does not need clean windows + wrpr %g0, %o7, %cleanwin ! Clear out %l0-%l8 and %o0-%o8 and inc %cleanwin and done +#ifdef NOT_DEBUG + !! + !! Check the sp redzone + !! + rdpr %wstate, t1 + cmp t1, WSTATE_KERN + bne,pt icc, 7f + sethi %hi(_C_LABEL(redzone)), t1 + ldx [t1 + %lo(_C_LABEL(redzone))], t2 + cmp %sp, t2 ! if sp >= t2, not in red zone + blu panic_red ! and can continue normally +7: +#endif + mov %l0, %l4; mov %l0, %l5; mov %l0, %l6; mov %l0, %l7 + mov %l0, %o0; mov %l0, %o1; mov %l0, %o2; mov %l0, %o3 + + mov %l0, %o4; mov %l0, %o5; mov %l0, %o6; mov %l0, %o7 + CLRTT + retry; nop; TA32 + .endm + /* * Here are some oft repeated traps as macros. */ @@ -492,7 +569,7 @@ srl %sp, 0, %sp; /* fixup 32-bit pointers */ \ NOTREACHED; \ TA32 - + .globl start, _C_LABEL(kernel_text) _C_LABEL(kernel_text) = kernel_start ! for kvm_mkdb(8) kernel_start: @@ -527,48 +604,7 @@ TRAP(T_FP_IEEE_754) ! 021 = ieee 754 exception TRAP(T_FP_OTHER) ! 022 = other fp exception TRAP(T_TAGOF) ! 023 = tag overflow - rdpr %cleanwin, %o7 ! 024-027 = clean window trap - inc %o7 ! This handler is in-lined and cannot fault -#ifdef DEBUG - set 0xbadcafe, %l0 ! DEBUG -- compiler should not rely on zero-ed registers. -#else - clr %l0 -#endif - wrpr %g0, %o7, %cleanwin ! Nucleus (trap&IRQ) code does not need clean windows - - mov %l0,%l1; mov %l0,%l2 ! Clear out %l0-%l8 and %o0-%o8 and inc %cleanwin and done - mov %l0,%l3; mov %l0,%l4 -#if 0 -#ifdef DIAGNOSTIC - !! - !! Check the sp redzone - !! - !! Since we can't spill the current window, we'll just keep - !! track of the frame pointer. Problems occur when the routine - !! allocates and uses stack storage. - !! -! rdpr %wstate, %l5 ! User stack? -! cmp %l5, WSTATE_KERN -! bne,pt %icc, 7f - sethi %hi(CPCB), %l5 - LDPTR [%l5 + %lo(CPCB)], %l5 ! If pcb < fp < pcb+sizeof(pcb) - inc PCB_SIZE, %l5 ! then we have a stack overflow - btst %fp, 1 ! 64-bit stack? - sub %fp, %l5, %l7 - bnz,a,pt %icc, 1f - inc BIAS, %l7 ! Remove BIAS -1: - cmp %l7, PCB_SIZE - blu %xcc, cleanwin_overflow -#endif -#endif - mov %l0, %l5 - mov %l0, %l6; mov %l0, %l7; mov %l0, %o0; mov %l0, %o1 - - mov %l0, %o2; mov %l0, %o3; mov %l0, %o4; mov %l0, %o5; - mov %l0, %o6; mov %l0, %o7 - CLRTT - retry; nop; NOTREACHED; TA32 + CLEANWIN0 ! 024-027 = clean window trap TRAP(T_DIV0) ! 028 = divide by zero UTRAP(0x029) ! 029 = internal processor error UTRAP(0x02a); UTRAP(0x02b); UTRAP(0x02c); UTRAP(0x02d); UTRAP(0x02e); UTRAP(0x02f) @@ -777,33 +813,7 @@ TRAP(T_FP_IEEE_754) ! 021 = ieee 754 exception TRAP(T_FP_OTHER) ! 022 = other fp exception TRAP(T_TAGOF) ! 023 = tag overflow - clr %l0 -#ifdef DEBUG - set 0xbadbeef, %l0 ! DEBUG -#endif - mov %l0, %l1; mov %l0, %l2 ! 024-027 = clean window trap - rdpr %cleanwin, %o7 ! This handler is in-lined and cannot fault - inc %o7; mov %l0, %l3 ! Nucleus (trap&IRQ) code does not need clean windows - wrpr %g0, %o7, %cleanwin ! Clear out %l0-%l8 and %o0-%o8 and inc %cleanwin and done -#ifdef NOT_DEBUG - !! - !! Check the sp redzone - !! - rdpr %wstate, t1 - cmp t1, WSTATE_KERN - bne,pt icc, 7f - sethi %hi(_C_LABEL(redzone)), t1 - ldx [t1 + %lo(_C_LABEL(redzone))], t2 - cmp %sp, t2 ! if sp >= t2, not in red zone - blu panic_red ! and can continue normally -7: -#endif - mov %l0, %l4; mov %l0, %l5; mov %l0, %l6; mov %l0, %l7 - mov %l0, %o0; mov %l0, %o1; mov %l0, %o2; mov %l0, %o3 - - mov %l0, %o4; mov %l0, %o5; mov %l0, %o6; mov %l0, %o7 - CLRTT - retry; nop; TA32 + CLEANWIN1 ! 024-027 = clean window trap TRAP(T_DIV0) ! 028 = divide by zero UTRAP(0x029) ! 029 = internal processor error UTRAP(0x02a); UTRAP(0x02b); UTRAP(0x02c); UTRAP(0x02d); UTRAP(0x02e); UTRAP(0x02f) @@ -1010,7 +1020,9 @@ ! ! trap level 0 ! - sun4v_trap_entry 49 ! 0x000-0x030 + sun4v_trap_entry 36 ! 0x000-0x023 + CLEANWIN0 ! 0x24-0x27 = clean window + sun4v_trap_entry 9 ! 0x028-0x030 VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss) ! 0x031 = data MMU miss sun4v_trap_entry 15 ! 0x032-0x040 HARDINT4V(1) ! 0x041 = level 1 interrupt @@ -1065,7 +1077,9 @@ ! ! trap level 1 ! - sun4v_trap_entry_fail 49 ! 0x000-0x030 + sun4v_trap_entry 36 ! 0x000-0x023 + CLEANWIN1 ! 0x24-0x27 = clean window + sun4v_trap_entry 9 ! 0x028-0x030 VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss) ! 0x031 = data MMU miss sun4v_trap_entry_fail 78 ! 0x032-0x07f SPILL64(uspill8_sun4vt1,ASI_AIUS) ! 0x080 spill_0_normal -- save user windows