From 745f41f7e7aabfa196f320ebfee60b398cd253bc Mon Sep 17 00:00:00 2001 From: uwe Date: Tue, 1 Feb 2011 01:54:14 +0000 Subject: [PATCH] cpu_setfunc() must use lwp_trampoline to arrange for the recycled lwp to go through lwp_startup() the first time it's switched to. This makes NetBSD-4.x SA binaries work on current. Tested with dig(1) in NetBSD-4.x chroot on landisk. Looks like this mistake of mine was picked up and replicated in several other ports, sorry. Reported by chuck@ in PR kern/44500 --- sys/arch/sh3/sh3/locore_subr.S | 5 ++--- sys/arch/sh3/sh3/vm_machdep.c | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sys/arch/sh3/sh3/locore_subr.S b/sys/arch/sh3/sh3/locore_subr.S index 335b2d97bb5a..f0d4cbb1fc12 100644 --- a/sys/arch/sh3/sh3/locore_subr.S +++ b/sys/arch/sh3/sh3/locore_subr.S @@ -1,4 +1,4 @@ -/* $NetBSD: locore_subr.S,v 1.53 2010/03/20 23:31:30 chs Exp $ */ +/* $NetBSD: locore_subr.S,v 1.54 2011/02/01 01:54:14 uwe Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #include #include -__KERNEL_RCSID(0, "$NetBSD: locore_subr.S,v 1.53 2010/03/20 23:31:30 chs Exp $") +__KERNEL_RCSID(0, "$NetBSD: locore_subr.S,v 1.54 2011/02/01 01:54:14 uwe Exp $") /* @@ -388,7 +388,6 @@ NENTRY(lwp_trampoline) mov r0, r4 /* previous lwp returned by cpu_switchto */ jsr @r1 mov r10, r5 /* my struct lwp */ -ALTENTRY(lwp_setfunc_trampoline) jsr @r12 mov r11, r4 __EXCEPTION_RETURN diff --git a/sys/arch/sh3/sh3/vm_machdep.c b/sys/arch/sh3/sh3/vm_machdep.c index 043f18d32b0c..f40917301ae9 100644 --- a/sys/arch/sh3/sh3/vm_machdep.c +++ b/sys/arch/sh3/sh3/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.69 2011/01/14 02:06:31 rmind Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.70 2011/02/01 01:54:14 uwe Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.69 2011/01/14 02:06:31 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.70 2011/02/01 01:54:14 uwe Exp $"); #include "opt_kstack_debug.h" @@ -107,7 +107,6 @@ __KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.69 2011/01/14 02:06:31 rmind Exp $" #include extern void lwp_trampoline(void); -extern void lwp_setfunc_trampoline(void); static void sh3_setup_uarea(struct lwp *); @@ -176,7 +175,8 @@ cpu_setfunc(struct lwp *l, void (*func)(void *), void *arg) l->l_md.md_regs->tf_ssr = PSL_USERSET; /* When lwp is switched to, jump to the trampoline */ - sf->sf_pr = (int)lwp_setfunc_trampoline; + sf->sf_pr = (int)lwp_trampoline; + sf->sf_r10 = (int)l; /* "new" lwp for lwp_startup() */ sf->sf_r11 = (int)arg; /* hook function/argument */ sf->sf_r12 = (int)func; }