From patchwork Wed Nov 11 20:43:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1398503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Received: from sourceware.org (unknown [8.43.85.97]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CWcBr6dxNz9sPB for ; Thu, 12 Nov 2020 07:43:32 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F01093833037; Wed, 11 Nov 2020 20:43:24 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by sourceware.org (Postfix) with ESMTPS id B3598386184F for ; Wed, 11 Nov 2020 20:43:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B3598386184F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 9B59EDAA; Wed, 11 Nov 2020 21:43:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EO2eGJq5zlQ6; Wed, 11 Nov 2020 21:43:20 +0100 (CET) Received: from function.youpi.perso.aquilenet.fr (lfbn-bor-1-56-204.w90-50.abo.wanadoo.fr [90.50.148.204]) by hera.aquilenet.fr (Postfix) with ESMTPSA id E2D43DB3; Wed, 11 Nov 2020 21:43:19 +0100 (CET) Received: from samy by function.youpi.perso.aquilenet.fr with local (Exim 4.94) (envelope-from ) id 1kcwxZ-002Uny-Sc; Wed, 11 Nov 2020 21:43:17 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd, commited 4/4] hurd: Notify the proc server later during initialization Date: Wed, 11 Nov 2020 21:43:16 +0100 Message-Id: <20201111204316.595017-5-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201111204316.595017-1-samuel.thibault@ens-lyon.org> References: <20201111204316.595017-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Notifying the proc server is an involved task, and unleashes various signal handling etc. so we have to do this after e.g. ifunc relocations are completed. --- hurd/hurdinit.c | 36 ++++++++++++++++++++--------- sysdeps/hurd/include/hurd.h | 3 +++ sysdeps/mach/hurd/i386/init-first.c | 3 +++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c index a884b78de6..e4ec005b48 100644 --- a/hurd/hurdinit.c +++ b/hurd/hurdinit.c @@ -34,6 +34,10 @@ sigset_t _hurdsig_traced; char **__libc_argv; int __libc_argc; +static int *_hurd_intarray; +static size_t _hurd_intarraysize; +static mach_port_t *_hurd_portarray; +static size_t _hurd_portarraysize; error_t _hurd_ports_use (int which, error_t (*operate) (mach_port_t)) @@ -87,17 +91,10 @@ _hurd_init (int flags, char **argv, if (intarraysize > INIT_TRACEMASK) _hurdsig_traced = intarray[INIT_TRACEMASK]; - /* Tell the proc server we exist, if it does. */ - if (portarray[INIT_PORT_PROC] != MACH_PORT_NULL) - _hurd_new_proc_init (argv, intarray, intarraysize); - - /* All done with init ints and ports. */ - __vm_deallocate (__mach_task_self (), - (vm_address_t) intarray, - intarraysize * sizeof (int)); - __vm_deallocate (__mach_task_self (), - (vm_address_t) portarray, - portarraysize * sizeof (mach_port_t)); + _hurd_intarray = intarray; + _hurd_intarraysize = intarraysize; + _hurd_portarray = portarray; + _hurd_portarraysize = portarraysize; if (flags & EXEC_SECURE) { @@ -113,6 +110,23 @@ _hurd_init (int flags, char **argv, RUN_HOOK (_hurd_subinit, ()); } libc_hidden_def (_hurd_init) + +void +_hurd_libc_proc_init (char **argv) +{ + /* Tell the proc server we exist, if it does. */ + if (_hurd_portarray[INIT_PORT_PROC] != MACH_PORT_NULL) + _hurd_new_proc_init (argv, _hurd_intarray, _hurd_intarraysize); + + /* All done with init ints and ports. */ + __vm_deallocate (__mach_task_self (), + (vm_address_t) _hurd_intarray, + _hurd_intarraysize * sizeof (int)); + __vm_deallocate (__mach_task_self (), + (vm_address_t) _hurd_portarray, + _hurd_portarraysize * sizeof (mach_port_t)); +} +libc_hidden_def (_hurd_libc_proc_init) #include diff --git a/sysdeps/hurd/include/hurd.h b/sysdeps/hurd/include/hurd.h index dc877173b5..7da9af2656 100644 --- a/sysdeps/hurd/include/hurd.h +++ b/sysdeps/hurd/include/hurd.h @@ -1,6 +1,8 @@ #ifndef _HURD_H #include_next +void _hurd_libc_proc_init (char **argv); + /* Like __USEPORT, but cleans fd on cancel. */ #define __USEPORT_CANCEL(which, expr) \ HURD_PORT_USE_CANCEL (&_hurd_ports[INIT_PORT_##which], (expr)) @@ -8,5 +10,6 @@ #ifndef _ISOMAC libc_hidden_proto (_hurd_exec_paths) libc_hidden_proto (_hurd_init) +libc_hidden_proto (_hurd_libc_proc_init) #endif #endif diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index 6c35dc8104..a3d2fdaba0 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -63,6 +63,9 @@ posixland_init (int argc, char **argv, char **envp) { /* Set the FPU control word to the proper default value. */ __setfpucw (__fpu_control); + + /* Now we have relocations etc. we can start signals etc. */ + _hurd_libc_proc_init (argv); } else {