From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2073.outbound.protection.outlook.com [40.107.13.73]) by sourceware.org (Postfix) with ESMTPS id C8A1B3882029 for ; Tue, 22 Aug 2023 10:39:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8A1B3882029 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GOtwWheurWwCRRiFQrWxmV6s1F9Y24Bg9djRAE8e7S8=; b=KbuRZAGEMQX2pY+ZdqLiyuvq5zBN4A+KjMlOkhu9s6AvOpbGlnU1/VQtkI9tbHDERb463emlU82Eq2q0vAf96xUqS1CYRGeQCjMvsaVrtbM7nP0XXVQvMEgpS+tmLh2IGFVxlsn6cEK84uC9uOK7vuzfaP8CzMkNthg62CEQsaQ= Received: from AS8PR04CA0134.eurprd04.prod.outlook.com (2603:10a6:20b:127::19) by PR3PR08MB5595.eurprd08.prod.outlook.com (2603:10a6:102:83::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 10:39:37 +0000 Received: from AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:127:cafe::51) by AS8PR04CA0134.outlook.office365.com (2603:10a6:20b:127::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Tue, 22 Aug 2023 10:39:37 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT029.mail.protection.outlook.com (100.127.140.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.15 via Frontend Transport; Tue, 22 Aug 2023 10:39:36 +0000 Received: ("Tessian outbound 5c548696a0e7:v175"); Tue, 22 Aug 2023 10:39:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 67d5cf7d1cb34ba3 X-CR-MTA-TID: 64aa7808 Received: from 63c615f6f66d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0C2EE54A-B347-42CA-8A37-2830EDB7DE18.1; Tue, 22 Aug 2023 10:39:29 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 63c615f6f66d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 22 Aug 2023 10:39:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IXh+LetWyvVB6KyM7mD6JEkNJm33Cz5mOp7aWOBplJXlefdiUsgZyEqSVLbXmWUASL9JtuWY+/zRvg6T6LX88NjKxR+j/DmhY2+ih25LhmIA0c+7KWrr3jg1bsBYMAK6e4ET2izTJLijlzvrC8/4f9smUiXRHZ7qkuchcal5aJQV1rCriV1+8/c9kenlJ3LIrzFWBGWvgC71clurBdZUvbY7t1gSXBA1k+aH3gyn7qgKaYz9r5/wUmDNCSMHcsRCVnP5gzhzRPPKHVInPgdyJ0bf2IBI8wGIFjk+WjOrd5FTdudAWX4GSJMXDMTJrJ0vzLidlVE8Mt+Jb1YQYa8r3g== 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=GOtwWheurWwCRRiFQrWxmV6s1F9Y24Bg9djRAE8e7S8=; b=Slyo03lIZQ6HVrJo6GAzSnY1ZV7sNvlykEZA6P4XxHOgE/29hPcN87E4ngwf7XMTkAZjjQdWBzb90L+vVt7bgZ3bijbVUQJHDpgtXENfaEjDElwRBFDDkDSLN9nYbgIfI4XGSz2RQJ7lZ8kRRLdB/XqXz0RBRPLVbiXg+QqG/7Xpqs98k2+HBa+3+TBT50mzxR/4+e2EUsZm5YjYp/4gj2kTX1ywg50i8Hm8uAarVVmxliaQHKFgCFVbRcLiVdrcO6dgL7GtJk7dqr44vq1zSQO20UzYnAyiwvUcbEXd/5Xp1XoDXHYLugeqfC9FoDKdxVIF1orvTmFFYt3jiv1tgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GOtwWheurWwCRRiFQrWxmV6s1F9Y24Bg9djRAE8e7S8=; b=KbuRZAGEMQX2pY+ZdqLiyuvq5zBN4A+KjMlOkhu9s6AvOpbGlnU1/VQtkI9tbHDERb463emlU82Eq2q0vAf96xUqS1CYRGeQCjMvsaVrtbM7nP0XXVQvMEgpS+tmLh2IGFVxlsn6cEK84uC9uOK7vuzfaP8CzMkNthg62CEQsaQ= Received: from AM6PR10CA0004.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:89::17) by PAVPR08MB9627.eurprd08.prod.outlook.com (2603:10a6:102:31b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Tue, 22 Aug 2023 10:39:26 +0000 Received: from AM7EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:89:cafe::3d) by AM6PR10CA0004.outlook.office365.com (2603:10a6:209:89::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Tue, 22 Aug 2023 10:39:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT044.mail.protection.outlook.com (100.127.140.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6723.15 via Frontend Transport; Tue, 22 Aug 2023 10:39:26 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 22 Aug 2023 10:39:25 +0000 Received: from armchair.cambridge.arm.com (10.2.80.71) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Tue, 22 Aug 2023 10:39:25 +0000 From: Szabolcs Nagy To: , , , Subject: [PATCH 11/11] aarch64,arm: Move branch-protection data to targets Date: Tue, 22 Aug 2023 11:39:24 +0100 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT044:EE_|PAVPR08MB9627:EE_|AM7EUR03FT029:EE_|PR3PR08MB5595:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cb686c0-674e-4681-0301-08dba2fc14f5 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Z3aH5qtlZykkUV81NLMKkQcgwnEp4b20vRZG1PzW1GbwFL7Ee2or3yNotZXSaW/P1ErQeCHBT739b+ENlT30Bbf4dNURHmNsY+i/QmBFo3On7SVEY0RZgrMxtXxlhQDifuzPMWA/rDXPO+c0ONlHP/UBpxd2cm2KFc6UATVYVmgWNwQl2L9r6X/RSnOQOD+tQL7tBszcSJbnZMqhEC6Wut8qekmiDzr0k+P8tdGzWm6Wcf/m8VG7FFMO637WRsHNzvoTCW3Hk7/PLvwZdSJnLnXr4E7g3vuqx0qiQ8KS75dzkIsQuhlf09XyRNlxlj2IjzDm7eqcqIunmnrK/d1nwlr562hA9vemjoKdp/J5HJIcIsuKQ39M+nOFN/NsQwUWCwrmbX6S50WmOwKmhx0Augyq3rhIzVmT2EOYdfJka05I+ToPEhKy0ffenQ0K/t3CgqWzikam3+gWFOD1oMQ3nsP5TFblkQlCGZX1TOKs9wCxmjKxi2qI3xmu3hFSIrwbhFpTpM3+QW7uwZ4z7Qou0e8UgVU72el2ygXvYk0a//SCqN9kjeu2aeUenK1uGguJhBiFBLgVRGjQVXOiPTTuEw0Bmk8D/tcynsstpPSSfKCsFNFYmd0OxNpjGL6ZFy6r7V+1g937sLJnkKZDXIMoOISAP0b/uuRbyYJqpjSRv7CYXuscaqyz/lKX04hhYvGuasj6SVmPCKV/ECO8HK9lbxUFE2pFbnVulU84WRy5xX1Bnu4wzS/K9Zh8DugcO8l3niO7muCeYWZR3YuxzbtFsw== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(186009)(82310400011)(1800799009)(451199024)(36840700001)(40470700004)(46966006)(86362001)(40480700001)(36756003)(81166007)(478600001)(40460700003)(6636002)(41300700001)(70206006)(316002)(70586007)(110136005)(82740400003)(356005)(26005)(7696005)(47076005)(336012)(426003)(5660300002)(8676002)(2906002)(36860700001)(2616005)(44832011)(8936002)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9627 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 03200353-7418-4689-143c-08dba2fc0eb9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J7LQsnTsKUk60qlsAKW6YsMjFOzDt6WGIvYQRIMybf5rNOys8fQldlLI+GGzHY7TybXIeEB+sIgL/3LX/4qa5NZTZjuve8D4TZl62kGOQkmaLk3K52Bv8qTZzhwuQ01BppOUrXOmYrI25O+T2sg4bF370W4QTluI1D3tK76LzdRqhXGfyOisyQMqzWE2G22o01aa+mhIMFmYOjtUMd95JRER++BIYlbIpldzxbastoCm7o+iQNQQUi6l0IFVAQ6YonZpYnjkV1ja3CIXZMfUxMcg8dl1gG2wXkzsJQWJL8+46UtACI/mIeDBZiXlu2fgmxnkXpoPrhsm6BMiUL1ZJoKJ1/V44NHf0J0kUUTH0ZNBomFWHfz1iW6cNb9g8oTbyiAKHOfIgZhFfvGj8iJWpMzUcbmfJPs4cB8Iph8DtZfu1nHnTiU5/99MOfi8Uq8k6KhPHVIWE2XUhyH1kRdEeDDHmqoNqHtNFOybhes36HyMHoYyQVLWFaSrl1zovMhEuhZWQC2fxkkRAwwiD0Upn47SSCR1omIZMXoSiH6Gr00V5dWwSnHz//ARum0BBl13HYbEMxYT99Y19hyrFfSjfpzzuwZ1GzBcCVZK8k3Q2/rWuUCyKGG8EtnW4w6kZXW7FJfXsBAgwYBL7Bb5w7KzLPdWBplC3kDvNlA22fHWAo8OM2/WRMpteD0Xm4ZHrX5CeBH36ecRctV9a3gLcZmD0k8E4nU5FjzoChyVfS+7L5PIb1vjY1KH9s7Fs8jA/8qE 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:(13230031)(4636009)(396003)(136003)(376002)(346002)(39860400002)(1800799009)(186009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(6636002)(70206006)(70586007)(316002)(110136005)(8676002)(8936002)(2616005)(40460700003)(36756003)(41300700001)(82740400003)(81166007)(478600001)(40480700001)(83380400001)(2906002)(86362001)(7696005)(47076005)(36860700001)(336012)(44832011)(426003)(5660300002)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 10:39:36.9335 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8cb686c0-674e-4681-0301-08dba2fc14f5 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: AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5595 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The branch-protection types are target specific, not the same on arm and aarch64. This currently affects pac-ret+b-key, but there will be a new type on aarch64 that is not relevant for arm. gcc/ChangeLog: * config/aarch64/aarch64-opts.h (enum aarch64_key_type): Rename to ... (enum aarch_key_type): ... this. * config/aarch64/aarch64.cc (aarch_handle_no_branch_protection): Copy. (aarch_handle_standard_branch_protection): Copy. (aarch_handle_pac_ret_protection): Copy. (aarch_handle_pac_ret_leaf): Copy. (aarch_handle_pac_ret_b_key): Copy. (aarch_handle_bti_protection): Copy. * config/arm/aarch-common.cc (aarch_handle_no_branch_protection): Remove. (aarch_handle_standard_branch_protection): Remove. (aarch_handle_pac_ret_protection): Remove. (aarch_handle_pac_ret_leaf): Remove. (aarch_handle_pac_ret_b_key): Remove. (aarch_handle_bti_protection): Remove. * config/arm/aarch-common.h (enum aarch_key_type): Remove. (struct aarch_branch_protect_type): Declare. * config/arm/arm-c.cc (arm_cpu_builtins): Remove aarch_ra_sign_key. * config/arm/arm.cc (aarch_handle_no_branch_protection): Copy. (aarch_handle_standard_branch_protection): Copy. (aarch_handle_pac_ret_protection): Copy. (aarch_handle_pac_ret_leaf): Copy. (aarch_handle_bti_protection): Copy. (arm_configure_build_target): Copy. * config/arm/arm.opt: Remove aarch_ra_sign_key. --- gcc/config/aarch64/aarch64-opts.h | 6 ++-- gcc/config/aarch64/aarch64.cc | 55 +++++++++++++++++++++++++++++++ gcc/config/arm/aarch-common.cc | 55 ------------------------------- gcc/config/arm/aarch-common.h | 11 +++---- gcc/config/arm/arm-c.cc | 2 -- gcc/config/arm/arm.cc | 52 +++++++++++++++++++++++++---- gcc/config/arm/arm.opt | 3 -- 7 files changed, 109 insertions(+), 75 deletions(-) diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h index 7e8f1babed8..75ef00b60d4 100644 --- a/gcc/config/aarch64/aarch64-opts.h +++ b/gcc/config/aarch64/aarch64-opts.h @@ -103,9 +103,9 @@ enum stack_protector_guard { }; /* The key type that -msign-return-address should use. */ -enum aarch64_key_type { - AARCH64_KEY_A, - AARCH64_KEY_B +enum aarch_key_type { + AARCH_KEY_A, + AARCH_KEY_B }; #endif diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 661ac12cacc..734980f78ec 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -18517,6 +18517,61 @@ aarch64_set_asm_isa_flags (aarch64_feature_flags flags) aarch64_set_asm_isa_flags (&global_options, flags); } +static void +aarch_handle_no_branch_protection (void) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NONE; + aarch_enable_bti = 0; +} + +static void +aarch_handle_standard_branch_protection (void) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; + aarch_ra_sign_key = AARCH_KEY_A; + aarch_enable_bti = 1; +} + +static void +aarch_handle_pac_ret_protection (void) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; + aarch_ra_sign_key = AARCH_KEY_A; +} + +static void +aarch_handle_pac_ret_leaf (void) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_ALL; +} + +static void +aarch_handle_pac_ret_b_key (void) +{ + aarch_ra_sign_key = AARCH_KEY_B; +} + +static void +aarch_handle_bti_protection (void) +{ + aarch_enable_bti = 1; +} + +static const struct aarch_branch_protect_type aarch_pac_ret_subtypes[] = { + { "leaf", false, aarch_handle_pac_ret_leaf, NULL, 0 }, + { "b-key", false, aarch_handle_pac_ret_b_key, NULL, 0 }, + { NULL, false, NULL, NULL, 0 } +}; + +const struct aarch_branch_protect_type aarch_branch_protect_types[] = { + { "none", true, aarch_handle_no_branch_protection, NULL, 0 }, + { "standard", true, aarch_handle_standard_branch_protection, NULL, 0 }, + { "pac-ret", false, aarch_handle_pac_ret_protection, aarch_pac_ret_subtypes, + ARRAY_SIZE (aarch_pac_ret_subtypes) }, + { "bti", false, aarch_handle_bti_protection, NULL, 0 }, + { NULL, false, NULL, NULL, 0 } +}; + /* Implement TARGET_OPTION_OVERRIDE. This is called once in the beginning and is used to parse the -m{cpu,tune,arch} strings and setup the initial tuning structs. In particular it must set selected_tune and diff --git a/gcc/config/arm/aarch-common.cc b/gcc/config/arm/aarch-common.cc index 159c61b786c..92e1248f83f 100644 --- a/gcc/config/arm/aarch-common.cc +++ b/gcc/config/arm/aarch-common.cc @@ -659,61 +659,6 @@ arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, return saw_asm_flag ? seq : NULL; } -static void -aarch_handle_no_branch_protection (void) -{ - aarch_ra_sign_scope = AARCH_FUNCTION_NONE; - aarch_enable_bti = 0; -} - -static void -aarch_handle_standard_branch_protection (void) -{ - aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; - aarch_ra_sign_key = AARCH_KEY_A; - aarch_enable_bti = 1; -} - -static void -aarch_handle_pac_ret_protection (void) -{ - aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; - aarch_ra_sign_key = AARCH_KEY_A; -} - -static void -aarch_handle_pac_ret_leaf (void) -{ - aarch_ra_sign_scope = AARCH_FUNCTION_ALL; -} - -static void -aarch_handle_pac_ret_b_key (void) -{ - aarch_ra_sign_key = AARCH_KEY_B; -} - -static void -aarch_handle_bti_protection (void) -{ - aarch_enable_bti = 1; -} - -static const struct aarch_branch_protect_type aarch_pac_ret_subtypes[] = { - { "leaf", false, aarch_handle_pac_ret_leaf, NULL, 0 }, - { "b-key", false, aarch_handle_pac_ret_b_key, NULL, 0 }, - { NULL, false, NULL, NULL, 0 } -}; - -static const struct aarch_branch_protect_type aarch_branch_protect_types[] = { - { "none", true, aarch_handle_no_branch_protection, NULL, 0 }, - { "standard", true, aarch_handle_standard_branch_protection, NULL, 0 }, - { "pac-ret", false, aarch_handle_pac_ret_protection, aarch_pac_ret_subtypes, - ARRAY_SIZE (aarch_pac_ret_subtypes) }, - { "bti", false, aarch_handle_bti_protection, NULL, 0 }, - { NULL, false, NULL, NULL, 0 } -}; - /* In-place split *str at delim, return *str and set *str to the tail of the string or NULL if the end is reached. */ diff --git a/gcc/config/arm/aarch-common.h b/gcc/config/arm/aarch-common.h index f72e21127fc..90d2112408f 100644 --- a/gcc/config/arm/aarch-common.h +++ b/gcc/config/arm/aarch-common.h @@ -44,12 +44,7 @@ enum aarch_function_type { AARCH_FUNCTION_ALL }; -/* The key type that -msign-return-address should use. */ -enum aarch_key_type { - AARCH_KEY_A, - AARCH_KEY_B -}; - +/* Specifies a -mbranch-protection= argument. */ struct aarch_branch_protect_type { /* The type's name that the user passes to the branch-protection option @@ -64,4 +59,8 @@ struct aarch_branch_protect_type unsigned int num_subtypes; }; +/* Target specific data and callbacks for parsing -mbranch-protection=. + The first item is used to reset the branch-protection settings. */ +extern const struct aarch_branch_protect_type aarch_branch_protect_types[]; + #endif /* GCC_AARCH_COMMON_H */ diff --git a/gcc/config/arm/arm-c.cc b/gcc/config/arm/arm-c.cc index d3d93ceba00..204403b3ff4 100644 --- a/gcc/config/arm/arm-c.cc +++ b/gcc/config/arm/arm-c.cc @@ -248,8 +248,6 @@ arm_cpu_builtins (struct cpp_reader* pfile) { unsigned int pac = 1; - gcc_assert (aarch_ra_sign_key == AARCH_KEY_A); - if (aarch_ra_sign_scope == AARCH_FUNCTION_ALL) pac |= 0x4; diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 5681073a948..5cb0f2858b7 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -3250,6 +3250,52 @@ static sbitmap isa_all_fpubits_internal; static sbitmap isa_all_fpbits; static sbitmap isa_quirkbits; +static void +aarch_handle_no_branch_protection (void) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NONE; + aarch_enable_bti = 0; +} + +static void +aarch_handle_standard_branch_protection (void) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; + aarch_enable_bti = 1; +} + +static void +aarch_handle_pac_ret_protection (void) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; +} + +static void +aarch_handle_pac_ret_leaf (void) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_ALL; +} + +static void +aarch_handle_bti_protection (void) +{ + aarch_enable_bti = 1; +} + +static const struct aarch_branch_protect_type aarch_pac_ret_subtypes[] = { + { "leaf", false, aarch_handle_pac_ret_leaf, NULL, 0 }, + { NULL, false, NULL, NULL, 0 } +}; + +const struct aarch_branch_protect_type aarch_branch_protect_types[] = { + { "none", true, aarch_handle_no_branch_protection, NULL, 0 }, + { "standard", true, aarch_handle_standard_branch_protection, NULL, 0 }, + { "pac-ret", false, aarch_handle_pac_ret_protection, aarch_pac_ret_subtypes, + ARRAY_SIZE (aarch_pac_ret_subtypes) }, + { "bti", false, aarch_handle_bti_protection, NULL, 0 }, + { NULL, false, NULL, NULL, 0 } +}; + /* Configure a build target TARGET from the user-specified options OPTS and OPTS_SET. If WARN_COMPATIBLE, emit a diagnostic if both the CPU and architecture have been specified, but the two are not identical. */ @@ -3299,12 +3345,6 @@ arm_configure_build_target (struct arm_build_target *target, { aarch_validate_mbranch_protection (opts->x_arm_branch_protection_string, "-mbranch-protection="); - - 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) diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt index 88299dabc3a..bd8bb00d035 100644 --- a/gcc/config/arm/arm.opt +++ b/gcc/config/arm/arm.opt @@ -30,9 +30,6 @@ enum aarch_function_type aarch_ra_sign_scope = AARCH_FUNCTION_NONE TargetVariable unsigned aarch_enable_bti = 0 -TargetVariable -enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A - Enum Name(tls_type) Type(enum arm_tls_type) TLS dialect to use: -- 2.25.1