From patchwork Tue May 12 10:14:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 38963 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 7C9633954C76; Tue, 12 May 2020 10:15:14 +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-eopbgr80075.outbound.protection.outlook.com [40.107.8.75]) by sourceware.org (Postfix) with ESMTPS id 72DEE389780F for ; Tue, 12 May 2020 10:15:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 72DEE389780F 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=iZh5KL8Go1oj+k9t8KzDO6b+0S5YUJTizL+ZLniEr7k=; b=HAMD2B0Jc9yTKZcDcuG0pS2EGIxccnNgwy8QAkV0JwhcPVhIeKOSXnEWIT2Cp4chmFGK0D53DwmeDIJTiu8Tv/mWOm2YOq6wvz9LsgItLelpzDB9gW2i05zQ83OQbuJbu2vXmcTJbFvBm17ilkNBAKsGBorviDul5o4SdEHCZRE= Received: from DB6PR1001CA0024.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::34) by AM5PR0802MB2435.eurprd08.prod.outlook.com (2603:10a6:203:9e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27; Tue, 12 May 2020 10:15:04 +0000 Received: from DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b7:cafe::46) by DB6PR1001CA0024.outlook.office365.com (2603:10a6:4:b7::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Tue, 12 May 2020 10:15:04 +0000 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 DB5EUR03FT003.mail.protection.outlook.com (10.152.20.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Tue, 12 May 2020 10:15:04 +0000 Received: ("Tessian outbound fb9de21a7e90:v54"); Tue, 12 May 2020 10:15:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8ae9410a25c3b333 X-CR-MTA-TID: 64aa7808 Received: from 568c2952da1c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1C552128-0C31-408A-B814-01E2870D9A8B.1; Tue, 12 May 2020 10:14:58 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 568c2952da1c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 May 2020 10:14:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dh6ZCzYeSkMZFjOZHvd/byvUkJhsLfaTFN3Ko+ABIt8OA5mxD0pkeV1DbjL23TGX64xclek1y4S5V3d7Rmz479s+aQqGu5LR9JfVlwJKQ5G/66Tm2vrKV2H3zt9agAazyavuSqaJatH1Ocym8NGnqrxTlSElclxMvGaWbyrvHMHBP7R/KceBtLDWIaJNvY/QSle+mUO1UUW4FN1Ask+qHPtCP1piB8relCVrdgGHcToK2anN8mNoRxB0r9hcy3ur8Wxe7WYvhF2CqaJGPbCf8YpHcSGniwYOWk1vAVuIK/Y0IOmRAlA9RxMMuH0jGspTc3w92QUJmyJxBM7tL3qbqg== 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=iZh5KL8Go1oj+k9t8KzDO6b+0S5YUJTizL+ZLniEr7k=; b=FOm9BeVSi3QcostbobjvXvQwR6GzPBFzZdRAQcpTAyxpHTRf/6k2bu5irPoX/O/7wGyHYhiQs6o9w7dH9s/9l/2rAhZPnBqmIr2AmTyEuhXnVRPumpWnW1mM2MN1rq/TsqsOhlOyPTfuN/iRK56chvyvxVR7Dz4XtTh/lVF7sWNiIYESpB4GAIBNUUzY6qTUxOupuACGGZVhEA5Bx+hjppH8uYJIB6N7KFMQEReIH74t8rf2yIRmlGnygF3jDZmzaizJA5O9Gsbpax73djZUupDtlH+cyvt6p10zC8civUpUDXVgKoHYOlahopxjHTSpJVLSdw4eh88RpekW5VHqiw== 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=iZh5KL8Go1oj+k9t8KzDO6b+0S5YUJTizL+ZLniEr7k=; b=HAMD2B0Jc9yTKZcDcuG0pS2EGIxccnNgwy8QAkV0JwhcPVhIeKOSXnEWIT2Cp4chmFGK0D53DwmeDIJTiu8Tv/mWOm2YOq6wvz9LsgItLelpzDB9gW2i05zQ83OQbuJbu2vXmcTJbFvBm17ilkNBAKsGBorviDul5o4SdEHCZRE= 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 AM6PR08MB2982.eurprd08.prod.outlook.com (2603:10a6:209:43::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28; Tue, 12 May 2020 10:14:58 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::49fd:6ded:4da7:8862]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::49fd:6ded:4da7:8862%7]) with mapi id 15.20.2979.033; Tue, 12 May 2020 10:14:58 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v2 04/13] aarch64: configure test for BTI support Date: Tue, 12 May 2020 11:14:40 +0100 Message-Id: <0b0dcdd2731b75a82ed9802a9f52be72babd32ac.1589277641.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: CWLP123CA0056.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:59::20) 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.55) by CWLP123CA0056.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:59::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Tue, 12 May 2020 10:14:57 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.55] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3451d0d6-2c86-4c99-b314-08d7f65d56a0 X-MS-TrafficTypeDiagnostic: AM6PR08MB2982:|AM5PR0802MB2435: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-Forefront-PRVS: 0401647B7F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: G5I0zbtiVyWHD6Q/93h7Mg3Ouo84NbhcwIH2mQk/viXXUyqJUolzAGEgklm25Q0okq6K40MMmkrpgHYP/ezBcs1P0FhdtQxNqNyriOSg3fKUazl2bKFZB/BpyCEEE728HHEFmvFf4AFjixFl5BEC4Z3cjQpUo3XwQxG9/lbZD4uYm5MMWQiV+L/QzPnPtVvDOWblXqCs8PF18L6Psi3D6pIz7pSCDNP4iw5EVCgI6WgoSGs6A4flXsF9WtQ+t+MbMFuEWtvyvq3zqTNoijjBSzJoBC+DgVw2qD9aIQDAIRIeuAvdTBYAfnflWwAc73yRqKWWHvsqn7l0HnjTSko1/9/rbrI0HMAmSLda5J+qJYcdBOIf0Ue6Og2SEuNNsqwQkD8kjWZymvhCJQZaQivSGl7sO5Z1Yb3qWaP4EXTAZ0kOihwl7oHorhDJ8Z+O4ya6Ub6MTuv//LeP5ZcPOe5ftVpTMo1GRAv5xQRoMuPlwVUrxDynCB7QZHV9aWovFzhcFap4I+zGHgdIWaWUrw7io50koQR+XU2WDjGuxcb3xJZqZPS/Qh0TnSLYYiOBxfmkcMSjF/GxWPeNRnW7gO8itNkfngRXN2tBiYbK9BsG40M= 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)(376002)(396003)(346002)(366004)(33430700001)(6916009)(16526019)(66556008)(66476007)(36756003)(44832011)(5660300002)(52116002)(86362001)(956004)(8676002)(66946007)(69590400007)(2906002)(6486002)(186003)(316002)(2616005)(33440700001)(6666004)(478600001)(6506007)(6512007)(8936002)(26005)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Zw/7GEu032nCKqbzM9Z9Iipsoqfffq5pTv8DUQzMLiKQ18xtvMftdkOt7iXQQXIS4JfjbCRxxwuWEuJNS/3IvKM8lBg75sDtP8HUNLIc9u5vGrVqbEUKh+GBXDD0bd16nJajgJEdheJfutJ6SduHDy5bQ7LS4Q0XhXZ/LkitjlHOwNEokJXorxxobSbjCptzWxr9ISna6k80xQOPFaDjRitKygjMDqVXIUm7Smq3TvHWRmLHc91CDE+hk9ee212/vG+t8oeId1FDqgMH4lI5pDHEc7S2+MLAAw8BcIAY6T9+IRnMPAj22n3V2BGW35bzcMfynM7pDUml5UXAjdDebBf6ElyGRSG94UufgbWzaF/3IuQ4KJPpe8nW2+axaIwvR0fzBZoenhYvcX+9Kcwsb5ob96EFUg+7C64eA3rYYsg7tWLBm99ffBz00f0haiZYjaclFrYxkcoa0gDGwLAtReg3ZooBaeXIg1YBECOkZgk0YMFWGZDm9HYVG5Z5PnGd X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB2982 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: DB5EUR03FT003.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)(396003)(346002)(136003)(39860400002)(376002)(46966005)(33430700001)(82310400002)(6666004)(6512007)(16526019)(336012)(356005)(956004)(44832011)(33440700001)(478600001)(70206006)(26005)(70586007)(6486002)(2616005)(36756003)(6506007)(6916009)(2906002)(8936002)(81166007)(186003)(5660300002)(82740400003)(8676002)(69590400007)(86362001)(47076004)(316002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 5ec3ddf1-3b4a-45f4-f8b0-08d7f65d5287 X-Forefront-PRVS: 0401647B7F X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M4RPL2SPAwZzBmI1JiwLQzc/BSGaDHLhlEYzIPKj/W0jTnYBa748Q9weAnAUy4UteJLm5D5pSZCphaz5jraAxko0hTQxbJMApb2fVzNDkpNNoryK6raareI/DpZlSKUIYG1j3nKkELUvif7MAFkt/kHbcHj1PXxhvb2q9lDyRju9mgfwQD9r0JSfgEpy8+cAeAjpitiVuxCTjXqHU7YKC3HGUlDG9XCBMQSC6jwPOtyA80Uh6bnaZSasuAQoafzmXrA/H8Ppxe+bVE1kIy1KKgUD6zWRxEFnv/2tjpM/z4yD1DDtRKdnRs9z4jVGUMYUYs10/JocYQcj/+ftdnbPQprZF7JbGRzczmYdt+r0orDRWZKCAqUyA7Y51Axp6skvcvQ/l/+hr5/wW8mzo1X0XZ0KKEJylkbe+q+qyrtv7mJsoScC3GR7GT1tzNsoMw8SusAJqLODGopqpIj6z4/NbaJGarw8hmP0Z63KjGJSyuCiGWVMHUgyxHQ4sv8DgsC3fmFLzH6gKdiMEHBi/1TY09l4ba8kwoDfMlSJCPBF9GepasJjZ7PUrGa6SKj0FAgQi4SuJLcK0/jibPRwEcl6GRwz2Wb7GL67+Q3aturvXFIlbdVostBB0POsmlmp0PpFQVVOHcIUU5KyJzz4Klg5RA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2020 10:15:04.1908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3451d0d6-2c86-4c99-b314-08d7f65d56a0 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: AM5PR0802MB2435 X-Spam-Status: No, score=-20.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. --- 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 dea43df438..506b0c416c 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. */ +#undef HAVE_AARCH64_BTI + /* 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 <