lx_misc.c revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/archsystm.h>
#include <sys/privregs.h>
#include <sys/lx_brand.h>
#include <sys/lx_futex.h>
/* Linux specific functions and definitions */
void lx_setrval(klwp_t *, int, int);
void lx_exec();
int lx_initlwp(klwp_t *);
void lx_exitlwp(klwp_t *);
void lx_freelwp(klwp_t *);
static void lx_restore(klwp_t *);
extern void lx_ptrace_free(proc_t *);
/*
* Set the return code for the forked child, always zero
*/
/*ARGSUSED*/
void
{
}
/*
* Reset process state on exec(2)
*/
void
lx_exec()
{
int err;
/*
* There are two mutually exclusive special cases we need to
* address. First, if this was a native process prior to this
* exec(), then this lwp won't have its brand-specific data
* initialized and it won't be assigned a Linux PID yet. Second,
* if this was a multi-threaded Linux process and this lwp wasn't
* the main lwp, then we need to make its Solaris and Linux PIDS
* match.
*/
/*
* Only possible failure from this routine should be an
* inability to allocate a new PID. Since single-threaded
* processes don't need a new PID, we should never hit this
* error.
*/
}
NULL);
/*
* clear out the tls array
*/
/*
* reset the tls entries in the gdt
*/
}
void
{
proc_t *p;
kthread_t *t;
return; /* second time thru' */
}
/*
* The first thread in a process doesn't cause a signal to
* be sent when it exits. It was created by a fork(), not
* a clone(), so the parent should get signalled when the
* process exits.
*/
goto free;
/*
* If br_ppid is 0, it means this is a CLONE_PARENT thread,
* so the signal goes to the parent process - not to a
* specific thread in this process.
*/
mutex_enter(&p->p_lock);
t = NULL;
} else {
/*
* If we have been reparented to init or if our
* parent thread is gone, then nobody gets
* signaled.
*/
(ptid == -1))
goto free;
goto free;
}
mutex_enter(&p->p_lock);
mutex_exit(&p->p_lock);
goto free;
}
}
mutex_exit(&p->p_lock);
}
free:
if (sqp)
}
void
{
}
}
int
{
struct lx_lwp_data *lwpd;
struct lx_lwp_data *plwpd;
lwpd->br_affinitymask = 0;
/*
* The first thread in a process has ppid set to the parent
* process's pid, and ptid set to -1. Subsequent threads in the
* process have their ppid set to the pid of the thread that
* created them, and their ptid to that thread's tid.
*/
} else {
/*
* Oddball case: the parent thread isn't a Linux process.
*/
}
if (lx_pid_assign(tp)) {
return (-1);
}
return (0);
}
/*
* There is no need to have any locking for either the source or
* destination struct lx_lwp_data structs. This is always run in the
* thread context of the source thread, and the destination thread is
* always newly created and not referred to from anywhere else.
*/
void
{
/*
* copy only these flags
*/
}
/*
* When switching a Linux process off the CPU, clear its GDT entries.
*/
/* ARGSUSED */
static void
{
static user_desc_t null_desc;
static int inited;
int i;
if (inited == 0) {
inited = 1;
}
gdt = cpu_get_gdt();
for (i = 0; i < LX_TLSNUM; i++)
}
/*
* When switching a Linux process on the CPU, set its GDT entries.
*/
static void
lx_restore(klwp_t *t)
{
int i;
gdt = cpu_get_gdt();
for (i = 0; i < LX_TLSNUM; i++)
}
void
{
}
void
lx_clear_gdt(int entry)
{
}
lx_nosys()
{
}
{
return (set_errno(EOPNOTSUPP));
}
/*
* Brand-specific routine to check if given non-Solaris standard segment
* register values should be used as-is or if they should be modified to other
* values.
*/
/*ARGSUSED*/
{
/*
* If the segreg is the same as the %gs the brand callback was last
* entered with, allow it to be used unmodified.
*/
return (sr);
/*
* Force the SR into the LDT in ring 3 for 32-bit processes.
*
* 64-bit processes get the null GDT selector since they are not
* allowed to have a private LDT.
*/
#if defined(__amd64)
#endif /* __amd64 */
}