From patchwork Wed Jan 3 17:14:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 83243 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9F183857B80 for ; Wed, 3 Jan 2024 17:17:40 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id B58A9385802E for ; Wed, 3 Jan 2024 17:15:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B58A9385802E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B58A9385802E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704302118; cv=none; b=MEgqEM94esdZcy33aKpug07BTjjybypS6IPxE0IObzAeWONKu2aTVtgUQh+HU4U33FCVWQYJ6kKRHV6S2Qa7FgwEyx80TBPQcwikypQjw0tLGSYiviAHQv/v2/ruALg7VnxfWZq5OMI5D0Ii6aMHAgausYLB8DFH2ggXkYkGb3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704302118; c=relaxed/simple; bh=3L1PcSU/rZVv6ze9ceOMsEohS7VXNB1T/XFO9dmfuJ4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cEtXkMB704jPkSwiWe7eTUCSMgs5bvIyOm87VZnc/2ME3HO+AME07NpZq21a2nKt6qErS/aZfI6WhyeKCERfXwrjy6fAKNnT6Ob5vaWUEJWhUvxQowKpkdHCOirVxQAArdd5WEJ4VVlMOqHPr4mwKIRi2wTOBpt/KdsrHWRNmxw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50e7aed09adso8866353e87.0 for ; Wed, 03 Jan 2024 09:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704302114; x=1704906914; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=RRRr+myZ/GmwLlQ6xFwOGG/ZOuG8vVS1AGS5J0BTw4k=; b=DmG+vE1j8PUOHI86QcaUyQeFRu2AlOjCTK6Iu2ddmfugSktl7b14BKSOKlV6TwDCei IV7UUfYe12/3fyKM94jucQj83gn+WG83VxcWdFfE4vugmDpccccuzXvs1GoP4GbIjvRz K0JQ4wMGMI+g4Ka8+ntBVXKszQr465XMsfSsra3RtRYCF1KAoLtP6B15pMZeXs+5hDRA WL7itqnDJA3N5coefBi9M/scMQ1r2RtAbGhSvlUDG0vLNTlkjk8F8Ma06kjH5KQpCtaO RT3eu9Q/RJY+BSFUN/Ivp+60BkNtoEVnUfC0h4niXs6tXBhlRTXhjXGqaXMhcmMYQ3pO tDTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704302114; x=1704906914; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RRRr+myZ/GmwLlQ6xFwOGG/ZOuG8vVS1AGS5J0BTw4k=; b=oXIo7E8DdB4c4dW6CJHWOC0CHH+8fhFuDlmdnLavJ6mIWHQE5vrMRbdIrIVbRoOka2 R/PWqoSNW440dg9SO7HtXDBxQQZNxoss8QLtXClRpQ/lTWu7qOkaeU3BH1PqDVfenCS5 7LGbsKbE+kan0M02MrU68vbo+HIe0KXH0R6zNsPJBSKAEIvgNLNRAcndaCTBFnZNdIgU 8Lxyuu640K38oWwqBG1b4X5zRq61owp7T6c7Ui5DKn067Oj7RDVhFn7vy7UhL5zM3RUJ wC/2oizU2bMkZqsQhUoE7AXpVLmn4L5HQNN9aPnZVs5+vKdY0/QAnDKGTdIOzUNNo1NK mfIQ== X-Gm-Message-State: AOJu0YzFDx5DpdLHczfahKd/KXCtt1h+v4y+/Ro7gBu544bvRrWB3YLL kAf2IciKUgrEBNtHwbUU/VmaIAjezeI= X-Google-Smtp-Source: AGHT+IEhWlyNWqfTP4p3FpVN5vh2S6WmB8XT375z4Xd7B55coWluwEln0sSV6uudDXoi6ut90Ku19w== X-Received: by 2002:a19:2d08:0:b0:50e:76eb:ba14 with SMTP id k8-20020a192d08000000b0050e76ebba14mr5900804lfj.32.1704302113859; Wed, 03 Jan 2024 09:15:13 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:b32f:ebdc:fd0:376b:8006]) by smtp.gmail.com with ESMTPSA id y23-20020a196417000000b0050e6d84d177sm3546068lfb.279.2024.01.03.09.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 09:15:13 -0800 (PST) From: Sergey Bugaev To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [RFC PATCH 10/23] hurd: Only init early static TLS if it's used to store stack or pointer guards Date: Wed, 3 Jan 2024 20:14:43 +0300 Message-ID: <20240103171502.1358371-11-bugaevc@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103171502.1358371-1-bugaevc@gmail.com> References: <20240103171502.1358371-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org This is the case on both x86 architectures, but not on AArch64. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/init-first.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sysdeps/mach/hurd/init-first.c b/sysdeps/mach/hurd/init-first.c index 85261916..26ccd37e 100644 --- a/sysdeps/mach/hurd/init-first.c +++ b/sysdeps/mach/hurd/init-first.c @@ -38,7 +38,16 @@ extern int __libc_argc attribute_hidden; extern char **__libc_argv attribute_hidden; extern char **_dl_argv; -#ifndef SHARED +#if !defined (SHARED) && (defined (THREAD_SET_STACK_GUARD) || defined (THREAD_SET_POINTER_GUARD)) +/* In the static case, we need to set up TLS early so that the stack + protection guard can be read at from TLS by the GCC-generated snippets, + on architectures that store the guard in TLS and not globally. */ +# define USE_INIT1_TCBHEAD 1 +#else +# define USE_INIT1_TCBHEAD 0 +#endif + +#if USE_INIT1_TCBHEAD static tcbhead_t __init1_tcbhead; #endif @@ -153,9 +162,7 @@ first_init (void) /* Initialize data structures so we can do RPCs. */ __mach_init (); -#ifndef SHARED - /* In the static case, we need to set up TLS early so that the stack - protection guard can be read at from TLS by the GCC-generated snippets. */ +#if USE_INIT1_TCBHEAD _hurd_tls_init (&__init1_tcbhead, 0); #endif