From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150048.outbound.protection.outlook.com [40.107.15.48]) by sourceware.org (Postfix) with ESMTPS id 2046B385841E for ; Thu, 3 Nov 2022 16:31:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2046B385841E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Oj5EF4smUZhlvOBzgCGummzzm+5ZCJLJgxvbVIWrgSqW0mreLZlaAylzN6VI3AWXCksrrCYJN9JZ6kGz2Dxry/3W/tuGl39CsCyjU1J2dgn+OFb8wV6FJBgOpMTNHc7ln39P/F6Jx2pe947fqQ/zY1nlZ80poFoBXeol4yCqXA1Y2Vo+HTUnXOwkvvpJuFR97YE9iOQbl2nJepCvyAiNjej2U0I81jpTGG+RwbI9UYQKGPpUCa9+T/tJ4tiYCShSbFsuGKpTXdfozC4oJuHsRtvJ9AGxXNz49ao6XDMf4RcI7Tn2FOKXyeyqvF0jq09+8lVPhtvd7V0kN3eGKS2vOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J5SqGZ3WzeCKkKpHRU+pV4MrI0OGxjA9X1at90FfgQ8=; b=KZVzPu0mkyfhVBNqDKPxZBo/ffGxYW7areJ24Z8H0lgGUIUFP3N1jSHPlliJctZgpRGEERnzJQrQuDfohiUGeqhmls4TxG9qNOzPbrVQuHM5fmTAfNW4ah015Jcvju6FbygehsbfUIMdyQbsTh38PbVop6Ouu4n5EJz/sMicqC2QQKkXkIkMtcx3ieAF0US7wYKosT2n3VaAmBGUMmL9Y2T9Hvl63evmEamwQhTK3VFzSAtHJnoKhZCWKqvrQRlw0S5sz+jltQShfL+DI7TfuAWxIk9io0VTdGV4PVMVwFnWYEA1itbsWblBfU1Cshsmhhw6LnwBdAzFRIsPisdDxg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J5SqGZ3WzeCKkKpHRU+pV4MrI0OGxjA9X1at90FfgQ8=; b=UmylAVJyU0NlDKja+rr5+aWGSWmKVorcoKmzbbDSUpPX+/nQjkOfF9u/1QhdP4bpJWMWAbRtkL/S8s1duTpD6l71inFDP12tFGnN+e0oGPi/TjrVrKP/yahws2dsVGqZkk8Tes2ck5+JIl1RM2UvO0XDx6rTaasUJJj2FT9ERfk= Received: from AM6P193CA0097.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::38) by PAWPR08MB9472.eurprd08.prod.outlook.com (2603:10a6:102:2e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Thu, 3 Nov 2022 16:31:25 +0000 Received: from AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::ab) by AM6P193CA0097.outlook.office365.com (2603:10a6:209:88::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22 via Frontend Transport; Thu, 3 Nov 2022 16:31:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT058.mail.protection.outlook.com (100.127.140.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 16:31:25 +0000 Received: ("Tessian outbound 0800d254cb3b:v130"); Thu, 03 Nov 2022 16:31:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4c1f967b64d62d8c X-CR-MTA-TID: 64aa7808 Received: from 8f8e50c675d1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BAE9B94B-57CE-45D4-BBA6-BE3F54B900FD.1; Thu, 03 Nov 2022 16:31:19 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8f8e50c675d1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Nov 2022 16:31:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cNH8rfGphFsGNpDmli/Z1xc9ei6cA6VC3NpIDvl3UKdzmWmNr8urAxpoaNb2WbXQg15fKZBIxzaIZVPnkhoN2sBUeZ3qzfGIynzUixk7dChjDqkHJUsWVZlGxnMvWgntCoRDXm5U8bKoMJdvhKvH33DMPbrHrFcG1YIXCZNLzne5nN3hnK2vH0S5WsOxHy+S8+eo0qdP6ofuik7bj69uPZ5MB9hn63E+pdSTK5QupIXyEG2vLJHXD/Z93YN2d/5q/xCzs7O47AejJNFxtxCk/T4gS80zXk0CDj8C09QvdTJiAOJriuPrHwAvEpuqnWCaz3BegDf71Htv1ElSErykLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J5SqGZ3WzeCKkKpHRU+pV4MrI0OGxjA9X1at90FfgQ8=; b=M/0Cv+bASMFh4qh91JiH8HKTnRVolg59J8/+zbXDb3XKsUyshAJJR43o9Mm3UXw/Oj9jxpXDfHKpmrSNXbsbkwJSL1PjgTLZS1AkQur5smsr+x9XT9nw93lluyDfq6rqtrwPzIf9Yk5I0dKES39BSjrVanlAtPzzgLgNhKThbYOs90wUL0o6a2KNveVfGO7zzNcYJS12jekTNmwW6FBKx+as7UYeG4of2GuFANo1QuDrmSZTi/w3aziqK+3bG/OusJgQlGurXOzz1StRg67NTrBamLVo8JhEABGMn5VVCHXmXNwHhcgotNiQEHwpbNPqmP40SaDXH4+N4rRGhY2vXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J5SqGZ3WzeCKkKpHRU+pV4MrI0OGxjA9X1at90FfgQ8=; b=UmylAVJyU0NlDKja+rr5+aWGSWmKVorcoKmzbbDSUpPX+/nQjkOfF9u/1QhdP4bpJWMWAbRtkL/S8s1duTpD6l71inFDP12tFGnN+e0oGPi/TjrVrKP/yahws2dsVGqZkk8Tes2ck5+JIl1RM2UvO0XDx6rTaasUJJj2FT9ERfk= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by AS1PR08MB7476.eurprd08.prod.outlook.com (2603:10a6:20b:4dc::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Thu, 3 Nov 2022 16:31:16 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::81ce:94a0:632d:7016]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::81ce:94a0:632d:7016%3]) with mapi id 15.20.5791.022; Thu, 3 Nov 2022 16:31:14 +0000 Date: Thu, 3 Nov 2022 16:31:00 +0000 From: Szabolcs Nagy To: Adhemerval Zanella Netto Cc: libc-alpha@sourceware.org, Christian Brauner , "H.J. Lu" Subject: Re: [PATCH v2 4/9] aarch64: Add the clone3 wrapper Message-ID: References: <20220930192613.3491147-1-adhemerval.zanella@linaro.org> <20220930192613.3491147-5-adhemerval.zanella@linaro.org> <1d4ce210-2b28-b061-9780-f643eaa80a27@linaro.org> <8a3dc5d9-b731-4c45-7252-8157ba0be6c2@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8a3dc5d9-b731-4c45-7252-8157ba0be6c2@linaro.org> X-ClientProxiedBy: LO2P265CA0072.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::36) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|AS1PR08MB7476:EE_|AM7EUR03FT058:EE_|PAWPR08MB9472:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b448ea3-664c-4f1c-96f7-08dabdb8da05 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ZsjMnFptYYisS0UQGr61ZUYNBpSFQWqPDYJxbLLK/zT2+5akJoA/lfXB8Aw4wTsC5wN08jwg5hW4R4zTAkUu3VgHJ91Wezx69A7BwcgAQtih5XcjSTZEG7tmAM70Y5ZDOqJrHyS3laYeOkrPWStJ9oJlGFv0sSRoBay/0AjxfpQaGK+2dUrs5DzckooZq2b5WyFePHL9EGJ3AdRfs4NmnYGPAmo7GGRh6whPMgTiGCb8wWb5dhnUUq4DHYegWv8fpjXktbRUXvxJ2o7eNAj3YAnffE2ppkIGY/d1Fx6FCzSoh9BgpRT0yn6rOEL4KtfDKCYqCsW/MNtKsRYmhOkD5cVkdSBnhW3+zEc5vNHkRNsZux9OB9xm7Z+211Q7nKyJ722/tRfsRPVknst2PMMe4D9tsJLrTbhuuspwlukPAkPodAwh5OGQFCXjNquPC5kMPKVkUAoqPmedoF+G6d35lO323GlqfGEO4+UALSTFlRkdLrVsRQ7tTS7+ryJaH9coTs+2MLeguTzo6ShxOzHNd6TgukdSHZgUjU6Oaxrl0fXtJoHtMQB/2JzYWha5iuVnroUtncCDHluVtV3MhsI7lOyjWqszy2EQEjTP6iZ534Af/AppJFFKCKqf/tv7rl1/Uu8uGoIewK4z7ueAZN4zGCR3s+gU+y8FMCAsktwCgvtRgi9ubCEtDgPxb/SmybQ9GBPNKoCxZhGOz898j40o2FIW6FYO+EHCejAPA56ZH40= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB7179.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(136003)(39860400002)(346002)(376002)(396003)(451199015)(38100700002)(36756003)(4326008)(8676002)(66476007)(66556008)(2616005)(6666004)(26005)(966005)(478600001)(86362001)(54906003)(6506007)(186003)(53546011)(5660300002)(6486002)(316002)(8936002)(6512007)(2906002)(66946007)(41300700001)(44832011)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR08MB7476 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 957ffb58-d7a9-49ab-e3c2-08dabdb8d315 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TLlRh1UaVbZDphIGpIrIPhrpFDXYgvhXcKrAv5MwO9cokM6k4hp3HHWowTNkRwZl/Ggww2apAO4YJnEBxB5nE3tKhbVwdRY/s31GmILxCG+/L2L1nZD5akjOvIM3Y97hi9PfM7eLvWvyt9nKej7wQbtGyKP6M6IL9tmWiC+0kHRjXK0/LwJWIt8zLr1wN6jJZ6sqQ1e47HqAlAEC43WNHP7MG9RK+opNC3V8yNYYc1HWbe33VatR+hrbS5oI2LghdKs7eCDmqgKF6kR6gWqaB4F9cyt1LEjxlkbcRwtMLHrINBn0rLmASTA1dN5VLrBgbHl0pLBp5dfzKqvUR3FTjSWJl9bJGowpv0E/CRSzENQURqFM6UZz7a/3yb2+McOcdXJTPeSD9nLJ6ebJrL9q26+TGLCBuAmo7BBxb0MrLfRRysFo3JQUR6+iDPc6KMPHYKUi1p6MT1Z0ok+cpE+fxXVb4MH8IHaqVjFIYz1WuK0eWiQsPTSIVbfT97tV0A+hxJKfsJG+frIJqzw/MkdJls45bIkJI+wKMzDivZCrTqbC6kudqB2QIjoVoA1TcR07NNRBVgIiALTXrUV9C3YJR9OTzWAfbPU0MGvg69xLHQm0xWnaWZIgwoTDJUN9QGnCiA3/pJyuqocG2sZs5KcvQbbfnkRU+iCj0AUy3shJieaauAlC7FQ6UtbK0s50aWRBxsVG/Iy8Ip6pd/DRdgtaH9eqY0iY1Fv5GfXEN5XCRMWeqLZlMyRxY44uRKZQjwxCQa5a7gS/NsHbXuXeNuH6bXndMc4l19zKW0oCwxk8ZFQ= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199015)(36840700001)(40470700004)(46966006)(44832011)(186003)(8676002)(41300700001)(2616005)(54906003)(4326008)(47076005)(40480700001)(40460700003)(36756003)(336012)(316002)(70206006)(8936002)(356005)(6862004)(70586007)(6506007)(107886003)(26005)(6666004)(81166007)(5660300002)(53546011)(2906002)(478600001)(966005)(6486002)(86362001)(36860700001)(6512007)(82310400005)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 16:31:25.5309 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b448ea3-664c-4f1c-96f7-08dabdb8da05 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9472 X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The 11/03/2022 13:22, Adhemerval Zanella Netto wrote: > > > On 03/11/22 11:01, Szabolcs Nagy wrote: > > The 11/03/2022 10:15, Adhemerval Zanella Netto wrote: > >> On 02/11/22 09:12, Szabolcs Nagy wrote: > >>> The 09/30/2022 16:26, Adhemerval Zanella via Libc-alpha wrote: > >>>> It follow the internal signature: > >>>> > >>>> extern int clone3 (struct clone_args *__cl_args, size_t __size, > >>>> int (*__func) (void *__arg), void *__arg); > >>>> > >>>> And x86_64 semantics to return EINVAL if either cl_args or func > >>>> is NULL. The stack is 16-byte aligned prior executing func. > >>> > >>> "x86_64 semantics" sounds wrong: maybe this should be documented? > >>> i'd expect 0 cl_args/func to be UB like in most posix apis. > >> > >> Right, I think it is worth to document the function semantic > >> properly at least on its internal header (include/clone_internal.h). > >> H.J also added a new clone3.h headers, which is not currently installed > >> that I am inclined to just remove it from now. We might reinstate > >> if/when we decide to provide the clone3 as an ABI. > >> > >> And returning EINVAL for 0 cl_args/func aligns with our exported clone > >> interface, where EINVAL is also returned for 0 function argument. > > > > ok. > > > >>> > >>> and aligning sp in the child fails if signals are allowed there > >>> (pthreads does not allow signals now, direct callers might). > >>> i dont know if that's a concert (or if unaligned stack is > >>> something we should fix up in clone3). > >> > >> It was overlooked on initial x86_64 clone3 implementation as well. I > >> think it better to just return EINVAL for unaligned stacks and avoid > >> to change the stack pointer in the created thread. > > > > long time ago linux did that on aarch64, but it was removed: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e6d9a52543338603e25e71e0e4942f05dae0dd8a > > > > i think in clone3 the kernel should have aligned (it knows > > the bounds now), doing it in the userspace wrapper is weird > > (should we adjust the stack size?). and not doing it at all > > makes clone3 hard to use portably (user has to know target > > specific pcs requirements). > > > > not sure what's the best way forward. > > I think the stack size won't matter much here, at least not from > kernel point of view (the resulting stack size will most likely > be page aligned anyway). But I think this kernel commit makes a good > point that silently adjusting the stack in userland is not the > correct approach, I think H.J has done to make it consistent with > glibc clone implementation which does it. > > IMHO the best approach would to just remove the stack alignment, > since it incurs the signal handling issue. current generic clone callers dont align the stack and e.g. unaligned pthread custom stack should work. so we have to do arch specific stack alignment somewhere, maybe in pthread_create?