define a new LWP flag which indicates that we're in the process of

doing a context switch.  use this on sparc and sparc64 to avoid trying
to access user memory (writing the register windows back to the stack)
in this case (since it's both unnecessary and wrong).
This commit is contained in:
chs 2005-01-30 16:56:26 +00:00
parent a4dab13a3b
commit 9a3f782ac4
4 changed files with 12 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.251 2004/06/30 21:16:39 pk Exp $ */
/* $NetBSD: machdep.c,v 1.252 2005/01/30 16:56:26 chs Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.251 2004/06/30 21:16:39 pk Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.252 2005/01/30 16:56:26 chs Exp $");
#include "opt_compat_netbsd.h"
#include "opt_compat_sunos.h"
@ -871,7 +871,7 @@ cpu_getmcontext(l, mcp, flags)
* registers into the pcb; we need them in the process's memory.
*/
write_user_windows();
if (rwindow_save(l))
if ((l->l_flag & L_SA_SWITCHING) == 0 && rwindow_save(l))
sigexit(l, SIGILL);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.176 2005/01/17 07:55:18 martin Exp $ */
/* $NetBSD: machdep.c,v 1.177 2005/01/30 16:56:26 chs Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.176 2005/01/17 07:55:18 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.177 2005/01/30 16:56:26 chs Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -1896,7 +1896,7 @@ cpu_getmcontext(l, mcp, flags)
/* First ensure consistent stack state (see sendsig). */ /* XXX? */
write_user_windows();
if (rwindow_save(l))
if ((l->l_flag & L_SA_SWITCHING) == 0 && rwindow_save(l))
sigexit(l, SIGILL);
/* For now: Erase any random indicators for optional state. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sa.c,v 1.56 2005/01/06 19:26:41 mycroft Exp $ */
/* $NetBSD: kern_sa.c,v 1.57 2005/01/30 16:56:26 chs Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.56 2005/01/06 19:26:41 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.57 2005/01/30 16:56:26 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -801,7 +801,9 @@ sa_upcall_getstate(union sau_state *ss, struct lwp *l)
size_t ucsize;
if (l) {
l->l_flag |= L_SA_SWITCHING;
getucontext(l, &ss->ss_captured.ss_ctx);
l->l_flag &= ~L_SA_SWITCHING;
sp = (void *)
((intptr_t)_UC_MACHINE_SP(&ss->ss_captured.ss_ctx));
sp = STACK_ALIGN(sp, ~_UC_UCONTEXT_ALIGN);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lwp.h,v 1.24 2004/07/18 21:26:52 chs Exp $ */
/* $NetBSD: lwp.h,v 1.25 2005/01/30 16:56:27 chs Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -117,6 +117,7 @@ extern struct lwp lwp0; /* LWP for proc0 */
#define L_SA_YIELD 0x10000000 /* LWP on VP is yielding */
#define L_SA_IDLE 0x20000000 /* VP is idle */
#define L_COWINPROGRESS 0x40000000 /* UFS: doing copy on write */
#define L_SA_SWITCHING 0x80000000 /* SA LWP in context switch */
/*
* Status values.