From nobody Thu Feb 02 14:59:08 2023 X-Original-To: dev-commits-src-main@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 4P724D5YvPz3fkJq; Thu, 2 Feb 2023 14:59:08 +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 4P724D3MjVz3FDj; Thu, 2 Feb 2023 14:59:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675349948; 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=j7K6iUBKiVBTZnZ1z6h1XtyB8x9Z106k8BrbwWnitrI=; b=FflV2AaAs16tuRdpMdlPX+q31jHP1DnPlJrpvcl7XIajCdPEs5bnqcaRqdiQ7wfMh0lLWE 63qifOOkKQ9V5x/QX2AGnih+JVOPQXkkk9Ht54fU7G80/7/tMGJX2xIyIpkqcpl4rASTJV wHMnmhUkYclx4V7LbBwOy0Q2S6ALVMm8b+j8XQ9LL3/X38gjyOk9fzE6G9YbS5RfloSKzN h6YLIfPFHBVpTsizjprgvE19cWUiPZE+fuhxswUIYY0gPHJwKUklS6XpRykFvl0QEX26Ck /qZ0uH4U+Bgh0+M1spveUPAHBfvUlPI322YMkkg4XNHYI9f6q4SpKkwB/X/tfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675349948; 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=j7K6iUBKiVBTZnZ1z6h1XtyB8x9Z106k8BrbwWnitrI=; b=NuNbL4TxJMxYPPaywBppn8VIqzAf3a7v+ohakIn+Eb8tCuw7l8wpgUQ0p54J+UrqAp2HeY 9fKwfUIZVq/WqP8Au0l+KRC2USgHMvQVMnzi7XvmcePlX6vTcLOyZcTZbGFaDD+GDGI0Ds N7pQcYBM4cCLL+kczpM64GtVo5seRI2/gABIYIiacjtVQWuHDMmC5Tj3lyjyDTmmFo5Re5 /oXSjeckd5OJsrqSMOH9uoczHe4Jf0oSr0A8c1JBpxWWA8tffxrYKHdY9a6q2gttn+lr4O wZ70vKIBZL8vkEToso9TVQstYYf/re7VkUmmd2aifdKmjE6VBkdO/aqAIE12cw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675349948; a=rsa-sha256; cv=none; b=xql6NMOzx34d/Q78C5nfiVN+fuJs2ptpNwdFuBdPXXSc3cLYYgbiyO8vOG5w0TyzASpSzr KtmEHIKD8WkznWKvrBfNnWja40zdbEB5sVttStnhXxz22CFW7VUsX8HNWCoSqfb7VLlzgG cg2hXsI0WyqTIf3/xXo9lJLOSNqi0A5vbyxcxlB95PKLA+cxLyEI0W5Yoby89fV/CKHxho /7RNkSGqvFQdTxVididZd2WvuBYsmdGVJzzsyQ8HZZXEzbT/BYw6U35iTNnOdrvR/Yy3OJ fkEphQ7ICTDlbuUxtFd4fDg/P6AeRyN/KFUaund/So9N1ownrj3rjgx0LTYJ6w== 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 4P724D2TWFzyQC; Thu, 2 Feb 2023 14:59:08 +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 312Ex8wq092110; Thu, 2 Feb 2023 14:59:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 312Ex8jW092109; Thu, 2 Feb 2023 14:59:08 GMT (envelope-from git) Date: Thu, 2 Feb 2023 14:59:08 GMT Message-Id: <202302021459.312Ex8jW092109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 9e550625f867 - main - linux(4): Deduplicate linux_fixup_elf(). List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 9e550625f867a23ea3d87a77aa3c216b79ecd790 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=9e550625f867a23ea3d87a77aa3c216b79ecd790 commit 9e550625f867a23ea3d87a77aa3c216b79ecd790 Author: Dmitry Chagin AuthorDate: 2023-02-02 14:58:07 +0000 Commit: Dmitry Chagin 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,