Deleted Added
sdiff udiff text old ( 293495 ) new ( 293514 )
full compact
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: stable/10/sys/i386/linux/linux_sysvec.c 293495 2016-01-09 15:18:36Z 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>

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

66#include <i386/linux/linux_proto.h>
67#include <compat/linux/linux_emul.h>
68#include <compat/linux/linux_futex.h>
69#include <compat/linux/linux_ioctl.h>
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
75MODULE_VERSION(linux, 1);
76
77MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures");
78
79#if BYTE_ORDER == LITTLE_ENDIAN
80#define SHELLMAGIC 0x2123 /* #! */
81#else

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

88 * to syscall 0. This is slightly less bogus than using
89 * ldebug(sigreturn).
90 */
91#define LINUX_SYS_linux_rt_sendsig 0
92#define LINUX_SYS_linux_sendsig 0
93
94#define LINUX_PS_STRINGS (LINUX_USRSTACK - sizeof(struct ps_strings))
95
96extern char linux_sigcode[];
97extern int linux_szsigcode;
98
99extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
100
101SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
102SET_DECLARE(linux_device_handler_set, struct linux_device_handler);
103
104static int linux_fixup(register_t **stack_base,
105 struct image_params *iparams);
106static int elf_linux_fixup(register_t **stack_base,
107 struct image_params *iparams);
108static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
109static void exec_linux_setregs(struct thread *td,
110 struct image_params *imgp, u_long stack);
111static register_t *linux_copyout_strings(struct image_params *imgp);
112static boolean_t linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
113
114static int linux_szplatform;
115const char *linux_platform;
116
117static eventhandler_tag linux_exit_tag;
118static eventhandler_tag linux_exec_tag;
119static eventhandler_tag linux_thread_dtor_tag;
120

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

194 19, /* 29 T_XMMFLT */
195 15 /* 30 T_RESERVED */
196};
197#define bsd_to_linux_trapcode(code) \
198 ((code)<sizeof(_bsd_to_linux_trapcode)/sizeof(*_bsd_to_linux_trapcode)? \
199 _bsd_to_linux_trapcode[(code)]: \
200 LINUX_T_UNKNOWN)
201
202/*
203 * If FreeBSD & Linux have a difference of opinion about what a trap
204 * means, deal with it here.
205 *
206 * MPSAFE
207 */
208static int
209translate_traps(int signal, int trap_code)

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

250 ("unsafe elf_linux_fixup(), should be curproc"));
251
252 p = imgp->proc;
253 arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
254 uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szplatform);
255 args = (Elf32_Auxargs *)imgp->auxargs;
256 pos = *stack_base + (imgp->args->argc + imgp->args->envc + 2);
257
258 AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
259
260 /*
261 * Do not export AT_CLKTCK when emulating Linux kernel prior to 2.4.0,
262 * as it has appeared in the 2.4.0-rc7 first time.
263 * Being exported, AT_CLKTCK is returned by sysconf(_SC_CLK_TCK),
264 * glibc falls back to the hard-coded CLK_TCK value when aux entry
265 * is not present.

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

394 }
395
396 /* end of vector table is a null pointer */
397 suword(vectp, 0);
398
399 return (stack_base);
400}
401
402
403
404extern unsigned long linux_sznonrtsigcode;
405
406static void
407linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
408{
409 struct thread *td = curthread;
410 struct proc *p = td->td_proc;
411 struct sigacts *psp;
412 struct trapframe *regs;
413 struct l_rt_sigframe *fp, frame;

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

473 frame.sf_sc.uc_mcontext.sc_gs = rgs();
474 frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs;
475 frame.sf_sc.uc_mcontext.sc_es = regs->tf_es;
476 frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds;
477 frame.sf_sc.uc_mcontext.sc_edi = regs->tf_edi;
478 frame.sf_sc.uc_mcontext.sc_esi = regs->tf_esi;
479 frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_ebp;
480 frame.sf_sc.uc_mcontext.sc_ebx = regs->tf_ebx;
481 frame.sf_sc.uc_mcontext.sc_edx = regs->tf_edx;
482 frame.sf_sc.uc_mcontext.sc_ecx = regs->tf_ecx;
483 frame.sf_sc.uc_mcontext.sc_eax = regs->tf_eax;
484 frame.sf_sc.uc_mcontext.sc_eip = regs->tf_eip;
485 frame.sf_sc.uc_mcontext.sc_cs = regs->tf_cs;
486 frame.sf_sc.uc_mcontext.sc_eflags = regs->tf_eflags;
487 frame.sf_sc.uc_mcontext.sc_esp_at_signal = regs->tf_esp;
488 frame.sf_sc.uc_mcontext.sc_ss = regs->tf_ss;

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

510 PROC_LOCK(p);
511 sigexit(td, SIGILL);
512 }
513
514 /*
515 * Build context to run handler in.
516 */
517 regs->tf_esp = (int)fp;
518 regs->tf_eip = p->p_sysent->sv_sigcode_base + linux_sznonrtsigcode;
519 regs->tf_eflags &= ~(PSL_T | PSL_VM | PSL_D);
520 regs->tf_cs = _ucodesel;
521 regs->tf_ds = _udatasel;
522 regs->tf_es = _udatasel;
523 regs->tf_fs = _udatasel;
524 regs->tf_ss = _udatasel;
525 PROC_LOCK(p);
526 mtx_lock(&psp->ps_mtx);

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

601 frame.sf_sc.sc_gs = rgs();
602 frame.sf_sc.sc_fs = regs->tf_fs;
603 frame.sf_sc.sc_es = regs->tf_es;
604 frame.sf_sc.sc_ds = regs->tf_ds;
605 frame.sf_sc.sc_edi = regs->tf_edi;
606 frame.sf_sc.sc_esi = regs->tf_esi;
607 frame.sf_sc.sc_ebp = regs->tf_ebp;
608 frame.sf_sc.sc_ebx = regs->tf_ebx;
609 frame.sf_sc.sc_edx = regs->tf_edx;
610 frame.sf_sc.sc_ecx = regs->tf_ecx;
611 frame.sf_sc.sc_eax = regs->tf_eax;
612 frame.sf_sc.sc_eip = regs->tf_eip;
613 frame.sf_sc.sc_cs = regs->tf_cs;
614 frame.sf_sc.sc_eflags = regs->tf_eflags;
615 frame.sf_sc.sc_esp_at_signal = regs->tf_esp;
616 frame.sf_sc.sc_ss = regs->tf_ss;

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

629 PROC_LOCK(p);
630 sigexit(td, SIGILL);
631 }
632
633 /*
634 * Build context to run handler in.
635 */
636 regs->tf_esp = (int)fp;
637 regs->tf_eip = p->p_sysent->sv_sigcode_base;
638 regs->tf_eflags &= ~(PSL_T | PSL_VM | PSL_D);
639 regs->tf_cs = _ucodesel;
640 regs->tf_ds = _udatasel;
641 regs->tf_es = _udatasel;
642 regs->tf_fs = _udatasel;
643 regs->tf_ss = _udatasel;
644 PROC_LOCK(p);
645 mtx_lock(&psp->ps_mtx);

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

945 .sv_mask = 0,
946 .sv_sigsize = LINUX_SIGTBLSZ,
947 .sv_sigtbl = bsd_to_linux_signal,
948 .sv_errsize = ELAST + 1,
949 .sv_errtbl = bsd_to_linux_errno,
950 .sv_transtrap = translate_traps,
951 .sv_fixup = linux_fixup,
952 .sv_sendsig = linux_sendsig,
953 .sv_sigcode = linux_sigcode,
954 .sv_szsigcode = &linux_szsigcode,
955 .sv_prepsyscall = NULL,
956 .sv_name = "Linux a.out",
957 .sv_coredump = NULL,
958 .sv_imgact_try = exec_linux_imgact_try,
959 .sv_minsigstksz = LINUX_MINSIGSTKSZ,
960 .sv_pagesize = PAGE_SIZE,
961 .sv_minuser = VM_MIN_ADDRESS,

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

984 .sv_mask = 0,
985 .sv_sigsize = LINUX_SIGTBLSZ,
986 .sv_sigtbl = bsd_to_linux_signal,
987 .sv_errsize = ELAST + 1,
988 .sv_errtbl = bsd_to_linux_errno,
989 .sv_transtrap = translate_traps,
990 .sv_fixup = elf_linux_fixup,
991 .sv_sendsig = linux_sendsig,
992 .sv_sigcode = linux_sigcode,
993 .sv_szsigcode = &linux_szsigcode,
994 .sv_prepsyscall = NULL,
995 .sv_name = "Linux ELF",
996 .sv_coredump = elf32_coredump,
997 .sv_imgact_try = exec_linux_imgact_try,
998 .sv_minsigstksz = LINUX_MINSIGSTKSZ,
999 .sv_pagesize = PAGE_SIZE,
1000 .sv_minuser = VM_MIN_ADDRESS,

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

1010 .sv_set_syscall_retval = cpu_set_syscall_retval,
1011 .sv_fetch_syscall_args = linux_fetch_syscall_args,
1012 .sv_syscallnames = NULL,
1013 .sv_shared_page_base = LINUX_SHAREDPAGE,
1014 .sv_shared_page_len = PAGE_SIZE,
1015 .sv_schedtail = linux_schedtail,
1016 .sv_thread_detach = linux_thread_detach,
1017};
1018INIT_SYSENTVEC(elf_sysvec, &elf_linux_sysvec);
1019
1020static char GNU_ABI_VENDOR[] = "GNU";
1021static int GNULINUX_ABI_DESC = 0;
1022
1023static boolean_t
1024linux_trans_osrel(const Elf_Note *note, int32_t *osrel)
1025{
1026 const Elf32_Word *desc;
1027 uintptr_t p;

--- 134 unchanged lines hidden ---