From nobody Thu Feb 09 07:56:44 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PC8Md3WCDz3myLQ; Thu, 9 Feb 2023 07:56:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PC8Mc4Q3Zz44mC; Thu, 9 Feb 2023 07:56:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675929404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VBuCqBNuVDUjvwt8eIupkCeTOuiN4EvoT5pIpsiw7Q4=; b=e56Mq7AcxqEA7x6O4BS0lMbAeoeiVqtL3V/9qPFWe7f5MOQwaNcs2hbAA9aRkcEduFtz5S LDgqzpPjPY1ElquWFzfTZQ+3R3lQeZDf7yNyddmktBLRygFWc2rmvwZOzn8BwXjhGK3COv Z17z2f5gqREbEB02VitrIHYkm+aujYlR11CR3B/xyrKpx5hPafsARBdKfa/fBiqO/0vVM3 sw2qj8c2JFkmHNbZORXjO8O4k0SGdMVEle+MOCz3Vkio3QZ9espAAP55V9Iq/PXKS8hnr7 ZI8w6OQ7sgou842OW7LH6jnQm5DiV2aReP9il6eKxWgS5CZpG+bxN2KsVlU13A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675929404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VBuCqBNuVDUjvwt8eIupkCeTOuiN4EvoT5pIpsiw7Q4=; b=NV5VzJMNQHbbl3A30mcAC4MBHgaGHDTY/cefFkx9VjIRJfAHX28Pvibj2TCxOcEKi1sA8z y4NQm0xVmT080waoEp2zHNWoMVxCwWOWZAlAsoDLwa82eqO0TirWi++gorQp9os9PE1ALl olbxKdTjndnwqqGQ1Ob+8P+QnyB09gXG4lMNZ8nMHDubweG1aUCxTQorORvAdqvAwzx6VW IyRmDRPs+RweuR3L6s6RZNILqG0WzysSq1izXaB+NyUqZQWEnPvnwBV27F/BJsNMHQvQ5d 46cTa2KCFfEHmbq94HTlBYGfyFQUNBF0FBzTwATD+2Y/r5tmQF4gVbC0zZC5zw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675929404; a=rsa-sha256; cv=none; b=p2LbPswrYazh4Wd7WwPyuVy4AxalI+0GbA+fp7/Ba01alEunaM2aQYOvZXTZuy+Miq8QH9 lWiStlZiWmegdSjxn8p8PzA4cW7aCwHMXQ9wdo4RU43zbCz27nSxI7/xP9dciEBXNPW4Tq 0YeSCpakSoIAyQG7ZxvlbL5VPf+gztXhB4APlXS9hhPl5e6EWqOAoqJ5vrUNxqWs7aKcpv rfpi3xTF02EXksuzZUVKM3Zmp2ipO899tMazZhueh+k+51Puum4q7MxYOPAHmA7/136bF1 9Es1U4vBWNHDNhsDCL31bTnDrt0ZLZbcv9+l1K6+dXdOP/KJFzQjW60oJUFZog== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PC8Mc3X9qzV5R; Thu, 9 Feb 2023 07:56:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 3197uiSS092923; Thu, 9 Feb 2023 07:56:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3197uiYR092922; Thu, 9 Feb 2023 07:56:44 GMT (envelope-from git) Date: Thu, 9 Feb 2023 07:56:44 GMT Message-Id: <202302090756.3197uiYR092922@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: c671998874ee - stable/13 - linux(4): Deduplicate linux_fixup_elf(). List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c671998874eeeb67be4099162cf6cb1c957db3e8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=c671998874eeeb67be4099162cf6cb1c957db3e8 commit c671998874eeeb67be4099162cf6cb1c957db3e8 Author: Dmitry Chagin AuthorDate: 2023-02-02 14:58:07 +0000 Commit: Dmitry Chagin 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,