19dcf90f8SEd Schouten /*- 28c9c3144SOlivier Houchard * Copyright (c) 2014, 2015 The FreeBSD Foundation. 38c9c3144SOlivier Houchard * Copyright (c) 2014, 2017 Andrew Turner. 48c9c3144SOlivier Houchard * Copyright (c) 2018 Olivier Houchard 58c9c3144SOlivier Houchard * All rights reserved. 68c9c3144SOlivier Houchard * 78c9c3144SOlivier Houchard * This software was developed by Andrew Turner under 88c9c3144SOlivier Houchard * sponsorship from the FreeBSD Foundation. 98c9c3144SOlivier Houchard * 108c9c3144SOlivier Houchard * Portions of this software were developed by Konstantin Belousov 118c9c3144SOlivier Houchard * under sponsorship from the FreeBSD Foundation. 129dcf90f8SEd Schouten * 139dcf90f8SEd Schouten * Redistribution and use in source and binary forms, with or without 149dcf90f8SEd Schouten * modification, are permitted provided that the following conditions 159dcf90f8SEd Schouten * are met: 169dcf90f8SEd Schouten * 1. Redistributions of source code must retain the above copyright 179dcf90f8SEd Schouten * notice, this list of conditions and the following disclaimer. 189dcf90f8SEd Schouten * 2. Redistributions in binary form must reproduce the above copyright 199dcf90f8SEd Schouten * notice, this list of conditions and the following disclaimer in the 209dcf90f8SEd Schouten * documentation and/or other materials provided with the distribution. 219dcf90f8SEd Schouten * 229dcf90f8SEd Schouten * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 239dcf90f8SEd Schouten * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 249dcf90f8SEd Schouten * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 259dcf90f8SEd Schouten * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 269dcf90f8SEd Schouten * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 279dcf90f8SEd Schouten * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 289dcf90f8SEd Schouten * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 299dcf90f8SEd Schouten * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 309dcf90f8SEd Schouten * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 319dcf90f8SEd Schouten * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 329dcf90f8SEd Schouten * SUCH DAMAGE. 339dcf90f8SEd Schouten */ 349dcf90f8SEd Schouten 359dcf90f8SEd Schouten #include <sys/cdefs.h> 369dcf90f8SEd Schouten #define __ELF_WORD_SIZE 32 378c9c3144SOlivier Houchard 388c9c3144SOlivier Houchard #include <sys/param.h> 398c9c3144SOlivier Houchard #include <sys/kernel.h> 408c9c3144SOlivier Houchard #include <sys/systm.h> 418c9c3144SOlivier Houchard #include <sys/exec.h> 428c9c3144SOlivier Houchard #include <sys/imgact.h> 438c9c3144SOlivier Houchard #include <sys/linker.h> 448c9c3144SOlivier Houchard #include <sys/proc.h> 45548a2ec4SAndrew Turner #include <sys/reg.h> 46967022aaSKonstantin Belousov #include <sys/sysctl.h> 478c9c3144SOlivier Houchard #include <sys/sysent.h> 489dcf90f8SEd Schouten #include <sys/imgact_elf.h> 498c9c3144SOlivier Houchard #include <sys/syscall.h> 508c9c3144SOlivier Houchard #include <sys/signalvar.h> 518c9c3144SOlivier Houchard #include <sys/vnode.h> 528c9c3144SOlivier Houchard 538c9c3144SOlivier Houchard #include <machine/elf.h> 542555f175SKonstantin Belousov #include <machine/pcb.h> 55953a7d7cSAlex Richardson #ifdef VFP 56953a7d7cSAlex Richardson #include <machine/vfp.h> 57953a7d7cSAlex Richardson #endif 588c9c3144SOlivier Houchard 598c9c3144SOlivier Houchard #include <compat/freebsd32/freebsd32_util.h> 608c9c3144SOlivier Houchard 618c9c3144SOlivier Houchard #define FREEBSD32_MINUSER 0x00001000 628c9c3144SOlivier Houchard #define FREEBSD32_MAXUSER ((1ul << 32) - PAGE_SIZE) 638c9c3144SOlivier Houchard #define FREEBSD32_SHAREDPAGE (FREEBSD32_MAXUSER - PAGE_SIZE) 648c9c3144SOlivier Houchard #define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE 65d093fe94SKonstantin Belousov #define AARCH32_MAXDSIZ (512 * 1024 * 1024) 66967022aaSKonstantin Belousov #define AARCH32_MAXSSIZ (64 * 1024 * 1024) 67967022aaSKonstantin Belousov #define AARCH32_MAXVMEM 0 688c9c3144SOlivier Houchard 698c9c3144SOlivier Houchard extern const char *freebsd32_syscallnames[]; 708c9c3144SOlivier Houchard 718c9c3144SOlivier Houchard extern char aarch32_sigcode[]; 728c9c3144SOlivier Houchard extern int sz_aarch32_sigcode; 738c9c3144SOlivier Houchard 748c9c3144SOlivier Houchard static int freebsd32_fetch_syscall_args(struct thread *td); 758c9c3144SOlivier Houchard static void freebsd32_setregs(struct thread *td, struct image_params *imgp, 768c9c3144SOlivier Houchard u_long stack); 778c9c3144SOlivier Houchard static void freebsd32_set_syscall_retval(struct thread *, int); 788c9c3144SOlivier Houchard 79407f6757SJohn Baldwin static bool elf32_arm_abi_supported(struct image_params *, int32_t *, 800cad2aa2SKonstantin Belousov uint32_t *); 81967022aaSKonstantin Belousov static void elf32_fixlimit(struct rlimit *rl, int which); 828c9c3144SOlivier Houchard 838c9c3144SOlivier Houchard extern void freebsd32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); 848c9c3144SOlivier Houchard 85bbe80bffSPeter Grehan u_long __read_frequently elf32_hwcap; 86bbe80bffSPeter Grehan u_long __read_frequently elf32_hwcap2; 87bbe80bffSPeter Grehan 88967022aaSKonstantin Belousov static SYSCTL_NODE(_compat, OID_AUTO, aarch32, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 89967022aaSKonstantin Belousov "aarch32 mode"); 90967022aaSKonstantin Belousov 91967022aaSKonstantin Belousov static u_long aarch32_maxdsiz = AARCH32_MAXDSIZ; 92967022aaSKonstantin Belousov SYSCTL_ULONG(_compat_aarch32, OID_AUTO, maxdsiz, CTLFLAG_RWTUN, 93967022aaSKonstantin Belousov &aarch32_maxdsiz, 0, ""); 94967022aaSKonstantin Belousov u_long aarch32_maxssiz = AARCH32_MAXSSIZ; 95967022aaSKonstantin Belousov SYSCTL_ULONG(_compat_aarch32, OID_AUTO, maxssiz, CTLFLAG_RWTUN, 96967022aaSKonstantin Belousov &aarch32_maxssiz, 0, ""); 97967022aaSKonstantin Belousov static u_long aarch32_maxvmem = AARCH32_MAXVMEM; 98967022aaSKonstantin Belousov SYSCTL_ULONG(_compat_aarch32, OID_AUTO, maxvmem, CTLFLAG_RWTUN, 99967022aaSKonstantin Belousov &aarch32_maxvmem, 0, ""); 100967022aaSKonstantin Belousov 1018c9c3144SOlivier Houchard static struct sysentvec elf32_freebsd_sysvec = { 1028c9c3144SOlivier Houchard .sv_size = SYS_MAXSYSCALL, 1038c9c3144SOlivier Houchard .sv_table = freebsd32_sysent, 1048c9c3144SOlivier Houchard .sv_fixup = elf32_freebsd_fixup, 1058c9c3144SOlivier Houchard .sv_sendsig = freebsd32_sendsig, 1068c9c3144SOlivier Houchard .sv_sigcode = aarch32_sigcode, 1078c9c3144SOlivier Houchard .sv_szsigcode = &sz_aarch32_sigcode, 1088c9c3144SOlivier Houchard .sv_name = "FreeBSD ELF32", 1098c9c3144SOlivier Houchard .sv_coredump = elf32_coredump, 110435754a5SEdward Tomasz Napierala .sv_elf_core_osabi = ELFOSABI_FREEBSD, 111435754a5SEdward Tomasz Napierala .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, 112435754a5SEdward Tomasz Napierala .sv_elf_core_prepare_notes = elf32_prepare_notes, 1138c9c3144SOlivier Houchard .sv_minsigstksz = MINSIGSTKSZ, 1148c9c3144SOlivier Houchard .sv_minuser = FREEBSD32_MINUSER, 1158c9c3144SOlivier Houchard .sv_maxuser = FREEBSD32_MAXUSER, 1168c9c3144SOlivier Houchard .sv_usrstack = FREEBSD32_USRSTACK, 1178c9c3144SOlivier Houchard .sv_psstrings = FREEBSD32_PS_STRINGS, 1183fc21fddSMark Johnston .sv_psstringssz = sizeof(struct freebsd32_ps_strings), 1198c9c3144SOlivier Houchard .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, 120e3532331SJohn Baldwin .sv_copyout_auxargs = elf32_freebsd_copyout_auxargs, 1218c9c3144SOlivier Houchard .sv_copyout_strings = freebsd32_copyout_strings, 1228c9c3144SOlivier Houchard .sv_setregs = freebsd32_setregs, 123967022aaSKonstantin Belousov .sv_fixlimit = elf32_fixlimit, 124967022aaSKonstantin Belousov .sv_maxssiz = &aarch32_maxssiz, 125f8e8a06dSConrad Meyer .sv_flags = SV_ABI_FREEBSD | SV_ILP32 | SV_SHP | SV_TIMEKEEP | 126b82b4ae7SKonstantin Belousov SV_RNG_SEED_VER | SV_SIGSYS, 1278c9c3144SOlivier Houchard .sv_set_syscall_retval = freebsd32_set_syscall_retval, 1288c9c3144SOlivier Houchard .sv_fetch_syscall_args = freebsd32_fetch_syscall_args, 1298c9c3144SOlivier Houchard .sv_syscallnames = freebsd32_syscallnames, 1308c9c3144SOlivier Houchard .sv_shared_page_base = FREEBSD32_SHAREDPAGE, 1318c9c3144SOlivier Houchard .sv_shared_page_len = PAGE_SIZE, 1328c9c3144SOlivier Houchard .sv_schedtail = NULL, 1338c9c3144SOlivier Houchard .sv_thread_detach = NULL, 1348c9c3144SOlivier Houchard .sv_trap = NULL, 135bbe80bffSPeter Grehan .sv_hwcap = &elf32_hwcap, 136bbe80bffSPeter Grehan .sv_hwcap2 = &elf32_hwcap2, 13728a66fc3SKonstantin Belousov .sv_onexec_old = exec_onexec_old, 13828a66fc3SKonstantin Belousov .sv_onexit = exit_onexit, 139548a2ec4SAndrew Turner .sv_regset_begin = SET_BEGIN(__elfN(regset)), 140548a2ec4SAndrew Turner .sv_regset_end = SET_LIMIT(__elfN(regset)), 1418c9c3144SOlivier Houchard }; 1428c9c3144SOlivier Houchard INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec); 1438c9c3144SOlivier Houchard 1448c9c3144SOlivier Houchard static Elf32_Brandinfo freebsd32_brand_info = { 1458c9c3144SOlivier Houchard .brand = ELFOSABI_FREEBSD, 1468c9c3144SOlivier Houchard .machine = EM_ARM, 1478c9c3144SOlivier Houchard .compat_3_brand = "FreeBSD", 1488c9c3144SOlivier Houchard .interp_path = "/libexec/ld-elf.so.1", 1498c9c3144SOlivier Houchard .sysvec = &elf32_freebsd_sysvec, 15024718606SJustin Hibbits .interp_newpath = "/libexec/ld-elf32.so.1", 1518c9c3144SOlivier Houchard .brand_note = &elf32_freebsd_brandnote, 1528c9c3144SOlivier Houchard .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE, 1538c9c3144SOlivier Houchard .header_supported= elf32_arm_abi_supported, 1548c9c3144SOlivier Houchard }; 1558c9c3144SOlivier Houchard 1560aa93010SKonstantin Belousov static void 1570aa93010SKonstantin Belousov register_elf32_brand(void *arg) 1580aa93010SKonstantin Belousov { 1590aa93010SKonstantin Belousov /* Check if we support AArch32 */ 1600aa93010SKonstantin Belousov if (ID_AA64PFR0_EL0_VAL(READ_SPECIALREG(id_aa64pfr0_el1)) == 1610aa93010SKonstantin Belousov ID_AA64PFR0_EL0_64_32) { 1620aa93010SKonstantin Belousov elf32_insert_brand_entry(&freebsd32_brand_info); 1630aa93010SKonstantin Belousov } 1640aa93010SKonstantin Belousov } 1650aa93010SKonstantin Belousov SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST, register_elf32_brand, NULL); 1668c9c3144SOlivier Houchard 167407f6757SJohn Baldwin static bool 1680cad2aa2SKonstantin Belousov elf32_arm_abi_supported(struct image_params *imgp, int32_t *osrel __unused, 1690cad2aa2SKonstantin Belousov uint32_t *fctl0 __unused) 1708c9c3144SOlivier Houchard { 1718c9c3144SOlivier Houchard const Elf32_Ehdr *hdr; 1728c9c3144SOlivier Houchard 17334784d17SWarner Losh #define EF_ARM_EABI_FREEBSD_MIN EF_ARM_EABI_VER4 1748c9c3144SOlivier Houchard hdr = (const Elf32_Ehdr *)imgp->image_header; 1758c9c3144SOlivier Houchard if (EF_ARM_EABI_VERSION(hdr->e_flags) < EF_ARM_EABI_FREEBSD_MIN) { 1768c9c3144SOlivier Houchard if (bootverbose) 1778c9c3144SOlivier Houchard uprintf("Attempting to execute non EABI binary " 1788c9c3144SOlivier Houchard "(rev %d) image %s", 1798c9c3144SOlivier Houchard EF_ARM_EABI_VERSION(hdr->e_flags), 1808c9c3144SOlivier Houchard imgp->args->fname); 181407f6757SJohn Baldwin return (false); 1828c9c3144SOlivier Houchard } 1838c9c3144SOlivier Houchard 184407f6757SJohn Baldwin return (true); 1858c9c3144SOlivier Houchard } 1868c9c3144SOlivier Houchard 1878c9c3144SOlivier Houchard static int 1888c9c3144SOlivier Houchard freebsd32_fetch_syscall_args(struct thread *td) 1898c9c3144SOlivier Houchard { 1908c9c3144SOlivier Houchard struct proc *p; 1918c9c3144SOlivier Houchard register_t *ap; 1928c9c3144SOlivier Houchard struct syscall_args *sa; 1931e2521ffSEdward Tomasz Napierala int error, i, nap, narg; 1948c9c3144SOlivier Houchard unsigned int args[4]; 1958c9c3144SOlivier Houchard 1968c9c3144SOlivier Houchard nap = 4; 1978c9c3144SOlivier Houchard p = td->td_proc; 1988c9c3144SOlivier Houchard ap = td->td_frame->tf_x; 1998c9c3144SOlivier Houchard sa = &td->td_sa; 2008c9c3144SOlivier Houchard 2018c9c3144SOlivier Houchard /* r7 is the syscall id */ 2028c9c3144SOlivier Houchard sa->code = td->td_frame->tf_x[7]; 203cf98bc28SDavid Chisnall sa->original_code = sa->code; 2048c9c3144SOlivier Houchard 2058c9c3144SOlivier Houchard if (sa->code == SYS_syscall) { 2068c9c3144SOlivier Houchard sa->code = *ap++; 2078c9c3144SOlivier Houchard nap--; 2088c9c3144SOlivier Houchard } else if (sa->code == SYS___syscall) { 2098c9c3144SOlivier Houchard sa->code = ap[1]; 2108c9c3144SOlivier Houchard nap -= 2; 2118c9c3144SOlivier Houchard ap += 2; 2128c9c3144SOlivier Houchard } 2138c9c3144SOlivier Houchard 2148c9c3144SOlivier Houchard if (sa->code >= p->p_sysent->sv_size) 21539024a89SKonstantin Belousov sa->callp = &nosys_sysent; 2168c9c3144SOlivier Houchard else 2178c9c3144SOlivier Houchard sa->callp = &p->p_sysent->sv_table[sa->code]; 2188c9c3144SOlivier Houchard 2191e2521ffSEdward Tomasz Napierala narg = sa->callp->sy_narg; 2208c9c3144SOlivier Houchard for (i = 0; i < nap; i++) 2218c9c3144SOlivier Houchard sa->args[i] = ap[i]; 2221e2521ffSEdward Tomasz Napierala if (narg > nap) { 2231e2521ffSEdward Tomasz Napierala if (narg - nap > nitems(args)) 2248c9c3144SOlivier Houchard panic("Too many system call arguiments"); 2258c9c3144SOlivier Houchard error = copyin((void *)td->td_frame->tf_x[13], args, 2261e2521ffSEdward Tomasz Napierala (narg - nap) * sizeof(int)); 2275b616dafSAndrew Turner if (error != 0) 2285b616dafSAndrew Turner return (error); 2291e2521ffSEdward Tomasz Napierala for (i = 0; i < (narg - nap); i++) 2308c9c3144SOlivier Houchard sa->args[i + nap] = args[i]; 2318c9c3144SOlivier Houchard } 2328c9c3144SOlivier Houchard 2338c9c3144SOlivier Houchard td->td_retval[0] = 0; 2348c9c3144SOlivier Houchard td->td_retval[1] = 0; 2358c9c3144SOlivier Houchard 2368c9c3144SOlivier Houchard return (0); 2378c9c3144SOlivier Houchard } 2388c9c3144SOlivier Houchard 2398c9c3144SOlivier Houchard static void 2408c9c3144SOlivier Houchard freebsd32_set_syscall_retval(struct thread *td, int error) 2418c9c3144SOlivier Houchard { 2428c9c3144SOlivier Houchard struct trapframe *frame; 2438c9c3144SOlivier Houchard 2448c9c3144SOlivier Houchard frame = td->td_frame; 2458c9c3144SOlivier Houchard switch (error) { 2468c9c3144SOlivier Houchard case 0: 2478c9c3144SOlivier Houchard frame->tf_x[0] = td->td_retval[0]; 2488c9c3144SOlivier Houchard frame->tf_x[1] = td->td_retval[1]; 2498c9c3144SOlivier Houchard frame->tf_spsr &= ~PSR_C; 2508c9c3144SOlivier Houchard break; 2518c9c3144SOlivier Houchard case ERESTART: 2528c9c3144SOlivier Houchard /* 2538c9c3144SOlivier Houchard * Reconstruct the pc to point at the swi. 2548c9c3144SOlivier Houchard */ 2558c9c3144SOlivier Houchard if ((frame->tf_spsr & PSR_T) != 0) 2568c9c3144SOlivier Houchard frame->tf_elr -= 2; //THUMB_INSN_SIZE; 2578c9c3144SOlivier Houchard else 2588c9c3144SOlivier Houchard frame->tf_elr -= 4; //INSN_SIZE; 2598c9c3144SOlivier Houchard break; 2608c9c3144SOlivier Houchard case EJUSTRETURN: 2618c9c3144SOlivier Houchard /* nothing to do */ 2628c9c3144SOlivier Houchard break; 2638c9c3144SOlivier Houchard default: 2648c9c3144SOlivier Houchard frame->tf_x[0] = error; 2658c9c3144SOlivier Houchard frame->tf_spsr |= PSR_C; 2668c9c3144SOlivier Houchard break; 2678c9c3144SOlivier Houchard } 2688c9c3144SOlivier Houchard } 2698c9c3144SOlivier Houchard 2708c9c3144SOlivier Houchard static void 2718c9c3144SOlivier Houchard freebsd32_setregs(struct thread *td, struct image_params *imgp, 27231174518SJohn Baldwin uintptr_t stack) 2738c9c3144SOlivier Houchard { 2748c9c3144SOlivier Houchard struct trapframe *tf = td->td_frame; 275a2a8b582SMitchell Horne struct pcb *pcb = td->td_pcb; 2768c9c3144SOlivier Houchard 2778c9c3144SOlivier Houchard memset(tf, 0, sizeof(struct trapframe)); 2788c9c3144SOlivier Houchard 2798c9c3144SOlivier Houchard /* 2808c9c3144SOlivier Houchard * We need to set x0 for init as it doesn't call 2818c9c3144SOlivier Houchard * cpu_set_syscall_retval to copy the value. We also 2828c9c3144SOlivier Houchard * need to set td_retval for the cases where we do. 2838c9c3144SOlivier Houchard */ 2848c9c3144SOlivier Houchard tf->tf_x[0] = stack; 2858c9c3144SOlivier Houchard /* SP_usr is mapped to x13 */ 2868c9c3144SOlivier Houchard tf->tf_x[13] = stack; 2878c9c3144SOlivier Houchard /* LR_usr is mapped to x14 */ 2888c9c3144SOlivier Houchard tf->tf_x[14] = imgp->entry_addr; 2898c9c3144SOlivier Houchard tf->tf_elr = imgp->entry_addr; 2908c9c3144SOlivier Houchard tf->tf_spsr = PSR_M_32; 291712c060cSOlivier Houchard if ((uint32_t)imgp->entry_addr & 1) 292712c060cSOlivier Houchard tf->tf_spsr |= PSR_T; 293953a7d7cSAlex Richardson 294953a7d7cSAlex Richardson #ifdef VFP 295a2a8b582SMitchell Horne vfp_reset_state(td, pcb); 296953a7d7cSAlex Richardson #endif 297a2a8b582SMitchell Horne 298a2a8b582SMitchell Horne /* 299a2a8b582SMitchell Horne * Clear debug register state. It is not applicable to the new process. 300a2a8b582SMitchell Horne */ 301a2a8b582SMitchell Horne bzero(&pcb->pcb_dbg_regs, sizeof(pcb->pcb_dbg_regs)); 3028c9c3144SOlivier Houchard } 3039dcf90f8SEd Schouten 3049dcf90f8SEd Schouten void 3058c9c3144SOlivier Houchard elf32_dump_thread(struct thread *td, void *dst, size_t *off) 3069dcf90f8SEd Schouten { 3079dcf90f8SEd Schouten } 308967022aaSKonstantin Belousov 309967022aaSKonstantin Belousov static void 310967022aaSKonstantin Belousov elf32_fixlimit(struct rlimit *rl, int which) 311967022aaSKonstantin Belousov { 312967022aaSKonstantin Belousov 313967022aaSKonstantin Belousov switch (which) { 314967022aaSKonstantin Belousov case RLIMIT_DATA: 315967022aaSKonstantin Belousov if (aarch32_maxdsiz != 0) { 316967022aaSKonstantin Belousov if (rl->rlim_cur > aarch32_maxdsiz) 317967022aaSKonstantin Belousov rl->rlim_cur = aarch32_maxdsiz; 318967022aaSKonstantin Belousov if (rl->rlim_max > aarch32_maxdsiz) 319967022aaSKonstantin Belousov rl->rlim_max = aarch32_maxdsiz; 320967022aaSKonstantin Belousov } 321967022aaSKonstantin Belousov break; 322967022aaSKonstantin Belousov case RLIMIT_STACK: 323967022aaSKonstantin Belousov if (aarch32_maxssiz != 0) { 324967022aaSKonstantin Belousov if (rl->rlim_cur > aarch32_maxssiz) 325967022aaSKonstantin Belousov rl->rlim_cur = aarch32_maxssiz; 326967022aaSKonstantin Belousov if (rl->rlim_max > aarch32_maxssiz) 327967022aaSKonstantin Belousov rl->rlim_max = aarch32_maxssiz; 328967022aaSKonstantin Belousov } 329967022aaSKonstantin Belousov break; 330967022aaSKonstantin Belousov case RLIMIT_VMEM: 331967022aaSKonstantin Belousov if (aarch32_maxvmem != 0) { 332967022aaSKonstantin Belousov if (rl->rlim_cur > aarch32_maxvmem) 333967022aaSKonstantin Belousov rl->rlim_cur = aarch32_maxvmem; 334967022aaSKonstantin Belousov if (rl->rlim_max > aarch32_maxvmem) 335967022aaSKonstantin Belousov rl->rlim_max = aarch32_maxvmem; 336967022aaSKonstantin Belousov } 337967022aaSKonstantin Belousov break; 338967022aaSKonstantin Belousov } 339967022aaSKonstantin Belousov } 340