/*
* 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 (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
*/
#include <sys/archsystm.h>
#include <sys/pathname.h>
#include <sys/machbrand.h>
#include "s10_brand.h"
void s10_init_brand_data(zone_t *);
void s10_free_brand_data(zone_t *);
void s10_setbrand(proc_t *);
void s10_exec();
int s10_initlwp(klwp_t *);
void s10_freelwp(klwp_t *);
void s10_lwpexit(klwp_t *);
void s10_sigset_native_to_s10(sigset_t *);
void s10_sigset_s10_to_native(sigset_t *);
/* s10 brand */
};
#ifdef sparc
};
#else /* sparc */
#ifdef __amd64
};
#else /* ! __amd64 */
NULL,
};
#endif /* __amd64 */
#endif /* _sparc */
"solaris10",
};
&mod_brandops, /* type of module */
"Solaris 10 Brand", /* description of module */
&s10_brand /* driver ops */
};
};
void
{
}
/*ARGSUSED*/
int
{
if (attr == S10_EMUL_BITMAP) {
return (EINVAL);
return (EFAULT);
return (0);
}
return (EINVAL);
}
int
{
if (attr == S10_EMUL_BITMAP) {
return (EINVAL);
emul_bitmap, sizeof (s10_emul_bitmap_t)) != 0)
return (EFAULT);
return (0);
}
return (EINVAL);
}
#ifdef __amd64
/*
* The Nevada kernel clears %fs for threads in 64-bit x86 processes but S10's
* libc expects %fs to be nonzero. This causes some committed
* libraries, including libdoor. This function sets the specified LWP's %fs
* register to the legacy S10 selector value (LWPFS_SEL).
*
* The best solution to the aforementioned problem is backporting CRs
* 6467491 to Solaris 10 so that 64-bit x86 Solaris 10 processes
* would accept zero for %fs. Backporting the CRs is a requirement for running
* S10 Containers in PV domUs because 64-bit Xen clears %fsbase when %fs is
* nonzero. Such behavior breaks 64-bit processes because Xen has to fetch the
* FS segments' base addresses from the LWPs' GDTs, which are only capable of
* 32-bit addressing.
*/
/*ARGSUSED*/
static void
{
if (lwp_getdatamodel(l) == DATAMODEL_NATIVE) {
}
}
#endif /* __amd64 */
/*
* Native processes are started with the native ld.so.1 as the command. This
* brand op is invoked by s10_npreload to fix up the command and arguments
* so that apps like pgrep or ps see the expected command strings.
*/
int
{
return (EFAULT);
return (EFAULT);
/*
* Make sure that the process' interpreter is the native dynamic linker.
* Convention dictates that native processes executing within solaris10-
* branded zones are interpreted by the native dynamic linker (the
* process and its arguments are specified as arguments to the dynamic
* linker). If this convention is violated (i.e.,
* brandsys(B_S10_NATIVE, ...) is invoked by a process that shouldn't be
* native), then do nothing and silently indicate success.
*/
return (0);
/*
* The sizeof has an extra value for the trailing '\0' so this covers
* the appended " " in the following strcmps.
*/
sizeof (BRAND_NATIVE_LINKER64)) != 0 &&
sizeof (BRAND_NATIVE_LINKER32)) != 0)
return (0);
return (0);
}
/*ARGSUSED*/
int
{
int res;
*rval = 0;
if (cmd == B_S10_NATIVE)
if (res >= 0)
return (res);
switch ((cmd)) {
case B_S10_PIDINFO:
/*
* The s10 brand needs to be able to get the pid of the
* current process and the pid of the zone's init, and it
* needs to do this on every process startup. Early in
* brand startup, we can't call getpid() because calls to
* getpid() represent a magical signal to some old-skool
* debuggers. By merging all of this into one call, we
* make this quite a bit cheaper and easier to handle in
* the brand module.
*/
return (EFAULT);
sizeof (pid_t)) != 0)
return (EFAULT);
return (0);
case B_S10_ISFDXATTRDIR: {
/*
* This subcommand enables the userland brand emulation library
* to determine whether a file descriptor refers to an extended
* file attributes directory. There is no standard syscall or
* libc function that can make such a determination.
*/
return (EBADF);
return (0);
}
#ifdef __amd64
case B_S10_FSREGCORRECTION:
/*
* This subcommand exists so that the SYS_lwp_private and
* SYS_lwp_create syscalls can manually set the current thread's
* %fs register to the legacy S10 selector value for 64-bit x86
* processes.
*/
return (0);
#endif /* __amd64 */
}
return (EINVAL);
}
void
{
}
void
{
brand_solaris_proc_exit(p, l, &s10_brand);
}
void
s10_exec()
{
}
int
{
return (brand_solaris_initlwp(l, &s10_brand));
}
void
{
brand_solaris_forklwp(p, c, &s10_brand);
#ifdef __amd64
/*
* Only correct the child's %fs register if the parent's %fs register
* is LWPFS_SEL. If the parent's %fs register is zero, then the Solaris
* 10 environment that we're emulating uses a version of libc that
* works when %fs is zero (i.e., it contains backports of CRs 6467491
* and 6501650).
*/
#endif /* __amd64 */
}
void
{
}
void
{
}
void
{
}
void
{
}
int
int brand_action)
{
}
void
{
int nativesig;
int s10sig;
/*
* Shortcut: we know the first 32 signals are the same in both
* s10 and native Solaris. Just assign the first word.
*/
/*
* Copy the remainder of the initial set of common signals.
*/
/*
* Convert any native RT signals to their S10 values.
*/
}
}
void
{
int s10sig;
int nativesig;
/*
* Shortcut: we know the first 32 signals are the same in both
* s10 and native Solaris. Just assign the first word.
*/
/*
* Copy the remainder of the initial set of common signals.
*/
/*
* Convert any S10 RT signals to their native values.
*/
}
}
int
_init(void)
{
int err;
/*
* Set up the table indicating which system calls we want to
* interpose on. We should probably build this automatically from
* a list of system calls that is shared with the user-space
* library.
*/
#if defined(__x86)
#endif
#if defined(__amd64)
#endif /* __amd64 */
if (err) {
}
return (err);
}
int
{
}
int
_fini(void)
{
&s10_brand));
}