From patchwork Wed Jul 1 14:40:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39870 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 7DADB3861870; Wed, 1 Jul 2020 14:40:25 +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-eopbgr80040.outbound.protection.outlook.com [40.107.8.40]) by sourceware.org (Postfix) with ESMTPS id 18026386186A for ; Wed, 1 Jul 2020 14:40:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 18026386186A 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=9bD+YvgJQWH/uqGG078T+1jWr0V27a3vqMC8tft2FD1N0RAu+I/HHWErLF74pDMS0i8NzDUWbx8YmH5Tzj/rTi5WPSQ5ENPO1mllkR7aCmjuKZ/rwDFqOmp4lmcTm6aPxuIoAJRIBRvQ9g0i0v+N5WbfpoektvBVPcoGkMjDsBo= Received: from AM6P195CA0096.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::37) by AM6PR08MB4788.eurprd08.prod.outlook.com (2603:10a6:20b:c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.23; Wed, 1 Jul 2020 14:40:20 +0000 Received: from VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:86:cafe::73) by AM6P195CA0096.outlook.office365.com (2603:10a6:209:86::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Wed, 1 Jul 2020 14:40:20 +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 VE1EUR03FT023.mail.protection.outlook.com (10.152.18.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Wed, 1 Jul 2020 14:40:19 +0000 Received: ("Tessian outbound 2dd9eeca983c:v62"); Wed, 01 Jul 2020 14:40:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d810ea14bc52b1f4 X-CR-MTA-TID: 64aa7808 Received: from 294259509533.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 06874060-07A7-4902-89F8-F1DEA5426AF6.1; Wed, 01 Jul 2020 14:40:14 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 294259509533.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 01 Jul 2020 14:40:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dRVx0UkZdQJgD/uDCxonRkVggP430hqzn2y/MUxYbbO6jgOlAZDpJhcEFE0Ob7N9xliq8X7XuLs73uwXBIopfaHtC546icJ2bp7pf6kvSbkt/wMti24hS7ZeTPq6LVYUS+kHD39C5gld+3ubGG0c+/FmADwuZtJHB1HBWrF4kLFmi2wkaVKPotzEQbBKAg8YLzZyYuEXTI6iWuH7k/An3FnBcYZ7WA7kafC3NfcrTIcCmWoPpcIPVjaen6xWSw8gwpcK5RkU3788TkakIST7fntP7CwKtspnD+OFQHTAtUcLkYuoudB8ngUDPP1jLHU39RQZZCZE24MV0ihrtw1k/g== 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=Yl249jM05lIhRF5sGGJKBMmOiCa7jj/RpH5W+lfIuwcCzP4ycAjdYWEO4ZEyF1h+gm7hi494SQyd0pO9e5QAogbVa3IJH2OFWU8Lia8yl3Y3NsX3RWDqrOdUBDVQmGx3mLv61lZit3UlxsjJOIxa36Ofa8n8C8f/RdW9JavxLyN5uPuyi+sB7SNd1nXaTB+8QEw+SAfWRpraE3hSVKZs8f4F+9IrV87Xz7+i6frmAkHbMhfTZAKC5XohEKnspv5CzOfRedQmI1l15Ev4cS7mdNKCfYu6j08gYyU0nPk3iMoIywE21hCE2XIZafnPMpmhY1JUFSYcAxnpQabnntbqUA== 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=9bD+YvgJQWH/uqGG078T+1jWr0V27a3vqMC8tft2FD1N0RAu+I/HHWErLF74pDMS0i8NzDUWbx8YmH5Tzj/rTi5WPSQ5ENPO1mllkR7aCmjuKZ/rwDFqOmp4lmcTm6aPxuIoAJRIBRvQ9g0i0v+N5WbfpoektvBVPcoGkMjDsBo= 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 AM6PR08MB3832.eurprd08.prod.outlook.com (2603:10a6:20b:89::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22; Wed, 1 Jul 2020 14:40:13 +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.3131.033; Wed, 1 Jul 2020 14:40:13 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v6 10/14] aarch64: configure check for pac-ret code generation Date: Wed, 1 Jul 2020 15:40:07 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0476.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::32) 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 LO2P265CA0476.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21 via Frontend Transport; Wed, 1 Jul 2020 14:40:12 +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: 167d3a07-9c0d-458e-666a-08d81dccade4 X-MS-TrafficTypeDiagnostic: AM6PR08MB3832:|AM6PR08MB4788: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3276;OLM:3276; X-Forefront-PRVS: 04519BA941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: a1bnmg2mvWfmA64Vr2uIfyUbA/NtlaRuIJeHh1tg9VjTuqSR68XVYpzN86zmmdgWobvlY5jxzyBXiQggcVl2Dr93fZZ+/zoR6LSiwSHUF8PvV9j1ShGz6FNp3bBR2vy6U5jSOZPWUUH7OwxLcT1BxppZEQ/k8e4QCr345KWOMvaOHcRXEOEaiZVABwwYPI/x7Awl4nRx7dErnkTuekSEMK4Qh6OuR8IZTdhNZT/EGbyMD/QVusW5NQPhRcqWAHyeJo14y5Q2zts+2b0hrPVlnWHR36AJwty8Tf9yhiD5fHVDkttZk9KD42EGHS7WUx4sGW9dM/Bms3P23flFgPI/zXUIQrilcpY8UiZMgRjkFJUf4oNNmrqW8TS81ra8Z+YVH3ZHmdrMicTB5FzEbkhsE5Q6cq9HD+QV4x9xGCc1yM4= 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)(366004)(346002)(136003)(376002)(39860400002)(6916009)(44832011)(83380400001)(6512007)(6666004)(66946007)(66556008)(66476007)(52116002)(36756003)(6486002)(956004)(2616005)(8936002)(69590400007)(186003)(26005)(8676002)(2906002)(86362001)(316002)(6506007)(5660300002)(16526019)(478600001)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: et4zQaWkESXZUV6wdDhPtkO/5Vr3U/FyiM/6VhOK2qx4PVVS/xbwEwY5zccCVQdmzfRymiMBWcQdRGqz7sjbl0Wv/kzWvG6zFw1qzI500AXOj5ye8h1/nmtUgbydSKuKTppTdHGQL+6oVQwTVd+EPuUzAp5vcCgTrZ+Tn7AA47Lw1lb+cz9+q8jcdm1+bSRYKTXbIPPUfWRC1ElLGSIWl6B1VKCM+fI5upIaNMSylG8cVCcSxhnS2w/mV4cgd0KI3UyMG+RjrAGu1p0udrWuSHqBzvPIXG3xZg4VCpBzb8UZZlq4B6SZc8AcZ/ytamGfN3ZkFsz5YHopNlVGmql/22DYoe82P8ycwmKISft9dtiGK/I6rlSFYRYzpxKTmGE1cEfMBK3lx8/c48u1AE2g+i71fGJrR3MCJIJqe7FyI5zhzSPJBgeoKVpjSnkwx3ueb8pWVewdHAgesDLBoK3Kq/N+ZzlxwsejQYbu01sdwzI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3832 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: VE1EUR03FT023.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)(346002)(376002)(396003)(39860400002)(136003)(46966005)(956004)(16526019)(186003)(336012)(6512007)(8936002)(82740400003)(44832011)(36756003)(6916009)(5660300002)(86362001)(70206006)(6486002)(70586007)(2616005)(36906005)(8676002)(316002)(69590400007)(2906002)(83380400001)(26005)(81166007)(356005)(6666004)(82310400002)(478600001)(47076004)(6506007)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 0a88a140-3537-4af0-f941-08d81dcca993 X-Forefront-PRVS: 04519BA941 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CZsQPdUVabkfBL8SnNAgqsKpwbWKsqaz5dY9BLRkxxWOEmgRpl+6sDooYjkHBhAb8V4O7mj4VZE7VXzeNCIgezWe82WtnkuDnV2zBWNMAE2xMVuYYaupxbzr4SvO7K2r5YwFTTnA1EGyLHRnJ3SAV3SZdOCMOeUuWgOHZatqPxEwHxptJmqtRr4qI+FrUX12f/Ajb4vOjt3lbCf75PVNV7B0ijW6dH4MET3c3PEMoggqRCXTCKooTvJHYPZUvV//ex9Ye7v2oMUtQI+6sXl5dHxjAniIRbEbhD6NwWi3dgFkzr6+Vt9HW19NWM7/sF73PKlb+OhcWUONjN+DbDXYf/KpeYQNLI5FH00OlknuArw2PXP5SQfWjEMZS9pu9dsBMEtPhJLHG+/SIaKqjRACFefbIK8jpeiFX3C4rTp1SR39Dlnfg7zr1Dy96BLE39bxkiXv81RgmlujAbmSu0+L7g== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2020 14:40:19.9466 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 167d3a07-9c0d-458e-666a-08d81dccade4 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: VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4788 X-Spam-Status: No, score=-16.3 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 <