The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/ia32/ia32_sysvec.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2002 Doug Rabson
    5  * Copyright (c) 2003 Peter Wemm
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  */
   29 
   30 #include <sys/cdefs.h>
   31 __FBSDID("$FreeBSD$");
   32 
   33 #define __ELF_WORD_SIZE 32
   34 
   35 #include <sys/param.h>
   36 #include <sys/exec.h>
   37 #include <sys/fcntl.h>
   38 #include <sys/imgact.h>
   39 #include <sys/kernel.h>
   40 #include <sys/lock.h>
   41 #include <sys/malloc.h>
   42 #include <sys/mutex.h>
   43 #include <sys/mman.h>
   44 #include <sys/namei.h>
   45 #include <sys/proc.h>
   46 #include <sys/procfs.h>
   47 #include <sys/resourcevar.h>
   48 #include <sys/systm.h>
   49 #include <sys/signalvar.h>
   50 #include <sys/stat.h>
   51 #include <sys/sx.h>
   52 #include <sys/syscall.h>
   53 #include <sys/sysctl.h>
   54 #include <sys/sysent.h>
   55 #include <sys/vnode.h>
   56 #include <sys/imgact_elf.h>
   57 
   58 #include <vm/vm.h>
   59 #include <vm/vm_kern.h>
   60 #include <vm/vm_param.h>
   61 #include <vm/pmap.h>
   62 #include <vm/vm_map.h>
   63 #include <vm/vm_object.h>
   64 #include <vm/vm_extern.h>
   65 
   66 #include <compat/freebsd32/freebsd32_signal.h>
   67 #include <compat/freebsd32/freebsd32_util.h>
   68 #include <compat/freebsd32/freebsd32_proto.h>
   69 #include <compat/freebsd32/freebsd32_syscall.h>
   70 #include <compat/ia32/ia32_signal.h>
   71 #include <machine/frame.h>
   72 #include <machine/md_var.h>
   73 #include <machine/pcb.h>
   74 #include <machine/cpufunc.h>
   75 
   76 CTASSERT(sizeof(struct ia32_mcontext) == 640);
   77 CTASSERT(sizeof(struct ia32_ucontext) == 704);
   78 CTASSERT(sizeof(struct ia32_sigframe) == 800);
   79 CTASSERT(sizeof(struct siginfo32) == 64);
   80 #ifdef COMPAT_FREEBSD4
   81 CTASSERT(sizeof(struct ia32_mcontext4) == 260);
   82 CTASSERT(sizeof(struct ia32_ucontext4) == 324);
   83 CTASSERT(sizeof(struct ia32_sigframe4) == 408);
   84 #endif
   85 
   86 extern const char *freebsd32_syscallnames[];
   87 
   88 static SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
   89     "ia32 mode");
   90 
   91 static u_long   ia32_maxdsiz = IA32_MAXDSIZ;
   92 SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RWTUN, &ia32_maxdsiz, 0, "");
   93 u_long  ia32_maxssiz = IA32_MAXSSIZ;
   94 SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RWTUN, &ia32_maxssiz, 0, "");
   95 static u_long   ia32_maxvmem = IA32_MAXVMEM;
   96 SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RWTUN, &ia32_maxvmem, 0, "");
   97 
   98 struct sysentvec ia32_freebsd_sysvec = {
   99         .sv_size        = FREEBSD32_SYS_MAXSYSCALL,
  100         .sv_table       = freebsd32_sysent,
  101         .sv_transtrap   = NULL,
  102         .sv_fixup       = elf32_freebsd_fixup,
  103         .sv_sendsig     = ia32_sendsig,
  104         .sv_sigcode     = ia32_sigcode,
  105         .sv_szsigcode   = &sz_ia32_sigcode,
  106         .sv_name        = "FreeBSD ELF32",
  107         .sv_coredump    = elf32_coredump,
  108         .sv_imgact_try  = NULL,
  109         .sv_minsigstksz = MINSIGSTKSZ,
  110         .sv_minuser     = FREEBSD32_MINUSER,
  111         .sv_maxuser     = FREEBSD32_MAXUSER,
  112         .sv_usrstack    = FREEBSD32_USRSTACK,
  113         .sv_psstrings   = FREEBSD32_PS_STRINGS,
  114         .sv_stackprot   = VM_PROT_ALL,
  115         .sv_copyout_auxargs     = elf32_freebsd_copyout_auxargs,
  116         .sv_copyout_strings     = freebsd32_copyout_strings,
  117         .sv_setregs     = ia32_setregs,
  118         .sv_fixlimit    = ia32_fixlimit,
  119         .sv_maxssiz     = &ia32_maxssiz,
  120         .sv_flags       = SV_ABI_FREEBSD | SV_ASLR | SV_IA32 | SV_ILP32 |
  121                             SV_SHP | SV_TIMEKEEP | SV_RNG_SEED_VER,
  122         .sv_set_syscall_retval = ia32_set_syscall_retval,
  123         .sv_fetch_syscall_args = ia32_fetch_syscall_args,
  124         .sv_syscallnames = freebsd32_syscallnames,
  125         .sv_shared_page_base = FREEBSD32_SHAREDPAGE,
  126         .sv_shared_page_len = PAGE_SIZE,
  127         .sv_schedtail   = NULL,
  128         .sv_thread_detach = NULL,
  129         .sv_trap        = NULL,
  130         .sv_stackgap    = elf32_stackgap,
  131         .sv_onexec_old  = exec_onexec_old,
  132         .sv_onexit      = exit_onexit,
  133 };
  134 INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);
  135 
  136 static Elf32_Brandinfo ia32_brand_info = {
  137         .brand          = ELFOSABI_FREEBSD,
  138         .machine        = EM_386,
  139         .compat_3_brand = "FreeBSD",
  140         .emul_path      = NULL,
  141         .interp_path    = "/libexec/ld-elf.so.1",
  142         .sysvec         = &ia32_freebsd_sysvec,
  143         .interp_newpath = "/libexec/ld-elf32.so.1",
  144         .brand_note     = &elf32_freebsd_brandnote,
  145         .flags          = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
  146 };
  147 
  148 SYSINIT(ia32, SI_SUB_EXEC, SI_ORDER_MIDDLE,
  149         (sysinit_cfunc_t) elf32_insert_brand_entry,
  150         &ia32_brand_info);
  151 
  152 static Elf32_Brandinfo ia32_brand_oinfo = {
  153         .brand          = ELFOSABI_FREEBSD,
  154         .machine        = EM_386,
  155         .compat_3_brand = "FreeBSD",
  156         .emul_path      = NULL,
  157         .interp_path    = "/usr/libexec/ld-elf.so.1",
  158         .sysvec         = &ia32_freebsd_sysvec,
  159         .interp_newpath = "/libexec/ld-elf32.so.1",
  160         .brand_note     = &elf32_freebsd_brandnote,
  161         .flags          = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
  162 };
  163 
  164 SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY,
  165         (sysinit_cfunc_t) elf32_insert_brand_entry,
  166         &ia32_brand_oinfo);
  167 
  168 static Elf32_Brandinfo kia32_brand_info = {
  169         .brand          = ELFOSABI_FREEBSD,
  170         .machine        = EM_386,
  171         .compat_3_brand = "FreeBSD",
  172         .emul_path      = NULL,
  173         .interp_path    = "/lib/ld.so.1",
  174         .sysvec         = &ia32_freebsd_sysvec,
  175         .brand_note     = &elf32_kfreebsd_brandnote,
  176         .flags          = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_MANDATORY
  177 };
  178 
  179 SYSINIT(kia32, SI_SUB_EXEC, SI_ORDER_ANY,
  180         (sysinit_cfunc_t) elf32_insert_brand_entry,
  181         &kia32_brand_info);
  182 
  183 void
  184 elf32_dump_thread(struct thread *td, void *dst, size_t *off)
  185 {
  186         void *buf;
  187         size_t len;
  188 
  189         len = 0;
  190         if (use_xsave) {
  191                 if (dst != NULL) {
  192                         fpugetregs(td);
  193                         len += elf32_populate_note(NT_X86_XSTATE,
  194                             get_pcb_user_save_td(td), dst,
  195                             cpu_max_ext_state_size, &buf);
  196                         *(uint64_t *)((char *)buf + X86_XSTATE_XCR0_OFFSET) =
  197                             xsave_mask;
  198                 } else
  199                         len += elf32_populate_note(NT_X86_XSTATE, NULL, NULL,
  200                             cpu_max_ext_state_size, NULL);
  201         }
  202         *off = len;
  203 }
  204 
  205 void
  206 ia32_fixlimit(struct rlimit *rl, int which)
  207 {
  208 
  209         switch (which) {
  210         case RLIMIT_DATA:
  211                 if (ia32_maxdsiz != 0) {
  212                         if (rl->rlim_cur > ia32_maxdsiz)
  213                                 rl->rlim_cur = ia32_maxdsiz;
  214                         if (rl->rlim_max > ia32_maxdsiz)
  215                                 rl->rlim_max = ia32_maxdsiz;
  216                 }
  217                 break;
  218         case RLIMIT_STACK:
  219                 if (ia32_maxssiz != 0) {
  220                         if (rl->rlim_cur > ia32_maxssiz)
  221                                 rl->rlim_cur = ia32_maxssiz;
  222                         if (rl->rlim_max > ia32_maxssiz)
  223                                 rl->rlim_max = ia32_maxssiz;
  224                 }
  225                 break;
  226         case RLIMIT_VMEM:
  227                 if (ia32_maxvmem != 0) {
  228                         if (rl->rlim_cur > ia32_maxvmem)
  229                                 rl->rlim_cur = ia32_maxvmem;
  230                         if (rl->rlim_max > ia32_maxvmem)
  231                                 rl->rlim_max = ia32_maxvmem;
  232                 }
  233                 break;
  234         }
  235 }

Cache object: 3cc16549d0c23f9847c29809e812bf93


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.