From patchwork Fri Jun 12 13:29:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39579 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 41AE6395B080; Fri, 12 Jun 2020 13:30:05 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80085.outbound.protection.outlook.com [40.107.8.85]) by sourceware.org (Postfix) with ESMTPS id 300B3395B033 for ; Fri, 12 Jun 2020 13:30:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 300B3395B033 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@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=Xkk70UnhwzcPDBDJqRTR+TK5gJxA5NMHZ+LDknF0r/E=; b=0hYZLihfuteEU7Sx/5erloYT7dVnS/nMVdo/gq9GsB0bStdMCQhYhrCnMLSwdbml5MqH7xLBIj0yOsp7C12uix5fi1XzaImLQGzf+KaOQTkR6yzRzmVTEWGUhCphaF8qI/ES6DjtkoOBPThj7un/UYQP51d0B25h6tmEe/YR+oE= Received: from AM6P194CA0034.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::47) by AM0PR08MB3619.eurprd08.prod.outlook.com (2603:10a6:208:e3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Fri, 12 Jun 2020 13:30:00 +0000 Received: from AM5EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::47) by AM6P194CA0034.outlook.office365.com (2603:10a6:209:90::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Fri, 12 Jun 2020 13:30:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT053.mail.protection.outlook.com (10.152.16.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18 via Frontend Transport; Fri, 12 Jun 2020 13:29:59 +0000 Received: ("Tessian outbound 3e82c366635e:v59"); Fri, 12 Jun 2020 13:29:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a6ad93773cda9168 X-CR-MTA-TID: 64aa7808 Received: from 5b2b20db0eca.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E193A802-4C75-4A68-8902-2A6B82DC7682.1; Fri, 12 Jun 2020 13:29:54 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5b2b20db0eca.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Jun 2020 13:29:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fy82+wlt7Itx2XCkiBeADxATr1eLh4Zi2T9yoaByRUh1665OjMGEZg8ANiYC8kRRiYkxXxRPiMKcIxiieus8V97qlp1Nyt/Vb15l8hDI+7r0xHjYqnYOtcsphBcYE3mY1pKAgEILS/ikqJc+F4bP+T+nyEWQbDWpymXe9bf+upfY7HcJPjXJdEQxrepGJUqx9nFFjZ+8GdgfbQMm+3kHR+KUGdvB5zJY03OqNR5lZY+JqhYZIB3D74hbrNZfq3ppgXj52VUo/PWj29OEdM5jHTon4x9aLS8nr9kaguO9ybzITOcVHHhzzERZi65iGu+nPkmzxEjxsKi7AQFApOEQ9A== 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-SenderADCheck; bh=Xkk70UnhwzcPDBDJqRTR+TK5gJxA5NMHZ+LDknF0r/E=; b=UgufGHE8bWc57czh+bz9ofD/kmAvMdgMMsWhscBlvP75Hy5u+/B0gKDd9DjcsmF1vHg7hh1tB1sQpc8W67VNGWEO7FNmtXI6nZiEERlYjFWLb8tiwy7JW3jtKlpqN7hHh9TtmcSMdbAenRrqX31CZJf/aM8PpOJ/qQx7hNve+7EGpfemE+5gxpXmKo8zP+RB5kWZX0Naa1PmCxpMH7VHXe0KTAp2Pke7Yt42G4aQ+swSZ2HCHp0fyMz5QV2dCwaVvTgUGpy9QWqRfpxROG4OEvcVWEeFAn4wi4AhGbrJXbaEDQ+iSmbA7Z4H8Eam6AbwijmfJzrWIpmPtx2oOFcmZg== 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=Xkk70UnhwzcPDBDJqRTR+TK5gJxA5NMHZ+LDknF0r/E=; b=0hYZLihfuteEU7Sx/5erloYT7dVnS/nMVdo/gq9GsB0bStdMCQhYhrCnMLSwdbml5MqH7xLBIj0yOsp7C12uix5fi1XzaImLQGzf+KaOQTkR6yzRzmVTEWGUhCphaF8qI/ES6DjtkoOBPThj7un/UYQP51d0B25h6tmEe/YR+oE= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB3912.eurprd08.prod.outlook.com (2603:10a6:20b:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.24; Fri, 12 Jun 2020 13:29:52 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3088.022; Fri, 12 Jun 2020 13:29:52 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v4 08/12] aarch64: configure check for pac-ret code generation Date: Fri, 12 Jun 2020 14:29:26 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SA9PR03CA0017.namprd03.prod.outlook.com (2603:10b6:806:20::22) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by SA9PR03CA0017.namprd03.prod.outlook.com (2603:10b6:806:20::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20 via Frontend Transport; Fri, 12 Jun 2020 13:29:51 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 83cbee8e-c53b-47da-8d46-08d80ed4b4b5 X-MS-TrafficTypeDiagnostic: AM6PR08MB3912:|AM0PR08MB3619: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3276;OLM:3276; X-Forefront-PRVS: 0432A04947 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: w4N43cfVoNqZ/aNkunmpPHOx+w/miL2JRVuZd5HRYk1YOiPHnM+zmGDitolKCSp736J44zUe9Vf3GEMFVyEUQ73d1dY8VOfKswU7qIwMMn1HPpJNyjo5A1CNLqFIgdUrNFjZr0EtaqkAIJqIlZpBA7OH0d9YKgYTF9a2CTX4B3dGW8XNDUZBDOpBjERdJbKjJ9hwYbbfiv0LK6qbO4A2665u5j5HBTr72ZjlIjQiCAq6P5C1M11Osg0wp9OW68VB2InBJHkr+zqYi3OtJSRsyJR+zwPQxepzB0c8SU68NMphU1UqURnbU2871M8ytXav8j1gDmfpKlR2K4BHS5tolswEvE7zULxFBGeS2ukREKXV4n2lHQMerIrVR/iq30Ok2FNjs1x6a4sjW33jMx8YIQ/UhOQPbcoZ4yUN6Z8BqK8= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(136003)(376002)(346002)(396003)(39860400002)(366004)(956004)(66476007)(66556008)(66946007)(6506007)(26005)(6512007)(5660300002)(6916009)(6666004)(2906002)(8676002)(6486002)(52116002)(8936002)(44832011)(186003)(16526019)(36756003)(2616005)(316002)(86362001)(83380400001)(69590400007)(478600001)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4qBKc39oGwsb355lQhGuYZM2OI0EELf4paPXO93qj/YmQbfP5Vw+MqFnNyQF28QItch1S7g3qDOasDibRwWENabSsCb8XjV9sE8cdzfGIZb8YwFv6ep7TWC3MMQzYjBotKmYOU+65TjMuxLV0bDxV9SfXe3SL2A0z5Bk667UEPIN+qTQ5UCUQvdyr2QMcbMNLICqEsWubKXqsuwkyFRr2kc1FCtqP6ZhDdfEXoPpDrDQrqdcIEI4N8F9DfyqqsUghedOhmWrjsdyFlmiP47kPZv+I0oC3JcQvZYi2vw99a8H0D0k3173O0PIB9NSSKtCfLeWgRu5lCG1ynvHEntwd/7zl5zFuPQgEHXQruHjxFdKe4KlqZ7gT/o1vqMf/amyqmDTkmFcA4AcYHdGFDJeYN+9h7QXzajVS15VJn2DM5wIer932vP2IXBiGW4ZyczE+WEaATh6CxvGIRdsyUpkWT6nNFwomj+YhTVfQLOYXi0uhC8VSVtOpLPOyFSAGtFQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3912 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT053.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(39860400002)(376002)(136003)(346002)(396003)(46966005)(6916009)(44832011)(81166007)(70206006)(82740400003)(336012)(316002)(478600001)(2616005)(47076004)(356005)(16526019)(26005)(6512007)(6486002)(6506007)(186003)(82310400002)(83380400001)(956004)(8676002)(69590400007)(8936002)(36756003)(70586007)(6666004)(5660300002)(2906002)(36906005)(86362001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 626f87c4-56e8-4f17-ab7c-08d80ed4b028 X-Forefront-PRVS: 0432A04947 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gNuSWJfKBCCBGdiUjAEp760JKtBQzdn9fB7/wtgcd7b79WbHIZuikqKmOVPrgbTyEbpOnXB+CrxstJKfpD5U4vpKWmEOp7ZRSrpEs14mR1Jya4fwd+5mI3XvzFh7oBiC6xLPRQIfxdhCHmF2sUsZszeM6wwGhSuTh8Ul+orn0n9cypvlLxuX1PfUXuBeIc+nbuFnU4sdAY5u9VZf7/cjZcwY2dA+0I1J4T0YMGYYjtTfqJjgFedQgwJGsTLU7Lz2z+PA4/2zuE0hupGr2j+LbrcEUKOGCqx50uLcX/wPpIK3KWKajQpaLsWUOJ4w7xHYou8h7mjSzp80O+TPo4R4o8pZ+puHJ5S44Rgv7KVU8jq2FUQ648WKLj16byJep1k45nCDVLuNOZGVTNUZ5Lv2PGqNMiGbXaUZ2/QzvHYayeaJbmotnXHAfuPADuZNlnDDysWgK5RJgoMkAEk0GK0ftA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2020 13:29:59.9838 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83cbee8e-c53b-47da-8d46-08d80ed4b4b5 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3619 X-Spam-Status: No, score=-17.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY 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: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Return address signing requires unwinder support, which is present in libgcc since >=gcc-7, however due to bugs the support may be broken in --- config.h.in | 3 +++ sysdeps/aarch64/configure | 39 ++++++++++++++++++++++++++++++++++++ sysdeps/aarch64/configure.ac | 21 +++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/config.h.in b/config.h.in index 67169e5d01..7921917ad2 100644 --- a/config.h.in +++ b/config.h.in @@ -112,6 +112,9 @@ /* AArch64 BTI support enabled. */ #define HAVE_AARCH64_BTI 0 +/* AArch64 PAC-RET code generation is enabled. */ +#define HAVE_AARCH64_PAC_RET 0 + /* C-SKY ABI version. */ #undef CSKYABI diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure index 70477a7fa5..5f1cdf5d9b 100644 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -214,3 +214,42 @@ if test $libc_cv_aarch64_bti = yes; then $as_echo "#define HAVE_AARCH64_BTI 1" >>confdefs.h fi + +# Check if glibc is built with return address signing, i.e. +# if -mbranch-protection=pac-ret is on. We need this because +# pac-ret relies on unwinder support so it's not safe to use +# it in assembly code unconditionally, but there is no +# feature test macro for it in gcc. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if pac-ret is enabled" >&5 +$as_echo_n "checking if pac-ret is enabled... " >&6; } +if ${libc_cv_aarch64_pac_ret+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } \ + && { ac_try='grep -q -E '\''(hint( | )+25|paciasp)'\'' conftest.s' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_aarch64_pac_ret=yes + fi + rm -rf conftest.* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_aarch64_pac_ret" >&5 +$as_echo "$libc_cv_aarch64_pac_ret" >&6; } +if test $libc_cv_aarch64_pac_ret = yes; then + $as_echo "#define HAVE_AARCH64_PAC_RET 1" >>confdefs.h + +fi diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac index 798f494740..8248ecf2ed 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -39,3 +39,24 @@ EOF if test $libc_cv_aarch64_bti = yes; then AC_DEFINE(HAVE_AARCH64_BTI) fi + +# Check if glibc is built with return address signing, i.e. +# if -mbranch-protection=pac-ret is on. We need this because +# pac-ret relies on unwinder support so it's not safe to use +# it in assembly code unconditionally, but there is no +# feature test macro for it in gcc. +AC_CACHE_CHECK([if pac-ret is enabled], [libc_cv_aarch64_pac_ret], [dnl + cat > conftest.c <