1/*-
2 * Copyright (c) 1994-1996 S��ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 13 unchanged lines hidden (view full) ---
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/i386/linux/linux_sysvec.c 283421 2015-05-24 15:51:18Z dchagin $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/exec.h>
35#include <sys/fcntl.h>
36#include <sys/imgact.h>
37#include <sys/imgact_aout.h>
38#include <sys/imgact_elf.h>
39#include <sys/kernel.h>
40#include <sys/lock.h>
41#include <sys/malloc.h>
42#include <sys/module.h>
43#include <sys/mutex.h>
44#include <sys/proc.h>
45#include <sys/signalvar.h>
46#include <sys/syscallsubr.h>
47#include <sys/sysctl.h>
48#include <sys/sysent.h>
49#include <sys/sysproto.h>
50#include <sys/vnode.h>
51#include <sys/eventhandler.h>
52
53#include <vm/vm.h>
54#include <vm/pmap.h>
55#include <vm/vm_extern.h>
--- 15 unchanged lines hidden (view full) ---
71#include <compat/linux/linux_mib.h>
72#include <compat/linux/linux_misc.h>
73#include <compat/linux/linux_signal.h>
74#include <compat/linux/linux_util.h>
75#include <compat/linux/linux_vdso.h>
76
77MODULE_VERSION(linux, 1);
78
79#if BYTE_ORDER == LITTLE_ENDIAN
80#define SHELLMAGIC 0x2123 /* #! */
81#else
82#define SHELLMAGIC 0x2321
83#endif
84
85#if defined(DEBUG)
86SYSCTL_PROC(_compat_linux, OID_AUTO, debug,
87 CTLTYPE_STRING | CTLFLAG_RW,
88 0, 0, linux_sysctl_debug, "A",
89 "Linux debugging control");
90#endif
91
92/*
93 * Allow the sendsig functions to use the ldebug() facility
94 * even though they are not syscalls themselves. Map them
95 * to syscall 0. This is slightly less bogus than using
96 * ldebug(sigreturn).
97 */
98#define LINUX_SYS_linux_rt_sendsig 0
99#define LINUX_SYS_linux_sendsig 0
--- 4 unchanged lines hidden (view full) ---
104static vm_object_t linux_shared_page_obj;
105static char *linux_shared_page_mapping;
106extern char _binary_linux_locore_o_start;
107extern char _binary_linux_locore_o_end;
108
109extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
110
111SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
112
113static int linux_fixup(register_t **stack_base,
114 struct image_params *iparams);
115static int elf_linux_fixup(register_t **stack_base,
116 struct image_params *iparams);
117static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
118static void exec_linux_setregs(struct thread *td,
119 struct image_params *imgp, u_long stack);
--- 1009 unchanged lines hidden (view full) ---
1129};
1130
1131static int
1132linux_elf_modevent(module_t mod, int type, void *data)
1133{
1134 Elf32_Brandinfo **brandinfo;
1135 int error;
1136 struct linux_ioctl_handler **lihp;
1137
1138 error = 0;
1139
1140 switch(type) {
1141 case MOD_LOAD:
1142 for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
1143 ++brandinfo)
1144 if (elf32_insert_brand_entry(*brandinfo) < 0)
1145 error = EINVAL;
1146 if (error == 0) {
1147 SET_FOREACH(lihp, linux_ioctl_handler_set)
1148 linux_ioctl_register_handler(*lihp);
1149 LIST_INIT(&futex_list);
1150 mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
1151 linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit,
1152 NULL, 1000);
1153 linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec,
1154 NULL, 1000);
1155 linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
1156 linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
--- 16 unchanged lines hidden (view full) ---
1173 for (brandinfo = &linux_brandlist[0];
1174 *brandinfo != NULL; ++brandinfo)
1175 if (elf32_remove_brand_entry(*brandinfo) < 0)
1176 error = EINVAL;
1177 }
1178 if (error == 0) {
1179 SET_FOREACH(lihp, linux_ioctl_handler_set)
1180 linux_ioctl_unregister_handler(*lihp);
1181 mtx_destroy(&futex_mtx);
1182 EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
1183 EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
1184 EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
1185 linux_osd_jail_deregister();
1186 if (bootverbose)
1187 printf("Linux ELF exec handler removed\n");
1188 } else
--- 15 unchanged lines hidden ---
2 * Copyright (c) 1994-1996 S��ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 13 unchanged lines hidden (view full) ---
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/i386/linux/linux_sysvec.c 283421 2015-05-24 15:51:18Z dchagin $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/exec.h>
35#include <sys/fcntl.h>
36#include <sys/imgact.h>
37#include <sys/imgact_aout.h>
38#include <sys/imgact_elf.h>
39#include <sys/kernel.h>
40#include <sys/lock.h>
41#include <sys/malloc.h>
42#include <sys/module.h>
43#include <sys/mutex.h>
44#include <sys/proc.h>
45#include <sys/signalvar.h>
46#include <sys/syscallsubr.h>
47#include <sys/sysctl.h>
48#include <sys/sysent.h>
49#include <sys/sysproto.h>
50#include <sys/vnode.h>
51#include <sys/eventhandler.h>
52
53#include <vm/vm.h>
54#include <vm/pmap.h>
55#include <vm/vm_extern.h>
--- 15 unchanged lines hidden (view full) ---
71#include <compat/linux/linux_mib.h>
72#include <compat/linux/linux_misc.h>
73#include <compat/linux/linux_signal.h>
74#include <compat/linux/linux_util.h>
75#include <compat/linux/linux_vdso.h>
76
77MODULE_VERSION(linux, 1);
78
79#if BYTE_ORDER == LITTLE_ENDIAN
80#define SHELLMAGIC 0x2123 /* #! */
81#else
82#define SHELLMAGIC 0x2321
83#endif
84
85#if defined(DEBUG)
86SYSCTL_PROC(_compat_linux, OID_AUTO, debug,
87 CTLTYPE_STRING | CTLFLAG_RW,
88 0, 0, linux_sysctl_debug, "A",
89 "Linux debugging control");
90#endif
91
92/*
93 * Allow the sendsig functions to use the ldebug() facility
94 * even though they are not syscalls themselves. Map them
95 * to syscall 0. This is slightly less bogus than using
96 * ldebug(sigreturn).
97 */
98#define LINUX_SYS_linux_rt_sendsig 0
99#define LINUX_SYS_linux_sendsig 0
--- 4 unchanged lines hidden (view full) ---
104static vm_object_t linux_shared_page_obj;
105static char *linux_shared_page_mapping;
106extern char _binary_linux_locore_o_start;
107extern char _binary_linux_locore_o_end;
108
109extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
110
111SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
112
113static int linux_fixup(register_t **stack_base,
114 struct image_params *iparams);
115static int elf_linux_fixup(register_t **stack_base,
116 struct image_params *iparams);
117static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
118static void exec_linux_setregs(struct thread *td,
119 struct image_params *imgp, u_long stack);
--- 1009 unchanged lines hidden (view full) ---
1129};
1130
1131static int
1132linux_elf_modevent(module_t mod, int type, void *data)
1133{
1134 Elf32_Brandinfo **brandinfo;
1135 int error;
1136 struct linux_ioctl_handler **lihp;
1137
1138 error = 0;
1139
1140 switch(type) {
1141 case MOD_LOAD:
1142 for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
1143 ++brandinfo)
1144 if (elf32_insert_brand_entry(*brandinfo) < 0)
1145 error = EINVAL;
1146 if (error == 0) {
1147 SET_FOREACH(lihp, linux_ioctl_handler_set)
1148 linux_ioctl_register_handler(*lihp);
1149 LIST_INIT(&futex_list);
1150 mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
1151 linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit,
1152 NULL, 1000);
1153 linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec,
1154 NULL, 1000);
1155 linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
1156 linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
--- 16 unchanged lines hidden (view full) ---
1173 for (brandinfo = &linux_brandlist[0];
1174 *brandinfo != NULL; ++brandinfo)
1175 if (elf32_remove_brand_entry(*brandinfo) < 0)
1176 error = EINVAL;
1177 }
1178 if (error == 0) {
1179 SET_FOREACH(lihp, linux_ioctl_handler_set)
1180 linux_ioctl_unregister_handler(*lihp);
1181 mtx_destroy(&futex_mtx);
1182 EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
1183 EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
1184 EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
1185 linux_osd_jail_deregister();
1186 if (bootverbose)
1187 printf("Linux ELF exec handler removed\n");
1188 } else
--- 15 unchanged lines hidden ---