From owner-cvs-src@FreeBSD.ORG Tue Apr 1 17:19:19 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DCB5937B401; Tue, 1 Apr 2003 17:19:18 -0800 (PST) Received: from k6.locore.ca (k6.locore.ca [198.96.117.170]) by mx1.FreeBSD.org (Postfix) with ESMTP id A253743F75; Tue, 1 Apr 2003 17:19:16 -0800 (PST) (envelope-from jake@k6.locore.ca) Received: from k6.locore.ca (localhost.locore.ca [127.0.0.1]) by k6.locore.ca (8.12.8/8.12.8) with ESMTP id h321PsxS044993; Tue, 1 Apr 2003 20:25:54 -0500 (EST) (envelope-from jake@k6.locore.ca) Received: (from jake@localhost) by k6.locore.ca (8.12.8/8.12.8/Submit) id h321Pr8e044992; Tue, 1 Apr 2003 20:25:53 -0500 (EST) Date: Tue, 1 Apr 2003 20:25:53 -0500 From: Jake Burkholder To: Daniel Eischen Message-ID: <20030402012553.GB44206@locore.ca> References: <20030402004854.GA44206@locore.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_context.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Apr 2003 01:19:19 -0000 Apparently, On Tue, Apr 01, 2003 at 08:00:18PM -0500, Daniel Eischen said words to the effect of; > On Tue, 1 Apr 2003, Jake Burkholder wrote: > > > Apparently, On Tue, Apr 01, 2003 at 06:42:30PM -0500, > > Daniel Eischen said words to the effect of; > > > > > On Tue, 1 Apr 2003, Jake Burkholder wrote: > > > > > > > jake 2003/04/01 15:25:18 PST > > > > > > > > FreeBSD src repository > > > > > > > > Modified files: > > > > sys/kern kern_context.c > > > > Log: > > > > - Fix UC_COPY_SIZE. Adding up the size of structure fields doesn't take > > > > alignment into account. > > > > - Return EJUSTRETURN from set_context on success to avoid clobbering the > > > > first 2 out registers with td_retval on sparc64. > > > > > > Oh shit. I forgot I have some local changes lying around > > > to fix being able to set/swapcontext on an interrupted > > > context (not formed by getcontext). When getcontext() > > > is called, the return value registers need to be cleared > > > so that 0 is returned after a subsequent setcontext(): > > > > > > ret = getcontext(&uc); > > > ... > > > setcontext(&uc); > > > > > > The above should work as well as: > > > > > > void > > > sighandler(int sig, siginfo_t *info, ucontext_t *ucp) > > > { > > > ... > > > setcontext(ucp); > > > } > > > > > > The latter case doesn't want to return 0 in the syscall; > > > it wants to return EJUSTRETURN. In the former case, you > > > need to be able to return 0. > > > > > > I think you need to fix get_mcontext() so that it clears > > > the return values or it breaks the first case. > > > > > > My changes add a third parameter to > > > get_mcontext(struct thread *td, mcontext_t *mcp, int clear_retval) > > > so that you can tell it to clear the return values. > > > When getcontext() calls get_mcontext() you want to clear > > > the return values in the context, but when get_mcontext() > > > is called by sendsig() or by the KSE system, you don't > > > want to clear the return values. > > > > > > Is this making any sense? > > > > Yes, I see what you mean. The problem on sparc64 is that the arguments > > setup in makecontext get clobbered. They're passed in the same registers > > as the return value for the system call, so when syscall copies td_retval > > into the registers it clobbers the arguments that were set. I can hack > > around it by just copying the registers that would be clobbered into > > td_retval if that would work better. execve has the same problem, we > > use the above hack there. > > I think the changes you made are correct; swapcontext() and > setcontext() now return EJUSTRETURN if there were no errors. > But we just need to fix getcontext() so that it clears the > return value registers in the mcontext. This needs to be > an option, though, because other uses of get_mcontext don't > want that behaviour. > > This would still work on sparc64, right? Unless I am > misunderstanding something. I see. Yes that would work fine. Jake