/*
* 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/ucontext.h>
#include <sys/asm_linkage.h>
#include <sys/archsystm.h>
#include <sys/sysmacros.h>
#include <sys/privregs.h>
#include <sys/schedctl.h>
/*
* Save user context.
*/
void
{
/*
* We assign to every field through uc_mcontext.fpregs.fpu_en,
* but we have to bzero() everything after that.
*/
/*
* There are unused holes in the ucontext_t structure, zero-fill
* them so that we don't expose kernel data to the user.
*/
/*
* Flushing the user windows isn't strictly necessary; we do
* it to maintain backward compatibility.
*/
(void) flush_user_windows_to_stack(NULL);
/*
* 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 {
}
}
/*
* Save signal mask.
*/
}
void
{
(void) flush_user_windows_to_stack(NULL);
xregrestore(lwp, 0);
else
}
if (model == DATAMODEL_LP64)
else
}
if (model == DATAMODEL_LP64)
else
}
/*
* We don't need to acquire p->p_lock here;
* we are manipulating thread-private data.
*/
t->t_sig_check = 1;
}
}
int
{
int xregs_size = 0;
extern int nwindows;
/*
* 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:
/*
* When using floating point it should not be possible to
* get here with a fpu_qcnt other than zero since we go
* to great pains to handle all outstanding FP exceptions
* before any system call code gets executed. However we
* clear fpu_q and fpu_qcnt here before copyout anyway -
* this will prevent us from interpreting the garbage we
* get back (when FP is not enabled) as valid queue data on
* a later setcontext(2).
*/
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.
*/
}
}
/*
* Need to copyin floating point state
*/
/* if floating queue not empty */
fpp->fpu_q_entrysize <= 0 ||
} else {
}
} else {
}
/*
* We do the same computation here to determine
* how many bytes of gwindows_t to copy in that
* is also done in sendsig() to decide how many
* bytes to copy out. We just *know* that wbcnt
* is the first element of the structure.
*/
}
}
SPARC_MAXREGWINDOW * sizeof (int *) + sizeof (long);
if (gwin_size > sizeof (gwindows_t) ||
}
}
/*
* get extra register state or asrs if any exists
* there is no extra register state for _LP64 user programs
*/
sizeof (asrset_t))) {
/* Free up gwin structure if used */
if (gwin)
}
restorecontext(&uc);
sizeof (stack_t));
}
/*
* free extra register state area
*/
if (xregs_size)
if (gwin)
return (0);
case GETUSTACK:
return (0);
case SETUSTACK:
return (0);
}
}
#ifdef _SYSCALL32_IMPL
/*
* Save user context for 32-bit processes.
*/
void
{
/*
* We assign to every field through uc_mcontext.fpregs.fpu_en,
* but we have to bzero() everything after that.
*/
/*
* There is an unused hole in the ucontext32_t structure; zero-fill
* it so that we don't expose kernel data to the user.
*/
/*
* Flushing the user windows isn't strictly necessary; we do
* it to maintain backward compatibility.
*/
(void) flush_user_windows_to_stack(NULL);
/*
* 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 {
}
}
/*
* Save signal mask (the 32- and 64-bit sigset_t structures are
* identical).
*/
}
int
{
int xregs_size = 0;
extern int nwindows;
/*
* 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:
/*
* When using floating point it should not be possible to
* get here with a fpu_qcnt other than zero since we go
* to great pains to handle all outstanding FP exceptions
* before any system call code gets executed. However we
* clear fpu_q and fpu_qcnt here before copyout anyway -
* this will prevent us from interpreting the garbage we
* get back (when FP is not enabled) as valid queue data on
* a later setcontext(2).
*/
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.
*/
}
}
/*
* Need to copyin floating point state
*/
/* if floating queue not empty */
fpp->fpu_q_entrysize <= 0 ||
} else {
}
} else {
}
/*
* We do the same computation here to determine
* how many bytes of gwindows_t to copy in that
* is also done in sendsig() to decide how many
* bytes to copy out. We just *know* that wbcnt
* is the first element of the structure.
*/
}
}
SPARC_MAXREGWINDOW * sizeof (caddr32_t) +
sizeof (int32_t);
if (gwin_size > sizeof (gwindows32_t) ||
}
/* restorecontext() should ignore this */
}
/*
* get extra register state if any exists
*/
xregs, xregs_size)) {
if (gwin)
}
} else {
}
}
if (gwin)
/*
* free extra register state area
*/
if (xregs_size)
if (gwin)
return (0);
case GETUSTACK:
return (0);
case SETUSTACK:
return (0);
}
}
#endif /* _SYSCALL32_IMPL */