From patchwork Wed Jul 8 12:13:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39974 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 8639838618C9; Wed, 8 Jul 2020 12:13:38 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140044.outbound.protection.outlook.com [40.107.14.44]) by sourceware.org (Postfix) with ESMTPS id 4FA60386186A for ; Wed, 8 Jul 2020 12:13:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FA60386186A 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=8v7sJxWvUa6D/3QYiFKUMbVS2pVuHK7KRe6W/votENI=; b=mSr2x9IhaVp8n2KHBL3m01pL5lYISH7gR8sEQHLaBOB1gC45j9aa3dIlPmpPyaIxgp+Gfb5Vgz21CvvHJrYDtORZEj6n05ya9tHRJt5GnXKhe2y7burZwIJ7k8u0jrs2H4VEbCuANpmM/hM9XQxged9yYE925+I85DSDgk33tRU= Received: from AM6PR08CA0022.eurprd08.prod.outlook.com (2603:10a6:20b:b2::34) by VI1PR0802MB2463.eurprd08.prod.outlook.com (2603:10a6:800:bb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Wed, 8 Jul 2020 12:13:32 +0000 Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::3c) by AM6PR08CA0022.outlook.office365.com (2603:10a6:20b:b2::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:13:32 +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 VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:13:31 +0000 Received: ("Tessian outbound f7489b7e84a7:v62"); Wed, 08 Jul 2020 12:13:31 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: dc873d991303a172 X-CR-MTA-TID: 64aa7808 Received: from 5320e664d902.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A3BC7C80-2231-418D-AACE-DC8516015DE6.1; Wed, 08 Jul 2020 12:13:26 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5320e664d902.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:13:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFINai/zdKeh+pvDUYY/cpZ4IVVuxvf9+Qbvq6NmZdwe4FQJMaAFnZ/F+XcAWNgWTAg5IudpnzUNG96wEXqC0ySpEQrb7r6cG2tYORz/JpByryG0a44Ra9BmTA3W1aWilYhXJttqX7ztgCVTQ3Q6pq8sgzOG9pDJ58vMxvBgbXmPAuur31oPTcXeCSg69PsXPmtcZe78EJ5GDAqMJl328N2Lmf81/yjYb5ITFXLbfuw3BNoFJ86BAXENXikMUQY8iIqg5rxvA04u7qdQJr3hMgzum/EdYau9Qd1I9W1imSkxbcwEzR0uwhFv6RLTT1S369zfwhwHFYQiaQllVm12mA== 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=8v7sJxWvUa6D/3QYiFKUMbVS2pVuHK7KRe6W/votENI=; b=Q15bR/vLOxQf5x25DgxhedIQeD/nNRsDeadJYyMk3GL1vBNi5CSKAaIX6HwHQSvmVGmKKw7VIvjF4iKBM4iXJ03Q6g2lyO61u8v3cykt2g3zYgKNavdcxuOw4GNNFz2BCl5XZTMczshCz5Q+vfXuSLvmiIVXMY+cx/SpWIQLFgLHBXtw37Eqkrlrj9EUX7Z45MrETPDbzwGnVTmmKzIl/dovJO4vxUh0r9zW1fcO9MxDyp/T335/AKFOGJof6HA+i1wghd+k1UGYde8Zjz2fFq7/zQGytQVbFZQSlK0vb+MlMMbA9sBQmBPyIRFgZZeLgI3MG0Ssj4O2qb6T18RrbA== 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=8v7sJxWvUa6D/3QYiFKUMbVS2pVuHK7KRe6W/votENI=; b=mSr2x9IhaVp8n2KHBL3m01pL5lYISH7gR8sEQHLaBOB1gC45j9aa3dIlPmpPyaIxgp+Gfb5Vgz21CvvHJrYDtORZEj6n05ya9tHRJt5GnXKhe2y7burZwIJ7k8u0jrs2H4VEbCuANpmM/hM9XQxged9yYE925+I85DSDgk33tRU= 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 AM6PR08MB5238.eurprd08.prod.outlook.com (2603:10a6:20b:e5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Wed, 8 Jul 2020 12:13:25 +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.3153.031; Wed, 8 Jul 2020 12:13:25 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 10/14] aarch64: configure check for pac-ret code generation Date: Wed, 8 Jul 2020 13:13:19 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0310.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::34) 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 LO2P265CA0310.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:13:25 +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: 9015c087-0f0b-4770-7fa4-08d8233854a1 X-MS-TrafficTypeDiagnostic: AM6PR08MB5238:|VI1PR0802MB2463: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3276;OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WLASQ/lREoDf4TkHtHJD/+dx93xLRX0nVyVTBHNZ8IGoJYgCZ55QBJhgXR/FHohXpubT/k0e0xrYdGOSWO27vlxm/Cd1Jaf8Lg54OPULutmb8+NjmogFMvxqTkennppzgKGPj6Hl0v6ot1d8ZdejqROAszEgXI+QGnQVKPHtvxn1CN/+jrZtJZ7C3qEJz1Xk9LAotiI37vvnUR2uPSReTQNhDO3HBuze9kKnA0KpMpkpiuILdfq6HQ6W0U3dPOxl+6EI9TqsnhVDtl/9de+V8uYhkyGVjLbjl1SlGmHAauoHabaDjxad0vaIHbJqbxL7LPrpkdSx4bIsoBCK5zXGv8kJaVOBu5YTN9QCFw9OXji+oxCzzds90mPqGJudtkecBcsPDxr9VJbuwrhDVrmaNMcRWR5G40fIv+NzXZu50ow= 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)(396003)(346002)(136003)(376002)(39860400002)(366004)(44832011)(6666004)(26005)(8936002)(6506007)(8676002)(83380400001)(956004)(478600001)(52116002)(2616005)(86362001)(6916009)(66556008)(66476007)(5660300002)(66946007)(316002)(36756003)(186003)(16526019)(6512007)(6486002)(2906002)(69590400007)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FoajxVOozmzzvVDK4NlNwi1RV7Ci+JviGp0zmwtbrXXr+aLGEek6kfUnbu9aDIZgiTfTfHcVLnMx/mmvWPrdwagXx+MbHBOATlht0a1GdCwErPZpcbx6zKLsWb+i/VpFIR8NttCKdc8vrgfMYXfRls7NAamO2zapNnv2ZraQh0K+c+sHv4xsc7NADhGW3zi7cqr5AmjsWXi/8AfUSu6Ibe3+g8SFTsyugbztbZgIxtJCIcx5UmfHLF0VlCwaJiXT4jlTKqjTyhFzs6kKh1UnmGZyw4ykjvPS758k3jqkcH+qN4KIWfMatVH5IEyLc4D9svGT14ix+QHEcL0DyAYOGAkFMwI9TW89Sm4DUgFqZxV350OIkP1ow22E2Didw7pc5mNBuAGylnYVI1VgFNNUg+DjTEZXx/h5+AlNwaZsfO6Eggzfjgu7AgnMgQLKg++3XsIvAwcCvXr5+UOJK/a6VHgiNjROVPaQG9GyKOMBZRM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5238 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: VE1EUR03FT049.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)(136003)(39860400002)(376002)(346002)(396003)(46966005)(336012)(16526019)(478600001)(26005)(8676002)(6506007)(44832011)(2616005)(956004)(6666004)(83380400001)(70586007)(70206006)(5660300002)(69590400007)(36756003)(81166007)(47076004)(356005)(82310400002)(6486002)(82740400003)(86362001)(2906002)(6512007)(186003)(8936002)(316002)(6916009)(36906005)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 1afae974-2fcf-44d3-9aa7-08d8233850b7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qMDRC8rJmZoZ3rVE1qyqJko1cVOuCypWJUbjuw6G5mDLNtSTVLzr5Qbr9y/uTAu83e2ObtLU3HTpePbCi+f1hFGVol4txnhnEcc7wwdGjsaHfgI5H51jMTL9R9CwR5h4DXIJaqmdrePYkeVFz2V/EURZQ2GEe81nWkL6lEXrF00djnB01WtVhotaXFG6W6Rp6lbO5MNuqff75TuK+NOMYtBZ2Bxs18xVjWYcJN/COE9URMnNnz1hoHvPSwVwtlejPPYSaJsWrUnum6NnUwGN56g5Eve4MLnr8MXyoGm91y/5OtkQ9+eGRNUG3UkD5IC6B42G2aDZPh3tLQATW2hFKXbAGffAJ5r4vgfzCttJOvec/MyA/037BNerYj0SIvybeyTrnXEJCWfHzVRcbOXMUYoqMFZqLeSe3HrJVp19HJRRBZrHe/TuxaT+dzFrdqJmKOEtBTuHVxOZFeQDdq9rcA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:13:31.6816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9015c087-0f0b-4770-7fa4-08d8233854a1 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: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2463 X-Spam-Status: No, score=-16.0 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 c637540436..ac3cf6fd36 100644 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -216,3 +216,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 2c2817514d..8b042d6d05 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -40,3 +40,24 @@ LIBC_CONFIG_VAR([aarch64-bti], [$libc_cv_aarch64_bti]) 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 <