Deleted Added
full compact
linux_sysvec.c (283411) linux_sysvec.c (283421)
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>
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 283411 2015-05-24 15:32:52Z dchagin $");
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>
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>
47#include <sys/sysent.h>
48#include <sys/sysproto.h>
49#include <sys/vnode.h>
50#include <sys/eventhandler.h>
51
52#include <vm/vm.h>
53#include <vm/pmap.h>
54#include <vm/vm_extern.h>

--- 15 unchanged lines hidden (view full) ---

70#include <compat/linux/linux_mib.h>
71#include <compat/linux/linux_misc.h>
72#include <compat/linux/linux_signal.h>
73#include <compat/linux/linux_util.h>
74#include <compat/linux/linux_vdso.h>
75
76MODULE_VERSION(linux, 1);
77
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
78MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures");
79
80#if BYTE_ORDER == LITTLE_ENDIAN
81#define SHELLMAGIC 0x2123 /* #! */
82#else
83#define SHELLMAGIC 0x2321
84#endif
85
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
86/*
87 * Allow the sendsig functions to use the ldebug() facility
88 * even though they are not syscalls themselves. Map them
89 * to syscall 0. This is slightly less bogus than using
90 * ldebug(sigreturn).
91 */
92#define LINUX_SYS_linux_rt_sendsig 0
93#define LINUX_SYS_linux_sendsig 0

--- 4 unchanged lines hidden (view full) ---

98static vm_object_t linux_shared_page_obj;
99static char *linux_shared_page_mapping;
100extern char _binary_linux_locore_o_start;
101extern char _binary_linux_locore_o_end;
102
103extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
104
105SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
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);
106SET_DECLARE(linux_device_handler_set, struct linux_device_handler);
107
108static int linux_fixup(register_t **stack_base,
109 struct image_params *iparams);
110static int elf_linux_fixup(register_t **stack_base,
111 struct image_params *iparams);
112static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
113static void exec_linux_setregs(struct thread *td,
114 struct image_params *imgp, u_long stack);

--- 1009 unchanged lines hidden (view full) ---

1124};
1125
1126static int
1127linux_elf_modevent(module_t mod, int type, void *data)
1128{
1129 Elf32_Brandinfo **brandinfo;
1130 int error;
1131 struct linux_ioctl_handler **lihp;
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;
1132 struct linux_device_handler **ldhp;
1133
1134 error = 0;
1135
1136 switch(type) {
1137 case MOD_LOAD:
1138 for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
1139 ++brandinfo)
1140 if (elf32_insert_brand_entry(*brandinfo) < 0)
1141 error = EINVAL;
1142 if (error == 0) {
1143 SET_FOREACH(lihp, linux_ioctl_handler_set)
1144 linux_ioctl_register_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);
1145 SET_FOREACH(ldhp, linux_device_handler_set)
1146 linux_device_register_handler(*ldhp);
1147 LIST_INIT(&futex_list);
1148 mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
1149 linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit,
1150 NULL, 1000);
1151 linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec,
1152 NULL, 1000);
1153 linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
1154 linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);

--- 16 unchanged lines hidden (view full) ---

1171 for (brandinfo = &linux_brandlist[0];
1172 *brandinfo != NULL; ++brandinfo)
1173 if (elf32_remove_brand_entry(*brandinfo) < 0)
1174 error = EINVAL;
1175 }
1176 if (error == 0) {
1177 SET_FOREACH(lihp, linux_ioctl_handler_set)
1178 linux_ioctl_unregister_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);
1179 SET_FOREACH(ldhp, linux_device_handler_set)
1180 linux_device_unregister_handler(*ldhp);
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 ---
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 ---