Deleted Added
full compact
linux32_sysvec.c (293514) linux32_sysvec.c (293516)
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: stable/10/sys/amd64/linux32/linux32_sysvec.c 293514 2016-01-09 15:44:38Z dchagin $");
34__FBSDID("$FreeBSD: stable/10/sys/amd64/linux32/linux32_sysvec.c 293516 2016-01-09 15:48:11Z 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

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

105 * Allow the sendsig functions to use the ldebug() facility
106 * even though they are not syscalls themselves. Map them
107 * to syscall 0. This is slightly less bogus than using
108 * ldebug(sigreturn).
109 */
110#define LINUX_SYS_linux_rt_sendsig 0
111#define LINUX_SYS_linux_sendsig 0
112
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

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

105 * Allow the sendsig functions to use the ldebug() facility
106 * even though they are not syscalls themselves. Map them
107 * to syscall 0. This is slightly less bogus than using
108 * ldebug(sigreturn).
109 */
110#define LINUX_SYS_linux_rt_sendsig 0
111#define LINUX_SYS_linux_sendsig 0
112
113const char *linux_platform = "i686";
114static int linux_szplatform;
113const char *linux_kplatform;
115static int linux_szsigcode;
116static vm_object_t linux_shared_page_obj;
117static char *linux_shared_page_mapping;
118extern char _binary_linux32_locore_o_start;
119extern char _binary_linux32_locore_o_end;
120
121extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
122

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

224 u_int ps_nargvstr; /* the number of argument strings */
225 u_int32_t ps_envstr; /* first of 0 or more environment strings */
226 u_int ps_nenvstr; /* the number of environment strings */
227};
228
229LINUX_VDSO_SYM_INTPTR(linux32_sigcode);
230LINUX_VDSO_SYM_INTPTR(linux32_rt_sigcode);
231LINUX_VDSO_SYM_INTPTR(linux32_vsyscall);
114static int linux_szsigcode;
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

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

223 u_int ps_nargvstr; /* the number of argument strings */
224 u_int32_t ps_envstr; /* first of 0 or more environment strings */
225 u_int ps_nenvstr; /* the number of environment strings */
226};
227
228LINUX_VDSO_SYM_INTPTR(linux32_sigcode);
229LINUX_VDSO_SYM_INTPTR(linux32_rt_sigcode);
230LINUX_VDSO_SYM_INTPTR(linux32_vsyscall);
231LINUX_VDSO_SYM_CHAR(linux_platform);
232
233/*
234 * If FreeBSD & Linux have a difference of opinion about what a trap
235 * means, deal with it here.
236 *
237 * MPSAFE
238 */
239static int

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

252 }
253}
254
255static int
256elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
257{
258 Elf32_Auxargs *args;
259 Elf32_Addr *base;
232
233/*
234 * If FreeBSD & Linux have a difference of opinion about what a trap
235 * means, deal with it here.
236 *
237 * MPSAFE
238 */
239static int

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

252 }
253}
254
255static int
256elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
257{
258 Elf32_Auxargs *args;
259 Elf32_Addr *base;
260 Elf32_Addr *pos, *uplatform;
260 Elf32_Addr *pos;
261 struct linux32_ps_strings *arginfo;
262
263 arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
261 struct linux32_ps_strings *arginfo;
262
263 arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
264 uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szplatform);
265
266 KASSERT(curthread->td_proc == imgp->proc,
267 ("unsafe elf_linux_fixup(), should be curproc"));
268 base = (Elf32_Addr *)*stack_base;
269 args = (Elf32_Auxargs *)imgp->auxargs;
270 pos = base + (imgp->args->argc + imgp->args->envc + 2);
271
272 AUXARGS_ENTRY_32(pos, LINUX_AT_SYSINFO_EHDR,

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

291 AUXARGS_ENTRY_32(pos, AT_FLAGS, args->flags);
292 AUXARGS_ENTRY_32(pos, AT_ENTRY, args->entry);
293 AUXARGS_ENTRY_32(pos, AT_BASE, args->base);
294 AUXARGS_ENTRY_32(pos, LINUX_AT_SECURE, 0);
295 AUXARGS_ENTRY_32(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
296 AUXARGS_ENTRY_32(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
297 AUXARGS_ENTRY_32(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
298 AUXARGS_ENTRY_32(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
264
265 KASSERT(curthread->td_proc == imgp->proc,
266 ("unsafe elf_linux_fixup(), should be curproc"));
267 base = (Elf32_Addr *)*stack_base;
268 args = (Elf32_Auxargs *)imgp->auxargs;
269 pos = base + (imgp->args->argc + imgp->args->envc + 2);
270
271 AUXARGS_ENTRY_32(pos, LINUX_AT_SYSINFO_EHDR,

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

290 AUXARGS_ENTRY_32(pos, AT_FLAGS, args->flags);
291 AUXARGS_ENTRY_32(pos, AT_ENTRY, args->entry);
292 AUXARGS_ENTRY_32(pos, AT_BASE, args->base);
293 AUXARGS_ENTRY_32(pos, LINUX_AT_SECURE, 0);
294 AUXARGS_ENTRY_32(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
295 AUXARGS_ENTRY_32(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
296 AUXARGS_ENTRY_32(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
297 AUXARGS_ENTRY_32(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
299 AUXARGS_ENTRY_32(pos, LINUX_AT_PLATFORM, PTROUT(uplatform));
298 AUXARGS_ENTRY_32(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
300 if (args->execfd != -1)
301 AUXARGS_ENTRY_32(pos, AT_EXECFD, args->execfd);
302 AUXARGS_ENTRY_32(pos, AT_NULL, 0);
303
304 free(imgp->auxargs, M_TEMP);
305 imgp->auxargs = NULL;
306
307 base--;

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

878 u_int32_t *stack_base;
879 struct linux32_ps_strings *arginfo;
880
881 /*
882 * Calculate string base and vector table pointers.
883 * Also deal with signal trampoline code for this exec type.
884 */
885 arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
299 if (args->execfd != -1)
300 AUXARGS_ENTRY_32(pos, AT_EXECFD, args->execfd);
301 AUXARGS_ENTRY_32(pos, AT_NULL, 0);
302
303 free(imgp->auxargs, M_TEMP);
304 imgp->auxargs = NULL;
305
306 base--;

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

877 u_int32_t *stack_base;
878 struct linux32_ps_strings *arginfo;
879
880 /*
881 * Calculate string base and vector table pointers.
882 * Also deal with signal trampoline code for this exec type.
883 */
884 arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
886 destp = (caddr_t)arginfo - SPARE_USRSPACE - linux_szplatform -
887 roundup((ARG_MAX - imgp->args->stringspace),
888 sizeof(char *));
885 destp = (caddr_t)arginfo - SPARE_USRSPACE -
886 roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *));
889
890 /*
887
888 /*
891 * Install LINUX_PLATFORM
892 */
893 copyout(linux_platform, ((caddr_t)arginfo - linux_szplatform),
894 linux_szplatform);
895
896 /*
897 * If we have a valid auxargs ptr, prepare some room
898 * on the stack.
899 */
900 if (imgp->auxargs) {
901 /*
902 * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
903 * lower compatibility.
904 */

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

1070 linux_shared_page_obj = __elfN(linux_shared_page_init)
1071 (&linux_shared_page_mapping);
1072
1073 __elfN(linux_vdso_reloc)(&elf_linux_sysvec, LINUX32_SHAREDPAGE);
1074
1075 bcopy(elf_linux_sysvec.sv_sigcode, linux_shared_page_mapping,
1076 linux_szsigcode);
1077 elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
889 * If we have a valid auxargs ptr, prepare some room
890 * on the stack.
891 */
892 if (imgp->auxargs) {
893 /*
894 * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
895 * lower compatibility.
896 */

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

1062 linux_shared_page_obj = __elfN(linux_shared_page_init)
1063 (&linux_shared_page_mapping);
1064
1065 __elfN(linux_vdso_reloc)(&elf_linux_sysvec, LINUX32_SHAREDPAGE);
1066
1067 bcopy(elf_linux_sysvec.sv_sigcode, linux_shared_page_mapping,
1068 linux_szsigcode);
1069 elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
1070
1071 linux_kplatform = linux_shared_page_mapping +
1072 (linux_platform - (caddr_t)LINUX32_SHAREDPAGE);
1078}
1079SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
1080 (sysinit_cfunc_t)linux_vdso_install, NULL);
1081
1082static void
1083linux_vdso_deinstall(void *param)
1084{
1085

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

1176 LIST_INIT(&futex_list);
1177 mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
1178 linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
1179 linux_proc_exit, NULL, 1000);
1180 linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
1181 linux_proc_exec, NULL, 1000);
1182 linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
1183 linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
1073}
1074SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
1075 (sysinit_cfunc_t)linux_vdso_install, NULL);
1076
1077static void
1078linux_vdso_deinstall(void *param)
1079{
1080

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

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);
1184 linux_szplatform = roundup(strlen(linux_platform) + 1,
1185 sizeof(char *));
1186 linux_osd_jail_register();
1187 stclohz = (stathz ? stathz : hz);
1188 if (bootverbose)
1189 printf("Linux ELF exec handler installed\n");
1190 } else
1191 printf("cannot insert Linux ELF brand handler\n");
1192 break;
1193 case MOD_UNLOAD:

--- 38 unchanged lines hidden ---
1179 linux_osd_jail_register();
1180 stclohz = (stathz ? stathz : hz);
1181 if (bootverbose)
1182 printf("Linux ELF exec handler installed\n");
1183 } else
1184 printf("cannot insert Linux ELF brand handler\n");
1185 break;
1186 case MOD_UNLOAD:

--- 38 unchanged lines hidden ---