From owner-freebsd-alpha Fri Jan 4 7:19:33 2002 Delivered-To: freebsd-alpha@freebsd.org Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by hub.freebsd.org (Postfix) with ESMTP id DB84637B405 for ; Fri, 4 Jan 2002 07:19:25 -0800 (PST) Received: (from uucp@localhost) by srv1.cosmo-project.de (8.11.6/8.11.6) with UUCP id g04FJLc57723; Fri, 4 Jan 2002 16:19:21 +0100 (CET) (envelope-from ticso@cicely8.cicely.de) Received: from mail.cicely.de (cicely20.cicely.de [10.1.1.22]) by cicely5.cicely.de (8.12.1/8.12.1) with ESMTP id g04FJDtx058955; Fri, 4 Jan 2002 16:19:13 +0100 (CET)?g (envelope-from ticso@cicely8.cicely.de) Received: from cicely8.cicely.de (cicely8.cicely.de [10.1.2.10]) by mail.cicely.de (8.11.0/8.11.0) with ESMTP id g04FJDW15939; Fri, 4 Jan 2002 16:19:13 +0100 (CET) Received: (from ticso@localhost) by cicely8.cicely.de (8.11.6/8.11.6) id g04FJCG09181; Fri, 4 Jan 2002 16:19:12 +0100 (CET) (envelope-from ticso) Date: Fri, 4 Jan 2002 16:19:12 +0100 From: Bernd Walter To: Daniel Eischen Cc: alpha@FreeBSD.org Subject: Re: {get,set,make,swap}context for alpha Message-ID: <20020104161911.B8703@cicely8.cicely.de> References: <20020104143622.A8703@cicely8.cicely.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.23i X-Operating-System: FreeBSD cicely8.cicely.de 5.0-CURRENT i386 Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Fri, Jan 04, 2002 at 09:14:58AM -0500, Daniel Eischen wrote: > On Fri, 4 Jan 2002, Bernd Walter wrote: > > On Thu, Jan 03, 2002 at 04:05:25PM -0500, Daniel Eischen wrote: > > > I've got *context implemented and working for i386, but need some > > > help getting them to work on the alpha. Anyone here care to give > > > it a try? You can get them from: > > > > > > http://people.freebsd.org/~deischen/ucontext/uc-libc-sys.diffs > > > http://people.freebsd.org/~deischen/ucontext/uc-i386-standalone.tgz > > > http://people.freebsd.org/~deischen/ucontext/uc-alpha-standalone.tgz > > [...] > > > One problem I found is that you defined getcontext to be a LEAF > > function, but actually call others. > > Hmm, lib/libc/alpha/gen/setjmp.S does the same thing and also > makes a call to sigprocmask. I see that it does save and restore > ra though. Yes - you can make this working as long as you take care to make it looks like a LEAF function. It was just my first guess. > So I guess I should use NESTED, or make sure I save and restore ra > and any S register I use? saving s* and ra is expected by every caller anyway. You are calling _sigprocmask yourself and expect it to return with the old s0 value. > It seems weird that ra needs to be restored in order for a branch > instruction to work properly... Actually it's needed to return getcontext. What happens is that getcontext tries to return and falls back to after the call to __sigprocmask because ra says we was called from there. restoring ra and s0 gets getcontext working: Send a few SIGUSR1's to pid 64935 Main: setting context to myself. Main: returned from setcontext. Segmentation fault (core dumped) Exit 139 --- setcontext.S.orig Fri Jan 4 16:12:48 2002 +++ setcontext.S Fri Jan 4 16:12:28 2002 @@ -314,6 +314,8 @@ ldiq a0, 3 /* how: SIG_SETMASK */ CALL(_sigprocmask) /* see what's blocked */ mov s0, a0 /* restore ptr to ucontext */ + ldq s0, ((FRAME_S0 + 3) * 8)(a0) /* restore s0 */ + ldq ra, ((FRAME_RA + 3) * 8)(a0) /* restore ra */ beq v0, Lgc2 /* check for error */ ldiq v0, -1 /* return -1 */ br Lgcend I'm now looking into setcontext function where something similar needs to be done. -- B.Walter COSMO-Project http://www.cosmo-project.de ticso@cicely.de Usergroup info@cosmo-project.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message