From patchwork Mon Jun 22 13:59:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39718 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 6096D388A810; Mon, 22 Jun 2020 13:59:41 +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 C916A3887013 for ; Mon, 22 Jun 2020 13:59:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C916A3887013 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=4EbXqF8HaDyISVTj9gvQdmqY8hS6m+gquJBEFuyWUw6/fIS/kqGxx51POxNoHjvnM5zsT9e/6+ZowMTb3eow+0qBUuhxbMNSry1z0F202akSjq9V2U9QhFCpSLnWUwNdjadWEt94b4ttIHY9O98hYHnKLu/1N1C5Fvuo+pPi/X0= Received: from AM5PR0201CA0022.eurprd02.prod.outlook.com (2603:10a6:203:3d::32) by AM6PR08MB3301.eurprd08.prod.outlook.com (2603:10a6:209:47::30) 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 13:59:37 +0000 Received: from VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:3d:cafe::3f) by AM5PR0201CA0022.outlook.office365.com (2603:10a6:203:3d::32) 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 13:59:37 +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 VE1EUR03FT004.mail.protection.outlook.com (10.152.18.106) 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 13:59:36 +0000 Received: ("Tessian outbound da41658aa5d4:v59"); Mon, 22 Jun 2020 13:59:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: af4f880c2bf0ff57 X-CR-MTA-TID: 64aa7808 Received: from c30830c61212.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 472C1102-077E-4F94-B3D5-F25375442035.1; Mon, 22 Jun 2020 13:59:31 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c30830c61212.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 13:59:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZZGFcGRWLSZOn9GhPsmQ57ZMyLt4IGC8YA4BZaEkuFRirE8h4LnpAX39/cRaoHhXa0GFXcn8PqqUYMmgkydKnheyN5cUKH6nCrFRFCLibW295+t0nKGda9nZY/Bra/JKPynCQfgXmQ2V4zY0qveC+1OVA339TAxvbyVrQ7uofIDMjo8ulUCuEMg9U13dFfgcxqc9e02hEVeGKFQzmaQ81c+8urlfmX4BYMAXJXwr3q2Ne4zq23YRk2RCaL0wrQ59x1Ddqxq7FA3wPXPdLgr1I0bQ6eoL4B6uR5jDHqf6T4S1uBG0Rsn3Lk8HAAMS7wEmihUvBxhTj8AlDRuk0/uJ+w== 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=bFV1sdb8MkLizExVpR+b3pWlIeh2zvYnA35zR6AkBbJcHqHRwE3qfcF3duPt5p8en15yuh3y39fycX0K8gqZb1PWmJLrlEHS+4Y6q51if+3n80Dm8tX9aGTwEjK4gE+ozTLhTTwXJtg9im73l7iGPX7A/yT6En4KoEoTri8vW+mv7Y3tqQSg9l5c3oJLxUnDbQDgw2NrXMIxkeAM+9+9+n2ixtXjSReav9djCh47Vvmxy0S1TyVY5OZjHcpDsfpBr0aTGr+1Z49lYpIe7gqbIbtm+IMUsOqK2gX9iGMi86BGhqtKmSxwawSBG7fINRj+vJLJx5g2kbMje+/cTBn9+g== 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=4EbXqF8HaDyISVTj9gvQdmqY8hS6m+gquJBEFuyWUw6/fIS/kqGxx51POxNoHjvnM5zsT9e/6+ZowMTb3eow+0qBUuhxbMNSry1z0F202akSjq9V2U9QhFCpSLnWUwNdjadWEt94b4ttIHY9O98hYHnKLu/1N1C5Fvuo+pPi/X0= 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 AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 13:59:30 +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 13:59:30 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 02/14] aarch64: configure test for BTI support Date: Mon, 22 Jun 2020 14:59:23 +0100 Message-Id: <088a606441f624221ce9be2038b71ca908f40c42.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0158.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::26) 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 LO2P265CA0158.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::26) 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 13:59:29 +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: 6a0825b9-206f-4f80-6e21-08d816b47fe6 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|AM6PR08MB3301: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xpmTGjQBR/gMv40OL8PgR9mporvCCgCXohNGHFifI6mI93H/olb0+A0f+PDKYF34Ymp3Y7V5gCKWnP8rWGFl7dbAQiVpIDSNAB6DwCpB/C8eztpAHKCd7Mu2/sZNWMXLOvm5/gUUH0uTDoYvMDOLDMKpIOCFfnsj3Cutom06uHOO01+J0kCTbtL+E7wRu2UXzCZaLRmu887RlhWmN9Wj8BjkPDLB5fPPzaoix47Rj5YIzfwFaSwbn4zBgdvvBiYFkwja/Ymz5LJqT/D604dIOvL48qeaYf8T2hitYZRAm1dIf0e6OQWWz0LTlhhPPqddXNScR1z8V6AGhDzCP0f4k2SFM42K7Q/rd1YK1x9nvGhhhY+AaWntXk1W3V94DC+9C7GKUheg8YHRICSaTgXEMoeqFbqQa1liyvZRtz3C2b8= 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)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(86362001)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 32KHkzio7kgoRWCz+FUPytCAIC5symAq9PGYk4PsApSRRvHhdk5KtOqGfjUl+uWsIDMP2YIMv8ZsnvLuM4IloNBVJcLD+GxR2y+XXdpPV1a35SrJDr0MPpuXlCgdIGM1R2abOeC+wce4NZ4qA/y/+8e5IhE4for3c1MdSLh0n8KiO5bMvWT4rrMapJLw4cFkH7eYiP469S4jEnYOTv1RlLSfZD5XzVzEaB5RGn+b+qJEiaUNNGwD3bn7Y5j/1aGaIxB5QINB9K+ISOmtNDnb0ayiaHpxrvCDtSoijqWY4vOZtrh+EVmITUR0aU2nukcd8cZrS6I7eL4FowPSgssRId+veSxj1f930sVsAEOdUBx7LI6eTe0L+pC2QWlRLvxJ9LEJcvQ00C2nzQC+fc4JfiVkJGk6xgb/80TWtMSjT1gZxTolMgijZJUzTyFywU91svK3tTOrRBnsjMZFVwV/lb38tWoKHjJCSVeQTAR8mpc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 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: VE1EUR03FT004.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)(39860400002)(346002)(396003)(136003)(46966005)(5660300002)(44832011)(2616005)(956004)(70206006)(36756003)(70586007)(36906005)(316002)(86362001)(6916009)(8936002)(8676002)(6486002)(336012)(478600001)(6512007)(47076004)(82740400003)(16526019)(69590400007)(26005)(6506007)(186003)(356005)(82310400002)(81166007)(2906002)(6666004)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4855a64c-1aac-42bc-f4c9-08d816b47ba6 X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i2kUjjmLQ/ChFjehsO186CwsTW8ehFRA7YnwnhJiKPcBT1qy/N9R1HwliMt+wo+nVvfgrqTDvSmDedsgV5trGceUlxi4YQllLl7LJr5LZl4taXVO+P3WotOSCHoE3Svg49gCe5gm28b+v/TDrOHCUTPMRIDumAZ+Z7ZgF1KOE7yqwqKYN/SQAeQchdfZBZfYk8luJpeqCliDSmJIIa40naNieohRu8qty5c64d2Fj4u2rK97+UhWHquU+Ikv/GreY57AGL5yZ5rX79gEF+k059Y28Rxr37FoSHjnSAw4wpLr53LQyOYx9UIFC9oVDDAVlp0mtb4W3K72U8Jhzv3zjWtN8vc4wDA8PVAAQ3eQxh0xqexMDv0gdr/ADA1ucWhcQy8Wom0F2d4W+7caHV7Se1KTbQQEShG0EKXad4Lq1FfdQfcnOz/HYEzc3UbfW8/dts4Do764h5J+V4MVxhiHXQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 13:59:36.7498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a0825b9-206f-4f80-6e21-08d816b47fe6 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: AM6PR08MB3301 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" 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 <