From patchwork Mon Jun 22 14:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39726 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 E3602388A82F; Mon, 22 Jun 2020 14:01:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00046.outbound.protection.outlook.com [40.107.0.46]) by sourceware.org (Postfix) with ESMTPS id 27A39388A83C for ; Mon, 22 Jun 2020 14:01:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 27A39388A83C 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=GW+tfOvtVZMvO7ibwcBmoUUER3XImR8n7i7lyBp7ACNpBtNa5rzVEn9R5N8vmII3rIiS1IGVnSw32E96aIsugRL1cz8+7WilrHGLo10MmcuZdVdRE2bNLjQTUlVEeosWpDrHpklL4+jCtoCCahqCed5/3MBZkFTJEy9uWGALS6k= Received: from AM6P191CA0067.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::44) by VI1PR0801MB2111.eurprd08.prod.outlook.com (2603:10a6:800:8d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:01:06 +0000 Received: from VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:7f:cafe::8b) by AM6P191CA0067.outlook.office365.com (2603:10a6:209:7f::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:06 +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 VE1EUR03FT038.mail.protection.outlook.com (10.152.19.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:06 +0000 Received: ("Tessian outbound 8fb20e43acb7:v59"); Mon, 22 Jun 2020 14:01:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fad9aaee73ca51e6 X-CR-MTA-TID: 64aa7808 Received: from aa30dbc25193.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F3FE66B0-6D6B-4B84-B70A-0F9DC6C4CA06.1; Mon, 22 Jun 2020 14:01:00 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id aa30dbc25193.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:01:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lWyNP8ertlrUgSBwKum3EjYKNvcyj44doH9ayv1BvQiCTM41A7zNhoHc/mMJGKZFRu4D5UKeIKDMU3B8+VLwkWGPiHqZqo6g31eptpvw/sq68pEJc4jMQo2Tcdyf5tUyywjiA8udEdEy7l9HsY2j6N8IoAubVsif/CByUUz4dsdqLgy5kIAzM9y/n7n90sAnKFgruFJaLXEr26o9sT2iXyp+qnjX8pxLxb2nbKKAFvwkGXe/T5hG+W23u2gnJlSoq2WjKF6IKgZzUL5H6tov9yLBFKWm9uvck+RUjtr99WASkV11JguclDwlSy7e3B384NS33/6IrEHICCPCaJBakg== 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=jyrnLpia34pXoJ9cmBEOEpMPcqBV9ntgOtBVWXbegFEmEo5UxCeeNP/swkD8+HvCjuwh14g8ifT4iF0FL3rct/qFIrFeMQKlaRNAJz6Mb2IPWGBfRWchYn8FVwTW+dBnimV8gW19oJFcKm7TYqt1tyIVeJ9roBW+kpActrM/97EDUB37p+jtXm9A/pkMpAIlZnsny82CtcF29pMq8Ish+7g7Z/EiuCct4u68eqSVAPm+vWyLQc/RJO3RPUOq9VCt/tUl/xBv0n3rvdM1SsnLRlHmnCcvcYN3nPZUCr+2YBAeRRR4eEQH1Z2E82a8HPTkC0ePt4uTsKgSaZT0cb3+pw== 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=GW+tfOvtVZMvO7ibwcBmoUUER3XImR8n7i7lyBp7ACNpBtNa5rzVEn9R5N8vmII3rIiS1IGVnSw32E96aIsugRL1cz8+7WilrHGLo10MmcuZdVdRE2bNLjQTUlVEeosWpDrHpklL4+jCtoCCahqCed5/3MBZkFTJEy9uWGALS6k= 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 AM6PR08MB4344.eurprd08.prod.outlook.com (2603:10a6:20b:74::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:00:58 +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.3109.027; Mon, 22 Jun 2020 14:00:58 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 10/14] aarch64: configure check for pac-ret code generation Date: Mon, 22 Jun 2020 15:00:52 +0100 Message-Id: <660c83073d49a06756a759bb511532a385e268b2.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LNXP265CA0023.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::35) 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 LNXP265CA0023.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Mon, 22 Jun 2020 14:00:58 +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: cbda2cb8-6b1f-40ee-3cdc-08d816b4b526 X-MS-TrafficTypeDiagnostic: AM6PR08MB4344:|VI1PR0801MB2111: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3276;OLM:3276; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: tsACYgHVPemyRV3ftUF6hzsqsLXdYJsDA33aZZPOoVdevZ42Cg4GaJj+5iM9biwBRvTaQhAg9k7x9rIZk7K6xxziTx7gMw+ZVrtr1KA7pzmgv5GzYsDKkKyfw2N2zD5XaCIylnFhEwpPNuGc7mPym8hXUMm+Q4lEda/BE+jI5x5RAwNioIzBOswcxi9p0FNh+5sR3yL29XAuPLFuaVq1YwSZW/90u6MwuGD9J6j/l0uJwJ62q+hWQG0bV11JgUu2Qd8sXXG+Igb0cfgkL1/dIPBn9UBWJTZYXfAye/SttyzsvCMSFdApVhEWr9wW8bXIDt0kef3LLQfABhoz/fyaoiKRqMQr482uceoHw2d5acxnLinNvnh8KVO2RDyECL8Bo/Ud5zC4t9PJzzRlSfrLHhBYhEqy/Ev++TDPIDeqlLU= 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)(39860400002)(136003)(396003)(346002)(366004)(376002)(52116002)(2616005)(69590400007)(66946007)(66556008)(26005)(66476007)(6916009)(956004)(6666004)(6506007)(2906002)(186003)(16526019)(86362001)(6486002)(44832011)(478600001)(8936002)(36756003)(316002)(5660300002)(83380400001)(6512007)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Li+ZojSrLANO/u0/NvzDcPo3DkbJBJxVTDXqmFgXb3ON/n+rEq9HxCXIJXumsEuIXPWUsS0dtmt5Vs5U1R/45BP+KovowgFPMxVK1JigXdDlBQz8wJuC1m9zdju4Ud9gnY/1xPpkkO1VELP+YAmOD/FsxNy+qcXP3kTDlCAYQFOGPCBc5n4ZBvw+Li9eURz1aYSTff2QWHjJSa7uCkCfGSCZZM9dSsjIehxbP481pxVBVWli8YUwqcQTFq18m1hsPFR3hRTeb/p0F8JcciZAirVJtnHe33tROisNDu5G1VkSqNhV7B0GpOwHf3AqfZSyJtrXnEke7lpGfLclE3kNqIWfAF0mdtTnB994w1+MBz4O9sw2i6MJoudU3EfYHG/OkmxNluhc1AcAKNHpJwph4G609e47ozr33InwHRrar5oSb4FBNXWpZd4RtijwBG1pRgBYccnEtBWJRTWKK223SVuxPmVKa5nD/RvtifTKOrDDRguxbrJS9u0QDa4PrVdJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4344 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: VE1EUR03FT038.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)(376002)(396003)(39860400002)(136003)(346002)(46966005)(47076004)(478600001)(6506007)(26005)(16526019)(316002)(186003)(69590400007)(356005)(36906005)(82310400002)(8936002)(2616005)(81166007)(5660300002)(2906002)(70206006)(44832011)(82740400003)(70586007)(336012)(6512007)(6916009)(6666004)(956004)(86362001)(83380400001)(6486002)(36756003)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 9754ae84-20d2-4b3c-515b-08d816b4b091 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kQYU3Xjk6EVIYt1bFxT8HvLD7LFjpsN0QPKHv4Kvnj9OeXQ8A05VmJlmtACqph2bezF317xuN7G7NHGuQhVGqAy6GrVQCI8DjsjVL29YgFGEdlx89NKqS+9fz1+UzOvpUW/H5JJV1mfGpHkgqYqvDG79vYaozQRLB6c/pUw/DXqtMqQumW1I8/WTCbNrVEqnzh2Qkt1J/twJIZG/z7XYUcPSdH1FcnCg5l1pnmotJKBNENP61ZfF2DCnYSrLl1bOm6AEgL6j8mwoJ8eCglf9PPMpayK6D3rU8dhN0oNEcrZUw+GtIweGqmJHGI5pbvQ6YSwbXkPW1byfj8mMBsrnzgEIbTPIzxmRRaiVTExIG+1ZlUJvrBfuK5kmJvFpEGa5+WH4qkmYbBjsw2l+tUa58Caa2TDSKka8kLY1TC1aJx+9I+BZeCBIq/ug3ViryYfXIrmpEWtrnC89fnXUm/oKLA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:01:06.0902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbda2cb8-6b1f-40ee-3cdc-08d816b4b526 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: VI1PR0801MB2111 X-Spam-Status: No, score=-16.8 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 <