From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 800893858289 for ; Wed, 18 Jan 2023 22:26:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 800893858289 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674080771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wbmnHTrp6H7FoGkcpX7MuZtp+LKO2bO+hxLzO6+BWgw=; b=U1qxt3DwTNO5wCAdFku63MylWkWXJz/xJHhzQ3D3K1Jj4tXvrUJnWyCKu0BTMNydMEMos3 W+uRcZO2HvtCM2ymQR0neLYQw47HLqU0mD0RMMT5txy2j3VoZcVDSp1lfJ8kNouuZ4Nbbj /ejcidGtCnbhazEXn+apzI7sJaHBxlM= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-27-XJTvuz-EMYicfHqk8BhDNw-1; Wed, 18 Jan 2023 17:26:10 -0500 X-MC-Unique: XJTvuz-EMYicfHqk8BhDNw-1 Received: by mail-io1-f71.google.com with SMTP id b21-20020a5d8d95000000b006fa39fbb94eso176073ioj.17 for ; Wed, 18 Jan 2023 14:26:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wbmnHTrp6H7FoGkcpX7MuZtp+LKO2bO+hxLzO6+BWgw=; b=JFAnimYagHbR74sPs/6+tBV3XiZq2ItYTVuNkB74qxsSq2YK7hETuOEqUnQjoX/3KB VOSWrhi/zLoRjFElFo729VFKMH3JHyx12gkTVMzwLrWiHOOhxl5IWQ/gqlEWo+Wa7cpt ukOiT0FlTnuSU9SKVzGy2orG4W4RWteSp/nevJhPLbA6yD5jXWjb045I2Srg7UOa6ikW BntuVB/ck0DQrXxC3f9M56+YE7KXOHtHNDpquCg66AqXL+frsk16M3I7gWH9VOaKz+MU 6EpvTGX4HsHeQ8ttR4DVDULvyW3Lo1ujnN7q+q3abFTvDwcUg6iokbJ7BP9YnDEzd99w 8XGg== X-Gm-Message-State: AFqh2koKCRIMnypxiZbA505QjlL/uWpNwCTLI/VFHtyYRuitJgjtBL+U wJd63LlLsCTvtz1ry7mimzQoXU273zUIFW92MPC+kXLSXlwaC2iEVJArRBClbUlSYeJpIL7sW5r 9S8mU5aUYuCRO9FAkLbLa X-Received: by 2002:a92:cb8c:0:b0:30f:15a6:8857 with SMTP id z12-20020a92cb8c000000b0030f15a68857mr6377759ilo.29.1674080769154; Wed, 18 Jan 2023 14:26:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXtLVdG6LxfNcuLc+8w54u/3MEGjIQQaK5iP0wdVNSyXrbOkMjd/ADq9wG4c+ViosFTNND9WDw== X-Received: by 2002:a92:cb8c:0:b0:30f:15a6:8857 with SMTP id z12-20020a92cb8c000000b0030f15a68857mr6377748ilo.29.1674080768886; Wed, 18 Jan 2023 14:26:08 -0800 (PST) Received: from [192.168.0.241] (192-0-145-146.cpe.teksavvy.com. [192.0.145.146]) by smtp.gmail.com with ESMTPSA id q8-20020a05663810c800b0038a5b48f3d4sm6042462jad.3.2023.01.18.14.26.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jan 2023 14:26:08 -0800 (PST) Message-ID: <8378c9cb-fa18-2ae9-b821-2f082b1f0122@redhat.com> Date: Wed, 18 Jan 2023 17:26:07 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v4 3/6] Linux: Do not align the stack for __clone3 To: Adhemerval Zanella , libc-alpha@sourceware.org References: <20230112135853.3786675-1-adhemerval.zanella@linaro.org> <20230112135853.3786675-4-adhemerval.zanella@linaro.org> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <20230112135853.3786675-4-adhemerval.zanella@linaro.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 1/12/23 08:58, Adhemerval Zanella wrote: > All internal callers of __clone3 should provide an already aligned > stack. Removing the stack alignment in __clone3 is a net gain: it > simplifies the internal function contract (mask/unmask signals) along > with the arch-specific code. > > Checked on x86_64-linux-gnu. OK for 2.28. Reviewed-by: Carlos O'Donell > --- > include/clone_internal.h | 3 + > .../sysv/linux/tst-misalign-clone-internal.c | 74 ------------------- > sysdeps/unix/sysv/linux/x86_64/clone3.S | 3 - > 3 files changed, 3 insertions(+), 77 deletions(-) > delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c > > diff --git a/include/clone_internal.h b/include/clone_internal.h > index 73b8114df4..f8198d8059 100644 > --- a/include/clone_internal.h > +++ b/include/clone_internal.h > @@ -11,6 +11,9 @@ > Different than kernel, the implementation also returns EINVAL for an > invalid NULL __CL_ARGS or __FUNC (similar to __clone). > > + All callers are responsible for correctly aligning the stack. The stack is > + not aligned prior to the syscall (this differs from the exported __clone). > + > This function is only implemented if the ABI defines HAVE_CLONE3_WRAPPER. > */ > extern int __clone3 (struct clone_args *__cl_args, size_t __size, > diff --git a/sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c b/sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c > deleted file mode 100644 > index 8b94a74819..0000000000 > --- a/sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c > +++ /dev/null > @@ -1,74 +0,0 @@ > -/* Verify that __clone_internal properly aligns the child stack. > - Copyright (C) 2021-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 > -#include > -#include > -#include > -#include > -#include > -#include > - > -static int > -check_stack_alignment (void *arg) > -{ > - puts ("in f"); > - > - return TEST_STACK_ALIGN () ? 1 : 0; > -} > - > -static int > -do_test (void) > -{ > - puts ("in do_test"); > - > - if (TEST_STACK_ALIGN ()) > - FAIL_EXIT1 ("stack isn't aligned\n"); > - > -#ifdef __ia64__ > -# define STACK_SIZE (256 * 1024) > -#else > -# define STACK_SIZE (128 * 1024) > -#endif > - char st[STACK_SIZE + 1]; > - /* NB: Align child stack to 1 byte. */ > - char *stack = PTR_ALIGN_UP (&st[0], 2) + 1; > - struct clone_args clone_args = > - { > - .stack = (uintptr_t) stack, > - .stack_size = STACK_SIZE, > - }; > - pid_t p = __clone_internal (&clone_args, check_stack_alignment, 0); > - > - /* Clone must not fail. */ > - TEST_VERIFY_EXIT (p != -1); > - > - int e; > - xwaitpid (p, &e, __WCLONE); > - TEST_VERIFY (WIFEXITED (e)); > - TEST_COMPARE (WEXITSTATUS (e), 0); > - > - return 0; > -} > - > -#include > diff --git a/sysdeps/unix/sysv/linux/x86_64/clone3.S b/sysdeps/unix/sysv/linux/x86_64/clone3.S > index bd4a834e46..802d56cbac 100644 > --- a/sysdeps/unix/sysv/linux/x86_64/clone3.S > +++ b/sysdeps/unix/sysv/linux/x86_64/clone3.S > @@ -73,9 +73,6 @@ L(thread_start): > the outermost frame obviously. */ > xorl %ebp, %ebp > > - /* Align stack to 16 bytes per the x86-64 psABI. */ > - and $-16, %RSP_LP > - > /* Set up arguments for the function call. */ > mov %R8_LP, %RDI_LP /* Argument. */ > call *%rdx /* Call function. */ -- Cheers, Carlos.