git: 9e550625f867 - main - linux(4): Deduplicate linux_fixup_elf().
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Feb 2023 14:59:08 UTC
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=9e550625f867a23ea3d87a77aa3c216b79ecd790 commit 9e550625f867a23ea3d87a77aa3c216b79ecd790 Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2023-02-02 14:58:07 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2023-02-02 14:58:07 +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 --- 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 3a2757338c89..12a673d87c96 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); @@ -270,20 +268,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 @@ -705,7 +689,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 9f681a85647e..c28f1c396d36 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) { @@ -858,7 +843,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 f478255dff69..a4bbf8333f58 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 */ @@ -801,7 +786,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,