Date: Sat, 26 Feb 2011 16:57:39 +0530 From: "Jayachandran C." <c.jayachandran@gmail.com> To: freebsd-mips@freebsd.org, Juli Mallett <jmallett@freebsd.org>, Warner Losh <imp@freebsd.org> Subject: [PATCH] stack usage of pmap_activate in cpu_switch() Message-ID: <AANLkTikmw7L0bePiEQKawUwKhPqCE9qj4JXzd9-y1r44@mail.gmail.com>
index | next in thread | raw e-mail
[-- Attachment #1 --] In the cpu_switch code, pmap_activate is called with the stack of the old thread even after the thread was switched out. This seems to be the cause of a crash I see here (on XLP) under stress. Seems like a bug to me, any thoughts? The attached patch restores the SP from the new thread from its PCB before calling pmap_activate(). JC. [-- Attachment #2 --] Index: sys/mips/mips/swtch.S =================================================================== --- sys/mips/mips/swtch.S (revision 217922) +++ sys/mips/mips/swtch.S (working copy) @@ -195,11 +195,6 @@ SAVE_U_PCB_CONTEXT(ra, PREG_PC, a0) move ra, v0 /* restore 'ra' before returning */ - /* - * FREEBSD_DEVELOPERS_FIXME: - * In case there are CPU-specific registers that need - * to be saved with the other registers do so here. - */ j ra move v0, zero END(savectx) @@ -254,11 +249,6 @@ nop getpc: SAVE_U_PCB_CONTEXT(ra, PREG_PC, a0) # save return address - /* - * FREEBSD_DEVELOPERS_FIXME: - * In case there are CPU-specific registers that need - * to be saved with the other registers do so here. - */ PTR_S a2, TD_LOCK(a3) # Switchout td_lock @@ -328,13 +318,15 @@ * Now running on new u struct. */ sw2: + PTR_L s0, TD_PCB(s7) + RESTORE_U_PCB_CONTEXT(sp, PREG_SP, s0) PTR_LA t1, _C_LABEL(pmap_activate) # s7 = new proc pointer jalr t1 # s7 = new proc pointer move a0, s7 # BDSLOT /* * Restore registers and return. */ - PTR_L a0, TD_PCB(s7) + move a0, s0 RESTORE_U_PCB_CONTEXT(gp, PREG_GP, a0) RESTORE_U_PCB_CONTEXT(v0, PREG_SR, a0) # restore kernel context RESTORE_U_PCB_CONTEXT(ra, PREG_RA, a0) @@ -346,13 +338,8 @@ RESTORE_U_PCB_CONTEXT(s5, PREG_S5, a0) RESTORE_U_PCB_CONTEXT(s6, PREG_S6, a0) RESTORE_U_PCB_CONTEXT(s7, PREG_S7, a0) - RESTORE_U_PCB_CONTEXT(sp, PREG_SP, a0) RESTORE_U_PCB_CONTEXT(s8, PREG_S8, a0) - /* - * FREEBSD_DEVELOPERS_FIXME: - * In case there are CPU-specific registers that need - * to be restored with the other registers do so here. - */ + mfc0 t0, MIPS_COP_0_STATUS and t0, t0, MIPS_SR_INT_MASK and v0, v0, ~MIPS_SR_INT_MASKhelp
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikmw7L0bePiEQKawUwKhPqCE9qj4JXzd9-y1r44>
