From patchwork Fri Oct 18 10:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 1999038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=SIfRsfIz; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=SIfRsfIz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XVL0v67lVz1xw2 for ; Fri, 18 Oct 2024 21:05:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 164CE3858D37 for ; Fri, 18 Oct 2024 10:05:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on20623.outbound.protection.outlook.com [IPv6:2a01:111:f403:260c::623]) by sourceware.org (Postfix) with ESMTPS id 14C87385840B for ; Fri, 18 Oct 2024 10:00:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 14C87385840B 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 14C87385840B Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:260c::623 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1729245655; cv=pass; b=RN2mgrN5KDQ3YL2rZTY5hziCh1+TgMQpagVDRpGa4SPir9WVWqtPz2mMWLWyF/thoNLeML1cD35n0Xa2lDLNS1eXmDnZiTEUXxVoYKxJ2aosx/zkyq2frcTXzlwMqJbPky5D4wmxoOKdl9//wB/+XqX4B6FyO+bhTb1Kj5zLjg8= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1729245655; c=relaxed/simple; bh=8Iw5rQsiZbL+jLZO63amAwGFryK7ll/KvJhJauRYqYs=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=XdYEV5cdVmGw2ZeM4Cu+iWt/15WU3OgF/yDFBrj9yTwhitQg7OxY26WEPtJ7xRcPOOgOLyVbYg4fTPQ7J4B4RqQHPRm7JwUrnFZ04E5XDyFT9iIUxscDWilYryIq5mImEIeTk8J0RtI4u+3zelzdLDm0iO3nCSQiGHpzQt5yg0E= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=bXZpMvC8tHll+McZngsvqs+9nTAZ/NR8l38PQ4tmuO3bPTUIOlOZKlCKA+vN3D5unXgQCrM1mjmLwu28AsnzG3SOPbzugFjWejSZCXfvJqFpg/C/zYH1tWKZQqLYQtgAlANDKkvlGC3G9v6CY9e/sxYSqKamrSIJV5kxdzCm1Lf3jGiZ0LpnD+rEveYu5+s+S8ggl9oOn/bja07hVTf3cemIeelbMRkIiS8CbHd0YGBmpKCNQ2QlbjGPkjosOJhsbzmrNDwsm1Ev0fMSmRmhbM6K1RT9roCQdruaUdUuojqJswNfhCatvzwG03VVKqbPgpyv8E08dNHp1I7phztvPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=P/SpUx2OVaKgFtsccDz/pz07a0VQnNjDOYqZg3g3uhc=; b=oCm10VKLWKlP9KLURJwqlDO21+T72vIE2TCVy/9GzQ3aEHDCYoFf1e32GDRld9PL2eFHJ/akGSfdoSxXKvWijpYhabYKYgW1gEwpKYnMm1xn1hXqcjoAWYUklBpHHtUNNg4vZWfVURwGgBRZcNB6P+jmaX+rn603AkL692nuk9NGsj4IhiKLkR0rqGmWH6ee3N8QZHAw2Bvex/3ytrMDqjMxoHzvsZYjd4fVYO2dqRt4SPiaDCkJ1d4zC1A9GdStzxSp8TE6MKOrxrTqT5Ltfo/NIUH1zyCYmRH0ZShNyKQwcAw7qsF672Z7gUIjXW0RJt8KJPD7y2Fh63hKzz2ORg== 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=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P/SpUx2OVaKgFtsccDz/pz07a0VQnNjDOYqZg3g3uhc=; b=SIfRsfIzcr8JNbEaZyQr1zvwoxbY+Bqh0KES+cI2WbHdIfrqgKHsHjkVUe/GHzwg22TEg4pfP01ocaEI5Kl+oQXyF8QmOsCKmnRJ2iEVMyPdLiZaRvS1ykwsdPVVy7BXZGmedYbyT/ZlC43Hsr1Saup1jMFR4FHTxbtNrQ4EESA= Received: from DU2PR04CA0030.eurprd04.prod.outlook.com (2603:10a6:10:3b::35) by DB5PR08MB10286.eurprd08.prod.outlook.com (2603:10a6:10:4a9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Fri, 18 Oct 2024 10:00:39 +0000 Received: from DB1PEPF00039233.eurprd03.prod.outlook.com (2603:10a6:10:3b:cafe::88) by DU2PR04CA0030.outlook.office365.com (2603:10a6:10:3b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.23 via Frontend Transport; Fri, 18 Oct 2024 10:00:39 +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=arm.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 DB1PEPF00039233.mail.protection.outlook.com (10.167.8.106) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Fri, 18 Oct 2024 10:00:39 +0000 Received: ("Tessian outbound da7ba6582322:v473"); Fri, 18 Oct 2024 10:00:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0890d43b65f54e68 X-TessianGatewayMetadata: KZH8VSekZ7E64KUCsHuO83JChuB0fxiv/UbP7h+awpGP/udju0wPOSsAykUn7K0q6yj1uPOZWEitXRfeMB080MQbJF2Oo8Tv6kH50CEoky/5zHGy3RL3CVnhe+Y9drUrFF9A7W8UCT5OoMKWHSFMbXACX9sCrgKAHz6XH5jb61s= X-CR-MTA-TID: 64aa7808 Received: from Lfda53fb4238c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5DB5549A-EB18-4F31-A757-DEDF52A6E758.1; Fri, 18 Oct 2024 10:00:32 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lfda53fb4238c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 18 Oct 2024 10:00:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qHDrQXcvZF5vMKQOAdoNdEr/n5S/OTVf3yx8Zepr7ZslSLh5gj7Q9NDxRdWFWtKAX1BCxFSk1QoML5etuBIis7nr8ZJGwwaBkKP356vZXmIL3Gx8yt7PyR8VeMFsXzgipoPq4PTKH58Wm18fTPbHaFZl2+M2jLdym+qDBVikNwvdUHPq66BDqtF5QI4qr42LnJegw53NdIZgizgPBrP+DS7PwzhMjjrbpHSOLKoBPl5+kodZqqv2ZJtPEGlL/8PumU1hr0Zw9uU+0epXlzGC1OCUCQHmDWY4V8QEAgo5xs82A6dUGf8wi65ILjyw6OXb06SH3nhhzNJfaHuawqX3JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=P/SpUx2OVaKgFtsccDz/pz07a0VQnNjDOYqZg3g3uhc=; b=pAfSi++KiYzOhiI1iofkY9sYvlIsQXPL7KTVOY7RHAHkYR0kfTamKOgYfEtOCRrR77rPYJu5eZ6IiwBFcZB4ZYEDJKhpZOH8HO+5tlPMpybZvAxGs1Yj+Q3CrtGJNacFerBms2YYNnZ6bavBOFv8tthtIRknocKehZrA6iNT3HtTz1hwEsH309jQbschtWa30pNaRebh2Id4l93iYc9aftnXgZNhN11bFscP/6Io9hYKGBp2zzPPjN5NJb4zImZmrifMJBXSJD3EdR1TIm0ZXUEVACczXhYYvK6ZWeBSK60UQZEX0/NX5spACSPE/At78I8zHjHctlOCX/rP1thyrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P/SpUx2OVaKgFtsccDz/pz07a0VQnNjDOYqZg3g3uhc=; b=SIfRsfIzcr8JNbEaZyQr1zvwoxbY+Bqh0KES+cI2WbHdIfrqgKHsHjkVUe/GHzwg22TEg4pfP01ocaEI5Kl+oQXyF8QmOsCKmnRJ2iEVMyPdLiZaRvS1ykwsdPVVy7BXZGmedYbyT/ZlC43Hsr1Saup1jMFR4FHTxbtNrQ4EESA= Received: from AS4P195CA0002.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5e2::6) by DB4PR08MB9406.eurprd08.prod.outlook.com (2603:10a6:10:3f2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Fri, 18 Oct 2024 10:00:28 +0000 Received: from AMS0EPF00000191.eurprd05.prod.outlook.com (2603:10a6:20b:5e2:cafe::ff) by AS4P195CA0002.outlook.office365.com (2603:10a6:20b:5e2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21 via Frontend Transport; Fri, 18 Oct 2024 10:00:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AMS0EPF00000191.mail.protection.outlook.com (10.167.16.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Fri, 18 Oct 2024 10:00:28 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 18 Oct 2024 10:00:27 +0000 Received: from udebian.localdomain (10.1.28.135) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Fri, 18 Oct 2024 10:00:27 +0000 From: Yury Khrustalev To: CC: , , , , Szabolcs Nagy Subject: [RFC v2 21/22] aarch64: Add GCS user-space allocation logic Date: Fri, 18 Oct 2024 11:00:25 +0100 Message-ID: <20241018100025.2955720-1-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241018095653.2954868-1-yury.khrustalev@arm.com> References: <20241018095653.2954868-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AMS0EPF00000191:EE_|DB4PR08MB9406:EE_|DB1PEPF00039233:EE_|DB5PR08MB10286:EE_ X-MS-Office365-Filtering-Correlation-Id: b3a6de75-5732-4b0e-7b29-08dcef5bb83e x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info-Original: u2W0L0n3FxSSWZgUwE+rTpCOwGe2fbgZDtcF9p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TnzZmtqvQRW9jvhZmHwutOVfVi4yUyEEphECpPK78a50AnHMR7fU1k4dYTTpwIoK6N9QhrOSHpNj7EYQG3vUFWUSXtqGezxaNwWtnLdqYFrlnmkJVsjQ/FfM4WCD3kLl6FCA4ZXaIA7wY4Y/UabxA2vgFYuHhG7h88g+KEb5CnaWH+Re8Dh3NQWHm534Rpx/3K8QCHRJfZt/uinffa4sDKJ9bHgRPxudmpFle/xoCW+eH3h2xa2Yl0Rcl+N6CTQfN4maPV9FX4iYMrYsyPZfguNzFLiQjG96is04O+gmjxC9RFg== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9406 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:20b:5e2::6]; domain=AS4P195CA0002.EURP195.PROD.OUTLOOK.COM X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF00039233.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1f4bb3e2-fac8-47aa-9f26-08dcef5bb1ef X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|35042699022|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: aiWUbkORmUy1xAg9AM7BQI0ckPNV+jvA79cUS/d22D7rPHAN2LLV81zuT3pDomL01NeZVnEhXa2altaG1BgZ4u3i1KDzWFOiDt8sCTkL+KDxBdVHQzPUw5aeW+5/WGHaBWR3jg2WtFiWfNtApizGQHnBdLvB5JSneJr/VpURR0u9h+MheF4NdYrd6zr8B93oXTCzwl33ubx4XCT1dR0aF/GWPPhMOM/EmThRoZ2v17GcpiExH1G4kBUjU1AL5N9uvcTTzdXZUqUAdJzMIIc5ol4nM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8AROUCpPvszIfBjWnw7Pq8Tc/NIRFjTrX5hRWjoxR8VkvHGrlQ== 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:(13230040)(376014)(35042699022)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 10:00:39.1932 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3a6de75-5732-4b0e-7b29-08dcef5bb83e 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: DB1PEPF00039233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB10286 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org From: Szabolcs Nagy Allocate GCS based on the stack size, this can be used for coroutines (makecontext) and thread creation (if the kernel allows user allocated GCS). --- sysdeps/aarch64/Makefile | 3 +- sysdeps/aarch64/__alloc_gcs.c | 66 +++++++++++++++++++++++++++++++++++ sysdeps/aarch64/aarch64-gcs.h | 36 +++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 sysdeps/aarch64/__alloc_gcs.c create mode 100644 sysdeps/aarch64/aarch64-gcs.h diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 74479604f2..4b7f8a5c07 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -71,7 +71,8 @@ sysdep_headers += sys/ifunc.h sysdep_routines += \ __mtag_tag_zero_region \ __mtag_tag_region \ - __arm_za_disable + __arm_za_disable \ + __alloc_gcs tests += \ tst-sme-jmp diff --git a/sysdeps/aarch64/__alloc_gcs.c b/sysdeps/aarch64/__alloc_gcs.c new file mode 100644 index 0000000000..62b7b6f396 --- /dev/null +++ b/sysdeps/aarch64/__alloc_gcs.c @@ -0,0 +1,66 @@ +/* AArch64 GCS allocation. + Copyright (C) 2024 Free Software Foundation, Inc. + + 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 + +#ifndef __NR_map_shadow_stack +# define __NR_map_shadow_stack 453 +#endif +#ifndef SHADOW_STACK_SET_TOKEN +# define SHADOW_STACK_SET_TOKEN (1UL << 0) +# define SHADOW_STACK_SET_MARKER (1UL << 1) +#endif + +static void * +map_shadow_stack (void *addr, size_t size, unsigned long flags) +{ + return (void *) INLINE_SYSCALL_CALL (map_shadow_stack, addr, size, flags); +} + +#define GCS_MAX_SIZE (1UL << 31) +#define GCS_ALTSTACK_RESERVE 160 + +void * +__alloc_gcs (size_t stack_size, void **ss_base, size_t *ss_size) +{ + size_t size = (stack_size / 2 + GCS_ALTSTACK_RESERVE) & -8UL; + if (size > GCS_MAX_SIZE) + size = GCS_MAX_SIZE; + + unsigned long flags = SHADOW_STACK_SET_MARKER | SHADOW_STACK_SET_TOKEN; + void *base = map_shadow_stack (NULL, size, flags); + if (base == (void *) -1) + return NULL; + + *ss_base = base; + *ss_size = size; + + uint64_t *gcsp = (uint64_t *) ((char *) base + size); + /* Skip end of GCS token. */ + gcsp--; + /* Verify GCS cap token. */ + gcsp--; + if (((uint64_t)gcsp & 0xfffffffffffff000) + 1 != *gcsp) + { + __munmap (base, size); + return NULL; + } + /* Return the target GCS pointer for context switch. */ + return gcsp + 1; +} diff --git a/sysdeps/aarch64/aarch64-gcs.h b/sysdeps/aarch64/aarch64-gcs.h new file mode 100644 index 0000000000..cbd1065a5d --- /dev/null +++ b/sysdeps/aarch64/aarch64-gcs.h @@ -0,0 +1,36 @@ +/* AArch64 GCS (Guarded Control Stack) declarations. + This file is part of the GNU C Library. + Copyright (C) 2024 Free Software Foundation, Inc. + Copyright The GNU Toolchain Authors. + + 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 _AARCH64_GCS_H +#define _AARCH64_GCS_H + +#include +#include + +void *__alloc_gcs (size_t, void **, size_t *) attribute_hidden; + +static inline bool +has_gcs (void) +{ + register unsigned long x16 asm ("x16") = 1; + asm ("hint 40" /* chkfeat x16 */ : "+r" (x16)); + return x16 == 0; +} + +#endif