From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2048.outbound.protection.outlook.com [40.107.15.48]) by sourceware.org (Postfix) with ESMTPS id C8B7A3861021 for ; Tue, 9 Apr 2024 11:46:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8B7A3861021 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-Filter: OpenARC Filter v1.0.0 sourceware.org C8B7A3861021 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.15.48 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1712663175; cv=pass; b=QDLRu1BYlnZxj1hOYdjp82Se705RJLERm69SNzJhTovoqt5wGNtEKw04IcZ5++H0bDWme+gQcGkREQ6509xrVWS0zw1p2k1K+EeZXvZWFQUdRH/F09d/sy05qt4MyI1NmW/oCW0N50AO2q81bu2fclANZWGnSSmM+zSTux/NCb4= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1712663175; c=relaxed/simple; bh=6ft3TDV34tD/irP2E3dJ3Vn2SVRCM58qW2lXq504iu4=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=KVs9xzguNK8mqeWCxFP0sdzwpxyNqXz1ZE24Y5DLT788pBtZ6vwAABanN6QQ8iGoZHM08Nx3K85mLDLRNC1cQDdYE2XlL6SdF6PabXFDQjRzBip8rP0K6PmMVaXtoxpstlus2cWp8U11kFo5JWhHIP0LSpvRUk44wDzFQqVqsAc= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=BAZ6tTE9o1atmibZSQyFRF4q/hvdR1/z9fcwSME2l/33MHn022KonXke4Zoh01Hbr2hpyElBXt/FZqNsUrwj8SA92gnb2hRKhdXhNht8iZvD40eHvW0vS0SsowTi0wqU6NLkWpjmTObJ2ZIhSS98qZLoMgezE5yHBNnjiMSJh9uOOyi6Imrh7hsHAmfwuNUuqU2iUdpP1nb456En7lRQoMr/sQwilm2fTo8Y/E/gLAQD6jnGnb02Mwu71hkgmDl6wCXrMYeb0PAHtb/+KHKvUkHbbwJcmJP3j9EoQseowEz6yTknWWYGa6u9lVyxJt+JUIZnixw+ocPtD8+G791wHA== 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=MeKtl6U//ThTPF3AqvqbD5BCHhucsPH0GtO4HMsLwgo=; b=NwhRMjfYHw81XMFZbZ118+5l6+XHcIObDU3bt9UqqzWkAaFkceMxS1LQgoLJcJJkYxS5YQ2Ip4x/237v9pv1FS4PCUsA1iHCXP5rR8tOuVSuuBydaQfvYbi5NrJNBWY7dXrcKwyht3PlZLlfLTQDGbvmwCObqOQyQyVoOUuWqGFM/xAvYi8lLmB84DlorAE3KDuaw3D35g70CAv7N57dcq1KHhygYEHDLgRc+LUjwnh0eIMPh05CQnQw/rbFKEZ2hNIkkcbWzpPduan7EECrWGY+vtq9iYOBP8yxoe5Hgea85AH6HAdA8UAffqa/od47fGoFGh1cOcOCT5354iN5JQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.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=MeKtl6U//ThTPF3AqvqbD5BCHhucsPH0GtO4HMsLwgo=; b=eY6jK7vAjzE/nS0EVjfUTR3vg2mXl+crgrahWFTFNBF8HT6mvs+KP4B9cxfhqvzy+WqGnCI6QowQOcT41rEu6I+zW1J+KR34aK2/kQCF3VXfhFcmK4FDBKeagU9dqB6JKoSiCM0+c/SbKNyybzpT2s7qYTe63qdNdhGKjmGY6Q8= Received: from DB8P191CA0016.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::26) by DB4PR08MB9288.eurprd08.prod.outlook.com (2603:10a6:10:3f4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Tue, 9 Apr 2024 11:46:08 +0000 Received: from DU6PEPF0000952A.eurprd02.prod.outlook.com (2603:10a6:10:130:cafe::f5) by DB8P191CA0016.outlook.office365.com (2603:10a6:10:130::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.35 via Frontend Transport; Tue, 9 Apr 2024 11:46:08 +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 DU6PEPF0000952A.mail.protection.outlook.com (10.167.8.11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 9 Apr 2024 11:46:07 +0000 Received: ("Tessian outbound 9b7417e2a8eb:v300"); Tue, 09 Apr 2024 11:46:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2fcf5dff056ea84c X-CR-MTA-TID: 64aa7808 Received: from 198e5ce7629e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FE22C8A3-FB85-4047-B3DE-C84CA38733A1.1; Tue, 09 Apr 2024 11:46:00 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 198e5ce7629e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 09 Apr 2024 11:46:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HR7xGOd585vldWMwxoNXVq8YVhP0ExYE3aA+MKIG41jCl2Qynir/tBAB5nYRU9t/qitCdk6UnVL0DqoDqM6tjq4FKK0kjIKCzQoPhHXZf3LjAemw7xrzQrg0c3Qk7Oz3+W6+prCbD4yD55ZX5V6QzlrWfnrOCvCCLTrWJiNPRJi6ddwskZxJC7XrzwUUrdc2Ua7FTeoDXzEpLnWOuN9LyzjivqspGzeEn4F55Qu1ubRESHi88cRiOJVo4Nos6foxm/tHthRYx5tDWUuRTzt9DfsJr3aaNYAf/nM9MoPBFfxLHWLhMlwCyO5SQehZ5Ep4fpitunPJ+Ee1E1SSPV6CMg== 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=MeKtl6U//ThTPF3AqvqbD5BCHhucsPH0GtO4HMsLwgo=; b=SnLhydwhqEcHYjEsw9k+upWMcqqzn1O04JP92zYtuM1isQdYEO+7N6gaioXiYorB6VwTKJaHferxmolylyI/647unB/36b3CbqJmft/qeLIOvR3NCp5B0N2hZlHXt9eYvv/LW7/fbJC59BFI9lQ3RDNgrmrInkBsO8b9kNr0//MspvSU2df8sRm32A0oWfu6z5SRFrMpk/Gk3B/N2EJqaOro4u2hb0ZlWbYhrn1o9JUzW00o3ieMxdoawzdR5N94KOq+xEW0hVpai9G65TKH5s37GW6Os3cbcYz9vyOUORatvqpgQ9EzqMc5RqHt1Fr26OMlEcCoGx34wmT9zrCbrg== 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=MeKtl6U//ThTPF3AqvqbD5BCHhucsPH0GtO4HMsLwgo=; b=eY6jK7vAjzE/nS0EVjfUTR3vg2mXl+crgrahWFTFNBF8HT6mvs+KP4B9cxfhqvzy+WqGnCI6QowQOcT41rEu6I+zW1J+KR34aK2/kQCF3VXfhFcmK4FDBKeagU9dqB6JKoSiCM0+c/SbKNyybzpT2s7qYTe63qdNdhGKjmGY6Q8= Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by GVXPR08MB10764.eurprd08.prod.outlook.com (2603:10a6:150:14f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 9 Apr 2024 11:45:58 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::8c23:46ef:c2c9:ea91]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::8c23:46ef:c2c9:ea91%4]) with mapi id 15.20.7409.042; Tue, 9 Apr 2024 11:45:58 +0000 Date: Tue, 9 Apr 2024 12:45:45 +0100 From: Szabolcs Nagy To: Matheus Afonso Martins Moreira , gcc@gcc.gnu.org Subject: Re: [RFC] Linux system call builtins Message-ID: References: <2d2f1e405361d2b36dd513e3fabd1fe0@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2d2f1e405361d2b36dd513e3fabd1fe0@gmail.com> X-ClientProxiedBy: LO4P123CA0056.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::7) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|GVXPR08MB10764:EE_|DU6PEPF0000952A:EE_|DB4PR08MB9288:EE_ 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: GUeMqEr7O80GLXkFKkKwoZIJJHUvF0dnjvmJCA/RFz3vpi90zprQm/B/8DjMbUzPMffzQPwWFbSNNzAP/aZqlkOv2j+ATwHchWqfM4cWw0SuOgZ4QfrafxuHF/KtxQ8G+o6nBoU+7UAdxHQE40Q8DXRQuek9Fi4ePp4WYtHTcRhzfJYvLAyu/FUprHx4iNtEarqrHoYNNmsIFJmzDo8IaYuu6Eq9w2Z5zCvoOKhAwWOc3lhcKSkxRYQvZdKVIyPIlD9HoacpUlaQEK044yofMgrmri4NY53zp2w33a5HN7cKQFmtzQNjpBiP8QsRGHVGhgJ0sYGyWuOf4OOTgVPSxELTkVjSgOEiV1tWEz6GY7epGusTnlpfabtzZ+clfodcitJltuJtLPUNuJk9Mj1RkEp3K6IYKfkTDVOTezoSP+DEVxJbhdQoCW4YZgDgpg4p96ftrz8J09KTNhoRNVATxdO8CbsdPhaPv3K74N7SUvx5Yv3JcCmUyimSvyG4zfSWKjwfaAjoCUmlvW25BqNp8ebEwg9aAiH+7Em/B+Sa1y+JYKTyhDNIILsAXgOxWWf6MChUKMsEidMeTr3YE/6Cv1VPOh5g2qHD2X2ybcNDBN8+2x3K8Bvq8MQQP/vfxAO1RXNtTXKCuqdx3xPrfvm4Yfi43Qpo/aYdXqIMx+4EQzA= 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:(13230031)(1800799015)(366007)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10764 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF0000952A.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9ba0ed4-f5b1-4605-61e6-08dc588aa4ac X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t0DWLE8ba/dhF1aUVEXaaaWgP76Y2Pvlr7b525lN294IYpe7wqzy5gwYWxM0E5uOsUd8TzqVAovLroOjE2uj8Zcd9hH/ZaOJ6gIa2YJAti+Ybkv95XoFqjdIu7cqq66pbim6yRzDeGaM7I00nJwu+HlDsotcJWUawlP5d+N8FO7laOp8j0NjCwfzikcQutiRySjWOfpgf+j+KQzJMQcMXd/MBCRhIrV/GRUEEjLGEgV9nJ14BCpdMQ9IB8GlGhxwe2reMUEjKk04rSyXR5MzYSde2FEUuvnquaqc0WU/e9tctXcWGO2vEikPCz2kLp9XJNIvk50JQfqSrmg4qRHC2DdhjSLQw+k1XxOgBMPn/N+6XsBcQtUU0B4/dXWCWmCSPS7jpfz1nrSHCT8B3nynnrJ039dtfegXseBeScEYfeIz3yanxIhJNmuFU+4+89z/Fvuz9Ffr8qCqmruvui3WDKlHil6iAaRCiSpJ4uFRTI5z22So5DR+wOTWhpI1d+L9o44P5wCdXZSnQxwGaMDD93xvUtexNqvcTpZS+lhbbVxO2PwCbqPOd0d+61iYN1GnPS3t+qtSp07sbE40jZLawNdqn9LaNaD5Fd2ZUXx+rsBLFLx06oJljJIlEFu+lMA6QIsiKMCOy6OfPETb6Yh36FP7Sg4joL+Kr0poMkJo84KnnJoP06YRY78i+XBS38/SfElZ6Ba7JKd/UJ4xz9no1Qhf2UyMCG54aJbkPMXA65lT5mzsX69nB6LcibdkFh/Z 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:(13230031)(376005)(36860700004)(1800799015)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2024 11:46:07.1103 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9ba0ed4-f5b1-4605-61e6-08dc588aa4ac 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: DU6PEPF0000952A.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9288 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_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 04/08/2024 06:19, Matheus Afonso Martins Moreira via Gcc wrote: > __builtin_linux_system_call(long n, ...) ... > Calling these builtins will make GCC place all the parameters > in the correct registers for the system call, emit the appropriate > instruction for the target architecture and return the result. > In other words, they would implement the calling convention[1] of > the Linux system calls. note: some syscalls / features don't work without asm (posix thread cancellation, vfork, signal return,..) and using raw syscalls outside of the single runtime the application is using is problematic (at least on linux). > + It doesn't make sense for libraries to support it > > There are libraries out there that provide > system call functionality. The various libcs do. > However they usually don't support the full set > of Linux system calls. Using certain system calls > could invalidate global state in these libraries > which leads to them not being supported. Clone is > the quintessential example. So I think libraries > are not the proper place for this functionality. i don't follow the reasoning here, where should the syscall be if not in a library like libc? clone cannot even be used from c code in general as CLONE_VM is not compatible with c semantics without a new stack (child clobbers the parent stack), so the c builtin would not always work, but it is also a syscall that only freestanding application can use not something that calls into the libc, and even in a freestanding application it is tricky to use right (especially in a portable way or with features like shadow stack), so i don't see why clone is the quintessential example. > + It allows freestanding software to easily target Linux > > Freestanding code usually refers to bare metal > targets but Linux is also a viable target. > This will make it much easier for developers > to create freestanding nolibc no dependency > software targeting Linux without having to > write any assembly code at all, making GCC > ever more useful. i think the asm call convention bit is by far not the hardest part in providing portable linux syscall wrappers. my main worry is that the builtins encourage the use of raw syscalls and outside of libc development it is not well understood how to do that correctly, but i guess it's ok if it is by default an error outside of -ffreestanding.