Module Name: src Committed By: martin Date: Wed Jan 23 21:03:25 UTC 2013
Modified Files: src/sys/arch/sparc64/sparc64: locore.s mp_subr.S Log Message: Fix sparc64_ipi_ccall by adding proper trap setup. Fixes xcall(9) problems, as exposed by pserialize(9). Noticed by J. Hannken-Illjes, cause pointed out by Takeshi Nakayama. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/sys/arch/sparc64/sparc64/locore.s cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/mp_subr.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.346 src/sys/arch/sparc64/sparc64/locore.s:1.347 --- src/sys/arch/sparc64/sparc64/locore.s:1.346 Wed Jan 23 12:19:02 2013 +++ src/sys/arch/sparc64/sparc64/locore.s Wed Jan 23 21:03:25 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.346 2013/01/23 12:19:02 martin Exp $ */ +/* $NetBSD: locore.s,v 1.347 2013/01/23 21:03:25 martin Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -6283,6 +6283,67 @@ ENTRY(OF_val2sym32) #endif /* _LP64 */ #endif /* DDB */ + +#if defined(MULTIPROCESSOR) +/* + * IPI target function to setup a C compatible environment and call a MI function. + * + * On entry: + * We are on one of the alternate set of globals + * %g2 = function to call + * %g3 = single argument to called function + */ +ENTRY(sparc64_ipi_ccall) +#ifdef TRAPS_USE_IG + wrpr %g0, PSTATE_KERN|PSTATE_IG, %pstate ! DEBUG +#endif + TRAP_SETUP(-CC64FSZ-TF_SIZE) + +#ifdef DEBUG + rdpr %tt, %o1 ! debug + sth %o1, [%sp + CC64FSZ + STKB + TF_TT]! debug +#endif + mov %g3, %o0 ! save argument of function to call + mov %g2, %o5 ! save function pointer + + wrpr %g0, PSTATE_KERN, %pstate ! Get back to normal globals + stx %g1, [%sp + CC64FSZ + STKB + TF_G + ( 1*8)] + mov %g1, %o1 ! code + rdpr %tpc, %o2 ! (pc) + stx %g2, [%sp + CC64FSZ + STKB + TF_G + ( 2*8)] + rdpr %tstate, %g1 + stx %g3, [%sp + CC64FSZ + STKB + TF_G + ( 3*8)] + rdpr %tnpc, %o3 + stx %g4, [%sp + CC64FSZ + STKB + TF_G + ( 4*8)] + rd %y, %o4 + stx %g5, [%sp + CC64FSZ + STKB + TF_G + ( 5*8)] + stx %g6, [%sp + CC64FSZ + STKB + TF_G + ( 6*8)] + wrpr %g0, 0, %tl ! return to tl=0 + stx %g7, [%sp + CC64FSZ + STKB + TF_G + ( 7*8)] + + stx %g1, [%sp + CC64FSZ + STKB + TF_TSTATE] + stx %o2, [%sp + CC64FSZ + STKB + TF_PC] + stx %o3, [%sp + CC64FSZ + STKB + TF_NPC] + st %o4, [%sp + CC64FSZ + STKB + TF_Y] + + rdpr %pil, %g5 + stb %g5, [%sp + CC64FSZ + STKB + TF_PIL] + stb %g5, [%sp + CC64FSZ + STKB + TF_OLDPIL] + + !! In the EMBEDANY memory model %g4 points to the start of the data segment. + !! In our case we need to clear it before calling any C-code + clr %g4 + wr %g0, ASI_NUCLEUS, %asi ! default kernel ASI + + call %o5 ! call function + nop + + ba,a return_from_trap ! and return from IPI + nop + +#endif + + .data _ALIGN #if NKSYMS || defined(DDB) || defined(LKM) Index: src/sys/arch/sparc64/sparc64/mp_subr.S diff -u src/sys/arch/sparc64/sparc64/mp_subr.S:1.3 src/sys/arch/sparc64/sparc64/mp_subr.S:1.4 --- src/sys/arch/sparc64/sparc64/mp_subr.S:1.3 Tue Jul 12 07:51:34 2011 +++ src/sys/arch/sparc64/sparc64/mp_subr.S Wed Jan 23 21:03:25 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: mp_subr.S,v 1.3 2011/07/12 07:51:34 mrg Exp $ */ +/* $NetBSD: mp_subr.S,v 1.4 2013/01/23 21:03:25 martin Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -410,22 +410,4 @@ ENTRY(sparc64_ipi_dcache_flush_page_us) ba,a ret_from_intr_vector nop -/* - * Setup a C compatible environment and call a MI function. - * - * On entry: - * %g2 = function to call - * %g3 = single argument to called function - */ -ENTRY(sparc64_ipi_ccall) - save %sp, -CC64FSZ-16, %sp ! create a stack frame - stx %g2, [%fp + BIAS -16 + 0] ! save function pointer - stx %g3, [%fp + BIAS -16 + 8] ! and argument - wrpr %g0, PSTATE_KERN, %pstate ! switch globals - ldx [%fp + BIAS -16 + 0], %l0 ! reload function - call %l0 ! call function - ldx [%fp + BIAS -16 + 8], %o0 ! reload argument - restore ! pop stack frame - ba,a ret_from_intr_vector ! and return from IPI - nop #endif