Wed Jan 23 21:03:25 2013 UTC ()
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.


(martin)
diff -r1.346 -r1.347 src/sys/arch/sparc64/sparc64/locore.s
diff -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/mp_subr.S

cvs diff -r1.346 -r1.347 src/sys/arch/sparc64/sparc64/locore.s (expand / switch to unified diff)

--- src/sys/arch/sparc64/sparc64/locore.s 2013/01/23 12:19:02 1.346
+++ src/sys/arch/sparc64/sparc64/locore.s 2013/01/23 21:03:25 1.347
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore.s,v 1.346 2013/01/23 12:19:02 martin Exp $ */ 1/* $NetBSD: locore.s,v 1.347 2013/01/23 21:03:25 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006-2010 Matthew R. Green 4 * Copyright (c) 2006-2010 Matthew R. Green
5 * Copyright (c) 1996-2002 Eduardo Horvath 5 * Copyright (c) 1996-2002 Eduardo Horvath
6 * Copyright (c) 1996 Paul Kranenburg 6 * Copyright (c) 1996 Paul Kranenburg
7 * Copyright (c) 1996 7 * Copyright (c) 1996
8 * The President and Fellows of Harvard College. 8 * The President and Fellows of Harvard College.
9 * All rights reserved. 9 * All rights reserved.
10 * Copyright (c) 1992, 1993 10 * Copyright (c) 1992, 1993
11 * The Regents of the University of California. 11 * The Regents of the University of California.
12 * All rights reserved. 12 * All rights reserved.
13 * 13 *
14 * This software was developed by the Computer Systems Engineering group 14 * This software was developed by the Computer Systems Engineering group
@@ -6273,26 +6273,87 @@ ENTRY(OF_val2sym32) @@ -6273,26 +6273,87 @@ ENTRY(OF_val2sym32)
6273 btst 7, %i0 6273 btst 7, %i0
6274 bnz,pn %icc, 1f 6274 bnz,pn %icc, 1f
6275 add %sp, BIAS, %o1 6275 add %sp, BIAS, %o1
6276 btst 1, %sp 6276 btst 1, %sp
6277 movnz %icc, %o1, %sp 6277 movnz %icc, %o1, %sp
6278 call _C_LABEL(OF_val2sym) 6278 call _C_LABEL(OF_val2sym)
6279 mov %i0, %o0 6279 mov %i0, %o0
62801: 62801:
6281 ret 6281 ret
6282 restore %o0, 0, %o0 6282 restore %o0, 0, %o0
6283#endif /* _LP64 */ 6283#endif /* _LP64 */
6284#endif /* DDB */ 6284#endif /* DDB */
6285 6285
 6286
 6287#if defined(MULTIPROCESSOR)
 6288/*
 6289 * IPI target function to setup a C compatible environment and call a MI function.
 6290 *
 6291 * On entry:
 6292 * We are on one of the alternate set of globals
 6293 * %g2 = function to call
 6294 * %g3 = single argument to called function
 6295 */
 6296ENTRY(sparc64_ipi_ccall)
 6297#ifdef TRAPS_USE_IG
 6298 wrpr %g0, PSTATE_KERN|PSTATE_IG, %pstate ! DEBUG
 6299#endif
 6300 TRAP_SETUP(-CC64FSZ-TF_SIZE)
 6301
 6302#ifdef DEBUG
 6303 rdpr %tt, %o1 ! debug
 6304 sth %o1, [%sp + CC64FSZ + STKB + TF_TT]! debug
 6305#endif
 6306 mov %g3, %o0 ! save argument of function to call
 6307 mov %g2, %o5 ! save function pointer
 6308
 6309 wrpr %g0, PSTATE_KERN, %pstate ! Get back to normal globals
 6310 stx %g1, [%sp + CC64FSZ + STKB + TF_G + ( 1*8)]
 6311 mov %g1, %o1 ! code
 6312 rdpr %tpc, %o2 ! (pc)
 6313 stx %g2, [%sp + CC64FSZ + STKB + TF_G + ( 2*8)]
 6314 rdpr %tstate, %g1
 6315 stx %g3, [%sp + CC64FSZ + STKB + TF_G + ( 3*8)]
 6316 rdpr %tnpc, %o3
 6317 stx %g4, [%sp + CC64FSZ + STKB + TF_G + ( 4*8)]
 6318 rd %y, %o4
 6319 stx %g5, [%sp + CC64FSZ + STKB + TF_G + ( 5*8)]
 6320 stx %g6, [%sp + CC64FSZ + STKB + TF_G + ( 6*8)]
 6321 wrpr %g0, 0, %tl ! return to tl=0
 6322 stx %g7, [%sp + CC64FSZ + STKB + TF_G + ( 7*8)]
 6323
 6324 stx %g1, [%sp + CC64FSZ + STKB + TF_TSTATE]
 6325 stx %o2, [%sp + CC64FSZ + STKB + TF_PC]
 6326 stx %o3, [%sp + CC64FSZ + STKB + TF_NPC]
 6327 st %o4, [%sp + CC64FSZ + STKB + TF_Y]
 6328
 6329 rdpr %pil, %g5
 6330 stb %g5, [%sp + CC64FSZ + STKB + TF_PIL]
 6331 stb %g5, [%sp + CC64FSZ + STKB + TF_OLDPIL]
 6332
 6333 !! In the EMBEDANY memory model %g4 points to the start of the data segment.
 6334 !! In our case we need to clear it before calling any C-code
 6335 clr %g4
 6336 wr %g0, ASI_NUCLEUS, %asi ! default kernel ASI
 6337
 6338 call %o5 ! call function
 6339 nop
 6340
 6341 ba,a return_from_trap ! and return from IPI
 6342 nop
 6343
 6344#endif
 6345
 6346
6286 .data 6347 .data
6287 _ALIGN 6348 _ALIGN
6288#if NKSYMS || defined(DDB) || defined(LKM) 6349#if NKSYMS || defined(DDB) || defined(LKM)
6289 .globl _C_LABEL(esym) 6350 .globl _C_LABEL(esym)
6290_C_LABEL(esym): 6351_C_LABEL(esym):
6291 POINTER 0 6352 POINTER 0
6292 .globl _C_LABEL(ssym) 6353 .globl _C_LABEL(ssym)
6293_C_LABEL(ssym): 6354_C_LABEL(ssym):
6294 POINTER 0 6355 POINTER 0
6295#endif 6356#endif
6296 .comm _C_LABEL(promvec), PTRSZ 6357 .comm _C_LABEL(promvec), PTRSZ
6297 6358
6298#ifdef DEBUG 6359#ifdef DEBUG

cvs diff -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/mp_subr.S (expand / switch to unified diff)

--- src/sys/arch/sparc64/sparc64/mp_subr.S 2011/07/12 07:51:34 1.3
+++ src/sys/arch/sparc64/sparc64/mp_subr.S 2013/01/23 21:03:25 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mp_subr.S,v 1.3 2011/07/12 07:51:34 mrg Exp $ */ 1/* $NetBSD: mp_subr.S,v 1.4 2013/01/23 21:03:25 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006-2010 Matthew R. Green 4 * Copyright (c) 2006-2010 Matthew R. Green
5 * Copyright (c) 1996-2002 Eduardo Horvath 5 * Copyright (c) 1996-2002 Eduardo Horvath
6 * Copyright (c) 1996 Paul Kranenburg 6 * Copyright (c) 1996 Paul Kranenburg
7 * Copyright (c) 1996 7 * Copyright (c) 1996
8 * The President and Fellows of Harvard College. 8 * The President and Fellows of Harvard College.
9 * All rights reserved. 9 * All rights reserved.
10 * Copyright (c) 1992, 1993 10 * Copyright (c) 1992, 1993
11 * The Regents of the University of California. 11 * The Regents of the University of California.
12 * All rights reserved. 12 * All rights reserved.
13 * 13 *
14 * This software was developed by the Computer Systems Engineering group 14 * This software was developed by the Computer Systems Engineering group
@@ -400,32 +400,14 @@ ENTRY(sparc64_ipi_dcache_flush_page_us) @@ -400,32 +400,14 @@ ENTRY(sparc64_ipi_dcache_flush_page_us)
400 membar #LoadStore 400 membar #LoadStore
401 401
402 stxa %g0, [%g2] ASI_DCACHE_TAG 402 stxa %g0, [%g2] ASI_DCACHE_TAG
403 ba,pt %icc, 1b 403 ba,pt %icc, 1b
404 membar #StoreLoad 404 membar #StoreLoad
4052: 4052:
406 406
407 sethi %hi(KERNBASE), %g5 407 sethi %hi(KERNBASE), %g5
408 flush %g5 408 flush %g5
409 membar #Sync 409 membar #Sync
410 ba,a ret_from_intr_vector 410 ba,a ret_from_intr_vector
411 nop 411 nop
412 412
413/* 
414 * Setup a C compatible environment and call a MI function. 
415 * 
416 * On entry: 
417 * %g2 = function to call 
418 * %g3 = single argument to called function 
419 */ 
420ENTRY(sparc64_ipi_ccall) 
421 save %sp, -CC64FSZ-16, %sp ! create a stack frame 
422 stx %g2, [%fp + BIAS -16 + 0] ! save function pointer 
423 stx %g3, [%fp + BIAS -16 + 8] ! and argument 
424 wrpr %g0, PSTATE_KERN, %pstate ! switch globals 
425 ldx [%fp + BIAS -16 + 0], %l0 ! reload function 
426 call %l0 ! call function 
427 ldx [%fp + BIAS -16 + 8], %o0 ! reload argument  
428 restore ! pop stack frame 
429 ba,a ret_from_intr_vector ! and return from IPI 
430 nop 
431#endif 413#endif