From patchwork Mon Sep 13 01:41:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 44929 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 543B13857C69 for ; Mon, 13 Sep 2021 01:42:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id A80913858429 for ; Mon, 13 Sep 2021 01:41:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A80913858429 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-x62d.google.com with SMTP id bb10so4778972plb.2 for ; Sun, 12 Sep 2021 18:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pLngZIKldCHq+lE8H3U99KHnGQ2Uv/zXuilixLPNQj8=; b=EiFsX+tLyRIWU309PKUIr2JPZRklhh4TmjQbezrRwocgo0oCF08HYRStU+JLZ0Nmko qWw+NA7Kt2dl7CpoV+j7ZOKEsNHSXoLCW0XKd7/F7bj80Vx32CKMDwFGnMXwHYPMmeYE bDlX/P38Cou0RFun94v+W9GkpAKBivu3NrfIKqc7fZd+j1jP3kIaY9Gv3SU1DNBBupI5 6VD/Xq9vuiHJDSNkb7sUszLs4zeIJmHb4p/t5R9AGeafhk9QlP9D+jEPP7C8PZKotHBp wIWjPZ0rTevIFkqH8ZiQVxqFH7jtG66gZtaU1zvV7vmisVJDBF+HCy0uLRguFDUy6usm Zrww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pLngZIKldCHq+lE8H3U99KHnGQ2Uv/zXuilixLPNQj8=; b=iHwlKRq+foGsflri/w/kJvRqxEC/ciAEX48VWr050VlJLBVz/aOx0tKQYKAfKyXRy/ GueuaVzH8fURUsLcyEeKnaEzeZQWVXLRGQ+1Lgw9E55tdjc5HuVi4p9vBpC7jfI1vI+0 pIZf/6FTa5efaJ+yKEvNtqasdR2Ida+VUq4Jw9hp58bNHli7a+t6IN2yeRkyERP56uXY FZkv6K3BbW6lyGqsu6Aqj8C0XAxfOFTpMkN7h6Q3SbHcxEHbW87+ET54DgOUgmrrm7IR veqzNvybnYjLF1K3mR8TEvvB/S/17LTU+umfypmaFo2un0RhASrW+JRdcZaWotMVTQoz Z8zw== X-Gm-Message-State: AOAM532+/7NY9B7Yo21JJUbeYbzU0sZSFNpawTSqcqtjp0JZDtbSX4uU /GmofuISarr5DRSRMHCk96vFAXi5mJ/4XA== X-Google-Smtp-Source: ABdhPJz0F0rHvQ5I0LfYmyFZAXgRC5Z4inU5lBo8HZtbeba3m3y1IX3hTzcuxK5FJRWCBgPyMdEIvg== X-Received: by 2002:a17:902:9692:b0:13a:2554:9646 with SMTP id n18-20020a170902969200b0013a25549646mr8354917plp.9.1631497295497; Sun, 12 Sep 2021 18:41:35 -0700 (PDT) Received: from localhost.localdomain (36-227-141-62.dynamic-ip.hinet.net. [36.227.141.62]) by smtp.gmail.com with ESMTPSA id i10sm5052173pfk.87.2021.09.12.18.41.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Sep 2021 18:41:35 -0700 (PDT) From: Vincent Chen To: libc-alpha@sourceware.org, palmer@dabbelt.com Subject: [RFC patch 1/5] RISC-V: Remove riscv-specific sigcontext.h Date: Mon, 13 Sep 2021 09:41:14 +0800 Message-Id: <1631497278-29829-2-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> References: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: andrew@sifive.com, Vincent Chen Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Remove riscv-specific sigcontext.h so that Glibc can directly use sigcontext.h provided by the kernel to reduce synchronization work when new extension support is introduced. --- sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h | 31 ------------------------- 1 file changed, 31 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h diff --git a/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h b/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h deleted file mode 100644 index 14e4e06..0000000 --- a/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Machine-dependent signal context structure for Linux. RISC-V version. - Copyright (C) 1996-2021 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 _BITS_SIGCONTEXT_H -#define _BITS_SIGCONTEXT_H 1 - -#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H -# error "Never use directly; include instead." -#endif - -struct sigcontext { - /* gregs[0] holds the program counter. */ - unsigned long int gregs[32]; - unsigned long long int fpregs[66] __attribute__ ((__aligned__ (16))); -}; - -#endif From patchwork Mon Sep 13 01:41:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 44930 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 D44E13857C69 for ; Mon, 13 Sep 2021 01:42:58 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id AE5613857C71 for ; Mon, 13 Sep 2021 01:41:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AE5613857C71 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pj1-x1029.google.com with SMTP id j10-20020a17090a94ca00b00181f17b7ef7so5435504pjw.2 for ; Sun, 12 Sep 2021 18:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nSQmwROcv/oeUnyd63OKOvZHXHfyP4pGcCHwesyDjvY=; b=BCY5519jqoB6POQ1qZzDrh4ikOXj1hk3l1+xRSI5BmJgZNf0aBxNjP4dO54a2SdM4Q 6HMtew/+uF9odzWAw5JiymtUMBSYN3T3lgxDfR/PrVce1g9Ued8P9v+mKxWzCPLT1FMM RczbFeD4Tvha/Cj4/Bt56PKI5PkkXrDO9kDjsd2dXfh18CHOdFE7bqRAuGRsdOp8hZdm 2V+WNQRaHTBL0FcAaznIW0cQsyJVfO41MIqiBQ85Af615yTeZm8F073P7b8fisjy6key G/30kIbzNLo9ESuySS+ayuKUesvStValzI5s6FHjrqZdbm8Gj6rAMsYsM4ivveqmcUQD MSEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nSQmwROcv/oeUnyd63OKOvZHXHfyP4pGcCHwesyDjvY=; b=KRUrQFYBYf4qcWqwO4AE3p6rGFJAqt7SdDJNgBagh7u2o8/anVr+irxzL9qQnk8lYz 3/rtqD3GJcmSe90lyDM+5VuRDLDUfXlftetJlaEeVH4RElbZhC7lMwimHnCvfEjwthsb ZQfeJauvYkaeL4l71TYFusi80hdUUTL97fXv+pBkkLpyFbo4FyAbbBSecH4udt1ydRcq 0DqZu4pGUvQJgrfq7G8dyVDsWhCj0aGNqjmcwXtHRoQjvNiOAUzXlVqPZWBE9N0TFp9r h4XNe7iDDE1EibELsSZ7Bzb8ntILO3RnjfMz6rR/1TtlgCYnn1jwU6tbbrvDbvHP+ZF6 zl4Q== X-Gm-Message-State: AOAM531foPy1pMuCyYVsyIABVdEBuH7KoHRNNSgVKsHpHA060RjqxNUX UnLmL05k2OtSdkHZB6kQ4VerLUiqyMUlhw== X-Google-Smtp-Source: ABdhPJwOFLOKx21miJW7xihJqSWSh4s8OdSBGbPb+yZGhp6PwwZbj9CyzLA+164rQbqkIL0o+k4+Qg== X-Received: by 2002:a17:90a:fc8e:: with SMTP id ci14mr10126719pjb.12.1631497298669; Sun, 12 Sep 2021 18:41:38 -0700 (PDT) Received: from localhost.localdomain (36-227-141-62.dynamic-ip.hinet.net. [36.227.141.62]) by smtp.gmail.com with ESMTPSA id i10sm5052173pfk.87.2021.09.12.18.41.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Sep 2021 18:41:38 -0700 (PDT) From: Vincent Chen To: libc-alpha@sourceware.org, palmer@dabbelt.com Subject: [RFC patch 2/5] RISC-V: Reserve about 5K space in mcontext_t to support future ISA expansion. Date: Mon, 13 Sep 2021 09:41:15 +0800 Message-Id: <1631497278-29829-3-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> References: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: andrew@sifive.com, Vincent Chen Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Following the changes of struct sigcontext in Linux to reserve about 5K space to support future ISA expansion. --- sysdeps/unix/sysv/linux/riscv/sys/ucontext.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h index cfafa44..80caf07 100644 --- a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h +++ b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h @@ -82,6 +82,8 @@ typedef struct mcontext_t { __riscv_mc_gp_state __gregs; union __riscv_mc_fp_state __fpregs; + /* 5K + 256 reserved for vector state and future expansion. */ + unsigned char __reserved[5376] __attribute__ ((__aligned__ (16))); } mcontext_t; /* Userlevel context. */ From patchwork Mon Sep 13 01:41:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 44931 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 923973858429 for ; Mon, 13 Sep 2021 01:43:25 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 0EB943857C76 for ; Mon, 13 Sep 2021 01:41:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0EB943857C76 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-x431.google.com with SMTP id j16so7355112pfc.2 for ; Sun, 12 Sep 2021 18:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t2WrEjYWz9ib+JYKbyF1O9NW4OZkmT437+KMSkBchIE=; b=aAg83HE1FeqQKQ0zKihzxuoYjrX0dgNMvesjgD0KwQ9aqkoK9trodP2y36I/rMzMdr /KN0+7R5YHFYsSd7AniCKDwcD3nIbDaUqGtA+Fo2RTvzailuMulb2yEhNN2KvGxzE0E2 ygGM7TWgKTQXD49hF1AJV3NhZauQIHXJvIO9ZD/xGWp3VcaTjImxADBzZCysaMzemOHT y/PMGTC03Q2oAtkVr0uXvAdcPoHy50DEJnh6t81f//YfjcZ7ZJCavu0R8DJrnV44NdPO UP7sQpcOnTtNxUxHnu3ArLIJVn1eAekrpuX00DiOci9jn0cx+ilOlFgWHtSql7dcSj3T nKZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t2WrEjYWz9ib+JYKbyF1O9NW4OZkmT437+KMSkBchIE=; b=rRSbz/5PsHx1oCvolDlsUmQKIzHfoHnrhVkVKZMPseg3MyKlNXSrrVdzLJ4euJki8B E63i7hq82/FFfCCWM7PDAeIqTqjL0FwQzg2rCRJ3Y17rTZfCJQn1rh5QXYnpn5m4x9W3 OrrTGkxyoj1m7JhUh5F9a/AGNdIYYgZEzy5bhQpOleyjNKzQBeWjXChO/Eg0Cf2I0WUN qvdDNcvT4h2YP9vzMVtRQdDaK0G6B1qWxxAMVI0+STjwxL2BufhnDgMHe/nvwxolKKVQ zzOEzs0ItaJIJxXTvhiff/AXkm3xcnJYjICcPz41dcccwh/6/4uahOjrSoKXCzkHGHLB Qp5g== X-Gm-Message-State: AOAM5334aaAjBXiyd4zV4Ar+++PmIhuwyx9LBeLMqgE3hVbFP343HEuG A64Iyh7GydUql+U3fG1oXi63E6f8ncAExg== X-Google-Smtp-Source: ABdhPJwPDo7CvdpylE8ybNS4Kt0JAiTv3doeujX4KDmOG62P6LsKoESPgJTggObtmClN3CiSiU6q9g== X-Received: by 2002:a65:5086:: with SMTP id r6mr8878261pgp.65.1631497300905; Sun, 12 Sep 2021 18:41:40 -0700 (PDT) Received: from localhost.localdomain (36-227-141-62.dynamic-ip.hinet.net. [36.227.141.62]) by smtp.gmail.com with ESMTPSA id i10sm5052173pfk.87.2021.09.12.18.41.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Sep 2021 18:41:40 -0700 (PDT) From: Vincent Chen To: libc-alpha@sourceware.org, palmer@dabbelt.com Subject: [RFC patch 3/5] RISC-V: Save and restore VCSR when doing user context switch Date: Mon, 13 Sep 2021 09:41:16 +0800 Message-Id: <1631497278-29829-4-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> References: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: andrew@sifive.com, Vincent Chen Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" According to the RISC-V V extension specification, all vector registers except VCSR are caller-saved registers. The VCSR (vxrm + vxsat) has thread storage duration. Therefore, only VCSR needs to be added to the user context operation. --- sysdeps/riscv/Makefile | 5 ++++ sysdeps/riscv/rtld-global-offsets.sym | 7 +++++ sysdeps/unix/sysv/linux/riscv/bits/hwcap.h | 31 +++++++++++++++++++++ sysdeps/unix/sysv/linux/riscv/getcontext.S | 22 ++++++++++++++- sysdeps/unix/sysv/linux/riscv/setcontext.S | 22 +++++++++++++++ sysdeps/unix/sysv/linux/riscv/swapcontext.S | 41 ++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 + sysdeps/unix/sysv/linux/riscv/ucontext_i.sym | 6 ++++ 8 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 sysdeps/riscv/rtld-global-offsets.sym create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/hwcap.h diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile index 20a9968..cda3ded 100644 --- a/sysdeps/riscv/Makefile +++ b/sysdeps/riscv/Makefile @@ -2,6 +2,11 @@ ifeq ($(subdir),misc) sysdep_headers += sys/asm.h endif +ifeq ($(subdir),csu) +# get offset to rtld_global._dl_hwcap and rtld_global._dl_hwcap2. +gen-as-const-headers += rtld-global-offsets.sym +endif + # RISC-V's assembler also needs to know about PIC as it changes the definition # of some assembler macros. ASFLAGS-.os += $(pic-ccflag) diff --git a/sysdeps/riscv/rtld-global-offsets.sym b/sysdeps/riscv/rtld-global-offsets.sym new file mode 100644 index 0000000..ff4e97f --- /dev/null +++ b/sysdeps/riscv/rtld-global-offsets.sym @@ -0,0 +1,7 @@ +#define SHARED 1 + +#include + +#define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem) + +RTLD_GLOBAL_RO_DL_HWCAP_OFFSET rtld_global_ro_offsetof (_dl_hwcap) diff --git a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h new file mode 100644 index 0000000..e6c5ef5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h @@ -0,0 +1,31 @@ +/* Defines for bits in AT_HWCAP. RISC-V Linux version. + Copyright (C) 2021 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 + . */ + +#if !defined (_SYS_AUXV_H) && !defined (_LINUX_RISCV_SYSDEP_H) +# error "Never include directly; use instead." +#endif + +/* The following must match the kernel's . */ +#define HWCAP_ISA_I 0x100 //(1 << ('I' - 'A')) +#define HWCAP_ISA_M 0x1000 //(1 << ('M' - 'A')) +#define HWCAP_ISA_A 0x1 //(1 << ('A' - 'A')) +#define HWCAP_ISA_F 0x20 //(1 << ('F' - 'A')) +#define HWCAP_ISA_D 0x8 //(1 << ('D' - 'A')) +#define HWCAP_ISA_C 0x4 //(1 << ('C' - 'A')) +#define HWCAP_ISA_V 0x200000 //(1 << ('V' - 'A')) + diff --git a/sysdeps/unix/sysv/linux/riscv/getcontext.S b/sysdeps/unix/sysv/linux/riscv/getcontext.S index d6a9bbc..840d8fe 100644 --- a/sysdeps/unix/sysv/linux/riscv/getcontext.S +++ b/sysdeps/unix/sysv/linux/riscv/getcontext.S @@ -16,6 +16,8 @@ License along with the GNU C Library. If not, see . */ +#include +#include #include "ucontext-macros.h" /* int getcontext (ucontext_t *ucp) */ @@ -39,6 +41,25 @@ LEAF (__getcontext) SAVE_INT_REG (s10, 26, a0) SAVE_INT_REG (s11, 27, a0) +#ifdef __riscv_vector +# ifdef SHARED + la t1, _rtld_global_ro + REG_L t1, RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(t1) +# else + la t1, _dl_hwcap + REG_L t1, (t1) +# endif + li t2, HWCAP_ISA_V + and t2, t1, t2 + beqz t2, 1f + addi t2, a0, MCONTEXT_EXTENSION + li t1, RVV_MAGIC + sw t1, (t2) + csrr t1, vcsr + REG_S t1, VCSR_OFFSET(t2) +1: +#endif + #ifndef __riscv_float_abi_soft frsr a1 @@ -73,5 +94,4 @@ LEAF (__getcontext) 99: j __syscall_error PSEUDO_END (__getcontext) - weak_alias (__getcontext, getcontext) diff --git a/sysdeps/unix/sysv/linux/riscv/setcontext.S b/sysdeps/unix/sysv/linux/riscv/setcontext.S index 9510518..d2404fb 100644 --- a/sysdeps/unix/sysv/linux/riscv/setcontext.S +++ b/sysdeps/unix/sysv/linux/riscv/setcontext.S @@ -16,6 +16,8 @@ License along with the GNU C Library. If not, see . */ +#include +#include #include "ucontext-macros.h" /* int __setcontext (const ucontext_t *ucp) @@ -64,6 +66,26 @@ LEAF (__setcontext) fssr t1 #endif /* __riscv_float_abi_soft */ +#ifdef __riscv_vector +#ifdef SHARED + la t1, _rtld_global_ro + REG_L t1, RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(t1) +#else + la t1, _dl_hwcap + REG_L t1, (t1) +#endif + li t2, HWCAP_ISA_V + and t2, t1, t2 + beqz t2, 1f + li t1, RVV_MAGIC + addi t2, t0, MCONTEXT_EXTENSION + lw a1, (t2) + bne a1, t1, 1f + REG_L t1, VCSR_OFFSET(t2) + csrw vcsr, t1 +1: +#endif + /* Note the contents of argument registers will be random unless makecontext() has been called. */ RESTORE_INT_REG (t1, 0, t0) diff --git a/sysdeps/unix/sysv/linux/riscv/swapcontext.S b/sysdeps/unix/sysv/linux/riscv/swapcontext.S index df0f699..94ae8e4 100644 --- a/sysdeps/unix/sysv/linux/riscv/swapcontext.S +++ b/sysdeps/unix/sysv/linux/riscv/swapcontext.S @@ -16,6 +16,8 @@ License along with the GNU C Library. If not, see . */ +#include +#include #include "ucontext-macros.h" /* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */ @@ -40,6 +42,25 @@ LEAF (__swapcontext) SAVE_INT_REG (s10, 26, a0) SAVE_INT_REG (s11, 27, a0) +#ifdef __riscv_vector +#ifdef SHARED + la t1, _rtld_global_ro + REG_L t1, RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(t1) +#else + la t1, _dl_hwcap + REG_L t1, (t1) +#endif + li t2, HWCAP_ISA_V + and t2, t1, t2 + beqz t2, 1f + addi t2, a0, MCONTEXT_EXTENSION + li t1, RVV_MAGIC + sw t1, (t2) + csrr t1, vcsr + REG_S t1, VCSR_OFFSET(t2) +1: +#endif + #ifndef __riscv_float_abi_soft frsr a1 @@ -89,6 +110,26 @@ LEAF (__swapcontext) fssr t1 #endif /* __riscv_float_abi_soft */ +#ifdef __riscv_vector +#ifdef SHARED + la t1, _rtld_global_ro + REG_L t1, RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(t1) +#else + la t1, _dl_hwcap + REG_L t1, (t1) +#endif + li t2, HWCAP_ISA_V + and t2, t1, t2 + beqz t2, 1f + li t1, RVV_MAGIC + addi t2, t0, MCONTEXT_EXTENSION + lw a1, (t2) + bne a1, t1, 1f + REG_L t1, VCSR_OFFSET(t2) + csrw vcsr, t1 +1: +#endif + /* Note the contents of argument registers will be random unless makecontext() has been called. */ RESTORE_INT_REG (t1, 0, t0) diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h index 37ff07a..c9f8fd8 100644 --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h @@ -50,6 +50,7 @@ #ifdef __ASSEMBLER__ +# include # include # define ENTRY(name) LEAF(name) diff --git a/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym b/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym index be55b26..4037473 100644 --- a/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym +++ b/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym @@ -2,6 +2,7 @@ #include #include #include +#include -- Constants used by the rt_sigprocmask call. @@ -27,5 +28,10 @@ STACK_FLAGS stack (ss_flags) MCONTEXT_GREGS mcontext (__gregs) MCONTEXT_FPREGS mcontext (__fpregs) +MCONTEXT_EXTENSION mcontext (__reserved) UCONTEXT_SIZE sizeof (ucontext_t) + +VCSR_OFFSET offsetof (struct __riscv_v_state, vcsr) + +RVV_MAGIC From patchwork Mon Sep 13 01:41:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 44932 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 5A6BA3858034 for ; Mon, 13 Sep 2021 01:43:48 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 38F433857C7E for ; Mon, 13 Sep 2021 01:41:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 38F433857C7E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-x62a.google.com with SMTP id d17so4763281plr.12 for ; Sun, 12 Sep 2021 18:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H4V4pCGgigVbif7j1GPDfO5UHx8Ok1qmfBYd1ZgFyaM=; b=cHj1sSV6ERq+0hGmGfEpRyc1fiRFC+bfugaG0xhlAq0kIoBjrqZsZHBpEDHDaAx4JA VAASzKi3J8DwMS/D/vhHT8/4Sz4ksuM5Y7H5t+7Wk2z5kHnKKGwpHOg7g7gvJHoyglM2 XpMfzZh/mIVDMUBIRcoRmFBuZQHiDIQaVhPGTqCv5UzP+bzrtf+i/6iq6qTj8BQ0VPjH XeE3sibaUiXHDx2cMoFF4CcnAUID5l/Ogg8FqkaEc7lteYJZWMAMXJlEqonCvPTb+/W2 D0olaYSrxCEFFXavDsv7AZ4/kRDtuRq+CDhYto4DVqQJoAQKMMoVLvaF48vn6uwuVdDr khCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H4V4pCGgigVbif7j1GPDfO5UHx8Ok1qmfBYd1ZgFyaM=; b=QTrXVkPr1WEIQslGcmgNPejNpJ1OahPnR4fgJOKAu/aqHNP3loB8/2FLIXr6yvZ69c RthnN2LYsPOqEsQU4n5v0gD9c46YColLiTuQZlbSGCXH34zkErLC6WAiAdq9sL7WiYPQ cLrCjooH87UIIBGewMoS+Cdyhjh/yJarfu3iGEPEjheQj1lsaENWFuzb4hc9Uv3u++oL 2OhEWZnp1rDYLtXPWUitotYefCcoMNsz3TWcZsZJgAG7Lnhq0DjUQbcVu4PI5ZsctUK0 4EGtUZq3ReHn7zXttpvo+fFL2zq+dAkcEhwV54eOU7+MKYPfMXwu49i8iJB13eg+ivqR hbaA== X-Gm-Message-State: AOAM5328emygNNGEA1PSL2wLjrjl7hYjDemwPBXDn55mOSgo4zPV0cNE EJSILgEKuuMEzV/a43QqjRioobjIM4ghfA== X-Google-Smtp-Source: ABdhPJxnR8t69xU/JkzUb0qoQgyJVNiR0VsOUBv5ialeW0it3CxyFVa6iTioJrR1qgYLoyRDot91Tg== X-Received: by 2002:a17:90b:1c0f:: with SMTP id oc15mr8138756pjb.1.1631497304133; Sun, 12 Sep 2021 18:41:44 -0700 (PDT) Received: from localhost.localdomain (36-227-141-62.dynamic-ip.hinet.net. [36.227.141.62]) by smtp.gmail.com with ESMTPSA id i10sm5052173pfk.87.2021.09.12.18.41.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Sep 2021 18:41:43 -0700 (PDT) From: Vincent Chen To: libc-alpha@sourceware.org, palmer@dabbelt.com Subject: [RFC patch 4/5] RISC-V: Extend MINSIGSTKSZ and SIGSTKSZ to backup RVV registers Date: Mon, 13 Sep 2021 09:41:17 +0800 Message-Id: <1631497278-29829-5-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> References: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: andrew@sifive.com, Vincent Chen Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" As using RVV extension, the original MINSIGSTKSZ is not enough to back up all RVV registers for the normal case. Therefore, the MINSIGSTKSZ is expanded to about 5K and the SIGSTKSZ is expanded to about 16K. This space is enough for the case that the VLENB of a vector register is 128 bytes. For the case that VLENB > 128 bytes, users can use sysconf (_SC_MINSIGSTKSZ) and sysconf (_SC_SIGSTKSZ) to get the appropriate signal stack size. --- sysdeps/unix/sysv/linux/riscv/bits/sigstack.h | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/sigstack.h diff --git a/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h new file mode 100644 index 0000000..c18512f --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h @@ -0,0 +1,32 @@ +/* sigstack, sigaltstack definitions. + Copyright (C) 2021 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 _BITS_SIGSTACK_H +#define _BITS_SIGSTACK_H 1 + +#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H +# error "Never include this file directly. Use instead" +#endif + +/* Minimum stack size (5k+256 bytes) for a signal handler. */ +#define MINSIGSTKSZ 5376 + +/* System default stack size. */ +#define SIGSTKSZ 16384 + +#endif /* bits/sigstack.h */ From patchwork Mon Sep 13 01:41:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 44933 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 33F643857C6C for ; Mon, 13 Sep 2021 01:44:10 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id 1B5DD3857C78 for ; Mon, 13 Sep 2021 01:41:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B5DD3857C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pj1-x102d.google.com with SMTP id u13-20020a17090abb0db0290177e1d9b3f7so5442894pjr.1 for ; Sun, 12 Sep 2021 18:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HT0CAfZOacZqLmo5v6zuqKRZ58RHSCIarASqR3U5c/g=; b=GwxzxuF9qQQqJGkb6Tmy24+ef75JmClEvS0FK6KHe2U075860vYk1Rll1D2N6m7tbV sDlTBSdUg5BSDsEnBTNw9j76R0cy2oC/bIcSt+UQJBOIDdrQVbLwY3nMTpVrP1iHGsgP EBI7O7sIsF3CRZUSQ+BzjZRxHZjs6g0VQmRkclC0Xq5RgmyHZZkyYNP9poPlvHLxo3dT oZaGHttoPzgDPwqNt8xBeNJ2xCuPS5qrsYNdLOYZzZ5K1l/tzQF842TIdLFn+HNAQGbI TbyO06r/+wv8qeww1NL8Q7iL+3gtv9pQU0HeBtqXx1fymXen6bcmhJqLqfmzQQXI4XHL /9Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HT0CAfZOacZqLmo5v6zuqKRZ58RHSCIarASqR3U5c/g=; b=wS86C5dpgnqP2DdfLwCof6X5EI6sRc33OjKILGk5CUfC8BJiXb6Kfr4Ixcc1lIW7Fg pFZtw9KoWClXo1h/Trjy1WSZYLmCVIN9wwTxY0V/cuP8MrabT7emJM98bYj8Z+kR5WF4 F6onQftyJHMrm815nSLTMURl+NblvqVgCBPZy/nJpmw9wbi5YF1/vWdNBZ57ilOTYA4C TjizsP+F8BJz175bdqvaymiZAhrNGFjEx9oEotu737MJWlkrkR+Qy0JDtO4JuqWExn0S ljI6SJUFTP8h+j0Nrwj6tfzvDjX5ug/LeRxT60bomKEy7K0Rf7RwBIaKC8MdY0oM+aBU SnVQ== X-Gm-Message-State: AOAM532PRP4+lKSbqnxrNYrgkQrSX4Szo8mCS6vUULIShiigUhGVcViu iUlhUsm/KR9cfGQErmcWjzqGtuASRJ2xIA== X-Google-Smtp-Source: ABdhPJzacwRKtFb+hJHQ/goOLpBfq9lgeKg4RyTezVR/6g/NvsrpLr1gQ97GxgIGh/HUlMxn4MB+gQ== X-Received: by 2002:a17:90a:c485:: with SMTP id j5mr10184059pjt.109.1631497306972; Sun, 12 Sep 2021 18:41:46 -0700 (PDT) Received: from localhost.localdomain (36-227-141-62.dynamic-ip.hinet.net. [36.227.141.62]) by smtp.gmail.com with ESMTPSA id i10sm5052173pfk.87.2021.09.12.18.41.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Sep 2021 18:41:46 -0700 (PDT) From: Vincent Chen To: libc-alpha@sourceware.org, palmer@dabbelt.com Subject: [RFC 5/5] RISC-V: Expand PTHREAD_STACK_MIN to support RVV environment Date: Mon, 13 Sep 2021 09:41:18 +0800 Message-Id: <1631497278-29829-6-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> References: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: andrew@sifive.com, Vincent Chen Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" In order to support all pthread operations in the RVV environment, here PTHREAD_STACK_MIN is set to 4 times GLRO(dl_minsigstacksize), and the default PTHREAD_STACK_MIN is expanded to 20K bytes. --- .../unix/sysv/linux/riscv/bits/pthread_stack_min.h | 21 ++++++++++++ .../sysv/linux/riscv/sysconf-pthread_stack_min.h | 39 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h create mode 100644 sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h diff --git a/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h new file mode 100644 index 0000000..83585b3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h @@ -0,0 +1,21 @@ +/* Definition of PTHREAD_STACK_MIN. Linux/riscv version. + Copyright (C) 2021 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 + . */ + +/* Minimum size for a thread. We are free to choose a reasonable value. */ +#define PTHREAD_STACK_MIN 20480 diff --git a/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h new file mode 100644 index 0000000..53ba6a1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h @@ -0,0 +1,39 @@ +/* __get_pthread_stack_min (). Linux version. + Copyright (C) 2021 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 + . */ + +/* Return sysconf (_SC_THREAD_STACK_MIN). */ + +static inline long int +__get_pthread_stack_min (void) +{ + /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */ + long int pthread_stack_min = GLRO(dl_minsigstacksize) * 4; + assert (pthread_stack_min != 0); + _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN), + "PTHREAD_STACK_MIN is constant"); + /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */ + if (pthread_stack_min < PTHREAD_STACK_MIN) + pthread_stack_min = PTHREAD_STACK_MIN; + /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE + which returns a larger size that includes the required TLS variable + space which has been determined at startup. For sysconf here we are + conservative and don't include the space required for TLS access. + Eventually the TLS variable space will not be part of the stack + (Bug 11787). */ + return pthread_stack_min; +}