From patchwork Sun Mar 19 15:09:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 66590 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 2A247383F420 for ; Sun, 19 Mar 2023 15:13:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A247383F420 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679238783; bh=//BwPHkLY+oidl68fxNLdLvXRMoYcjOxe3yhNbqTXy0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=u/SOgVIKJrHj1VT594c6nktNZTbVerxJ7xMRpdZXnkiiR6HWVKx7W8tYLh3XFRBKU VMC0bd+6PTaflxTE3/ZscJRpYp1NysVowlylL3G768W3r2byovqwm9eWVvtpieytb8 GTC7JoMDqqcFWHawBd/NXCZ+hVRQdlndqfWwDKxA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 313FF3857C44 for ; Sun, 19 Mar 2023 15:11:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 313FF3857C44 Received: by mail-lj1-x231.google.com with SMTP id by8so8496258ljb.12 for ; Sun, 19 Mar 2023 08:11:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679238660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=//BwPHkLY+oidl68fxNLdLvXRMoYcjOxe3yhNbqTXy0=; b=lPKHg6hOKg6FeeWqAVXpmks6bg83EAq6Ahb8s+R4HYeu29Jw+x20umffCPVFDRu+Q2 ANhaaSNi6n1FXfSameADRhzCyzNCs7HrZwDbKSuWSJ4rIt5DVBcfLnjyUxw40Sf4Z7Ds 7V6+bhysdW5x8sBONo8qipMFIEsFqPBpD+JkAYkCu3dJZiVO3GW1lJ2LnK/pmeM/db9P Rf7DSymbsHknUFYmeu2LVVkE9Ulak05Kunw1oizSe+czCiM7RuOF0eWl8ufHmCVJ0jXr 2ZmLJQMhwSabMn1Dw7Zy7t733uhwBuPJ1H71syzIPfEJiYQe4TAg0DYJvsXjU5KODZpj smlw== X-Gm-Message-State: AO0yUKWiziYB+yNi6VZmRlUswtQ05FWvsmdk70wOvRPPgmC7VFU4cFaD eonppEtHcLgu0pPAj7HEN/LMpSvdYHSLXg== X-Google-Smtp-Source: AK7set/rz7cnbroJ5KGT8tAZ343lZMzYLhHTqu+ZXecET+unFXV+JN/sXge+zcQskdJmWCUswbl9lg== X-Received: by 2002:a2e:6816:0:b0:299:ac58:1c4 with SMTP id c22-20020a2e6816000000b00299ac5801c4mr3285578lja.1.1679238660506; Sun, 19 Mar 2023 08:11:00 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:577a:76f4:df43:5e66]) by smtp.gmail.com with ESMTPSA id m19-20020ac24253000000b004e90dee5469sm1274089lfl.157.2023.03.19.08.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 08:11:00 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Samuel Thibault , Sergey Bugaev Subject: [RFC PATCH glibc 05/34] hurd: Remove __hurd_threadvar_stack_{offset, mask} Date: Sun, 19 Mar 2023 18:09:48 +0300 Message-Id: <20230319151017.531737-6-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319151017.531737-1-bugaevc@gmail.com> References: <20230319151017.531737-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 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Noone is or should be using __hurd_threadvar_stack_{offset,mask}, we have proper TLS now. These two remaining variables are never set to anything other than zero, so any code that would try to use them as described would just dereference a zero pointer and crash. So remove them entirely. Signed-off-by: Sergey Bugaev --- hurd/Versions | 5 ----- hurd/hurd/threadvar.h | 15 --------------- sysdeps/mach/hurd/Versions | 3 --- sysdeps/mach/hurd/_Fork.c | 20 ++------------------ sysdeps/mach/hurd/i386/libc.abilist | 2 -- sysdeps/mach/hurd/x86/init-first.c | 3 --- 6 files changed, 2 insertions(+), 46 deletions(-) diff --git a/hurd/Versions b/hurd/Versions index 7e4f1c56..3d8b412d 100644 --- a/hurd/Versions +++ b/hurd/Versions @@ -1,8 +1,5 @@ libc { GLIBC_2.0 { - # variables used in macros & inline functions - __hurd_threadvar_stack_mask; __hurd_threadvar_stack_offset; - # functions used in libmachuser and libhurduser _S_catch_exception_raise; _S_catch_exception_raise_state; @@ -129,8 +126,6 @@ libc { _hurd_fd_error_signal; _hurd_fd_error; __hurd_dfail; __hurd_sockfail; _hurd_port_locked_set; - __hurd_threadvar_location_from_sp; - __hurd_threadvar_location; _hurd_userlink_link; _hurd_userlink_unlink; _hurd_userlink_clear; } GLIBC_2.29 { diff --git a/hurd/hurd/threadvar.h b/hurd/hurd/threadvar.h index 2a94f4de..f5c6a278 100644 --- a/hurd/hurd/threadvar.h +++ b/hurd/hurd/threadvar.h @@ -22,21 +22,6 @@ #include #include -/* The per-thread variables are found by ANDing this mask - with the value of the stack pointer and then adding this offset. - - In the multi-threaded case, cthreads initialization sets - __hurd_threadvar_stack_mask to ~(cthread_stack_size - 1), a mask which - finds the base of the fixed-size cthreads stack; and - __hurd_threadvar_stack_offset to a small offset that skips the data - cthreads itself maintains at the base of each thread's stack. - - In the single-threaded or libpthread case, __hurd_threadvar_stack_mask is - zero, so the stack pointer is ignored. */ - -extern unsigned long int __hurd_threadvar_stack_mask; -extern unsigned long int __hurd_threadvar_stack_offset; - /* The variables __hurd_sigthread_stack_base and __hurd_sigthread_stack_end define the bounds of the stack used by the signal thread, so that thread can always be specifically identified. */ diff --git a/sysdeps/mach/hurd/Versions b/sysdeps/mach/hurd/Versions index d75e674b..bf2e870a 100644 --- a/sysdeps/mach/hurd/Versions +++ b/sysdeps/mach/hurd/Versions @@ -33,9 +33,6 @@ libc { ld { GLIBC_2.0 { - # variables that must be shared with libc - __hurd_threadvar_stack_mask; __hurd_threadvar_stack_offset; - # functions that must be shared with libc __close; __getpid; __mmap; __open; __read; __sbrk; __strtoul_internal; diff --git a/sysdeps/mach/hurd/_Fork.c b/sysdeps/mach/hurd/_Fork.c index 4984cecd..77cd2917 100644 --- a/sysdeps/mach/hurd/_Fork.c +++ b/sysdeps/mach/hurd/_Fork.c @@ -482,25 +482,9 @@ retry: (natural_t *) &state, &statecount)) LOSE; #ifdef STACK_GROWTH_UP - if (__hurd_sigthread_stack_base == 0) - { - state.SP &= __hurd_threadvar_stack_mask; - state.SP += __hurd_threadvar_stack_offset; - } - else - state.SP = __hurd_sigthread_stack_base; + state.SP = __hurd_sigthread_stack_base; #else - if (__hurd_sigthread_stack_end == 0) - { - /* The signal thread has a stack assigned by pthread. - The threadvar_stack variables conveniently tell us how - to get to the highest address in the stack, just below - the per-thread variables. */ - state.SP &= __hurd_threadvar_stack_mask; - state.SP += __hurd_threadvar_stack_offset; - } - else - state.SP = __hurd_sigthread_stack_end; + state.SP = __hurd_sigthread_stack_end; #endif MACHINE_THREAD_STATE_SET_PC (&state, (unsigned long int) _hurd_msgport_receive); diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index ed0c4789..da1cad67 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -279,8 +279,6 @@ GLIBC_2.2.6 __gettimeofday F GLIBC_2.2.6 __gmtime_r F GLIBC_2.2.6 __h_errno_location F GLIBC_2.2.6 __hurd_fail F -GLIBC_2.2.6 __hurd_threadvar_stack_mask D 0x4 -GLIBC_2.2.6 __hurd_threadvar_stack_offset D 0x4 GLIBC_2.2.6 __isalnum_l F GLIBC_2.2.6 __isalpha_l F GLIBC_2.2.6 __isascii_l F diff --git a/sysdeps/mach/hurd/x86/init-first.c b/sysdeps/mach/hurd/x86/init-first.c index 75a5c842..6ca27155 100644 --- a/sysdeps/mach/hurd/x86/init-first.c +++ b/sysdeps/mach/hurd/x86/init-first.c @@ -34,9 +34,6 @@ extern void __mach_init (void); extern void __init_misc (int, char **, char **); -unsigned long int __hurd_threadvar_stack_offset; -unsigned long int __hurd_threadvar_stack_mask; - extern int __libc_argc attribute_hidden; extern char **__libc_argv attribute_hidden; extern char **_dl_argv;