Add preliminary support for x86-64 Linux binaries.
Differential Revision: https://reviews.freebsd.org/D1076
This commit is contained in:
parent
0edc82b564
commit
b2f587918d
17
sys/amd64/linux/Makefile
Normal file
17
sys/amd64/linux/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
# Makefile for syscall tables
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
all:
|
||||
@echo "make sysent only"
|
||||
|
||||
sysent: linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c
|
||||
|
||||
linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c: \
|
||||
../../kern/makesyscalls.sh syscalls.master syscalls.conf
|
||||
-mv -f linux_sysent.c linux_sysent.c.bak
|
||||
-mv -f linux_syscall.h linux_syscall.h.bak
|
||||
-mv -f linux_proto.h linux_proto.h.bak
|
||||
-mv -f linux_syscalls.c linux_syscalls.c.bak
|
||||
-mv -f linux_systrace_args.c linux_systrace_args.c.bak
|
||||
sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf
|
666
sys/amd64/linux/linux.h
Normal file
666
sys/amd64/linux/linux.h
Normal file
@ -0,0 +1,666 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 Dmitry Chagin
|
||||
* Copyright (c) 1994-1996 Søren Schmidt
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* 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
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _AMD64_LINUX_H_
|
||||
#define _AMD64_LINUX_H_
|
||||
|
||||
#include <amd64/linux/linux_syscall.h>
|
||||
|
||||
/*
|
||||
* debugging support
|
||||
*/
|
||||
extern u_char linux_debug_map[];
|
||||
#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
|
||||
#define ARGS(nm, fmt) "linux(%ld/%ld): "#nm"("fmt")\n", \
|
||||
(long)td->td_proc->p_pid, (long)td->td_tid
|
||||
#define LMSG(fmt) "linux(%ld/%ld): "fmt"\n", \
|
||||
(long)td->td_proc->p_pid, (long)td->td_tid
|
||||
#define LINUX_DTRACE linuxulator
|
||||
|
||||
#define PTRIN(v) (void *)(v)
|
||||
#define PTROUT(v) (uintptr_t)(v)
|
||||
|
||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
||||
#define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0)
|
||||
#define PTRIN_CP(src,dst,fld) \
|
||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
||||
|
||||
/*
|
||||
* Provide a separate set of types for the Linux types.
|
||||
*/
|
||||
typedef int32_t l_int;
|
||||
typedef int64_t l_long;
|
||||
typedef int16_t l_short;
|
||||
typedef uint32_t l_uint;
|
||||
typedef uint64_t l_ulong;
|
||||
typedef uint16_t l_ushort;
|
||||
|
||||
typedef l_ulong l_uintptr_t;
|
||||
typedef l_long l_clock_t;
|
||||
typedef l_int l_daddr_t;
|
||||
typedef l_ulong l_dev_t;
|
||||
typedef l_uint l_gid_t;
|
||||
typedef l_uint l_uid_t;
|
||||
typedef l_ulong l_ino_t;
|
||||
typedef l_int l_key_t;
|
||||
typedef l_long l_loff_t;
|
||||
typedef l_uint l_mode_t;
|
||||
typedef l_long l_off_t;
|
||||
typedef l_int l_pid_t;
|
||||
typedef l_ulong l_size_t;
|
||||
typedef l_long l_ssize_t;
|
||||
typedef l_long l_suseconds_t;
|
||||
typedef l_long l_time_t;
|
||||
typedef l_int l_timer_t;
|
||||
typedef l_int l_mqd_t;
|
||||
typedef l_size_t l_socklen_t;
|
||||
|
||||
typedef struct {
|
||||
l_int val[2];
|
||||
} l_fsid_t;
|
||||
|
||||
typedef struct {
|
||||
l_time_t tv_sec;
|
||||
l_suseconds_t tv_usec;
|
||||
} l_timeval;
|
||||
|
||||
#define l_fd_set fd_set
|
||||
|
||||
/*
|
||||
* Miscellaneous
|
||||
*/
|
||||
#define LINUX_NAME_MAX 255
|
||||
#define LINUX_CTL_MAXNAME 10
|
||||
|
||||
#define LINUX_AT_COUNT 17 /* Count of used aux entry types. */
|
||||
|
||||
struct l___sysctl_args
|
||||
{
|
||||
l_uintptr_t name;
|
||||
l_int nlen;
|
||||
l_uintptr_t oldval;
|
||||
l_uintptr_t oldlenp;
|
||||
l_uintptr_t newval;
|
||||
l_size_t newlen;
|
||||
l_ulong __spare[4];
|
||||
};
|
||||
|
||||
/* Scheduling policies */
|
||||
#define LINUX_SCHED_OTHER 0
|
||||
#define LINUX_SCHED_FIFO 1
|
||||
#define LINUX_SCHED_RR 2
|
||||
|
||||
/* Resource limits */
|
||||
#define LINUX_RLIMIT_CPU 0
|
||||
#define LINUX_RLIMIT_FSIZE 1
|
||||
#define LINUX_RLIMIT_DATA 2
|
||||
#define LINUX_RLIMIT_STACK 3
|
||||
#define LINUX_RLIMIT_CORE 4
|
||||
#define LINUX_RLIMIT_RSS 5
|
||||
#define LINUX_RLIMIT_NPROC 6
|
||||
#define LINUX_RLIMIT_NOFILE 7
|
||||
#define LINUX_RLIMIT_MEMLOCK 8
|
||||
#define LINUX_RLIMIT_AS 9 /* Address space limit */
|
||||
|
||||
#define LINUX_RLIM_NLIMITS 10
|
||||
|
||||
struct l_rlimit {
|
||||
l_ulong rlim_cur;
|
||||
l_ulong rlim_max;
|
||||
};
|
||||
|
||||
/* mmap options */
|
||||
#define LINUX_MAP_SHARED 0x0001
|
||||
#define LINUX_MAP_PRIVATE 0x0002
|
||||
#define LINUX_MAP_FIXED 0x0010
|
||||
#define LINUX_MAP_ANON 0x0020
|
||||
#define LINUX_MAP_GROWSDOWN 0x0100
|
||||
|
||||
/*
|
||||
* stat family of syscalls
|
||||
*/
|
||||
struct l_timespec {
|
||||
l_time_t tv_sec;
|
||||
l_long tv_nsec;
|
||||
};
|
||||
|
||||
struct l_newstat {
|
||||
l_dev_t st_dev;
|
||||
l_ino_t st_ino;
|
||||
l_ulong st_nlink;
|
||||
l_uint st_mode;
|
||||
l_uid_t st_uid;
|
||||
l_gid_t st_gid;
|
||||
l_uint __st_pad1;
|
||||
l_dev_t st_rdev;
|
||||
l_off_t st_size;
|
||||
l_long st_blksize;
|
||||
l_long st_blocks;
|
||||
struct l_timespec st_atim;
|
||||
struct l_timespec st_mtim;
|
||||
struct l_timespec st_ctim;
|
||||
l_long __unused1;
|
||||
l_long __unused2;
|
||||
l_long __unused3;
|
||||
};
|
||||
|
||||
/*
|
||||
* Signalling
|
||||
*/
|
||||
#define LINUX_SIGHUP 1
|
||||
#define LINUX_SIGINT 2
|
||||
#define LINUX_SIGQUIT 3
|
||||
#define LINUX_SIGILL 4
|
||||
#define LINUX_SIGTRAP 5
|
||||
#define LINUX_SIGABRT 6
|
||||
#define LINUX_SIGIOT LINUX_SIGABRT
|
||||
#define LINUX_SIGBUS 7
|
||||
#define LINUX_SIGFPE 8
|
||||
#define LINUX_SIGKILL 9
|
||||
#define LINUX_SIGUSR1 10
|
||||
#define LINUX_SIGSEGV 11
|
||||
#define LINUX_SIGUSR2 12
|
||||
#define LINUX_SIGPIPE 13
|
||||
#define LINUX_SIGALRM 14
|
||||
#define LINUX_SIGTERM 15
|
||||
#define LINUX_SIGSTKFLT 16
|
||||
#define LINUX_SIGCHLD 17
|
||||
#define LINUX_SIGCONT 18
|
||||
#define LINUX_SIGSTOP 19
|
||||
#define LINUX_SIGTSTP 20
|
||||
#define LINUX_SIGTTIN 21
|
||||
#define LINUX_SIGTTOU 22
|
||||
#define LINUX_SIGURG 23
|
||||
#define LINUX_SIGXCPU 24
|
||||
#define LINUX_SIGXFSZ 25
|
||||
#define LINUX_SIGVTALRM 26
|
||||
#define LINUX_SIGPROF 27
|
||||
#define LINUX_SIGWINCH 28
|
||||
#define LINUX_SIGIO 29
|
||||
#define LINUX_SIGPOLL LINUX_SIGIO
|
||||
#define LINUX_SIGPWR 30
|
||||
#define LINUX_SIGSYS 31
|
||||
#define LINUX_SIGRTMIN 32
|
||||
|
||||
#define LINUX_SIGTBLSZ 31
|
||||
#define LINUX_NSIG 64
|
||||
#define LINUX_NBPW 64
|
||||
#define LINUX_NSIG_WORDS (LINUX_NSIG / LINUX_NBPW)
|
||||
|
||||
/* sigaction flags */
|
||||
#define LINUX_SA_NOCLDSTOP 0x00000001
|
||||
#define LINUX_SA_NOCLDWAIT 0x00000002
|
||||
#define LINUX_SA_SIGINFO 0x00000004
|
||||
#define LINUX_SA_RESTORER 0x04000000
|
||||
#define LINUX_SA_ONSTACK 0x08000000
|
||||
#define LINUX_SA_RESTART 0x10000000
|
||||
#define LINUX_SA_INTERRUPT 0x20000000
|
||||
#define LINUX_SA_NOMASK 0x40000000
|
||||
#define LINUX_SA_ONESHOT 0x80000000
|
||||
|
||||
/* sigprocmask actions */
|
||||
#define LINUX_SIG_BLOCK 0
|
||||
#define LINUX_SIG_UNBLOCK 1
|
||||
#define LINUX_SIG_SETMASK 2
|
||||
|
||||
/* primitives to manipulate sigset_t */
|
||||
|
||||
#define LINUX_SIGEMPTYSET(set) \
|
||||
do { \
|
||||
(set).__bits[0] = 0; \
|
||||
} while(0)
|
||||
|
||||
#define LINUX_SIGISMEMBER(set, sig) \
|
||||
(1UL & ((set).__bits[0] >> _SIG_IDX(sig)))
|
||||
|
||||
#define LINUX_SIGADDSET(set, sig) \
|
||||
(set).__bits[0] |= 1UL << _SIG_IDX(sig)
|
||||
|
||||
/* sigaltstack */
|
||||
#define LINUX_MINSIGSTKSZ 2048
|
||||
#define LINUX_SS_ONSTACK 1
|
||||
#define LINUX_SS_DISABLE 2
|
||||
|
||||
int linux_to_bsd_sigaltstack(int lsa);
|
||||
int bsd_to_linux_sigaltstack(int bsa);
|
||||
|
||||
typedef void (*l_handler_t)(l_int);
|
||||
|
||||
typedef struct {
|
||||
l_ulong __bits[LINUX_NSIG_WORDS];
|
||||
} l_sigset_t;
|
||||
|
||||
typedef struct {
|
||||
l_handler_t lsa_handler;
|
||||
l_ulong lsa_flags;
|
||||
l_uintptr_t lsa_restorer;
|
||||
l_sigset_t lsa_mask;
|
||||
} l_sigaction_t;
|
||||
|
||||
typedef struct {
|
||||
l_uintptr_t ss_sp;
|
||||
l_int ss_flags;
|
||||
l_size_t ss_size;
|
||||
} l_stack_t;
|
||||
|
||||
struct l_fpstate {
|
||||
u_int16_t cwd;
|
||||
u_int16_t swd;
|
||||
u_int16_t twd;
|
||||
u_int16_t fop;
|
||||
u_int64_t rip;
|
||||
u_int64_t rdp;
|
||||
u_int32_t mxcsr;
|
||||
u_int32_t mxcsr_mask;
|
||||
u_int32_t st_space[32];
|
||||
u_int32_t xmm_space[64];
|
||||
u_int32_t reserved2[24];
|
||||
};
|
||||
|
||||
struct l_sigcontext {
|
||||
l_ulong sc_r8;
|
||||
l_ulong sc_r9;
|
||||
l_ulong sc_r10;
|
||||
l_ulong sc_r11;
|
||||
l_ulong sc_r12;
|
||||
l_ulong sc_r13;
|
||||
l_ulong sc_r14;
|
||||
l_ulong sc_r15;
|
||||
l_ulong sc_rdi;
|
||||
l_ulong sc_rsi;
|
||||
l_ulong sc_rbp;
|
||||
l_ulong sc_rbx;
|
||||
l_ulong sc_rdx;
|
||||
l_ulong sc_rax;
|
||||
l_ulong sc_rcx;
|
||||
l_ulong sc_rsp;
|
||||
l_ulong sc_rip;
|
||||
l_ulong sc_rflags;
|
||||
l_ushort sc_cs;
|
||||
l_ushort sc_gs;
|
||||
l_ushort sc_fs;
|
||||
l_ushort sc___pad0;
|
||||
l_ulong sc_err;
|
||||
l_ulong sc_trapno;
|
||||
l_sigset_t sc_mask;
|
||||
l_ulong sc_cr2;
|
||||
struct l_fpstate *sc_fpstate;
|
||||
l_ulong sc_reserved1[8];
|
||||
};
|
||||
|
||||
struct l_ucontext {
|
||||
l_ulong uc_flags;
|
||||
l_uintptr_t uc_link;
|
||||
l_stack_t uc_stack;
|
||||
struct l_sigcontext uc_mcontext;
|
||||
l_sigset_t uc_sigmask;
|
||||
};
|
||||
|
||||
#define LINUX_SI_PREAMBLE_SIZE (4 * sizeof(int))
|
||||
#define LINUX_SI_MAX_SIZE 128
|
||||
#define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE - \
|
||||
LINUX_SI_PREAMBLE_SIZE) / sizeof(l_int))
|
||||
typedef union l_sigval {
|
||||
l_int sival_int;
|
||||
l_uintptr_t sival_ptr;
|
||||
} l_sigval_t;
|
||||
|
||||
typedef struct l_siginfo {
|
||||
l_int lsi_signo;
|
||||
l_int lsi_errno;
|
||||
l_int lsi_code;
|
||||
union {
|
||||
l_int _pad[LINUX_SI_PAD_SIZE];
|
||||
|
||||
struct {
|
||||
l_pid_t _pid;
|
||||
l_uid_t _uid;
|
||||
} _kill;
|
||||
|
||||
struct {
|
||||
l_timer_t _tid;
|
||||
l_int _overrun;
|
||||
char _pad[sizeof(l_uid_t) - sizeof(int)];
|
||||
union l_sigval _sigval;
|
||||
l_uint _sys_private;
|
||||
} _timer;
|
||||
|
||||
struct {
|
||||
l_pid_t _pid; /* sender's pid */
|
||||
l_uid_t _uid; /* sender's uid */
|
||||
union l_sigval _sigval;
|
||||
} _rt;
|
||||
|
||||
struct {
|
||||
l_pid_t _pid; /* which child */
|
||||
l_uid_t _uid; /* sender's uid */
|
||||
l_int _status; /* exit code */
|
||||
l_clock_t _utime;
|
||||
l_clock_t _stime;
|
||||
} _sigchld;
|
||||
|
||||
struct {
|
||||
l_uintptr_t _addr; /* Faulting insn/memory ref. */
|
||||
} _sigfault;
|
||||
|
||||
struct {
|
||||
l_long _band; /* POLL_IN,POLL_OUT,POLL_MSG */
|
||||
l_int _fd;
|
||||
} _sigpoll;
|
||||
} _sifields;
|
||||
} l_siginfo_t;
|
||||
|
||||
#define lsi_pid _sifields._kill._pid
|
||||
#define lsi_uid _sifields._kill._uid
|
||||
#define lsi_tid _sifields._timer._tid
|
||||
#define lsi_overrun _sifields._timer._overrun
|
||||
#define lsi_sys_private _sifields._timer._sys_private
|
||||
#define lsi_status _sifields._sigchld._status
|
||||
#define lsi_utime _sifields._sigchld._utime
|
||||
#define lsi_stime _sifields._sigchld._stime
|
||||
#define lsi_value _sifields._rt._sigval
|
||||
#define lsi_int _sifields._rt._sigval.sival_int
|
||||
#define lsi_ptr _sifields._rt._sigval.sival_ptr
|
||||
#define lsi_addr _sifields._sigfault._addr
|
||||
#define lsi_band _sifields._sigpoll._band
|
||||
#define lsi_fd _sifields._sigpoll._fd
|
||||
|
||||
/*
|
||||
* We make the stack look like Linux expects it when calling a signal
|
||||
* handler, but use the BSD way of calling the handler and sigreturn().
|
||||
* This means that we need to pass the pointer to the handler too.
|
||||
* It is appended to the frame to not interfere with the rest of it.
|
||||
*/
|
||||
|
||||
struct l_rt_sigframe {
|
||||
struct l_ucontext sf_sc;
|
||||
struct l_siginfo sf_si;
|
||||
l_handler_t sf_handler;
|
||||
};
|
||||
|
||||
/*
|
||||
* open/fcntl flags
|
||||
*/
|
||||
#define LINUX_O_RDONLY 00000000
|
||||
#define LINUX_O_WRONLY 00000001
|
||||
#define LINUX_O_RDWR 00000002
|
||||
#define LINUX_O_ACCMODE 00000003
|
||||
#define LINUX_O_CREAT 00000100
|
||||
#define LINUX_O_EXCL 00000200
|
||||
#define LINUX_O_NOCTTY 00000400
|
||||
#define LINUX_O_TRUNC 00001000
|
||||
#define LINUX_O_APPEND 00002000
|
||||
#define LINUX_O_NONBLOCK 00004000
|
||||
#define LINUX_O_NDELAY LINUX_O_NONBLOCK
|
||||
#define LINUX_O_SYNC 00010000
|
||||
#define LINUX_FASYNC 00020000
|
||||
#define LINUX_O_DIRECT 00040000 /* Direct disk access hint */
|
||||
#define LINUX_O_LARGEFILE 00100000
|
||||
#define LINUX_O_DIRECTORY 00200000 /* Must be a directory */
|
||||
#define LINUX_O_NOFOLLOW 00400000 /* Do not follow links */
|
||||
#define LINUX_O_NOATIME 01000000
|
||||
#define LINUX_O_CLOEXEC 02000000
|
||||
|
||||
#define LINUX_F_DUPFD 0
|
||||
#define LINUX_F_GETFD 1
|
||||
#define LINUX_F_SETFD 2
|
||||
#define LINUX_F_GETFL 3
|
||||
#define LINUX_F_SETFL 4
|
||||
#define LINUX_F_GETLK 5
|
||||
#define LINUX_F_SETLK 6
|
||||
#define LINUX_F_SETLKW 7
|
||||
#define LINUX_F_SETOWN 8
|
||||
#define LINUX_F_GETOWN 9
|
||||
|
||||
#define LINUX_F_RDLCK 0
|
||||
#define LINUX_F_WRLCK 1
|
||||
#define LINUX_F_UNLCK 2
|
||||
|
||||
/*
|
||||
* mount flags
|
||||
*/
|
||||
#define LINUX_MS_RDONLY 0x0001
|
||||
#define LINUX_MS_NOSUID 0x0002
|
||||
#define LINUX_MS_NODEV 0x0004
|
||||
#define LINUX_MS_NOEXEC 0x0008
|
||||
#define LINUX_MS_REMOUNT 0x0020
|
||||
|
||||
/*
|
||||
* SystemV IPC defines
|
||||
*/
|
||||
#define LINUX_IPC_RMID 0
|
||||
#define LINUX_IPC_SET 1
|
||||
#define LINUX_IPC_STAT 2
|
||||
#define LINUX_IPC_INFO 3
|
||||
|
||||
#define LINUX_SHM_LOCK 11
|
||||
#define LINUX_SHM_UNLOCK 12
|
||||
#define LINUX_SHM_STAT 13
|
||||
#define LINUX_SHM_INFO 14
|
||||
|
||||
#define LINUX_SHM_RDONLY 0x1000
|
||||
#define LINUX_SHM_RND 0x2000
|
||||
#define LINUX_SHM_REMAP 0x4000
|
||||
|
||||
/* semctl commands */
|
||||
#define LINUX_GETPID 11
|
||||
#define LINUX_GETVAL 12
|
||||
#define LINUX_GETALL 13
|
||||
#define LINUX_GETNCNT 14
|
||||
#define LINUX_GETZCNT 15
|
||||
#define LINUX_SETVAL 16
|
||||
#define LINUX_SETALL 17
|
||||
#define LINUX_SEM_STAT 18
|
||||
#define LINUX_SEM_INFO 19
|
||||
|
||||
union l_semun {
|
||||
l_int val;
|
||||
l_uintptr_t buf;
|
||||
l_uintptr_t array;
|
||||
l_uintptr_t __buf;
|
||||
l_uintptr_t __pad;
|
||||
};
|
||||
|
||||
struct l_ipc_perm {
|
||||
l_key_t key;
|
||||
l_uid_t uid;
|
||||
l_gid_t gid;
|
||||
l_uid_t cuid;
|
||||
l_gid_t cgid;
|
||||
l_ushort mode;
|
||||
l_ushort seq;
|
||||
};
|
||||
|
||||
/*
|
||||
* Socket defines
|
||||
*/
|
||||
|
||||
#define LINUX_SOL_SOCKET 1
|
||||
#define LINUX_SOL_IP 0
|
||||
#define LINUX_SOL_IPX 256
|
||||
#define LINUX_SOL_AX25 257
|
||||
#define LINUX_SOL_TCP 6
|
||||
#define LINUX_SOL_UDP 17
|
||||
|
||||
#define LINUX_SO_DEBUG 1
|
||||
#define LINUX_SO_REUSEADDR 2
|
||||
#define LINUX_SO_TYPE 3
|
||||
#define LINUX_SO_ERROR 4
|
||||
#define LINUX_SO_DONTROUTE 5
|
||||
#define LINUX_SO_BROADCAST 6
|
||||
#define LINUX_SO_SNDBUF 7
|
||||
#define LINUX_SO_RCVBUF 8
|
||||
#define LINUX_SO_KEEPALIVE 9
|
||||
#define LINUX_SO_OOBINLINE 10
|
||||
#define LINUX_SO_NO_CHECK 11
|
||||
#define LINUX_SO_PRIORITY 12
|
||||
#define LINUX_SO_LINGER 13
|
||||
#define LINUX_SO_PASSCRED 16
|
||||
#define LINUX_SO_PEERCRED 17
|
||||
#define LINUX_SO_RCVLOWAT 18
|
||||
#define LINUX_SO_SNDLOWAT 19
|
||||
#define LINUX_SO_RCVTIMEO 20
|
||||
#define LINUX_SO_SNDTIMEO 21
|
||||
#define LINUX_SO_TIMESTAMP 29
|
||||
#define LINUX_SO_ACCEPTCONN 30
|
||||
|
||||
#define LINUX_IP_TOS 1
|
||||
#define LINUX_IP_TTL 2
|
||||
#define LINUX_IP_HDRINCL 3
|
||||
#define LINUX_IP_OPTIONS 4
|
||||
|
||||
#define LINUX_IP_MULTICAST_IF 32
|
||||
#define LINUX_IP_MULTICAST_TTL 33
|
||||
#define LINUX_IP_MULTICAST_LOOP 34
|
||||
#define LINUX_IP_ADD_MEMBERSHIP 35
|
||||
#define LINUX_IP_DROP_MEMBERSHIP 36
|
||||
|
||||
struct l_sockaddr {
|
||||
l_ushort sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
struct l_msghdr {
|
||||
l_uintptr_t msg_name;
|
||||
l_int msg_namelen;
|
||||
l_uintptr_t msg_iov;
|
||||
l_size_t msg_iovlen;
|
||||
l_uintptr_t msg_control;
|
||||
l_size_t msg_controllen;
|
||||
l_uint msg_flags;
|
||||
};
|
||||
|
||||
struct l_cmsghdr {
|
||||
l_size_t cmsg_len;
|
||||
l_int cmsg_level;
|
||||
l_int cmsg_type;
|
||||
};
|
||||
|
||||
struct l_ifmap {
|
||||
l_ulong mem_start;
|
||||
l_ulong mem_end;
|
||||
l_ushort base_addr;
|
||||
u_char irq;
|
||||
u_char dma;
|
||||
u_char port;
|
||||
} __packed;
|
||||
|
||||
#define LINUX_IFHWADDRLEN 6
|
||||
#define LINUX_IFNAMSIZ 16
|
||||
|
||||
struct l_ifreq {
|
||||
union {
|
||||
char ifrn_name[LINUX_IFNAMSIZ];
|
||||
} ifr_ifrn;
|
||||
|
||||
union {
|
||||
struct l_sockaddr ifru_addr;
|
||||
struct l_sockaddr ifru_dstaddr;
|
||||
struct l_sockaddr ifru_broadaddr;
|
||||
struct l_sockaddr ifru_netmask;
|
||||
struct l_sockaddr ifru_hwaddr;
|
||||
l_short ifru_flags[1];
|
||||
l_int ifru_metric;
|
||||
l_int ifru_mtu;
|
||||
struct l_ifmap ifru_map;
|
||||
char ifru_slave[LINUX_IFNAMSIZ];
|
||||
l_uintptr_t ifru_data;
|
||||
} ifr_ifru;
|
||||
} __packed;
|
||||
|
||||
#define ifr_name ifr_ifrn.ifrn_name /* Interface name */
|
||||
#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
|
||||
|
||||
struct l_ifconf {
|
||||
int ifc_len;
|
||||
union {
|
||||
l_uintptr_t ifcu_buf;
|
||||
l_uintptr_t ifcu_req;
|
||||
} ifc_ifcu;
|
||||
};
|
||||
|
||||
#define ifc_buf ifc_ifcu.ifcu_buf
|
||||
#define ifc_req ifc_ifcu.ifcu_req
|
||||
|
||||
/*
|
||||
* poll()
|
||||
*/
|
||||
#define LINUX_POLLIN 0x0001
|
||||
#define LINUX_POLLPRI 0x0002
|
||||
#define LINUX_POLLOUT 0x0004
|
||||
#define LINUX_POLLERR 0x0008
|
||||
#define LINUX_POLLHUP 0x0010
|
||||
#define LINUX_POLLNVAL 0x0020
|
||||
#define LINUX_POLLRDNORM 0x0040
|
||||
#define LINUX_POLLRDBAND 0x0080
|
||||
#define LINUX_POLLWRNORM 0x0100
|
||||
#define LINUX_POLLWRBAND 0x0200
|
||||
#define LINUX_POLLMSG 0x0400
|
||||
|
||||
struct l_pollfd {
|
||||
l_int fd;
|
||||
l_short events;
|
||||
l_short revents;
|
||||
};
|
||||
|
||||
|
||||
#define LINUX_CLONE_VM 0x00000100
|
||||
#define LINUX_CLONE_FS 0x00000200
|
||||
#define LINUX_CLONE_FILES 0x00000400
|
||||
#define LINUX_CLONE_SIGHAND 0x00000800
|
||||
#define LINUX_CLONE_PID 0x00001000 /* No longer exist in Linux */
|
||||
#define LINUX_CLONE_VFORK 0x00004000
|
||||
#define LINUX_CLONE_PARENT 0x00008000
|
||||
#define LINUX_CLONE_THREAD 0x00010000
|
||||
#define LINUX_CLONE_SETTLS 0x00080000
|
||||
#define LINUX_CLONE_PARENT_SETTID 0x00100000
|
||||
#define LINUX_CLONE_CHILD_CLEARTID 0x00200000
|
||||
#define LINUX_CLONE_CHILD_SETTID 0x01000000
|
||||
|
||||
#define LINUX_ARCH_SET_GS 0x1001
|
||||
#define LINUX_ARCH_SET_FS 0x1002
|
||||
#define LINUX_ARCH_GET_GS 0x1003
|
||||
#define LINUX_ARCH_GET_FS 0x1004
|
||||
|
||||
#define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r))
|
||||
|
||||
/* robust futexes */
|
||||
struct linux_robust_list {
|
||||
l_uintptr_t next;
|
||||
};
|
||||
|
||||
struct linux_robust_list_head {
|
||||
struct linux_robust_list list;
|
||||
l_long futex_offset;
|
||||
l_uintptr_t pending_list;
|
||||
};
|
||||
|
||||
#endif /* !_AMD64_LINUX_H_ */
|
154
sys/amd64/linux/linux_dummy.c
Normal file
154
sys/amd64/linux/linux_dummy.c
Normal file
@ -0,0 +1,154 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 Dmitry Chagin
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_compat.h"
|
||||
#include "opt_kdtrace.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/sdt.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <amd64/linux/linux.h>
|
||||
#include <amd64/linux/linux_proto.h>
|
||||
#include <compat/linux/linux_dtrace.h>
|
||||
#include <compat/linux/linux_util.h>
|
||||
|
||||
/* DTrace init */
|
||||
LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
|
||||
|
||||
DUMMY(mincore);
|
||||
DUMMY(sendfile);
|
||||
DUMMY(ptrace);
|
||||
DUMMY(syslog);
|
||||
DUMMY(setfsuid);
|
||||
DUMMY(setfsgid);
|
||||
DUMMY(sysfs);
|
||||
DUMMY(vhangup);
|
||||
DUMMY(pivot_root);
|
||||
DUMMY(adjtimex);
|
||||
DUMMY(swapoff);
|
||||
DUMMY(create_module);
|
||||
DUMMY(init_module);
|
||||
DUMMY(delete_module);
|
||||
DUMMY(get_kernel_syms);
|
||||
DUMMY(query_module);
|
||||
DUMMY(quotactl);
|
||||
DUMMY(nfsservctl);
|
||||
DUMMY(getpmsg);
|
||||
DUMMY(putpmsg);
|
||||
DUMMY(afs_syscall);
|
||||
DUMMY(tuxcall);
|
||||
DUMMY(security);
|
||||
DUMMY(set_thread_area);
|
||||
DUMMY(lookup_dcookie);
|
||||
DUMMY(epoll_create);
|
||||
DUMMY(epoll_ctl_old);
|
||||
DUMMY(epoll_wait_old);
|
||||
DUMMY(remap_file_pages);
|
||||
DUMMY(semtimedop);
|
||||
DUMMY(epoll_ctl);
|
||||
DUMMY(epoll_wait);
|
||||
DUMMY(mbind);
|
||||
DUMMY(get_mempolicy);
|
||||
DUMMY(set_mempolicy);
|
||||
DUMMY(mq_open);
|
||||
DUMMY(mq_unlink);
|
||||
DUMMY(mq_timedsend);
|
||||
DUMMY(mq_timedreceive);
|
||||
DUMMY(mq_notify);
|
||||
DUMMY(mq_getsetattr);
|
||||
DUMMY(kexec_load);
|
||||
DUMMY(add_key);
|
||||
DUMMY(request_key);
|
||||
DUMMY(keyctl);
|
||||
DUMMY(ioprio_set);
|
||||
DUMMY(ioprio_get);
|
||||
DUMMY(inotify_init);
|
||||
DUMMY(inotify_add_watch);
|
||||
DUMMY(inotify_rm_watch);
|
||||
DUMMY(migrate_pages);
|
||||
DUMMY(ppoll);
|
||||
DUMMY(unshare);
|
||||
DUMMY(splice);
|
||||
DUMMY(tee);
|
||||
DUMMY(sync_file_range);
|
||||
DUMMY(vmsplice);
|
||||
DUMMY(move_pages);
|
||||
DUMMY(utimensat);
|
||||
DUMMY(epoll_pwait);
|
||||
DUMMY(signalfd);
|
||||
DUMMY(timerfd);
|
||||
DUMMY(eventfd);
|
||||
DUMMY(fallocate);
|
||||
DUMMY(timerfd_settime);
|
||||
DUMMY(timerfd_gettime);
|
||||
DUMMY(signalfd4);
|
||||
DUMMY(eventfd2);
|
||||
DUMMY(epoll_create1);
|
||||
DUMMY(inotify_init1);
|
||||
DUMMY(preadv);
|
||||
DUMMY(pwritev);
|
||||
DUMMY(rt_tsigqueueinfo);
|
||||
DUMMY(perf_event_open);
|
||||
DUMMY(recvmmsg);
|
||||
DUMMY(fanotify_init);
|
||||
DUMMY(fanotify_mark);
|
||||
DUMMY(name_to_handle_at);
|
||||
DUMMY(open_by_handle_at);
|
||||
DUMMY(clock_adjtime);
|
||||
DUMMY(syncfs);
|
||||
DUMMY(sendmmsg);
|
||||
DUMMY(setns);
|
||||
DUMMY(process_vm_readv);
|
||||
DUMMY(process_vm_writev);
|
||||
DUMMY(kcmp);
|
||||
DUMMY(finit_module);
|
||||
|
||||
#define DUMMY_XATTR(s) \
|
||||
int \
|
||||
linux_ ## s ## xattr( \
|
||||
struct thread *td, struct linux_ ## s ## xattr_args *arg) \
|
||||
{ \
|
||||
\
|
||||
return (ENOATTR); \
|
||||
}
|
||||
DUMMY_XATTR(set);
|
||||
DUMMY_XATTR(lset);
|
||||
DUMMY_XATTR(fset);
|
||||
DUMMY_XATTR(get);
|
||||
DUMMY_XATTR(lget);
|
||||
DUMMY_XATTR(fget);
|
||||
DUMMY_XATTR(list);
|
||||
DUMMY_XATTR(llist);
|
||||
DUMMY_XATTR(flist);
|
||||
DUMMY_XATTR(remove);
|
||||
DUMMY_XATTR(lremove);
|
||||
DUMMY_XATTR(fremove);
|
15
sys/amd64/linux/linux_genassym.c
Normal file
15
sys/amd64/linux/linux_genassym.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/assym.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <amd64/linux/linux.h>
|
||||
#include <compat/linux/linux_mib.h>
|
||||
|
||||
ASSYM(LINUX_RT_SIGF_HANDLER, offsetof(struct l_rt_sigframe, sf_handler));
|
||||
ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_sc));
|
||||
ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext));
|
||||
ASSYM(LINUX_VERSION_CODE, LINUX_VERSION_CODE);
|
||||
ASSYM(LINUX_SC_RSP, offsetof(struct l_sigcontext, sc_rsp));
|
142
sys/amd64/linux/linux_ipc64.h
Normal file
142
sys/amd64/linux/linux_ipc64.h
Normal file
@ -0,0 +1,142 @@
|
||||
/*-
|
||||
* Copyright (c) 2002 Maxim Sobolev <sobomax@FreeBSD.org>
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* 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
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _AMD64_LINUX_LINUX_IPC64_H_
|
||||
#define _AMD64_LINUX_LINUX_IPC64_H_
|
||||
|
||||
/*
|
||||
* The ipc64_perm structure for i386 architecture.
|
||||
* Note extra padding because this structure is passed back and forth
|
||||
* between kernel and user space.
|
||||
*
|
||||
* Pad space is left for:
|
||||
* - 32-bit mode_t and seq
|
||||
* - 2 miscellaneous 32-bit values
|
||||
*/
|
||||
|
||||
struct l_ipc64_perm
|
||||
{
|
||||
l_key_t key;
|
||||
l_uid_t uid;
|
||||
l_gid_t gid;
|
||||
l_uid_t cuid;
|
||||
l_gid_t cgid;
|
||||
l_mode_t mode;
|
||||
l_ushort __pad1;
|
||||
l_ushort seq;
|
||||
l_ushort __pad2;
|
||||
l_ulong __unused1;
|
||||
l_ulong __unused2;
|
||||
};
|
||||
|
||||
/*
|
||||
* The msqid64_ds structure for i386 architecture.
|
||||
* Note extra padding because this structure is passed back and forth
|
||||
* between kernel and user space.
|
||||
*
|
||||
* Pad space is left for:
|
||||
* - 64-bit time_t to solve y2038 problem
|
||||
* - 2 miscellaneous 32-bit values
|
||||
*/
|
||||
|
||||
struct l_msqid64_ds {
|
||||
struct l_ipc64_perm msg_perm;
|
||||
l_time_t msg_stime; /* last msgsnd time */
|
||||
l_ulong __unused1;
|
||||
l_time_t msg_rtime; /* last msgrcv time */
|
||||
l_ulong __unused2;
|
||||
l_time_t msg_ctime; /* last change time */
|
||||
l_ulong __unused3;
|
||||
l_ulong msg_cbytes; /* current number of bytes on queue */
|
||||
l_ulong msg_qnum; /* number of messages in queue */
|
||||
l_ulong msg_qbytes; /* max number of bytes on queue */
|
||||
l_pid_t msg_lspid; /* pid of last msgsnd */
|
||||
l_pid_t msg_lrpid; /* last receive pid */
|
||||
l_ulong __unused4;
|
||||
l_ulong __unused5;
|
||||
};
|
||||
|
||||
/*
|
||||
* The semid64_ds structure for i386 architecture.
|
||||
* Note extra padding because this structure is passed back and forth
|
||||
* between kernel and user space.
|
||||
*
|
||||
* Pad space is left for:
|
||||
* - 64-bit time_t to solve y2038 problem
|
||||
* - 2 miscellaneous 32-bit values
|
||||
*/
|
||||
|
||||
struct l_semid64_ds {
|
||||
struct l_ipc64_perm sem_perm; /* permissions */
|
||||
l_time_t sem_otime; /* last semop time */
|
||||
l_ulong __unused1;
|
||||
l_time_t sem_ctime; /* last change time */
|
||||
l_ulong __unused2;
|
||||
l_ulong sem_nsems; /* no. of semaphores in array */
|
||||
l_ulong __unused3;
|
||||
l_ulong __unused4;
|
||||
};
|
||||
|
||||
/*
|
||||
* The shmid64_ds structure for i386 architecture.
|
||||
* Note extra padding because this structure is passed back and forth
|
||||
* between kernel and user space.
|
||||
*
|
||||
* Pad space is left for:
|
||||
* - 64-bit time_t to solve y2038 problem
|
||||
* - 2 miscellaneous 32-bit values
|
||||
*/
|
||||
|
||||
struct l_shmid64_ds {
|
||||
struct l_ipc64_perm shm_perm; /* operation perms */
|
||||
l_size_t shm_segsz; /* size of segment (bytes) */
|
||||
l_time_t shm_atime; /* last attach time */
|
||||
l_time_t shm_dtime; /* last detach time */
|
||||
l_time_t shm_ctime; /* last change time */
|
||||
l_pid_t shm_cpid; /* pid of creator */
|
||||
l_pid_t shm_lpid; /* pid of last operator */
|
||||
l_ulong shm_nattch; /* no. of current attaches */
|
||||
l_ulong __unused4;
|
||||
l_ulong __unused5;
|
||||
};
|
||||
|
||||
struct l_shminfo64 {
|
||||
l_ulong shmmax;
|
||||
l_ulong shmmin;
|
||||
l_ulong shmmni;
|
||||
l_ulong shmseg;
|
||||
l_ulong shmall;
|
||||
l_ulong __unused1;
|
||||
l_ulong __unused2;
|
||||
l_ulong __unused3;
|
||||
l_ulong __unused4;
|
||||
};
|
||||
|
||||
#endif /* !_AMD64_LINUX_LINUX_IPC64_H_ */
|
75
sys/amd64/linux/linux_locore.s
Normal file
75
sys/amd64/linux/linux_locore.s
Normal file
@ -0,0 +1,75 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#include "linux_assym.h" /* system definitions */
|
||||
#include <machine/asmacros.h> /* miscellaneous asm macros */
|
||||
|
||||
#include <amd64/linux/linux_syscall.h> /* system call numbers */
|
||||
|
||||
.data
|
||||
|
||||
.globl linux_platform
|
||||
linux_platform:
|
||||
.asciz "x86_64"
|
||||
|
||||
|
||||
.text
|
||||
/*
|
||||
* To avoid excess stack frame the signal trampoline code emulates
|
||||
* the 'call' instruction.
|
||||
*/
|
||||
NON_GPROF_ENTRY(linux_rt_sigcode)
|
||||
movq %rsp, %rbx /* preserve sigframe */
|
||||
call .getip
|
||||
.getip:
|
||||
popq %rax
|
||||
add $.startrtsigcode-.getip, %rax /* ret address */
|
||||
pushq %rax
|
||||
jmp *LINUX_RT_SIGF_HANDLER(%rbx)
|
||||
.startrtsigcode:
|
||||
movq $LINUX_SYS_linux_rt_sigreturn,%rax /* linux_rt_sigreturn() */
|
||||
syscall /* enter kernel with args */
|
||||
hlt
|
||||
0: jmp 0b
|
||||
|
||||
NON_GPROF_ENTRY(__vdso_clock_gettime)
|
||||
movq $LINUX_SYS_linux_clock_gettime,%rax
|
||||
syscall
|
||||
ret
|
||||
.weak clock_gettime
|
||||
.set clock_gettime, __vdso_clock_gettime
|
||||
|
||||
NON_GPROF_ENTRY(__vdso_time)
|
||||
movq $LINUX_SYS_linux_time,%rax
|
||||
syscall
|
||||
ret
|
||||
.weak time
|
||||
.set time, __vdso_time
|
||||
|
||||
NON_GPROF_ENTRY(__vdso_gettimeofday)
|
||||
movq $LINUX_SYS_gettimeofday,%rax
|
||||
syscall
|
||||
ret
|
||||
.weak gettimeofday
|
||||
.set gettimeofday, __vdso_gettimeofday
|
||||
|
||||
NON_GPROF_ENTRY(__vdso_getcpu)
|
||||
movq $-38,%rax /* not implemented */
|
||||
ret
|
||||
.weak getcpu
|
||||
.set getcpu, __vdso_getcpu
|
||||
|
||||
|
||||
.section .note.Linux, "a",@note
|
||||
.long 2f - 1f /* namesz */
|
||||
.balign 4
|
||||
.long 4f - 3f /* descsz */
|
||||
.long 0
|
||||
1:
|
||||
.asciz "Linux"
|
||||
2:
|
||||
.balign 4
|
||||
3:
|
||||
.long LINUX_VERSION_CODE
|
||||
4:
|
||||
.balign 4
|
||||
.previous
|
492
sys/amd64/linux/linux_machdep.c
Normal file
492
sys/amd64/linux/linux_machdep.c
Normal file
@ -0,0 +1,492 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 Dmitry Chagin
|
||||
* Copyright (c) 2004 Tim J. Robbins
|
||||
* Copyright (c) 2002 Doug Rabson
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* 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
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/capability.h>
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/clock.h>
|
||||
#include <sys/imgact.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/sched.h>
|
||||
#include <sys/syscallsubr.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <security/mac/mac_framework.h>
|
||||
|
||||
#include <ufs/ufs/extattr.h>
|
||||
#include <ufs/ufs/quota.h>
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/md_var.h>
|
||||
#include <machine/pcb.h>
|
||||
#include <machine/psl.h>
|
||||
#include <machine/segments.h>
|
||||
#include <machine/specialreg.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
#include <vm/vm_extern.h>
|
||||
#include <vm/vm_kern.h>
|
||||
#include <vm/vm_map.h>
|
||||
|
||||
#include <amd64/linux/linux.h>
|
||||
#include <amd64/linux/linux_proto.h>
|
||||
#include <compat/linux/linux_ipc.h>
|
||||
#include <compat/linux/linux_file.h>
|
||||
#include <compat/linux/linux_misc.h>
|
||||
#include <compat/linux/linux_signal.h>
|
||||
#include <compat/linux/linux_util.h>
|
||||
#include <compat/linux/linux_emul.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int
|
||||
linux_execve(struct thread *td, struct linux_execve_args *args)
|
||||
{
|
||||
struct image_args eargs;
|
||||
char *path;
|
||||
int error;
|
||||
|
||||
LCONVPATHEXIST(td, args->path, &path);
|
||||
|
||||
LINUX_CTR(execve);
|
||||
|
||||
error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, args->argp,
|
||||
args->envp);
|
||||
free(path, M_TEMP);
|
||||
if (error == 0)
|
||||
error = linux_common_execve(td, &eargs);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
linux_set_upcall_kse(struct thread *td, register_t stack)
|
||||
{
|
||||
|
||||
if (stack)
|
||||
td->td_frame->tf_rsp = stack;
|
||||
|
||||
/*
|
||||
* The newly created Linux thread returns
|
||||
* to the user space by the same path that a parent do.
|
||||
*/
|
||||
td->td_frame->tf_rax = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
#define STACK_SIZE (2 * 1024 * 1024)
|
||||
#define GUARD_SIZE (4 * PAGE_SIZE)
|
||||
|
||||
int
|
||||
linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
|
||||
{
|
||||
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;
|
||||
int error;
|
||||
struct file *fp;
|
||||
cap_rights_t rights;
|
||||
|
||||
LINUX_CTR6(mmap2, "0x%lx, %ld, %ld, 0x%08lx, %ld, 0x%lx",
|
||||
args->addr, args->len, args->prot,
|
||||
args->flags, args->fd, args->pgoff);
|
||||
|
||||
error = 0;
|
||||
bsd_args.flags = 0;
|
||||
fp = NULL;
|
||||
|
||||
/*
|
||||
* Linux mmap(2):
|
||||
* You must specify exactly one of MAP_SHARED and MAP_PRIVATE
|
||||
*/
|
||||
if (! ((args->flags & LINUX_MAP_SHARED) ^
|
||||
(args->flags & LINUX_MAP_PRIVATE)))
|
||||
return (EINVAL);
|
||||
|
||||
if (args->flags & LINUX_MAP_SHARED)
|
||||
bsd_args.flags |= MAP_SHARED;
|
||||
if (args->flags & LINUX_MAP_PRIVATE)
|
||||
bsd_args.flags |= MAP_PRIVATE;
|
||||
if (args->flags & LINUX_MAP_FIXED)
|
||||
bsd_args.flags |= MAP_FIXED;
|
||||
if (args->flags & LINUX_MAP_ANON)
|
||||
bsd_args.flags |= MAP_ANON;
|
||||
else
|
||||
bsd_args.flags |= MAP_NOSYNC;
|
||||
if (args->flags & LINUX_MAP_GROWSDOWN)
|
||||
bsd_args.flags |= MAP_STACK;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
bsd_args.prot = args->prot;
|
||||
if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
|
||||
bsd_args.prot |= PROT_READ | PROT_EXEC;
|
||||
|
||||
/* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
|
||||
bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : args->fd;
|
||||
if (bsd_args.fd != -1) {
|
||||
/*
|
||||
* Linux follows Solaris mmap(2) description:
|
||||
* The file descriptor fildes is opened with
|
||||
* read permission, regardless of the
|
||||
* protection options specified.
|
||||
*/
|
||||
|
||||
error = fget(td, bsd_args.fd,
|
||||
cap_rights_init(&rights, CAP_MMAP), &fp);
|
||||
if (error != 0 )
|
||||
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);
|
||||
}
|
||||
|
||||
if (args->flags & LINUX_MAP_GROWSDOWN) {
|
||||
/*
|
||||
* The Linux MAP_GROWSDOWN option does not limit auto
|
||||
* 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 then maps the top SGROWSIZ bytes,
|
||||
* and auto grows the region down, up to the limit
|
||||
* 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).
|
||||
*/
|
||||
|
||||
if ((caddr_t)PTRIN(args->addr) + args->len >
|
||||
p->p_vmspace->vm_maxsaddr) {
|
||||
/*
|
||||
* Some Linux apps will attempt to mmap
|
||||
* 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.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
p->p_vmspace->vm_maxsaddr = (char *)USRSTACK -
|
||||
lim_cur(p, RLIMIT_STACK);
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
if (args->len > STACK_SIZE - GUARD_SIZE) {
|
||||
bsd_args.addr = (caddr_t)PTRIN(args->addr);
|
||||
bsd_args.len = args->len;
|
||||
} else {
|
||||
bsd_args.addr = (caddr_t)PTRIN(args->addr) -
|
||||
(STACK_SIZE - GUARD_SIZE - args->len);
|
||||
bsd_args.len = STACK_SIZE - GUARD_SIZE;
|
||||
}
|
||||
} else {
|
||||
bsd_args.addr = (caddr_t)PTRIN(args->addr);
|
||||
bsd_args.len = args->len;
|
||||
}
|
||||
bsd_args.pos = (off_t)args->pgoff;
|
||||
|
||||
error = sys_mmap(td, &bsd_args);
|
||||
|
||||
LINUX_CTR2(mmap2, "return: %d (%p)",
|
||||
error, td->td_retval[0]);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
|
||||
{
|
||||
struct mprotect_args bsd_args;
|
||||
|
||||
LINUX_CTR(mprotect);
|
||||
|
||||
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;
|
||||
return (sys_mprotect(td, &bsd_args));
|
||||
}
|
||||
|
||||
int
|
||||
linux_iopl(struct thread *td, struct linux_iopl_args *args)
|
||||
{
|
||||
int error;
|
||||
|
||||
LINUX_CTR(iopl);
|
||||
|
||||
if (args->level > 3)
|
||||
return (EINVAL);
|
||||
if ((error = priv_check(td, PRIV_IO)) != 0)
|
||||
return (error);
|
||||
if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
|
||||
return (error);
|
||||
td->td_frame->tf_rflags = (td->td_frame->tf_rflags & ~PSL_IOPL) |
|
||||
(args->level * (PSL_IOPL / 3));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)
|
||||
{
|
||||
l_sigset_t lmask;
|
||||
sigset_t sigmask;
|
||||
int error;
|
||||
|
||||
LINUX_CTR2(rt_sigsuspend, "%p, %ld",
|
||||
uap->newset, uap->sigsetsize);
|
||||
|
||||
if (uap->sigsetsize != sizeof(l_sigset_t))
|
||||
return (EINVAL);
|
||||
|
||||
error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
linux_to_bsd_sigset(&lmask, &sigmask);
|
||||
return (kern_sigsuspend(td, sigmask));
|
||||
}
|
||||
|
||||
int
|
||||
linux_pause(struct thread *td, struct linux_pause_args *args)
|
||||
{
|
||||
struct proc *p = td->td_proc;
|
||||
sigset_t sigmask;
|
||||
|
||||
LINUX_CTR(pause);
|
||||
|
||||
PROC_LOCK(p);
|
||||
sigmask = td->td_sigmask;
|
||||
PROC_UNLOCK(p);
|
||||
return (kern_sigsuspend(td, sigmask));
|
||||
}
|
||||
|
||||
int
|
||||
linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
|
||||
{
|
||||
stack_t ss, oss;
|
||||
l_stack_t lss;
|
||||
int error;
|
||||
|
||||
LINUX_CTR2(sigaltstack, "%p, %p", uap->uss, uap->uoss);
|
||||
|
||||
if (uap->uss != NULL) {
|
||||
error = copyin(uap->uss, &lss, sizeof(l_stack_t));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
ss.ss_sp = PTRIN(lss.ss_sp);
|
||||
ss.ss_size = lss.ss_size;
|
||||
ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
|
||||
}
|
||||
error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
|
||||
(uap->uoss != NULL) ? &oss : NULL);
|
||||
if (!error && uap->uoss != NULL) {
|
||||
lss.ss_sp = PTROUT(oss.ss_sp);
|
||||
lss.ss_size = oss.ss_size;
|
||||
lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
|
||||
error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* XXX do all */
|
||||
int
|
||||
linux_arch_prctl(struct thread *td, struct linux_arch_prctl_args *args)
|
||||
{
|
||||
int error;
|
||||
struct pcb *pcb;
|
||||
|
||||
LINUX_CTR2(arch_prctl, "0x%x, %p", args->code, args->addr);
|
||||
|
||||
error = ENOTSUP;
|
||||
pcb = td->td_pcb;
|
||||
|
||||
switch (args->code) {
|
||||
case LINUX_ARCH_GET_GS:
|
||||
error = copyout(&pcb->pcb_gsbase, (unsigned long *)args->addr,
|
||||
sizeof(args->addr));
|
||||
break;
|
||||
case LINUX_ARCH_SET_GS:
|
||||
if (args->addr >= VM_MAXUSER_ADDRESS)
|
||||
return(EPERM);
|
||||
break;
|
||||
case LINUX_ARCH_GET_FS:
|
||||
error = copyout(&pcb->pcb_fsbase, (unsigned long *)args->addr,
|
||||
sizeof(args->addr));
|
||||
break;
|
||||
case LINUX_ARCH_SET_FS:
|
||||
error = linux_set_cloned_tls(td, (void *)args->addr);
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
linux_set_cloned_tls(struct thread *td, void *desc)
|
||||
{
|
||||
struct pcb *pcb;
|
||||
|
||||
if ((uint64_t)desc >= VM_MAXUSER_ADDRESS)
|
||||
return (EPERM);
|
||||
|
||||
pcb = td->td_pcb;
|
||||
pcb->pcb_fsbase = (register_t)desc;
|
||||
td->td_frame->tf_fs = _ufssel;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
linux_to_bsd_sigset(l_sigset_t *lss, sigset_t *bss)
|
||||
{
|
||||
int b, l;
|
||||
|
||||
SIGEMPTYSET(*bss);
|
||||
for (l = 1; l <= LINUX_NSIG; l++) {
|
||||
if (LINUX_SIGISMEMBER(*lss, l)) {
|
||||
if (l <= LINUX_SIGTBLSZ)
|
||||
b = linux_to_bsd_signal[_SIG_IDX(l)];
|
||||
else
|
||||
b = l;
|
||||
if (b)
|
||||
SIGADDSET(*bss, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bsd_to_linux_sigset(sigset_t *bss, l_sigset_t *lss)
|
||||
{
|
||||
int b, l;
|
||||
|
||||
LINUX_SIGEMPTYSET(*lss);
|
||||
for (b = 1; b <= LINUX_NSIG; b++) {
|
||||
if (SIGISMEMBER(*bss, b)) {
|
||||
if (b <= LINUX_SIGTBLSZ)
|
||||
l = bsd_to_linux_signal[_SIG_IDX(b)];
|
||||
else
|
||||
l = b;
|
||||
if (l)
|
||||
LINUX_SIGADDSET(*lss, l);
|
||||
}
|
||||
}
|
||||
}
|
124
sys/amd64/linux/linux_support.s
Normal file
124
sys/amd64/linux/linux_support.s
Normal file
@ -0,0 +1,124 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Konstantin Belousov
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "linux_assym.h" /* system definitions */
|
||||
#include <machine/asmacros.h> /* miscellaneous asm macros */
|
||||
|
||||
#include "assym.s"
|
||||
|
||||
futex_fault:
|
||||
movq $0,PCB_ONFAULT(%r8)
|
||||
movl $-EFAULT,%eax
|
||||
ret
|
||||
|
||||
ENTRY(futex_xchgl)
|
||||
movq PCPU(CURPCB),%r8
|
||||
movq $futex_fault,PCB_ONFAULT(%r8)
|
||||
movq $VM_MAXUSER_ADDRESS-4,%rax
|
||||
cmpq %rax,%rsi
|
||||
ja futex_fault
|
||||
xchgq %rdi,(%rsi)
|
||||
movq %rdi,(%rdx)
|
||||
xorq %rax,%rax
|
||||
movq %rax,PCB_ONFAULT(%r8)
|
||||
ret
|
||||
|
||||
ENTRY(futex_addl)
|
||||
movq PCPU(CURPCB),%r8
|
||||
movq $futex_fault,PCB_ONFAULT(%r8)
|
||||
movq $VM_MAXUSER_ADDRESS-4,%rax
|
||||
cmpq %rax,%rsi
|
||||
ja futex_fault
|
||||
#ifdef SMP
|
||||
lock
|
||||
#endif
|
||||
xaddq %rdi,(%rsi)
|
||||
movq %rdi,(%rdx)
|
||||
xorq %rax,%rax
|
||||
movq %rax,PCB_ONFAULT(%r8)
|
||||
ret
|
||||
|
||||
ENTRY(futex_orl)
|
||||
movq PCPU(CURPCB),%r8
|
||||
movq $futex_fault,PCB_ONFAULT(%r8)
|
||||
movq $VM_MAXUSER_ADDRESS-4,%rax
|
||||
cmpq %rax,%rsi
|
||||
ja futex_fault
|
||||
movq (%rsi),%rax
|
||||
1: movq %rax,%rcx
|
||||
orq %rdi,%rcx
|
||||
#ifdef SMP
|
||||
lock
|
||||
#endif
|
||||
cmpxchgq %rcx,(%rsi)
|
||||
jnz 1b
|
||||
movq %rax,(%rdx)
|
||||
xorq %rax,%rax
|
||||
movq %rax,PCB_ONFAULT(%r8)
|
||||
ret
|
||||
|
||||
ENTRY(futex_andl)
|
||||
movq PCPU(CURPCB),%r8
|
||||
movq $futex_fault,PCB_ONFAULT(%r8)
|
||||
movq $VM_MAXUSER_ADDRESS-4,%rax
|
||||
cmpq %rax,%rsi
|
||||
ja futex_fault
|
||||
movq (%rsi),%rax
|
||||
1: movq %rax,%rcx
|
||||
andq %rdi,%rcx
|
||||
#ifdef SMP
|
||||
lock
|
||||
#endif
|
||||
cmpxchgq %rcx,(%rsi)
|
||||
jnz 1b
|
||||
movq %rax,(%rdx)
|
||||
xorq %rax,%rax
|
||||
movq %rax,PCB_ONFAULT(%r8)
|
||||
ret
|
||||
|
||||
ENTRY(futex_xorl)
|
||||
movq PCPU(CURPCB),%r8
|
||||
movq $futex_fault,PCB_ONFAULT(%r8)
|
||||
movq $VM_MAXUSER_ADDRESS-4,%rax
|
||||
cmpq %rax,%rsi
|
||||
ja futex_fault
|
||||
movq (%rsi),%rax
|
||||
1: movq %rax,%rcx
|
||||
xorq %rdi,%rcx
|
||||
#ifdef SMP
|
||||
lock
|
||||
#endif
|
||||
cmpxchgq %rcx,(%rsi)
|
||||
jnz 1b
|
||||
movq %rax,(%rdx)
|
||||
xorq %rax,%rax
|
||||
movq %rax,PCB_ONFAULT(%r8)
|
||||
ret
|
942
sys/amd64/linux/linux_sysvec.c
Normal file
942
sys/amd64/linux/linux_sysvec.c
Normal file
@ -0,0 +1,942 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 Dmitry Chagin
|
||||
* Copyright (c) 2004 Tim J. Robbins
|
||||
* Copyright (c) 2003 Peter Wemm
|
||||
* Copyright (c) 2002 Doug Rabson
|
||||
* Copyright (c) 1998-1999 Andrew Gallatin
|
||||
* Copyright (c) 1994-1996 Søren Schmidt
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* 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
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_compat.h"
|
||||
|
||||
#define __ELF_WORD_SIZE 64
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/imgact.h>
|
||||
#include <sys/imgact_elf.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/syscallsubr.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/eventhandler.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
#include <vm/vm_extern.h>
|
||||
#include <vm/vm_map.h>
|
||||
#include <vm/vm_object.h>
|
||||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_param.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/md_var.h>
|
||||
#include <machine/pcb.h>
|
||||
#include <machine/specialreg.h>
|
||||
|
||||
#include <amd64/linux/linux.h>
|
||||
#include <amd64/linux/linux_proto.h>
|
||||
#include <compat/linux/linux_emul.h>
|
||||
#include <compat/linux/linux_futex.h>
|
||||
#include <compat/linux/linux_ioctl.h>
|
||||
#include <compat/linux/linux_mib.h>
|
||||
#include <compat/linux/linux_misc.h>
|
||||
#include <compat/linux/linux_signal.h>
|
||||
#include <compat/linux/linux_sysproto.h>
|
||||
#include <compat/linux/linux_util.h>
|
||||
#include <compat/linux/linux_vdso.h>
|
||||
|
||||
MODULE_VERSION(linux64, 1);
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#define SHELLMAGIC 0x2123 /* #! */
|
||||
#else
|
||||
#define SHELLMAGIC 0x2321
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
SYSCTL_PROC(_compat_linux, OID_AUTO, debug,
|
||||
CTLTYPE_STRING | CTLFLAG_RW,
|
||||
0, 0, linux_sysctl_debug, "A",
|
||||
"Linux 64 debugging control");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allow the this functions to use the ldebug() facility
|
||||
* even though they are not syscalls themselves. Map them
|
||||
* to syscall 0. This is slightly less bogus than using
|
||||
* ldebug(sigreturn).
|
||||
*/
|
||||
#define LINUX_SYS_linux_rt_sendsig 0
|
||||
|
||||
const char *linux_kplatform;
|
||||
static int linux_szsigcode;
|
||||
static vm_object_t linux_shared_page_obj;
|
||||
static char *linux_shared_page_mapping;
|
||||
extern char _binary_linux_locore_o_start;
|
||||
extern char _binary_linux_locore_o_end;
|
||||
|
||||
extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
|
||||
|
||||
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
|
||||
|
||||
static register_t * linux_copyout_strings(struct image_params *imgp);
|
||||
static int elf_linux_fixup(register_t **stack_base,
|
||||
struct image_params *iparams);
|
||||
static boolean_t linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
|
||||
static void linux_vdso_install(void *param);
|
||||
static void linux_vdso_deinstall(void *param);
|
||||
static void linux_set_syscall_retval(struct thread *td, int error);
|
||||
static int linux_fetch_syscall_args(struct thread *td, struct syscall_args *sa);
|
||||
static void linux_exec_setregs(struct thread *td, struct image_params *imgp,
|
||||
u_long stack);
|
||||
|
||||
/*
|
||||
* Linux syscalls return negative errno's, we do positive and map them
|
||||
* Reference:
|
||||
* FreeBSD: src/sys/sys/errno.h
|
||||
* Linux: linux-2.6.17.8/include/asm-generic/errno-base.h
|
||||
* linux-2.6.17.8/include/asm-generic/errno.h
|
||||
*/
|
||||
static int bsd_to_linux_errno[ELAST + 1] = {
|
||||
-0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
|
||||
-10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
|
||||
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
|
||||
-30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
|
||||
-90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
|
||||
-100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
|
||||
-110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
|
||||
-116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
|
||||
-6, -6, -43, -42, -75,-125, -84, -95, -16, -74,
|
||||
-72, -67, -71
|
||||
};
|
||||
|
||||
int bsd_to_linux_signal[LINUX_SIGTBLSZ] = {
|
||||
LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL,
|
||||
LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE,
|
||||
LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, LINUX_SIGSYS,
|
||||
LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG,
|
||||
LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD,
|
||||
LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU,
|
||||
LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH,
|
||||
0, LINUX_SIGUSR1, LINUX_SIGUSR2
|
||||
};
|
||||
|
||||
int linux_to_bsd_signal[LINUX_SIGTBLSZ] = {
|
||||
SIGHUP, SIGINT, SIGQUIT, SIGILL,
|
||||
SIGTRAP, SIGABRT, SIGBUS, SIGFPE,
|
||||
SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2,
|
||||
SIGPIPE, SIGALRM, SIGTERM, SIGBUS,
|
||||
SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP,
|
||||
SIGTTIN, SIGTTOU, SIGURG, SIGXCPU,
|
||||
SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH,
|
||||
SIGIO, SIGURG, SIGSYS
|
||||
};
|
||||
|
||||
#define LINUX_T_UNKNOWN 255
|
||||
static int _bsd_to_linux_trapcode[] = {
|
||||
LINUX_T_UNKNOWN, /* 0 */
|
||||
6, /* 1 T_PRIVINFLT */
|
||||
LINUX_T_UNKNOWN, /* 2 */
|
||||
3, /* 3 T_BPTFLT */
|
||||
LINUX_T_UNKNOWN, /* 4 */
|
||||
LINUX_T_UNKNOWN, /* 5 */
|
||||
16, /* 6 T_ARITHTRAP */
|
||||
254, /* 7 T_ASTFLT */
|
||||
LINUX_T_UNKNOWN, /* 8 */
|
||||
13, /* 9 T_PROTFLT */
|
||||
1, /* 10 T_TRCTRAP */
|
||||
LINUX_T_UNKNOWN, /* 11 */
|
||||
14, /* 12 T_PAGEFLT */
|
||||
LINUX_T_UNKNOWN, /* 13 */
|
||||
17, /* 14 T_ALIGNFLT */
|
||||
LINUX_T_UNKNOWN, /* 15 */
|
||||
LINUX_T_UNKNOWN, /* 16 */
|
||||
LINUX_T_UNKNOWN, /* 17 */
|
||||
0, /* 18 T_DIVIDE */
|
||||
2, /* 19 T_NMI */
|
||||
4, /* 20 T_OFLOW */
|
||||
5, /* 21 T_BOUND */
|
||||
7, /* 22 T_DNA */
|
||||
8, /* 23 T_DOUBLEFLT */
|
||||
9, /* 24 T_FPOPFLT */
|
||||
10, /* 25 T_TSSFLT */
|
||||
11, /* 26 T_SEGNPFLT */
|
||||
12, /* 27 T_STKFLT */
|
||||
18, /* 28 T_MCHK */
|
||||
19, /* 29 T_XMMFLT */
|
||||
15 /* 30 T_RESERVED */
|
||||
};
|
||||
#define bsd_to_linux_trapcode(code) \
|
||||
((code)<sizeof(_bsd_to_linux_trapcode)/sizeof(*_bsd_to_linux_trapcode)? \
|
||||
_bsd_to_linux_trapcode[(code)]: \
|
||||
LINUX_T_UNKNOWN)
|
||||
|
||||
LINUX_VDSO_SYM_INTPTR(linux_rt_sigcode);
|
||||
LINUX_VDSO_SYM_CHAR(linux_platform);
|
||||
|
||||
/*
|
||||
* If FreeBSD & Linux have a difference of opinion about what a trap
|
||||
* means, deal with it here.
|
||||
*
|
||||
* MPSAFE
|
||||
*/
|
||||
static int
|
||||
translate_traps(int signal, int trap_code)
|
||||
{
|
||||
|
||||
if (signal != SIGBUS)
|
||||
return signal;
|
||||
switch (trap_code) {
|
||||
case T_PROTFLT:
|
||||
case T_TSSFLT:
|
||||
case T_DOUBLEFLT:
|
||||
case T_PAGEFLT:
|
||||
return SIGSEGV;
|
||||
default:
|
||||
return signal;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
linux_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
|
||||
{
|
||||
struct proc *p;
|
||||
struct trapframe *frame;
|
||||
|
||||
p = td->td_proc;
|
||||
frame = td->td_frame;
|
||||
|
||||
sa->args[0] = frame->tf_rdi;
|
||||
sa->args[1] = frame->tf_rsi;
|
||||
sa->args[2] = frame->tf_rdx;
|
||||
sa->args[3] = frame->tf_rcx;
|
||||
sa->args[4] = frame->tf_r8;
|
||||
sa->args[5] = frame->tf_r9;
|
||||
sa->code = frame->tf_rax;
|
||||
|
||||
if (sa->code >= p->p_sysent->sv_size) {
|
||||
PROC_LOCK(p);
|
||||
sigexit(td, SIGILL);
|
||||
} else
|
||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||
sa->narg = sa->callp->sy_narg;
|
||||
|
||||
td->td_retval[0] = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_set_syscall_retval(struct thread *td, int error)
|
||||
{
|
||||
struct trapframe *frame = td->td_frame;
|
||||
|
||||
/*
|
||||
* On Linux only %rcx and %r11 values are not preserved across
|
||||
* the syscall.
|
||||
* So, do not clobber %rdx and %r10
|
||||
*/
|
||||
td->td_retval[1] = frame->tf_rdx;
|
||||
frame->tf_r10 = frame->tf_rcx;
|
||||
|
||||
cpu_set_syscall_retval(td, error);
|
||||
|
||||
/* Restore all registers. */
|
||||
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
|
||||
}
|
||||
|
||||
static int
|
||||
elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
||||
{
|
||||
Elf_Auxargs *args;
|
||||
Elf_Addr *base;
|
||||
Elf_Addr *pos;
|
||||
struct ps_strings *arginfo;
|
||||
struct proc *p;
|
||||
|
||||
p = imgp->proc;
|
||||
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
|
||||
|
||||
KASSERT(curthread->td_proc == imgp->proc,
|
||||
("unsafe elf_linux_fixup(), should be curproc"));
|
||||
base = (Elf64_Addr *)*stack_base;
|
||||
args = (Elf64_Auxargs *)imgp->auxargs;
|
||||
pos = base + (imgp->args->argc + imgp->args->envc + 2);
|
||||
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR,
|
||||
imgp->proc->p_sysent->sv_shared_page_base);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
|
||||
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
||||
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
||||
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
||||
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
||||
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
||||
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
||||
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
||||
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
||||
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
||||
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
|
||||
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_SECURE, 0);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
||||
if (args->execfd != -1)
|
||||
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
||||
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
||||
free(imgp->auxargs, M_TEMP);
|
||||
imgp->auxargs = NULL;
|
||||
|
||||
base--;
|
||||
suword(base, (uint64_t)imgp->args->argc);
|
||||
|
||||
*stack_base = (register_t *)base;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy strings out to the new process address space, constructing new arg
|
||||
* and env vector tables. Return a pointer to the base so that it can be used
|
||||
* as the initial stack pointer.
|
||||
*/
|
||||
static register_t *
|
||||
linux_copyout_strings(struct image_params *imgp)
|
||||
{
|
||||
int argc, envc;
|
||||
char **vectp;
|
||||
char *stringp, *destp;
|
||||
register_t *stack_base;
|
||||
struct ps_strings *arginfo;
|
||||
struct proc *p;
|
||||
|
||||
/*
|
||||
* Calculate string base and vector table pointers.
|
||||
*/
|
||||
p = imgp->proc;
|
||||
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
|
||||
destp = (caddr_t)arginfo - SPARE_USRSPACE -
|
||||
roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *));
|
||||
|
||||
/*
|
||||
* If we have a valid auxargs ptr, prepare some room
|
||||
* on the stack.
|
||||
*/
|
||||
if (imgp->auxargs) {
|
||||
/*
|
||||
* 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
|
||||
* lower compatibility.
|
||||
*/
|
||||
imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size :
|
||||
(LINUX_AT_COUNT * 2);
|
||||
|
||||
/*
|
||||
* The '+ 2' is for the null pointers at the end of each of
|
||||
* the arg and env vector sets,and imgp->auxarg_size is room
|
||||
* for argument of Runtime loader.
|
||||
*/
|
||||
vectp = (char **)(destp - (imgp->args->argc +
|
||||
imgp->args->envc + 2 + imgp->auxarg_size) * sizeof(char *));
|
||||
|
||||
} else {
|
||||
/*
|
||||
* The '+ 2' is for the null pointers at the end of each of
|
||||
* the arg and env vector sets
|
||||
*/
|
||||
vectp = (char **)(destp - (imgp->args->argc +
|
||||
imgp->args->envc + 2) * sizeof(char *));
|
||||
}
|
||||
|
||||
/*
|
||||
* vectp also becomes our initial stack base
|
||||
*/
|
||||
stack_base = (register_t *)vectp;
|
||||
|
||||
stringp = imgp->args->begin_argv;
|
||||
argc = imgp->args->argc;
|
||||
envc = imgp->args->envc;
|
||||
|
||||
/*
|
||||
* Copy out strings - arguments and environment.
|
||||
*/
|
||||
copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
|
||||
|
||||
/*
|
||||
* Fill in "ps_strings" struct for ps, w, etc.
|
||||
*/
|
||||
suword(&arginfo->ps_argvstr, (long)(intptr_t)vectp);
|
||||
suword(&arginfo->ps_nargvstr, argc);
|
||||
|
||||
/*
|
||||
* Fill in argument portion of vector table.
|
||||
*/
|
||||
for (; argc > 0; --argc) {
|
||||
suword(vectp++, (long)(intptr_t)destp);
|
||||
while (*stringp++ != 0)
|
||||
destp++;
|
||||
destp++;
|
||||
}
|
||||
|
||||
/* a null vector table pointer separates the argp's from the envp's */
|
||||
suword(vectp++, 0);
|
||||
|
||||
suword(&arginfo->ps_envstr, (long)(intptr_t)vectp);
|
||||
suword(&arginfo->ps_nenvstr, envc);
|
||||
|
||||
/*
|
||||
* Fill in environment portion of vector table.
|
||||
*/
|
||||
for (; envc > 0; --envc) {
|
||||
suword(vectp++, (long)(intptr_t)destp);
|
||||
while (*stringp++ != 0)
|
||||
destp++;
|
||||
destp++;
|
||||
}
|
||||
|
||||
/* end of vector table is a null pointer */
|
||||
suword(vectp, 0);
|
||||
return (stack_base);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset registers to default values on exec.
|
||||
*/
|
||||
static void
|
||||
linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
|
||||
{
|
||||
struct trapframe *regs = td->td_frame;
|
||||
struct pcb *pcb = td->td_pcb;
|
||||
|
||||
mtx_lock(&dt_lock);
|
||||
if (td->td_proc->p_md.md_ldt != NULL)
|
||||
user_ldt_free(td);
|
||||
else
|
||||
mtx_unlock(&dt_lock);
|
||||
|
||||
pcb->pcb_fsbase = 0;
|
||||
pcb->pcb_gsbase = 0;
|
||||
clear_pcb_flags(pcb, PCB_32BIT);
|
||||
pcb->pcb_initial_fpucw = __LINUX_NPXCW__;
|
||||
set_pcb_flags(pcb, PCB_FULL_IRET);
|
||||
|
||||
bzero((char *)regs, sizeof(struct trapframe));
|
||||
regs->tf_rip = imgp->entry_addr;
|
||||
regs->tf_rsp = stack;
|
||||
regs->tf_rflags = PSL_USER | (regs->tf_rflags & PSL_T);
|
||||
regs->tf_ss = _udatasel;
|
||||
regs->tf_cs = _ucodesel;
|
||||
regs->tf_ds = _udatasel;
|
||||
regs->tf_es = _udatasel;
|
||||
regs->tf_fs = _ufssel;
|
||||
regs->tf_gs = _ugssel;
|
||||
regs->tf_flags = TF_HASSEGS;
|
||||
|
||||
/*
|
||||
* Reset the hardware debug registers if they were in use.
|
||||
* They won't have any meaning for the newly exec'd process.
|
||||
*/
|
||||
if (pcb->pcb_flags & PCB_DBREGS) {
|
||||
pcb->pcb_dr0 = 0;
|
||||
pcb->pcb_dr1 = 0;
|
||||
pcb->pcb_dr2 = 0;
|
||||
pcb->pcb_dr3 = 0;
|
||||
pcb->pcb_dr6 = 0;
|
||||
pcb->pcb_dr7 = 0;
|
||||
if (pcb == curpcb) {
|
||||
/*
|
||||
* Clear the debug registers on the running
|
||||
* CPU, otherwise they will end up affecting
|
||||
* the next process we switch to.
|
||||
*/
|
||||
reset_dbregs();
|
||||
}
|
||||
clear_pcb_flags(pcb, PCB_DBREGS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Drop the FP state if we hold it, so that the process gets a
|
||||
* clean FP state if it uses the FPU again.
|
||||
*/
|
||||
fpstate_drop(td);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copied from amd64/amd64/machdep.c
|
||||
*
|
||||
* XXX fpu state need? don't think so
|
||||
*/
|
||||
int
|
||||
linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
|
||||
{
|
||||
struct proc *p;
|
||||
struct l_ucontext uc;
|
||||
struct l_sigcontext *context;
|
||||
struct trapframe *regs;
|
||||
unsigned long rflags;
|
||||
int error;
|
||||
ksiginfo_t ksi;
|
||||
|
||||
regs = td->td_frame;
|
||||
error = copyin((void *)regs->tf_rbx, &uc, sizeof(uc));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
p = td->td_proc;
|
||||
context = &uc.uc_mcontext;
|
||||
rflags = context->sc_rflags;
|
||||
|
||||
/*
|
||||
* Don't allow users to change privileged or reserved flags.
|
||||
*/
|
||||
/*
|
||||
* XXX do allow users to change the privileged flag PSL_RF.
|
||||
* The cpu sets PSL_RF in tf_rflags for faults. Debuggers
|
||||
* should sometimes set it there too. tf_rflags is kept in
|
||||
* the signal context during signal handling and there is no
|
||||
* other place to remember it, so the PSL_RF bit may be
|
||||
* corrupted by the signal handler without us knowing.
|
||||
* Corruption of the PSL_RF bit at worst causes one more or
|
||||
* one less debugger trap, so allowing it is fairly harmless.
|
||||
*/
|
||||
|
||||
#define RFLAG_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
|
||||
if (!RFLAG_SECURE(rflags & ~PSL_RF, regs->tf_rflags & ~PSL_RF)) {
|
||||
printf("linux_rt_sigreturn: rflags = 0x%lx\n", rflags);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't allow users to load a valid privileged %cs. Let the
|
||||
* hardware check for invalid selectors, excess privilege in
|
||||
* other selectors, invalid %eip's and invalid %esp's.
|
||||
*/
|
||||
#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL)
|
||||
if (!CS_SECURE(context->sc_cs)) {
|
||||
printf("linux_rt_sigreturn: cs = 0x%x\n", context->sc_cs);
|
||||
ksiginfo_init_trap(&ksi);
|
||||
ksi.ksi_signo = SIGBUS;
|
||||
ksi.ksi_code = BUS_OBJERR;
|
||||
ksi.ksi_trapno = T_PROTFLT;
|
||||
ksi.ksi_addr = (void *)regs->tf_rip;
|
||||
trapsignal(td, &ksi);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
PROC_LOCK(p);
|
||||
linux_to_bsd_sigset(&uc.uc_sigmask, &td->td_sigmask);
|
||||
SIG_CANTMASK(td->td_sigmask);
|
||||
signotify(td);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
regs->tf_rdi = context->sc_rdi;
|
||||
regs->tf_rsi = context->sc_rsi;
|
||||
regs->tf_rdx = context->sc_rdx;
|
||||
regs->tf_rbp = context->sc_rbp;
|
||||
regs->tf_rbx = context->sc_rbx;
|
||||
regs->tf_rcx = context->sc_rcx;
|
||||
regs->tf_rax = context->sc_rax;
|
||||
regs->tf_rip = context->sc_rip;
|
||||
regs->tf_rsp = context->sc_rsp;
|
||||
regs->tf_r8 = context->sc_r8;
|
||||
regs->tf_r9 = context->sc_r9;
|
||||
regs->tf_r10 = context->sc_r10;
|
||||
regs->tf_r11 = context->sc_r11;
|
||||
regs->tf_r12 = context->sc_r12;
|
||||
regs->tf_r13 = context->sc_r13;
|
||||
regs->tf_r14 = context->sc_r14;
|
||||
regs->tf_r15 = context->sc_r15;
|
||||
regs->tf_cs = context->sc_cs;
|
||||
regs->tf_err = context->sc_err;
|
||||
regs->tf_rflags = rflags;
|
||||
|
||||
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
|
||||
return (EJUSTRETURN);
|
||||
}
|
||||
|
||||
/*
|
||||
* copied from amd64/amd64/machdep.c
|
||||
*
|
||||
* Send an interrupt to process.
|
||||
*/
|
||||
static void
|
||||
linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
{
|
||||
struct l_rt_sigframe sf, *sfp;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
struct sigacts *psp;
|
||||
caddr_t sp;
|
||||
struct trapframe *regs;
|
||||
int sig, code;
|
||||
int oonstack;
|
||||
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
PROC_LOCK_ASSERT(p, MA_OWNED);
|
||||
sig = ksi->ksi_signo;
|
||||
psp = p->p_sigacts;
|
||||
code = ksi->ksi_code;
|
||||
mtx_assert(&psp->ps_mtx, MA_OWNED);
|
||||
regs = td->td_frame;
|
||||
oonstack = sigonstack(regs->tf_rsp);
|
||||
|
||||
LINUX_CTR4(rt_sendsig, "%p, %d, %p, %u",
|
||||
catcher, sig, mask, code);
|
||||
|
||||
/* Allocate space for the signal handler context. */
|
||||
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
|
||||
SIGISMEMBER(psp->ps_sigonstack, sig)) {
|
||||
sp = td->td_sigstk.ss_sp + td->td_sigstk.ss_size -
|
||||
sizeof(struct l_rt_sigframe);
|
||||
} else
|
||||
sp = (caddr_t)regs->tf_rsp - sizeof(struct l_rt_sigframe) - 128;
|
||||
/* Align to 16 bytes. */
|
||||
sfp = (struct l_rt_sigframe *)((unsigned long)sp & ~0xFul);
|
||||
mtx_unlock(&psp->ps_mtx);
|
||||
|
||||
/* Translate the signal if appropriate. */
|
||||
sig = BSD_TO_LINUX_SIGNAL(sig);
|
||||
|
||||
/* Save user context. */
|
||||
bzero(&sf, sizeof(sf));
|
||||
bsd_to_linux_sigset(mask, &sf.sf_sc.uc_sigmask);
|
||||
bsd_to_linux_sigset(mask, &sf.sf_sc.uc_mcontext.sc_mask);
|
||||
|
||||
sf.sf_sc.uc_stack.ss_sp = PTROUT(td->td_sigstk.ss_sp);
|
||||
sf.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size;
|
||||
sf.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
|
||||
? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
sf.sf_sc.uc_mcontext.sc_rdi = regs->tf_rdi;
|
||||
sf.sf_sc.uc_mcontext.sc_rsi = regs->tf_rsi;
|
||||
sf.sf_sc.uc_mcontext.sc_rdx = regs->tf_rdx;
|
||||
sf.sf_sc.uc_mcontext.sc_rbp = regs->tf_rbp;
|
||||
sf.sf_sc.uc_mcontext.sc_rbx = regs->tf_rbx;
|
||||
sf.sf_sc.uc_mcontext.sc_rcx = regs->tf_rcx;
|
||||
sf.sf_sc.uc_mcontext.sc_rax = regs->tf_rax;
|
||||
sf.sf_sc.uc_mcontext.sc_rip = regs->tf_rip;
|
||||
sf.sf_sc.uc_mcontext.sc_rsp = regs->tf_rsp;
|
||||
sf.sf_sc.uc_mcontext.sc_r8 = regs->tf_r8;
|
||||
sf.sf_sc.uc_mcontext.sc_r9 = regs->tf_r9;
|
||||
sf.sf_sc.uc_mcontext.sc_r10 = regs->tf_r10;
|
||||
sf.sf_sc.uc_mcontext.sc_r11 = regs->tf_r11;
|
||||
sf.sf_sc.uc_mcontext.sc_r12 = regs->tf_r12;
|
||||
sf.sf_sc.uc_mcontext.sc_r13 = regs->tf_r13;
|
||||
sf.sf_sc.uc_mcontext.sc_r14 = regs->tf_r14;
|
||||
sf.sf_sc.uc_mcontext.sc_r15 = regs->tf_r15;
|
||||
sf.sf_sc.uc_mcontext.sc_cs = regs->tf_cs;
|
||||
sf.sf_sc.uc_mcontext.sc_rflags = regs->tf_rflags;
|
||||
sf.sf_sc.uc_mcontext.sc_err = regs->tf_err;
|
||||
sf.sf_sc.uc_mcontext.sc_trapno = bsd_to_linux_trapcode(code);
|
||||
sf.sf_sc.uc_mcontext.sc_cr2 = (register_t)ksi->ksi_addr;
|
||||
|
||||
/* Build the argument list for the signal handler. */
|
||||
regs->tf_rdi = sig; /* arg 1 in %rdi */
|
||||
regs->tf_rax = 0;
|
||||
regs->tf_rsi = (register_t)&sfp->sf_si; /* arg 2 in %rsi */
|
||||
regs->tf_rdx = (register_t)&sfp->sf_sc; /* arg 3 in %rdx */
|
||||
|
||||
sf.sf_handler = catcher;
|
||||
/* Fill in POSIX parts */
|
||||
ksiginfo_to_lsiginfo(ksi, &sf.sf_si, sig);
|
||||
|
||||
/*
|
||||
* Copy the sigframe out to the user's stack.
|
||||
*/
|
||||
if (copyout(&sf, sfp, sizeof(*sfp)) != 0) {
|
||||
#ifdef DEBUG
|
||||
printf("process %ld has trashed its stack\n", (long)p->p_pid);
|
||||
#endif
|
||||
PROC_LOCK(p);
|
||||
sigexit(td, SIGILL);
|
||||
}
|
||||
|
||||
regs->tf_rsp = (long)sfp;
|
||||
regs->tf_rip = linux_rt_sigcode;
|
||||
regs->tf_rflags &= ~(PSL_T | PSL_D);
|
||||
regs->tf_cs = _ucodesel;
|
||||
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
|
||||
PROC_LOCK(p);
|
||||
mtx_lock(&psp->ps_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* If a linux binary is exec'ing something, try this image activator
|
||||
* first. We override standard shell script execution in order to
|
||||
* be able to modify the interpreter path. We only do this if a linux
|
||||
* binary is doing the exec, so we do not create an EXEC module for it.
|
||||
*/
|
||||
static int exec_linux_imgact_try(struct image_params *iparams);
|
||||
|
||||
static int
|
||||
exec_linux_imgact_try(struct image_params *imgp)
|
||||
{
|
||||
const char *head = (const char *)imgp->image_header;
|
||||
char *rpath;
|
||||
int error = -1, len;
|
||||
|
||||
/*
|
||||
* The interpreter for shell scripts run from a linux binary needs
|
||||
* to be located in /compat/linux if possible in order to recursively
|
||||
* maintain linux path emulation.
|
||||
*/
|
||||
if (((const short *)head)[0] == SHELLMAGIC) {
|
||||
/*
|
||||
* Run our normal shell image activator. If it succeeds
|
||||
* attempt to use the alternate path for the interpreter.
|
||||
* If an alternate path is found, use our stringspace
|
||||
* to store it.
|
||||
*/
|
||||
if ((error = exec_shell_imgact(imgp)) == 0) {
|
||||
linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc),
|
||||
imgp->interpreter_name, UIO_SYSSPACE,
|
||||
&rpath, 0, AT_FDCWD);
|
||||
if (rpath != NULL) {
|
||||
len = strlen(rpath) + 1;
|
||||
|
||||
if (len <= MAXSHELLCMDLEN)
|
||||
memcpy(imgp->interpreter_name,
|
||||
rpath, len);
|
||||
free(rpath, M_TEMP);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(error);
|
||||
}
|
||||
|
||||
struct sysentvec elf_linux_sysvec = {
|
||||
.sv_size = LINUX_SYS_MAXSYSCALL,
|
||||
.sv_table = linux_sysent,
|
||||
.sv_mask = 0,
|
||||
.sv_sigsize = LINUX_SIGTBLSZ,
|
||||
.sv_sigtbl = bsd_to_linux_signal,
|
||||
.sv_errsize = ELAST + 1,
|
||||
.sv_errtbl = bsd_to_linux_errno,
|
||||
.sv_transtrap = translate_traps,
|
||||
.sv_fixup = elf_linux_fixup,
|
||||
.sv_sendsig = linux_rt_sendsig,
|
||||
.sv_sigcode = &_binary_linux_locore_o_start,
|
||||
.sv_szsigcode = &linux_szsigcode,
|
||||
.sv_prepsyscall = NULL,
|
||||
.sv_name = "Linux ELF64",
|
||||
.sv_coredump = elf64_coredump,
|
||||
.sv_imgact_try = exec_linux_imgact_try,
|
||||
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
|
||||
.sv_pagesize = PAGE_SIZE,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
.sv_maxuser = VM_MAXUSER_ADDRESS,
|
||||
.sv_usrstack = USRSTACK,
|
||||
.sv_psstrings = PS_STRINGS,
|
||||
.sv_stackprot = VM_PROT_ALL,
|
||||
.sv_copyout_strings = linux_copyout_strings,
|
||||
.sv_setregs = linux_exec_setregs,
|
||||
.sv_fixlimit = NULL,
|
||||
.sv_maxssiz = NULL,
|
||||
.sv_flags = SV_ABI_LINUX | SV_LP64 | SV_SHP,
|
||||
.sv_set_syscall_retval = linux_set_syscall_retval,
|
||||
.sv_fetch_syscall_args = linux_fetch_syscall_args,
|
||||
.sv_syscallnames = NULL,
|
||||
.sv_shared_page_base = SHAREDPAGE,
|
||||
.sv_shared_page_len = PAGE_SIZE,
|
||||
.sv_schedtail = linux_schedtail,
|
||||
.sv_thread_detach = linux_thread_detach
|
||||
};
|
||||
|
||||
static void
|
||||
linux_vdso_install(void *param)
|
||||
{
|
||||
|
||||
linux_szsigcode = (&_binary_linux_locore_o_end -
|
||||
&_binary_linux_locore_o_start);
|
||||
|
||||
if (linux_szsigcode > elf_linux_sysvec.sv_shared_page_len)
|
||||
panic("Linux invalid vdso size\n");
|
||||
|
||||
__elfN(linux_vdso_fixup)(&elf_linux_sysvec);
|
||||
|
||||
linux_shared_page_obj = __elfN(linux_shared_page_init)
|
||||
(&linux_shared_page_mapping);
|
||||
|
||||
__elfN(linux_vdso_reloc)(&elf_linux_sysvec, SHAREDPAGE);
|
||||
|
||||
bcopy(elf_linux_sysvec.sv_sigcode, linux_shared_page_mapping,
|
||||
linux_szsigcode);
|
||||
elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
|
||||
|
||||
linux_kplatform = linux_shared_page_mapping +
|
||||
(linux_platform - (caddr_t)SHAREDPAGE);
|
||||
}
|
||||
SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
|
||||
(sysinit_cfunc_t)linux_vdso_install, NULL);
|
||||
|
||||
static void
|
||||
linux_vdso_deinstall(void *param)
|
||||
{
|
||||
|
||||
__elfN(linux_shared_page_fini)(linux_shared_page_obj);
|
||||
};
|
||||
SYSUNINIT(elf_linux_vdso_uninit, SI_SUB_EXEC, SI_ORDER_FIRST,
|
||||
(sysinit_cfunc_t)linux_vdso_deinstall, NULL);
|
||||
|
||||
static char GNULINUX_ABI_VENDOR[] = "GNU";
|
||||
static int GNULINUX_ABI_DESC = 0;
|
||||
|
||||
static boolean_t
|
||||
linux_trans_osrel(const Elf_Note *note, int32_t *osrel)
|
||||
{
|
||||
const Elf32_Word *desc;
|
||||
uintptr_t p;
|
||||
|
||||
p = (uintptr_t)(note + 1);
|
||||
p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
|
||||
|
||||
desc = (const Elf32_Word *)p;
|
||||
if (desc[0] != GNULINUX_ABI_DESC)
|
||||
return (FALSE);
|
||||
|
||||
/*
|
||||
* For linux we encode osrel as follows (see linux_mib.c):
|
||||
* VVVMMMIII (version, major, minor), see linux_mib.c.
|
||||
*/
|
||||
*osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3];
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Elf_Brandnote linux64_brandnote = {
|
||||
.hdr.n_namesz = sizeof(GNULINUX_ABI_VENDOR),
|
||||
.hdr.n_descsz = 16,
|
||||
.hdr.n_type = 1,
|
||||
.vendor = GNULINUX_ABI_VENDOR,
|
||||
.flags = BN_TRANSLATE_OSREL,
|
||||
.trans_osrel = linux_trans_osrel
|
||||
};
|
||||
|
||||
static Elf64_Brandinfo linux_glibc2brand = {
|
||||
.brand = ELFOSABI_LINUX,
|
||||
.machine = EM_X86_64,
|
||||
.compat_3_brand = "Linux",
|
||||
.emul_path = "/compat/linux",
|
||||
.interp_path = "/lib64/ld-linux-x86-64.so.2",
|
||||
.sysvec = &elf_linux_sysvec,
|
||||
.interp_newpath = NULL,
|
||||
.brand_note = &linux64_brandnote,
|
||||
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
|
||||
};
|
||||
|
||||
static Elf64_Brandinfo linux_glibc2brandshort = {
|
||||
.brand = ELFOSABI_LINUX,
|
||||
.machine = EM_X86_64,
|
||||
.compat_3_brand = "Linux",
|
||||
.emul_path = "/compat/linux",
|
||||
.interp_path = "/lib64/ld-linux.so.2",
|
||||
.sysvec = &elf_linux_sysvec,
|
||||
.interp_newpath = NULL,
|
||||
.brand_note = &linux64_brandnote,
|
||||
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
|
||||
};
|
||||
|
||||
Elf64_Brandinfo *linux_brandlist[] = {
|
||||
&linux_glibc2brand,
|
||||
&linux_glibc2brandshort,
|
||||
NULL
|
||||
};
|
||||
|
||||
static int
|
||||
linux64_elf_modevent(module_t mod, int type, void *data)
|
||||
{
|
||||
Elf64_Brandinfo **brandinfo;
|
||||
int error;
|
||||
struct linux_ioctl_handler **lihp;
|
||||
|
||||
error = 0;
|
||||
|
||||
switch(type) {
|
||||
case MOD_LOAD:
|
||||
for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
|
||||
++brandinfo)
|
||||
if (elf64_insert_brand_entry(*brandinfo) < 0)
|
||||
error = EINVAL;
|
||||
if (error == 0) {
|
||||
SET_FOREACH(lihp, linux_ioctl_handler_set)
|
||||
linux_ioctl_register_handler(*lihp);
|
||||
LIST_INIT(&futex_list);
|
||||
mtx_init(&futex_mtx, "ftllk64", NULL, MTX_DEF);
|
||||
stclohz = (stathz ? stathz : hz);
|
||||
if (bootverbose)
|
||||
printf("Linux x86-64 ELF exec handler installed\n");
|
||||
} else
|
||||
printf("cannot insert Linux x86-64 ELF brand handler\n");
|
||||
break;
|
||||
case MOD_UNLOAD:
|
||||
for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
|
||||
++brandinfo)
|
||||
if (elf64_brand_inuse(*brandinfo))
|
||||
error = EBUSY;
|
||||
if (error == 0) {
|
||||
for (brandinfo = &linux_brandlist[0];
|
||||
*brandinfo != NULL; ++brandinfo)
|
||||
if (elf64_remove_brand_entry(*brandinfo) < 0)
|
||||
error = EINVAL;
|
||||
}
|
||||
if (error == 0) {
|
||||
SET_FOREACH(lihp, linux_ioctl_handler_set)
|
||||
linux_ioctl_unregister_handler(*lihp);
|
||||
mtx_destroy(&futex_mtx);
|
||||
if (bootverbose)
|
||||
printf("Linux ELF exec handler removed\n");
|
||||
} else
|
||||
printf("Could not deinstall ELF interpreter entry\n");
|
||||
break;
|
||||
default:
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
static moduledata_t linux64_elf_mod = {
|
||||
"linux64elf",
|
||||
linux64_elf_modevent,
|
||||
0
|
||||
};
|
||||
|
||||
DECLARE_MODULE_TIED(linux64elf, linux64_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
|
||||
MODULE_DEPEND(linux64elf, linux_common, 1, 1, 1);
|
69
sys/amd64/linux/linux_vdso.lds.s
Normal file
69
sys/amd64/linux/linux_vdso.lds.s
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Linker script for 64-bit vDSO.
|
||||
* Copied from Linux kernel arch/x86/vdso/vdso-layout.lds.S
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = . + SIZEOF_HEADERS;
|
||||
|
||||
.hash : { *(.hash) } :text
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
|
||||
.note : { *(.note.*) } :text :note
|
||||
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
|
||||
.eh_frame : { KEEP (*(.eh_frame)) } :text
|
||||
|
||||
.dynamic : { *(.dynamic) } :text :dynamic
|
||||
|
||||
.rodata : { *(.rodata*) } :text
|
||||
.data : {
|
||||
*(.data*)
|
||||
*(.sdata*)
|
||||
*(.got.plt) *(.got)
|
||||
*(.gnu.linkonce.d.*)
|
||||
*(.bss*)
|
||||
*(.dynbss*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
}
|
||||
|
||||
.altinstructions : { *(.altinstructions) }
|
||||
.altinstr_replacement : { *(.altinstr_replacement) }
|
||||
|
||||
. = ALIGN(0x100);
|
||||
.text : { *(.test .text*) } :text =0x90909090
|
||||
}
|
||||
|
||||
PHDRS
|
||||
{
|
||||
text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
|
||||
dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
|
||||
note PT_NOTE FLAGS(4); /* PF_R */
|
||||
eh_frame_hdr PT_GNU_EH_FRAME;
|
||||
}
|
||||
|
||||
VERSION
|
||||
{
|
||||
LINUX_2.6 {
|
||||
global:
|
||||
time;
|
||||
__vdso_time;
|
||||
gettimeofday;
|
||||
__vdso_gettimeofday;
|
||||
getcpu;
|
||||
__vdso_getcpu;
|
||||
clock_gettime;
|
||||
__vdso_clock_gettime;
|
||||
linux_rt_sigcode;
|
||||
linux_platform;
|
||||
local: *;
|
||||
};
|
||||
}
|
11
sys/amd64/linux/syscalls.conf
Normal file
11
sys/amd64/linux/syscalls.conf
Normal file
@ -0,0 +1,11 @@
|
||||
# $FreeBSD$
|
||||
sysnames="linux_syscalls.c"
|
||||
sysproto="linux_proto.h"
|
||||
sysproto_h=_LINUX_SYSPROTO_H_
|
||||
syshdr="linux_syscall.h"
|
||||
syssw="linux_sysent.c"
|
||||
sysmk="/dev/null"
|
||||
syscallprefix="LINUX_SYS_"
|
||||
switchname="linux_sysent"
|
||||
namesname="linux_syscallnames"
|
||||
systrace="linux_systrace_args.c"
|
503
sys/amd64/linux/syscalls.master
Normal file
503
sys/amd64/linux/syscalls.master
Normal file
@ -0,0 +1,503 @@
|
||||
$FreeBSD$
|
||||
|
||||
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||
; System call name/number master file (or rather, slave, from LINUX).
|
||||
; Processed to create linux_sysent.c, linux_proto.h and linux_syscall.h.
|
||||
|
||||
; Columns: number audit type nargs name alt{name,tag,rtyp}/comments
|
||||
; number system call number, must be in order
|
||||
; audit the audit event associated with the system call
|
||||
; A value of AUE_NULL means no auditing, but it also means that
|
||||
; there is no audit event for the call at this time. For the
|
||||
; case where the event exists, but we don't want auditing, the
|
||||
; event should be #defined to AUE_NULL in audit_kevents.h.
|
||||
; type one of STD, OBSOL, UNIMPL
|
||||
; name psuedo-prototype of syscall routine
|
||||
; If one of the following alts is different, then all appear:
|
||||
; altname name of system call if different
|
||||
; alttag name of args struct tag if different from [o]`name'"_args"
|
||||
; altrtyp return type if not int (bogus - syscalls always return int)
|
||||
; for UNIMPL/OBSOL, name continues with comments
|
||||
|
||||
; types:
|
||||
; STD always included
|
||||
; OBSOL obsolete, not included in system, only specifies name
|
||||
; UNIMPL not implemented, placeholder only
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <compat/linux/linux_sysproto.h>
|
||||
#include <amd64/linux/linux.h>
|
||||
#include <amd64/linux/linux_proto.h>
|
||||
|
||||
; Isn't pretty, but there seems to be no other way to trap nosys
|
||||
#define nosys linux_nosys
|
||||
|
||||
; #ifdef's, etc. may be included, and are copied to the output files.
|
||||
|
||||
0 AUE_NULL NOPROTO { int read(int fd, char *buf, \
|
||||
u_int nbyte); }
|
||||
1 AUE_NULL NOPROTO { int write(int fd, char *buf, \
|
||||
u_int nbyte); }
|
||||
2 AUE_OPEN_RWTC STD { int linux_open(char *path, l_int flags, \
|
||||
l_int mode); }
|
||||
3 AUE_CLOSE NOPROTO { int close(int fd); }
|
||||
4 AUE_STAT STD { int linux_newstat(char *path, \
|
||||
struct l_newstat *buf); }
|
||||
5 AUE_FSTAT STD { int linux_newfstat(l_uint fd, \
|
||||
struct l_newstat *buf); }
|
||||
6 AUE_LSTAT STD { int linux_newlstat(char *path, \
|
||||
struct l_newstat *buf); }
|
||||
7 AUE_POLL NOPROTO { int poll(struct pollfd*, \
|
||||
unsigned int nfds, int timeout); }
|
||||
8 AUE_LSEEK STD { int linux_lseek(l_uint fdes, l_off_t off, \
|
||||
l_int whence); }
|
||||
9 AUE_MMAP STD { int linux_mmap2(l_ulong addr, l_ulong len, \
|
||||
l_ulong prot, l_ulong flags, l_ulong fd, \
|
||||
l_ulong pgoff); }
|
||||
10 AUE_MPROTECT STD { int linux_mprotect(caddr_t addr, int len, \
|
||||
int prot); }
|
||||
11 AUE_MUNMAP NOPROTO { int munmap(caddr_t addr, int len); }
|
||||
12 AUE_NULL STD { int linux_brk(l_ulong dsend); }
|
||||
13 AUE_NULL STD { int linux_rt_sigaction(l_int sig, \
|
||||
l_sigaction_t *act, l_sigaction_t *oact, \
|
||||
l_size_t sigsetsize); }
|
||||
14 AUE_NULL STD { int linux_rt_sigprocmask(l_int how, \
|
||||
l_sigset_t *mask, l_sigset_t *omask, \
|
||||
l_size_t sigsetsize); }
|
||||
15 AUE_NULL STD { int linux_rt_sigreturn( \
|
||||
struct l_ucontext *ucp); }
|
||||
16 AUE_IOCTL STD { int linux_ioctl(l_uint fd, l_uint cmd, \
|
||||
uintptr_t arg); }
|
||||
17 AUE_PREAD STD { int linux_pread(l_uint fd, char *buf, \
|
||||
l_size_t nbyte, l_loff_t offset); }
|
||||
18 AUE_PWRITE STD { int linux_pwrite(l_uint fd, char *buf, \
|
||||
l_size_t nbyte, l_loff_t offset); }
|
||||
19 AUE_READV NOPROTO { int readv(int fd, struct iovec *iovp, \
|
||||
u_int iovcnt); }
|
||||
20 AUE_WRITEV NOPROTO { int writev(int fd, struct iovec *iovp, \
|
||||
u_int iovcnt); }
|
||||
21 AUE_ACCESS STD { int linux_access(char *path, l_int amode); }
|
||||
22 AUE_PIPE STD { int linux_pipe(l_ulong *pipefds); }
|
||||
23 AUE_SELECT STD { int linux_select(l_int nfds, \
|
||||
l_fd_set *readfds, l_fd_set *writefds, \
|
||||
l_fd_set *exceptfds, \
|
||||
struct l_timeval *timeout); }
|
||||
24 AUE_NULL NOPROTO { int sched_yield(void); }
|
||||
25 AUE_NULL STD { int linux_mremap(l_ulong addr, \
|
||||
l_ulong old_len, l_ulong new_len, \
|
||||
l_ulong flags, l_ulong new_addr); }
|
||||
26 AUE_MSYNC STD { int linux_msync(l_ulong addr, \
|
||||
l_size_t len, l_int fl); }
|
||||
27 AUE_MINCORE STD { int linux_mincore(l_ulong start, \
|
||||
l_size_t len, u_char *vec); }
|
||||
28 AUE_MADVISE NOPROTO { int madvise(void *addr, size_t len, \
|
||||
int behav); }
|
||||
29 AUE_NULL STD { int linux_shmget(l_key_t key, l_size_t size, \
|
||||
l_int shmflg); }
|
||||
30 AUE_NULL STD { int linux_shmat(l_int shmid, char *shmaddr, \
|
||||
l_int shmflg); }
|
||||
31 AUE_NULL STD { int linux_shmctl(l_int shmid, l_int cmd, \
|
||||
struct l_shmid_ds *buf); }
|
||||
32 AUE_DUP NOPROTO { int dup(u_int fd); }
|
||||
33 AUE_DUP2 NOPROTO { int dup2(u_int from, u_int to); }
|
||||
34 AUE_NULL STD { int linux_pause(void); }
|
||||
35 AUE_NULL STD { int linux_nanosleep( \
|
||||
const struct l_timespec *rqtp, \
|
||||
struct l_timespec *rmtp); }
|
||||
36 AUE_GETITIMER STD { int linux_getitimer(l_int which, \
|
||||
struct l_itimerval *itv); }
|
||||
37 AUE_NULL STD { int linux_alarm(l_uint secs); }
|
||||
38 AUE_SETITIMER STD { int linux_setitimer(l_int which, \
|
||||
struct l_itimerval *itv, \
|
||||
struct l_itimerval *oitv); }
|
||||
39 AUE_GETPID STD { int linux_getpid(void); }
|
||||
40 AUE_SENDFILE STD { int linux_sendfile(int out, int in, \
|
||||
l_long *offset, l_size_t count); }
|
||||
41 AUE_SOCKET STD { int linux_socket(l_int domain, l_int type, \
|
||||
l_int protocol); }
|
||||
42 AUE_CONNECT STD { int linux_connect(l_int s, l_uintptr_t name, \
|
||||
l_int namelen); }
|
||||
43 AUE_ACCEPT STD { int linux_accept(l_int s, l_uintptr_t addr, \
|
||||
l_uintptr_t namelen); }
|
||||
44 AUE_SENDTO STD { int linux_sendto(l_int s, l_uintptr_t msg, \
|
||||
l_int len, l_int flags, l_uintptr_t to, \
|
||||
l_int tolen); }
|
||||
45 AUE_RECVFROM STD { int linux_recvfrom(l_int s, l_uintptr_t buf, \
|
||||
l_size_t len, l_int flags, l_uintptr_t from, \
|
||||
l_uintptr_t fromlen); }
|
||||
46 AUE_SENDMSG STD { int linux_sendmsg(l_int s, l_uintptr_t msg, \
|
||||
l_int flags); }
|
||||
47 AUE_RECVMSG STD { int linux_recvmsg(l_int s, l_uintptr_t msg, \
|
||||
l_int flags); }
|
||||
48 AUE_NULL STD { int linux_shutdown(l_int s, l_int how); }
|
||||
49 AUE_BIND STD { int linux_bind(l_int s, l_uintptr_t name, \
|
||||
l_int namelen); }
|
||||
50 AUE_LISTEN STD { int linux_listen(l_int s, l_int backlog); }
|
||||
51 AUE_GETSOCKNAME STD { int linux_getsockname(l_int s, \
|
||||
l_uintptr_t addr, l_uintptr_t namelen); }
|
||||
52 AUE_GETPEERNAME STD { int linux_getpeername(l_int s, \
|
||||
l_uintptr_t addr, l_uintptr_t namelen); }
|
||||
53 AUE_SOCKETPAIR STD { int linux_socketpair(l_int domain, \
|
||||
l_int type, l_int protocol, l_uintptr_t rsv); }
|
||||
54 AUE_SETSOCKOPT STD { int linux_setsockopt(l_int s, l_int level, \
|
||||
l_int optname, l_uintptr_t optval, \
|
||||
l_int optlen); }
|
||||
55 AUE_GETSOCKOPT STD { int linux_getsockopt(l_int s, l_int level, \
|
||||
l_int optname, l_uintptr_t optval, \
|
||||
l_uintptr_t optlen); }
|
||||
56 AUE_RFORK STD { int linux_clone(l_int flags, void *stack, \
|
||||
void *parent_tidptr, void * child_tidptr, void *tls ); }
|
||||
57 AUE_FORK STD { int linux_fork(void); }
|
||||
58 AUE_VFORK STD { int linux_vfork(void); }
|
||||
59 AUE_EXECVE STD { int linux_execve(char *path, char **argp, \
|
||||
char **envp); }
|
||||
60 AUE_EXIT STD { void linux_exit(int rval); }
|
||||
61 AUE_WAIT4 STD { int linux_wait4(l_pid_t pid, \
|
||||
l_int *status, l_int options, \
|
||||
struct rusage *rusage); }
|
||||
62 AUE_KILL STD { int linux_kill(l_int pid, l_int signum); }
|
||||
63 AUE_NULL STD { int linux_newuname( \
|
||||
struct l_new_utsname *buf); }
|
||||
64 AUE_NULL STD { int linux_semget(l_key_t key, \
|
||||
l_int nsems, l_int semflg); }
|
||||
65 AUE_NULL STD { int linux_semop(l_int semid, \
|
||||
struct l_sembuf *tsops, l_uint nsops); }
|
||||
66 AUE_NULL STD { int linux_semctl(l_int semid, \
|
||||
l_int semnum, l_int cmd, union l_semun arg); }
|
||||
67 AUE_NULL STD { int linux_shmdt(char *shmaddr); }
|
||||
68 AUE_NULL STD { int linux_msgget(l_key_t key, l_int msgflg); }
|
||||
69 AUE_NULL STD { int linux_msgsnd(l_int msqid, \
|
||||
struct l_msgbuf *msgp, l_size_t msgsz, \
|
||||
l_int msgflg); }
|
||||
70 AUE_NULL STD { int linux_msgrcv(l_int msqid, \
|
||||
struct l_msgbuf *msgp, l_size_t msgsz, \
|
||||
l_long msgtyp, l_int msgflg); }
|
||||
71 AUE_NULL STD { int linux_msgctl(l_int msqid, l_int cmd, \
|
||||
struct l_msqid_ds *buf); }
|
||||
72 AUE_FCNTL STD { int linux_fcntl(l_uint fd, l_uint cmd, \
|
||||
l_ulong arg); }
|
||||
73 AUE_FLOCK NOPROTO { int flock(int fd, int how); }
|
||||
74 AUE_FSYNC NOPROTO { int fsync(int fd); }
|
||||
75 AUE_NULL STD { int linux_fdatasync(l_uint fd); }
|
||||
76 AUE_TRUNCATE STD { int linux_truncate(char *path, \
|
||||
l_ulong length); }
|
||||
77 AUE_FTRUNCATE STD { int linux_ftruncate(l_int fd, l_long length); }
|
||||
78 AUE_GETDIRENTRIES STD { int linux_getdents(l_uint fd, void *dent, \
|
||||
l_uint count); }
|
||||
79 AUE_GETCWD STD { int linux_getcwd(char *buf, \
|
||||
l_ulong bufsize); }
|
||||
80 AUE_CHDIR STD { int linux_chdir(char *path); }
|
||||
81 AUE_FCHDIR NOPROTO { int fchdir(int fd); }
|
||||
82 AUE_RENAME STD { int linux_rename(char *from, char *to); }
|
||||
83 AUE_MKDIR STD { int linux_mkdir(char *path, l_int mode); }
|
||||
84 AUE_RMDIR STD { int linux_rmdir(char *path); }
|
||||
85 AUE_CREAT STD { int linux_creat(char *path, \
|
||||
l_int mode); }
|
||||
86 AUE_LINK STD { int linux_link(char *path, char *to); }
|
||||
87 AUE_UNLINK STD { int linux_unlink(char *path); }
|
||||
88 AUE_SYMLINK STD { int linux_symlink(char *path, char *to); }
|
||||
89 AUE_READLINK STD { int linux_readlink(char *name, char *buf, \
|
||||
l_int count); }
|
||||
90 AUE_CHMOD STD { int linux_chmod(char *path, \
|
||||
l_mode_t mode); }
|
||||
91 AUE_FCHMOD NOPROTO { int fchmod(int fd, int mode); }
|
||||
92 AUE_LCHOWN STD { int linux_chown(char *path, \
|
||||
l_uid_t uid, l_gid_t gid); }
|
||||
93 AUE_FCHOWN NOPROTO { int fchown(int fd, int uid, int gid); }
|
||||
94 AUE_LCHOWN STD { int linux_lchown(char *path, l_uid_t uid, \
|
||||
l_gid_t gid); }
|
||||
95 AUE_UMASK NOPROTO { int umask(int newmask); }
|
||||
96 AUE_NULL NOPROTO { int gettimeofday(struct l_timeval *tp, \
|
||||
struct timezone *tzp); }
|
||||
97 AUE_GETRLIMIT STD { int linux_getrlimit(l_uint resource, \
|
||||
struct l_rlimit *rlim); }
|
||||
98 AUE_GETRUSAGE NOPROTO { int getrusage(int who, struct rusage *rusage); }
|
||||
99 AUE_NULL STD { int linux_sysinfo(struct l_sysinfo *info); }
|
||||
100 AUE_NULL STD { int linux_times(struct l_times_argv *buf); }
|
||||
101 AUE_PTRACE STD { int linux_ptrace(l_long req, l_long pid, \
|
||||
l_long addr, l_long data); }
|
||||
102 AUE_GETUID STD { int linux_getuid(void); }
|
||||
103 AUE_NULL STD { int linux_syslog(l_int type, char *buf, \
|
||||
l_int len); }
|
||||
104 AUE_GETGID STD { int linux_getgid(void); }
|
||||
105 AUE_SETUID NOPROTO { int setuid(uid_t uid); }
|
||||
106 AUE_SETGID NOPROTO { int setgid(gid_t gid); }
|
||||
107 AUE_GETEUID NOPROTO { int geteuid(void); }
|
||||
108 AUE_GETEGID NOPROTO { int getegid(void); }
|
||||
109 AUE_SETPGRP NOPROTO { int setpgid(int pid, int pgid); }
|
||||
110 AUE_GETPPID STD { int linux_getppid(void); }
|
||||
111 AUE_GETPGRP NOPROTO { int getpgrp(void); }
|
||||
112 AUE_SETSID NOPROTO { int setsid(void); }
|
||||
113 AUE_SETREUID NOPROTO { int setreuid(uid_t ruid, uid_t euid); }
|
||||
114 AUE_SETREGID NOPROTO { int setregid(gid_t rgid, gid_t egid); }
|
||||
115 AUE_GETGROUPS STD { int linux_getgroups(l_int gidsetsize, \
|
||||
l_gid_t *grouplist); }
|
||||
116 AUE_SETGROUPS STD { int linux_setgroups(l_int gidsetsize, \
|
||||
l_gid_t *grouplist); }
|
||||
117 AUE_SETRESUID NOPROTO { int setresuid(uid_t ruid, uid_t euid, \
|
||||
uid_t suid); }
|
||||
118 AUE_GETRESUID NOPROTO { int getresuid(uid_t *ruid, uid_t *euid, \
|
||||
uid_t *suid); }
|
||||
119 AUE_SETRESGID NOPROTO { int setresgid(gid_t rgid, gid_t egid, \
|
||||
gid_t sgid); }
|
||||
120 AUE_GETRESGID NOPROTO { int getresgid(gid_t *rgid, gid_t *egid, \
|
||||
gid_t *sgid); }
|
||||
121 AUE_GETPGID NOPROTO { int getpgid(int pid); }
|
||||
122 AUE_SETFSUID STD { int linux_setfsuid(l_uid_t uid); }
|
||||
123 AUE_SETFSGID STD { int linux_setfsgid(l_gid_t gid); }
|
||||
124 AUE_GETSID STD { int linux_getsid(l_pid_t pid); }
|
||||
125 AUE_CAPGET STD { int linux_capget(struct l_user_cap_header *hdrp, \
|
||||
struct l_user_cap_data *datap); }
|
||||
126 AUE_CAPSET STD { int linux_capset(struct l_user_cap_header *hdrp, \
|
||||
struct l_user_cap_data *datap); }
|
||||
127 AUE_NULL STD { int linux_rt_sigpending(l_sigset_t *set, \
|
||||
l_size_t sigsetsize); }
|
||||
128 AUE_NULL STD { int linux_rt_sigtimedwait(l_sigset_t *mask, \
|
||||
l_siginfo_t *ptr, \
|
||||
struct l_timeval *timeout, \
|
||||
l_size_t sigsetsize); }
|
||||
129 AUE_NULL STD { int linux_rt_sigqueueinfo(l_pid_t pid, l_int sig, \
|
||||
l_siginfo_t *info); }
|
||||
130 AUE_NULL STD { int linux_rt_sigsuspend( \
|
||||
l_sigset_t *newset, \
|
||||
l_size_t sigsetsize); }
|
||||
131 AUE_NULL STD { int linux_sigaltstack(l_stack_t *uss, \
|
||||
l_stack_t *uoss); }
|
||||
132 AUE_UTIME STD { int linux_utime(char *fname, \
|
||||
struct l_utimbuf *times); }
|
||||
133 AUE_MKNOD STD { int linux_mknod(char *path, l_int mode, \
|
||||
l_dev_t dev); }
|
||||
134 AUE_USELIB UNIMPL uselib
|
||||
135 AUE_PERSONALITY STD { int linux_personality(l_ulong per); }
|
||||
136 AUE_NULL STD { int linux_ustat(l_dev_t dev, \
|
||||
struct l_ustat *ubuf); }
|
||||
137 AUE_STATFS STD { int linux_statfs(char *path, \
|
||||
struct l_statfs_buf *buf); }
|
||||
138 AUE_FSTATFS STD { int linux_fstatfs(l_uint fd, \
|
||||
struct l_statfs_buf *buf); }
|
||||
139 AUE_NULL STD { int linux_sysfs(l_int option, \
|
||||
l_ulong arg1, l_ulong arg2); }
|
||||
140 AUE_GETPRIORITY STD { int linux_getpriority(int which, int who); }
|
||||
141 AUE_SETPRIORITY NOPROTO { int setpriority(int which, int who, \
|
||||
int prio); }
|
||||
142 AUE_SCHED_SETPARAM STD { int linux_sched_setparam(l_pid_t pid, \
|
||||
struct l_sched_param *param); }
|
||||
143 AUE_SCHED_GETPARAM STD { int linux_sched_getparam(l_pid_t pid, \
|
||||
struct l_sched_param *param); }
|
||||
144 AUE_SCHED_SETSCHEDULER STD { int linux_sched_setscheduler( \
|
||||
l_pid_t pid, l_int policy, \
|
||||
struct l_sched_param *param); }
|
||||
145 AUE_SCHED_GETSCHEDULER STD { int linux_sched_getscheduler( \
|
||||
l_pid_t pid); }
|
||||
146 AUE_SCHED_GET_PRIORITY_MAX STD { int linux_sched_get_priority_max( \
|
||||
l_int policy); }
|
||||
147 AUE_SCHED_GET_PRIORITY_MIN STD { int linux_sched_get_priority_min( \
|
||||
l_int policy); }
|
||||
148 AUE_SCHED_RR_GET_INTERVAL STD { int linux_sched_rr_get_interval(l_pid_t pid, \
|
||||
struct l_timespec *interval); }
|
||||
149 AUE_MLOCK NOPROTO { int mlock(const void *addr, size_t len); }
|
||||
150 AUE_MUNLOCK NOPROTO { int munlock(const void *addr, size_t len); }
|
||||
151 AUE_MLOCKALL NOPROTO { int mlockall(int how); }
|
||||
152 AUE_MUNLOCKALL NOPROTO { int munlockall(void); }
|
||||
153 AUE_NULL STD { int linux_vhangup(void); }
|
||||
154 AUE_NULL UNIMPL modify_ldt
|
||||
155 AUE_PIVOT_ROOT STD { int linux_pivot_root(void); }
|
||||
156 AUE_SYSCTL STD { int linux_sysctl( \
|
||||
struct l___sysctl_args *args); }
|
||||
157 AUE_PRCTL STD { int linux_prctl(l_int option, l_uintptr_t arg2, \
|
||||
l_uintptr_t arg3, l_uintptr_t arg4, \
|
||||
l_uintptr_t arg5); }
|
||||
158 AUE_PRCTL STD { int linux_arch_prctl(l_int code, l_ulong addr); }
|
||||
159 AUE_ADJTIME STD { int linux_adjtimex(void); }
|
||||
160 AUE_SETRLIMIT STD { int linux_setrlimit(l_uint resource, \
|
||||
struct l_rlimit *rlim); }
|
||||
161 AUE_CHROOT NOPROTO { int chroot(char *path); }
|
||||
162 AUE_SYNC NOPROTO { int sync(void); }
|
||||
163 AUE_ACCT NOPROTO { int acct(char *path); }
|
||||
164 AUE_SETTIMEOFDAY NOPROTO { int settimeofday(struct l_timeval *tp, struct timezone *tzp); }
|
||||
165 AUE_MOUNT STD { int linux_mount(char *specialfile, \
|
||||
char *dir, char *filesystemtype, \
|
||||
l_ulong rwflag, void *data); }
|
||||
166 AUE_UMOUNT STD { int linux_umount(char *path, l_int flags); }
|
||||
167 AUE_SWAPON NOPROTO { int swapon(char *name); }
|
||||
168 AUE_SWAPOFF STD { int linux_swapoff(void); }
|
||||
169 AUE_REBOOT STD { int linux_reboot(l_int magic1, \
|
||||
l_int magic2, l_uint cmd, void *arg); }
|
||||
170 AUE_SYSCTL STD { int linux_sethostname(char *hostname, \
|
||||
l_uint len); }
|
||||
171 AUE_SYSCTL STD { int linux_setdomainname(char *name, \
|
||||
l_int len); }
|
||||
172 AUE_NULL STD { int linux_iopl(l_uint level); }
|
||||
173 AUE_NULL UNIMPL ioperm
|
||||
174 AUE_NULL STD { int linux_create_module(void); }
|
||||
175 AUE_NULL STD { int linux_init_module(void); }
|
||||
176 AUE_NULL STD { int linux_delete_module(void); }
|
||||
177 AUE_NULL STD { int linux_get_kernel_syms(void); }
|
||||
178 AUE_NULL STD { int linux_query_module(void); }
|
||||
179 AUE_QUOTACTL STD { int linux_quotactl(void); }
|
||||
180 AUE_NULL STD { int linux_nfsservctl(void); }
|
||||
181 AUE_GETPMSG STD { int linux_getpmsg(void); }
|
||||
182 AUE_PUTPMSG STD { int linux_putpmsg(void); }
|
||||
183 AUE_NULL STD { int linux_afs_syscall(void); }
|
||||
184 AUE_NULL STD { int linux_tuxcall(void); }
|
||||
185 AUE_NULL STD { int linux_security(void); }
|
||||
186 AUE_NULL STD { int linux_gettid(void); }
|
||||
187 AUE_NULL UNIMPL linux_readahead
|
||||
188 AUE_NULL STD { int linux_setxattr(void); }
|
||||
189 AUE_NULL STD { int linux_lsetxattr(void); }
|
||||
190 AUE_NULL STD { int linux_fsetxattr(void); }
|
||||
191 AUE_NULL STD { int linux_getxattr(void); }
|
||||
192 AUE_NULL STD { int linux_lgetxattr(void); }
|
||||
193 AUE_NULL STD { int linux_fgetxattr(void); }
|
||||
194 AUE_NULL STD { int linux_listxattr(void); }
|
||||
195 AUE_NULL STD { int linux_llistxattr(void); }
|
||||
196 AUE_NULL STD { int linux_flistxattr(void); }
|
||||
197 AUE_NULL STD { int linux_removexattr(void); }
|
||||
198 AUE_NULL STD { int linux_lremovexattr(void); }
|
||||
199 AUE_NULL STD { int linux_fremovexattr(void); }
|
||||
200 AUE_NULL STD { int linux_tkill(int tid, int sig); }
|
||||
201 AUE_NULL STD { int linux_time(l_time_t *tm); }
|
||||
202 AUE_NULL STD { int linux_sys_futex(void *uaddr, int op, int val, \
|
||||
struct l_timespec *timeout, void *uaddr2, int val3); }
|
||||
203 AUE_NULL STD { int linux_sched_setaffinity(l_pid_t pid, l_uint len, \
|
||||
l_ulong *user_mask_ptr); }
|
||||
204 AUE_NULL STD { int linux_sched_getaffinity(l_pid_t pid, l_uint len, \
|
||||
l_ulong *user_mask_ptr); }
|
||||
205 AUE_NULL STD { int linux_set_thread_area(void); }
|
||||
206 AUE_NULL UNIMPL linux_io_setup
|
||||
207 AUE_NULL UNIMPL linux_io_destroy
|
||||
208 AUE_NULL UNIMPL linux_io_getevents
|
||||
209 AUE_NULL UNIMPL inux_io_submit
|
||||
210 AUE_NULL UNIMPL linux_io_cancel
|
||||
211 AUE_NULL UNIMPL linux_get_thread_area
|
||||
212 AUE_NULL STD { int linux_lookup_dcookie(void); }
|
||||
213 AUE_NULL STD { int linux_epoll_create(void); }
|
||||
214 AUE_NULL STD { int linux_epoll_ctl_old(void); }
|
||||
215 AUE_NULL STD { int linux_epoll_wait_old(void); }
|
||||
216 AUE_NULL STD { int linux_remap_file_pages(void); }
|
||||
217 AUE_GETDIRENTRIES STD { int linux_getdents64(l_uint fd, \
|
||||
void *dirent, l_uint count); }
|
||||
218 AUE_NULL STD { int linux_set_tid_address(int *tidptr); }
|
||||
219 AUE_NULL UNIMPL restart_syscall
|
||||
220 AUE_NULL STD { int linux_semtimedop(void); }
|
||||
221 AUE_NULL STD { int linux_fadvise64(int fd, l_loff_t offset, \
|
||||
l_size_t len, int advice); }
|
||||
222 AUE_NULL STD { int linux_timer_create(clockid_t clock_id, \
|
||||
struct sigevent *evp, l_timer_t *timerid); }
|
||||
223 AUE_NULL STD { int linux_timer_settime(l_timer_t timerid, l_int flags, \
|
||||
const struct itimerspec *new, struct itimerspec *old); }
|
||||
224 AUE_NULL STD { int linux_timer_gettime(l_timer_t timerid, struct itimerspec *setting); }
|
||||
225 AUE_NULL STD { int linux_timer_getoverrun(l_timer_t timerid); }
|
||||
226 AUE_NULL STD { int linux_timer_delete(l_timer_t timerid); }
|
||||
227 AUE_CLOCK_SETTIME STD { int linux_clock_settime(clockid_t which, struct l_timespec *tp); }
|
||||
228 AUE_NULL STD { int linux_clock_gettime(clockid_t which, struct l_timespec *tp); }
|
||||
229 AUE_NULL STD { int linux_clock_getres(clockid_t which, struct l_timespec *tp); }
|
||||
230 AUE_NULL STD { int linux_clock_nanosleep(clockid_t which, int flags, \
|
||||
struct l_timespec *rqtp, struct l_timespec *rmtp); }
|
||||
231 AUE_EXIT STD { int linux_exit_group(int error_code); }
|
||||
232 AUE_NULL STD { int linux_epoll_wait(void); }
|
||||
233 AUE_NULL STD { int linux_epoll_ctl(void); }
|
||||
234 AUE_NULL STD { int linux_tgkill(int tgid, int pid, int sig); }
|
||||
235 AUE_UTIMES STD { int linux_utimes(char *fname, \
|
||||
struct l_timeval *tptr); }
|
||||
236 AUE_NULL UNIMPL vserver
|
||||
237 AUE_NULL STD { int linux_mbind(void); }
|
||||
238 AUE_NULL STD { int linux_set_mempolicy(void); }
|
||||
239 AUE_NULL STD { int linux_get_mempolicy(void); }
|
||||
240 AUE_NULL STD { int linux_mq_open(void); }
|
||||
241 AUE_NULL STD { int linux_mq_unlink(void); }
|
||||
242 AUE_NULL STD { int linux_mq_timedsend(void); }
|
||||
243 AUE_NULL STD { int linux_mq_timedreceive(void); }
|
||||
244 AUE_NULL STD { int linux_mq_notify(void); }
|
||||
245 AUE_NULL STD { int linux_mq_getsetattr(void); }
|
||||
246 AUE_NULL STD { int linux_kexec_load(void); }
|
||||
247 AUE_WAIT6 STD { int linux_waitid(int idtype, l_pid_t id, \
|
||||
l_siginfo_t *info, int options, \
|
||||
struct rusage *rusage); }
|
||||
248 AUE_NULL STD { int linux_add_key(void); }
|
||||
249 AUE_NULL STD { int linux_request_key(void); }
|
||||
250 AUE_NULL STD { int linux_keyctl(void); }
|
||||
251 AUE_NULL STD { int linux_ioprio_set(void); }
|
||||
252 AUE_NULL STD { int linux_ioprio_get(void); }
|
||||
253 AUE_NULL STD { int linux_inotify_init(void); }
|
||||
254 AUE_NULL STD { int linux_inotify_add_watch(void); }
|
||||
255 AUE_NULL STD { int linux_inotify_rm_watch(void); }
|
||||
256 AUE_NULL STD { int linux_migrate_pages(void); }
|
||||
257 AUE_OPEN_RWTC STD { int linux_openat(l_int dfd, const char *filename, \
|
||||
l_int flags, l_int mode); }
|
||||
258 AUE_MKDIRAT STD { int linux_mkdirat(l_int dfd, const char *pathname, \
|
||||
l_int mode); }
|
||||
259 AUE_MKNODAT STD { int linux_mknodat(l_int dfd, const char *filename, \
|
||||
l_int mode, l_uint dev); }
|
||||
260 AUE_FCHOWNAT STD { int linux_fchownat(l_int dfd, const char *filename, \
|
||||
l_uid_t uid, l_gid_t gid, l_int flag); }
|
||||
261 AUE_FUTIMESAT STD { int linux_futimesat(l_int dfd, char *filename, \
|
||||
struct l_timeval *utimes); }
|
||||
262 AUE_FSTATAT STD { int linux_newfstatat(l_int dfd, char *pathname, \
|
||||
struct l_stat64 *statbuf, l_int flag); }
|
||||
263 AUE_UNLINKAT STD { int linux_unlinkat(l_int dfd, const char *pathname, \
|
||||
l_int flag); }
|
||||
264 AUE_RENAMEAT STD { int linux_renameat(l_int olddfd, const char *oldname, \
|
||||
l_int newdfd, const char *newname); }
|
||||
265 AUE_LINKAT STD { int linux_linkat(l_int olddfd, const char *oldname, \
|
||||
l_int newdfd, const char *newname, l_int flag); }
|
||||
266 AUE_SYMLINKAT STD { int linux_symlinkat(const char *oldname, l_int newdfd, \
|
||||
const char *newname); }
|
||||
267 AUE_READLINKAT STD { int linux_readlinkat(l_int dfd, const char *path, \
|
||||
char *buf, l_int bufsiz); }
|
||||
268 AUE_FCHMODAT STD { int linux_fchmodat(l_int dfd, const char *filename, \
|
||||
l_mode_t mode); }
|
||||
269 AUE_FACCESSAT STD { int linux_faccessat(l_int dfd, const char *filename, \
|
||||
l_int amode, l_int flag); }
|
||||
270 AUE_SELECT STD { int linux_pselect6(l_int nfds, \
|
||||
l_fd_set *readfds, l_fd_set *writefds, l_fd_set *exceptfds, \
|
||||
struct l_timespec *tsp, l_uintptr_t *sig); }
|
||||
271 AUE_NULL STD { int linux_ppoll(void); }
|
||||
272 AUE_NULL STD { int linux_unshare(void); }
|
||||
273 AUE_NULL STD { int linux_set_robust_list(struct linux_robust_list_head *head, \
|
||||
l_size_t len); }
|
||||
274 AUE_NULL STD { int linux_get_robust_list(l_int pid, struct linux_robust_list_head *head, \
|
||||
l_size_t *len); }
|
||||
275 AUE_NULL STD { int linux_splice(void); }
|
||||
276 AUE_NULL STD { int linux_tee(void); }
|
||||
277 AUE_NULL STD { int linux_sync_file_range(void); }
|
||||
278 AUE_NULL STD { int linux_vmsplice(void); }
|
||||
279 AUE_NULL STD { int linux_move_pages(void); }
|
||||
280 AUE_NULL STD { int linux_utimensat(void); }
|
||||
281 AUE_NULL STD { int linux_epoll_pwait(void); }
|
||||
282 AUE_NULL STD { int linux_signalfd(void); }
|
||||
283 AUE_NULL STD { int linux_timerfd(void); }
|
||||
284 AUE_NULL STD { int linux_eventfd(void); }
|
||||
285 AUE_NULL STD { int linux_fallocate(void); }
|
||||
286 AUE_NULL STD { int linux_timerfd_settime(void); }
|
||||
287 AUE_NULL STD { int linux_timerfd_gettime(void); }
|
||||
288 AUE_ACCEPT STD { int linux_accept4(l_int s, l_uintptr_t addr, \
|
||||
l_uintptr_t namelen, int flags); }
|
||||
289 AUE_NULL STD { int linux_signalfd4(void); }
|
||||
290 AUE_NULL STD { int linux_eventfd2(void); }
|
||||
291 AUE_NULL STD { int linux_epoll_create1(void); }
|
||||
292 AUE_NULL STD { int linux_dup3(l_int oldfd, \
|
||||
l_int newfd, l_int flags); }
|
||||
293 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); }
|
||||
294 AUE_NULL STD { int linux_inotify_init1(void); }
|
||||
295 AUE_NULL STD { int linux_preadv(void); }
|
||||
296 AUE_NULL STD { int linux_pwritev(void); }
|
||||
297 AUE_NULL STD { int linux_rt_tsigqueueinfo(void); }
|
||||
298 AUE_NULL STD { int linux_perf_event_open(void); }
|
||||
299 AUE_NULL STD { int linux_recvmmsg(void); }
|
||||
300 AUE_NULL STD { int linux_fanotify_init(void); }
|
||||
301 AUE_NULL STD { int linux_fanotify_mark(void); }
|
||||
302 AUE_NULL STD { int linux_prlimit64(l_pid_t pid, l_uint resource, \
|
||||
struct rlimit *new, struct rlimit *old); }
|
||||
303 AUE_NULL STD { int linux_name_to_handle_at(void); }
|
||||
304 AUE_NULL STD { int linux_open_by_handle_at(void); }
|
||||
305 AUE_NULL STD { int linux_clock_adjtime(void); }
|
||||
306 AUE_NULL STD { int linux_syncfs(void); }
|
||||
307 AUE_NULL STD { int linux_sendmmsg(void); }
|
||||
308 AUE_NULL STD { int linux_setns(void); }
|
||||
309 AUE_NULL STD { int linux_process_vm_readv(void); }
|
||||
310 AUE_NULL STD { int linux_process_vm_writev(void); }
|
||||
311 AUE_NULL STD { int linux_kcmp(void); }
|
||||
312 AUE_NULL STD { int linux_finit_module(void); }
|
55
sys/modules/linux64/Makefile
Normal file
55
sys/modules/linux64/Makefile
Normal file
@ -0,0 +1,55 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../compat/linux ${.CURDIR}/../../${MACHINE_ARCH}/linux
|
||||
|
||||
VDSO= linux_vdso
|
||||
|
||||
KMOD= linux64
|
||||
SRCS= linux_fork.c linux_dummy.c linux_file.c \
|
||||
linux_futex.c linux_getcwd.c linux_ioctl.c linux_ipc.c \
|
||||
linux_machdep.c linux_misc.c linux_signal.c \
|
||||
linux_socket.c linux_stats.c linux_sysctl.c linux_sysent.c \
|
||||
linux_sysvec.c linux_time.c linux_vdso.c linux_timer.c \
|
||||
opt_inet6.h opt_compat.h opt_kdtrace.h opt_posix.h opt_usb.h \
|
||||
vnode_if.h device_if.h bus_if.h assym.s \
|
||||
linux_support.s
|
||||
DPSRCS= linux_genassym.c
|
||||
|
||||
# XXX: for assym.s
|
||||
SRCS+= opt_kstack_pages.h opt_nfs.h opt_apic.h opt_hwpmc_hooks.h
|
||||
|
||||
CLEANFILES= linux_assym.h linux_genassym.o linux_locore.o
|
||||
|
||||
OBJS= ${VDSO}.so
|
||||
|
||||
linux_assym.h: linux_genassym.o
|
||||
sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET}
|
||||
|
||||
linux_locore.o: linux_locore.s linux_assym.h
|
||||
${CC} -x assembler-with-cpp -DLOCORE -shared -mcmodel=small \
|
||||
-pipe -I. -I${SYSDIR} -Werror -Wall -fno-common -nostdinc \
|
||||
-Wl,-T${.CURDIR}/../../${MACHINE_CPUARCH}/linux/${VDSO}.lds.s \
|
||||
-Wl,-soname=${VDSO}.so.1,-fPIC,-warn-common -nostdlib \
|
||||
${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
${VDSO}.so: linux_locore.o
|
||||
${OBJCOPY} --input binary --output elf64-x86-64-freebsd \
|
||||
-S -g --binary-architecture i386:x86-64 linux_locore.o ${.TARGET}
|
||||
|
||||
linux_support.o: assym.s linux_assym.h
|
||||
${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
|
||||
${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
linux_genassym.o:
|
||||
${CC} -c ${CFLAGS:N-fno-common} ${.IMPSRC}
|
||||
|
||||
.if !defined(KERNBUILDDIR)
|
||||
.if defined(DEBUG)
|
||||
CFLAGS+=-DDEBUG
|
||||
.endif
|
||||
.if defined(KTR)
|
||||
CFLAGS+=-DKTR
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.include <bsd.kmod.mk>
|
Loading…
x
Reference in New Issue
Block a user