Deleted Added
full compact
linux32_sysvec.c (283411) linux32_sysvec.c (283421)
1/*-
2 * Copyright (c) 2004 Tim J. Robbins
3 * Copyright (c) 2003 Peter Wemm
4 * Copyright (c) 2002 Doug Rabson
5 * Copyright (c) 1998-1999 Andrew Gallatin
6 * Copyright (c) 1994-1996 S��ren Schmidt
7 * All rights reserved.
8 *

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

26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Tim J. Robbins
3 * Copyright (c) 2003 Peter Wemm
4 * Copyright (c) 2002 Doug Rabson
5 * Copyright (c) 1998-1999 Andrew Gallatin
6 * Copyright (c) 1994-1996 S��ren Schmidt
7 * All rights reserved.
8 *

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

26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/amd64/linux32/linux32_sysvec.c 283411 2015-05-24 15:32:52Z dchagin $");
34__FBSDID("$FreeBSD: head/sys/amd64/linux32/linux32_sysvec.c 283421 2015-05-24 15:51:18Z dchagin $");
35#include "opt_compat.h"
36
37#ifndef COMPAT_FREEBSD32
38#error "Unable to compile Linux-emulator due to missing COMPAT_FREEBSD32 option!"
39#endif
40
41#define __ELF_WORD_SIZE 32
42

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

82#include <compat/linux/linux_mib.h>
83#include <compat/linux/linux_misc.h>
84#include <compat/linux/linux_signal.h>
85#include <compat/linux/linux_util.h>
86#include <compat/linux/linux_vdso.h>
87
88MODULE_VERSION(linux, 1);
89
35#include "opt_compat.h"
36
37#ifndef COMPAT_FREEBSD32
38#error "Unable to compile Linux-emulator due to missing COMPAT_FREEBSD32 option!"
39#endif
40
41#define __ELF_WORD_SIZE 32
42

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

82#include <compat/linux/linux_mib.h>
83#include <compat/linux/linux_misc.h>
84#include <compat/linux/linux_signal.h>
85#include <compat/linux/linux_util.h>
86#include <compat/linux/linux_vdso.h>
87
88MODULE_VERSION(linux, 1);
89
90MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures");
91
92#define AUXARGS_ENTRY_32(pos, id, val) \
93 do { \
94 suword32(pos++, id); \
95 suword32(pos++, val); \
96 } while (0)
97
98#if BYTE_ORDER == LITTLE_ENDIAN
99#define SHELLMAGIC 0x2123 /* #! */

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

115static vm_object_t linux_shared_page_obj;
116static char *linux_shared_page_mapping;
117extern char _binary_linux32_locore_o_start;
118extern char _binary_linux32_locore_o_end;
119
120extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
121
122SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
90#define AUXARGS_ENTRY_32(pos, id, val) \
91 do { \
92 suword32(pos++, id); \
93 suword32(pos++, val); \
94 } while (0)
95
96#if BYTE_ORDER == LITTLE_ENDIAN
97#define SHELLMAGIC 0x2123 /* #! */

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

113static vm_object_t linux_shared_page_obj;
114static char *linux_shared_page_mapping;
115extern char _binary_linux32_locore_o_start;
116extern char _binary_linux32_locore_o_end;
117
118extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
119
120SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
123SET_DECLARE(linux_device_handler_set, struct linux_device_handler);
124
125static int elf_linux_fixup(register_t **stack_base,
126 struct image_params *iparams);
127static register_t *linux_copyout_strings(struct image_params *imgp);
128static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
129static void exec_linux_setregs(struct thread *td,
130 struct image_params *imgp, u_long stack);
131static void linux32_fixlimit(struct rlimit *rl, int which);

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

971 &linux32_maxdsiz, 0, "");
972static u_long linux32_maxssiz = LINUX32_MAXSSIZ;
973SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxssiz, CTLFLAG_RW,
974 &linux32_maxssiz, 0, "");
975static u_long linux32_maxvmem = LINUX32_MAXVMEM;
976SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxvmem, CTLFLAG_RW,
977 &linux32_maxvmem, 0, "");
978
121
122static int elf_linux_fixup(register_t **stack_base,
123 struct image_params *iparams);
124static register_t *linux_copyout_strings(struct image_params *imgp);
125static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
126static void exec_linux_setregs(struct thread *td,
127 struct image_params *imgp, u_long stack);
128static void linux32_fixlimit(struct rlimit *rl, int which);

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

968 &linux32_maxdsiz, 0, "");
969static u_long linux32_maxssiz = LINUX32_MAXSSIZ;
970SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxssiz, CTLFLAG_RW,
971 &linux32_maxssiz, 0, "");
972static u_long linux32_maxvmem = LINUX32_MAXVMEM;
973SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxvmem, CTLFLAG_RW,
974 &linux32_maxvmem, 0, "");
975
976#if defined(DEBUG)
977SYSCTL_PROC(_compat_linux32, OID_AUTO, debug,
978 CTLTYPE_STRING | CTLFLAG_RW,
979 0, 0, linux_sysctl_debug, "A",
980 "Linux debugging control");
981#endif
982
979static void
980linux32_fixlimit(struct rlimit *rl, int which)
981{
982
983 switch (which) {
984 case RLIMIT_DATA:
985 if (linux32_maxdsiz != 0) {
986 if (rl->rlim_cur > linux32_maxdsiz)

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

1147};
1148
1149static int
1150linux_elf_modevent(module_t mod, int type, void *data)
1151{
1152 Elf32_Brandinfo **brandinfo;
1153 int error;
1154 struct linux_ioctl_handler **lihp;
983static void
984linux32_fixlimit(struct rlimit *rl, int which)
985{
986
987 switch (which) {
988 case RLIMIT_DATA:
989 if (linux32_maxdsiz != 0) {
990 if (rl->rlim_cur > linux32_maxdsiz)

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

1151};
1152
1153static int
1154linux_elf_modevent(module_t mod, int type, void *data)
1155{
1156 Elf32_Brandinfo **brandinfo;
1157 int error;
1158 struct linux_ioctl_handler **lihp;
1155 struct linux_device_handler **ldhp;
1156
1157 error = 0;
1158
1159 switch(type) {
1160 case MOD_LOAD:
1161 for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
1162 ++brandinfo)
1163 if (elf32_insert_brand_entry(*brandinfo) < 0)
1164 error = EINVAL;
1165 if (error == 0) {
1166 SET_FOREACH(lihp, linux_ioctl_handler_set)
1167 linux_ioctl_register_handler(*lihp);
1159
1160 error = 0;
1161
1162 switch(type) {
1163 case MOD_LOAD:
1164 for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
1165 ++brandinfo)
1166 if (elf32_insert_brand_entry(*brandinfo) < 0)
1167 error = EINVAL;
1168 if (error == 0) {
1169 SET_FOREACH(lihp, linux_ioctl_handler_set)
1170 linux_ioctl_register_handler(*lihp);
1168 SET_FOREACH(ldhp, linux_device_handler_set)
1169 linux_device_register_handler(*ldhp);
1170 LIST_INIT(&futex_list);
1171 mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
1172 linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
1173 linux_proc_exit, NULL, 1000);
1174 linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
1175 linux_proc_exec, NULL, 1000);
1176 linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
1177 linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
1171 LIST_INIT(&futex_list);
1172 mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
1173 linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
1174 linux_proc_exit, NULL, 1000);
1175 linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
1176 linux_proc_exec, NULL, 1000);
1177 linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
1178 linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
1178 linux_osd_jail_register();
1179 stclohz = (stathz ? stathz : hz);
1180 if (bootverbose)
1181 printf("Linux ELF exec handler installed\n");
1182 } else
1183 printf("cannot insert Linux ELF brand handler\n");
1184 break;
1185 case MOD_UNLOAD:
1186 for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;

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

1191 for (brandinfo = &linux_brandlist[0];
1192 *brandinfo != NULL; ++brandinfo)
1193 if (elf32_remove_brand_entry(*brandinfo) < 0)
1194 error = EINVAL;
1195 }
1196 if (error == 0) {
1197 SET_FOREACH(lihp, linux_ioctl_handler_set)
1198 linux_ioctl_unregister_handler(*lihp);
1179 stclohz = (stathz ? stathz : hz);
1180 if (bootverbose)
1181 printf("Linux ELF exec handler installed\n");
1182 } else
1183 printf("cannot insert Linux ELF brand handler\n");
1184 break;
1185 case MOD_UNLOAD:
1186 for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;

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

1191 for (brandinfo = &linux_brandlist[0];
1192 *brandinfo != NULL; ++brandinfo)
1193 if (elf32_remove_brand_entry(*brandinfo) < 0)
1194 error = EINVAL;
1195 }
1196 if (error == 0) {
1197 SET_FOREACH(lihp, linux_ioctl_handler_set)
1198 linux_ioctl_unregister_handler(*lihp);
1199 SET_FOREACH(ldhp, linux_device_handler_set)
1200 linux_device_unregister_handler(*ldhp);
1201 mtx_destroy(&futex_mtx);
1202 EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
1203 EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
1204 EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
1199 mtx_destroy(&futex_mtx);
1200 EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
1201 EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
1202 EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
1205 linux_osd_jail_deregister();
1206 if (bootverbose)
1207 printf("Linux ELF exec handler removed\n");
1208 } else
1209 printf("Could not deinstall ELF interpreter entry\n");
1210 break;
1211 default:
1212 return (EOPNOTSUPP);
1213 }
1214 return (error);
1215}
1216
1217static moduledata_t linux_elf_mod = {
1218 "linuxelf",
1219 linux_elf_modevent,
1220 0
1221};
1222
1223DECLARE_MODULE_TIED(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
1203 if (bootverbose)
1204 printf("Linux ELF exec handler removed\n");
1205 } else
1206 printf("Could not deinstall ELF interpreter entry\n");
1207 break;
1208 default:
1209 return (EOPNOTSUPP);
1210 }
1211 return (error);
1212}
1213
1214static moduledata_t linux_elf_mod = {
1215 "linuxelf",
1216 linux_elf_modevent,
1217 0
1218};
1219
1220DECLARE_MODULE_TIED(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
1221MODULE_DEPEND(linuxelf, linux_common, 1, 1, 1);