From patchwork Wed May 17 19:14:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=TuPzb/wo; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2rK16mBz20dn for ; Thu, 18 May 2023 05:15:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 211463882AEB for ; Wed, 17 May 2023 19:15:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 211463882AEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350943; bh=eOnoHkYxHv7fF44ZeE4O+2X9ErpyjFQXbKn/jsenADE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TuPzb/wolRGChmuIqjGMLkX0SvBOvbUgD/dImbTs4soscfk5tBu6Ymg8KCjqNcBJA 5GMEbuXgWEBfq6gXyaSeWyPq9NYnbmKF5zFbizet92uTXutqtMgjO4B8f4MW3ddvy5 SK73NrMDn89SB6LRGgOGF0Uoiy883sLCToAPKvMs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id D55393858C5E for ; Wed, 17 May 2023 19:14:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D55393858C5E Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f2510b2b98so1376877e87.3 for ; Wed, 17 May 2023 12:14:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350880; x=1686942880; 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=eOnoHkYxHv7fF44ZeE4O+2X9ErpyjFQXbKn/jsenADE=; b=W/J+KCZnidbGfwVmGUhAietPOnIaW5AgBAPGH7foD23ck9ZotQazleaoaEQUVkDLCR cntVEqEcleH0ZL8GZ+NbP43ycpZEhDFpkoZUfjF7BFm6H5CFIkohk/RP9L/Ni8dkj1V0 WffMHBuaPWpj00NaY8CGaYQHcj5JQaSmcF61aSfhowkCdh2bOhaPxrcez47CrIzXxvtO 5VjapUTl3/LScWrSAVrijVVftI411AZv0UBaZxlqJiENM2Q2ygQll35xxKxOqRmMEEuM YqIsLgs0vFu2wLu3H1TT6OMzygDEs/IRUdTb/ONiuRFAp+pSMJcDD+bnyf7paiLMKdtD LhyQ== X-Gm-Message-State: AC+VfDwt8c8sJOpbaLwTvBx3pGhnP415X1VKIkriKIEL6cW4dw3yBlZi vAOuoZgUn23vG9/VtJ1YaXb0qaySiPI= X-Google-Smtp-Source: ACHHUZ4vKs1ESjpbFoeJl6vYnVk5Vfh9XGJTS4AbSD7o52vAJt78TchznrKzwdUJs+zoA3ErFAqkgg== X-Received: by 2002:ac2:43b2:0:b0:4dd:cb1d:b3cc with SMTP id t18-20020ac243b2000000b004ddcb1db3ccmr497233lfl.11.1684350879853; Wed, 17 May 2023 12:14:39 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:38 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 01/10] Remove sysdeps/generic/thread_state.h Date: Wed, 17 May 2023 22:14:27 +0300 Message-Id: <20230517191436.73636-2-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-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, KAM_SHORT, 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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This is a Mach-specific thread state definitions, and it's already handled by sysdeps/mach/thread_state.h. Signed-off-by: Sergey Bugaev --- sysdeps/generic/thread_state.h | 51 ---------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 sysdeps/generic/thread_state.h diff --git a/sysdeps/generic/thread_state.h b/sysdeps/generic/thread_state.h deleted file mode 100644 index 18926efb..00000000 --- a/sysdeps/generic/thread_state.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Mach thread state definitions for machine-independent code. Stub version. - Copyright (C) 1994-2023 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* Everything else is called `thread_state', but CMU's header file is - called `thread_status'. Oh boy. */ -#include - -/* Replace with "i386" or "mips" or whatever. */ - -/* This lets the kernel define architecture-specific registers for a new - thread. */ -#define MACHINE_NEW_THREAD_STATE_FLAVOR _NEW_THREAD_STATE -/* This makes the kernel load all architectures-specific registers for the - thread. */ -#define MACHINE_THREAD_STATE_FLAVOR _THREAD_STATE -#define MACHINE_THREAD_STATE_COUNT _THREAD_STATE_COUNT - -#define machine_thread_state _thread_state - -/* Define these to the member names in `struct _thread_state' - for the PC and stack pointer. */ -#define PC ? -#define SP ? - -/* This structure should contain all of the different flavors of thread - state structures which are meaningful for this machine. Every machine's - definition of this structure should have a member `int set' which is a - bit mask (1 << FLAVOR) of the flavors of thread state in the structure - which are filled in; and a member `struct machine_thread_state basic'. - On some machines those are the only members (e.g. i386); on others, - there are several relevant flavors of thread state (e.g. mips). */ -struct machine_thread_all_state - { - int set; /* Mask of bits (1 << FLAVOR). */ - struct _thread_state basic; - }; From patchwork Wed May 17 19:14:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=gPTUH8cU; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2qV63QQz20dX for ; Thu, 18 May 2023 05:15:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D87C13836E83 for ; Wed, 17 May 2023 19:15:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D87C13836E83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350900; bh=85WWdk4rPFjt4WrV3R0b3y8iHoN/8C0zYsFRSicwoHo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=gPTUH8cU2M0dG/gHzZQWPnkKoGaxyjpEtmNj6OT7Vxeb5r+CTqt445HZHaKjOictK CKxj1gXWltwKM1p1tVH+LiAmY4xuTuwic6eIDX5KnhUS0Pn1XV3aPJtEDXM5OOUeAV jfFlkPbXGN4/FSfqkR/O8AmGUeygXImC+jl+qcJ0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 002663858C78 for ; Wed, 17 May 2023 19:14:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 002663858C78 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f22908a082so1407453e87.1 for ; Wed, 17 May 2023 12:14:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350881; x=1686942881; 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=85WWdk4rPFjt4WrV3R0b3y8iHoN/8C0zYsFRSicwoHo=; b=aYTnmcJy1pY8fCM2A3k9lJIOfiE/9aPi2BBxJNd1WKaNsfYC8MT2CdpKcep/wMPAmy 8AUHLtq3vzP1R/hfSdZbSRi/MupV/QGUHSu9BedufcHimqNhKQ8QquJaiiVGsL6TnXg/ S8zNInAxGXVehpkVGr7dEcHJOiQR2zx0yAKxH/4ZKrc2h4mwhYXBR+AatoHi2U9x2bdB mcEDLWGoUGX8iLXFResku51okSgn5CvCLHgZUL+8TJs+nyzcvkRfZ/tnMdv64Hkgwytl VL4lRjwjpm5AuxO6G9C08rRkvMxICfDzJ3MpnT7oKlPfVz9AjJa99IKndWbZ4w3hsUMO WYTw== X-Gm-Message-State: AC+VfDwkHYaCr2bre9qMT8kbuLe6QR/f371bzM4xrYp+iTPPN1IOwSMC FdXIxTmXZ2HVG3SFKVeMksS2sPOORik= X-Google-Smtp-Source: ACHHUZ7cGrZgU/dfc6RGJAZxJ1/3MWQLT4HwxS5bAd+mmXrUPVY5zMwMVaYr9g4IoclbotkV9TDGkQ== X-Received: by 2002:a05:6512:51a:b0:4ed:bf01:3ff3 with SMTP id o26-20020a056512051a00b004edbf013ff3mr428154lfb.43.1684350880916; Wed, 17 May 2023 12:14:40 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:40 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 02/10] mach: Define MACHINE_THREAD_STATE_SETUP_CALL Date: Wed, 17 May 2023 22:14:28 +0300 Message-Id: <20230517191436.73636-3-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The existing two macros, MACHINE_THREAD_STATE_SET_PC and MACHINE_THREAD_STATE_SET_SP, can be used to set program counter and the stack pointer registers in a machine-specific thread state structure. Useful as it is, this may not be enough to set up the thread to make a function call, because the machine-specific ABI may impose additional requirements. In particular, x86_64 ABI requires that upon function entry, the stack pointer is 8 less than 16-byte aligned (sp & 15 == 8). To deal with this, introduce a new macro, MACHINE_THREAD_STATE_SETUP_CALL (), which sets both stack and instruction pointers, and also applies any machine-specific requirements to make a valid function call. The default implementation simply forwards to MACHINE_THREAD_STATE_SET_PC and MACHINE_THREAD_STATE_SET_SP, but on x86_64 we additionally align the stack pointer. Signed-off-by: Sergey Bugaev --- Any ideas for a better name than PTR_ALIGN_DOWN_8_16? sysdeps/mach/thread_state.h | 9 +++++++++ sysdeps/mach/x86/thread_state.h | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/sysdeps/mach/thread_state.h b/sysdeps/mach/thread_state.h index 9fa3d4e1..431aaf82 100644 --- a/sysdeps/mach/thread_state.h +++ b/sysdeps/mach/thread_state.h @@ -38,6 +38,15 @@ #endif #endif +/* Set up the thread state to call the given function on the given state. + Dependning on architecture, this may imply more than just setting PC + and SP. */ +#ifndef MACHINE_THREAD_STATE_SETUP_CALL +#define MACHINE_THREAD_STATE_SETUP_CALL(ts, stack, size, func) \ + (MACHINE_THREAD_STATE_SET_PC (ts, func), \ + MACHINE_THREAD_STATE_SET_SP (ts, stack, size)) +#endif + /* This copies architecture-specific bits from the current thread to the new thread state. */ #ifndef MACHINE_THREAD_STATE_FIX_NEW diff --git a/sysdeps/mach/x86/thread_state.h b/sysdeps/mach/x86/thread_state.h index 5be0bec1..8c419515 100644 --- a/sysdeps/mach/x86/thread_state.h +++ b/sysdeps/mach/x86/thread_state.h @@ -20,6 +20,7 @@ #define _MACH_X86_THREAD_STATE_H 1 #include +#include /* This lets the kernel define segments for a new thread. */ #define MACHINE_NEW_THREAD_STATE_FLAVOR i386_THREAD_STATE @@ -54,6 +55,18 @@ struct machine_thread_all_state struct i386_float_state fpu; }; +#ifdef __x86_64__ +/* We're setting up the stack to perform a function call. On function entry, + the stack pointer must be 8 bytes less than 16-aligned. */ +#define PTR_ALIGN_DOWN_8_16(ptr) \ + ({ uintptr_t __ptr = PTR_ALIGN_DOWN (ptr, 8); \ + PTR_IS_ALIGNED (__ptr, 16) ? (__ptr - 8) : __ptr; }) + +#define MACHINE_THREAD_STATE_SETUP_CALL(ts, stack, size, func) \ + ((ts)->SP = PTR_ALIGN_DOWN_8_16 ((uintptr_t) (stack) + (size)), \ + (ts)->PC = (uintptr_t) func) +#endif + #include #endif /* mach/x86/thread_state.h */ From patchwork Wed May 17 19:14:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=S0JxFmn1; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2qY29prz20KF for ; Thu, 18 May 2023 05:15:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51D193857357 for ; Wed, 17 May 2023 19:15:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51D193857357 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350903; bh=aDkP3cui13RbJktuMTr+l/amo3TuUCSm3cZ/6kdcibg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=S0JxFmn1aGxBvLvz7OcElxncZQWeUSuZxE4aPNhvFu0X5q77QimnoVjSOV/6FYXNJ 3hkmQGl+drptN0XVjazn9+byeDOr9sUhpGO4UlSvvir8XmNNtIxM+2kMSIRhEPVa+L afo6x9tNOIUET8O3nW2Zv360sIKpE6m0rrpts9Hg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 44242385702F for ; Wed, 17 May 2023 19:14:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 44242385702F Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2ac8c0fbb16so11507701fa.2 for ; Wed, 17 May 2023 12:14:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350882; x=1686942882; 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=aDkP3cui13RbJktuMTr+l/amo3TuUCSm3cZ/6kdcibg=; b=fU/mZqNCURr+D6dxVWTr52s5h6PGHRH08gCP63OhzjfHcClXwzuLT8LlXhrHirZCUC yKr/MJjqFH71DPE4+RuU1dFCouDx8FCA3ctzEEMHGq3UTYSI1HgUDub+S5REEUzGltqU wRimaTiEW53IXdYYSgotYj9kRJ74ruCKrt//yF1b6RnjBm+TTGLrLtTVL5WT9sTFg4Bd e8eRfY16IeaUzvU8aOSJZwy15xKv+me5VVOFEPk1KlkUJ7SP8WL//AEUwlmjTYyDEOp7 jguw6l8h7Q8/zD7CCQll0bpbFfZm0VGkLfTDNMcXC9yYx0P/WEFGyY4mLgakobs+oNb4 MPXw== X-Gm-Message-State: AC+VfDxizI4UsxZySxpaI6hk8OqqGNKvccvziP3XsH7dOYqMkQjlv6K1 CPh1mjeowgu4sPfllJd7gIEolAAiUUg= X-Google-Smtp-Source: ACHHUZ5LtfKHuu5gXkOIEoq3QKi9m2TMEh8Ksp/2z8luQxsE+86JKtTa8WHGPmctBKED5SsVCCx8ow== X-Received: by 2002:a19:c507:0:b0:4f1:3eea:eaf9 with SMTP id w7-20020a19c507000000b004f13eeaeaf9mr528304lfe.24.1684350882250; Wed, 17 May 2023 12:14:42 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:41 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 03/10] hurd: Use MACHINE_THREAD_STATE_SETUP_CALL Date: Wed, 17 May 2023 22:14:29 +0300 Message-Id: <20230517191436.73636-4-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Sergey Bugaev --- hurd/hurdfault.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c index 4340897d..dae889a9 100644 --- a/hurd/hurdfault.c +++ b/hurd/hurdfault.c @@ -205,8 +205,8 @@ _hurdsig_fault_init (void) It runs the function above. */ memset (&state, 0, sizeof state); MACHINE_THREAD_STATE_FIX_NEW (&state); - MACHINE_THREAD_STATE_SET_PC (&state, faulted); - MACHINE_THREAD_STATE_SET_SP (&state, faultstack, sizeof faultstack); + MACHINE_THREAD_STATE_SETUP_CALL (&state, faultstack, + sizeof faultstack, faulted); err = __USEPORT (PROC, From patchwork Wed May 17 19:14:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=XId1hkLg; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2rM5h5Wz20dn for ; Thu, 18 May 2023 05:15:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1C0B3883018 for ; Wed, 17 May 2023 19:15:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1C0B3883018 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350945; bh=PQeF2UNB+92aUMXnsUUaGeRq0Or6LfsjJk2p7NQETCY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XId1hkLg8tMoEotJLbPFlJOaFf4o/P1r+LLTFRYnOLuctlShhFNb8t0sr3lIKreA9 zvs1WbAKVERumhalClz9FFtgdxgZN0SMhJWSrD5CmJxkerQFOXprQt4q5LV3qZ7GfM Fa9KdY2ruGJ76d02rQaAd3EkxDOJCT+PopuhqU+c= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id 981D33856DD0 for ; Wed, 17 May 2023 19:14:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 981D33856DD0 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f13d8f74abso1405412e87.0 for ; Wed, 17 May 2023 12:14:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350884; x=1686942884; 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=PQeF2UNB+92aUMXnsUUaGeRq0Or6LfsjJk2p7NQETCY=; b=kCUAgFybSgAUaIfSW4aY57aarVPqYGQGX1f8/0TO3vgSzVHlKCWN9AS5H+eY2akBAg GJd0mydrb0G6yb4c9/8udg32qWWtWAFU6zDu0RjvdhbSA/32OjguMYrkCc66GL99sU5h KvfbzuHC4D3+OMDvP3yBV9NZ4QPL7kvzS87TBSsvWLId9t31KZuLehQsscqxwY2ZZjc2 Nc0x2zhYTdCsaXlT7KTQpniXc82HxU2oqXVB/REHVlVPDhIelqCcJiY0CEvKAvWCG3YA UtAImNXz3rKeUPBbCSoaVix7QghMciUrGvB8eqtp6DkQjSKughLZ7r4wMnduoG05/zTQ k7Og== X-Gm-Message-State: AC+VfDw67af24SyYSrZchHcKz5qfPI6t/FchjSqELEOgHZw0Y8m5Vkzt jzYmgOyYwN2qteE+T2Xlr8Gm3aGpyr0= X-Google-Smtp-Source: ACHHUZ6NkHN67b9pMF1SQ4EVxocGSjwqLIcrBZoNFMMErEjF4Jcu+hrLN0etfPm9w3TRcNrqada57g== X-Received: by 2002:a19:f715:0:b0:4f1:5001:1d9c with SMTP id z21-20020a19f715000000b004f150011d9cmr453794lfe.55.1684350883681; Wed, 17 May 2023 12:14:43 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:42 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 04/10] mach: Add __mach_setup_thread_call () Date: Wed, 17 May 2023 22:14:30 +0300 Message-Id: <20230517191436.73636-5-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-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, KAM_SHORT, 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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This is just like mach_setup_thread (), but it's suitable for making the thread call a function correctly, as opposed to explicitly setting the thread's stack and instruction pointers to the given values. Internally, it uses MACHINE_THREAD_STATE_SETUP_CALL. Unlike mach_setup_thread (), which is exported via mach.h for the benefit of the Hurd exec server, __mach_setup_thread_call () is private to glibc for the time being. Signed-off-by: Sergey Bugaev --- mach/mach.h | 6 +++++- mach/setup-thread.c | 52 ++++++++++++++++++++++++++++++++------------- mach/setup-thread.h | 32 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 mach/setup-thread.h diff --git a/mach/mach.h b/mach/mach.h index d115f5a1..348f0196 100644 --- a/mach/mach.h +++ b/mach/mach.h @@ -88,7 +88,11 @@ extern FILE *mach_open_devstream (mach_port_t device_port, const char *mode); If STACK_BASE is not null it is filled in with the chosen stack base. If STACK_SIZE is not null it is filled in with the chosen stack size. Regardless, an extra page of red zone is allocated off the end; this - is not included in *STACK_SIZE. */ + is not included in *STACK_SIZE. + + Mote: this function is unsuitable for setting up the thread to call a + function at PC, since the architecture ABI may impose additional + requirements beyond setting PC and stack. */ kern_return_t __mach_setup_thread (task_t task, thread_t thread, void *pc, vm_address_t *stack_base, vm_size_t *stack_size); diff --git a/mach/setup-thread.c b/mach/setup-thread.c index ae24a149..0e149787 100644 --- a/mach/setup-thread.c +++ b/mach/setup-thread.c @@ -16,6 +16,7 @@ . */ #include +#include #include #include #include @@ -24,17 +25,10 @@ #define STACK_SIZE (16 * 1024 * 1024) /* 16MB, arbitrary. */ -/* Give THREAD a stack and set it to run at PC when resumed. - If *STACK_SIZE is nonzero, that size of stack is allocated. - If *STACK_BASE is nonzero, that stack location is used. - If STACK_BASE is not null it is filled in with the chosen stack base. - If STACK_SIZE is not null it is filled in with the chosen stack size. - Regardless, an extra page of red zone is allocated off the end; this - is not included in *STACK_SIZE. */ - -kern_return_t -__mach_setup_thread (task_t task, thread_t thread, void *pc, - vm_address_t *stack_base, vm_size_t *stack_size) +static kern_return_t +mach_setup_thread_impl (task_t task, thread_t thread, int is_call, + void *pc, vm_address_t *stack_base, + vm_size_t *stack_size) { kern_return_t error; struct machine_thread_state ts; @@ -43,6 +37,8 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc, vm_size_t size; int anywhere; + memset (&ts, 0, sizeof (ts)); + size = stack_size ? *stack_size ? : STACK_SIZE : STACK_SIZE; stack = stack_base ? *stack_base ? : 0 : 0; anywhere = !stack_base || !*stack_base; @@ -54,21 +50,25 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc, if (stack_size) *stack_size = size; - memset (&ts, 0, sizeof (ts)); - MACHINE_THREAD_STATE_SET_PC (&ts, pc); #ifdef STACK_GROWTH_DOWN if (stack_base) *stack_base = stack + __vm_page_size; - ts.SP = stack + __vm_page_size + size; #elif defined (STACK_GROWTH_UP) if (stack_base) *stack_base = stack; - ts.SP = stack; stack += size; #else #error stack direction unknown #endif + if (is_call) + MACHINE_THREAD_STATE_SETUP_CALL (&ts, *stack_base, size, pc); + else + { + MACHINE_THREAD_STATE_SET_PC (&ts, pc); + MACHINE_THREAD_STATE_SET_SP (&ts, *stack_base, size); + } + /* Create the red zone. */ if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE)) return error; @@ -77,8 +77,30 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc, (natural_t *) &ts, tssize); } +/* Give THREAD a stack and set it to run at PC when resumed. + If *STACK_SIZE is nonzero, that size of stack is allocated. + If *STACK_BASE is nonzero, that stack location is used. + If STACK_BASE is not null it is filled in with the chosen stack base. + If STACK_SIZE is not null it is filled in with the chosen stack size. + Regardless, an extra page of red zone is allocated off the end; this + is not included in *STACK_SIZE. */ + +kern_return_t +__mach_setup_thread (task_t task, thread_t thread, void *pc, + vm_address_t *stack_base, vm_size_t *stack_size) +{ + return mach_setup_thread_impl (task, thread, 0, pc, stack_base, stack_size); +} + weak_alias (__mach_setup_thread, mach_setup_thread) +kern_return_t +__mach_setup_thread_call (task_t task, thread_t thread, void *pc, + vm_address_t *stack_base, vm_size_t *stack_size) +{ + return mach_setup_thread_impl (task, thread, 1, pc, stack_base, stack_size); +} + /* Give THREAD a TLS area. */ kern_return_t __mach_setup_tls (thread_t thread) diff --git a/mach/setup-thread.h b/mach/setup-thread.h new file mode 100644 index 00000000..b4c94d1d --- /dev/null +++ b/mach/setup-thread.h @@ -0,0 +1,32 @@ +/* Setup a Mach thread. + Copyright (C) 1993-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MACH_SETUP_THREAD_H + +#define _MACH_SETUP_THREAD_H 1 + +#include + +/* Like mach_setup_thread (), but suitable for setting up function + calls. */ +kern_return_t __mach_setup_thread_call (task_t task, thread_t thread, + void *function, + vm_address_t *stack_base, + vm_size_t *stack_size); + +#endif /* mach/setup-thread.h */ From patchwork Wed May 17 19:14:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=TkHJ2PAY; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2sF2RJyz20dn for ; Thu, 18 May 2023 05:16:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 67D6638432D7 for ; Wed, 17 May 2023 19:16:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67D6638432D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350988; bh=scwiVF/vMF8p8A/eAORjCkOU/PAbDLBDq9Zi0mkKLvY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TkHJ2PAYIVXqJlMx6AhhHO4EjSR36OinEuBEWg8+EUVJDK94hTJUq9nTeenhSWh5k A9Z94NN7ef4Bh53Rn36G1Z9Njx0JPMco9FGLQ0WnTxtj04flPU6Dzi08b0fwP5jIXA rtfMeAcjcpqcoWItM66eOsEAKANlQMBK8JypimVo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 32F0F3856976 for ; Wed, 17 May 2023 19:14:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 32F0F3856976 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f24d4900bbso1387532e87.3 for ; Wed, 17 May 2023 12:14:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350885; x=1686942885; 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=scwiVF/vMF8p8A/eAORjCkOU/PAbDLBDq9Zi0mkKLvY=; b=Zqbwldu/HSgig2N+6oQTqCHM7lcBrsly94QpUhD/eLpBxFIGJS1kwU8lIokqJKYJ0j yUOaAQwI6c/fmHEYaLc7j27Jd9lVcixMBnXhyKcxxl/TWTPoKilIAdLcOj5/AMZ6SMFM uRTO5uDYq0+P+q+R/CXaDWa403rLKl05QySMePcJTYKtaKFANya+RMSCQ21wwVkDsvD+ BJ9eqXP0Rxxw0E0TfhhBEEyR9s5BUhaaNizjKVLjZGbSk4bmS8w8MFDTlhm5dszOG32V HgXVlGnxmkUfgn12lUOa7KLGHdeddAypy3bZzqo9sWz4AmqXadxvK9t1M6VW37MrZgbc CNLg== X-Gm-Message-State: AC+VfDxEj0Xr1pyYtudaDb8FfaVv76732/RCsT2X8pHvmqvrL9OsLD0D TQ0QDZ+RtVrv4Fkk8DaBMU5NJ8onqTs= X-Google-Smtp-Source: ACHHUZ5bXS1oeKlGfUXjSssLrD1MlXjWewf+sRal5mQVIAP0eBOEmVBJCG+sLSdxWuCXD4hyj0VT2g== X-Received: by 2002:a19:ad4a:0:b0:4ed:c286:7ab6 with SMTP id s10-20020a19ad4a000000b004edc2867ab6mr470538lfd.67.1684350885169; Wed, 17 May 2023 12:14:45 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:44 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 05/10] hurd: Use __mach_setup_thread_call () Date: Wed, 17 May 2023 22:14:31 +0300 Message-Id: <20230517191436.73636-6-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" ...instead of mach_setup_thread (), which is unsuitable for setting up function calls. Checked on x86_64-gnu: the signal thread no longer crashes upon trying to process a message. Signed-off-by: Sergey Bugaev --- hurd/hurdsig.c | 10 ++++++---- sysdeps/mach/hurd/profil.c | 5 +++-- sysdeps/mach/hurd/setitimer.c | 11 ++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 78ea59d9..313e95ae 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -22,6 +22,7 @@ #include /* For `struct mutex'. */ #include #include +#include #include #include #include @@ -1525,10 +1526,11 @@ _hurdsig_init (const int *intarray, size_t intarraysize) assert_perror (err); stacksize = __vm_page_size * 8; /* Small stack for signal thread. */ - err = __mach_setup_thread (__mach_task_self (), _hurd_msgport_thread, - _hurd_msgport_receive, - (vm_address_t *) &__hurd_sigthread_stack_base, - &stacksize); + err = __mach_setup_thread_call (__mach_task_self (), + _hurd_msgport_thread, + _hurd_msgport_receive, + (vm_address_t *) &__hurd_sigthread_stack_base, + &stacksize); assert_perror (err); err = __mach_setup_tls (_hurd_msgport_thread); assert_perror (err); diff --git a/sysdeps/mach/hurd/profil.c b/sysdeps/mach/hurd/profil.c index 64fe76f7..8092df0a 100644 --- a/sysdeps/mach/hurd/profil.c +++ b/sysdeps/mach/hurd/profil.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -68,8 +69,8 @@ update_waiter (u_short *sample_buffer, size_t size, size_t offset, u_int scale) /* Set up the profiling collector thread. */ err = __thread_create (__mach_task_self (), &profile_thread); if (! err) - err = __mach_setup_thread (__mach_task_self (), profile_thread, - &profile_waiter, NULL, NULL); + err = __mach_setup_thread_call (__mach_task_self (), profile_thread, + &profile_waiter, NULL, NULL); if (! err) err = __mach_setup_tls(profile_thread); } diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c index d09c59dc..03191b91 100644 --- a/sysdeps/mach/hurd/setitimer.c +++ b/sysdeps/mach/hurd/setitimer.c @@ -25,6 +25,7 @@ #include #include #include +#include /* XXX Temporary cheezoid implementation of ITIMER_REAL/SIGALRM. */ @@ -227,11 +228,11 @@ setitimer_locked (const struct itimerval *new, struct itimerval *old, goto out; _hurd_itimer_thread_stack_base = 0; /* Anywhere. */ _hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack. */ - if ((err = __mach_setup_thread (__mach_task_self (), - _hurd_itimer_thread, - &timer_thread, - &_hurd_itimer_thread_stack_base, - &_hurd_itimer_thread_stack_size)) + if ((err = __mach_setup_thread_call (__mach_task_self (), + _hurd_itimer_thread, + &timer_thread, + &_hurd_itimer_thread_stack_base, + &_hurd_itimer_thread_stack_size)) || (err = __mach_setup_tls(_hurd_itimer_thread))) { __thread_terminate (_hurd_itimer_thread); From patchwork Wed May 17 19:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=QZ+L8BSG; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2rK4Q4Mz20dq for ; Thu, 18 May 2023 05:15:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9879E38346B7 for ; Wed, 17 May 2023 19:15:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9879E38346B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350943; bh=5dPGJhcZg6lHzRIz+7HN9+JEHTfCzz8yFj8r2ixXrLo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QZ+L8BSGPULK8LRZooGLf53NRFC6mgOxmsmzBSke+lkZYSHsjhNBByTsUOE9QkJ8H YOlK1sciKW1kLcq64PG2B63Jmc3iASIAsKb9J77PyYPkijlmzLSvmyomv0DuNgjaSS kvBTKYpIwOQt2KCDcrcs/a/jGSlCkQNIVsyOXWtU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id D0995385696A for ; Wed, 17 May 2023 19:14:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D0995385696A Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4ec8eca56cfso1395904e87.0 for ; Wed, 17 May 2023 12:14:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350887; x=1686942887; 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=5dPGJhcZg6lHzRIz+7HN9+JEHTfCzz8yFj8r2ixXrLo=; b=TNUZ1jWg9gvfDdTzOt7/OZTI6RR4FAmNivAaszvj560cVP+LeTATxoUBz4v07hRkLZ 84VGKrM4nv2dzEIO1KMb4DvmlMw6YsawT/oKFocAkYja3tJkuuh2v/kWjsS9ObeXPeUt lwPlsLKoMjCkwA1pCBrZL9taH+wCKvU9QgqVyZSMqZjkLvruY0pVJXdxOkveuG8VH8Z7 nCSu98DpgEYHn6N9A4Gq/pwYSfgvhijXmp9frIJ2YLkCKPQb7QnJ8X3S2QXNCq+CAPPC 7ZZMIhCVBa1aSYWnPMUJ2F3i7uleF7ttqEAxnzfxvQ8vogsfnvHkYn6oIyDXEKXqNhjI RWgQ== X-Gm-Message-State: AC+VfDwq7DS4CZ76pk5isOr+aPRQUFRVyg0Tp7NgO1hJW/MniOQ4+pQ5 dn2QckvWH76z0/7vT9BIBdv468Cv5sw= X-Google-Smtp-Source: ACHHUZ6CelYMAgmTxFxMvgTPwPy+BAoOzA4VSJ//FwFi2hKfuHNR5d/kyF7Mwysgz2mpgNG0ucqqwg== X-Received: by 2002:ac2:4143:0:b0:4f3:895f:f3f8 with SMTP id c3-20020ac24143000000b004f3895ff3f8mr411845lfi.16.1684350886796; Wed, 17 May 2023 12:14:46 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:45 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [RFC PATCH 06/10] hurd: Make sure to not use tcb->self Date: Wed, 17 May 2023 22:14:32 +0300 Message-Id: <20230517191436.73636-7-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Unlike sigstate->thread, tcb->self did not hold a Mach port reference on the thread port it names. This means that the port can be deallocated, and the name reused for something else, without anyone noticing. Using tcb->self will then lead to port use-after-free. Fortunately nothing was accessing tcb->self, other than it being intially set to then-valid thread port name upon TCB initialization. To assert that this keeps being the case without altering TCB layout, rename self -> self_do_not_use, and stop initializing it. Also, do not (re-)allocate a whole separate and unused stack for the main thread, and just exit __pthread_setup early in this case. Found upon attempting to use tcb->self and getting unexpected crashes. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/i386/tls.h | 3 +-- sysdeps/mach/hurd/x86/htl/pt-setup.c | 34 ++++++++++------------------ sysdeps/mach/hurd/x86_64/tls.h | 3 +-- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index e124fb10..ba283008 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -32,7 +32,7 @@ typedef struct { void *tcb; /* Points to this structure. */ dtv_t *dtv; /* Vector of pointers to TLS data. */ - thread_t self; /* This thread's control port. */ + thread_t self_do_not_use; /* This thread's control port. */ int multiple_threads; uintptr_t sysinfo; uintptr_t stack_guard; @@ -419,7 +419,6 @@ _hurd_tls_new (thread_t child, tcbhead_t *tcb) HURD_TLS_DESC_DECL (desc, tcb); tcb->tcb = tcb; - tcb->self = child; if (HURD_SEL_LDT (sel)) err = __i386_set_ldt (child, sel, &desc, 1); diff --git a/sysdeps/mach/hurd/x86/htl/pt-setup.c b/sysdeps/mach/hurd/x86/htl/pt-setup.c index 3abd92b2..686124d7 100644 --- a/sysdeps/mach/hurd/x86/htl/pt-setup.c +++ b/sysdeps/mach/hurd/x86/htl/pt-setup.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -76,35 +77,24 @@ __pthread_setup (struct __pthread *thread, void *), void *(*start_routine) (void *), void *arg) { - tcbhead_t *tcb; error_t err; - mach_port_t ktid; - thread->mcontext.pc = entry_point; - thread->mcontext.sp = stack_setup (thread, start_routine, arg); - - ktid = __mach_thread_self (); - if (thread->kernel_thread == ktid) + if (thread->kernel_thread == hurd_thread_self ()) /* Fix up the TCB for the main thread. The C library has already installed a TCB, which we want to keep using. This TCB must not be freed so don't register it in the thread structure. On the other hand, it's not yet possible to reliably release a TCB. - Leave the unused one registered so that it doesn't leak. The - only thing left to do is to correctly set the `self' member in - the already existing TCB. */ - tcb = THREAD_SELF; - else - { - err = __thread_set_pcsptp (thread->kernel_thread, - 1, thread->mcontext.pc, - 1, thread->mcontext.sp, - 1, thread->tcb); - assert_perror (err); - tcb = thread->tcb; - } - __mach_port_deallocate (__mach_task_self (), ktid); + Leave the unused one registered so that it doesn't leak. */ + return 0; + + thread->mcontext.pc = entry_point; + thread->mcontext.sp = stack_setup (thread, start_routine, arg); - tcb->self = thread->kernel_thread; + err = __thread_set_pcsptp (thread->kernel_thread, + 1, thread->mcontext.pc, + 1, thread->mcontext.sp, + 1, thread->tcb); + assert_perror (err); return 0; } diff --git a/sysdeps/mach/hurd/x86_64/tls.h b/sysdeps/mach/hurd/x86_64/tls.h index 1274723a..35dcef44 100644 --- a/sysdeps/mach/hurd/x86_64/tls.h +++ b/sysdeps/mach/hurd/x86_64/tls.h @@ -35,7 +35,7 @@ typedef struct { void *tcb; /* Points to this structure. */ dtv_t *dtv; /* Vector of pointers to TLS data. */ - thread_t self; /* This thread's control port. */ + thread_t self_do_no_use; /* This thread's control port. */ int __glibc_padding1; int multiple_threads; int gscope_flag; @@ -158,7 +158,6 @@ _hurd_tls_new (thread_t child, tcbhead_t *tcb) struct i386_fsgs_base_state state; tcb->tcb = tcb; - tcb->self = child; /* Install the TCB address into FS base. */ state.fs_base = (uintptr_t) tcb; From patchwork Wed May 17 19:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=b7ALcg28; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2qj0Gblz20dq for ; Thu, 18 May 2023 05:15:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A93B3882008 for ; Wed, 17 May 2023 19:15:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A93B3882008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350911; bh=jjtjP6SNJz4/32jzlkayjhTbYUKbetfqAZX5bBd03kU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=b7ALcg28X/G1hK6CpxBC2x4GqcbhKjoE4snxyOSpskmbB1q1Wtq2kUSZrhX70TEqH Gkjxo/XsY+Iuq/rgI7H6p4WDylQ62fA4KRwIwVS24ygYpPcSiUQ3BjWzUvp8mAdVdX ZvIhx/PE+gMism926Gmr3AX8sOE66N0zbm+R2NWE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id 3933C385483A for ; Wed, 17 May 2023 19:14:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3933C385483A Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f387d97dddso1425416e87.3 for ; Wed, 17 May 2023 12:14:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350888; x=1686942888; 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=jjtjP6SNJz4/32jzlkayjhTbYUKbetfqAZX5bBd03kU=; b=Kf4ByLTTkdwML+CPu6HB8VztxXXsvI+VGK1gNfYoURQpNYozaTBZHRR6TXXk8w5xX5 bGkbvrJlJy0m6bDBcy2Hfpz4tVpUcnfKbSve65AM4sAD03XaZT7P6n2JnvLJjzzowp7s R1+tOFqG9okFRTldEcO5yB4hLjzWYJP6SCPv9IkXCfgh+ido2IASVA/OyXn/1V2coNIx gunSjXvdnweRDMrxV/2yI3BplCN99n8TwqZFDk0Op312+o3rU4XzpSwgLSHJLnrp7PsC eBJjzWpJu1YLYkqwOId9ygXgpu3YGDQ99ct8NCJIx6xsV/JMOdq5tbtscMFqU00EN5A8 4frg== X-Gm-Message-State: AC+VfDzVCJTOhk3vAMuvMpYUKSyC9zVXSDLAozzJrVMymd0qfgQwphFk YjljBkWIdUrQl8CwjL8kfFtl+pJga4o= X-Google-Smtp-Source: ACHHUZ6jRYsBPTkPhdU5zuHxNu4LjbQAQM+890Efsf0dzuMd0l/cZOl/uK+OEtHGGoVNBV4K9aOvTw== X-Received: by 2002:ac2:5934:0:b0:4ef:f4ef:a1cc with SMTP id v20-20020ac25934000000b004eff4efa1ccmr467330lfi.14.1684350888378; Wed, 17 May 2023 12:14:48 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:47 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 07/10] hurd: Fix x86_64 _hurd_tls_fork Date: Wed, 17 May 2023 22:14:33 +0300 Message-Id: <20230517191436.73636-8-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" It is illegal to call thread_get_state () on mach_thread_self (), so this codepath cannot be used as-is to fork the calling thread's TLS. Fortunately we can use THREAD_SELF (aka %fs:0x0) to find out the value of our fs_base without calling into the kernel. Fixes: f6cf701efc61c9ad910372bda14b9a235db310a8 "hurd: Implement TLS for x86_64" Checked on x86_64-gnu: fork () now works! Signed-off-by: Sergey Bugaev --- It would be nice if GNU Mach allowed thread_get_state (mach_thread_self (), i386_FSGS_BASE_STATE) like it already allows thread_set_state for this case. But even if gnumach adds suppport for this, doing it in userspace without an extra RPC is still better. sysdeps/mach/hurd/x86_64/tls.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/sysdeps/mach/hurd/x86_64/tls.h b/sysdeps/mach/hurd/x86_64/tls.h index 35dcef44..6487ed35 100644 --- a/sysdeps/mach/hurd/x86_64/tls.h +++ b/sysdeps/mach/hurd/x86_64/tls.h @@ -140,12 +140,25 @@ _hurd_tls_fork (thread_t child, thread_t orig, error_t err; struct i386_fsgs_base_state state; mach_msg_type_number_t state_count = i386_FSGS_BASE_STATE_COUNT; - err = __thread_get_state (orig, i386_FSGS_BASE_STATE, - (thread_state_t) &state, - &state_count); - if (err) - return err; - assert (state_count == i386_FSGS_BASE_STATE_COUNT); + + extern thread_t hurd_thread_self (void); + if (orig != hurd_thread_self ()) + { + err = __thread_get_state (orig, i386_FSGS_BASE_STATE, + (thread_state_t) &state, + &state_count); + if (err) + return err; + assert (state_count == i386_FSGS_BASE_STATE_COUNT); + } + else + { + /* It is illegal to call thread_get_state () on mach_thread_self (). + But we're only interested in the value of fs_base, and since we're + this thread, we know it points to our TCB. */ + state.fs_base = (unsigned long) THREAD_SELF; + state.gs_base = 0; + } return __thread_set_state (child, i386_FSGS_BASE_STATE, (thread_state_t) &state, From patchwork Wed May 17 19:14:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=uBGV4hLd; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2s702rmz20dn for ; Thu, 18 May 2023 05:16:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 07FAA388A414 for ; Wed, 17 May 2023 19:16:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07FAA388A414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350985; bh=cXT6TtIV88qIUohZRRm5TOpZwH3Jf3/4Fo9cDFNgLSg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=uBGV4hLdTMpb0nuDrEf0ITq6ubHJUjlekYRJ6RwkUneL3md9KAXWQ25asQsP9Q+d7 0wFUTJxtVBMmlA+aiHFmx/1p7CkNvc39ubIrPGK5GKng33r2Z9//7ltvHIDGPIrVfX 4eGvmXojN6WQuRF9x309uvhAyUkXm4lxo9Fm7a6I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id E390F38560AA for ; Wed, 17 May 2023 19:14:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E390F38560AA Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2af12685274so4483991fa.2 for ; Wed, 17 May 2023 12:14:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350890; x=1686942890; 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=cXT6TtIV88qIUohZRRm5TOpZwH3Jf3/4Fo9cDFNgLSg=; b=k4xERBaqTKDMM4YQM/O/7bb3JQIIRt3bcP0pa921trCnKf/Mjwa2tX/qMaDVp0aADJ ZAQUehkDjLKeqAXeWhRTOBHGZtSN294nZgXvEngMpUeqnHj9w/42/G7olbXg15IzY5HY kAvE+fcVW+X7QgkN3iPrJzyE1KfBpMiS/HEE2Gw+wpUb7QUMLhTXaX484AAoYnVX0DK8 AgYFCfb9eYWQiRGgxlVCBxf7bZROcoU9ZDIkeV/IZzF8toVlAjXBh8KIW+Gi5NuwPf3R ayDGPbpcNMQrf40wwcLEy5JK1w4PBejf0a9lwUmt1CkMBePMEnbtjsgccxmOfhbVWhbk 5Nbg== X-Gm-Message-State: AC+VfDxHaybOURtrLWkiRt0o5PRmh6Kf38pwBddIYhTNCWfAObp0bPzC e2Rar404dBfwBqSQOscwf6kIEnc4zyM= X-Google-Smtp-Source: ACHHUZ6/XKTzv4K9quZl2YUHZtX+divK7uBBR26hbzVCBfB5ROpoN7yUs25ExeyMldkpoavK9UbP+A== X-Received: by 2002:a2e:9c18:0:b0:2ad:bedc:995b with SMTP id s24-20020a2e9c18000000b002adbedc995bmr7839874lji.16.1684350889884; Wed, 17 May 2023 12:14:49 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:48 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 08/10] hurd: Fix setting up pthreads Date: Wed, 17 May 2023 22:14:34 +0300 Message-Id: <20230517191436.73636-9-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" On x86_64, we have to pass function arguments in registers, not on the stack. We also have to align the stack pointer in a specific way. Since sharing the logic with i386 does not bring much benefit, split the file back into i386- and x86_64-specific versions, and fix the x86_64 version to set up the thread properly. Bonus: i386 keeps doing the extra RPC inside __thread_set_pcsptp to fetch the state of the thread before setting it; but x86_64 no lnoger does that. Checked on x86_64-gnu and i686-gnu. Fixes be6d002ca277ffc90058d382396150cb0e785b9c "hurd: Set up the basic tree for x86_64-gnu" Signed-off-by: Sergey Bugaev --- __thread_set_pcsptp is also used by pthread_cancel (), which suffers from the same issue. Eventually I'd like to remove __thread_set_pcsptp entirely. .../mach/hurd/{x86 => i386}/htl/pt-setup.c | 2 +- sysdeps/mach/hurd/x86_64/htl/pt-setup.c | 93 +++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) rename sysdeps/mach/hurd/{x86 => i386}/htl/pt-setup.c (98%) create mode 100644 sysdeps/mach/hurd/x86_64/htl/pt-setup.c diff --git a/sysdeps/mach/hurd/x86/htl/pt-setup.c b/sysdeps/mach/hurd/i386/htl/pt-setup.c similarity index 98% rename from sysdeps/mach/hurd/x86/htl/pt-setup.c rename to sysdeps/mach/hurd/i386/htl/pt-setup.c index 686124d7..ba108b96 100644 --- a/sysdeps/mach/hurd/x86/htl/pt-setup.c +++ b/sysdeps/mach/hurd/i386/htl/pt-setup.c @@ -1,4 +1,4 @@ -/* Setup thread stack. Hurd/x86 version. +/* Setup thread stack. Hurd/i386 version. Copyright (C) 2000-2023 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/sysdeps/mach/hurd/x86_64/htl/pt-setup.c b/sysdeps/mach/hurd/x86_64/htl/pt-setup.c new file mode 100644 index 00000000..7dc62912 --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/htl/pt-setup.c @@ -0,0 +1,93 @@ +/* Setup thread stack. Hurd/x86_64 version. + Copyright (C) 2000-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include +#include + +/* Set up the stack for THREAD. Return the stack pointer + for the new thread. */ +static void * +stack_setup (struct __pthread *thread) +{ + error_t err; + uintptr_t bottom, top; + + /* Calculate the top of the new stack. */ + bottom = (uintptr_t) thread->stackaddr; + top = bottom + thread->stacksize + round_page (thread->guardsize); + + if (thread->guardsize) + { + err = __vm_protect (__mach_task_self (), (vm_address_t) bottom, + thread->guardsize, 0, 0); + assert_perror (err); + } + + return (void *) PTR_ALIGN_DOWN_8_16 (top); +} + +int +__pthread_setup (struct __pthread *thread, + void (*entry_point) (struct __pthread *, void *(*)(void *), + void *), void *(*start_routine) (void *), + void *arg) +{ + error_t err; + struct i386_thread_state state; + struct i386_fsgs_base_state fsgs_state; + + if (thread->kernel_thread == hurd_thread_self ()) + /* Fix up the TCB for the main thread. The C library has already + installed a TCB, which we want to keep using. This TCB must not + be freed so don't register it in the thread structure. On the + other hand, it's not yet possible to reliably release a TCB. + Leave the unused one registered so that it doesn't leak. */ + return 0; + + + thread->mcontext.pc = entry_point; + thread->mcontext.sp = stack_setup (thread); + + /* Set up the state to call entry_point (thread, start_routine, arg) */ + memset (&state, 0, sizeof (state)); + state.ursp = (uintptr_t) thread->mcontext.sp; + state.rip = (uintptr_t) thread->mcontext.pc; + state.rdi = (uintptr_t) thread; + state.rsi = (uintptr_t) start_routine; + state.rdx = (uintptr_t) arg; + + err = __thread_set_state (thread->kernel_thread, i386_THREAD_STATE, + (thread_state_t) &state, + i386_THREAD_STATE_COUNT); + assert_perror (err); + + /* Set fs_base to the TCB pointer for the thread. */ + memset (&fsgs_state, 0, sizeof (fsgs_state)); + fsgs_state.fs_base = (uintptr_t) thread->tcb; + err = __thread_set_state (thread->kernel_thread, i386_FSGS_BASE_STATE, + (thread_state_t) &fsgs_state, + i386_FSGS_BASE_STATE_COUNT); + assert_perror (err); + + return 0; +} From patchwork Wed May 17 19:14:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=bAZ9bUi7; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2s804B4z20dn for ; Thu, 18 May 2023 05:16:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A2FE388B694 for ; Wed, 17 May 2023 19:16:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A2FE388B694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350986; bh=lDW7m9qT30zUHDJ7STKcuPub1TiTzDZj1uSu9leu8PE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bAZ9bUi7N+oN2R7VNquP3G8lvbxVH8OWmGsRurzyFqL0DzVoJ1Af1U0Ym6pkCCn+l tzIF3v3UhiCIu9obKhk+cnRhGw+0DqRkHEBEo7+YmYPSSQ4gC/3Una/5PyV+eA7cc/ UUjYFmH0ZtTQYp34cJf8qssh967vOLLM/qlpFQb4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 2D48C3856DDF for ; Wed, 17 May 2023 19:14:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D48C3856DDF Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4f383d6f2f8so1431838e87.2 for ; Wed, 17 May 2023 12:14:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350891; x=1686942891; 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=lDW7m9qT30zUHDJ7STKcuPub1TiTzDZj1uSu9leu8PE=; b=J/aGl5/c97gMBxMp641c6erP4cH8Qlj4oT/E69SAT2AV2cZWGgxrW2h356xF+Bltxi vEDypWC818K8vK4LapCjgpdtAq++0mpHkEQhKBW/kvbKxjV4LVX9arVw1kra2//2/99K T5XJGALggx0AvAt0vAVTprzR785zz5q8k5R7e+SQEiMRx7yD39aOM3iJBXRqBBXwjBni diXcKOr8BZtZBm1fqkOzb28saiTMtoNa2hcqg/FXTxDvOhXDi8LZG7HHn1xuBylvY2lr ZwnjvSnApxgSiUlHc2kRWxE/DFWK1d8fcqnNTfw3+C/RyJ+Fn0qLWbSEbZcz9SMQRCZK q2Bw== X-Gm-Message-State: AC+VfDxq8+ePm8KpGNL7eiUF64wO1DwGr3WwzwDpxlgqZ0OqmXa3c26k pP4KkU3WOgJtWO51ycK7oMvZ3rI75zI= X-Google-Smtp-Source: ACHHUZ5MoFgLF8bdigsaFiqKTl4k0n94vnYovclKrTz/G4UQB+MoYTCX4RtVQGF2ylqIL+exlEWz/w== X-Received: by 2002:ac2:4a76:0:b0:4f2:7b64:f16f with SMTP id q22-20020ac24a76000000b004f27b64f16fmr472508lfp.52.1684350891141; Wed, 17 May 2023 12:14:51 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:50 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 09/10] hurd: Also make it possible to call strlen very early Date: Wed, 17 May 2023 22:14:35 +0300 Message-Id: <20230517191436.73636-10-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" strlen, which is another ifunc-selected function, is invoked during early static executable startup if the argv arrives from the exec server. Make it not crash. Checked on x86_64-gnu: statically linked executables launched after the exec server is up now start up successfully. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/static-start.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sysdeps/mach/hurd/x86_64/static-start.S b/sysdeps/mach/hurd/x86_64/static-start.S index cc8e2410..0fed375c 100644 --- a/sysdeps/mach/hurd/x86_64/static-start.S +++ b/sysdeps/mach/hurd/x86_64/static-start.S @@ -22,6 +22,9 @@ _start: leaq __memcpy_sse2_unaligned(%rip), %rax movq %rax, memcpy@GOTPCREL(%rip) + leaq __strlen_sse2(%rip), %rax + movq %rax, strlen@GOTPCREL(%rip) + call _hurd_stack_setup xorq %rdx, %rdx jmp _start1 From patchwork Wed May 17 19:14:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1782937 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Ek/TluZv; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QM2rW2ZlCz20dn for ; Thu, 18 May 2023 05:15:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5EE1A388456D for ; Wed, 17 May 2023 19:15:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EE1A388456D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684350953; bh=wZyJCoTbMYEIs2p02zPf14iGyHOm4h/oVtFbPMe9zeA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Ek/TluZvUpy9xj48Ahg5R05SBILirzmijeMvk/j//TBOgDDvEI0+y88qC6Jdmkm25 QqVr8gDKBvPNTTji0fdHnhhO1nppewI6z5Zde8Nbk9g2EI/gCmQraUdJV9Gpf1bRyJ wddHfWndpShhQBfLwQVsesiRUKkm3C7CFCVfidJM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 9BCA538460A7 for ; Wed, 17 May 2023 19:14:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BCA538460A7 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f13c577e36so1438919e87.1 for ; Wed, 17 May 2023 12:14:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350893; x=1686942893; 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=wZyJCoTbMYEIs2p02zPf14iGyHOm4h/oVtFbPMe9zeA=; b=eh8HIdlsY5mLGOvLMRhVoSxFphv3jkTvTw4Tyu+yBQo986rZm7VyMeqv0zy+uwBOsy VH9N4LQD8wKCKdjSFYyPOJjWp1iZxtOPQ0kx6TcbLPhRHZN3wOWd+IK1KrDMrG3jIpK+ FhnMCl3t/bVRINsbFj+T/7o+wq+X36lR6kmoS8ow+3ylIDp5h+ghKMCEuuPkhJ6+xt2f lt2ntFZJPEh0FC9j5SfP97cttFFF35ibG/JmfaeB1hl7DVkAjEZ1NFL4DiPFXg3niJqu t4yHcnH24oVJJ2642QI5gQivcyf2x/7RLCa5bI36OEfPLGpKEGuhnGPbfjgk8cHnZ8fd Dx4Q== X-Gm-Message-State: AC+VfDzf7LCgS8OUB0UU177Te9Ghai/Xb92adaXtFb4AK62QKwwDm/Jp 02G29xslO0e4HZtBWgvthyYL36iM0J0= X-Google-Smtp-Source: ACHHUZ6knRM6ysihyfDZAfL0zIfDGB6bTktHU9g3Z8BSaXFtkLlkFevSabilQCaPIfA7mdBwMei2CQ== X-Received: by 2002:a05:6512:3906:b0:4e7:dd1e:e521 with SMTP id a6-20020a056512390600b004e7dd1ee521mr442985lfu.9.1684350892817; Wed, 17 May 2023 12:14:52 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id o18-20020ac24352000000b004eed8de597csm3415744lfl.32.2023.05.17.12.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:51 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [RFC PATCH 10/10] hurd: Regenerate errno.h Date: Wed, 17 May 2023 22:14:36 +0300 Message-Id: <20230517191436.73636-11-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517191436.73636-1-bugaevc@gmail.com> References: <20230517191436.73636-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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.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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Sergey Bugaev --- My build keeps insisting that stdc-predef.h should be next to sysdeps and sys/cdefs.h; maybe it's right? If not, how do I stop it from changing? sysdeps/mach/hurd/bits/errno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/mach/hurd/bits/errno.h b/sysdeps/mach/hurd/bits/errno.h index a0794f96..080daebe 100644 --- a/sysdeps/mach/hurd/bits/errno.h +++ b/sysdeps/mach/hurd/bits/errno.h @@ -1,6 +1,5 @@ /* This file generated by errnos.awk from errno.texi - stdc-predef.h libc-symbols.h mach/message.h mach/kern_return.h @@ -12,6 +11,7 @@ features.h features-time64.h ../sysdeps/generic/features-time64.h + stdc-predef.h sys/cdefs.h ../misc/sys/cdefs.h ../sysdeps/x86/bits/wordsize.h