From patchwork Wed Jul 8 12:10:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39966 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 888CD38618BB; Wed, 8 Jul 2020 12:11:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70059.outbound.protection.outlook.com [40.107.7.59]) by sourceware.org (Postfix) with ESMTPS id 85D913861841 for ; Wed, 8 Jul 2020 12:11:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 85D913861841 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=QxeFC5qmo+ItRdSh9AYP94EE7hhDDTCdDJUgYrLNETU=; b=NeKu1Su6bk4yCc5/xcnEJ6EaKHozkpCsWuPMGBU/+OMg/CvI8IP2LFPfAnDdT+tuagLfP0qMpDawA3bXKP7iEM282/nyRA3VUe5G/gNeQhDK0hBG0627gGv4P+lcUaDbpZVzsMWYetALRUFA5YrhmnYtYGwAu3kkNeEmgbKlrvg= Received: from AM6PR04CA0031.eurprd04.prod.outlook.com (2603:10a6:20b:92::44) by AM6PR08MB3304.eurprd08.prod.outlook.com (2603:10a6:209:49::19) 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:11:02 +0000 Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:92:cafe::ed) by AM6PR04CA0031.outlook.office365.com (2603:10a6:20b:92::44) 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:11:02 +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 VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) 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:11:02 +0000 Received: ("Tessian outbound a4b10e5b482d:v62"); Wed, 08 Jul 2020 12:11:02 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0421ed4d0df2c2d0 X-CR-MTA-TID: 64aa7808 Received: from 6c2799e1bb09.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F0F84366-FAEE-4F70-8733-C762100AE6A9.1; Wed, 08 Jul 2020 12:10:56 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6c2799e1bb09.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:10:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=niiTGUlxRmYSiGaeIqW7AIJvW3T55Qa4VPJVePJGmXHO0SvrwZqtR7kYOdu++zseAEZpgQkHQfu84XGIgtQzar8pKCv3xeqzyCw1nONY4eBG7Y6s7OkGxYkhQZxP4ryxcX9CpM2gWkFmJ5GHJmkryNf9xPKeAWVZ+16QuGKGCaq577/QiwtMgCSJd+12Yv+r0s2d41Ua0w5uqtyUv2zkNFggETtBRosbFiAD2/N+1bWc6Ru+BJ/CCHwz4S7w+MCgtExqGejU9Kdzp9IY+8c0kYqXwPhKHur1aikdtwLBp85kYjvAxeNMIPfRUk6zdI3GJd6Fj6XALS1gwH+aVu74PA== 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=QxeFC5qmo+ItRdSh9AYP94EE7hhDDTCdDJUgYrLNETU=; b=eVkxgD/mpGFDTUlrya6bUI7mY5d9AiFe1rR38aMwPC5u5LbMZYauIadwX/asz3HMze5B2JcqlEsw39RqVuNGIun1RAQ35KDNB1eupmsm5QHBK65w2MIrUX1TD2988EJQt+6+Ctpn3yNYQxydwiL6YGeoPzgAumw11ZhESH14ve9/HeoVWG3tzOq45Y0Mg6wi2HK5PcpqARr3TC5h7ZeitbdGVrBpnnuZsU/lnQQhQmAndW/+/fsZqhoZnytVIQ6L6avHY3Vb2NRWPlxfn+mQZ6oR5VStj706d4du8OxlsucNLGJBA7B0PJJmp0FI86XPNbcBGx3BKPMC5kkIMQdxuA== 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=QxeFC5qmo+ItRdSh9AYP94EE7hhDDTCdDJUgYrLNETU=; b=NeKu1Su6bk4yCc5/xcnEJ6EaKHozkpCsWuPMGBU/+OMg/CvI8IP2LFPfAnDdT+tuagLfP0qMpDawA3bXKP7iEM282/nyRA3VUe5G/gNeQhDK0hBG0627gGv4P+lcUaDbpZVzsMWYetALRUFA5YrhmnYtYGwAu3kkNeEmgbKlrvg= 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:10:55 +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:10:55 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 02/14] aarch64: configure test for BTI support Date: Wed, 8 Jul 2020 13:10:49 +0100 Message-Id: <213866f01f7ea12adf76dcce1d1404d8afa7a7e2.1594209990.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0441.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::21) 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 LO2P265CA0441.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::21) 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, 8 Jul 2020 12:10:54 +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: d93fac84-1294-45a8-3e88-08d82337fb95 X-MS-TrafficTypeDiagnostic: AM6PR08MB5238:|AM6PR08MB3304: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 67upPpBi9RFcCLS8cd6H70YqwdIREpbrszj8qHJwETkuUlV4QYJYdUw0fLHLMSXDveBvsqYssE15GbGT3S2AsepVEQo1sk5+KWgOWqz0jdGoek9sny4joJxQUpqnHfTzGiN+UdA/AP+nHYybESfjpCgJ9G19ieFCO7OBtySGSnRPqERTFG4285Xogiee0wUANbHNqjOdTFu1TCgtk2G+C+NlvsZglGm+Cbvv2VzjfVjSDcKYyZHcs0QHuy863i3JD3ZbgOOV8hdo5b9qupFTFxiqOTwdVdjz3XBT7d+0aWHFh8PJgwDf6zNkazXbAi+UOaJPX9ak3e/46cX3PdEvNY3/TBEX2mrgqYvjLXRHEsEbWu8ZL+HlwkK0U3v7VkudVrY2mXJZdDQSWiUoosgVWxqAj7Q1ax94D4eyLzdmuuU= 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)(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: IaH4GX0U6hVLMUKM5Obep/WPRVJSq4yQDx2LDyYhMz36JdG9VsupPNi/VZgPF/3H2rY34GFGYAkqkekurfhTe+Q2lB8SfQDpS4VSz1yOQ3zQAB2pGe/dl0KWsvjDTrHA2Nn5ZUYtB6K62gF6p2rkbtHxOeNHNXdsblgVGcbqLhRmxqAwyISDhGwsYDwIwZOUatHwXTzUqdBIrAxFbsliuc02t3uhN9xsRUgYgc2Lece941KHBpLm5xUP0YLaKQWiNBd9I4EpPFjXUagv3HpWuzzbTBZU/TXrdOai7/2lGkysMfRgTuDuySoK7IGlsREFtwuTdnuOEP52tdcTkybNyx9/KdWVHrOfy276lkOmlc/bPLQrFQ0PGyd9AH5m3i4hZD+eGCQBTkd3lITVylt5lU+0hIuhsWx5LOCw+9ydIBdAIxIl4F2xLSu0VNAJyZjSVDGhadIK0LLErc3MTgHumdov4OxX5CsuvFccM8mJFUI= 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: VE1EUR03FT053.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)(39860400002)(376002)(136003)(396003)(46966005)(2616005)(6916009)(356005)(81166007)(16526019)(186003)(86362001)(6506007)(5660300002)(2906002)(70586007)(36756003)(6486002)(6512007)(70206006)(82310400002)(478600001)(6666004)(47076004)(26005)(956004)(36906005)(336012)(82740400003)(8676002)(44832011)(69590400007)(8936002)(316002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 0cc7f3e8-1c47-4d62-aeb5-08d82337f725 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3d3fK0LqWeyWAYi/yFrAytjy5an5mESs7Pd1ekDbtX6bMpdpSLd7hnQsZLiYS4pbCbmV7h+zXx3IdFYlqldTc+nfa+lbQ2dvBFn5rPt0wpZMtkgsP6tmUXPEB9MKPHXfqEWQwSUWk5W0/WfBDQIn0ij+uJtDu6GhAfBSK+beNaKdd5RMTUOJMBelBuj5IAn9ip1XdtVZwzXHY4eWLzCivtCohrSJLF7iC2Xkry4OD72s4IYJbLQjl+eGLvJuhdjQgJWy72qch8IkypLa1NCo92cmuAWPk/wNzujcrzJecEpV7AQLQmUDH6b2b9B+0ZlmSVLWhDSdJmJWGc1IFQZOo+tG4LO3b38vJ+oiieWurbcU4FAbPOee/bdGEwVujk5BBHML6FOjtclVviGb9RXz1iOAIjTVzbJ6Ts6UMUU8tfTLsVlXQ9K5YKza6USbkLChvn4R99dEzDrwpMQfUghBZQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:11:02.2861 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d93fac84-1294-45a8-3e88-08d82337fb95 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3304 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" Check BTI support in the compiler and linker. The check also requires READELF that understands the BTI GNU property note. It is expected to succeed with gcc >=gcc-9 configured with --enable-standard-branch-protection and binutils >=binutils-2.33. Note: passing -mbranch-protection=bti in CFLAGS when building glibc may not be enough to get a glibc that supports BTI because crtbegin* and crtend* provided by the compiler needs to be BTI compatible too. Reviewed-by: Adhemerval Zanella --- config.h.in | 3 +++ sysdeps/aarch64/configure | 42 ++++++++++++++++++++++++++++++++++++ sysdeps/aarch64/configure.ac | 19 ++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/config.h.in b/config.h.in index 831eca2fe1..67169e5d01 100644 --- a/config.h.in +++ b/config.h.in @@ -109,6 +109,9 @@ /* AArch64 big endian ABI */ #undef HAVE_AARCH64_BE +/* AArch64 BTI support enabled. */ +#define HAVE_AARCH64_BTI 0 + /* C-SKY ABI version. */ #undef CSKYABI diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure index 5bd355a691..70477a7fa5 100644 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -172,3 +172,45 @@ else config_vars="$config_vars default-abi = lp64" fi + +# Only consider BTI supported if -mbranch-protection=bti is +# on by default in the compiler and the linker produces +# binaries with GNU property notes in PT_GNU_PROPERTY segment. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BTI support" >&5 +$as_echo_n "checking for BTI support... " >&6; } +if ${libc_cv_aarch64_bti+:} 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='$READELF -lW conftest.so | grep -q GNU_PROPERTY' + { { 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; }; } \ + && { ac_try='$READELF -nW conftest.so | grep -q "NT_GNU_PROPERTY_TYPE_0.*AArch64 feature:.* BTI"' + { { 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_bti=yes + fi + rm -rf conftest.* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_aarch64_bti" >&5 +$as_echo "$libc_cv_aarch64_bti" >&6; } +if test $libc_cv_aarch64_bti = yes; then + $as_echo "#define HAVE_AARCH64_BTI 1" >>confdefs.h + +fi diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac index 7851dd4dac..798f494740 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -20,3 +20,22 @@ if test $libc_cv_aarch64_be = yes; then else LIBC_CONFIG_VAR([default-abi], [lp64]) fi + +# Only consider BTI supported if -mbranch-protection=bti is +# on by default in the compiler and the linker produces +# binaries with GNU property notes in PT_GNU_PROPERTY segment. +AC_CACHE_CHECK([for BTI support], [libc_cv_aarch64_bti], [dnl + cat > conftest.c <