git: c671998874ee - stable/13 - linux(4): Deduplicate linux_fixup_elf().
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 09 Feb 2023 07:56:44 UTC
The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=c671998874eeeb67be4099162cf6cb1c957db3e8 commit c671998874eeeb67be4099162cf6cb1c957db3e8 Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2023-02-02 14:58:07 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2023-02-09 07:55:23 +0000 linux(4): Deduplicate linux_fixup_elf(). Use native routines to fixup initial process stack. On Arm64 linux_elf_fixup() is noop, as it do the stack fixup (room for argc) in the linux_copyout_strings(). MFC after: 1 week (cherry picked from commit 9e550625f867a23ea3d87a77aa3c216b79ecd790) --- sys/amd64/linux/linux_sysvec.c | 18 +----------------- sys/amd64/linux32/linux32_sysvec.c | 17 +---------------- sys/i386/linux/linux_sysvec.c | 17 +---------------- 3 files changed, 3 insertions(+), 49 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index eb45fa183f84..211bd1533933 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -117,8 +117,6 @@ SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); static int linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base); -static int linux_fixup_elf(uintptr_t *stack_base, - struct image_params *iparams); static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); static void linux_vdso_install(const void *param); static void linux_vdso_deinstall(const void *param); @@ -269,20 +267,6 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base) return (error); } -static int -linux_fixup_elf(uintptr_t *stack_base, struct image_params *imgp) -{ - Elf_Addr *base; - - base = (Elf64_Addr *)*stack_base; - base--; - if (suword(base, (uint64_t)imgp->args->argc) == -1) - return (EFAULT); - - *stack_base = (uintptr_t)base; - return (0); -} - /* * Copy strings out to the new process address space, constructing new arg * and env vector tables. Return a pointer to the base so that it can be used @@ -704,7 +688,7 @@ linux_vsyscall(struct thread *td) struct sysentvec elf_linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, - .sv_fixup = linux_fixup_elf, + .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = linux_rt_sendsig, .sv_sigcode = &_binary_linux_vdso_so_o_start, .sv_szsigcode = &linux_szsigcode, diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index 6aa171c3f5ea..432ed51cbb7e 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -118,8 +118,6 @@ extern const char *linux32_syscallnames[]; SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); -static int linux_fixup_elf(uintptr_t *stack_base, - struct image_params *iparams); static int linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base); static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); @@ -210,19 +208,6 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base) return (error); } -static int -linux_fixup_elf(uintptr_t *stack_base, struct image_params *imgp) -{ - Elf32_Addr *base; - - base = (Elf32_Addr *)*stack_base; - base--; - if (suword32(base, (uint32_t)imgp->args->argc) == -1) - return (EFAULT); - *stack_base = (uintptr_t)base; - return (0); -} - static void linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) { @@ -857,7 +842,7 @@ linux32_fixlimit(struct rlimit *rl, int which) struct sysentvec elf_linux_sysvec = { .sv_size = LINUX32_SYS_MAXSYSCALL, .sv_table = linux32_sysent, - .sv_fixup = linux_fixup_elf, + .sv_fixup = elf32_freebsd_fixup, .sv_sendsig = linux_sendsig, .sv_sigcode = &_binary_linux32_vdso_so_o_start, .sv_szsigcode = &linux_szsigcode, diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index cff9b1c780d5..dd924ab8a148 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -105,8 +105,6 @@ SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); static int linux_fixup(uintptr_t *stack_base, struct image_params *iparams); -static int linux_fixup_elf(uintptr_t *stack_base, - struct image_params *iparams); static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); static void linux_exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack); @@ -203,19 +201,6 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base) return (error); } -static int -linux_fixup_elf(uintptr_t *stack_base, struct image_params *imgp) -{ - register_t *base; - - base = (register_t *)*stack_base; - base--; - if (suword(base, (register_t)imgp->args->argc) == -1) - return (EFAULT); - *stack_base = (uintptr_t)base; - return (0); -} - /* * Copied from kern/kern_exec.c */ @@ -800,7 +785,7 @@ INIT_SYSENTVEC(aout_sysvec, &linux_sysvec); struct sysentvec elf_linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, - .sv_fixup = linux_fixup_elf, + .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = linux_sendsig, .sv_sigcode = &_binary_linux_vdso_so_o_start, .sv_szsigcode = &linux_szsigcode,