diff --git a/sys/mips/mips/exception.S b/sys/mips/mips/exception.S index 7cc4059fcd0c..3be0d4b2059e 100644 --- a/sys/mips/mips/exception.S +++ b/sys/mips/mips/exception.S @@ -426,6 +426,12 @@ NNON_LEAF(MipsUserGenException, CALLFRAME_SIZ, ra) /* * Save all of the registers except for the kernel temporaries in u.u_pcb. */ + mfc0 k0, MIPS_COP_0_STATUS + HAZARD_DELAY +#ifdef __mips_n64 + ori k1, k0, MIPS_SR_KX + mtc0 k1, MIPS_COP_0_STATUS +#endif GET_CPU_PCPU(k1) PTR_L k1, PC_CURPCB(k1) SAVE_U_PCB_REG(AT, AST, k1) @@ -443,7 +449,7 @@ NNON_LEAF(MipsUserGenException, CALLFRAME_SIZ, ra) SAVE_U_PCB_REG(t2, T2, k1) SAVE_U_PCB_REG(t3, T3, k1) SAVE_U_PCB_REG(ta0, TA0, k1) - mfc0 a0, MIPS_COP_0_STATUS # First arg is the status reg. + move a0, k0 # First arg is the status reg. SAVE_U_PCB_REG(ta1, TA1, k1) SAVE_U_PCB_REG(ta2, TA2, k1) SAVE_U_PCB_REG(ta3, TA3, k1) @@ -642,6 +648,12 @@ NNON_LEAF(MipsUserIntr, CALLFRAME_SIZ, ra) * Save the relevant user registers into the u.u_pcb struct. * We don't need to save s0 - s8 because the compiler does it for us. */ + mfc0 k0, MIPS_COP_0_STATUS + HAZARD_DELAY +#ifdef __mips_n64 + ori k1, k0, MIPS_SR_KX + mtc0 k1, MIPS_COP_0_STATUS +#endif GET_CPU_PCPU(k1) PTR_L k1, PC_CURPCB(k1) SAVE_U_PCB_REG(AT, AST, k1) @@ -680,7 +692,7 @@ NNON_LEAF(MipsUserIntr, CALLFRAME_SIZ, ra) mflo v0 # get lo/hi late to avoid stall mfhi v1 - mfc0 a0, MIPS_COP_0_STATUS + move a0, k0 mfc0 a1, MIPS_COP_0_CAUSE MFC0 a3, MIPS_COP_0_EXC_PC SAVE_U_PCB_REG(v0, MULLO, k1) diff --git a/sys/mips/mips/genassym.c b/sys/mips/mips/genassym.c index 53f962b69f31..8a5cbf33d3da 100644 --- a/sys/mips/mips/genassym.c +++ b/sys/mips/mips/genassym.c @@ -103,3 +103,4 @@ ASSYM(MAXCOMLEN, MAXCOMLEN); ASSYM(MIPS_KSEG0_START, MIPS_KSEG0_START); ASSYM(MIPS_KSEG1_START, MIPS_KSEG1_START); ASSYM(MIPS_KSEG2_START, MIPS_KSEG2_START); +ASSYM(MIPS_XKSEG_START, MIPS_XKSEG_START); diff --git a/sys/mips/mips/swtch.S b/sys/mips/mips/swtch.S index b6412dbf3933..9e1f39d8d89e 100644 --- a/sys/mips/mips/swtch.S +++ b/sys/mips/mips/swtch.S @@ -278,10 +278,12 @@ blocked_loop: PTR_L a2, TD_PCB(a1) PTR_S a2, PC_CURPCB(a3) PTR_L v0, TD_KSTACK(a1) -#if !defined(__mips_n64) +#if defined(__mips_n64) + PTR_LI s0, MIPS_XKSEG_START +#else PTR_LI s0, MIPS_KSEG2_START # If Uarea addr is below kseg2, - bltu v0, s0, sw2 # no need to insert in TLB. #endif + bltu v0, s0, sw2 # no need to insert in TLB. lw a1, TD_UPTE + 0(s7) # a1 = u. pte #0 lw a2, TD_UPTE + 4(s7) # a2 = u. pte #1 /*