From patchwork Thu May 6 18:11:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43278 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 BC2B53AAB497; Thu, 6 May 2021 18:10:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC2B53AAB497 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620324659; bh=TTDCQq0SNcSMnwAhNGL4iEaBrD17zbNoJQXXDv167VE=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mn1Wdybbjy8yAR+aAFibr4UtvW4pC1wnWGCk3S0yQNyeBQppUMMVheJLXETST6L47 cF7KSMv8DE2E4y0smkwy+EquJqfyu4EItKeKxiOUBHQdExyhlakkCZeJxN3KhxKWZY S+IbsuR0zsADccbohGI7JbenNBDd55OFaYMSGLaw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 854583AAB472 for ; Thu, 6 May 2021 18:10:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 854583AAB472 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-525-GDhqrcihPd6UAoCu_wCScA-1; Thu, 06 May 2021 14:10:54 -0400 X-MC-Unique: GDhqrcihPd6UAoCu_wCScA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 821C010B3CBF for ; Thu, 6 May 2021 18:10:42 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-137.ams2.redhat.com [10.36.112.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7CF610016F4 for ; Thu, 6 May 2021 18:10:41 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 09/13] nptl: Simplify the change_stack_perm calling convention In-Reply-To: References: Message-Id: Date: Thu, 06 May 2021 20:11:00 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Only ia64 needs the page mask, and it is straightforward to compute the value within the function itself. Tested-by: Carlos O'Donell Reviewed-by: Carlos O'Donell --- nptl/allocatestack.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 71cfa874d1..46089163f4 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -293,13 +293,10 @@ queue_stack (struct pthread *stack) static int -change_stack_perm (struct pthread *pd -#ifdef NEED_SEPARATE_REGISTER_STACK - , size_t pagemask -#endif - ) +change_stack_perm (struct pthread *pd) { #ifdef NEED_SEPARATE_REGISTER_STACK + size_t pagemask = __getpagesize () - 1; void *stack = (pd->stackblock + (((((pd->stackblock_size - pd->guardsize) / 2) & pagemask) + pd->guardsize) & pagemask)); @@ -628,11 +625,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, if (__builtin_expect ((GL(dl_stack_flags) & PF_X) != 0 && (prot & PROT_EXEC) == 0, 0)) { - int err = change_stack_perm (pd -#ifdef NEED_SEPARATE_REGISTER_STACK - , ~pagesize_m1 -#endif - ); + int err = change_stack_perm (pd); if (err != 0) { /* Free the stack memory we just allocated. */ @@ -796,20 +789,12 @@ __make_stacks_executable (void **stack_endp) if (err != 0) return err; -#ifdef NEED_SEPARATE_REGISTER_STACK - const size_t pagemask = ~(__getpagesize () - 1); -#endif - lll_lock (GL (dl_stack_cache_lock), LLL_PRIVATE); list_t *runp; list_for_each (runp, &GL (dl_stack_used)) { - err = change_stack_perm (list_entry (runp, struct pthread, list) -#ifdef NEED_SEPARATE_REGISTER_STACK - , pagemask -#endif - ); + err = change_stack_perm (list_entry (runp, struct pthread, list)); if (err != 0) break; } @@ -820,11 +805,7 @@ __make_stacks_executable (void **stack_endp) if (err == 0) list_for_each (runp, &GL (dl_stack_cache)) { - err = change_stack_perm (list_entry (runp, struct pthread, list) -#ifdef NEED_SEPARATE_REGISTER_STACK - , pagemask -#endif - ); + err = change_stack_perm (list_entry (runp, struct pthread, list)); if (err != 0) break; }