From patchwork Thu Oct 28 11:41:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46739 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 0A4783858012 for ; Thu, 28 Oct 2021 11:42:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A4783858012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421329; bh=18p0O29owTiaf1zOYObuEmNE7P53xoUjh9P67Mf0NN0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VhLMkyf9d6vJh/zKB/0fA5FfaGnwMdNwL1DUvPQcA8z7tUTWY6esv2BqPFLPsXODh 5zusBkmcqmhAIleErChCuaxntr0YuAW1DjDGCv3E7WApigHDxUN4bvKObPpc1Phkrr 94FCXsgH042uNsf5fgxAI3PLx0+xIbHdKvxcdjTE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60088.outbound.protection.outlook.com [40.107.6.88]) by sourceware.org (Postfix) with ESMTPS id 697D33857C72 for ; Thu, 28 Oct 2021 11:41:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 697D33857C72 Received: from AS9PR0301CA0039.eurprd03.prod.outlook.com (2603:10a6:20b:469::8) by HE1PR0801MB2076.eurprd08.prod.outlook.com (2603:10a6:3:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Thu, 28 Oct 2021 11:41:29 +0000 Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:469:cafe::50) by AS9PR0301CA0039.outlook.office365.com (2603:10a6:20b:469::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18 via Frontend Transport; Thu, 28 Oct 2021 11:41:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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 VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:41:29 +0000 Received: ("Tessian outbound d49ee2bec50d:v108"); Thu, 28 Oct 2021 11:41:28 +0000 X-CR-MTA-TID: 64aa7808 Received: from 022f8c404fb1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F1CD4B07-BEDB-4FA0-8791-F0538CB0D906.1; Thu, 28 Oct 2021 11:41:22 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 022f8c404fb1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:41:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HdycCkkgKm8mLlFeDUqjlaE61wTgAGDHGJE4ppyOc8vpN3a+ZHYMQxVypg4zgtr0sYZLQd3Ku5VXk36lYc75SrGkig0Qo2b5XQwGvle9nNpoonqCQznxxpxZVE6EvBNUuflv2mwO0asF3ks8QLOC2Fldn/U/V3AQRVRPqD63TUKCNDEumIEmGdEBHXmosf0Lj7oXk7aFwuYw3h/ZXcWwzY430SWrNv6jUQH+6eXyqWq4rdesmAeszQ7pBRYQ84DRHkPbP24xU1KDm3ZutL49ZgvjcfDNu8fGiyDiHDm40iXF8GOuKa03mOXxGI9hRl44g/Cy1d1yhWXTnBaxl153mQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=18p0O29owTiaf1zOYObuEmNE7P53xoUjh9P67Mf0NN0=; b=jX3jy3C3zUv5bU3/e3+2hMd73kUuSHSnyqJD7BfqS6uRpvY2msZNluBdICR8P8jdHKxC/8pVQRBlMBcW3mXLbozgr828eMPrs0zcf+8UBi/SvVczx3oNr7q+JCSUK9yn+j71+d7+v+qWk74eLeNN3ArV3vsYNqkX+AF8JAvZZXrfgjyMDb9+jmUBe1k1fzGX9OpUFiEKl+KIJ/lmg8WXVmsE+awZkfU4XL8Vi/0HexCyeWOcVozH0Jlt5Dw5pAZZt9zUgSxBvgqixCkRegZu7UBpC1VVyfId2pEUYL0fCVRJloEf5c14Bi9pZbcqQhl1UaGPCrGFR1z+xPEuH3QCbw== 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 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7261.eurprd08.prod.outlook.com (2603:10a6:102:210::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 28 Oct 2021 11:41:21 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:41:21 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 1/8, Arm, AArch64, GCC] Refactor mbranch-protection option parsing and make it common to AArch32 and AArch64 backends. [Was RE: [Patch 2/7, Arm, GCC] Add option -mbranch-protection.] Thread-Topic: [Patch 1/8, Arm, AArch64, GCC] Refactor mbranch-protection option parsing and make it common to AArch32 and AArch64 backends. [Was RE: [Patch 2/7, Arm, GCC] Add option -mbranch-protection.] Thread-Index: AdfL8JcvuDyOwd6+SjWpR5X5uwhAlQ== Date: Thu, 28 Oct 2021 11:41:21 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: B21AA4EF4D9DD54B8CDB47CAC94CF512.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: d517c707-431e-4bcd-b355-08d99a07e1b4 x-ms-traffictypediagnostic: PAXPR08MB7261:|HE1PR0801MB2076: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: g/kfL8JQI/5pKF7HDc/Q5OwHH0sW6Wnu3KFlqng1cavYXjmxNK5QJDp93elftIyMb/Gb6nFfe4uknp5H5Hbav5uvafKdHIeXy3CEqUpdZcp5JpyM8PP4ZnwZkw3H2qcvvygYdVlkiR/87O7klCmRbV1ozr5eiKYAAau8+jeOC555MnC0VUTozGB7dGdfYR/mLtszSH8CDyyVgKuYoQlfSnTFZcO9nylSmJRDT8d9ERgL7pFSyiGPn3buNTxOGHdXgBUc+z0l2336sLOhyvILXh4bTnpRXS0mpMWJ5lG+l5jznRIidWhcs+frHzxhmCjGt5X7o8VtdCt33BOzfjcBlmNFwD5ABBEu3ICJgnquv4pVjhXda9v8IzlJhYBZxdiMUNrOu8ybDEWxUBc3Y23FV6VmPyGBu1VJvbVmeuCXNJA/79ZoPaq7zWSKJjK80+QtSHMiupQcF7fSQn6gcDepomu2agSFz9D4B9yDSnljtrdO3r82lAX+m/8oBc1xh/2OkErnaweBpFgd68pWC9fp7CEY+k6HngeExipjqUcsoQBq9TRo4SZ752ZnhWeHKoiwiWtgh6is3hP+rZHuQlXvWVDW+NVPlBwWxrxo57wyJmi4d1dGijXoH94yo2nbhbJBKORqzGHb1sV6orZQYiODfM9O91SWjli50oxXeqi9cv0VsvyroGQ1LV8UYM3kNwecv1So4FsRjvHq7I+ERjgcEw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(8676002)(110136005)(55016002)(9686003)(64756008)(66446008)(86362001)(38070700005)(66476007)(83380400001)(66556008)(8936002)(71200400001)(76116006)(66946007)(4001150100001)(7696005)(26005)(33656002)(52536014)(5660300002)(122000001)(2906002)(38100700002)(6506007)(53546011)(186003)(508600001)(99936003); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7261 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 0eed663d-03c4-4a86-cc46-08d99a07dd2f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1cHX/dmK/ljKtjpRwsh7E7qrAfraX7xLumPEs4+lNTdi93Z/2XGofgrpjUXRVbHNeQkoxq30bgr/MT6aHZDk+q++e7CmvRhRN2QnJ0uz+ui3ih7mxkqzjCQOzX94KmmQu4uGMttA7NnzvTkHW00qnbC2cpHWX0qjK8IXr+yeaNx0usr9MlRQdGH+Z5P8icZXqcpmDhGmuP5ZOCRaAoMeH1bs7CV4rSh/PnEjvYjgfQOkXiSdfEQSIU8OhcC9V3+IXvIk1zWkU6CvdUxcGbgsf0fjOroUDPRZ2kFu9ZHaS70W+DmeYM0TukaEwSaM8UI98NHgAFbk0NVfoR/KPsL0VzXel8fs3VcN2dUgdZebS04PnHvtq8cmhNrM4DFuK6dXk98S8lqZ/FO2zz0XGL0WwVDhKeqKZSX3QtANLF1WGTvAmV+GkI/9wgWQ7ujbWWMzdFTAuClLG+097EFnIlTFrdYcE6co5VpDlgTIj9h94PSD0wOV9EYKwlNPpOXYb3AOoOLGgKkVAULCHwkAplURhzn57fsbFAebTpqmLQ97ZKtHQXbnndhPwsv/jUDwziVS7xxRXEsThSmYSKyKeBr/4cET0Hy2j+iohKd6eHZ33OVVdkNKWcwDRYXSaUOFobNSJwh3m4gJEubHMn7uu++keSVWqAXpIC2XQAtmWfnmqQH0VccY0S2qAT9NbXWudyFtQ/WwMX/0aL0Ar+MSKgwY8w== 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; SFS:(4636009)(36840700001)(46966006)(26005)(21480400003)(9686003)(81166007)(70586007)(52536014)(356005)(36860700001)(55016002)(6506007)(33656002)(82310400003)(4001150100001)(33964004)(8676002)(83380400001)(53546011)(86362001)(316002)(336012)(8936002)(99936003)(70206006)(5660300002)(110136005)(2906002)(47076005)(186003)(235185007)(7696005)(508600001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:41:29.0411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d517c707-431e-4bcd-b355-08d99a07e1b4 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: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2076 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Richard Earnshaw > Sent: Monday, October 11, 2021 1:58 PM > To: Tejas Belagod ; gcc-patches@gcc.gnu.org > Subject: Re: [Patch 2/7, Arm, GCC] Add option -mbranch-protection. > > On 08/10/2021 13:17, Tejas Belagod via Gcc-patches wrote: > > Hi, > > > > Add -mbranch-protection option and its associated parsing routines. > > This option enables the code-generation of pointer signing and > > authentication instructions in function prologues and epilogues. > > > > Tested on arm-none-eabi. OK for trunk? > > > > 2021-10-04 Tejas Belagod > > > > gcc/ChangeLog: > > > > * common/config/arm/arm-common.c > > (arm_print_hit_for_pacbti_option): New. > > (arm_progress_next_token): New. > > (arm_parse_pac_ret_clause): New routine for parsing the > > pac-ret clause for -mbranch-protection. > > (arm_parse_pacbti_option): New routine to parse all the options > > to -mbranch-protection. > > * config/arm/arm-protos.h (arm_parse_pacbti_option): Export. > > * config/arm/arm.c (arm_configure)build_target): Handle option > > to -mbranch-protection. > > * config/arm/arm.opt (mbranch-protection). New. > > (arm_enable_pacbti): New. > > > > You're missing documentation for invoke.texi. > > Also, how does this differ from the exising option in aarch64? Can the code > from that be adapted to be made common to both targets rather than doing > a new implementation? > > Finally, there are far to many manifest constants in this patch, they need > replacing with enums or #defines as appropriate if we cannot share the > aarch64 code. > Thanks for the reviews. This change refactors all the mbranch-protection option parsing code and types to make it common to both AArch32 and AArch64 backends. This change also pulls in some supporting types from AArch64 to make it common (aarch_parse_opt_result). The significant changes in this patch are the movement of all branch protection parsing routines from aarch64.c to aarch-common.c and supporting data types and static data structures. This patch also pre-declares variables and types required in the aarch32 back for moved variables for function sign scope and key to prepare for the impending series of patches that support parsing the feature mbranch-protection in the aarch32 back end. 2021-10-25 Tejas Belagod gcc/ChangeLog: * common/config/aarch64/aarch64-common.c: Include aarch-common.h. (all_architectures): Fix comment. (aarch64_parse_extension): Rename return type, enum value names. * config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Rename factored out aarch_ra_sign_scope and aarch_ra_sign_key variables. Also rename corresponding enum values. * config/aarch64/aarch64-opts.h (aarch64_function_type): Factor out aarch64_function_type and move it to common code as aarch_function_type in aarch-common.h. * config/aarch64/aarch64-protos.h: Include common types header, move out types aarch64_parse_opt_result and aarch64_key_type to aarch-common.h * config/aarch64/aarch64.c: Move mbranch-protection parsing types and functions out into aarch-common.h and aarch-common.c. Fix up all the name changes resulting from the move. * config/aarch64/aarch64.md: Fix up aarch64_ra_sign_key type name change and enum value. * config/aarch64/aarch64.opt: Include aarch-common.h to import type move. Fix up name changes from factoring out common code and data. * config/arm/aarch-common-protos.h: Export factored out routines to both backends. * config/arm/aarch-common.c: Include newly factored out types. Move all mbranch-protection code and data structures from aarch64.c. * config/arm/aarch-common.h: New header that declares types shared between aarch32 and aarch64 backends. * config/arm/arm-protos.h: Declare types and variables that are made common to aarch64 and aarch32 backends - aarch_ra_sign_key, aarch_ra_sign_scope and aarch_enable_bti. Tested the following configurations. OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap Thanks, Tejas. > R. diff --git a/gcc/common/config/aarch64/aarch64-common.c b/gcc/common/config/aarch64/aarch64-common.c index 6d200a186604be2028b19ee9691e7bbf4a7be9c2..92c8f14a17466b9d6c44bdf4ede673a65f1b426f 100644 --- a/gcc/common/config/aarch64/aarch64-common.c +++ b/gcc/common/config/aarch64/aarch64-common.c @@ -30,6 +30,7 @@ #include "opts.h" #include "flags.h" #include "diagnostic.h" +#include "config/arm/aarch-common.h" #ifdef TARGET_BIG_ENDIAN_DEFAULT #undef TARGET_DEFAULT_TARGET_FLAGS @@ -192,11 +193,11 @@ static const struct arch_to_arch_name all_architectures[] = /* Parse the architecture extension string STR and update ISA_FLAGS with the architecture features turned on or off. Return a - aarch64_parse_opt_result describing the result. + aarch_parse_opt_result describing the result. When the STR string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ -enum aarch64_parse_opt_result +enum aarch_parse_opt_result aarch64_parse_extension (const char *str, uint64_t *isa_flags, std::string *invalid_extension) { @@ -229,7 +230,7 @@ aarch64_parse_extension (const char *str, uint64_t *isa_flags, adding_ext = 1; if (len == 0) - return AARCH64_PARSE_MISSING_ARG; + return AARCH_PARSE_MISSING_ARG; /* Scan over the extensions table trying to find an exact match. */ @@ -251,13 +252,13 @@ aarch64_parse_extension (const char *str, uint64_t *isa_flags, /* Extension not found in list. */ if (invalid_extension) *invalid_extension = std::string (str, len); - return AARCH64_PARSE_INVALID_FEATURE; + return AARCH_PARSE_INVALID_FEATURE; } str = ext; }; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } /* Append all architecture extension candidates to the CANDIDATES vector. */ diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c index f9ddffa007818a42710cfc0d60af580dd6c76f95..3518e9ab6cac6915e1b88eab450bb31879fbbabd 100644 --- a/gcc/config/aarch64/aarch64-c.c +++ b/gcc/config/aarch64/aarch64-c.c @@ -183,14 +183,14 @@ aarch64_update_cpp_builtins (cpp_reader *pfile) "__ARM_FEATURE_BTI_DEFAULT", pfile); cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT"); - if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE) + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE) { int v = 0; - if (aarch64_ra_sign_key == AARCH64_KEY_A) + if (aarch_ra_sign_key == AARCH_KEY_A) v |= 1; - if (aarch64_ra_sign_key == AARCH64_KEY_B) + if (aarch_ra_sign_key == AARCH_KEY_B) v |= 2; - if (aarch64_ra_sign_scope == AARCH64_FUNCTION_ALL) + if (aarch_ra_sign_scope == AARCH_FUNCTION_ALL) v |= 4; builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", v); } diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h index af3b7364a748f7b95cdbb5c1508a1e9566244175..d47e1e74f6c2f448ed364bf8787f11484e2f3595 100644 --- a/gcc/config/aarch64/aarch64-opts.h +++ b/gcc/config/aarch64/aarch64-opts.h @@ -71,16 +71,6 @@ enum aarch64_code_model { AARCH64_CMODEL_LARGE }; -/* Function types -msign-return-address should sign. */ -enum aarch64_function_type { - /* Don't sign any function. */ - AARCH64_FUNCTION_NONE, - /* Non-leaf functions. */ - AARCH64_FUNCTION_NON_LEAF, - /* All functions. */ - AARCH64_FUNCTION_ALL -}; - /* SVE vector register sizes. */ enum aarch64_sve_vector_bits_enum { SVE_SCALABLE, diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 768e8fae136daa866fe589d72f30514e1229180f..b1dc87bcbdc888967a32a966ad0fd8a896e454be 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -23,6 +23,7 @@ #define GCC_AARCH64_PROTOS_H #include "input.h" +#include "config/arm/aarch-common.h" /* SYMBOL_SMALL_ABSOLUTE: Generate symbol accesses through high and lo relocs that calculate the base address using a PC @@ -637,18 +638,6 @@ enum aarch64_extra_tuning_flags AARCH64_EXTRA_TUNE_ALL = (1u << AARCH64_EXTRA_TUNE_index_END) - 1 }; -/* Enum describing the various ways that the - aarch64_parse_{arch,tune,cpu,extension} functions can fail. - This way their callers can choose what kind of error to give. */ - -enum aarch64_parse_opt_result -{ - AARCH64_PARSE_OK, /* Parsing was successful. */ - AARCH64_PARSE_MISSING_ARG, /* Missing argument. */ - AARCH64_PARSE_INVALID_FEATURE, /* Invalid feature modifier. */ - AARCH64_PARSE_INVALID_ARG /* Invalid arch, tune, cpu arg. */ -}; - /* Enum to distinguish which type of check is to be done in aarch64_simd_valid_immediate. This is used as a bitmask where AARCH64_CHECK_MOV has both bits set. Thus AARCH64_CHECK_MOV will @@ -659,13 +648,7 @@ enum simd_immediate_check { AARCH64_CHECK_MOV = AARCH64_CHECK_ORR | AARCH64_CHECK_BIC }; -/* The key type that -msign-return-address should use. */ -enum aarch64_key_type { - AARCH64_KEY_A, - AARCH64_KEY_B -}; - -extern enum aarch64_key_type aarch64_ra_sign_key; +extern enum aarch_key_type aarch_ra_sign_key; extern struct tune_params aarch64_tune_params; @@ -1013,9 +996,9 @@ extern bool aarch64_classify_address (struct aarch64_address_info *, rtx, bool aarch64_handle_option (struct gcc_options *, struct gcc_options *, const struct cl_decoded_option *, location_t); const char *aarch64_rewrite_selected_cpu (const char *name); -enum aarch64_parse_opt_result aarch64_parse_extension (const char *, - uint64_t *, - std::string *); +enum aarch_parse_opt_result aarch64_parse_extension (const char *, + uint64_t *, + std::string *); void aarch64_get_all_extension_candidates (auto_vec *candidates); std::string aarch64_get_extension_string_for_isa_flags (uint64_t, uint64_t); diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 699c105a42a613c06c462e2de686795279d85bc9..d2e1324520f8260a6abce6c162e2eb133e44e7c1 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -79,6 +79,8 @@ #include "tree-ssa-loop-niter.h" #include "fractional-cost.h" #include "rtlanal.h" +#include "config/arm/aarch-common.h" +#include "config/arm/aarch-common-protos.h" /* This file should be included last. */ #include "target-def.h" @@ -319,12 +321,8 @@ bool aarch64_pcrelative_literal_loads; /* Global flag for whether frame pointer is enabled. */ bool aarch64_use_frame_pointer; -#define BRANCH_PROTECT_STR_MAX 255 char *accepted_branch_protection_string = NULL; -static enum aarch64_parse_opt_result -aarch64_parse_branch_protection (const char*, char**); - /* Support for command line parsing of boolean flags in the tuning structures. */ struct aarch64_flag_desc @@ -2087,7 +2085,7 @@ static const struct processor *selected_arch; static const struct processor *selected_cpu; static const struct processor *selected_tune; -enum aarch64_key_type aarch64_ra_sign_key = AARCH64_KEY_A; +enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A; /* The current tuning set. */ struct tune_params aarch64_tune_params = generic_tunings; @@ -2156,100 +2154,6 @@ aarch64_cc; #define AARCH64_INVERSE_CONDITION_CODE(X) ((aarch64_cc) (((int) X) ^ 1)) -struct aarch64_branch_protect_type -{ - /* The type's name that the user passes to the branch-protection option - string. */ - const char* name; - /* Function to handle the protection type and set global variables. - First argument is the string token corresponding with this type and the - second argument is the next token in the option string. - Return values: - * AARCH64_PARSE_OK: Handling was sucessful. - * AARCH64_INVALID_ARG: The type is invalid in this context and the caller - should print an error. - * AARCH64_INVALID_FEATURE: The type is invalid and the handler prints its - own error. */ - enum aarch64_parse_opt_result (*handler)(char*, char*); - /* A list of types that can follow this type in the option string. */ - const aarch64_branch_protect_type* subtypes; - unsigned int num_subtypes; -}; - -static enum aarch64_parse_opt_result -aarch64_handle_no_branch_protection (char* str, char* rest) -{ - aarch64_ra_sign_scope = AARCH64_FUNCTION_NONE; - aarch64_enable_bti = 0; - if (rest) - { - error ("unexpected %<%s%> after %<%s%>", rest, str); - return AARCH64_PARSE_INVALID_FEATURE; - } - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_standard_branch_protection (char* str, char* rest) -{ - aarch64_ra_sign_scope = AARCH64_FUNCTION_NON_LEAF; - aarch64_ra_sign_key = AARCH64_KEY_A; - aarch64_enable_bti = 1; - if (rest) - { - error ("unexpected %<%s%> after %<%s%>", rest, str); - return AARCH64_PARSE_INVALID_FEATURE; - } - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_pac_ret_protection (char* str ATTRIBUTE_UNUSED, - char* rest ATTRIBUTE_UNUSED) -{ - aarch64_ra_sign_scope = AARCH64_FUNCTION_NON_LEAF; - aarch64_ra_sign_key = AARCH64_KEY_A; - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_pac_ret_leaf (char* str ATTRIBUTE_UNUSED, - char* rest ATTRIBUTE_UNUSED) -{ - aarch64_ra_sign_scope = AARCH64_FUNCTION_ALL; - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_pac_ret_b_key (char* str ATTRIBUTE_UNUSED, - char* rest ATTRIBUTE_UNUSED) -{ - aarch64_ra_sign_key = AARCH64_KEY_B; - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_bti_protection (char* str ATTRIBUTE_UNUSED, - char* rest ATTRIBUTE_UNUSED) -{ - aarch64_enable_bti = 1; - return AARCH64_PARSE_OK; -} - -static const struct aarch64_branch_protect_type aarch64_pac_ret_subtypes[] = { - { "leaf", aarch64_handle_pac_ret_leaf, NULL, 0 }, - { "b-key", aarch64_handle_pac_ret_b_key, NULL, 0 }, - { NULL, NULL, NULL, 0 } -}; - -static const struct aarch64_branch_protect_type aarch64_branch_protect_types[] = { - { "none", aarch64_handle_no_branch_protection, NULL, 0 }, - { "standard", aarch64_handle_standard_branch_protection, NULL, 0 }, - { "pac-ret", aarch64_handle_pac_ret_protection, aarch64_pac_ret_subtypes, - ARRAY_SIZE (aarch64_pac_ret_subtypes) }, - { "bti", aarch64_handle_bti_protection, NULL, 0 }, - { NULL, NULL, NULL, 0 } -}; /* The condition codes of the processor, and the inverse function. */ static const char * const aarch64_condition_codes[] = @@ -7792,10 +7696,10 @@ aarch64_return_address_signing_enabled (void) if (crtl->calls_eh_return) return false; - /* If signing scope is AARCH64_FUNCTION_NON_LEAF, we only sign a leaf function + /* If signing scope is AARCH_FUNCTION_NON_LEAF, we only sign a leaf function if its LR is pushed onto stack. */ - return (aarch64_ra_sign_scope == AARCH64_FUNCTION_ALL - || (aarch64_ra_sign_scope == AARCH64_FUNCTION_NON_LEAF + return (aarch_ra_sign_scope == AARCH_FUNCTION_ALL + || (aarch_ra_sign_scope == AARCH_FUNCTION_NON_LEAF && known_ge (cfun->machine->frame.reg_offset[LR_REGNUM], 0))); } @@ -7803,7 +7707,7 @@ aarch64_return_address_signing_enabled (void) bool aarch64_bti_enabled (void) { - return (aarch64_enable_bti == 1); + return (aarch_enable_bti == 1); } /* The caller is going to use ST1D or LD1D to save or restore an SVE @@ -8795,12 +8699,12 @@ aarch64_expand_prologue (void) /* Sign return address for functions. */ if (aarch64_return_address_signing_enabled ()) { - switch (aarch64_ra_sign_key) + switch (aarch_ra_sign_key) { - case AARCH64_KEY_A: + case AARCH_KEY_A: insn = emit_insn (gen_paciasp ()); break; - case AARCH64_KEY_B: + case AARCH_KEY_B: insn = emit_insn (gen_pacibsp ()); break; default: @@ -9084,12 +8988,12 @@ aarch64_expand_epilogue (bool for_sibcall) if (aarch64_return_address_signing_enabled () && (for_sibcall || !TARGET_ARMV8_3 || crtl->calls_eh_return)) { - switch (aarch64_ra_sign_key) + switch (aarch_ra_sign_key) { - case AARCH64_KEY_A: + case AARCH_KEY_A: insn = emit_insn (gen_autiasp ()); break; - case AARCH64_KEY_B: + case AARCH_KEY_B: insn = emit_insn (gen_autibsp ()); break; default: @@ -15994,12 +15898,12 @@ static void initialize_aarch64_code_model (struct gcc_options *); /* Parse the TO_PARSE string and put the architecture struct that it selects into RES and the architectural features into ISA_FLAGS. - Return an aarch64_parse_opt_result describing the parse result. + Return an aarch_parse_opt_result describing the parse result. If there is an error parsing, RES and ISA_FLAGS are left unchanged. When the TO_PARSE string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ -static enum aarch64_parse_opt_result +static enum aarch_parse_opt_result aarch64_parse_arch (const char *to_parse, const struct processor **res, uint64_t *isa_flags, std::string *invalid_extension) { @@ -16015,7 +15919,7 @@ aarch64_parse_arch (const char *to_parse, const struct processor **res, len = strlen (to_parse); if (len == 0) - return AARCH64_PARSE_MISSING_ARG; + return AARCH_PARSE_MISSING_ARG; /* Loop through the list of supported ARCHes to find a match. */ @@ -16029,32 +15933,32 @@ aarch64_parse_arch (const char *to_parse, const struct processor **res, if (ext != NULL) { /* TO_PARSE string contains at least one extension. */ - enum aarch64_parse_opt_result ext_res + enum aarch_parse_opt_result ext_res = aarch64_parse_extension (ext, &isa_temp, invalid_extension); - if (ext_res != AARCH64_PARSE_OK) + if (ext_res != AARCH_PARSE_OK) return ext_res; } /* Extension parsing was successful. Confirm the result arch and ISA flags. */ *res = arch; *isa_flags = isa_temp; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } } /* ARCH name not found in list. */ - return AARCH64_PARSE_INVALID_ARG; + return AARCH_PARSE_INVALID_ARG; } /* Parse the TO_PARSE string and put the result tuning in RES and the - architecture flags in ISA_FLAGS. Return an aarch64_parse_opt_result + architecture flags in ISA_FLAGS. Return an aarch_parse_opt_result describing the parse result. If there is an error parsing, RES and ISA_FLAGS are left unchanged. When the TO_PARSE string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ -static enum aarch64_parse_opt_result +static enum aarch_parse_opt_result aarch64_parse_cpu (const char *to_parse, const struct processor **res, uint64_t *isa_flags, std::string *invalid_extension) { @@ -16070,7 +15974,7 @@ aarch64_parse_cpu (const char *to_parse, const struct processor **res, len = strlen (to_parse); if (len == 0) - return AARCH64_PARSE_MISSING_ARG; + return AARCH_PARSE_MISSING_ARG; /* Loop through the list of supported CPUs to find a match. */ @@ -16084,29 +15988,29 @@ aarch64_parse_cpu (const char *to_parse, const struct processor **res, if (ext != NULL) { /* TO_PARSE string contains at least one extension. */ - enum aarch64_parse_opt_result ext_res + enum aarch_parse_opt_result ext_res = aarch64_parse_extension (ext, &isa_temp, invalid_extension); - if (ext_res != AARCH64_PARSE_OK) + if (ext_res != AARCH_PARSE_OK) return ext_res; } /* Extension parsing was successfull. Confirm the result cpu and ISA flags. */ *res = cpu; *isa_flags = isa_temp; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } } /* CPU name not found in list. */ - return AARCH64_PARSE_INVALID_ARG; + return AARCH_PARSE_INVALID_ARG; } /* Parse the TO_PARSE string and put the cpu it selects into RES. - Return an aarch64_parse_opt_result describing the parse result. + Return an aarch_parse_opt_result describing the parse result. If the parsing fails the RES does not change. */ -static enum aarch64_parse_opt_result +static enum aarch_parse_opt_result aarch64_parse_tune (const char *to_parse, const struct processor **res) { const struct processor *cpu; @@ -16117,12 +16021,12 @@ aarch64_parse_tune (const char *to_parse, const struct processor **res) if (strcmp (cpu->name, to_parse) == 0) { *res = cpu; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } } /* CPU name not found in list. */ - return AARCH64_PARSE_INVALID_ARG; + return AARCH_PARSE_INVALID_ARG; } /* Parse TOKEN, which has length LENGTH to see if it is an option @@ -16696,22 +16600,22 @@ aarch64_validate_mcpu (const char *str, const struct processor **res, uint64_t *isa_flags) { std::string invalid_extension; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_cpu (str, res, isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) return true; switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing cpu name in %<-mcpu=%s%>", str); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("unknown value %qs for %<-mcpu%>", str); aarch64_print_hint_for_core (str); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs in %<-mcpu=%s%>", invalid_extension.c_str (), str); aarch64_print_hint_for_extensions (invalid_extension); @@ -16796,110 +16700,6 @@ aarch64_validate_sls_mitigation (const char *const_str) free (str_root); } -/* Parses CONST_STR for branch protection features specified in - aarch64_branch_protect_types, and set any global variables required. Returns - the parsing result and assigns LAST_STR to the last processed token from - CONST_STR so that it can be used for error reporting. */ - -static enum -aarch64_parse_opt_result aarch64_parse_branch_protection (const char *const_str, - char** last_str) -{ - char *str_root = xstrdup (const_str); - char* token_save = NULL; - char *str = strtok_r (str_root, "+", &token_save); - enum aarch64_parse_opt_result res = AARCH64_PARSE_OK; - if (!str) - res = AARCH64_PARSE_MISSING_ARG; - else - { - char *next_str = strtok_r (NULL, "+", &token_save); - /* Reset the branch protection features to their defaults. */ - aarch64_handle_no_branch_protection (NULL, NULL); - - while (str && res == AARCH64_PARSE_OK) - { - const aarch64_branch_protect_type* type = aarch64_branch_protect_types; - bool found = false; - /* Search for this type. */ - while (type && type->name && !found && res == AARCH64_PARSE_OK) - { - if (strcmp (str, type->name) == 0) - { - found = true; - res = type->handler (str, next_str); - str = next_str; - next_str = strtok_r (NULL, "+", &token_save); - } - else - type++; - } - if (found && res == AARCH64_PARSE_OK) - { - bool found_subtype = true; - /* Loop through each token until we find one that isn't a - subtype. */ - while (found_subtype) - { - found_subtype = false; - const aarch64_branch_protect_type *subtype = type->subtypes; - /* Search for the subtype. */ - while (str && subtype && subtype->name && !found_subtype - && res == AARCH64_PARSE_OK) - { - if (strcmp (str, subtype->name) == 0) - { - found_subtype = true; - res = subtype->handler (str, next_str); - str = next_str; - next_str = strtok_r (NULL, "+", &token_save); - } - else - subtype++; - } - } - } - else if (!found) - res = AARCH64_PARSE_INVALID_ARG; - } - } - /* Copy the last processed token into the argument to pass it back. - Used by option and attribute validation to print the offending token. */ - if (last_str) - { - if (str) strcpy (*last_str, str); - else *last_str = NULL; - } - if (res == AARCH64_PARSE_OK) - { - /* If needed, alloc the accepted string then copy in const_str. - Used by override_option_after_change_1. */ - if (!accepted_branch_protection_string) - accepted_branch_protection_string = (char *) xmalloc ( - BRANCH_PROTECT_STR_MAX - + 1); - strncpy (accepted_branch_protection_string, const_str, - BRANCH_PROTECT_STR_MAX + 1); - /* Forcibly null-terminate. */ - accepted_branch_protection_string[BRANCH_PROTECT_STR_MAX] = '\0'; - } - return res; -} - -static bool -aarch64_validate_mbranch_protection (const char *const_str) -{ - char *str = (char *) xmalloc (strlen (const_str)); - enum aarch64_parse_opt_result res = - aarch64_parse_branch_protection (const_str, &str); - if (res == AARCH64_PARSE_INVALID_ARG) - error ("invalid argument %<%s%> for %<-mbranch-protection=%>", str); - else if (res == AARCH64_PARSE_MISSING_ARG) - error ("missing argument for %<-mbranch-protection=%>"); - free (str); - return res == AARCH64_PARSE_OK; -} - /* Validate a command-line -march option. Parse the arch and extensions (if any) specified in STR and throw errors if appropriate. Put the results, if they are valid, in RES and ISA_FLAGS. Return whether the @@ -16910,22 +16710,22 @@ aarch64_validate_march (const char *str, const struct processor **res, uint64_t *isa_flags) { std::string invalid_extension; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_arch (str, res, isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) return true; switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing arch name in %<-march=%s%>", str); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("unknown value %qs for %<-march%>", str); aarch64_print_hint_for_arch (str); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs in %<-march=%s%>", invalid_extension.c_str (), str); aarch64_print_hint_for_extensions (invalid_extension); @@ -16945,18 +16745,18 @@ aarch64_validate_march (const char *str, const struct processor **res, static bool aarch64_validate_mtune (const char *str, const struct processor **res) { - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_tune (str, res); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) return true; switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing cpu name in %<-mtune=%s%>", str); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("unknown value %qs for %<-mtune%>", str); aarch64_print_hint_for_core (str); break; @@ -17044,7 +16844,7 @@ aarch64_override_options (void) aarch64_validate_sls_mitigation (aarch64_harden_sls_string); if (aarch64_branch_protection_string) - aarch64_validate_mbranch_protection (aarch64_branch_protection_string); + aarch_validate_mbranch_protection (aarch64_branch_protection_string); /* -mcpu=CPU is shorthand for -march=ARCH_FOR_CPU, -mtune=CPU. If either of -march or -mtune is given, they override their @@ -17122,12 +16922,12 @@ aarch64_override_options (void) if (!selected_tune) selected_tune = selected_cpu; - if (aarch64_enable_bti == 2) + if (aarch_enable_bti == 2) { #ifdef TARGET_ENABLE_BTI - aarch64_enable_bti = 1; + aarch_enable_bti = 1; #else - aarch64_enable_bti = 0; + aarch_enable_bti = 0; #endif } @@ -17137,9 +16937,9 @@ aarch64_override_options (void) if (!TARGET_ILP32 && accepted_branch_protection_string == NULL) { #ifdef TARGET_ENABLE_PAC_RET - aarch64_ra_sign_scope = AARCH64_FUNCTION_NON_LEAF; + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; #else - aarch64_ra_sign_scope = AARCH64_FUNCTION_NONE; + aarch_ra_sign_scope = AARCH_FUNCTION_NONE; #endif } @@ -17153,7 +16953,7 @@ aarch64_override_options (void) /* Convert -msve-vector-bits to a VG count. */ aarch64_sve_vg = aarch64_convert_sve_vector_bits (aarch64_sve_vector_bits); - if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE && TARGET_ILP32) + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE && TARGET_ILP32) sorry ("return address signing is only supported for %<-mabi=lp64%>"); /* Make sure we properly set up the explicit options. */ @@ -17280,7 +17080,7 @@ aarch64_option_restore (struct gcc_options *opts, = ptr->x_aarch64_branch_protection_string; if (opts->x_aarch64_branch_protection_string) { - aarch64_parse_branch_protection (opts->x_aarch64_branch_protection_string, + aarch_parse_branch_protection (opts->x_aarch64_branch_protection_string, NULL); } @@ -17404,10 +17204,10 @@ aarch64_handle_attr_arch (const char *str) { const struct processor *tmp_arch = NULL; std::string invalid_extension; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_arch (str, &tmp_arch, &aarch64_isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) { gcc_assert (tmp_arch); selected_arch = tmp_arch; @@ -17417,14 +17217,14 @@ aarch64_handle_attr_arch (const char *str) switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing name in % pragma or attribute"); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("invalid name (\"%s\") in % pragma or attribute", str); aarch64_print_hint_for_arch (str); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %s of value (\"%s\") in " "% pragma or attribute", invalid_extension.c_str (), str); aarch64_print_hint_for_extensions (invalid_extension); @@ -17443,10 +17243,10 @@ aarch64_handle_attr_cpu (const char *str) { const struct processor *tmp_cpu = NULL; std::string invalid_extension; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_cpu (str, &tmp_cpu, &aarch64_isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) { gcc_assert (tmp_cpu); selected_tune = tmp_cpu; @@ -17459,14 +17259,14 @@ aarch64_handle_attr_cpu (const char *str) switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing name in % pragma or attribute"); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("invalid name (\"%s\") in % pragma or attribute", str); aarch64_print_hint_for_core (str); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %s of value (\"%s\") in " "% pragma or attribute", invalid_extension.c_str (), str); aarch64_print_hint_for_extensions (invalid_extension); @@ -17484,23 +17284,23 @@ aarch64_handle_attr_cpu (const char *str) aarch64_handle_attr_branch_protection (const char* str) { char *err_str = (char *) xmalloc (strlen (str) + 1); - enum aarch64_parse_opt_result res = aarch64_parse_branch_protection (str, - &err_str); + enum aarch_parse_opt_result res = aarch_parse_branch_protection (str, + &err_str); bool success = false; switch (res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing argument to % pragma or" " attribute"); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("invalid protection type (\"%s\") in % pragma or attribute", err_str); break; - case AARCH64_PARSE_OK: + case AARCH_PARSE_OK: success = true; /* Fall through. */ - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: break; default: gcc_unreachable (); @@ -17515,10 +17315,10 @@ static bool aarch64_handle_attr_tune (const char *str) { const struct processor *tmp_tune = NULL; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_tune (str, &tmp_tune); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) { gcc_assert (tmp_tune); selected_tune = tmp_tune; @@ -17528,7 +17328,7 @@ aarch64_handle_attr_tune (const char *str) switch (parse_res) { - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("invalid name (\"%s\") in % pragma or attribute", str); aarch64_print_hint_for_core (str); break; @@ -17547,7 +17347,7 @@ aarch64_handle_attr_tune (const char *str) static bool aarch64_handle_attr_isa_flags (char *str) { - enum aarch64_parse_opt_result parse_res; + enum aarch_parse_opt_result parse_res; uint64_t isa_flags = aarch64_isa_flags; /* We allow "+nothing" in the beginning to clear out all architectural @@ -17561,7 +17361,7 @@ aarch64_handle_attr_isa_flags (char *str) std::string invalid_extension; parse_res = aarch64_parse_extension (str, &isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) { aarch64_isa_flags = isa_flags; return true; @@ -17569,11 +17369,11 @@ aarch64_handle_attr_isa_flags (char *str) switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing value in % pragma or attribute"); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %s of value (\"%s\") in " "% pragma or attribute", invalid_extension.c_str (), str); break; @@ -21473,7 +21273,7 @@ void aarch64_post_cfi_startproc (FILE *f, tree ignored ATTRIBUTE_UNUSED) { if (cfun->machine->frame.laid_out && aarch64_return_address_signing_enabled () - && aarch64_ra_sign_key == AARCH64_KEY_B) + && aarch_ra_sign_key == AARCH_KEY_B) asm_fprintf (f, "\t.cfi_b_key_frame\n"); } @@ -25574,7 +25374,7 @@ aarch64_file_end_indicate_exec_stack () if (aarch64_bti_enabled ()) feature_1_and |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI; - if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE) + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE) feature_1_and |= GNU_PROPERTY_AARCH64_FEATURE_1_PAC; if (feature_1_and) diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 1a39470a1feeb8d23a3d0d4f8a9b54535f769fd9..de6052b588ac6e8537ec0c8c40cc1476d3dfa8f5 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -882,7 +882,7 @@ && (TARGET_PAUTH) && !crtl->calls_eh_return) { - if (aarch64_ra_sign_key == AARCH64_KEY_B) + if (aarch_ra_sign_key == AARCH_KEY_B) ret = "retab"; else ret = "retaa"; diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt index 32191cf1acf43302c4a544b85db60b7b6e14da48..0739a4fe0064c0359107cde3c1c34dae43075fa6 100644 --- a/gcc/config/aarch64/aarch64.opt +++ b/gcc/config/aarch64/aarch64.opt @@ -21,6 +21,9 @@ HeaderInclude config/aarch64/aarch64-opts.h +HeaderInclude +config/arm/aarch-common.h + TargetVariable enum aarch64_processor explicit_tune_core = aarch64_none @@ -34,7 +37,7 @@ TargetVariable uint64_t aarch64_isa_flags = 0 TargetVariable -unsigned aarch64_enable_bti = 2 +unsigned aarch_enable_bti = 2 ; The TLS dialect names to use with -mtls-dialect. @@ -161,21 +164,21 @@ Target RejectNegative Joined Var(aarch64_branch_protection_string) Save Use branch-protection features. msign-return-address= -Target WarnRemoved RejectNegative Joined Enum(aarch64_ra_sign_scope_t) Var(aarch64_ra_sign_scope) Init(AARCH64_FUNCTION_NONE) Save +Target WarnRemoved RejectNegative Joined Enum(aarch_ra_sign_scope_t) Var(aarch_ra_sign_scope) Init(AARCH_FUNCTION_NONE) Save Select return address signing scope. Enum -Name(aarch64_ra_sign_scope_t) Type(enum aarch64_function_type) +Name(aarch_ra_sign_scope_t) Type(enum aarch_function_type) Supported AArch64 return address signing scope (for use with -msign-return-address= option): EnumValue -Enum(aarch64_ra_sign_scope_t) String(none) Value(AARCH64_FUNCTION_NONE) +Enum(aarch_ra_sign_scope_t) String(none) Value(AARCH_FUNCTION_NONE) EnumValue -Enum(aarch64_ra_sign_scope_t) String(non-leaf) Value(AARCH64_FUNCTION_NON_LEAF) +Enum(aarch_ra_sign_scope_t) String(non-leaf) Value(AARCH_FUNCTION_NON_LEAF) EnumValue -Enum(aarch64_ra_sign_scope_t) String(all) Value(AARCH64_FUNCTION_ALL) +Enum(aarch_ra_sign_scope_t) String(all) Value(AARCH_FUNCTION_ALL) mlow-precision-recip-sqrt Target Var(flag_mrecip_low_precision_sqrt) Optimization diff --git a/gcc/config/arm/aarch-common-protos.h b/gcc/config/arm/aarch-common-protos.h index 6be5fb1e083d7ff130386dfa181b9a0c8fd5437c..bea0f306ecf641429d03df3f6b1440e5dd80f907 100644 --- a/gcc/config/arm/aarch-common-protos.h +++ b/gcc/config/arm/aarch-common-protos.h @@ -150,4 +150,10 @@ rtx_insn *arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t loc); +/* Parsing routine for branch-protection common to AArch64 and Arm. */ +enum aarch_parse_opt_result aarch_parse_branch_protection (const char*, char**); + +/* Validation routine for branch-protection common to AArch64 and Arm. */ +bool aarch_validate_mbranch_protection (const char *); + #endif /* GCC_AARCH_COMMON_PROTOS_H */ diff --git a/gcc/config/arm/aarch-common.h b/gcc/config/arm/aarch-common.h new file mode 100644 index 0000000000000000000000000000000000000000..486726a61fdaaa54457ad06f663446487a20e701 --- /dev/null +++ b/gcc/config/arm/aarch-common.h @@ -0,0 +1,73 @@ +/* Types shared between arm and aarch64. + + Copyright (C) 1991-2021 Free Software Foundation, Inc. + Contributed by ARM Ltd. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef GCC_AARCH_COMMON_H +#define GCC_AARCH_COMMON_H + +/* Enum describing the various ways that the + aarch*_parse_{arch,tune,cpu,extension} functions can fail. + This way their callers can choose what kind of error to give. */ + +enum aarch_parse_opt_result +{ + AARCH_PARSE_OK, /* Parsing was successful. */ + AARCH_PARSE_MISSING_ARG, /* Missing argument. */ + AARCH_PARSE_INVALID_FEATURE, /* Invalid feature modifier. */ + AARCH_PARSE_INVALID_ARG /* Invalid arch, tune, cpu arg. */ +}; + +/* Function types -msign-return-address should sign. */ +enum aarch_function_type { + /* Don't sign any function. */ + AARCH_FUNCTION_NONE, + /* Non-leaf functions. */ + AARCH_FUNCTION_NON_LEAF, + /* All functions. */ + AARCH_FUNCTION_ALL +}; + +/* The key type that -msign-return-address should use. */ +enum aarch_key_type { + AARCH_KEY_A, + AARCH_KEY_B +}; + +struct aarch_branch_protect_type +{ + /* The type's name that the user passes to the branch-protection option + string. */ + const char* name; + /* Function to handle the protection type and set global variables. + First argument is the string token corresponding with this type and the + second argument is the next token in the option string. + Return values: + * AARCH_PARSE_OK: Handling was sucessful. + * AARCH_INVALID_ARG: The type is invalid in this context and the caller + should print an error. + * AARCH_INVALID_FEATURE: The type is invalid and the handler prints its + own error. */ + enum aarch_parse_opt_result (*handler)(char*, char*); + /* A list of types that can follow this type in the option string. */ + const struct aarch_branch_protect_type* subtypes; + unsigned int num_subtypes; +}; + +#endif /* GCC_AARCH_COMMON_H */ diff --git a/gcc/config/arm/aarch-common.c b/gcc/config/arm/aarch-common.c index 67343fe40250221c8b791f7776c39a2d2287cc35..26631572a39c543d615f5f7c76eba0387990300f 100644 --- a/gcc/config/arm/aarch-common.c +++ b/gcc/config/arm/aarch-common.c @@ -36,6 +36,7 @@ #include "expr.h" #include "function.h" #include "emit-rtl.h" +#include "aarch-common.h" /* Return TRUE if X is either an arithmetic shift left, or is a multiplication by a power of two. */ @@ -657,3 +658,187 @@ arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, return saw_asm_flag ? seq : NULL; } + +#include "aarch-common.h" + +#define BRANCH_PROTECT_STR_MAX 255 +extern char *accepted_branch_protection_string; +extern enum aarch_key_type aarch_ra_sign_key; + +static enum aarch_parse_opt_result +aarch_handle_no_branch_protection (char* str, char* rest) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NONE; + aarch_enable_bti = 0; + if (rest) + { + error ("unexpected %<%s%> after %<%s%>", rest, str); + return AARCH_PARSE_INVALID_FEATURE; + } + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_standard_branch_protection (char* str, char* rest) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; + aarch_ra_sign_key = AARCH_KEY_A; + aarch_enable_bti = 1; + if (rest) + { + error ("unexpected %<%s%> after %<%s%>", rest, str); + return AARCH_PARSE_INVALID_FEATURE; + } + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_pac_ret_protection (char* str ATTRIBUTE_UNUSED, + char* rest ATTRIBUTE_UNUSED) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; + aarch_ra_sign_key = AARCH_KEY_A; + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_pac_ret_leaf (char* str ATTRIBUTE_UNUSED, + char* rest ATTRIBUTE_UNUSED) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_ALL; + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_pac_ret_b_key (char* str ATTRIBUTE_UNUSED, + char* rest ATTRIBUTE_UNUSED) +{ + aarch_ra_sign_key = AARCH_KEY_B; + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_bti_protection (char* str ATTRIBUTE_UNUSED, + char* rest ATTRIBUTE_UNUSED) +{ + aarch_enable_bti = 1; + return AARCH_PARSE_OK; +} + +static const struct aarch_branch_protect_type aarch_pac_ret_subtypes[] = { + { "leaf", aarch_handle_pac_ret_leaf, NULL, 0 }, + { "b-key", aarch_handle_pac_ret_b_key, NULL, 0 }, + { NULL, NULL, NULL, 0 } +}; + +static const struct aarch_branch_protect_type aarch_branch_protect_types[] = { + { "none", aarch_handle_no_branch_protection, NULL, 0 }, + { "standard", aarch_handle_standard_branch_protection, NULL, 0 }, + { "pac-ret", aarch_handle_pac_ret_protection, aarch_pac_ret_subtypes, + ARRAY_SIZE (aarch_pac_ret_subtypes) }, + { "bti", aarch_handle_bti_protection, NULL, 0 }, + { NULL, NULL, NULL, 0 } +}; + +/* Parses CONST_STR for branch protection features specified in + aarch64_branch_protect_types, and set any global variables required. Returns + the parsing result and assigns LAST_STR to the last processed token from + CONST_STR so that it can be used for error reporting. */ + +enum aarch_parse_opt_result +aarch_parse_branch_protection (const char *const_str, char** last_str) +{ + char *str_root = xstrdup (const_str); + char* token_save = NULL; + char *str = strtok_r (str_root, "+", &token_save); + enum aarch_parse_opt_result res = AARCH_PARSE_OK; + if (!str) + res = AARCH_PARSE_MISSING_ARG; + else + { + char *next_str = strtok_r (NULL, "+", &token_save); + /* Reset the branch protection features to their defaults. */ + aarch_handle_no_branch_protection (NULL, NULL); + + while (str && res == AARCH_PARSE_OK) + { + const aarch_branch_protect_type* type = aarch_branch_protect_types; + bool found = false; + /* Search for this type. */ + while (type && type->name && !found && res == AARCH_PARSE_OK) + { + if (strcmp (str, type->name) == 0) + { + found = true; + res = type->handler (str, next_str); + str = next_str; + next_str = strtok_r (NULL, "+", &token_save); + } + else + type++; + } + if (found && res == AARCH_PARSE_OK) + { + bool found_subtype = true; + /* Loop through each token until we find one that isn't a + subtype. */ + while (found_subtype) + { + found_subtype = false; + const aarch_branch_protect_type *subtype = type->subtypes; + /* Search for the subtype. */ + while (str && subtype && subtype->name && !found_subtype + && res == AARCH_PARSE_OK) + { + if (strcmp (str, subtype->name) == 0) + { + found_subtype = true; + res = subtype->handler (str, next_str); + str = next_str; + next_str = strtok_r (NULL, "+", &token_save); + } + else + subtype++; + } + } + } + else if (!found) + res = AARCH_PARSE_INVALID_ARG; + } + } + /* Copy the last processed token into the argument to pass it back. + Used by option and attribute validation to print the offending token. */ + if (last_str) + { + if (str) strcpy (*last_str, str); + else *last_str = NULL; + } + if (res == AARCH_PARSE_OK) + { + /* If needed, alloc the accepted string then copy in const_str. + Used by override_option_after_change_1. */ + if (!accepted_branch_protection_string) + accepted_branch_protection_string = (char *) xmalloc ( + BRANCH_PROTECT_STR_MAX + + 1); + strncpy (accepted_branch_protection_string, const_str, + BRANCH_PROTECT_STR_MAX + 1); + /* Forcibly null-terminate. */ + accepted_branch_protection_string[BRANCH_PROTECT_STR_MAX] = '\0'; + } + return res; +} + +bool +aarch_validate_mbranch_protection (const char *const_str) +{ + char *str = (char *) xmalloc (strlen (const_str)); + enum aarch_parse_opt_result res = + aarch_parse_branch_protection (const_str, &str); + if (res == AARCH_PARSE_INVALID_ARG) + error ("invalid argument %<%s%> for %<-mbranch-protection=%>", str); + else if (res == AARCH_PARSE_MISSING_ARG) + error ("missing argument for %<-mbranch-protection=%>"); + free (str); + return res == AARCH_PARSE_OK; +} diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 9b1f61394ad7d778a6c0b84bc6c805f14709f598..463ecdc4f363604a7349aad557cd207fe291458e 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -577,6 +577,8 @@ struct cpu_option extern const arch_option all_architectures[]; extern const cpu_option all_cores[]; +extern enum aarch_key_type aarch_ra_sign_key; + const cpu_option *arm_parse_cpu_option_name (const cpu_option *, const char *, const char *, bool = true); const arch_option *arm_parse_arch_option_name (const arch_option *, diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index c4ff06b087ebecc91c419cb4ecf009c3535955df..a952655db80663f28f5a5d12005f2adb4702894f 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -72,6 +72,8 @@ #include "selftest.h" #include "tree-vectorizer.h" #include "opts.h" +#include "aarch-common.h" +#include "aarch-common-protos.h" /* This file should be included last. */ #include "target-def.h" @@ -2390,6 +2392,11 @@ const struct tune_params arm_fa726te_tune = tune_params::SCHED_AUTOPREF_OFF }; +/* Key type for Pointer Authentication extension. */ +enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A; + +char *accepted_branch_protection_string = NULL; + /* Auto-generated CPU, FPU and architecture tables. */ #include "arm-cpu-data.h" diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt index a7677eeb45c805d6a314f4d1d2d6063d8c0b687c..5c5b4f3ae0699a3a9d78df40a5ab65324dcba7b9 100644 --- a/gcc/config/arm/arm.opt +++ b/gcc/config/arm/arm.opt @@ -21,6 +21,15 @@ HeaderInclude config/arm/arm-opts.h +HeaderInclude +config/arm/aarch-common.h + +TargetVariable +enum aarch_function_type aarch_ra_sign_scope = AARCH_FUNCTION_NONE + +TargetVariable +unsigned aarch_enable_bti = 2 + Enum Name(tls_type) Type(enum arm_tls_type) TLS dialect to use: From patchwork Thu Oct 28 11:41:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46740 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 4EEB63858410 for ; Thu, 28 Oct 2021 11:43:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4EEB63858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421420; bh=XVHoefkTB+i+/S/o1Px7nKteOc7WWUAlGFVkYrjAwKI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GTwTwjwXcBwmeOaB8qOlfuIksOO2yB+q4edLzOOC88bCMT64wcDwgsHMr4x8zSkbP dTbQXNYlsgSlcb8pGQGPrUUOB20niOw4oIsD132t3WeccDhFnjsvRUoUxViK/SORLH H9XP20oO54RvW0TKZlendYg+mvH/KhFfbad899j0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150050.outbound.protection.outlook.com [40.107.15.50]) by sourceware.org (Postfix) with ESMTPS id 9A2193857C6F for ; Thu, 28 Oct 2021 11:42:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A2193857C6F Received: from DB6PR1001CA0005.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::15) by DB8PR08MB5001.eurprd08.prod.outlook.com (2603:10a6:10:e3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Thu, 28 Oct 2021 11:42:07 +0000 Received: from DB5EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b7:cafe::bf) by DB6PR1001CA0005.outlook.office365.com (2603:10a6:4:b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:42:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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 DB5EUR03FT056.mail.protection.outlook.com (10.152.21.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:42:07 +0000 Received: ("Tessian outbound c71e1a752bff:v108"); Thu, 28 Oct 2021 11:42:07 +0000 X-CR-MTA-TID: 64aa7808 Received: from fc69481cf55a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D3EA3F75-83BA-44BA-AC3B-38B61D4644B1.1; Thu, 28 Oct 2021 11:41:56 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fc69481cf55a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:41:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UeMH0f7c+SgiOUYF62/N4P79avDqXrqtxTsDrBjDjHXAJUAJfAnI3p/ui9LRtxedLx7BWT/oGPsh2vd94BK4XZ0n13QXVTObI41o2REGHmemHPy+8VyOsPK/1x30lRQHRfTEYMOJeisMSSTtpNZ+ojoKZJiT6SF5DEUF282bhV8yl5KPcL/wZxUwffuDVpNsKCvsx1Zft6H2HIfoI4TbawEt/IrEM6S/2vXdkW/7cy6plHlKFdszMoHjAs039NW+F59psr8ZaiqGbNSNw6iaTA4fR+1k1hmmjzBvm/KkpxkuZ5HuqcZlIgpD7o4ybsU7jVajBnuU1Gq/a1buwJzMUg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XVHoefkTB+i+/S/o1Px7nKteOc7WWUAlGFVkYrjAwKI=; b=S8nOsVlJYZ4nn/jCWjrCxkFwAj+U7srXG5GuQHJrheNbv8lIMWKN69P7zD8geOiGO0zN9NiN0W5VW2CKn+sZvJy5a0DfzSzzUkd7pXUq1/hHn5wiXP0IEoP82qudF83TxBoa/K6F8t1SKkSU3kaTPEmbrbwYSI72woXgMUVdj5oSDGyvx9ckhidJvGrvx4Vh+8h4tE4Hq6srBMcfkoYkl2PysR09oVaDcV9x9u0AgrGBPDgB+4SIH2zyJH7fds9eFBLrMTaj//7V0rTDOhUi1XAKwx5sXhwKWV/GzwPXv8elQILvXPK68vUUSXEtSl+iBW/uLftX91Ut9dn3K6F0EA== 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 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7123.eurprd08.prod.outlook.com (2603:10a6:102:206::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Thu, 28 Oct 2021 11:41:53 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:41:53 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 2/8, Arm, GCC] Add Armv8.1-M Mainline target feature +pacbti. [Was RE: [Patch 1/7, Arm, GCC] Add Armv8.1-M Mainline target feature +pacbti.] Thread-Topic: [Patch 2/8, Arm, GCC] Add Armv8.1-M Mainline target feature +pacbti. [Was RE: [Patch 1/7, Arm, GCC] Add Armv8.1-M Mainline target feature +pacbti.] Thread-Index: AdfL676lIMUySIDYSt+hS2nb4v5SGQ== Date: Thu, 28 Oct 2021 11:41:53 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: DA024D552C264C4DA206DCF720774614.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 3a51fed7-9b98-4f24-205c-08d99a07f88b x-ms-traffictypediagnostic: PAXPR08MB7123:|DB8PR08MB5001: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dIKWb+XkiBFGIn6r9Ot81DJfS10EwCvvkGD4vMsoes5fjEdHlMrROaBHZcnB8AMTyalFMzy2NtK4BcYpW4FF1T7RWZK9qA+/yhCiugSgI6MxmKl2Xsqy/MtsdRkfEsS6vnolSksZMuE6tehckeN4FgMCK1SRDYdk5bxehq8Rg8e/y7Ti976MfnONvtrLDSHXsnALt9KQuk3XStIs0h/yVtYnImud/j6HxBr9hNZKhwiYGL652cDfdRSsW7Z0aDOd4cf4vD3j4KVAi/IyqZlLB61B7WQDPEG4SBlMHrkjEI7sSCiOWeXzWXLDIO46X0qUm3CLTyb+ftaTIJaSqgqSZ0zuPLLmsiXHrKcqN2hbtQ2igk8nd62LrfJJrBGmBFlp1MDtxOuste2ClDkZfRyGsy8MePWufjcu2DabWxYWbceBJHGFXv3u8Ng95N8pZ2jGWQ3bz2/rpoJVNNGG6V/pTeK4ONJ+l0flhiBwhEKpwVHykEEeCSKlxX1egPaQ1CtHy27JlsDMrJyYa8dRHUXwTxfaqNZCfT82FN2h5hD9dzmIEACF3oqQ16yqJuVt6J1y83k2g9qR/KRZN9sO9T/UL0aPXI9W/2lisHRitOKYLuU1ie/EDkMpVliF8OXUpa6MbWoD74EBht/tJ6xrQ5MLHVu1Ha4ky89rgl31wRH1AvL2nbQPef5qCQ0pP+r5RcnZwEAqeT1n1r2nZ70FhF4WGg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(2906002)(71200400001)(33656002)(7696005)(83380400001)(38070700005)(99936003)(4001150100001)(66946007)(6506007)(9686003)(76116006)(38100700002)(53546011)(26005)(55016002)(52536014)(508600001)(186003)(110136005)(122000001)(316002)(66446008)(66556008)(8936002)(64756008)(66476007)(5660300002)(8676002)(86362001); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7123 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: fe46daed-2150-4b6a-e5ab-08d99a07f018 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2KSNYpjgaO/lZyueAGZgoirV3ASuPnIZ6wvHnY8qBQeZyjZS/xWKWaR2tPO79Ox8YrKApRvaGL9aFJs/bFPxdhPXvznyLzigPQdJ8yt9fP2iLvR8UFxMQ8wfRVdnCGX1fMYfHoGVtk/oKjj9SSKtkS0IDOZOiL73kmYq6eh/a9DZYLmmmc5EytHsbdo3QI0qXIY6qRyfr5bxc2SrrHfE8856WUjcQJhkGykdlaaRTRs2080PL3IEJet4LQjfPQCCUiTlrDCBTI5ASSavNyqSrka5+IVrKtRHGZgCDphVNVKuNobS2j9mbDIUdx5ibk4qKmqiBUUOHL6oQBAwlKpvh5Ee+IMQdtLlx1P/tvS2OCTQJv7RD5mp/Ff0GtNx3cbkzrnWTTKMvgDsoed5yl7YklS1cZApWQpoyrNRTwedcXdffT/rHZp/NntpdVlZC6BKeNv8MHqZO6IakYQR5eDUqrrS51jDoQ41EDyY/+z19k6tdtMmPPCxnTB+2HyecuMEC4RLuTrJn/B+OW8ii/PiHksVrTADQ7RNauCgFg7UBahqNLsWJLhwGCPaEHi1T231CG0ccGAyFEmcrEOUEmBp8pMtpxdv9GVBjaY5ipbz+mXS6fpuSTiivTYpMCC0iRTPyeAVNMJ3DppTyCPApjocy2q5i+GI7fo1XX9bTk4ZF5p5vHXIJetW+IWeh1yVoDg22mSTqxZJCj6iX2hBr+nMug== 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; SFS:(4636009)(36840700001)(46966006)(508600001)(21480400003)(36860700001)(82310400003)(8936002)(33964004)(4001150100001)(7696005)(53546011)(235185007)(336012)(316002)(83380400001)(70206006)(70586007)(5660300002)(99936003)(110136005)(33656002)(86362001)(26005)(8676002)(2906002)(356005)(47076005)(9686003)(52536014)(55016002)(6506007)(186003)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:42:07.4871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a51fed7-9b98-4f24-205c-08d99a07f88b 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: DB5EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5001 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Richard Earnshaw > Sent: Monday, October 11, 2021 1:29 PM > To: Tejas Belagod ; gcc-patches@gcc.gnu.org > Subject: Re: [Patch 1/7, Arm, GCC] Add Armv8.1-M Mainline target feature > +pacbti. > > On 08/10/2021 13:17, Tejas Belagod via Gcc-patches wrote: > > Hi, > > > > This patch adds the -march feature +pacbti to Armv8.1-M Mainline. > > This feature enables pointer signing and authentication instructions > > on M-class architectures. > > > > Tested on arm-none-eabi. OK for trunk? > > > > 2021-10-04 Tejas Belagod > > > > gcc/Changelog: > > > > * config/arm/arm-cpus.in: Define new feature pacbti. > > * config/arm/arm.h (TARGET_HAVE_PACBTI): New. > > > > "+pacbti" needs to be documented in invoke.texi at the appropriate place. > Thanks for the reviews. This patch adds the -march feature +pacbti to Armv8.1-M Mainline. This feature enables pointer signing and authentication instructions on M-class architectures. 2021-10-25 Tejas Belagod gcc/Changelog: * config/arm/arm-cpus.in: Define new feature pacbti. * config/arm/arm.h (TARGET_HAVE_PACBTI): New. * doc/invoke.texi: Document new feature pacbti. Tested the following configurations, OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap > R. diff --git a/gcc/config/arm/arm-cpus.in b/gcc/config/arm/arm-cpus.in index d0d0d0f1c7e4176fc4aa30d82394fe938b083a59..8a0e9c79682766ee2bec3fd7ba6ed67dff69dbad 100644 --- a/gcc/config/arm/arm-cpus.in +++ b/gcc/config/arm/arm-cpus.in @@ -223,6 +223,10 @@ define feature cdecp5 define feature cdecp6 define feature cdecp7 +# M-profile control flow integrity extensions (PAC/AUT/BTI). +# Optional from Armv8.1-M Mainline. +define feature pacbti + # Feature groups. Conventionally all (or mostly) upper case. # ALL_FPU lists all the feature bits associated with the floating-point # unit; these will all be removed if the floating-point unit is disabled @@ -741,6 +745,7 @@ begin arch armv8.1-m.main option nofp remove ALL_FP option mve add MVE option mve.fp add MVE_FP + option pacbti add pacbti option cdecp0 add cdecp0 option cdecp1 add cdecp1 option cdecp2 add cdecp2 diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 015299c15346f1bea59d70fdcb1d19545473b23b..8e6ef41f6b065217d1af3f4f1cb85b2d8fbd0dc0 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -335,6 +335,12 @@ emission of floating point pcs attributes. */ isa_bit_mve_float) \ && !TARGET_GENERAL_REGS_ONLY) +/* Non-zero if this target supports Armv8.1-M Mainline pointer-signing + extension. */ +#define TARGET_HAVE_PACBTI (arm_arch8_1m_main \ + && bitmap_bit_p (arm_active_target.isa, \ + isa_bit_pacbti)) + /* MVE have few common instructions as VFP, like VLDM alias VPOP, VLDR, VSTM alia VPUSH, VSTR and VMOV, VMSR and VMRS. In the same manner it updates few registers such as FPCAR, FPCCR, FPDSCR, FPSCR, MVFR0, MVFR1 and MVFR2. All diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 71992b8c59749f5508a3c6a1b1792910652eac57..27df8cf5bee79c2abac8b81c1ac54f1c3e50c628 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -20469,6 +20469,9 @@ Disable the floating-point extension. @item +cdecp0, +cdecp1, ... , +cdecp7 Enable the Custom Datapath Extension (CDE) on selected coprocessors according to the numbers given in the options in the range 0 to 7. + +@item +pacbti +Enable the Pointer Authentication and Branch Target Identification Extension. @end table @item armv8-m.main From patchwork Thu Oct 28 11:42:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46741 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 3B6A53857C74 for ; Thu, 28 Oct 2021 11:44:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B6A53857C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421479; bh=mBcCr6dFFnrfgmru26iyvfnAOgQHBFS/avRC24cwGDM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=TCrs9p9F8FksCm7UbFJRPSHJMgk76YYwsu+ir45fDPopIW5njPTC+/zP0VuwhN3MR 6JxHFZ+G4IqKuf1zKqV6bk8KRhXUywi8ucVbpoybTYy+w71LyQGTEVuHf2JUDm8nKy +PkRscOY/wutUHLsLa0lBSRsu6hk1ZAiWJcBQGow= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2056.outbound.protection.outlook.com [40.107.20.56]) by sourceware.org (Postfix) with ESMTPS id 6DECD3857C7A for ; Thu, 28 Oct 2021 11:42:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6DECD3857C7A Received: from DB8PR03CA0009.eurprd03.prod.outlook.com (2603:10a6:10:be::22) by AM7PR08MB5447.eurprd08.prod.outlook.com (2603:10a6:20b:10b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Thu, 28 Oct 2021 11:42:29 +0000 Received: from DB5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:be:cafe::88) by DB8PR03CA0009.outlook.office365.com (2603:10a6:10:be::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:42:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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 DB5EUR03FT014.mail.protection.outlook.com (10.152.20.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:42:29 +0000 Received: ("Tessian outbound 6ebd41198c5d:v108"); Thu, 28 Oct 2021 11:42:29 +0000 X-CR-MTA-TID: 64aa7808 Received: from fda0f00b0952.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 22750B36-D0F5-48E9-87E6-BF4A9D516FD6.1; Thu, 28 Oct 2021 11:42:19 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fda0f00b0952.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:42:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DWxDfQi8qWXLm5XorHqZqPt6+oD3BlQxPNpT9CShB/wSJP2TT07R6PgbyLmXusch1Akd1AZz6t39jqOwCvsdQ8ioGuhoGOFoXDxcOxAdrnTDwy2F4wRCKzWhTIjhexadV0SZTxb8oMs5/H5vWj5mjsAyEndfEiCU9/gOCOQSO6aM38tRXd/Xy2r8lgrU8a6iMQ3pJ8DaRgmmtCTqe56IWG7b3U+W2Qfy7NjbLBeZH5Ejm7bC2JxN9H1cFv5hfJfjvHmFBhi3RJavugnHCn1ov3W+IFQiFNRt0vyZ/iC/wcrYT+C+zMghLGz6jtWHgtxH4q6RJ32GI+Z/h3EIdhYuSQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mBcCr6dFFnrfgmru26iyvfnAOgQHBFS/avRC24cwGDM=; b=BW+bBRlRtJ475svArjNuET8VYLDcmPDSG+eIweW5tb9dHxjBfzzo2XRmyxnnfh8t4kag5V0crHHV4B+cwRVf/NWg4z3prtZNH0KZDtv8Ys0yToVzLur6jGMGZH/UpYGDBXCEYPFKxbmqZ3VInzZ7eTj1IPNwwD45YzHROLg9lx2iL63ibgh/ZK0OyHjXlcPA/oKjMDCW7T9LP7X/xoE7hl3mVIJmRv1Zg74jmdC+m5kEDQP5eC6IEc0iMK9aTqSZTTEaZtC99oY/ekSaXeJ0JYb/09cdYEQVbN2ToHd2aCNQVdxbJlYLkT+WOxAyo9FEpB+xa+OOvDsDbHvjU2fBcA== 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 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7123.eurprd08.prod.outlook.com (2603:10a6:102:206::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Thu, 28 Oct 2021 11:42:16 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:42:16 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 3/8, Arm, GCC] Add option -mbranch-protection. [Was RE: [Patch 2/7, Arm, GCC] Add option -mbranch-protection.] Thread-Topic: [Patch 3/8, Arm, GCC] Add option -mbranch-protection. [Was RE: [Patch 2/7, Arm, GCC] Add option -mbranch-protection.] Thread-Index: AdfL7BKI2laQ6UQ8RLSiOvSwvpo37g== Date: Thu, 28 Oct 2021 11:42:16 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: F2C38273A4E67F49965CCFE3DDF7BFBF.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 0eeedcfc-9bf2-495e-0e1d-08d99a0805d7 x-ms-traffictypediagnostic: PAXPR08MB7123:|AM7PR08MB5447: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: StOG+ZJo0wTZUBQgoqvtnqCZwOMJQWUsy5EEJiLcRjCF0odzMrXyPlxgyEOq5icXxMSfx1i2+Dykt2ShchHEd1haShL362yNf8NXD8O/vDUR9lms2JRjb7pKWz51fGtZIPD0UsFsZ/GOFrhec9vFfjTFchlJZITvs5vwu7fx76+hQsMcKKhO2v38QlO4Z9CfZuzrrilojmc58HeG2tfo9gcnqH3w4jIcDYRr6dTlqr8m542VbPtCDeWEQK2BeoGAlOYdTunUZ6K0raKLhZNneToNIpGm9n3ZjFbaXYxmHNb999lcpCyJlSNc2nFsH63fNbeRmk6js+9/nlxB6mPd4UDhgTARRtdGxhnW0MwxdAMoYeqbOC4nYXMuZ2sGCXj0rZTUNPlD8ilE8U+KPYay6ilGw6A/8Fe0i7fYU0/mYs2RAk8IOMP/IcreSlu0fp2BkyX9QgzBSKUz0rma7trVvp2Hru7smO3CAt6LreieMoF8ifygicxmOJB64Hr5L7yqNpX9sDygrLqwrQ9GT8oCxzd4OG5v15whYZ4RSj1K/NNhq0G2Q/UTKY3vrX+/TY/de1Yfl8BvY1SXIe86MzQvar8hxvZcqPB2JV7JSdwBavdnLhELUTISsA9Bsg7CTTSzAf1tFqZSYPdIky+d2aO1uykpWZWhsk8IuLFOTKEDBkQq2FCI6cWHlSzx62S6GOi1BVU4LfeVbf5ivWMz2o48Jg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(2906002)(71200400001)(33656002)(7696005)(83380400001)(38070700005)(99936003)(4001150100001)(66946007)(6506007)(9686003)(76116006)(38100700002)(53546011)(26005)(55016002)(52536014)(508600001)(186003)(110136005)(122000001)(316002)(66446008)(66556008)(8936002)(64756008)(66476007)(5660300002)(8676002)(86362001); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7123 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8ed6ae9a-268b-4cae-9415-08d99a07fe2e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1G1GTL8fDg1/klMJSHXo6HgD65iCMcGhtpQ13kVvOpuHm24QzO9JpOM1Am/AP9Q577W1/eBsJ8BbAyYveeEKoG4YdPZWv8bBcVT8m++5YB2IOpEOfTQ8f89BXjiHRCdtE4jT84TnHYFiSHwKkWKheB5HtVV53KdP/s7i6eSLhgSV5Krsl3ypxk9GkMbK9yEXqwvBTnlzd/tak1k7U63bLKyCH5Tqj0oVZdBDLmuGmOF5DBUeo0f7JQWLu7Kty2YWxDqaqfD4jbH3BKq1WuEBJ1b0IjwKQX8TmcW8A6DFVEbRaw+wbBdoXYMxqevVQQIUyoQQw2KlfV3YWPI3n7nsB3Z/13gj6n7UVWS8eZKY1XwXVx5VuA1tpQiN0pRbL3dIg+59okIvxMjCLqAyzBZFH9GLLgSN9QtoxNXcKbR78LvDfwnijjBiloz1w5pTygTHhMwH8eUYusuCz+ysCIYZnkg1fs/B3hNquSBMsAgp/eD9qKZiPWn8PPhDI4cAuXIjf9T1cC+AJ8o9xzKwZqFoxQ2l1nL/Qrgbmo2STwY9QzyYpaoZf5rtNYsx4GfKCGA94/2H4aKQ1lOa8G8oGXBE2Vm79th8R03dzCDFfkXP64FV3/Yxy8hB8J1CMH41yqJxrop5AcNLzT7ek5hOPpDWSU3U4Dt4RSd2aHmVE2pJVCfLjjQXuDUt1J46kGBv8Ip7vBr0kx30XD2eaX1CBbOzEw== 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; SFS:(4636009)(46966006)(36840700001)(8676002)(99936003)(86362001)(2906002)(235185007)(356005)(5660300002)(186003)(81166007)(21480400003)(47076005)(36860700001)(8936002)(82310400003)(33656002)(70586007)(55016002)(70206006)(33964004)(110136005)(336012)(9686003)(316002)(508600001)(83380400001)(4001150100001)(6506007)(52536014)(26005)(53546011)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:42:29.7951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0eeedcfc-9bf2-495e-0e1d-08d99a0805d7 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: DB5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5447 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Richard Earnshaw > Sent: Monday, October 11, 2021 1:58 PM > To: Tejas Belagod ; gcc-patches@gcc.gnu.org > Subject: Re: [Patch 2/7, Arm, GCC] Add option -mbranch-protection. > > On 08/10/2021 13:17, Tejas Belagod via Gcc-patches wrote: > > Hi, > > > > Add -mbranch-protection option and its associated parsing routines. > > This option enables the code-generation of pointer signing and > > authentication instructions in function prologues and epilogues. > > > > Tested on arm-none-eabi. OK for trunk? > > > > 2021-10-04 Tejas Belagod > > > > gcc/ChangeLog: > > > > * common/config/arm/arm-common.c > > (arm_print_hit_for_pacbti_option): New. > > (arm_progress_next_token): New. > > (arm_parse_pac_ret_clause): New routine for parsing the > > pac-ret clause for -mbranch-protection. > > (arm_parse_pacbti_option): New routine to parse all the options > > to -mbranch-protection. > > * config/arm/arm-protos.h (arm_parse_pacbti_option): Export. > > * config/arm/arm.c (arm_configure)build_target): Handle option > > to -mbranch-protection. > > * config/arm/arm.opt (mbranch-protection). New. > > (arm_enable_pacbti): New. > > > > You're missing documentation for invoke.texi. > > Also, how does this differ from the exising option in aarch64? Can the code > from that be adapted to be made common to both targets rather than doing > a new implementation? > > Finally, there are far to many manifest constants in this patch, they need > replacing with enums or #defines as appropriate if we cannot share the > aarch64 code. Thanks for the reviews. Add -mbranch-protection option. This option enables the code-generation of pointer signing and authentication instructions in function prologues and epilogues. 2021-10-25 Tejas Belagod gcc/ChangeLog: * config/arm/arm.c (arm_configure_build_target): Parse and validate -mbranch-protection option and initialize appropriate data structures. * config/arm/arm.opt: New option -mbranch-protection. * doc/invoke.texi: Document -mbranch-protection. Tested the following configurations, OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index a952655db80663f28f5a5d12005f2adb4702894f..946841526ee127105396097d143e755bdfc756f5 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3216,6 +3216,17 @@ arm_configure_build_target (struct arm_build_target *target, tune_opts = strchr (opts->x_arm_tune_string, '+'); } + if (opts->x_arm_branch_protection_string) + { + aarch_validate_mbranch_protection (opts->x_arm_branch_protection_string); + + if (aarch_ra_sign_key != AARCH_KEY_A) + { + warning (0, "invalid key type for %<-mbranch-protection=%>"); + aarch_ra_sign_key = AARCH_KEY_A; + } + } + if (arm_selected_arch) { arm_initialize_isa (target->isa, arm_selected_arch->common.isa_bits); diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt index 5c5b4f3ae0699a3a9d78df40a5ab65324dcba7b9..4f2754c3e84c436f7058ea0bd1c9f517b3a63ccd 100644 --- a/gcc/config/arm/arm.opt +++ b/gcc/config/arm/arm.opt @@ -313,6 +313,10 @@ mbranch-cost= Target RejectNegative Joined UInteger Var(arm_branch_cost) Init(-1) Cost to assume for a branch insn. +mbranch-protection= +Target RejectNegative Joined Var(arm_branch_protection_string) Save +Use branch-protection features. + mgeneral-regs-only Target RejectNegative Mask(GENERAL_REGS_ONLY) Save Generate code which uses the core registers only (r0-r14). diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 27df8cf5bee79c2abac8b81c1ac54f1c3e50c628..7f886db008a39c44819616eb2799c01822d0aae9 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -810,7 +810,9 @@ Objective-C and Objective-C++ Dialects}. -mpure-code @gol -mcmse @gol -mfix-cmse-cve-2021-35465 @gol --mfdpic} +-mfdpic @gol +-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] +[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} @emph{AVR Options} @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol @@ -20969,6 +20971,18 @@ The opposite @option{-mno-fdpic} option is useful (and required) to build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) toolchain as the one used to build the userland programs. +@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] +@opindex mbranch-protection +Select the branch protection features to use. +@samp{none} is the default and turns off all types of branch protection. +@samp{standard} turns on all types of branch protection features. If a feature +has additional tuning options, then @samp{standard} sets it to its standard +level. +@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard +level: signing functions that save the return address to memory (non-leaf +functions will practically always do this). The optional argument @samp{leaf} +can be used to extend the signing to include leaf functions. +@samp{bti} turns on branch target identification mechanism. @end table @node AVR Options From patchwork Thu Oct 28 11:42:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46742 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 6C1D13857C4E for ; Thu, 28 Oct 2021 11:45:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C1D13857C4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421544; bh=pgAxxPaQhNQLH+xuYl/i+iS4yFjqo/kxHZ65g87mh/Q=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uZbBhTCn3ry5Hbu5yF2ZgiQlGd+ICLkfG4LmH4yUKU3aB6Uiw8Oevx/VFlST98+tr TkCJmbR7HoRhxq6+ENsXs0t8hiPFEopK+Ql6uCwn0aQquGOMmBIG5GXpakXKwhcbLT lbkYX6b0BirIkKsY1hdkWPB60mIcKIq1/ccwYYhM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80053.outbound.protection.outlook.com [40.107.8.53]) by sourceware.org (Postfix) with ESMTPS id 5B56B3857C56 for ; Thu, 28 Oct 2021 11:42:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B56B3857C56 Received: from DU2PR04CA0049.eurprd04.prod.outlook.com (2603:10a6:10:234::24) by VI1PR08MB4045.eurprd08.prod.outlook.com (2603:10a6:803:dd::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Thu, 28 Oct 2021 11:42:47 +0000 Received: from DB5EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:234:cafe::1a) by DU2PR04CA0049.outlook.office365.com (2603:10a6:10:234::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:42:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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 DB5EUR03FT055.mail.protection.outlook.com (10.152.21.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:42:47 +0000 Received: ("Tessian outbound 7b0bcc4a550a:v108"); Thu, 28 Oct 2021 11:42:47 +0000 X-CR-MTA-TID: 64aa7808 Received: from d1e856ed3bb6.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 25680E0F-7C5B-4BCC-A0D1-19DCC92602F0.1; Thu, 28 Oct 2021 11:42:36 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d1e856ed3bb6.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:42:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ykh5UY7EAMfKF42rcApQc8+/dWOpB9aiUwryA6aJ0ewx86Mdpg0PdMAHugO//DFdFI73nhE6NmW4QUjJmMq/5SK4QeOn9smLVyxQONYfiRaVxCObAK1BLCnYn3qLaseK2HXoSuMN3sgaLGq1xWg5Y9rWkpWF2yiMSusJ8nh6R6n414LgjjlKlzP5Jvdk0lvbitalG+SajqieiRtV1BHD0duRbQF+5nrureUZq2hO88UNYxsjPZb8zCac0/Ry68BUvpVsxyjBCoX0i4iGZrWz6u317SemK58I1YbfaGtzP6rNgs1D+9NnC/qWUrkMPlzLz0BlxxBO+VdlPcg9L3cF+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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pgAxxPaQhNQLH+xuYl/i+iS4yFjqo/kxHZ65g87mh/Q=; b=YTI3lHP8ljpLCFedogBYS4bNwFtyRd5sIr/l6l/KHTzZ/J5M0UdLNYBVYnsLAvq/7X0UvFeO//V7g/4S05FPG3zixr39T3UzxqL7+jJnLeeO6SwPAYjBWYQ53hpLf1M1ZlDCAkyugMhmanGhZhBRpPQ4f16tLex+6nh25W2ixoBM/J+gp77UjrfUDulK1r2I0KMXYG+f+kA2skqqYx6X7Spxmlqnl84ckau5x66rh8rw8tgEGO4OrNb6w0LcuHmyy3HARi67m97WSt3PlT4Cr3P6U3w42ci6HxeOkohCtVcy5SRC33hyOU7lmexKFIqt5pUjHX/o4+9cORRmjOUJ7Q== 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 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7105.eurprd08.prod.outlook.com (2603:10a6:102:203::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Thu, 28 Oct 2021 11:42:35 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:42:35 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 4/8, Arm. GCC] Add testsuite library support for PACBTI target. [Was RE: [Patch 3/7, Arm, GCC] Add testsuite library support for PACBTI target.] Thread-Topic: [Patch 4/8, Arm. GCC] Add testsuite library support for PACBTI target. [Was RE: [Patch 3/7, Arm, GCC] Add testsuite library support for PACBTI target.] Thread-Index: AdfL7NWdMpISI84oQwamqek1K3045w== Date: Thu, 28 Oct 2021 11:42:35 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: 6B81A58E9D265640A0C9A73C1A2F44F5.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: e6986c79-9c02-483c-2639-08d99a081087 x-ms-traffictypediagnostic: PAXPR08MB7105:|VI1PR08MB4045: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: DlOX/VskV2DnK/JiT2CfvR0r22fkJPP8ZThdX9fmX2Z9kxkMGnFNCrnZX1mod5EmwXESkQerBTrYmR4jHBeSY1vUd6E2TmzndlAv8mmiD8Q7qIgEozqcbLfyo140xenhyfCoQKXClfwtOeu0LSoYNhfRugBQ9vs6mmrCC8q1xBS8wuzH9+KbaEKs1DFP6Z4ZeMa/3hHHZU0HAoasmf0VtM+KLi96nfDtPf0WMPYRzTMuL6WZu3XxpFMYZSqEuGssu/BXKhwrNjkilGOxNBMtLGl80rF8eJojbnQClwlGWC87MzygLzGu1vSx6YHCq5byRNSc3P6UaVDWLPiHRA8yEgCBmDi319czsa+94GrI/z6xp5IcvFPa/7Db32NtMsHWL4ydqOHv0B0yPW9feB2wLkNDFyR4uLgSU1JAumdA7bu4rsu3OtHr13m81pgeu45IVmogwXtSu7+o3YFMASZZ7pC8dUjwXlT2Q0D3u/u0A+UsUnJSx/fEk9KP0B5hAQTJgG8Nwhwod9J4P/lC5cIlCzLgQmOqbbXE85edZNpqN2sUx8Dd/fRD2Yc+2FBkvrM35bH+g3HBtgrwaGhy/m6qP3AJjOVwMRXWNq2h+i2j5MU44sMLDfzhXU1Tdmgw5Ix9tOmQ34J6zFigql/GsJ95u0j+bTiIDc+a7WteSN/ZGGzjW83tgDHS0Dc9icH8c8TI8tEogFWCgmsZ7sN3FuwXDg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66556008)(71200400001)(66446008)(66476007)(66946007)(8676002)(64756008)(110136005)(4001150100001)(86362001)(122000001)(38100700002)(76116006)(8936002)(99936003)(83380400001)(6506007)(38070700005)(7696005)(53546011)(2906002)(52536014)(5660300002)(33656002)(55016002)(9686003)(26005)(508600001)(186003)(316002); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7105 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ab997be2-c266-44f8-acf1-08d99a08091a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b4/1nC21OlorsqOQ2/wXJP+zrBjbW0Tm0ZcnFFYyksToyuVDGTFIHr1pRZthNqeg5X8jrFgP8mSEtCzvk3GqCiyEDm+dtNt731jqgnQp7YqEX3pp6CeZY87y6/b/xkqGCnm+n2/4wMym6xdAbaY3RnZUBd3db1QRlqH69W2d/rxDwtJDn8hzwdcQIp93dGWxv7QTzk4CV9ZLbRDX3Hg7M9Ir3Y+AG01C8j4ApPiL6bD6351P4d/YZeosGuHlJPIvefY8Ix9msiCuGxeJMdWju0bXp48vcTfiKMlpcuLpReAxP24O/pP3Tqk+Gy9zHQiRpOdbynN5QKO1pkFMUvGU1jjQMWEh2C//rCLGQ+VXdxrSDDxQlJ4ZCdmf8vDTfStb+xEimVyXAxx8wYzQ8UDzoXoyLCgmJGj54jN7CWINbXvgzqQsIJ5nFEpnPOO1P3Ug0CZMiKWzwVS7UMu3q4xlVKSHKGZgKS7aDIv2sHaaw+zBGvDiDIYhSSpJ3jGotcOhR8C06aaTcoIY9VkQHPv1iq7KN+QcDJPk7+83lVV20hPSEqy0jPLps6rMZNbz5TQfMgjEaKW8Xx9uNyYKs51rPt0uo1WTyJwFcJ+GPb8RBM7jgWBJ1ocHSaJDnL9JtjNfki2Qff9Bre7yCs7ehrIEZ1BLSwZrkandBsn8zjtSQy/FJGPVLNT0uD9c+z6VjJQoKUL5cpk/A0hCct5e4FuMtw== 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; SFS:(4636009)(46966006)(36840700001)(26005)(82310400003)(110136005)(52536014)(55016002)(33656002)(36860700001)(8676002)(86362001)(186003)(4001150100001)(5660300002)(99936003)(33964004)(508600001)(356005)(7696005)(336012)(81166007)(235185007)(53546011)(2906002)(8936002)(316002)(9686003)(21480400003)(47076005)(70586007)(70206006)(6506007)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:42:47.7274 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6986c79-9c02-483c-2639-08d99a081087 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: DB5EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4045 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Richard Earnshaw > Sent: Monday, October 11, 2021 2:38 PM > To: Tejas Belagod ; gcc-patches@gcc.gnu.org > Subject: Re: [Patch 3/7, Arm, GCC] Add testsuite library support for PACBTI > target. > > On 11/10/2021 14:36, Richard Earnshaw via Gcc-patches wrote: > > On 08/10/2021 13:17, Tejas Belagod via Gcc-patches wrote: > >> Hi, > >> > >> Add targeting-checking entities for PACBTI in testsuite framework. > >> > >> Tested on arm-none-eabi. OK for trunk? > >> > >> 2021-10-04  Tejas Belagod  > >> > >> gcc/ChangeLog: > >> > >>     * testsuite/lib/target-supports.exp > >>     (check_effective_target_arm_pacbti_hw): New. > >> > > > > OK. > > > > R. > > Oh, wait! Not OK. Needs documentation in sourcebuild.texi. > Thanks for the reviews. Add targeting-checking entities for PACBTI in testsuite framework. 2021-10-25 Tejas Belagod gcc/ChangeLog: * testsuite/lib/target-supports.exp: (check_effective_target_arm_pacbti_hw): New. * doc/sourcebuild.texi: Document arm_pacbti_hw. Tested the following configurations, OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap Thanks, Tejas. diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 6a16576763006a13e946147ab1ea5b16b5bc219b..3dd1dd8d7f031720e55cf389376f1572991d8071 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2141,6 +2141,10 @@ ARM target supports options to generate instructions from ARMv8.1-M with the Custom Datapath Extension (CDE) and M-Profile Vector Extension (MVE). Some multilibs may be incompatible with these options. +@item arm_pacbti_hw +Test system supports executing Pointer Authentication and Branch Target +Identification instructions. + @item arm_prefer_ldrd_strd ARM target prefers @code{LDRD} and @code{STRD} instructions over @code{LDM} and @code{STM} instructions. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 1c8b1ebb86e8769e40fe88af3a4c651990dbb2a1..843397adf437700ca622ce140359b6aaa0172e42 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5064,6 +5064,22 @@ proc check_effective_target_arm_cmse_clear_ok {} { } "-mcmse"]; } +# Return 1 if the target supports executing PACBTI instructions, 0 +# otherwise. + +proc check_effective_target_arm_pacbti_hw {} { + return [check_runtime arm_pacbti_hw_available { + __attribute__ ((naked)) int + main (void) + { + asm ("pac r12, lr, sp"); + asm ("mov r0, #0"); + asm ("autg r12, lr, sp"); + asm ("bx lr"); + } + } ""] +} + # Return 1 if this compilation turns on string_ops_prefer_neon on. proc check_effective_target_arm_tune_string_ops_prefer_neon { } { From patchwork Thu Oct 28 11:43:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46743 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 57A993857C47 for ; Thu, 28 Oct 2021 11:46:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57A993857C47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421603; bh=8SNuJv21i5wQKDw9w2oGee3gGA4hvTU3o0BHbjRSjV0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OZSeNvgrPcbxJ2wTf5hDeY21MEiqBVW0GWp0IGteWViu5cBYKAagWyrPz3ZKt8fEg QMKyy9t8KZqLbQgGnNUycoaoWeDDdW6mxViSZm+ynIQdccJ/CCb+W4Dq63xeQ6aRJ0 SUxHR20DjDLf1aYjlgZU36UtCq2RmILx+k2/FFEA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140082.outbound.protection.outlook.com [40.107.14.82]) by sourceware.org (Postfix) with ESMTPS id 4822C3857C4C for ; Thu, 28 Oct 2021 11:43:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4822C3857C4C Received: from AM6P195CA0101.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::42) by AM0PR08MB3953.eurprd08.prod.outlook.com (2603:10a6:208:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13; Thu, 28 Oct 2021 11:43:10 +0000 Received: from AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:86:cafe::da) by AM6P195CA0101.outlook.office365.com (2603:10a6:209:86::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:43:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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 AM5EUR03FT032.mail.protection.outlook.com (10.152.16.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:43:09 +0000 Received: ("Tessian outbound 2bb1f94ba47e:v108"); Thu, 28 Oct 2021 11:43:08 +0000 X-CR-MTA-TID: 64aa7808 Received: from 6c292bccfe16.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 77C3E1F9-8D3A-4D32-8A21-F69A1F0FBF93.1; Thu, 28 Oct 2021 11:43:02 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6c292bccfe16.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:43:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HAf2oipFMjm5pC5hsgtUTuIuvUqIFbj66LcSq9KiW8TDpvkLkeKkVXYhRCGW4NlkcAg1wiZ35uH2T2AvxXRTW9Zb2eUGztESv3c1zCMhkedR2c1aJAJTDf97MQI2fjWgdWm3lakpkVEIii+QbhUdMCfxPwHn81u+AQ7/OjjhDmJ6tPcEY+Xjx7scqZZ9//e9lIMVgZM1oIH1oYC86T4bszFwN0EvDfrbU16kIK0YZjJ0dc74V8n3nBH83DFo0MqSrz3piCcorzBG+q+zgfkZVSntTuITfd3hCRLOoi1UklbILSA/AeS0shMCqQtJQqDzAOyccEozQVrh43tgU/BK+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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8SNuJv21i5wQKDw9w2oGee3gGA4hvTU3o0BHbjRSjV0=; b=aPgkcIGSeXC0cxvuzHEeFvSTEpF1mVdrPOMXmZsTOcGBBVTNNRuzGlxvqwN60HQ3TVTQS1xF9Uv8QSY0AoxKOlUSPRsfy5FmTiSATsRDU3SVhzcbX9vc6qZl6r7Rs+fCLIkTTDmyX+RKw5sj6F3mYegYVgTbaY/cPqV0zCleA46WzxtXi5pp3rZbndy3ykHMEOIeJYqiNC1hc5TrXycsF6lEpp4MzpWFlBVxGBTaPExwwLaJxut/IKtVu+S2f8/jeAMVCZgjVap/MckoQHtWA9C6BATFgjRvYhTBccIom7qt27ffHfPUOrIjcxmYceKB0LYqLAMVRAmqyNu184GagQ== 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 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7336.eurprd08.prod.outlook.com (2603:10a6:102:223::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Thu, 28 Oct 2021 11:43:01 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:43:01 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 5/8, Arm, GCC] Implement target feature macros for PACBTI. [Was RE: [Patch 4/7, Arm. GCC] Implement target feature macros for PACBTI.] Thread-Topic: [Patch 5/8, Arm, GCC] Implement target feature macros for PACBTI. [Was RE: [Patch 4/7, Arm. GCC] Implement target feature macros for PACBTI.] Thread-Index: AdfL7sWjcuVwp8nCRWGxzbTXLqW2Fg== Date: Thu, 28 Oct 2021 11:43:01 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: 18AA94D8668CFF40A9A59CCA6B2638BF.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 7e21a914-897a-4a56-562c-08d99a081d48 x-ms-traffictypediagnostic: PAXPR08MB7336:|AM0PR08MB3953: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 4GSnludICW0p9Ix79Vp4SdTHYoaqIIibzBDUult9kX9kl912Fl/sSb0c07LB9qBqb6JQBKcpTE1Jbmw1brVfFj2oouIU0SZ0Qe804iBm/y6Fj4eWOmo0uXBAkeqpOQAxcZNygS3oFYsvoeZ4xzGiTFiPHHqcUGN0xfU+0+G/rdKhS8EJi4nZZA/ldIVX7h+p2tsTKmhnWelowJyjRVWvQWjMwYIo1RWMNyZZ+UO3iB+Mta+gMYSwHzcc65y5IqqtGAi/C2cvBx52LuCCScf1LJqNBFqCbFdROtYa+YmOzh14n6p9jUYP0ls6Zq1S6EnkIbjSpu8xE8gKauxVARXUe86AdMxYuIauUmgDOCQczY9DmYVREwNxj+YtOerqTao42A9vjgZdLgXzqvzoQIqFpVFz4hEfUdlWjhFWRHMpoFktnn+ijFFnuKR/6oW1jr6AbkLOTGt0relguiNubef1F4BvHvDn9CN5bzkqPd+k7GbXwsT+c2LCWQ05e57WQLBiM5XAaot00gh2BB9wHfHzpUEetOK8GtNF5FiaHqZqtdooBQIjA1+ocvO3vP8hRclwPACmjcRKZRcsCYvTrmZ3D3KZqqcYYe50Bibu+bD1EmxHIYqzyQnRRppuVbRR5AvAKOCWR2zb/04f/VXdm//4PESUc6iJ8FFiYn0HIVLajboCh0lPS8nEwjmIqe7U2LcHEhxpD88aJ3YR9SCVWZij1Keh6FmbpdJ3KXHnB2pa0ipnAvJVpREwpYf6XH6Oy9auWN6MvpHRSOP9eVGWZxmkSDNCnITSFkfD8eSA2ipC9XEH7WVkiszqWuQOA0EOTCETFSLebX+CkxtI6zkSbYMtBA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(122000001)(508600001)(26005)(38100700002)(8936002)(5660300002)(53546011)(55016002)(71200400001)(4001150100001)(110136005)(52536014)(186003)(38070700005)(316002)(8676002)(9686003)(66946007)(66476007)(66446008)(76116006)(86362001)(33656002)(2906002)(66556008)(99936003)(6506007)(7696005)(83380400001)(64756008); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7336 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 373034f1-b617-41d0-fdca-08d99a08189a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A7EgDvFhEegkBUVEe3b2+r1H9Z0FOLObHaApW8OV0SiHn9PbzF6yg6tGFHdhaQurCWq4LvNDEOK5BMfEeNtAmlVrV9m3FOyBx3FvgXSwVtPFb4AZJYU591+N1uLAx5F2Cf1d2nvmIvd5Cqoa01Osp6NBsIyuFXjTHCEhyQlfwtw7AfQb7LrFxRuVdE/ughHSwr0pzV/G33zncnsh3Q6VK8EETzhqYDInkKhoPW+ex+xuivRtD0JkWFNg7/XwIIWXuLgNgcjxQFJgrr17jUzFFpvDcRHXBXPm/tCy5U+EqZTMHsw4k8e/ZvuyzlZskPRlXDvrqohHfUQ/GbS5ZrzUI2MQ3eNu0ik0gxcXLQun9NMRjHzEYNt9x66bG4AUeLHg7nJY9Ja6LX8iRaWiP4pY3WjEaOtX/Ow7cnCec+l5DsiXKPkglqJG/TA+SXYG9Xa8kQh0vhk2+jBCpbwSpKHj5N/xgt8EcRbfNjGaOzWFI5yIhxzJNEVoUx4RznChNTDlTnQc3A+H1cr+J5mO0ulbRIgHuYeLxr6QoJMjFbABMY4oY8xdpcBHiVBsxZZTnNaRICZV/X7MiHHINJJCbNOF7BoBvo9VYwupbBDIXH8RrBQWgiPF7haIbnzA/79yo7qG9VsFGxa4JTPnsh3IDCMF0jzCVP2FeyIOMjiB+qlSkhC9IeDztLdKBkryqdUBKOih9TV6jKtubDg+twDevxWw0X3MnuhhcHlEC2vTwfKUp+JYcvkDoG8iG1E+kWxgQE/gfde4Q9n0FrfmezYL5QpY06oKwSB1fxvezKC2VSdgpjVfh7+eU9cMOM8+ofW0QGwx3Ch9u+v5CWcEFYdb/fgWmg== 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; SFS:(4636009)(46966006)(36840700001)(36860700001)(9686003)(316002)(52536014)(8676002)(82310400003)(7696005)(508600001)(21480400003)(33656002)(8936002)(26005)(83380400001)(70586007)(86362001)(70206006)(235185007)(336012)(356005)(53546011)(33964004)(4001150100001)(81166007)(2906002)(47076005)(6506007)(5660300002)(186003)(55016002)(99936003)(110136005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:43:09.0597 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e21a914-897a-4a56-562c-08d99a081d48 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: AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3953 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Richard Earnshaw > Sent: Monday, October 11, 2021 2:58 PM > To: Tejas Belagod ; gcc-patches@gcc.gnu.org > Subject: Re: [Patch 4/7, Arm. GCC] Implement target feature macros for > PACBTI. > > On 08/10/2021 13:18, Tejas Belagod via Gcc-patches wrote: > > Hi, > > > > This patch implements target feature macros when PACBTI is enabled > > through the -march option or -mbranch-protection. > > > > Tested on arm-none-eabi. OK for trunk? > > > > 2021-10-04 Tejas Belagod > > > > gcc/ChangeLog: > > > > * config/arm/arm-c.c (arm_cpu_builtins): Define > > __ARM_FEATURE_BTI_DEFAULT and > __ARM_FEATURE_PAC_DEFAULT. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/arm/acle/pacbti-m-predef-2.c: New test. > > * gcc.target/arm/acle/pacbti-m-predef-4.c: New test. > > * gcc.target/arm/acle/pacbti-m-predef-5.c: New test. > > > > I presume the specification for this is ACLE - please say so rather than making > me guess. > Yes, sorry, very poor description on my part. Now fixed - please see patch description below for links to specific ACLE sections. > > + cpp_undef (pfile, "__ARM_FEATURE_BTI_DEFAULT"); > + cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT"); > + if (TARGET_HAVE_PACBTI) > + { > + builtin_define_with_int_value ("__ARM_FEATURE_BTI_DEFAULT", > + arm_enable_pacbti & 0x1); > > My reading of the ACLE specification would suggest this shouldn't be > defined if it would have a value of 0, but that's not what this code > does. I think it would be better to move this outside the > TARGET_HAVE_PACBTI and use the def_or_undef approach. > > + builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", > + arm_enable_pacbti >> 1); > > This one is less clear, could the value ever be zero? I guess exactly > one of a-key and b-key must be defined and each has a separate bit. > Now fixed according to what the arch specifies. For the M-profile, there's only one key which means when -mbranch-protection is invoked, bit 0 is always 1. > + } > + > + > > Not more than one blank line at the end of a block. > > > diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c > b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c > > > Given what I've said above, I think you need to also test that > __ARM_FEATURE_BTI_DEFAULT is defined before testing the value (and > emitting #error if it isn't). > Fixed. This patch implements target feature macros when PACBTI is enabled through the -march option or -mbranch-protection. The target feature macros __ARM_FEATURE_PAC_DEFAULT and __ARM_FEATURE_BTI_DEFAULT are specified in ARM ACLE (https://developer.arm.com/documentation/101028/0012/5--Feature-test-macros?lang=en) __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI are specified in the pull-request (https://github.com/ARM-software/acle/pull/55). 2021-10-25 Tejas Belagod gcc/ChangeLog: * config/arm/arm-c.c (arm_cpu_builtins): Define __ARM_FEATURE_BTI_DEFAULT, __ARM_FEATURE_PAC_DEFAULT, __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI. gcc/testsuite/ChangeLog: * gcc.target/arm/acle/pacbti-m-predef-2.c: New test. * gcc.target/arm/acle/pacbti-m-predef-4.c: New test. * gcc.target/arm/acle/pacbti-m-predef-5.c: New test. Tested the following configurations, OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap Thanks, Tejas. diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c index cc7901bca8dc9c5c27ed6afc5bc26afd42689e6d..98d47ad4cc6e88aa7401429a809c555c5aadc15f 100644 --- a/gcc/config/arm/arm-c.c +++ b/gcc/config/arm/arm-c.c @@ -193,6 +193,24 @@ arm_cpu_builtins (struct cpp_reader* pfile) def_or_undef_macro (pfile, "__ARM_FEATURE_COMPLEX", TARGET_COMPLEX); def_or_undef_macro (pfile, "__ARM_32BIT_STATE", TARGET_32BIT); + def_or_undef_macro (pfile, "__ARM_FEATURE_PAUTH", TARGET_HAVE_PACBTI); + def_or_undef_macro (pfile, "__ARM_FEATURE_BTI", TARGET_HAVE_PACBTI); + def_or_undef_macro (pfile, "__ARM_FEATURE_BTI_DEFAULT", + aarch_enable_bti == 1); + + cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT"); + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE) + { + unsigned int pac = 1; + + gcc_assert (aarch_ra_sign_key == AARCH_KEY_A); + + if (aarch_ra_sign_scope == AARCH_FUNCTION_ALL) + pac |= 0x4; + + builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", pac); + } + cpp_undef (pfile, "__ARM_FEATURE_MVE"); if (TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT) { diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c new file mode 100644 index 0000000000000000000000000000000000000000..4394fd147d7bf468238bd66a24b79bd1338d33aa --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c @@ -0,0 +1,24 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=bti+pac-ret+leaf" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 5) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c new file mode 100644 index 0000000000000000000000000000000000000000..90f0c724b9efe38d3c3a1345d49a9615b853207e --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c @@ -0,0 +1,21 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=pac-ret" } */ + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif + +int +main() +{ + if (__ARM_FEATURE_PAC_DEFAULT != 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c new file mode 100644 index 0000000000000000000000000000000000000000..c865809b8b01db8f8c021501e7d3317b0b8bb0ed --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c @@ -0,0 +1,24 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=bti+pac-ret" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 1) + __builtin_abort (); + + return 0; +} From patchwork Thu Oct 28 11:43:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46744 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 AF3BD385801E for ; Thu, 28 Oct 2021 11:47:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF3BD385801E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421668; bh=jxrQ73XGpFpnWnScSLHyat1NUb6qZzjfH+J1q2PW4Yc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=d9IuBnlvObdJe8OslbGhleyMwOkGEJhdEMfhMWr2TJ+OTRorNCMSJMM0JBGZqWzOF GN+FDHgaZi1oKbRwX46AbwBCOy3wOBypzU5MnCN4CoDvYxeyLZglHkj+V6gJszKE9v wBT7N9O0yyTB6EWC5YD1IkorkrnF4rvFFJ1qDZf8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60077.outbound.protection.outlook.com [40.107.6.77]) by sourceware.org (Postfix) with ESMTPS id 2F4A73858007 for ; Thu, 28 Oct 2021 11:43:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2F4A73858007 Received: from AS8PR04CA0091.eurprd04.prod.outlook.com (2603:10a6:20b:31e::6) by AM6PR08MB4485.eurprd08.prod.outlook.com (2603:10a6:20b:bd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Thu, 28 Oct 2021 11:43:24 +0000 Received: from AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31e:cafe::32) by AS8PR04CA0091.outlook.office365.com (2603:10a6:20b:31e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18 via Frontend Transport; Thu, 28 Oct 2021 11:43:24 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT047.mail.protection.outlook.com (10.152.16.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:43:23 +0000 Received: ("Tessian outbound c71e1a752bff:v108"); Thu, 28 Oct 2021 11:43:23 +0000 X-CR-MTA-TID: 64aa7808 Received: from 6cbbe0f3f7b8.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A70C0BA4-3C4C-4C05-A801-FE1325CC179A.1; Thu, 28 Oct 2021 11:43:17 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6cbbe0f3f7b8.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:43:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJd2fXirhE3Vzz8si1XJhzDDySB0p7L4wcX9ggWmK5d8SKUe0MuY/e/IYnIs5NMDdPmHbzt/ltPglA1EDX0GxANm/PHuKIUVbqlmJ49BVF4SLYqc3PaFk8QO015Er4vRn3R4a/landY9GNPx5mQ728CWYvefgtn14kag/vIXU7xBRLvV9MXLLbr7Ac+/WyHQDVntDQ0NT0cbt8ZUk0eG0n9oVp982fr1WruY6t0UREYsnAWDsLPNw9Vcp+2LpXt4exTP5118H8f5GyvKPFOoReuOZ/aYmyiqjNb5jT7gKlNyTch5arTMH+TaIWY6X52U/h4C3E6xBFMI/P+RlwV19Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jxrQ73XGpFpnWnScSLHyat1NUb6qZzjfH+J1q2PW4Yc=; b=gGxFn5hzKCtm5MIYQzRp3AIxMYQUEaD3Z3KCRPGf/QTYIH/DwZZAzKM+brQgGJvKA5U+Iv9D2y9AHgSbwgvGjYqJA3Bao51XBfTujuHKQfVuIEodJUsW0WdfvqmpZ62lDSO2jKzlcTWcDeHrxepDIAgI0lJCJphm7g7+q6cG290seyfmYJ/2IxkBWtYjIvwZmrG+uQ8gPWMUv4jVQpCXO3jJHVXvw52dcll8yFYpCObbANSxeg6RmFzTJOs+Q0VFltVTtCn1Ep6WDSzi1i/UFSf1teC65f7lbLGCdA/b8Pp/nM3t0fEA96y+McI70rNmjLV+J+I4wUwei8456Zusww== 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 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7365.eurprd08.prod.outlook.com (2603:10a6:102:225::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 28 Oct 2021 11:43:16 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:43:16 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 6/8, Arm. GCC] Add pointer authentication for stack-unwinding runtime. [Was RE: [Patch 5/7, Arm. GCC] Add pointer authentication for stack-unwinding runtime.] Thread-Topic: [Patch 6/8, Arm. GCC] Add pointer authentication for stack-unwinding runtime. [Was RE: [Patch 5/7, Arm. GCC] Add pointer authentication for stack-unwinding runtime.] Thread-Index: AdfL7qTsck0UGgeISmO/CEbxTs+7/Q== Date: Thu, 28 Oct 2021 11:43:16 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: 99743363606E054DBE7960C2E5A8ECC8.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 8eeef9f2-5c07-471f-3194-08d99a0825e2 x-ms-traffictypediagnostic: PAXPR08MB7365:|AM6PR08MB4485: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:6108;OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: nNdSkWhQocH/IB/Ld06CbLeJIYVqVzf6HRF6l5OBy0gkPGOwV/pBXkr5MHbUMmEf+/naIWtJF/+4opSNQZC5/6Dqs5ivAYUgah/FqRI1Cdj8QxErrn+994n9spDNi629JIeejugEo6R93ScveXuc5sqTbmXAulTG0Lg3OGHXrVfslICJ4ORApa2nbkxUxVtdo0rk185/G78OGRP6O0+BJ7urlS8D4nbrabCs9IKtstEsxr4XKySz7Hj4ZJQzRVWWouPROGqJCXAjVJHQMFg4xs0FTOrJEalrIZqj3Yj2Xu1oyYb3eN6yP2NUSzV/6dNHy7IBR2G9nIYw7IWwEfSMFwSdVrmWRDCrq2zb2IIKOz6uNLY3NGQkNkYMhHeYW4dZS5jAIkyV0CqHKt3igTXppA5XU8ousBS9KrwhFinz6jriJZwqXEJ58I/IbVkoHoXhcswkNeBDEtZF/D9ZQ1fxbW68RAiwJNcep7ouM5siWerMHKb+VQm6+X6fKb/aE5Ta48TvEsgv5WhyYwwRq7IHhJw9QFzeO1idEc6NmgkPYbAqEeeKvPPk7LwB7RbkByTrF25hlNJ26BiOsvNC4rIteB6TXLiTqEboVZxN4dag5IBC8X0VuJbgBPICtiA3CzK5laOADYGcEFxYgvucBOFF/a/SSt0ShI19hiqGcUtBJphj0f9RqM2JNqXPJGao0r8oNhE/dvMfQXbmL0VmowvnFw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8676002)(53546011)(71200400001)(33656002)(8936002)(38070700005)(508600001)(9686003)(2906002)(83380400001)(4001150100001)(6506007)(86362001)(99936003)(64756008)(316002)(66556008)(66476007)(66946007)(76116006)(186003)(26005)(110136005)(38100700002)(66446008)(55016002)(5660300002)(7696005)(52536014)(122000001); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7365 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: da345f0e-d88f-4729-346f-08d99a082186 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w17p9kMGTvFgcX/E40p1+5iCrDVRgc/8wGZNuNYDe0AhS1jkp6eI8IHTVx7sXpoB4fCl+W+JE1zAJb5oY3LUR5cC30JgsyFz0FT8QrRKX+Tyyb7+uwOMTod8gkgyw8QA4joMLFC9UuJ67qpRO0JFmGoB4cSLDvyUAiCWy4xne/bvgfEWtHzA/on0dtaGHeaZ+p7Ush/DpkidLrai7qf9RPPt04K91gObJJQHbl2gV1rch79ynSG+5CIpCewXaX82ctytsL06414IADLZKCRGeLk6bWdpr4q9UYPCCQcQO5soUGIwumdvMpONSGm7sYm26Nx8fLGhtYjTh8x2MXSOaUh6SXdZ6CVSZGfINjeoupqVZ0MlBTAzNTfazcce+on9ZpE5HDk7E4DNdbZpOXshFzB9xwK9RMbMl1DYV27D/5zQBjxE8chZ+4CPzJkz63ESQPPPFzQD29IryrGUDyIpe0wnPAlxoKnsBWLnKz4W9b6NKNPX2KLMZI+7UfzUNMs/Lh/fQ8C1aKN60CHrrZpE4qKXo4GIf9E93skjd+NbrN8HJWIGTXCZ7gbz7BQtYjaF6257UbX7lcZQ2w8zJtikDcDoeKd1NaWW7P1NOYBmIrMDW0ucD6sLp4R3OOxASvmiAbwGp1b3N/RytZiIqrDDCsPpMzMpcze+CmAmXRYmg9OykF+49qr0/KL8nrJgXjIj12QQPqNUaXdXeb0fHrCDWA== 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; SFS:(4636009)(36840700001)(46966006)(110136005)(186003)(70206006)(336012)(9686003)(55016002)(81166007)(63350400001)(82310400003)(356005)(4001150100001)(83380400001)(2906002)(99936003)(86362001)(7696005)(508600001)(52536014)(63370400001)(36860700001)(235185007)(21480400003)(8676002)(5660300002)(6506007)(8936002)(53546011)(26005)(33656002)(316002)(70586007)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:43:23.4912 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8eeef9f2-5c07-471f-3194-08d99a0825e2 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: AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4485 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Gcc-patches bounces+belagod=gcc.gnu.org@gcc.gnu.org> On Behalf Of Tejas Belagod via > Gcc-patches > Sent: Friday, October 8, 2021 1:18 PM > To: gcc-patches@gcc.gnu.org > Subject: [Patch 5/7, Arm. GCC] Add pointer authentication for stack- > unwinding runtime. > > Hi, > > This patch adds authentication for when the stack is unwound when an > exception is taken. All the changes here are done to the runtime code in > libgcc's unwinder code for Arm target. All the changes are guarded under > defined (__ARM_FEATURE_PAC_DEFAULT) and activates only if the +pacbti > feature is switched on for the architecture. This means that switching on the > target feature via -march or -mcpu is sufficient and -mbranch-protection > need not be enabled. This ensures that the unwinder is authenticated only if > the PACBTI instructions are available in the non-NOP space as it uses AUTG. > Just generating PAC/AUT instructions using -mbranch-protection will not > enable authentication on the unwinder. > > Tested on arm-none-eabi. OK for trunk? > > 2021-10-04 Tejas Belagod > > gcc/ChangeLog: > > * ginclude/unwind-arm-common.h (_Unwind_VRS_RegClass): > Introduce > new pseudo register class _UVRSC_PAC. > * libgcc/config/arm/pr-support.c (__gnu_unwind_execute): Decode > exception opcode (0xb4) for saving RA_AUTH_CODE and > authenticate > with AUTG if found. > * libgcc/config/arm/unwind-arm.c (struct pseudo_regs): New. > (phase1_vrs): Introduce new field to store pseudo-reg state. > (phase2_vrs): Likewise. > (_Unwind_VRS_Get): Load pseudo register state from virtual reg set. > (_Unwind_VRS_Set): Store pseudo register state to virtual reg set. > (_Unwind_VRS_Pop): Load pseudo register value from stack into > VRS. Rebased and respin based on reviews for previous patches. This patch adds authentication for when the stack is unwound when an exception is taken. All the changes here are done to the runtime code in libgcc's unwinder code for Arm target. All the changes are guarded under defined (__ARM_FEATURE_PAUTH) and activates only if the +pacbti feature is switched on for the architecture. This means that switching on the target feature via -march or -mcpu is sufficient and -mbranch-protection need not be enabled. This ensures that the unwinder is authenticated only if the PACBTI instructions are available in the non-NOP space as it uses AUTG. Just generating PAC/AUT instructions using -mbranch-protection will not enable authentication on the unwinder. 2021-10-25 Tejas Belagod gcc/ChangeLog: * ginclude/unwind-arm-common.h (_Unwind_VRS_RegClass): Introduce new pseudo register class _UVRSC_PAC. * libgcc/config/arm/pr-support.c (__gnu_unwind_execute): Decode exception opcode (0xb4) for saving RA_AUTH_CODE and authenticate with AUTG if found. * libgcc/config/arm/unwind-arm.c (struct pseudo_regs): New. (phase1_vrs): Introduce new field to store pseudo-reg state. (phase2_vrs): Likewise. (_Unwind_VRS_Get): Load pseudo register state from virtual reg set. (_Unwind_VRS_Set): Store pseudo register state to virtual reg set. (_Unwind_VRS_Pop): Load pseudo register value from stack into VRS. Tested the following configurations, OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap Thanks, Tejas. diff --git a/gcc/ginclude/unwind-arm-common.h b/gcc/ginclude/unwind-arm-common.h index 79f107d8abb2dd1e2d4903531db47147da63fee8..b60c07128460f8c5e82bdffac7ec469f3607a271 100644 --- a/gcc/ginclude/unwind-arm-common.h +++ b/gcc/ginclude/unwind-arm-common.h @@ -127,7 +127,10 @@ extern "C" { _UVRSC_VFP = 1, /* vfp */ _UVRSC_FPA = 2, /* fpa */ _UVRSC_WMMXD = 3, /* Intel WMMX data register */ - _UVRSC_WMMXC = 4 /* Intel WMMX control register */ + _UVRSC_WMMXC = 4, /* Intel WMMX control register */ +#if defined(__ARM_FEATURE_PAUTH) + _UVRSC_PAC = 5 /* Armv8.1-M Mainline PAC/AUTH pseudo-register */ +#endif } _Unwind_VRS_RegClass; diff --git a/libgcc/config/arm/pr-support.c b/libgcc/config/arm/pr-support.c index 7525e35b4918d38b4ab3ae73a69b722e31b4b322..da27d742fc7be1cef7704a1ea03204743017a591 100644 --- a/libgcc/config/arm/pr-support.c +++ b/libgcc/config/arm/pr-support.c @@ -106,6 +106,9 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) { _uw op; int set_pc; +#if defined(__ARM_FEATURE_PAUTH) + int set_pac = 0; +#endif _uw reg; set_pc = 0; @@ -114,6 +117,22 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) op = next_unwind_byte (uws); if (op == CODE_FINISH) { +#if defined(__ARM_FEATURE_PAUTH) + /* When we reach end, we have to authenticate R12 we just popped earlier. */ + if (set_pac) + { + _uw sp; + _uw lr; + _uw pac; + _Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp); + _Unwind_VRS_Get (context, _UVRSC_CORE, R_LR, _UVRSD_UINT32, &lr); + _Unwind_VRS_Get (context, _UVRSC_PAC, R_IP, + _UVRSD_UINT32, &pac); + __asm__ __volatile__ + ("autg %0, %1, %2" : : "r"(pac), "r"(lr), "r"(sp) :); + } +#endif + /* If we haven't already set pc then copy it from lr. */ if (!set_pc) { @@ -227,6 +246,19 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) return _URC_FAILURE; continue; } +#if defined(__ARM_FEATURE_PAUTH) + /* Pop PAC off the stack into VRS pseudo.pac. */ + if (op == 0xb4) + { + if (_Unwind_VRS_Pop (context, _UVRSC_PAC, 0, _UVRSD_UINT32) + != _UVRSR_OK) + return _URC_FAILURE; + set_pac = 1; + continue; + } + +#endif + if ((op & 0xfc) == 0xb4) /* Obsolete FPA. */ return _URC_FAILURE; diff --git a/libgcc/config/arm/unwind-arm.c b/libgcc/config/arm/unwind-arm.c index d0394019c3649f2f6d6a2882389e55b56c21b8ef..ab89fbd3d845c6c7bca9fa539929c743ce530e1a 100644 --- a/libgcc/config/arm/unwind-arm.c +++ b/libgcc/config/arm/unwind-arm.c @@ -64,6 +64,14 @@ struct wmmxc_regs _uw wc[4]; }; +#if defined(__ARM_FEATURE_PAUTH) +/* Holds value of pseudo registers eg. PAC. */ +struct pseudo_regs +{ + _uw pac; +}; +#endif + /* The ABI specifies that the unwind routines may only use core registers, except when actually manipulating coprocessor state. This allows us to write one implementation that works on all platforms by @@ -78,6 +86,11 @@ typedef struct /* The first fields must be the same as a phase2_vrs. */ _uw demand_save_flags; struct core_regs core; +#if defined(__ARM_FEATURE_PAUTH) + /* Armv8.1-M Mainline PAC/AUTH values. This field should be in the same field + order as phase2_vrs. */ + struct pseudo_regs pseudo; +#endif _uw prev_sp; /* Only valid during forced unwinding. */ struct vfp_regs vfp; struct vfpv3_regs vfp_regs_16_to_31; @@ -99,6 +112,9 @@ typedef struct { _uw demand_save_flags; struct core_regs core; +#if defined(__ARM_FEATURE_PAUTH) + struct pseudo_regs pac; +#endif } phase2_vrs; /* Coprocessor register state manipulation functions. */ @@ -175,6 +191,12 @@ _Unwind_VRS_Result _Unwind_VRS_Get (_Unwind_Context *context, case _UVRSC_WMMXC: return _UVRSR_NOT_IMPLEMENTED; +#if defined(__ARM_FEATURE_PAUTH) + case _UVRSC_PAC: + *(_uw *) valuep = vrs->pseudo.pac; + return _UVRSR_OK; +#endif + default: return _UVRSR_FAILED; } @@ -206,6 +228,12 @@ _Unwind_VRS_Result _Unwind_VRS_Set (_Unwind_Context *context, case _UVRSC_WMMXC: return _UVRSR_NOT_IMPLEMENTED; +#if defined(__ARM_FEATURE_PAUTH) + case _UVRSC_PAC: + vrs->pseudo.pac = *(_uw *) valuep; + return _UVRSR_OK; +#endif + default: return _UVRSR_FAILED; } @@ -246,6 +274,16 @@ _Unwind_VRS_Result _Unwind_VRS_Pop (_Unwind_Context *context, } return _UVRSR_OK; +#if defined(__ARM_FEATURE_PAUTH) + case _UVRSC_PAC: + { + if (discriminator != 0) + return _UVRSR_FAILED; + vrs->pseudo.pac = *(_uw *) vrs->core.r[R_SP]; + return _UVRSR_OK; + } +#endif + case _UVRSC_VFP: { _uw start = discriminator >> 16; From patchwork Thu Oct 28 11:43:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46745 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 B748D3857C6B for ; Thu, 28 Oct 2021 11:48:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B748D3857C6B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421727; bh=+EZ8W9PlqgjfuWjcb0nEaT5TCQdoWCB2aeKT/JjsSS0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ju3OiCBR2Qp6q+eUh62fCA4flEn0rgjmiJWfldM2gv+dWDKn6WtwGWsbIHwX4Z7nF 0v6A0YiFQaU8et7sVCLraPb5ETgp4iGXF/BU2m0br4iS3Qj3nz7gn5XHriu754i6ID BJdZOKz0mrtORR+R2BOqRCHdTMbiR0YKj4RLU0MQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2043.outbound.protection.outlook.com [40.107.22.43]) by sourceware.org (Postfix) with ESMTPS id 97D8E3857C7C for ; Thu, 28 Oct 2021 11:43:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 97D8E3857C7C Received: from DB7PR05CA0067.eurprd05.prod.outlook.com (2603:10a6:10:2e::44) by AS8PR08MB6517.eurprd08.prod.outlook.com (2603:10a6:20b:31b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Thu, 28 Oct 2021 11:43:55 +0000 Received: from DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::6d) by DB7PR05CA0067.outlook.office365.com (2603:10a6:10:2e::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Thu, 28 Oct 2021 11:43:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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 DB5EUR03FT019.mail.protection.outlook.com (10.152.20.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:43:55 +0000 Received: ("Tessian outbound e7ce0d853b63:v108"); Thu, 28 Oct 2021 11:43:54 +0000 X-CR-MTA-TID: 64aa7808 Received: from bc3896ce8dc7.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9DD5B48D-FCD9-4D64-AB17-30BF6E61571F.1; Thu, 28 Oct 2021 11:43:44 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bc3896ce8dc7.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:43:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jA8NOxYV6erwjXsFNL+7fwjcM4gOMiL72rTSATlIJK6NGwI4gIwsoH+pRRmRz6faEgX2P8TbdlXYQNxYTwkg8sRD7JWm4P0J2vGWIY+VWrvgsoBk76LFghIwa4oGD8GeMM/YGdVQfYEP5bWzHTSE5BCRYstTU21FeCuV6BWUDzowNQ176ciu0xIu3yC/l1TYRiWj33nsS8Sjn+z7fgrkICTGZZ671D8At7eZafmOqWXj4GiozRBS608PtRUvxkNU7/HwY2bDINhLlQF+C5XQTuxsbjw4AzQCRPLaofH7Jjtg0LcxJ2IkPUx0jJ7uFg/52zqLGZzaY8m3dAeabpf18w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+EZ8W9PlqgjfuWjcb0nEaT5TCQdoWCB2aeKT/JjsSS0=; b=TIb5Z+n+UeGFe4Iap1C7QthydkBKPkN3u4ZCj5tfhvHYDwn5jKeY+ooOyYFoIEPxZT34VOoAB1n0B3c8h+1aR7A2IGB7AJItBVw2JuopestByEg96dtD6hCMAv94QpaoqLBpmgWciscyTvp0cHh9Hl90BREjvTwOcGK0E/DArakpCKXJYgeNuEvX93n9IrVUwQoLX44rmXAJBpCEfFPPLP3kha+rx1N2F+ooFMOhIW5ySNWONhnTCfWKbP2YV4gpVvHP9EOEYKq7TCXkhRE5I2zRCiScXTX2LKqnWOyN6ShaufUHGaxfiPgabIGzDeLRBQAJmROwnOaqC7+jy/AfJA== 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 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7365.eurprd08.prod.outlook.com (2603:10a6:102:225::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 28 Oct 2021 11:43:43 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:43:43 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 7/8, Arm, GCC] Emit build attributes for PACBTI target feature. [ Was RE: [Patch 6/7, Arm, GCC] Emit build attributes for PACBTI target feature.] Thread-Topic: [Patch 7/8, Arm, GCC] Emit build attributes for PACBTI target feature. [ Was RE: [Patch 6/7, Arm, GCC] Emit build attributes for PACBTI target feature.] Thread-Index: AdfL8BbH6/HjgYmDSemkv/e8EPApBQ== Date: Thu, 28 Oct 2021 11:43:42 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: EEF4DC19373CAC49B5C4ACB0EBD3951F.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 502aff14-4d5d-4246-8801-08d99a0838a0 x-ms-traffictypediagnostic: PAXPR08MB7365:|AS8PR08MB6517: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: YSDtz1kn73yQKUshHPoM/8QSvx5SLfEH3HPdOr5BlvmXg6Gl5d9UgwIxxoKaA4eNiyvaOvF5QgkcmJjWvXctOiwi2myDDrlx5CBA/izRMQ9MO/5WUlg2d0D9hBOkhbkG9s1r//J71RtBrlE9st2s1SxBxfhe4WkCkqSCYxFv8MswCnrDZdDbjpvFI7g7oM4DyZ+bBqSYmRJzFwDa7TSM1DsRmqVsSdmRunijdG09tvlJEqdKlqkC3iQKaACe5mNavmlUs3UJ7tkt52P/iweLXf8v1+uwJJSvFpy/jDpgXVtLksHdVMeQdvjfih9WEDg4Sy70BUVK9H0PozTK1JZ7Weao4QvUJxBNA9VwXdhscgxyeZqwBUBzL1dkxsD2R9K4SLQmyFoJ8lF79fGMdi8FFH999K6JOAankdxWF8mBXS1yiFtLlbo9OEiOjC2ZX/qtxEF2dK7kBCHaAIsacIyp/vpwzzAKbHhhlFgYBIgCjNbg6wOGVEK3kRHWCokyZIazneNvldpFPqcVnOssCZVf++6neTlVZ8XyH1XQfk0mmV7q5dsf5tylJeLVCzK9FuDJrAbmUYITmtvW6hX3dkZgL+3O4ApLSKy8h13nTcOfOGNNMzCO/55iUopsXFLcoq2CKqty3yGQ+FGaBeg4dXJRHb4zxZ7PcPN4lw6u68wxMmHiL8DAWMppy5rfr3HEnUEHLbAPTIPBPhTkaiwUkTxsy0t174UA+D6MFwEPmQikCe4p7/AnG8yjIIzGGlvsn+dcSKWp1r8HWL0NPJs2DIsfEPh9Lbg9v4fi3i1B1AtyL/0wsX0+ucL9Mwhvldhr/OMJ41TZJfNTiyMi9ZDopTFgvw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8676002)(966005)(53546011)(71200400001)(33656002)(8936002)(38070700005)(508600001)(9686003)(2906002)(83380400001)(4001150100001)(6506007)(86362001)(99936003)(64756008)(316002)(66556008)(66476007)(66946007)(76116006)(186003)(26005)(110136005)(38100700002)(66446008)(55016002)(5660300002)(7696005)(52536014)(122000001); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7365 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: f7446ec2-dfe6-4c57-eb0b-08d99a083184 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qu+pKLgJjKX4DJG+2UiJ1UJogt17dvBkKSlxshh4NE6ZD3dAFOxOg7lvM7buk5tYJTYwN/nCZtQLV+5JCKDjDinnFF2Sd+28YQAHiab1x8vtiK8PdenLvuNFukAF7ZFQROfdElTk4s1wY91HBwhWA+Dh5GgIhfhj7N86WmpDbS7fZZhF7QT1/Ay04mgO6819fWDOLJ1DU1BCbZBJnbHWQ3AU10r30AwYy0Ln2ATG5eRTx+gSr1Tmjs2Pmn0zZfLYRdgtG4elEQE/7t1E6gpQSslVLUOrTJ8ZPmkxnVwZhWGuiZb24dhd3EEnm7WFwdbr5YWsPPuXn4aOjus6x7wszdo8D+xCZkRbd+M51WJwUaiJOmL34fDq1M58DekP04YJKqK18R3zL0vIkpZt8tCslLdhf6rSF2VF0RXXYOUcKNs6kKMHcYv/AWpvd76HJwaKGmUpk6UZEb+ay1EB0U9KXwxVCuvFi9K1rD/hCFSx1VRVLY9gT72xtHU6yp+qlbOk/RYLMpuQZwwAWblVxqf3suISV9F0y4hsK11j6s0TqY95DYXsb83MfBc3/eZhWSLNG/+rrV7qTHnVpWnw3sG3AffRUlwwd5NNcbB7CemTBv9lNSs+LHpVcsA0j/mJATqGcQQYhfSSOgBk898HXGwmtyFzvBvvM+FBcr4Tf5O0yjtsjGFuYRLbd+jlV8vUoQf7z9UCmlJuOLP9JSld4DdN2vW3pNSMt+20VM3WnA6+qANclrAx6YX82vgQ9ex7yAnYkHfERP7l6KAS31u0fDEKTf3DnyTrz4nLgWQ3yNAnmyOrIfuT7h3MGqBbGMj0oD4J 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; SFS:(4636009)(46966006)(36840700001)(966005)(186003)(7696005)(33656002)(21480400003)(26005)(2906002)(53546011)(6506007)(70586007)(70206006)(82310400003)(336012)(508600001)(47076005)(81166007)(8936002)(356005)(8676002)(9686003)(316002)(110136005)(4001150100001)(52536014)(36860700001)(86362001)(83380400001)(55016002)(99936003)(5660300002)(235185007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:43:55.0016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 502aff14-4d5d-4246-8801-08d99a0838a0 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: DB5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6517 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Gcc-patches bounces+belagod=gcc.gnu.org@gcc.gnu.org> On Behalf Of Tejas Belagod via > Gcc-patches > Sent: Friday, October 8, 2021 1:19 PM > To: gcc-patches@gcc.gnu.org > Subject: [Patch 6/7, Arm, GCC] Emit build attributes for PACBTI target > feature. > > Hi, > > This patch emits assembler directives for PACBTI build attributes as defined > by the ABI. (https://github.com/ARM-software/abi- > aa/releases/download/2021Q1/addenda32.pdf) > > Tested on arm-none-eabi. > > 2021-10-04 Tejas Belagod > > gcc/ChangeLog: > > * config/arm/arm.c (arm_file_start): Emit EABI attributes for > Tag_PAC_extension, Tag_BTI_extension, TAG_BTI_use, > TAG_PACRET_use. > > gcc/testsuite/ChangeLog: > > * gcc.target/arm/acle/pacbti-m-predef-1.c: New test. > * gcc.target/arm/acle/pacbti-m-predef-3: New test. > * gcc.target/arm/acle/pacbti-m-predef-6.c: New test. This patch emits assembler directives for PACBTI build attributes as defined by the ABI. https://github.com/ARM-software/abi-aa/releases/download/2021Q1/addenda32.pdf 2021-10-25 Tejas Belagod gcc/ChangeLog: * config/arm/arm.c (arm_file_start): Emit EABI attributes for Tag_PAC_extension, Tag_BTI_extension, TAG_BTI_use, TAG_PACRET_use. gcc/testsuite/ChangeLog: * gcc.target/arm/acle/pacbti-m-predef-1.c: New test. * gcc.target/arm/acle/pacbti-m-predef-3: New test. * gcc.target/arm/acle/pacbti-m-predef-6.c: New test. Tested the following configurations, OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap Thanks, Tejas. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 946841526ee127105396097d143e755bdfc756f5..a87bcb298f9e6d7b2f3fd61b4586e291f46b0f81 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -28200,6 +28200,8 @@ static void arm_file_start (void) { int val; + bool pac = (aarch_ra_sign_scope != AARCH_FUNCTION_NONE); + bool bti = (aarch_enable_bti == 1); arm_print_asm_arch_directives (asm_out_file, TREE_TARGET_OPTION (target_option_default_node)); @@ -28270,6 +28272,24 @@ arm_file_start (void) arm_emit_eabi_attribute ("Tag_ABI_FP_16bit_format", 38, (int) arm_fp16_format); + if (TARGET_HAVE_PACBTI) + { + arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 2); + arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 2); + arm_emit_eabi_attribute ("TAG_BTI_use", 74, bti); + arm_emit_eabi_attribute ("TAG_PACRET_use", 76, pac); + } + else + { + if (pac || bti) + { + arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 1); + arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 1); + arm_emit_eabi_attribute ("TAG_BTI_use", 74, bti); + arm_emit_eabi_attribute ("TAG_PACRET_use", 76, pac); + } + } + if (arm_lang_output_object_attributes_hook) arm_lang_output_object_attributes_hook(); } diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c new file mode 100644 index 0000000000000000000000000000000000000000..cc88380731ae81dd27c0a343518252a172f8f3ef --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c @@ -0,0 +1,30 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=pac-ret+bti --save-temps" } */ + +/* { dg-final { scan-assembler "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c new file mode 100644 index 0000000000000000000000000000000000000000..8bebd995b170df953e13f86d2276576d5ab34e93 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c @@ -0,0 +1,26 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=pac-ret+leaf --save-temps" } */ + +/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 0" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */ + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +int +main() +{ + if (__ARM_FEATURE_PAC_DEFAULT != 5) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c new file mode 100644 index 0000000000000000000000000000000000000000..13990a310fdd045832bdfa96ab61b9b8ae11efa4 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c @@ -0,0 +1,26 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=bti --save-temps" } */ + +/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 0" } } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be undefined." +#endif + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + return 0; +} From patchwork Thu Oct 28 11:43:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46746 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 8F2043858405 for ; Thu, 28 Oct 2021 11:49:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F2043858405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421793; bh=URftdqbrJm4dKFYeoAA0MY13WngBZfQ2QEaCBSZm7uw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Z0HsqfHsHo0BaN8rWtY6PuqIPgey/sZSxO5LNHLxqQqLJYAyJ/YaJzQpnfTlMDRnA 3Z3aul8N7fBUxsgTjKvUHKMXKo3W3ondPy6GwHUSyOTubB9hq+nuPgVtSRjJIhmZnD iV15j/bA587ttri20Iry1c3ldEIULvKUFcktRFUI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by sourceware.org (Postfix) with ESMTPS id 4C4F0385802E for ; Thu, 28 Oct 2021 11:44:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C4F0385802E Received: from AS8PR04CA0154.eurprd04.prod.outlook.com (2603:10a6:20b:331::9) by VI1PR0802MB2495.eurprd08.prod.outlook.com (2603:10a6:800:b9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.20; Thu, 28 Oct 2021 11:43:59 +0000 Received: from AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:331:cafe::ef) by AS8PR04CA0154.outlook.office365.com (2603:10a6:20b:331::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:43:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:43:58 +0000 Received: ("Tessian outbound 7b0bcc4a550a:v108"); Thu, 28 Oct 2021 11:43:58 +0000 X-CR-MTA-TID: 64aa7808 Received: from 795b51839364.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DE05F8F7-A5D9-466B-B07B-E71B56973B02.1; Thu, 28 Oct 2021 11:43:52 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 795b51839364.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:43:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cxV1VJzAlJbqbTxg7+Cq+As2jVPYRNeQIGcsUGW/m1o8XjSe/xiw5zrd2LnJ+fsk2/6udG9xlePST09awnpoH3qnGvkaaCwAL4NAOncg0lasedQHev38IdNNf9SOT5SmNMBgkY44LVo6PhNhNbE6TlE+sYyG8AccxR8Ew1F8VizHkpggBYYR/PSUx5r2ZXzG4VyFkRGU0rsvqb9Av5fKoTyEiX5KA0fs0VfVzSSFTYCc3WHPoLVhzQOMXfVzsMOIGp/Cp/TPd6vAGGizjkeuSQyzDlPFxKY25nQgAlGvzTuOorHEiswDEDRTo7gSBTgLNsvqcylhe50RYQClXIRVNQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=URftdqbrJm4dKFYeoAA0MY13WngBZfQ2QEaCBSZm7uw=; b=CDhpi+joAgsHsG+2kBTlJnKFDlRdTebTYCRqphSIWJaqHY+VsfA+PovRfZAqlXQ1CKRT45dG28i/XIrX6JdSPvIbb12F7jARZO7bXXsrn/UH6FhpQ9cibIjpR/lhyJ2hbVLHHZJ1PywCO78LxpxCci5RNFX4CX5FYCaTQLXIxDyMBpawZQPP4IpcaEDKTX+1KbilNDsYhbzwfK5ovTVfL7GP8g+fvt6XTWquFg52PQYkBx/njrkd5dRRBSQmK/8PWvYdVqLbQJUHKxWn20ady+PGrmdZzb6W0E/s1hoRLv24xCUpdjsPGB15VyfjKKOxPGmO/yzNQQxihzExVjvxhg== 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 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7365.eurprd08.prod.outlook.com (2603:10a6:102:225::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 28 Oct 2021 11:43:51 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:43:51 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 8/8, Arm, GCC] Introduce multilibs for PACBTI target feature. [Was RE: [Patch 7/7, Arm, GCC] Introduce multilibs for PACBTI target feature.] Thread-Topic: [Patch 8/8, Arm, GCC] Introduce multilibs for PACBTI target feature. [Was RE: [Patch 7/7, Arm, GCC] Introduce multilibs for PACBTI target feature.] Thread-Index: AdfL75GOe3NVGpOITZqkCD7MDkZL6A== Date: Thu, 28 Oct 2021 11:43:51 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: 1519EEAF911A4C4C8FE8C853A0A46DF0.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 37cafd0b-6d18-47da-80d0-08d99a083ade x-ms-traffictypediagnostic: PAXPR08MB7365:|VI1PR0802MB2495: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:6108;OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 0v3FbNYbOsCa41BMTcxQXFFwUA20zgh4DSCakbEZfF/nX2k5s0invkrR8pEqni/eV4EggArjTA9Mh3ViIWtLVpuLneMvfzpTUHEYHG5JkvM4DKGdLxJT5KoVaN02ooNbuSg8XbbFoNyZl8n2B4Lbs5O1yadi1mZ5TbxWdQW1fd4PxoTsNyAIh7C4aP/6cn0ISfQlcrjzMHp7Bc4rTxIRwFxK14lUIunXqHp4VxndPqQAI7jER+4nL6bxZ0+lW8cvZ1gxUg9Q+nTrFHXhtSpXSCoQpj3TgOQNhu51s0oWx/QdW6lGCuOg1a/ytpNSDZoBKUbv3SsO55Z3ws5MQTMubc1HM+vp1dQniZOcJ+DplI3oaq6HbRr0h7PWBOJKFFiJpBnEgDgJ/pL4FfucajcCbaYtuWiDg735MsTtfPkhivOnnyaJMuI+zt4ZUkhUW7iB+Unb3mcw9TFTDLexufTUevCX9wWVZk3lfdi1W/aqtPPvVhSMshBYr4lL6xEinpeJXsjdSb8hct57Z1mTO1cDQkTf8W7AfWJC9u+DgCfcIBel3ryMV5jYmnati0LdljCI3DpblZh3pXG/FBxQ9o5oiIP7sy29ZLT6KSLuLAdGiAhWJFsxhNNdRBzXw286dlnZGDmYX+0yB+PcyBWB83Rq/I/Iwt11g6459ZsbyvqELEFU/NNgktEVtkbzEg6BGxEG1dIkW4kt+n6DXjFLAno4zg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8676002)(53546011)(71200400001)(33656002)(8936002)(38070700005)(508600001)(9686003)(2906002)(83380400001)(6506007)(86362001)(99936003)(64756008)(316002)(66556008)(66476007)(66946007)(4744005)(76116006)(186003)(26005)(110136005)(38100700002)(66446008)(55016002)(5660300002)(7696005)(52536014)(122000001); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7365 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a5e91a2b-8434-47ad-5302-08d99a08365f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GbYpoSrA5P28fmrJjQe17bsMcI32l0WcVgPszKjgEq4Ovfz/v9G49r9b6ytJO5CuWxRwRV41eKTbAUJD2wkdr6D+xJSJall3y3VmAeSsfA3dwMtd1NHm/R1uYIIEPTpMneyOcVt26ULCHMr+7cyfFLQ7IHKpZd8QBlg7TzwktswDx7DooHI+FS9IPXCrWqaplne2f6bkfY4ajsoWLlRXVJbrwCOcngGCZYOiV3Mk4D4yTEPe1sLL8FJK2JrPbpsNOLV8YzJfzYppVLJkWpsqTcpF/ubz27CRDcNgKOTIrLI0hC/WVHP0c1mKKA2VaSg3PwGhfH/yVvBDRUtXKK3tV5Yvav/qFNKRSN2MIn7VQnwy7VJkS7xE4Q/EF/IfTm5ojKS2nfMA7GjWQkg15ttBjzcDa+G9WRT/+QkeRmYMckBVE9Yx73Wqcd1HuRwsCwl4mk3Isqv2zHhOo2DeFYhVuQmBMBBgji2ysWlqBSlX8UtveqUgNkx9KYSC7X/Rno1VzPXjId8pRqkr+bsP3LK1qsva99kpzfJtekE3FykEe9qp/kmaCnf7xqF85FwigkHv3OwGc47zAyMVIgagvx59VU8cPpO18Q/OYgu3Rr6C0WOLFldiWDQjiOvO30AWr/WWkngXKli9x88JJos3ezlBd2GzRakS+3lt4iEbAQQEOSA61fqBlOqJMOUXe1x4hF1YrRCb8QgJC/D6Q2dUzYuqPg== 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; SFS:(4636009)(46966006)(36840700001)(52536014)(508600001)(70586007)(70206006)(33656002)(2906002)(36860700001)(81166007)(110136005)(99936003)(47076005)(55016002)(316002)(26005)(21480400003)(7696005)(8936002)(86362001)(8676002)(356005)(83380400001)(53546011)(5660300002)(82310400003)(9686003)(186003)(235185007)(6506007)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:43:58.7102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37cafd0b-6d18-47da-80d0-08d99a083ade 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: AM5EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2495 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Gcc-patches bounces+belagod=gcc.gnu.org@gcc.gnu.org> On Behalf Of Tejas Belagod via > Gcc-patches > Sent: Friday, October 8, 2021 1:19 PM > To: gcc-patches@gcc.gnu.org > Subject: [Patch 7/7, Arm, GCC] Introduce multilibs for PACBTI target feature. > > Hi, > > This patch adds a multilib for pacbti target feature. > > Tested on arm-none-eabi. OK for trunk? > > 2021-10-04 Tejas Belagod > > gcc/ChangeLog: > > * config/arm/t-rmprofile: Add multilib rules for +pacbti. This patch adds a multilib for pacbti target feature. 2021-10-04 Tejas Belagod gcc/ChangeLog: * config/arm/t-rmprofile: Add multilib rules for +pacbti. Tested the following configurations, OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap Thanks, Tejas. diff --git a/gcc/config/arm/t-rmprofile b/gcc/config/arm/t-rmprofile index a6036bf0a5191a3cac3bfbe2329783204d5c3ef4..241bf1939e30ae7890ae332556d33759f538ced5 100644 --- a/gcc/config/arm/t-rmprofile +++ b/gcc/config/arm/t-rmprofile @@ -27,8 +27,8 @@ # Arch and FPU variants to build libraries with -MULTI_ARCH_OPTS_RM = march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7e-m+fp/march=armv7e-m+fp.dp/march=armv8-m.base/march=armv8-m.main/march=armv8-m.main+fp/march=armv8-m.main+fp.dp/march=armv8.1-m.main+mve -MULTI_ARCH_DIRS_RM = v6-m v7-m v7e-m v7e-m+fp v7e-m+dp v8-m.base v8-m.main v8-m.main+fp v8-m.main+dp v8.1-m.main+mve +MULTI_ARCH_OPTS_RM = march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7e-m+fp/march=armv7e-m+fp.dp/march=armv8-m.base/march=armv8-m.main/march=armv8-m.main+fp/march=armv8-m.main+fp.dp/march=armv8.1-m.main+mve/march=armv8.1-m.main+pacbti +MULTI_ARCH_DIRS_RM = v6-m v7-m v7e-m v7e-m+fp v7e-m+dp v8-m.base v8-m.main v8-m.main+fp v8-m.main+dp v8.1-m.main+mve v8.1-m.main+pacbti # Base M-profile (no fp) MULTILIB_REQUIRED += mthumb/march=armv6s-m/mfloat-abi=soft @@ -36,6 +36,7 @@ MULTILIB_REQUIRED += mthumb/march=armv7-m/mfloat-abi=soft MULTILIB_REQUIRED += mthumb/march=armv7e-m/mfloat-abi=soft MULTILIB_REQUIRED += mthumb/march=armv8-m.base/mfloat-abi=soft MULTILIB_REQUIRED += mthumb/march=armv8-m.main/mfloat-abi=soft +MULTILIB_REQUIRED += mthumb/march=armv8.1-m.main+pacbti/mfloat-abi=soft # ARMv7e-M with FP (single and double precision variants) MULTILIB_REQUIRED += mthumb/march=armv7e-m+fp/mfloat-abi=hard @@ -93,3 +94,4 @@ MULTILIB_MATCHES += march?armv8-m.main=mlibarch?armv8-m.main MULTILIB_MATCHES += march?armv8-m.main+fp=mlibarch?armv8-m.main+fp MULTILIB_MATCHES += march?armv8-m.main+fp.dp=mlibarch?armv8-m.main+fp.dp MULTILIB_MATCHES += march?armv8.1-m.main+mve=mlibarch?armv8.1-m.main+mve +MULTILIB_MATCHES += march?armv8.1-m.main+pacbti=mlibarch?armv8.1-m.main+pacbti