2000-08-22 02:24:02 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2000 Marcel Moolenaar
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
2003-03-03 09:17:12 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer
|
2000-08-22 02:24:02 +00:00
|
|
|
* in this position and unchanged.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
2000-08-25 07:32:24 +00:00
|
|
|
* derived from this software without specific prior written permission.
|
2000-08-22 02:24:02 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-06-02 16:56:40 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-08-22 02:24:02 +00:00
|
|
|
#include <sys/param.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/systm.h>
|
2011-08-11 12:30:23 +00:00
|
|
|
#include <sys/capability.h>
|
2006-09-20 17:24:20 +00:00
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/fcntl.h>
|
2005-01-29 23:12:00 +00:00
|
|
|
#include <sys/imgact.h>
|
2001-10-11 17:52:20 +00:00
|
|
|
#include <sys/lock.h>
|
2005-01-29 23:12:00 +00:00
|
|
|
#include <sys/malloc.h>
|
2000-08-22 02:24:02 +00:00
|
|
|
#include <sys/mman.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/mutex.h>
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#include <sys/sx.h>
|
2006-11-06 13:42:10 +00:00
|
|
|
#include <sys/priv.h>
|
2000-08-22 02:24:02 +00:00
|
|
|
#include <sys/proc.h>
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#include <sys/queue.h>
|
2000-10-17 00:25:43 +00:00
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/resourcevar.h>
|
2004-09-06 09:32:59 +00:00
|
|
|
#include <sys/signalvar.h>
|
2002-09-01 22:30:27 +00:00
|
|
|
#include <sys/syscallsubr.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/sysproto.h>
|
|
|
|
#include <sys/unistd.h>
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#include <sys/wait.h>
|
2007-01-23 08:46:51 +00:00
|
|
|
#include <sys/sched.h>
|
2000-08-22 02:24:02 +00:00
|
|
|
|
|
|
|
#include <machine/frame.h>
|
|
|
|
#include <machine/psl.h>
|
|
|
|
#include <machine/segments.h>
|
|
|
|
#include <machine/sysarch.h>
|
|
|
|
|
2000-10-17 00:25:43 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/pmap.h>
|
|
|
|
#include <vm/vm_map.h>
|
|
|
|
|
2000-08-22 02:24:02 +00:00
|
|
|
#include <i386/linux/linux.h>
|
2000-11-10 21:30:19 +00:00
|
|
|
#include <i386/linux/linux_proto.h>
|
2000-08-22 02:24:02 +00:00
|
|
|
#include <compat/linux/linux_ipc.h>
|
2011-01-28 18:47:07 +00:00
|
|
|
#include <compat/linux/linux_misc.h>
|
2000-08-22 02:24:02 +00:00
|
|
|
#include <compat/linux/linux_signal.h>
|
|
|
|
#include <compat/linux/linux_util.h>
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#include <compat/linux/linux_emul.h>
|
|
|
|
|
|
|
|
#include <i386/include/pcb.h> /* needed for pcb definition in linux_set_thread_area */
|
|
|
|
|
|
|
|
#include "opt_posix.h"
|
|
|
|
|
|
|
|
extern struct sysentvec elf32_freebsd_sysvec; /* defined in i386/i386/elf_machdep.c */
|
2000-08-22 02:24:02 +00:00
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_descriptor {
|
|
|
|
l_uint entry_number;
|
|
|
|
l_ulong base_addr;
|
|
|
|
l_uint limit;
|
|
|
|
l_uint seg_32bit:1;
|
|
|
|
l_uint contents:2;
|
|
|
|
l_uint read_exec_only:1;
|
|
|
|
l_uint limit_in_pages:1;
|
|
|
|
l_uint seg_not_present:1;
|
|
|
|
l_uint useable:1;
|
2000-08-22 02:24:02 +00:00
|
|
|
};
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_old_select_argv {
|
|
|
|
l_int nfds;
|
|
|
|
l_fd_set *readfds;
|
|
|
|
l_fd_set *writefds;
|
|
|
|
l_fd_set *exceptfds;
|
|
|
|
struct l_timeval *timeout;
|
2000-08-22 02:24:02 +00:00
|
|
|
};
|
|
|
|
|
2009-10-28 20:17:54 +00:00
|
|
|
static int linux_mmap_common(struct thread *td, l_uintptr_t addr,
|
|
|
|
l_size_t len, l_int prot, l_int flags, l_int fd,
|
|
|
|
l_loff_t pos);
|
|
|
|
|
2000-10-13 01:57:43 +00:00
|
|
|
int
|
|
|
|
linux_to_bsd_sigaltstack(int lsa)
|
|
|
|
{
|
|
|
|
int bsa = 0;
|
|
|
|
|
|
|
|
if (lsa & LINUX_SS_DISABLE)
|
|
|
|
bsa |= SS_DISABLE;
|
|
|
|
if (lsa & LINUX_SS_ONSTACK)
|
|
|
|
bsa |= SS_ONSTACK;
|
|
|
|
return (bsa);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bsd_to_linux_sigaltstack(int bsa)
|
|
|
|
{
|
|
|
|
int lsa = 0;
|
|
|
|
|
|
|
|
if (bsa & SS_DISABLE)
|
|
|
|
lsa |= LINUX_SS_DISABLE;
|
|
|
|
if (bsa & SS_ONSTACK)
|
|
|
|
lsa |= LINUX_SS_ONSTACK;
|
|
|
|
return (lsa);
|
|
|
|
}
|
|
|
|
|
2000-08-22 02:24:02 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_execve(struct thread *td, struct linux_execve_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2005-01-29 23:12:00 +00:00
|
|
|
int error;
|
|
|
|
char *newpath;
|
|
|
|
struct image_args eargs;
|
2000-08-22 02:24:02 +00:00
|
|
|
|
2005-02-07 18:37:13 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &newpath);
|
2000-08-22 02:24:02 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(execve))
|
2005-01-29 23:12:00 +00:00
|
|
|
printf(ARGS(execve, "%s"), newpath);
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
|
|
|
|
2005-01-29 23:12:00 +00:00
|
|
|
error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE,
|
|
|
|
args->argp, args->envp);
|
|
|
|
free(newpath, M_TEMP);
|
|
|
|
if (error == 0)
|
2005-08-01 17:35:48 +00:00
|
|
|
error = kern_execve(td, &eargs, NULL);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
if (error == 0)
|
|
|
|
/* linux process can exec fbsd one, dont attempt
|
|
|
|
* to create emuldata for such process using
|
|
|
|
* linux_proc_init, this leads to a panic on KASSERT
|
|
|
|
* because such process has p->p_emuldata == NULL
|
|
|
|
*/
|
2011-01-26 20:03:58 +00:00
|
|
|
if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX)
|
|
|
|
error = linux_proc_init(td, 0, 0);
|
2005-01-29 23:12:00 +00:00
|
|
|
return (error);
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_ipc_kludge {
|
|
|
|
struct l_msgbuf *msgp;
|
|
|
|
l_long msgtyp;
|
|
|
|
};
|
|
|
|
|
2000-08-22 02:24:02 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_ipc(struct thread *td, struct linux_ipc_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
switch (args->what & 0xFFFF) {
|
|
|
|
case LINUX_SEMOP: {
|
|
|
|
struct linux_semop_args a;
|
|
|
|
|
|
|
|
a.semid = args->arg1;
|
|
|
|
a.tsops = args->ptr;
|
|
|
|
a.nsops = args->arg2;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_semop(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_SEMGET: {
|
|
|
|
struct linux_semget_args a;
|
|
|
|
|
|
|
|
a.key = args->arg1;
|
|
|
|
a.nsems = args->arg2;
|
|
|
|
a.semflg = args->arg3;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_semget(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_SEMCTL: {
|
|
|
|
struct linux_semctl_args a;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
a.semid = args->arg1;
|
|
|
|
a.semnum = args->arg2;
|
|
|
|
a.cmd = args->arg3;
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin(args->ptr, &a.arg, sizeof(a.arg));
|
2001-09-08 19:07:04 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_semctl(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_MSGSND: {
|
|
|
|
struct linux_msgsnd_args a;
|
|
|
|
|
|
|
|
a.msqid = args->arg1;
|
|
|
|
a.msgp = args->ptr;
|
|
|
|
a.msgsz = args->arg2;
|
|
|
|
a.msgflg = args->arg3;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_msgsnd(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_MSGRCV: {
|
|
|
|
struct linux_msgrcv_args a;
|
|
|
|
|
|
|
|
a.msqid = args->arg1;
|
|
|
|
a.msgsz = args->arg2;
|
|
|
|
a.msgflg = args->arg3;
|
|
|
|
if ((args->what >> 16) == 0) {
|
|
|
|
struct l_ipc_kludge tmp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (args->ptr == NULL)
|
|
|
|
return (EINVAL);
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin(args->ptr, &tmp, sizeof(tmp));
|
2001-09-08 19:07:04 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
a.msgp = tmp.msgp;
|
|
|
|
a.msgtyp = tmp.msgtyp;
|
|
|
|
} else {
|
|
|
|
a.msgp = args->ptr;
|
|
|
|
a.msgtyp = args->arg5;
|
|
|
|
}
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_msgrcv(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_MSGGET: {
|
|
|
|
struct linux_msgget_args a;
|
|
|
|
|
|
|
|
a.key = args->arg1;
|
|
|
|
a.msgflg = args->arg2;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_msgget(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_MSGCTL: {
|
|
|
|
struct linux_msgctl_args a;
|
|
|
|
|
|
|
|
a.msqid = args->arg1;
|
|
|
|
a.cmd = args->arg2;
|
|
|
|
a.buf = args->ptr;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_msgctl(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_SHMAT: {
|
|
|
|
struct linux_shmat_args a;
|
|
|
|
|
|
|
|
a.shmid = args->arg1;
|
|
|
|
a.shmaddr = args->ptr;
|
|
|
|
a.shmflg = args->arg2;
|
|
|
|
a.raddr = (l_ulong *)args->arg3;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_shmat(td, &a));
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
2001-09-08 19:07:04 +00:00
|
|
|
case LINUX_SHMDT: {
|
|
|
|
struct linux_shmdt_args a;
|
2000-08-22 02:24:02 +00:00
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
a.shmaddr = args->ptr;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_shmdt(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_SHMGET: {
|
|
|
|
struct linux_shmget_args a;
|
|
|
|
|
|
|
|
a.key = args->arg1;
|
|
|
|
a.size = args->arg2;
|
|
|
|
a.shmflg = args->arg3;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_shmget(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
case LINUX_SHMCTL: {
|
|
|
|
struct linux_shmctl_args a;
|
|
|
|
|
|
|
|
a.shmid = args->arg1;
|
|
|
|
a.cmd = args->arg2;
|
|
|
|
a.buf = args->ptr;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_shmctl(td, &a));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (EINVAL);
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_old_select(struct thread *td, struct linux_old_select_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_old_select_argv linux_args;
|
|
|
|
struct linux_select_args newsel;
|
2000-08-22 02:24:02 +00:00
|
|
|
int error;
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(old_select))
|
2002-02-27 23:21:46 +00:00
|
|
|
printf(ARGS(old_select, "%p"), args->ptr);
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
|
|
|
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin(args->ptr, &linux_args, sizeof(linux_args));
|
2000-08-22 02:24:02 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
newsel.nfds = linux_args.nfds;
|
|
|
|
newsel.readfds = linux_args.readfds;
|
|
|
|
newsel.writefds = linux_args.writefds;
|
|
|
|
newsel.exceptfds = linux_args.exceptfds;
|
|
|
|
newsel.timeout = linux_args.timeout;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_select(td, &newsel));
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2011-02-12 15:50:21 +00:00
|
|
|
linux_set_cloned_tls(struct thread *td, void *desc)
|
|
|
|
{
|
|
|
|
struct segment_descriptor sd;
|
|
|
|
struct l_user_desc info;
|
|
|
|
int idx, error;
|
|
|
|
int a[2];
|
|
|
|
|
|
|
|
error = copyin(desc, &info, sizeof(struct l_user_desc));
|
|
|
|
if (error) {
|
|
|
|
printf(LMSG("copyin failed!"));
|
|
|
|
} else {
|
|
|
|
idx = info.entry_number;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* looks like we're getting the idx we returned
|
|
|
|
* in the set_thread_area() syscall
|
|
|
|
*/
|
|
|
|
if (idx != 6 && idx != 3) {
|
|
|
|
printf(LMSG("resetting idx!"));
|
|
|
|
idx = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this doesnt happen in practice */
|
|
|
|
if (idx == 6) {
|
|
|
|
/* we might copy out the entry_number as 3 */
|
|
|
|
info.entry_number = 3;
|
|
|
|
error = copyout(&info, desc, sizeof(struct l_user_desc));
|
|
|
|
if (error)
|
|
|
|
printf(LMSG("copyout failed!"));
|
|
|
|
}
|
|
|
|
|
|
|
|
a[0] = LINUX_LDT_entry_a(&info);
|
|
|
|
a[1] = LINUX_LDT_entry_b(&info);
|
|
|
|
|
|
|
|
memcpy(&sd, &a, sizeof(a));
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(clone))
|
|
|
|
printf("Segment created in clone with "
|
|
|
|
"CLONE_SETTLS: lobase: %x, hibase: %x, "
|
|
|
|
"lolimit: %x, hilimit: %x, type: %i, "
|
|
|
|
"dpl: %i, p: %i, xx: %i, def32: %i, "
|
|
|
|
"gran: %i\n", sd.sd_lobase, sd.sd_hibase,
|
|
|
|
sd.sd_lolimit, sd.sd_hilimit, sd.sd_type,
|
|
|
|
sd.sd_dpl, sd.sd_p, sd.sd_xx,
|
|
|
|
sd.sd_def32, sd.sd_gran);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* set %gs */
|
|
|
|
td->td_pcb->pcb_gsd = sd;
|
|
|
|
td->td_pcb->pcb_gs = GSEL(GUGS_SEL, SEL_UPL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2011-02-12 16:33:00 +00:00
|
|
|
int
|
|
|
|
linux_set_upcall_kse(struct thread *td, register_t stack)
|
|
|
|
{
|
|
|
|
|
|
|
|
td->td_frame->tf_esp = stack;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-08-22 02:24:02 +00:00
|
|
|
#define STACK_SIZE (2 * 1024 * 1024)
|
|
|
|
#define GUARD_SIZE (4 * PAGE_SIZE)
|
|
|
|
|
2002-10-11 11:43:09 +00:00
|
|
|
int
|
|
|
|
linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(mmap2))
|
2003-03-03 09:17:12 +00:00
|
|
|
printf(ARGS(mmap2, "%p, %d, %d, 0x%08x, %d, %d"),
|
|
|
|
(void *)args->addr, args->len, args->prot,
|
|
|
|
args->flags, args->fd, args->pgoff);
|
2002-10-11 11:43:09 +00:00
|
|
|
#endif
|
|
|
|
|
2009-10-28 20:17:54 +00:00
|
|
|
return (linux_mmap_common(td, args->addr, args->len, args->prot,
|
|
|
|
args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff *
|
|
|
|
PAGE_SIZE));
|
2002-10-11 11:43:09 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 02:24:02 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_mmap(struct thread *td, struct linux_mmap_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
|
|
|
int error;
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_mmap_argv linux_args;
|
2000-08-22 02:24:02 +00:00
|
|
|
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin(args->ptr, &linux_args, sizeof(linux_args));
|
2000-08-22 02:24:02 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(mmap))
|
|
|
|
printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"),
|
2002-10-12 13:48:21 +00:00
|
|
|
(void *)linux_args.addr, linux_args.len, linux_args.prot,
|
2007-02-15 00:54:40 +00:00
|
|
|
linux_args.flags, linux_args.fd, linux_args.pgoff);
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
|
|
|
|
2009-10-28 20:17:54 +00:00
|
|
|
return (linux_mmap_common(td, linux_args.addr, linux_args.len,
|
|
|
|
linux_args.prot, linux_args.flags, linux_args.fd,
|
|
|
|
(uint32_t)linux_args.pgoff));
|
2002-10-11 11:43:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-10-28 20:17:54 +00:00
|
|
|
linux_mmap_common(struct thread *td, l_uintptr_t addr, l_size_t len, l_int prot,
|
|
|
|
l_int flags, l_int fd, l_loff_t pos)
|
2002-10-11 11:43:09 +00:00
|
|
|
{
|
|
|
|
struct proc *p = td->td_proc;
|
|
|
|
struct mmap_args /* {
|
|
|
|
caddr_t addr;
|
|
|
|
size_t len;
|
|
|
|
int prot;
|
|
|
|
int flags;
|
|
|
|
int fd;
|
|
|
|
long pad;
|
|
|
|
off_t pos;
|
|
|
|
} */ bsd_args;
|
2003-03-25 20:02:55 +00:00
|
|
|
int error;
|
2006-09-20 17:24:20 +00:00
|
|
|
struct file *fp;
|
Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.
The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.
The structure definition looks like this:
struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};
The initial CAP_RIGHTS_VERSION is 0.
The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.
The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.
To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.
#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)
We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:
#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)
#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)
There is new API to manage the new cap_rights_t structure:
cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);
bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);
Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:
cap_rights_t rights;
cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);
There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:
#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);
Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:
cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);
Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.
This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.
Sponsored by: The FreeBSD Foundation
2013-09-05 00:09:56 +00:00
|
|
|
cap_rights_t rights;
|
2002-10-11 11:43:09 +00:00
|
|
|
|
2003-03-25 20:02:55 +00:00
|
|
|
error = 0;
|
2000-08-22 02:24:02 +00:00
|
|
|
bsd_args.flags = 0;
|
2006-09-20 17:24:20 +00:00
|
|
|
fp = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Linux mmap(2):
|
|
|
|
* You must specify exactly one of MAP_SHARED and MAP_PRIVATE
|
|
|
|
*/
|
2009-10-28 20:17:54 +00:00
|
|
|
if (!((flags & LINUX_MAP_SHARED) ^ (flags & LINUX_MAP_PRIVATE)))
|
2006-09-20 19:27:11 +00:00
|
|
|
return (EINVAL);
|
2006-09-20 17:24:20 +00:00
|
|
|
|
2009-10-28 20:17:54 +00:00
|
|
|
if (flags & LINUX_MAP_SHARED)
|
2000-08-22 02:24:02 +00:00
|
|
|
bsd_args.flags |= MAP_SHARED;
|
2009-10-28 20:17:54 +00:00
|
|
|
if (flags & LINUX_MAP_PRIVATE)
|
2000-08-22 02:24:02 +00:00
|
|
|
bsd_args.flags |= MAP_PRIVATE;
|
2009-10-28 20:17:54 +00:00
|
|
|
if (flags & LINUX_MAP_FIXED)
|
2000-08-22 02:24:02 +00:00
|
|
|
bsd_args.flags |= MAP_FIXED;
|
2010-06-10 17:59:47 +00:00
|
|
|
if (flags & LINUX_MAP_ANON) {
|
|
|
|
/* Enforce pos to be on page boundary, then ignore. */
|
|
|
|
if ((pos & PAGE_MASK) != 0)
|
|
|
|
return (EINVAL);
|
|
|
|
pos = 0;
|
2000-08-22 02:24:02 +00:00
|
|
|
bsd_args.flags |= MAP_ANON;
|
2010-06-10 17:59:47 +00:00
|
|
|
} else
|
2001-02-28 04:30:27 +00:00
|
|
|
bsd_args.flags |= MAP_NOSYNC;
|
2009-10-28 20:17:54 +00:00
|
|
|
if (flags & LINUX_MAP_GROWSDOWN)
|
2000-08-22 02:24:02 +00:00
|
|
|
bsd_args.flags |= MAP_STACK;
|
|
|
|
|
2007-02-15 00:54:40 +00:00
|
|
|
/*
|
|
|
|
* PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC
|
|
|
|
* on Linux/i386. We do this to ensure maximum compatibility.
|
|
|
|
* Linux/ia64 does the same in i386 emulation mode.
|
|
|
|
*/
|
2009-10-28 20:17:54 +00:00
|
|
|
bsd_args.prot = prot;
|
2007-02-15 00:54:40 +00:00
|
|
|
if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
|
|
|
|
bsd_args.prot |= PROT_READ | PROT_EXEC;
|
|
|
|
|
2007-02-27 02:08:01 +00:00
|
|
|
/* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
|
2009-10-28 20:17:54 +00:00
|
|
|
bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : fd;
|
2007-02-27 02:08:01 +00:00
|
|
|
if (bsd_args.fd != -1) {
|
2007-02-15 00:54:40 +00:00
|
|
|
/*
|
|
|
|
* Linux follows Solaris mmap(2) description:
|
|
|
|
* The file descriptor fildes is opened with
|
|
|
|
* read permission, regardless of the
|
|
|
|
* protection options specified.
|
2011-08-11 12:30:23 +00:00
|
|
|
*
|
|
|
|
* Checking just CAP_MMAP is fine here, since the real work
|
|
|
|
* is done in the FreeBSD mmap().
|
2007-02-15 00:54:40 +00:00
|
|
|
*/
|
|
|
|
|
Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.
The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.
The structure definition looks like this:
struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};
The initial CAP_RIGHTS_VERSION is 0.
The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.
The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.
To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.
#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)
We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:
#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)
#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)
There is new API to manage the new cap_rights_t structure:
cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);
bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);
Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:
cap_rights_t rights;
cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);
There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:
#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);
Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:
cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);
Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.
This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.
Sponsored by: The FreeBSD Foundation
2013-09-05 00:09:56 +00:00
|
|
|
error = fget(td, bsd_args.fd,
|
|
|
|
cap_rights_init(&rights, CAP_MMAP), &fp);
|
|
|
|
if (error != 0)
|
2007-02-15 00:54:40 +00:00
|
|
|
return (error);
|
|
|
|
if (fp->f_type != DTYPE_VNODE) {
|
|
|
|
fdrop(fp, td);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Linux mmap() just fails for O_WRONLY files */
|
|
|
|
if (!(fp->f_flag & FREAD)) {
|
|
|
|
fdrop(fp, td);
|
|
|
|
return (EACCES);
|
|
|
|
}
|
|
|
|
|
|
|
|
fdrop(fp, td);
|
|
|
|
}
|
|
|
|
|
2009-10-28 20:17:54 +00:00
|
|
|
if (flags & LINUX_MAP_GROWSDOWN) {
|
2006-08-16 18:54:51 +00:00
|
|
|
/*
|
2009-10-28 20:17:54 +00:00
|
|
|
* The Linux MAP_GROWSDOWN option does not limit auto
|
2000-08-22 02:24:02 +00:00
|
|
|
* growth of the region. Linux mmap with this option
|
|
|
|
* takes as addr the inital BOS, and as len, the initial
|
|
|
|
* region size. It can then grow down from addr without
|
|
|
|
* limit. However, linux threads has an implicit internal
|
|
|
|
* limit to stack size of STACK_SIZE. Its just not
|
|
|
|
* enforced explicitly in linux. But, here we impose
|
|
|
|
* a limit of (STACK_SIZE - GUARD_SIZE) on the stack
|
|
|
|
* region, since we can do this with our mmap.
|
|
|
|
*
|
|
|
|
* Our mmap with MAP_STACK takes addr as the maximum
|
|
|
|
* downsize limit on BOS, and as len the max size of
|
|
|
|
* the region. It them maps the top SGROWSIZ bytes,
|
2007-02-24 16:49:25 +00:00
|
|
|
* and auto grows the region down, up to the limit
|
2000-08-22 02:24:02 +00:00
|
|
|
* in addr.
|
|
|
|
*
|
|
|
|
* If we don't use the MAP_STACK option, the effect
|
|
|
|
* of this code is to allocate a stack region of a
|
|
|
|
* fixed size of (STACK_SIZE - GUARD_SIZE).
|
|
|
|
*/
|
|
|
|
|
2009-10-28 20:17:54 +00:00
|
|
|
if ((caddr_t)PTRIN(addr) + len > p->p_vmspace->vm_maxsaddr) {
|
2006-08-16 18:54:51 +00:00
|
|
|
/*
|
|
|
|
* Some linux apps will attempt to mmap
|
2000-10-17 00:25:43 +00:00
|
|
|
* thread stacks near the top of their
|
|
|
|
* address space. If their TOS is greater
|
|
|
|
* than vm_maxsaddr, vm_map_growstack()
|
|
|
|
* will confuse the thread stack with the
|
|
|
|
* process stack and deliver a SEGV if they
|
|
|
|
* attempt to grow the thread stack past their
|
|
|
|
* current stacksize rlimit. To avoid this,
|
|
|
|
* adjust vm_maxsaddr upwards to reflect
|
|
|
|
* the current stacksize rlimit rather
|
|
|
|
* than the maximum possible stacksize.
|
|
|
|
* It would be better to adjust the
|
|
|
|
* mmap'ed region, but some apps do not check
|
|
|
|
* mmap's return value.
|
|
|
|
*/
|
2004-02-04 21:52:57 +00:00
|
|
|
PROC_LOCK(p);
|
2000-10-17 00:25:43 +00:00
|
|
|
p->p_vmspace->vm_maxsaddr = (char *)USRSTACK -
|
2004-02-04 21:52:57 +00:00
|
|
|
lim_cur(p, RLIMIT_STACK);
|
|
|
|
PROC_UNLOCK(p);
|
2000-10-17 00:25:43 +00:00
|
|
|
}
|
|
|
|
|
2008-02-11 19:35:03 +00:00
|
|
|
/*
|
|
|
|
* This gives us our maximum stack size and a new BOS.
|
|
|
|
* If we're using VM_STACK, then mmap will just map
|
|
|
|
* the top SGROWSIZ bytes, and let the stack grow down
|
|
|
|
* to the limit at BOS. If we're not using VM_STACK
|
|
|
|
* we map the full stack, since we don't have a way
|
|
|
|
* to autogrow it.
|
2000-08-22 02:24:02 +00:00
|
|
|
*/
|
2009-10-28 20:17:54 +00:00
|
|
|
if (len > STACK_SIZE - GUARD_SIZE) {
|
|
|
|
bsd_args.addr = (caddr_t)PTRIN(addr);
|
|
|
|
bsd_args.len = len;
|
2008-02-11 19:35:03 +00:00
|
|
|
} else {
|
2009-10-28 20:17:54 +00:00
|
|
|
bsd_args.addr = (caddr_t)PTRIN(addr) -
|
|
|
|
(STACK_SIZE - GUARD_SIZE - len);
|
2008-02-11 19:35:03 +00:00
|
|
|
bsd_args.len = STACK_SIZE - GUARD_SIZE;
|
|
|
|
}
|
2000-08-22 02:24:02 +00:00
|
|
|
} else {
|
2009-10-28 20:17:54 +00:00
|
|
|
bsd_args.addr = (caddr_t)PTRIN(addr);
|
|
|
|
bsd_args.len = len;
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
2009-10-28 20:17:54 +00:00
|
|
|
bsd_args.pos = pos;
|
2000-08-22 02:24:02 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(mmap))
|
2003-03-25 20:02:55 +00:00
|
|
|
printf("-> %s(%p, %d, %d, 0x%08x, %d, 0x%x)\n",
|
|
|
|
__func__,
|
2001-02-16 16:40:43 +00:00
|
|
|
(void *)bsd_args.addr, bsd_args.len, bsd_args.prot,
|
|
|
|
bsd_args.flags, bsd_args.fd, (int)bsd_args.pos);
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
2011-09-16 13:58:51 +00:00
|
|
|
error = sys_mmap(td, &bsd_args);
|
2003-03-25 20:02:55 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(mmap))
|
|
|
|
printf("-> %s() return: 0x%x (0x%08x)\n",
|
|
|
|
__func__, error, (u_int)td->td_retval[0]);
|
|
|
|
#endif
|
|
|
|
return (error);
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
2007-02-15 00:54:40 +00:00
|
|
|
int
|
|
|
|
linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
|
|
|
|
{
|
|
|
|
struct mprotect_args bsd_args;
|
|
|
|
|
|
|
|
bsd_args.addr = uap->addr;
|
|
|
|
bsd_args.len = uap->len;
|
|
|
|
bsd_args.prot = uap->prot;
|
|
|
|
if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
|
|
|
|
bsd_args.prot |= PROT_READ | PROT_EXEC;
|
2011-09-16 13:58:51 +00:00
|
|
|
return (sys_mprotect(td, &bsd_args));
|
2007-02-15 00:54:40 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 02:24:02 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_ioperm(struct thread *td, struct linux_ioperm_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2005-01-26 13:59:46 +00:00
|
|
|
int error;
|
|
|
|
struct i386_ioperm_args iia;
|
|
|
|
|
|
|
|
iia.start = args->start;
|
|
|
|
iia.length = args->length;
|
|
|
|
iia.enable = args->enable;
|
|
|
|
error = i386_set_ioperm(td, &iia);
|
|
|
|
return (error);
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_iopl(struct thread *td, struct linux_iopl_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (args->level < 0 || args->level > 3)
|
|
|
|
return (EINVAL);
|
2006-11-06 13:42:10 +00:00
|
|
|
if ((error = priv_check(td, PRIV_IO)) != 0)
|
2000-08-22 02:24:02 +00:00
|
|
|
return (error);
|
2002-02-27 18:32:23 +00:00
|
|
|
if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
|
2001-09-26 20:22:38 +00:00
|
|
|
return (error);
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_frame->tf_eflags = (td->td_frame->tf_eflags & ~PSL_IOPL) |
|
2000-08-22 02:24:02 +00:00
|
|
|
(args->level * (PSL_IOPL / 3));
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-10-19 11:57:38 +00:00
|
|
|
linux_modify_ldt(struct thread *td, struct linux_modify_ldt_args *uap)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
|
|
|
int error;
|
2005-01-26 13:59:46 +00:00
|
|
|
struct i386_ldt_args ldt;
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_descriptor ld;
|
2005-01-26 13:59:46 +00:00
|
|
|
union descriptor desc;
|
2007-11-26 11:06:19 +00:00
|
|
|
int size, written;
|
2000-08-22 02:24:02 +00:00
|
|
|
|
|
|
|
switch (uap->func) {
|
|
|
|
case 0x00: /* read_ldt */
|
2005-01-26 13:59:46 +00:00
|
|
|
ldt.start = 0;
|
|
|
|
ldt.descs = uap->ptr;
|
|
|
|
ldt.num = uap->bytecount / sizeof(union descriptor);
|
|
|
|
error = i386_get_ldt(td, &ldt);
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] *= sizeof(union descriptor);
|
2000-08-22 02:24:02 +00:00
|
|
|
break;
|
2007-11-26 11:06:19 +00:00
|
|
|
case 0x02: /* read_default_ldt = 0 */
|
|
|
|
size = 5*sizeof(struct l_desc_struct);
|
|
|
|
if (size > uap->bytecount)
|
|
|
|
size = uap->bytecount;
|
|
|
|
for (written = error = 0; written < size && error == 0; written++)
|
|
|
|
error = subyte((char *)uap->ptr + written, 0);
|
|
|
|
td->td_retval[0] = written;
|
|
|
|
break;
|
2000-08-22 02:24:02 +00:00
|
|
|
case 0x01: /* write_ldt */
|
|
|
|
case 0x11: /* write_ldt */
|
|
|
|
if (uap->bytecount != sizeof(ld))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
error = copyin(uap->ptr, &ld, sizeof(ld));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
2005-01-26 13:59:46 +00:00
|
|
|
ldt.start = ld.entry_number;
|
|
|
|
ldt.descs = &desc;
|
|
|
|
ldt.num = 1;
|
|
|
|
desc.sd.sd_lolimit = (ld.limit & 0x0000ffff);
|
|
|
|
desc.sd.sd_hilimit = (ld.limit & 0x000f0000) >> 16;
|
|
|
|
desc.sd.sd_lobase = (ld.base_addr & 0x00ffffff);
|
|
|
|
desc.sd.sd_hibase = (ld.base_addr & 0xff000000) >> 24;
|
|
|
|
desc.sd.sd_type = SDT_MEMRO | ((ld.read_exec_only ^ 1) << 1) |
|
2000-08-22 02:24:02 +00:00
|
|
|
(ld.contents << 2);
|
2005-01-26 13:59:46 +00:00
|
|
|
desc.sd.sd_dpl = 3;
|
|
|
|
desc.sd.sd_p = (ld.seg_not_present ^ 1);
|
|
|
|
desc.sd.sd_xx = 0;
|
|
|
|
desc.sd.sd_def32 = ld.seg_32bit;
|
|
|
|
desc.sd.sd_gran = ld.limit_in_pages;
|
|
|
|
error = i386_set_ldt(td, &ldt, &desc);
|
2000-08-22 02:24:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-06-26 19:39:33 +00:00
|
|
|
error = ENOSYS;
|
2000-08-22 02:24:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error == EOPNOTSUPP) {
|
|
|
|
printf("linux: modify_ldt needs kernel option USER_LDT\n");
|
|
|
|
error = ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
l_osigaction_t osa;
|
|
|
|
l_sigaction_t act, oact;
|
2000-08-22 02:24:02 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(sigaction))
|
|
|
|
printf(ARGS(sigaction, "%d, %p, %p"),
|
|
|
|
args->sig, (void *)args->nsa, (void *)args->osa);
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (args->nsa != NULL) {
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin(args->nsa, &osa, sizeof(l_osigaction_t));
|
2000-08-22 02:24:02 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
act.lsa_handler = osa.lsa_handler;
|
|
|
|
act.lsa_flags = osa.lsa_flags;
|
|
|
|
act.lsa_restorer = osa.lsa_restorer;
|
|
|
|
LINUX_SIGEMPTYSET(act.lsa_mask);
|
|
|
|
act.lsa_mask.__bits[0] = osa.lsa_mask;
|
|
|
|
}
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL,
|
2000-08-22 02:24:02 +00:00
|
|
|
args->osa ? &oact : NULL);
|
|
|
|
|
|
|
|
if (args->osa != NULL && !error) {
|
|
|
|
osa.lsa_handler = oact.lsa_handler;
|
|
|
|
osa.lsa_flags = oact.lsa_flags;
|
|
|
|
osa.lsa_restorer = oact.lsa_restorer;
|
|
|
|
osa.lsa_mask = oact.lsa_mask.__bits[0];
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyout(&osa, args->osa, sizeof(l_osigaction_t));
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Linux has two extra args, restart and oldmask. We dont use these,
|
|
|
|
* but it seems that "restart" is actually a context pointer that
|
|
|
|
* enables the signal to happen with a different register set.
|
|
|
|
*/
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
sigset_t sigmask;
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigset_t mask;
|
2000-08-22 02:24:02 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(sigsuspend))
|
|
|
|
printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask);
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
LINUX_SIGEMPTYSET(mask);
|
|
|
|
mask.__bits[0] = args->mask;
|
2002-09-01 22:30:27 +00:00
|
|
|
linux_to_bsd_sigset(&mask, &sigmask);
|
|
|
|
return (kern_sigsuspend(td, sigmask));
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-10-19 11:57:38 +00:00
|
|
|
linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigset_t lmask;
|
2002-09-01 22:30:27 +00:00
|
|
|
sigset_t sigmask;
|
2000-08-22 02:24:02 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(rt_sigsuspend))
|
|
|
|
printf(ARGS(rt_sigsuspend, "%p, %d"),
|
|
|
|
(void *)uap->newset, uap->sigsetsize);
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
if (uap->sigsetsize != sizeof(l_sigset_t))
|
2000-08-22 02:24:02 +00:00
|
|
|
return (EINVAL);
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
|
2000-08-22 02:24:02 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
linux_to_bsd_sigset(&lmask, &sigmask);
|
|
|
|
return (kern_sigsuspend(td, sigmask));
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_pause(struct thread *td, struct linux_pause_args *args)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct proc *p = td->td_proc;
|
2002-09-01 22:30:27 +00:00
|
|
|
sigset_t sigmask;
|
2000-08-22 02:24:02 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(pause))
|
|
|
|
printf(ARGS(pause, ""));
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
|
|
|
|
2001-01-24 00:23:30 +00:00
|
|
|
PROC_LOCK(p);
|
2003-03-31 22:49:17 +00:00
|
|
|
sigmask = td->td_sigmask;
|
2001-01-24 00:23:30 +00:00
|
|
|
PROC_UNLOCK(p);
|
2002-09-01 22:30:27 +00:00
|
|
|
return (kern_sigsuspend(td, sigmask));
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
|
2000-08-22 02:24:02 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
stack_t ss, oss;
|
2001-09-08 19:07:04 +00:00
|
|
|
l_stack_t lss;
|
2000-08-22 02:24:02 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(sigaltstack))
|
|
|
|
printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss);
|
2000-08-22 02:24:02 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
if (uap->uss != NULL) {
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyin(uap->uss, &lss, sizeof(l_stack_t));
|
2000-10-13 01:57:43 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
2000-08-22 02:24:02 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
ss.ss_sp = lss.ss_sp;
|
|
|
|
ss.ss_size = lss.ss_size;
|
|
|
|
ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
|
2000-10-13 01:57:43 +00:00
|
|
|
}
|
2004-08-24 20:52:52 +00:00
|
|
|
error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
|
|
|
|
(uap->uoss != NULL) ? &oss : NULL);
|
2002-09-01 22:30:27 +00:00
|
|
|
if (!error && uap->uoss != NULL) {
|
|
|
|
lss.ss_sp = oss.ss_sp;
|
|
|
|
lss.ss_size = oss.ss_size;
|
|
|
|
lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
|
2000-08-22 02:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
2002-10-11 11:43:09 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_ftruncate64(struct thread *td, struct linux_ftruncate64_args *args)
|
|
|
|
{
|
|
|
|
struct ftruncate_args sa;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(ftruncate64))
|
2002-10-12 13:48:21 +00:00
|
|
|
printf(ARGS(ftruncate64, "%u, %jd"), args->fd,
|
|
|
|
(intmax_t)args->length);
|
2002-10-11 11:43:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
sa.fd = args->fd;
|
|
|
|
sa.length = args->length;
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_ftruncate(td, &sa);
|
2002-10-11 11:43:09 +00:00
|
|
|
}
|
2004-09-06 09:32:59 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args)
|
|
|
|
{
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
struct l_user_desc info;
|
|
|
|
int error;
|
|
|
|
int idx;
|
|
|
|
int a[2];
|
|
|
|
struct segment_descriptor sd;
|
|
|
|
|
|
|
|
error = copyin(args->desc, &info, sizeof(struct l_user_desc));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(set_thread_area))
|
|
|
|
printf(ARGS(set_thread_area, "%i, %x, %x, %i, %i, %i, %i, %i, %i\n"),
|
|
|
|
info.entry_number,
|
|
|
|
info.base_addr,
|
|
|
|
info.limit,
|
|
|
|
info.seg_32bit,
|
|
|
|
info.contents,
|
|
|
|
info.read_exec_only,
|
|
|
|
info.limit_in_pages,
|
|
|
|
info.seg_not_present,
|
|
|
|
info.useable);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
idx = info.entry_number;
|
2006-08-16 18:54:51 +00:00
|
|
|
/*
|
2007-02-24 16:49:25 +00:00
|
|
|
* Semantics of linux version: every thread in the system has array of
|
|
|
|
* 3 tls descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. This
|
|
|
|
* syscall loads one of the selected tls decriptors with a value and
|
|
|
|
* also loads GDT descriptors 6, 7 and 8 with the content of the
|
|
|
|
* per-thread descriptors.
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
*
|
2007-02-24 16:49:25 +00:00
|
|
|
* Semantics of fbsd version: I think we can ignore that linux has 3
|
|
|
|
* per-thread descriptors and use just the 1st one. The tls_array[]
|
|
|
|
* is used only in set/get-thread_area() syscalls and for loading the
|
|
|
|
* GDT descriptors. In fbsd we use just one GDT descriptor for TLS so
|
|
|
|
* we will load just one.
|
|
|
|
*
|
|
|
|
* XXX: this doesn't work when a user space process tries to use more
|
|
|
|
* than 1 TLS segment. Comment in the linux sources says wine might do
|
|
|
|
* this.
|
2004-09-06 09:32:59 +00:00
|
|
|
*/
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
2006-08-16 18:54:51 +00:00
|
|
|
/*
|
|
|
|
* we support just GLIBC TLS now
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
* we should let 3 proceed as well because we use this segment so
|
|
|
|
* if code does two subsequent calls it should succeed
|
|
|
|
*/
|
|
|
|
if (idx != 6 && idx != -1 && idx != 3)
|
|
|
|
return (EINVAL);
|
|
|
|
|
2006-08-16 18:54:51 +00:00
|
|
|
/*
|
|
|
|
* we have to copy out the GDT entry we use
|
2007-02-24 16:49:25 +00:00
|
|
|
* FreeBSD uses GDT entry #3 for storing %gs so load that
|
|
|
|
*
|
|
|
|
* XXX: what if a user space program doesn't check this value and tries
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
* to use 6, 7 or 8?
|
|
|
|
*/
|
|
|
|
idx = info.entry_number = 3;
|
|
|
|
error = copyout(&info, args->desc, sizeof(struct l_user_desc));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
2007-03-02 00:08:47 +00:00
|
|
|
if (LINUX_LDT_empty(&info)) {
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
a[0] = 0;
|
|
|
|
a[1] = 0;
|
|
|
|
} else {
|
2007-03-02 00:08:47 +00:00
|
|
|
a[0] = LINUX_LDT_entry_a(&info);
|
|
|
|
a[1] = LINUX_LDT_entry_b(&info);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&sd, &a, sizeof(a));
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(set_thread_area))
|
|
|
|
printf("Segment created in set_thread_area: lobase: %x, hibase: %x, lolimit: %x, hilimit: %x, type: %i, dpl: %i, p: %i, xx: %i, def32: %i, gran: %i\n", sd.sd_lobase,
|
|
|
|
sd.sd_hibase,
|
|
|
|
sd.sd_lolimit,
|
|
|
|
sd.sd_hilimit,
|
|
|
|
sd.sd_type,
|
|
|
|
sd.sd_dpl,
|
|
|
|
sd.sd_p,
|
|
|
|
sd.sd_xx,
|
|
|
|
sd.sd_def32,
|
|
|
|
sd.sd_gran);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* this is taken from i386 version of cpu_set_user_tls() */
|
|
|
|
critical_enter();
|
|
|
|
/* set %gs */
|
|
|
|
td->td_pcb->pcb_gsd = sd;
|
|
|
|
PCPU_GET(fsgs_gdt)[1] = sd;
|
|
|
|
load_gs(GSEL(GUGS_SEL, SEL_UPL));
|
|
|
|
critical_exit();
|
|
|
|
|
|
|
|
return (0);
|
2004-09-06 09:32:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
linux_get_thread_area(struct thread *td, struct linux_get_thread_area_args *args)
|
2004-09-06 09:32:59 +00:00
|
|
|
{
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
|
|
|
struct l_user_desc info;
|
|
|
|
int error;
|
|
|
|
int idx;
|
|
|
|
struct l_desc_struct desc;
|
|
|
|
struct segment_descriptor sd;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(get_thread_area))
|
|
|
|
printf(ARGS(get_thread_area, "%p"), args->desc);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
error = copyin(args->desc, &info, sizeof(struct l_user_desc));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
idx = info.entry_number;
|
|
|
|
/* XXX: I am not sure if we want 3 to be allowed too. */
|
|
|
|
if (idx != 6 && idx != 3)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
idx = 3;
|
|
|
|
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
|
|
|
|
sd = PCPU_GET(fsgs_gdt)[1];
|
|
|
|
|
|
|
|
memcpy(&desc, &sd, sizeof(desc));
|
|
|
|
|
|
|
|
info.entry_number = idx;
|
2007-03-02 00:08:47 +00:00
|
|
|
info.base_addr = LINUX_GET_BASE(&desc);
|
|
|
|
info.limit = LINUX_GET_LIMIT(&desc);
|
|
|
|
info.seg_32bit = LINUX_GET_32BIT(&desc);
|
|
|
|
info.contents = LINUX_GET_CONTENTS(&desc);
|
|
|
|
info.read_exec_only = !LINUX_GET_WRITABLE(&desc);
|
|
|
|
info.limit_in_pages = LINUX_GET_LIMIT_PAGES(&desc);
|
|
|
|
info.seg_not_present = !LINUX_GET_PRESENT(&desc);
|
|
|
|
info.useable = LINUX_GET_USEABLE(&desc);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
|
|
|
error = copyout(&info, args->desc, sizeof(struct l_user_desc));
|
|
|
|
if (error)
|
|
|
|
return (EFAULT);
|
2004-09-06 09:32:59 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
/* copied from kern/kern_time.c */
|
|
|
|
int
|
|
|
|
linux_timer_create(struct thread *td, struct linux_timer_create_args *args)
|
|
|
|
{
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_ktimer_create(td, (struct ktimer_create_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_timer_settime(struct thread *td, struct linux_timer_settime_args *args)
|
|
|
|
{
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_ktimer_settime(td, (struct ktimer_settime_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_timer_gettime(struct thread *td, struct linux_timer_gettime_args *args)
|
|
|
|
{
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_ktimer_gettime(td, (struct ktimer_gettime_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_timer_getoverrun(struct thread *td, struct linux_timer_getoverrun_args *args)
|
|
|
|
{
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_ktimer_getoverrun(td, (struct ktimer_getoverrun_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
}
|
|
|
|
|
2004-09-06 09:32:59 +00:00
|
|
|
int
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
linux_timer_delete(struct thread *td, struct linux_timer_delete_args *args)
|
2004-09-06 09:32:59 +00:00
|
|
|
{
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_ktimer_delete(td, (struct ktimer_delete_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: this wont work with module - convert it */
|
|
|
|
int
|
|
|
|
linux_mq_open(struct thread *td, struct linux_mq_open_args *args)
|
|
|
|
{
|
|
|
|
#ifdef P1003_1B_MQUEUE
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_kmq_open(td, (struct kmq_open_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#else
|
|
|
|
return (ENOSYS);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_mq_unlink(struct thread *td, struct linux_mq_unlink_args *args)
|
|
|
|
{
|
|
|
|
#ifdef P1003_1B_MQUEUE
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_kmq_unlink(td, (struct kmq_unlink_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#else
|
|
|
|
return (ENOSYS);
|
|
|
|
#endif
|
|
|
|
}
|
2004-09-06 09:32:59 +00:00
|
|
|
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
int
|
|
|
|
linux_mq_timedsend(struct thread *td, struct linux_mq_timedsend_args *args)
|
|
|
|
{
|
|
|
|
#ifdef P1003_1B_MQUEUE
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_kmq_timedsend(td, (struct kmq_timedsend_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#else
|
|
|
|
return (ENOSYS);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_mq_timedreceive(struct thread *td, struct linux_mq_timedreceive_args *args)
|
|
|
|
{
|
|
|
|
#ifdef P1003_1B_MQUEUE
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_kmq_timedreceive(td, (struct kmq_timedreceive_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#else
|
|
|
|
return (ENOSYS);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_mq_notify(struct thread *td, struct linux_mq_notify_args *args)
|
|
|
|
{
|
|
|
|
#ifdef P1003_1B_MQUEUE
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_kmq_notify(td, (struct kmq_notify_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#else
|
|
|
|
return (ENOSYS);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_mq_getsetattr(struct thread *td, struct linux_mq_getsetattr_args *args)
|
|
|
|
{
|
|
|
|
#ifdef P1003_1B_MQUEUE
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_kmq_setattr(td, (struct kmq_setattr_args *) args);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#else
|
|
|
|
return (ENOSYS);
|
|
|
|
#endif
|
2004-09-06 09:32:59 +00:00
|
|
|
}
|
|
|
|
|
2011-01-28 18:47:07 +00:00
|
|
|
int
|
|
|
|
linux_wait4(struct thread *td, struct linux_wait4_args *args)
|
|
|
|
{
|
|
|
|
int error, options;
|
|
|
|
struct rusage ru, *rup;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(wait4))
|
|
|
|
printf(ARGS(wait4, "%d, %p, %d, %p"),
|
|
|
|
args->pid, (void *)args->status, args->options,
|
|
|
|
(void *)args->rusage);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
options = (args->options & (WNOHANG | WUNTRACED));
|
|
|
|
/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
|
|
|
|
if (args->options & __WCLONE)
|
|
|
|
options |= WLINUXCLONE;
|
|
|
|
|
|
|
|
if (args->rusage != NULL)
|
|
|
|
rup = &ru;
|
|
|
|
else
|
|
|
|
rup = NULL;
|
|
|
|
error = linux_common_wait(td, args->pid, args->status, options, rup);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (args->rusage != NULL)
|
|
|
|
error = copyout(&ru, args->rusage, sizeof(ru));
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|