From owner-dev-commits-src-main@freebsd.org Tue Jul 20 07:10:31 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0F613666155; Tue, 20 Jul 2021 07:10:31 +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 4GTVGt2fqzz3tC5; Tue, 20 Jul 2021 07:10:29 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D05C025E61; Tue, 20 Jul 2021 07:10:29 +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 16K7ATFL030357; Tue, 20 Jul 2021 07:10:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16K7AT9U030356; Tue, 20 Jul 2021 07:10:29 GMT (envelope-from git) Date: Tue, 20 Jul 2021 07:10:29 GMT Message-Id: <202107200710.16K7AT9U030356@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: 09cffde975b8 - main - linux(4): Fixup the vDSO initialization order. 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: 09cffde975b87b293457c9a228cb980ec729384a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2021 07:10:31 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=09cffde975b87b293457c9a228cb980ec729384a commit 09cffde975b87b293457c9a228cb980ec729384a Author: Dmitry Chagin AuthorDate: 2021-07-20 07:02:34 +0000 Commit: Dmitry Chagin CommitDate: 2021-07-20 07:02:34 +0000 linux(4): Fixup the vDSO initialization order. The vDSO initialisation order should be as follows: - native abi init via exec_sysvec_init(); - vDSO symbols queued to the linux_vdso_syms list; - linux_vdso_install(); - linux_exec_sysvec_init(); As the exec_sysvec_init() called with SI_ORDER_ANY (last) at SI_SUB_EXEC order, move linux_vdso_install() and linux_exec_sysvec_init() to the SI_SUB_EXEC+1 order. Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D30902 MFC after 2 weeks --- sys/amd64/linux/linux_sysvec.c | 8 ++++++-- sys/amd64/linux32/linux32_sysvec.c | 8 ++++++-- sys/arm64/linux/linux_sysvec.c | 8 ++++++-- sys/i386/linux/linux_sysvec.c | 13 +++++++++++-- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 999f22a410ab..2a429f323682 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -804,6 +804,10 @@ linux_on_exec_vmspace(struct proc *p, struct image_params *imgp) return (error); } +/* + * linux_vdso_install() and linux_exec_sysvec_init() must be called + * after exec_sysvec_init() which is SI_SUB_EXEC (SI_ORDER_ANY). + */ static void linux_exec_sysvec_init(void *param) { @@ -826,7 +830,7 @@ linux_exec_sysvec_init(void *param) if (bootverbose) printf("Linux x86-64 vDSO tsc_selector: %lu\n", *ktsc_selector); } -SYSINIT(elf_linux_exec_sysvec_init, SI_SUB_EXEC, SI_ORDER_ANY, +SYSINIT(elf_linux_exec_sysvec_init, SI_SUB_EXEC + 1, SI_ORDER_ANY, linux_exec_sysvec_init, &elf_linux_sysvec); static void @@ -850,7 +854,7 @@ linux_vdso_install(const void *param) linux_vdso_reloc(linux_vdso_mapping, linux_vdso_base); } -SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_FIRST, +SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC + 1, SI_ORDER_FIRST, linux_vdso_install, NULL); static void diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index 720df298b670..38b777fb5629 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -970,6 +970,10 @@ linux_on_exec_vmspace(struct proc *p, struct image_params *imgp) return (error); } +/* + * linux_vdso_install() and linux_exec_sysvec_init() must be called + * after exec_sysvec_init() which is SI_SUB_EXEC (SI_ORDER_ANY). + */ static void linux_exec_sysvec_init(void *param) { @@ -991,7 +995,7 @@ linux_exec_sysvec_init(void *param) if (bootverbose) printf("Linux i386 vDSO tsc_selector: %u\n", *ktsc_selector); } -SYSINIT(elf_linux_exec_sysvec_init, SI_SUB_EXEC, SI_ORDER_ANY, +SYSINIT(elf_linux_exec_sysvec_init, SI_SUB_EXEC + 1, SI_ORDER_ANY, linux_exec_sysvec_init, &elf_linux_sysvec); static void @@ -1013,7 +1017,7 @@ linux_vdso_install(const void *param) linux_vdso_reloc(linux_vdso_mapping, linux_vdso_base); } -SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_FIRST, +SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC + 1, SI_ORDER_FIRST, linux_vdso_install, NULL); static void diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c index 1d467540fd36..247b6dc9fa3b 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -476,6 +476,10 @@ linux_on_exec_vmspace(struct proc *p, struct image_params *imgp) return (error); } +/* + * linux_vdso_install() and linux_exec_sysvec_init() must be called + * after exec_sysvec_init() which is SI_SUB_EXEC (SI_ORDER_ANY). + */ static void linux_exec_sysvec_init(void *param) { @@ -491,7 +495,7 @@ linux_exec_sysvec_init(void *param) ktimekeep_base = (l_uintptr_t *)(linux_vdso_mapping + tkoff); *ktimekeep_base = sv->sv_timekeep_base; } -SYSINIT(elf_linux_exec_sysvec_init, SI_SUB_EXEC, SI_ORDER_ANY, +SYSINIT(elf_linux_exec_sysvec_init, SI_SUB_EXEC + 1, SI_ORDER_ANY, linux_exec_sysvec_init, &elf_linux_sysvec); static void @@ -513,7 +517,7 @@ linux_vdso_install(const void *param) linux_vdso_reloc(linux_vdso_mapping, linux_vdso_base); } -SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_FIRST, +SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC + 1, SI_ORDER_FIRST, linux_vdso_install, NULL); static void diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 833819101ed0..f3101db96d41 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -915,6 +915,10 @@ linux_on_exec_vmspace(struct proc *p, struct image_params *imgp) return (error); } +/* + * linux_vdso_install() and linux_exec_sysvec_init() must be called + * after exec_sysvec_init() which is SI_SUB_EXEC (SI_ORDER_ANY). + */ static void linux_exec_sysvec_init(void *param) { @@ -936,7 +940,7 @@ linux_exec_sysvec_init(void *param) if (bootverbose) printf("Linux i386 vDSO tsc_selector: %u\n", *ktsc_selector); } -SYSINIT(elf_linux_exec_sysvec_init, SI_SUB_EXEC, SI_ORDER_ANY, +SYSINIT(elf_linux_exec_sysvec_init, SI_SUB_EXEC + 1, SI_ORDER_ANY, linux_exec_sysvec_init, &elf_linux_sysvec); static void @@ -958,7 +962,7 @@ linux_vdso_install(const void *param) linux_vdso_reloc(linux_vdso_mapping, linux_vdso_base); } -SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_FIRST, +SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC + 1, SI_ORDER_FIRST, linux_vdso_install, NULL); static void @@ -1169,3 +1173,8 @@ static moduledata_t linux_elf_mod = { DECLARE_MODULE_TIED(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY); FEATURE(linux, "Linux 32bit support"); + +/* + * linux_vdso_install() and linux_exec_sysvec_init() must be called + * after exec_sysvec_init() which is SI_SUB_EXEC (SI_ORDER_ANY). + */