From patchwork Fri Jul 22 14:34:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 56270 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 DE8973835404 for ; Fri, 22 Jul 2022 14:35:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE8973835404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658500528; bh=JSGrtCF4IvfU2Y0pkf8DQIzb6F3jVwmdbBLvoijM+7Y=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=lSfpGYrtQtHVBC8swiRcNn7/8y6NtAAtoQtzrUZj0Nz+95yEDZoQ++IhofGV8DW5w apCqtYhyDxOZ+3VHjs5ZKvehLxn25iot5ROsqaeT/SLOw3TQRCYhli4ls/Qs2+xUnV YEwWmCvQZ7BzRovdagyCwz1xxdB8qTx2FFXiI6KE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2088.outbound.protection.outlook.com [40.107.21.88]) by sourceware.org (Postfix) with ESMTPS id E757938356A5 for ; Fri, 22 Jul 2022 14:34:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E757938356A5 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Gv2K+agsRz5WNMa4ECA23V8gehBdPXM8cmvhiX9oHuWbZi3jh1P5zLs6uTEafejC5Q1Zv9s2F6Qx3XnSMX0niXv8WsG/dewdWPJFuRmZ6gXUqVm4ayxYEt/BDeb39cf70IA8AOZG7Ns8gxXhnLFTw/AqtR1QbqNfYge+Dj7wl+emh65l9pY30J13AX6qT61zsk59/b2OMFWArPsLYzNWw1aQWywyHjhgc/1rhda+CDMKpRogxZI7qqHTadjFeOB7auov4MUuHlJYkvVJfsKFZ1eoAgz2pVo6akJzARxpG/ZZpNno/hRxqOesu/SssWg63drDNK0VBlGHES7Im/wKXA== ARC-Message-Signature: i=2; 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=JSGrtCF4IvfU2Y0pkf8DQIzb6F3jVwmdbBLvoijM+7Y=; b=RslQRlvt6k8GJO8SwciLOq6Uz6XY4ajzkkC1KaxYUQ0S+qCnN9YyPf/gShUNFtuW3+umJrMMAO5xEbu9duj2Jn5W/kecud2YufXiy81nNPPrxPcRpc16QgMxDDZnrSDIl3tuoq88EKGo/f6aeHuTI+xJlZaIriApw5/eWRM7GfpHtqkF/lPxu4PEn7pmmmXmbEFb2wpy+wJ/XZduvs6pVvjITcbQISTNWzzhOHfFpexAZu71SqVz1wDSVraAakdXdTdjUrXyfK6Kzg+06o4Fp1sUHxa3ld+QmI7Em+blYcGR7ElIsYvAKAoJ/SRCh7cvimO5j5g7QF5q9SreMeEgRg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AM6PR0202CA0071.eurprd02.prod.outlook.com (2603:10a6:20b:3a::48) by AM0PR08MB5236.eurprd08.prod.outlook.com (2603:10a6:208:155::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Fri, 22 Jul 2022 14:34:51 +0000 Received: from VE1EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:3a:cafe::cc) by AM6PR0202CA0071.outlook.office365.com (2603:10a6:20b:3a::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19 via Frontend Transport; Fri, 22 Jul 2022 14:34:51 +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 VE1EUR03FT063.mail.protection.outlook.com (10.152.18.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.17 via Frontend Transport; Fri, 22 Jul 2022 14:34:51 +0000 Received: ("Tessian outbound 6a3290ff1310:v123"); Fri, 22 Jul 2022 14:34:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e44afd7f59734c4e X-CR-MTA-TID: 64aa7808 Received: from c21c2d6a5746.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 921F81DC-C099-422E-A529-B14906EDFB0F.1; Fri, 22 Jul 2022 14:34:44 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c21c2d6a5746.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 22 Jul 2022 14:34:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n2Kmzgxy/JKpDeWtCkOCT6n2Z8RRdeGqFa5DJd1Q50Ep3bWp20T3dCUYA/bYyNQAOJ4Q8PQX5v9v7vAY4/57wizCHQZYMHd8pPXGTlI+LigcStrAimjMKS7u1E0oH1Nx05T9+jj//KRcbfVAR92KfSMlt3aT8wGx4L2IKHqzLr44FUogHJyCFHGg/3oFWXw4WEXOd9UQLqZnGo/kwW/hmZUVMrAXDHSqVCmR1GCoqDwArjk+ZsktPV27WExifik+UFx7m9lRR8LsV7SHZlCq0ueNNnVun6hg2/cxVHqnCdLfSIl6LmPxM+z2/JfVIlSOa4ioiWK9bTsEeXGrBkOkOg== 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=JSGrtCF4IvfU2Y0pkf8DQIzb6F3jVwmdbBLvoijM+7Y=; b=LR+QdWOXD8OxwFaUzOo9jZtunjMgfUiGCeJWxkNnFEncixGniKsEpYWHKrjP9zoOcXjmHAhiZR55tUk4I7qKkOakZgqGMkOMWzuZHCm2Akco8W8ATMIPqNb5H63nW6HmtTUDmcYLfUlmZItSZdjkj311fXn25RkhHUZtLuk2sD5FZrLaQocRyFkFOw0uMX1UWOnqYeYH9OWKGqigeQMEqyHlak3oBFxf4z/5x3zyq7b8/Lhw5HxKItj5hpy08aDlkbtkM1jqDIIWbZRAsJMgPb08TwluO0K1OjES36lPs6txQIYl0hWAVWxkHKqpveHYTIkboX8Oui5xaWeSXuakoQ== 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 Received: from AS4PR10CA0006.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5dc::6) by AS8PR08MB5878.eurprd08.prod.outlook.com (2603:10a6:20b:29b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Fri, 22 Jul 2022 14:34:42 +0000 Received: from AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:5dc:cafe::ab) by AS4PR10CA0006.outlook.office365.com (2603:10a6:20b:5dc::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19 via Frontend Transport; Fri, 22 Jul 2022 14:34:42 +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 AM5EUR03FT041.mail.protection.outlook.com (10.152.17.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5458.17 via Frontend Transport; Fri, 22 Jul 2022 14:34:42 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2507.9; Fri, 22 Jul 2022 14:34:41 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.9; Fri, 22 Jul 2022 14:34:41 +0000 Received: from e124257 (10.34.105.24) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9 via Frontend Transport; Fri, 22 Jul 2022 14:34:40 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 5/12 V4] arm: Implement target feature macros for PACBTI References: Date: Fri, 22 Jul 2022 16:34:40 +0200 In-Reply-To: (Andrea Corallo via Gcc-patches's message of "Fri, 22 Jul 2022 12:35:24 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1.50 (gnu/linux) MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: d7103d2a-3039-43dd-0822-08da6bef5635 X-MS-TrafficTypeDiagnostic: AS8PR08MB5878:EE_|VE1EUR03FT063:EE_|AM0PR08MB5236:EE_ 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: BnzFhtSIwSnWKHagM/0BS5nWFP0Oyt5sEHPuDf1jNKhBeynpWPnTC4mUtrCg+S8I2kEuD9R+j3+6SsKOmhu4wt70G87TiF/itviS7ty8nAAp1uzyN5ga8BmFyAgVTu8x2kT8OFWSyhiI12m6orWSj9a3cznUdFge7bdwtrdtHbpJ6rscOee3u0jmkB7yWGppo5bDMlzCQ08C993r6uz1c+yDWWdCZ1EJTGFhv+MoYVxqFE+hcKfHFDgslNfdhHMjv0vwiCFTX3jbiLAxgL/bU8F1RncLXGoc04n/oxzLjGMt19E2gFECOmrBpolx1NldZyCSA/5Guys6rnocBBB2yQOm/Q0NAFCUYWoicXt0wpeRnR7GH2/pdma/Wy7g/UJZh3v48xBscb44nItlbIc/qLNgxhyPyW3m9Za8OjUAmjZjDlMT2/Am0nxOFcBZYNV7C81FTH+TrC/Ka1KXrfjz7Dthot1sfT69p4ywsxAPUi91Y3yvH/48dgGHJ6eelx0s0u7/nT0rJYd2RuJLe8QmJKZD7v/nFOOIhndilCq6Qu59pgX71kJ65jfrce2m6m/bHny8VibqkrUAz8xrk67pwt3y8AgtGU0AYo1SCUim7Zhdc8VqPlvrb5aHLrguLQWdN9Rwe2DHogNxoQ78KUp5QNZWz6RwzBGuEtP1ToAYzt/InC+TDUjr9CbhstWKI8VBgQdbLG82klzPJO2csENW3QZAuNTbSyHMntaF5FajRK9eXsZEmyrQfonAhCP7pl8Y2NVJ2o8KoQqrB95qC5T8sW6pTtiLrIpNphnZWhWMbSOyPH7BSJvyZpYj+GlFaRmTWcEXxOErZYzMql0T0p1deA== 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:(13230016)(4636009)(396003)(136003)(346002)(39860400002)(376002)(40470700004)(36840700001)(46966006)(44832011)(36860700001)(81166007)(40480700001)(47076005)(82740400003)(356005)(83380400001)(70586007)(426003)(70206006)(4326008)(6916009)(8676002)(316002)(36756003)(54906003)(33964004)(478600001)(82310400005)(5660300002)(26005)(2906002)(40460700003)(41300700001)(8936002)(2616005)(336012)(186003)(235185007)(86362001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5878 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d5837b3f-ae14-44ca-aa17-08da6bef50bd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ql8+ai7HQDBC1LGmTBPXkSbzouwvltMZ29U9LuWYc871ZPujH5ISn0BLxsqi4c3Ch1p7J4b526vRHeja+mHMxqN5/cAheFg94lorTh/WuUWxc/eq840kAU6V5gGcfmgujhvICxXBoH4BBDBGR49v2O92sWI2B2esjLRyEY+B/95oXToNX51SVIE8UsAifXQjch68x2V/sGBF5/1IT8Zz63XZIhm9s0GkAj8+4mWL7ilzLIkEgOeU7jC5vScZgfhW0SNgFQJixyw3tQZpgDkQZDPd38DlJe3LUq/wiNq5TyGMiHZjSjwt+EBNlpo5MVIRfBQft1xBef3ARCxekdfl4CKtu/CVkKas2dTCGfOugLLKZ5GuuETAF8fVQRr/QFY4IaTx24QNyLzr8QkXt8hDDj4uQFHz8gnABU6MuYiUsrIc2Cvc/CMOtOiyZOal3swp+No5BsIJQehCWldGRACyT+EQKJ2gljqxgaTERPLTrOqaSB/3rQKlh4K58rrq0zax42VsVYH+MQ6VjB5B0nhsfHJCqPSaLXkeryVaYoqp1Rr6gvpkuQtuvT7fWEe0RL1bDrqzkipq73a8+6yrvSNP0GZk7Aq6PfAmqvc+IjWaKvalWUZyZlU8GwO/e206IqWh1xsKos/0F2pjo2r2cswHUQ8ncDxlDdwtaaShhd8oAXbgAlqrcGBG0eYy/vdrmJp1hun026Ycy2yVyi3KU4R3FAp7tC0AzYa0keOp0fltrwPFcb2TJUIIjAQzCYjHn2nvPJkzRcfiKFxgiTT+bJ6/+4kxuEO5SiAfPN/oUroORKkCO8JGlp3rF2RbCfTiuav/ 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:(13230016)(4636009)(136003)(346002)(376002)(396003)(39860400002)(46966006)(36840700001)(40470700004)(82310400005)(478600001)(33964004)(2906002)(2616005)(47076005)(426003)(41300700001)(83380400001)(40480700001)(186003)(26005)(336012)(36860700001)(54906003)(70586007)(4326008)(8676002)(86362001)(70206006)(36756003)(40460700003)(6916009)(316002)(82740400003)(235185007)(8936002)(5660300002)(44832011)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 14:34:51.2612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7103d2a-3039-43dd-0822-08da6bef5635 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: VE1EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5236 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, 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 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: Andrea Corallo via Gcc-patches From: Andrea Corallo Reply-To: Andrea Corallo Cc: Richard Earnshaw , nd , Richard Earnshaw Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Andrea Corallo via Gcc-patches writes: > Hi Richard, > > thanks for reviewing. > > Richard Earnshaw writes: > > [...] > >> diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c >> b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c >> new file mode 100644 >> index 00000000000..311cf572dd9 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c >> @@ -0,0 +1,10 @@ >> +/* { dg-do compile } */ >> +/* { dg-additional-options " -mbranch-protection=bti+pac-ret" } */ >> >> This is not enough. For example, if the testsuite is being run with >> "-march=armv6-m" as the testrun options, we'll get an error that will >> cause a test failure. You need to run a pre-test rule that validates >> that adding -mbranch-protection is safe. > > Right, please find attached the updated patch, it should fix this and > the mentioned spacing issue. Scratch that, I think the attached is better. Sorry for the noise. Andrea From 0238ad4a53b78b8458ed254d0cb226457b6a76de Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Mon, 6 Dec 2021 11:39:59 +0100 Subject: [PATCH] [PATCH 5/12] arm: Implement target feature macros for PACBTI 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 __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI are specified in the pull-request . Approved here . gcc/ * 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/ * lib/target-supports.exp (check_effective_target_mbranch_protection_ok): New function. * gcc.target/arm/acle/pacbti-m-predef-2.c: New test. * gcc.target/arm/acle/pacbti-m-predef-4.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-5.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-8.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-9.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-10.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-11.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-12.c: Likewise. Co-Authored-By: Tejas Belagod --- gcc/config/arm/arm-c.cc | 18 +++++++++++++++ .../gcc.target/arm/acle/pacbti-m-predef-10.c | 11 +++++++++ .../gcc.target/arm/acle/pacbti-m-predef-11.c | 11 +++++++++ .../gcc.target/arm/acle/pacbti-m-predef-12.c | 11 +++++++++ .../gcc.target/arm/acle/pacbti-m-predef-2.c | 23 +++++++++++++++++++ .../gcc.target/arm/acle/pacbti-m-predef-4.c | 20 ++++++++++++++++ .../gcc.target/arm/acle/pacbti-m-predef-5.c | 23 +++++++++++++++++++ .../gcc.target/arm/acle/pacbti-m-predef-8.c | 12 ++++++++++ .../gcc.target/arm/acle/pacbti-m-predef-9.c | 11 +++++++++ gcc/testsuite/lib/target-supports.exp | 10 ++++++++ 10 files changed, 150 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c create mode 100644 gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c create mode 100644 gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c create mode 100644 gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c create mode 100644 gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c create mode 100644 gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c create mode 100644 gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c create mode 100644 gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c diff --git a/gcc/config/arm/arm-c.cc b/gcc/config/arm/arm-c.cc index a8697b8c62f..190099b2c37 100644 --- a/gcc/config/arm/arm-c.cc +++ b/gcc/config/arm/arm-c.cc @@ -212,6 +212,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-10.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c new file mode 100644 index 00000000000..4fcc96f3eb4 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options " -mbranch-protection=bti+pac-ret" } */ + +#if (__ARM_FEATURE_BTI_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c new file mode 100644 index 00000000000..47d4ac2ab9a --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-options "-march=armv8.1-m.main+pacbti" } */ + +#if (__ARM_FEATURE_BTI != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if (__ARM_FEATURE_PAUTH != 1) +#error "Feature test macro __ARM_FEATURE__PAUTH should be defined to 1." +#endif diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c new file mode 100644 index 00000000000..ea95f7c7b91 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-options "-march=armv8.1-m.main" } */ + +#if defined (__ARM_FEATURE_BTI) +#error "Feature test macro __ARM_FEATURE_BTI should not be defined." +#endif + +#if defined (__ARM_FEATURE_PAUTH) +#error "Feature test macro __ARM_FEATURE_PAUTH should not be defined." +#endif 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 00000000000..bd29806c326 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c @@ -0,0 +1,23 @@ +/* { 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 00000000000..88e7957486d --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c @@ -0,0 +1,20 @@ +/* { 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 00000000000..17e3543ab8f --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c @@ -0,0 +1,23 @@ +/* { 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; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c new file mode 100644 index 00000000000..ffae0d2a24e --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options " -mbranch-protection=bti+pac-ret+leaf" } */ + +#if (__ARM_FEATURE_BTI_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if (__ARM_FEATURE_PAC_DEFAULT != 5) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined to 5." +#endif + diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c new file mode 100644 index 00000000000..4dde64b827c --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options " -mbranch-protection=pac-ret" } */ + +#if (__ARM_FEATURE_PAC_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined to 1." +#endif + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index df8ab037fb3..62e41d1e8d4 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5090,6 +5090,16 @@ proc check_effective_target_arm_cmse_clear_ok {} { } "-mcmse"]; } +# Return 1 if this is an ARM target supporting +# -mbranch-protection=standard, 0 otherwise. + +proc check_effective_target_mbranch_protection_ok {} { + + return [check_no_compiler_messages mbranch_protection_ok object { + int main (void) { return 0; } + } "-mbranch-protection=standard"] +} + # Return 1 if the target supports executing PACBTI instructions, 0 # otherwise.