From patchwork Fri Jun 12 13:29:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39574 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 DC115395B045; Fri, 12 Jun 2020 13:29:57 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30082.outbound.protection.outlook.com [40.107.3.82]) by sourceware.org (Postfix) with ESMTPS id 75896395A831 for ; Fri, 12 Jun 2020 13:29:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 75896395A831 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=fEi7LUYSbc6kJcZwWclKwetJ3pn75Ey8g9x1dXZ8Ak8=; b=YooEMRt3UcNDQDm0HxBjVFPVefbO54CzE1NeYmx3rSIskldpuUC1OC1gfeBNlxKmBgvoCxY2N5OoPs8bRqzkHiKqPM0gCSlqjP14gLOYPjFEEHhM9og8Piq9UDkvRBoMiy91/KfbSb9VMO0fH4HevfrMsRrVM1dl8zQNBJkCklo= Received: from AM5PR04CA0014.eurprd04.prod.outlook.com (2603:10a6:206:1::27) by HE1PR0801MB1737.eurprd08.prod.outlook.com (2603:10a6:3:81::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19; Fri, 12 Jun 2020 13:29:51 +0000 Received: from AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::ee) by AM5PR04CA0014.outlook.office365.com (2603:10a6:206:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18 via Frontend Transport; Fri, 12 Jun 2020 13:29:51 +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 AM5EUR03FT062.mail.protection.outlook.com (10.152.17.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18 via Frontend Transport; Fri, 12 Jun 2020 13:29:51 +0000 Received: ("Tessian outbound 1145f7a293ca:v59"); Fri, 12 Jun 2020 13:29:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: aa842ac9c1c68abf X-CR-MTA-TID: 64aa7808 Received: from f222e7764416.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F79F5542-0F42-4BB7-8A33-10C46F851328.1; Fri, 12 Jun 2020 13:29:45 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f222e7764416.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Jun 2020 13:29:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B3F6Yt0TlFDr34qm45zQpHiV8SEfkAiWlHu6Nf5wJF4hmGZaceiWXWSbmwyS4K7WXTU1OIE7dQ6JJNqNODwfuW3dEw68192qi/EQj9xMlTyyUaoTH36tx3MqMVQ/aVxCB7C7XzwAjgRawO+pC3MmMkO2n4JBF6NDWAHsHSZ5PkrZPe2ZeCNU2axpuwmhBsn/j7rDUz5pNffK9PXj+4/TtgJWZqSbArp4WLYrtCiS3k1bxX26Ji6S7/V13C5tLebYpYX0NGC+dAcVRebpjSImxQPHnIqZh02CXvNqcLYgi5HWmAGw5JmtFt6mvj2lsQq3hNZSHzSR7J0kcykj3TGqoQ== 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=fEi7LUYSbc6kJcZwWclKwetJ3pn75Ey8g9x1dXZ8Ak8=; b=D/nDf87svi9uiFNxpuV7dE7HPtyh564KIt3djoiI5VKyA/SY8unLFNmC9CrFWRNMZjlMwQ1R4C0SaYRMqRSrlcdpv0/2qoPfE+/yVTudiQcS7evzeznsK9KC5MQ/dKzD8p7lZPHsAbZ/f7spgsrpBJ7KXUDvu52NuZZwoumLeWStVLOMYRoj6go391BeqVv5Zy9+fnkEHg8iTmYseVJw3TPnkjywgAdJiCp2A9ZkUjeRbtI0JhDcDzIS0dUm2LRJPb4XVpvIAVl2CGEvAQaK2/n/Rv6iDCEVRBCXOGepAKXtrEyIyHa8QuD1Qjs5VxuNUl1qKn7vsgCFGfGCUfFEzw== 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=fEi7LUYSbc6kJcZwWclKwetJ3pn75Ey8g9x1dXZ8Ak8=; b=YooEMRt3UcNDQDm0HxBjVFPVefbO54CzE1NeYmx3rSIskldpuUC1OC1gfeBNlxKmBgvoCxY2N5OoPs8bRqzkHiKqPM0gCSlqjP14gLOYPjFEEHhM9og8Piq9UDkvRBoMiy91/KfbSb9VMO0fH4HevfrMsRrVM1dl8zQNBJkCklo= 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 AM6PR08MB3912.eurprd08.prod.outlook.com (2603:10a6:20b:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.24; Fri, 12 Jun 2020 13:29:44 +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.3088.022; Fri, 12 Jun 2020 13:29:44 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v4 02/12] aarch64: configure test for BTI support Date: Fri, 12 Jun 2020 14:29:20 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SA9PR03CA0017.namprd03.prod.outlook.com (2603:10b6:806:20::22) 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 SA9PR03CA0017.namprd03.prod.outlook.com (2603:10b6:806:20::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20 via Frontend Transport; Fri, 12 Jun 2020 13:29:43 +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: 07e3e343-a179-4e4e-fccf-08d80ed4af8a X-MS-TrafficTypeDiagnostic: AM6PR08MB3912:|HE1PR0801MB1737: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Forefront-PRVS: 0432A04947 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: zCDxEKj8K1APzSTLrnpG8nzpQvufTul2RMmICH660SaW5EEcDouMUwi4EHky3n8175h5BD77vQqpZgP7tUKOy0e20bptZjz3wFuuECQvbbDkNnC3z43ukQZva2SNESQM1zjgM0ODWOfh0xugg9nkTAYRsENl0aP2P4vvtdabkc0QBRAK+bu7L62w1lUJOkE7oyHjrq1Asn9utFvWMALQOWxgCY9TOSfYR1q4HGWYyh6Q2VuPJgOyVA5iss2kiPD3FunfMp1Pl6J5WWK/QTAJENo+wdont/AC471saAjpZUHBbmcqUrn1MQY779p+9ldVton6q8Qpoy1bCz807kmt4bnCWunmAoyJqKC3MwLCTPu0J4RzCh/4YR7I4ZUJ8kgjsU9RTapQLHibyMcGOX7OKGRnouu2P2X+WYLZmvZ6wpQ= 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)(136003)(376002)(346002)(396003)(39860400002)(366004)(956004)(66476007)(66556008)(66946007)(6506007)(26005)(6512007)(5660300002)(6916009)(6666004)(2906002)(8676002)(6486002)(52116002)(8936002)(44832011)(186003)(16526019)(36756003)(2616005)(316002)(86362001)(69590400007)(478600001)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CU+hA3RnilrqnrpMzaf4XWBV+zTy55UJQtmSmC0NPCxVSGaJj95W3YRAP9FRemg2RaLqz/u7AOMs390a25QZ9V1ZTOZ71OTwaFxo6us6H39iWSu4F00vDvsASG8oS4vtRdAlzMCBZAwW6rpIz7YGrEOXnkoPOcCdG9ioMk8+s8J79LRKg+WKv4wTxcTicE5WwHALnl9eSIue5rZNp9X75flf95Chp6SMaxvy7uojePWPyEBr+yh7lwDta7kx3jmIocZjR35+zm8p1xW1uvlV4DJ1TG92axxvuUWso3h0Vz1zK0hRx4TIokDxWc9DQSJzOdmSpSOo01/LI7Gr4BsmeX/YGElUSGe/uV+hXmxRwTAi1fBigfIjD8lb2gWpYB/vYv/KTKInMmDVqKum69Y4/sUDswBiYwgWc06I9bmuetNyiVkIn0uVx+4NaLyqpDz1SwMvPq3C/tpPF4mF3TlzGNW74MD8/28CQxpEjzJGEeI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3912 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: AM5EUR03FT062.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)(39860400002)(346002)(396003)(376002)(136003)(46966005)(8676002)(5660300002)(6512007)(36756003)(36906005)(44832011)(316002)(336012)(70586007)(70206006)(6506007)(186003)(82310400002)(956004)(6916009)(6486002)(47076004)(69590400007)(8936002)(82740400003)(6666004)(86362001)(356005)(81166007)(26005)(16526019)(478600001)(2906002)(2616005)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: f12d7f5f-fe31-491b-7bca-08d80ed4ab3d X-Forefront-PRVS: 0432A04947 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +765K4YNmin6X5PVu2gk7/IgTTIEw3C3ZxXE1UJwfKJDD52xgYD4rmFKXoSL2DfU+qR9TJyz2SfZMFWILzX2A5HIJ0wngdeo+KUal0ICd+PxUFCIMjFRaAdYTu8RyKMNtxc0yWUzBYI74P+Y2/C+7C2ygZh+DLbJqq03UcrD1nqJEWkddS30sNinCqtinsAYRAONSdpJq7pVkdTrkWUy19TiI0R+10NhwAis6IxxFhDQbC4zfbRjUWFx4RwJFxoZ3r+m/RO/wPYeBKB7rElfwsUnkAs//oxHrhrqBHIIzYT5wIlUmmKdBdyf4STC7kNw0nvBBwBTazoBk9YiQzQJkNcAKFG1fjPE3K//TNSRaxZn5fXDu/ubwpJ4G13s46KcQ2NhxRx5JC+tgoi7+2cFv4c7UGjamI3eXSwhhmMEHjl+R+8LHbcD8LaHAdvzwcKMhNOBqZU9XvcJHjsZM9i1ug== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2020 13:29:51.3322 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07e3e343-a179-4e4e-fccf-08d80ed4af8a 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: HE1PR0801MB1737 X-Spam-Status: No, score=-17.4 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. --- 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 <