/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <sys/privregs.h>
#include <sys/ucontext.h>
#include <sys/asm_linkage.h>
#include <sys/archsystm.h>
#include <sys/schedctl.h>
#include <sys/sysmacros.h>
/*
* Save user context.
*/
void
{
/*
* We unconditionally assign to every field through the end
* of the gregs, but we need to bzero() everything -after- that
* to avoid having any kernel stack garbage escape to userland.
*/
/*
* Try to copyin() the ustack if one is registered. If the stack
* has zero size, this indicates that stack bounds checking has
* been disabled for this LWP. If stack bounds checking is disabled
* or the copyin() fails, we fall back to the legacy behavior.
*/
} else {
}
}
/*
* If either the trace flag or REQUEST_STEP is set,
* arrange for single-stepping and turn off the trace flag.
*/
/*
* Clear PS_T so that saved user context won't have trace
* flag set.
*/
/*
* trap() always checks DEBUG_PENDING before
* checking for any pending signal. This at times
* can potentially lead to DEBUG_PENDING not being
* honoured. (for eg: the lwp is stopped by
* stop_on_fault() called from trap(), after being
* awakened it might see a pending signal and call
* savecontext(), however on the way back to userland
* there is no place it can be detected). Hence in
* anticipation of such occassions, set AST flag for
* the thread which will make the thread take an
* excursion through trap() where it will be handled
* appropriately.
*/
}
}
else
}
/*
* Restore user context.
*/
void
{
else
}
/*
* If the trace flag is set, mark the lwp to take a
* single-step trap on return to user level (below).
* The x86 lcall interface and sysenter has already done this,
* and turned off the flag, but amd64 syscall interface has not.
*/
t->t_post_sys = 1;
}
/*
* We don't need to acquire p->p_lock here;
* we are manipulating thread-private data.
*/
t->t_sig_check = 1;
}
}
int
{
/*
* In future releases, when the ucontext structure grows,
* getcontext should be modified to only return the fields
* specified in the uc_flags. That way, the structure can grow
* and still be binary compatible will all .o's which will only
* have old fields defined in uc_flags
*/
switch (flag) {
default:
case GETCONTEXT:
return (0);
case SETCONTEXT:
exit(CLD_EXITED, 0);
/*
* Don't copyin filler or floating state unless we need it.
* The ucontext_t struct and fields are specified in the ABI.
*/
}
}
restorecontext(&uc);
return (0);
case GETUSTACK:
return (0);
case SETUSTACK:
return (0);
}
}
#ifdef _SYSCALL32_IMPL
/*
* Save user context for 32-bit processes.
*/
void
{
} else {
(p->p_usrstack - p->p_stksize);
}
}
/*
* If either the trace flag or REQUEST_STEP is set, arrange
* for single-stepping and turn off the trace flag.
*/
/*
* Clear PS_T so that saved user context won't have trace
* flag set.
*/
/*
* See comments in savecontext().
*/
}
}
else
}
int
{
switch (flag) {
default:
case GETCONTEXT:
return (0);
case SETCONTEXT:
exit(CLD_EXITED, 0);
}
}
return (0);
case GETUSTACK:
return (0);
case SETUSTACK:
return (0);
}
}
#endif /* _SYSCALL32_IMPL */