Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/linux32/linux32_sysvec.c
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 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"); | |||||
#define AUXARGS_ENTRY_32(pos, id, val) \ | #define AUXARGS_ENTRY_32(pos, id, val) \ | ||||
do { \ | do { \ | ||||
suword32(pos++, id); \ | suword32(pos++, id); \ | ||||
suword32(pos++, val); \ | suword32(pos++, val); \ | ||||
} while (0) | } while (0) | ||||
#if BYTE_ORDER == LITTLE_ENDIAN | #if BYTE_ORDER == LITTLE_ENDIAN | ||||
#define SHELLMAGIC 0x2123 /* #! */ | #define SHELLMAGIC 0x2123 /* #! */ | ||||
Show All 15 Lines | |||||
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_linux32_locore_o_start; | extern char _binary_linux32_locore_o_start; | ||||
extern char _binary_linux32_locore_o_end; | extern char _binary_linux32_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 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 register_t *linux_copyout_strings(struct image_params *imgp); | static register_t *linux_copyout_strings(struct image_params *imgp); | ||||
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); | ||||
static void linux32_fixlimit(struct rlimit *rl, int which); | static void linux32_fixlimit(struct rlimit *rl, int which); | ||||
▲ Show 20 Lines • Show All 838 Lines • ▼ Show 20 Lines | SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxdsiz, CTLFLAG_RW, | ||||
&linux32_maxdsiz, 0, ""); | &linux32_maxdsiz, 0, ""); | ||||
static u_long linux32_maxssiz = LINUX32_MAXSSIZ; | static u_long linux32_maxssiz = LINUX32_MAXSSIZ; | ||||
SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxssiz, CTLFLAG_RW, | SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxssiz, CTLFLAG_RW, | ||||
&linux32_maxssiz, 0, ""); | &linux32_maxssiz, 0, ""); | ||||
static u_long linux32_maxvmem = LINUX32_MAXVMEM; | static u_long linux32_maxvmem = LINUX32_MAXVMEM; | ||||
SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxvmem, CTLFLAG_RW, | SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxvmem, CTLFLAG_RW, | ||||
&linux32_maxvmem, 0, ""); | &linux32_maxvmem, 0, ""); | ||||
#if defined(DEBUG) | |||||
SYSCTL_PROC(_compat_linux32, OID_AUTO, debug, | |||||
CTLTYPE_STRING | CTLFLAG_RW, | |||||
0, 0, linux_sysctl_debug, "A", | |||||
"Linux debugging control"); | |||||
#endif | |||||
static void | static void | ||||
linux32_fixlimit(struct rlimit *rl, int which) | linux32_fixlimit(struct rlimit *rl, int which) | ||||
{ | { | ||||
switch (which) { | switch (which) { | ||||
case RLIMIT_DATA: | case RLIMIT_DATA: | ||||
if (linux32_maxdsiz != 0) { | if (linux32_maxdsiz != 0) { | ||||
if (rl->rlim_cur > linux32_maxdsiz) | if (rl->rlim_cur > linux32_maxdsiz) | ||||
▲ Show 20 Lines • Show All 159 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_exec_tag = EVENTHANDLER_REGISTER(process_exec, | ||||
linux_proc_exec, NULL, 1000); | linux_proc_exec, 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_osd_jail_register(); | |||||
stclohz = (stathz ? stathz : hz); | stclohz = (stathz ? stathz : hz); | ||||
if (bootverbose) | if (bootverbose) | ||||
printf("Linux ELF exec handler installed\n"); | printf("Linux ELF exec handler installed\n"); | ||||
} else | } else | ||||
printf("cannot insert Linux ELF brand handler\n"); | printf("cannot insert Linux ELF brand handler\n"); | ||||
break; | break; | ||||
case MOD_UNLOAD: | case MOD_UNLOAD: | ||||
for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; | for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; | ||||
++brandinfo) | ++brandinfo) | ||||
if (elf32_brand_inuse(*brandinfo)) | if (elf32_brand_inuse(*brandinfo)) | ||||
error = EBUSY; | error = EBUSY; | ||||
if (error == 0) { | 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(); | |||||
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"); | ||||
break; | break; | ||||
default: | default: | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
static moduledata_t linux_elf_mod = { | static moduledata_t linux_elf_mod = { | ||||
"linuxelf", | "linuxelf", | ||||
linux_elf_modevent, | linux_elf_modevent, | ||||
0 | 0 | ||||
}; | }; | ||||
DECLARE_MODULE_TIED(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY); | DECLARE_MODULE_TIED(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY); | ||||
MODULE_DEPEND(linuxelf, linux_common, 1, 1, 1); |