Changeset View
Changeset View
Standalone View
Standalone View
sys/i386/linux/linux_sysvec.c
Show All 38 Lines | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/syscallsubr.h> | #include <sys/syscallsubr.h> | ||||
#include <sys/sysctl.h> | |||||
#include <sys/sysent.h> | #include <sys/sysent.h> | ||||
#include <sys/sysproto.h> | #include <sys/sysproto.h> | ||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
Show All 15 Lines | |||||
#include <compat/linux/linux_mib.h> | #include <compat/linux/linux_mib.h> | ||||
#include <compat/linux/linux_misc.h> | #include <compat/linux/linux_misc.h> | ||||
#include <compat/linux/linux_signal.h> | #include <compat/linux/linux_signal.h> | ||||
#include <compat/linux/linux_util.h> | #include <compat/linux/linux_util.h> | ||||
#include <compat/linux/linux_vdso.h> | #include <compat/linux/linux_vdso.h> | ||||
MODULE_VERSION(linux, 1); | MODULE_VERSION(linux, 1); | ||||
MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures"); | |||||
#if BYTE_ORDER == LITTLE_ENDIAN | #if BYTE_ORDER == LITTLE_ENDIAN | ||||
#define SHELLMAGIC 0x2123 /* #! */ | #define SHELLMAGIC 0x2123 /* #! */ | ||||
#else | #else | ||||
#define SHELLMAGIC 0x2321 | #define SHELLMAGIC 0x2321 | ||||
#endif | #endif | ||||
#if defined(DEBUG) | |||||
SYSCTL_PROC(_compat_linux, OID_AUTO, debug, | |||||
CTLTYPE_STRING | CTLFLAG_RW, | |||||
0, 0, linux_sysctl_debug, "A", | |||||
"Linux debugging control"); | |||||
#endif | |||||
/* | /* | ||||
* Allow the sendsig functions to use the ldebug() facility | * Allow the sendsig functions to use the ldebug() facility | ||||
* even though they are not syscalls themselves. Map them | * even though they are not syscalls themselves. Map them | ||||
* to syscall 0. This is slightly less bogus than using | * to syscall 0. This is slightly less bogus than using | ||||
* ldebug(sigreturn). | * ldebug(sigreturn). | ||||
*/ | */ | ||||
#define LINUX_SYS_linux_rt_sendsig 0 | #define LINUX_SYS_linux_rt_sendsig 0 | ||||
#define LINUX_SYS_linux_sendsig 0 | #define LINUX_SYS_linux_sendsig 0 | ||||
#define LINUX_PS_STRINGS (LINUX_USRSTACK - sizeof(struct ps_strings)) | #define LINUX_PS_STRINGS (LINUX_USRSTACK - sizeof(struct ps_strings)) | ||||
static int linux_szsigcode; | static int linux_szsigcode; | ||||
static vm_object_t linux_shared_page_obj; | static vm_object_t linux_shared_page_obj; | ||||
static char *linux_shared_page_mapping; | static char *linux_shared_page_mapping; | ||||
extern char _binary_linux_locore_o_start; | extern char _binary_linux_locore_o_start; | ||||
extern char _binary_linux_locore_o_end; | extern char _binary_linux_locore_o_end; | ||||
extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL]; | extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL]; | ||||
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); | SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); | ||||
SET_DECLARE(linux_device_handler_set, struct linux_device_handler); | |||||
static int linux_fixup(register_t **stack_base, | static int linux_fixup(register_t **stack_base, | ||||
struct image_params *iparams); | struct image_params *iparams); | ||||
static int elf_linux_fixup(register_t **stack_base, | static int elf_linux_fixup(register_t **stack_base, | ||||
struct image_params *iparams); | struct image_params *iparams); | ||||
static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); | static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); | ||||
static void exec_linux_setregs(struct thread *td, | static void exec_linux_setregs(struct thread *td, | ||||
struct image_params *imgp, u_long stack); | struct image_params *imgp, u_long stack); | ||||
▲ Show 20 Lines • Show All 1,006 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
static int | static int | ||||
linux_elf_modevent(module_t mod, int type, void *data) | linux_elf_modevent(module_t mod, int type, void *data) | ||||
{ | { | ||||
Elf32_Brandinfo **brandinfo; | Elf32_Brandinfo **brandinfo; | ||||
int error; | int error; | ||||
struct linux_ioctl_handler **lihp; | struct linux_ioctl_handler **lihp; | ||||
struct linux_device_handler **ldhp; | |||||
error = 0; | error = 0; | ||||
switch(type) { | switch(type) { | ||||
case MOD_LOAD: | case MOD_LOAD: | ||||
for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; | for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; | ||||
++brandinfo) | ++brandinfo) | ||||
if (elf32_insert_brand_entry(*brandinfo) < 0) | if (elf32_insert_brand_entry(*brandinfo) < 0) | ||||
error = EINVAL; | error = EINVAL; | ||||
if (error == 0) { | if (error == 0) { | ||||
SET_FOREACH(lihp, linux_ioctl_handler_set) | SET_FOREACH(lihp, linux_ioctl_handler_set) | ||||
linux_ioctl_register_handler(*lihp); | linux_ioctl_register_handler(*lihp); | ||||
SET_FOREACH(ldhp, linux_device_handler_set) | |||||
linux_device_register_handler(*ldhp); | |||||
LIST_INIT(&futex_list); | LIST_INIT(&futex_list); | ||||
mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF); | mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF); | ||||
linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec, | linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec, | ||||
NULL, 1000); | NULL, 1000); | ||||
linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, | linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, | ||||
linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY); | linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY); | ||||
linux_get_machine(&linux_kplatform); | linux_get_machine(&linux_kplatform); | ||||
linux_szplatform = roundup(strlen(linux_kplatform) + 1, | linux_szplatform = roundup(strlen(linux_kplatform) + 1, | ||||
Show All 14 Lines | if (error == 0) { | ||||
for (brandinfo = &linux_brandlist[0]; | for (brandinfo = &linux_brandlist[0]; | ||||
*brandinfo != NULL; ++brandinfo) | *brandinfo != NULL; ++brandinfo) | ||||
if (elf32_remove_brand_entry(*brandinfo) < 0) | if (elf32_remove_brand_entry(*brandinfo) < 0) | ||||
error = EINVAL; | error = EINVAL; | ||||
} | } | ||||
if (error == 0) { | if (error == 0) { | ||||
SET_FOREACH(lihp, linux_ioctl_handler_set) | SET_FOREACH(lihp, linux_ioctl_handler_set) | ||||
linux_ioctl_unregister_handler(*lihp); | linux_ioctl_unregister_handler(*lihp); | ||||
SET_FOREACH(ldhp, linux_device_handler_set) | |||||
linux_device_unregister_handler(*ldhp); | |||||
mtx_destroy(&futex_mtx); | mtx_destroy(&futex_mtx); | ||||
EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag); | EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag); | ||||
EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag); | EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag); | ||||
linux_osd_jail_deregister(); | linux_osd_jail_deregister(); | ||||
if (bootverbose) | if (bootverbose) | ||||
printf("Linux ELF exec handler removed\n"); | printf("Linux ELF exec handler removed\n"); | ||||
} else | } else | ||||
printf("Could not deinstall ELF interpreter entry\n"); | printf("Could not deinstall ELF interpreter entry\n"); | ||||
Show All 14 Lines |