Index: sys/systm.h =================================================================== RCS file: /cvs/src/sys/sys/systm.h,v retrieving revision 1.121 diff -u -p -r1.121 systm.h --- sys/systm.h 29 Dec 2016 12:12:44 -0000 1.121 +++ sys/systm.h 20 Jan 2017 06:01:58 -0000 @@ -332,6 +332,10 @@ void user_config(void); #endif #if defined(MULTIPROCESSOR) +struct cpu_info; +struct task; +void cpu_xcall(struct cpu_info *, struct task *); + void _kernel_lock_init(void); void _kernel_lock(void); void _kernel_unlock(void); Index: arch/sparc64/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/sparc64/conf/GENERIC,v retrieving revision 1.305 diff -u -p -r1.305 GENERIC --- arch/sparc64/conf/GENERIC 28 Jun 2016 04:41:37 -0000 1.305 +++ arch/sparc64/conf/GENERIC 20 Jan 2017 06:01:58 -0000 @@ -28,6 +28,8 @@ option WSDISPLAY_COMPAT_RAWKBD # provid config bsd swap generic +makeoption DEBUG="-g" + # Main bus and CPU .. all systems. mainbus0 at root cpu0 at mainbus0 Index: arch/sparc64/conf/ld.script =================================================================== RCS file: /cvs/src/sys/arch/sparc64/conf/ld.script,v retrieving revision 1.10 diff -u -p -r1.10 ld.script --- arch/sparc64/conf/ld.script 4 Sep 2016 08:33:50 -0000 1.10 +++ arch/sparc64/conf/ld.script 20 Jan 2017 06:01:58 -0000 @@ -44,7 +44,7 @@ SECTIONS { *(.openbsd.randomdata) } :text :openbsd_randomize - . = 0x01800000; + . = 0x02000000; .data : { *(.data) Index: arch/sparc64/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/sparc64/include/cpu.h,v retrieving revision 1.89 diff -u -p -r1.89 cpu.h --- arch/sparc64/include/cpu.h 17 Aug 2016 11:09:01 -0000 1.89 +++ arch/sparc64/include/cpu.h 20 Jan 2017 06:01:58 -0000 @@ -78,6 +78,7 @@ #include #include +#include /* * The cpu_info structure is part of a 64KB structure mapped both the kernel @@ -119,6 +120,9 @@ struct cpu_info { #ifdef MULTIPROCESSOR int ci_itid; struct srp_hazard ci_srp_hazards[SRP_HAZARD_NUM]; + + struct task_list ci_xcall_list; + struct intrhand ci_xcall_intr; #endif int ci_node; u_int32_t ci_randseed; @@ -189,6 +193,7 @@ void sparc64_send_ipi(int, void (*)(void void sparc64_broadcast_ipi(void (*)(void), u_int64_t, u_int64_t); void cpu_unidle(struct cpu_info *); +int cpu_xcall_intr(void *); #else /* MULTIPROCESSOR */ Index: arch/sparc64/sparc64/cpu.c =================================================================== RCS file: /cvs/src/sys/arch/sparc64/sparc64/cpu.c,v retrieving revision 1.65 diff -u -p -r1.65 cpu.c --- arch/sparc64/sparc64/cpu.c 3 May 2016 08:30:15 -0000 1.65 +++ arch/sparc64/sparc64/cpu.c 20 Jan 2017 06:01:58 -0000 @@ -167,6 +167,11 @@ alloc_cpuinfo(struct mainbus_attach_args cpi->ci_upaid = portid; cpi->ci_fpproc = NULL; #ifdef MULTIPROCESSOR + TAILQ_INIT(&cpi->ci_xcall_list); + cpi->ci_xcall_intr.ih_fun = cpu_xcall_intr; + cpi->ci_xcall_intr.ih_pil = IPL_SOFTCLOCK; + cpi->ci_xcall_intr.ih_mpsafe = 1; + cpi->ci_spinup = cpu_hatch; /* XXX */ #else cpi->ci_spinup = NULL; Index: arch/sparc64/sparc64/ipifuncs.c =================================================================== RCS file: /cvs/src/sys/arch/sparc64/sparc64/ipifuncs.c,v retrieving revision 1.15 diff -u -p -r1.15 ipifuncs.c --- arch/sparc64/sparc64/ipifuncs.c 10 May 2014 12:29:58 -0000 1.15 +++ arch/sparc64/sparc64/ipifuncs.c 20 Jan 2017 06:01:58 -0000 @@ -58,6 +58,7 @@ void sun4u_ipi_tlb_context_demap(void); void sun4v_ipi_tlb_page_demap(void); void sun4v_ipi_tlb_context_demap(void); void ipi_softint(void); +void ipi_xcall(void); /* * Send an interprocessor interrupt. @@ -246,4 +247,56 @@ cpu_unidle(struct cpu_info *ci) sun4v_send_ipi(ci->ci_itid, ipi_softint, 1 << IPL_SOFTINT, 0); else sun4u_send_ipi(ci->ci_itid, ipi_softint, 1 << IPL_SOFTINT, 0); +} + +void +cpu_xcall(struct cpu_info *ci, struct task *t) +{ + if (ci == curcpu()) { + int s = splsoftclock(); + (*t->t_func)(t->t_arg); + splx(s); + } else { + sparc64_send_ipi(ci->ci_itid, ipi_xcall, (uint64_t)t, 0); + } +} + +/* this is what ipi_xcall should do */ +void +cpu_xcall_ipi(struct task *t) +{ + struct cpu_info *ci = curcpu(); + struct intrhand *ih = &ci->ci_xcall_intr; + u_int64_t s; + + s = intr_disable(); + TAILQ_INSERT_TAIL(&ci->ci_xcall_list, t, t_entry); + intr_restore(s); + + send_softint(-1, ih->ih_pil, ih); +} + +int +cpu_xcall_intr(void *arg) +{ + struct cpu_info *ci = arg; + struct task *list; + u_int64_t s; + int rv; + + s = intr_disable(); + list = TAILQ_FIRST(&ci->ci_xcall_list); + TAILQ_INIT(&ci->ci_xcall_list); + intr_restore(s); + + while (list != NULL) { + struct task *t = list; + list = TAILQ_NEXT(t, t_entry); + + (*t->t_func)(t->t_arg); + + rv = 1; + } + + return (rv); }