From patchwork Fri Aug 12 15:41:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp952022pxh; Fri, 12 Aug 2022 08:42:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR5vTQTnsyc8nmXmRuGBXNkHeECtG/HnPSWKlU7Z5i6gnx8rhPLSFqpBfHtwR/m03NKShQOs X-Received: by 2002:a17:907:c0d:b0:730:a85d:8300 with SMTP id ga13-20020a1709070c0d00b00730a85d8300mr3115250ejc.558.1660318968877; Fri, 12 Aug 2022 08:42:48 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id lw28-20020a170906bcdc00b00730a4246dd0si1881729ejb.593.2022.08.12.08.42.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:42:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GbYWMLc1; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A636C385842E for ; Fri, 12 Aug 2022 15:42:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A636C385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318967; bh=HAfcdaI5Xkx4Equxzg3jJdQmaNIRDdl2EnobdkTETNU=; 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=GbYWMLc1GEneDZOnS/NrNIlLS8Dk+4qnjG6hF7Y95B20gopJgOm1jfxJgLettQ18f PnS3/KVdDeNe5PoCLAZh8+3J7FQCWEIBxfJTgWk6JDvKA01S7RU0BUdn+IE6kY40s0 yBQIUs3kEA85Z3UITYKDp5ZeL1eARe0PYA/qBshI= 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-eopbgr80082.outbound.protection.outlook.com [40.107.8.82]) by sourceware.org (Postfix) with ESMTPS id 58CCB3858D28 for ; Fri, 12 Aug 2022 15:42:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 58CCB3858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Lo9h2iwLeCIv26iD6sUMOqZGhn9zQepqglXgl00vzpjYR6ROGANy4+RJQbBtkZjShnhOtfklaUPT5ehubS0Qi6BoknrHWObhfVXzZ35i12T5nmuu7UeGuovqrDItCmWCO6PP+JWhF0u1c6ePHK2Sv07PIUgcN7mqbEK33POp+YfWDN0nJPcQgd3/TLOI3jtLIIdV+5ejQSatsFgtydQoyDyRV/fipUU6vGo5v0KEwNjJ5eXECxkOkaCyLL9GHcceZGi5Wt+IfbHLtHC16UAMylGgGEEj1dFkj9OsFJ9w0XILTV1y5nI793xZvA8i582tOhhGdUebdmTfe7tuMinSpw== 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=HAfcdaI5Xkx4Equxzg3jJdQmaNIRDdl2EnobdkTETNU=; b=eVJMNN94JFZSJQb3W7KpHEaiRikvf88W9IdaoDIqpXXDugoo5ho3GnvJ/B0nn/HyRP7KwRbnZ+BSBUbr98pmm1bhyk6uBumeHFe2hmFY4SyT8uRuRM/elYKmJ+qcyunp77Jxv3+EatT1A784bDXRWJ8YkgCfCWnjSqsdcwUYLxWv0kqUp9aQ0kF+LNsxNA7jycobJKqynKF2KYN4clcFjCgm9nK8PKNX/aIlgdPr7YppapCGGQIeTo4jMvtoip3L88kHGQbN6mqRMaQFA1ArIBhxm0eJHIq22TfFEdJil6yPBZFhmp8dm66DEHA2li5D8cWbi8G0om2iasbDohK5mA== 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 FR0P281CA0089.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::11) by VI1PR08MB3199.eurprd08.prod.outlook.com (2603:10a6:803:46::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16; Fri, 12 Aug 2022 15:41:57 +0000 Received: from VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:1e:cafe::ad) by FR0P281CA0089.outlook.office365.com (2603:10a6:d10:1e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.10 via Frontend Transport; Fri, 12 Aug 2022 15:41:57 +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 VE1EUR03FT043.mail.protection.outlook.com (10.152.19.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11 via Frontend Transport; Fri, 12 Aug 2022 15:41:56 +0000 Received: ("Tessian outbound 73dd6a25223d:v123"); Fri, 12 Aug 2022 15:41:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e65a04a6027dfbf3 X-CR-MTA-TID: 64aa7808 Received: from 39d03384b156.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EAB0FE64-B1F7-4713-884B-E53C8ADD919A.1; Fri, 12 Aug 2022 15:41:48 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 39d03384b156.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:41:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkUxq4ZeAgJ2HEE7KbmUlgxjZraq7ORgwW6mFIqs/v2YhAafh+Y96xJWkKWXvePaGkVBHTNqL+sZeT/EbbZVV3HlCIDWqHlgX+Ys2rOoXWMF4YATcsN44Y84xyo14MrE7+4GlRoSdI3VmIl/sZNgD0Ep9nE8NtcpbQefIYsD82Ujr5j5HWaN+ihclsl5o2N34rHZ/9tqM4maDDvGWjD4SBm5JKjYeWK8Lq1OhlC0frVIL+rwozK9oJrzYWHLaL9YzuBzZGxCjOnTjHNWY+wl3H/X8hCEruyL6Hjcz8ukPyNTEBT4C7Y66RIRG2vAQw8E0dP3+Aa1KsAVSu3y2BBzrA== 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=HAfcdaI5Xkx4Equxzg3jJdQmaNIRDdl2EnobdkTETNU=; b=T6APPmO+Sc3ji+vFzL0oSknuzwl4fjlMnOrk1CSA105f7qMKNLWr+EAbzgK+6VHi0/P+AtjjmHTU9FTUGYDUQfbRBXJ1rYS7h0ZVoGSv+fJBiiM04tQguEkpS/4+l974lxDw6tdl9+cwRaHLLPafoO1RSBINqyx8WrH0iwqathBOE2/9n3vkraAEtrztgouhrX9TFsOB1HZXwgdqJT5FklkMQzt56T+7lPb0xmJWix7JwrcnoHXI0olUPBzcDyjIBnQvbPko60MerZJkPMlUs9MJJ2hREGKljzhyRdEcI/W6LNcro5eZAi59sgmRuO/XXAdjj6xKJA4DGKbSI6DmeQ== 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 FR0P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::17) by AS8PR08MB7694.eurprd08.prod.outlook.com (2603:10a6:20b:509::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.25; Fri, 12 Aug 2022 15:41:45 +0000 Received: from VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a8:cafe::68) by FR0P281CA0119.outlook.office365.com (2603:10a6:d10:a8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.6 via Frontend Transport; Fri, 12 Aug 2022 15:41:44 +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 VE1EUR03FT008.mail.protection.outlook.com (10.152.18.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5525.11 via Frontend Transport; Fri, 12 Aug 2022 15:41:44 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.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; Fri, 12 Aug 2022 15:41:43 +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, 12 Aug 2022 15:41:43 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 12/15] arm: implement bti injection References: Date: Fri, 12 Aug 2022 17:41:42 +0200 In-Reply-To: (Andrea Corallo via Gcc-patches's message of "Fri, 12 Aug 2022 16:26:49 +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: 103e4a80-cf46-4099-4ddb-08da7c793061 X-MS-TrafficTypeDiagnostic: AS8PR08MB7694:EE_|VE1EUR03FT043:EE_|VI1PR08MB3199: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: Dij4ME4RCNIyX8YETfduu6/dcuABvZqdvQQ5uWB5gNddVv6Jn5ehEG3cqu8tiiuyETdwOTmCy1odF1z+Za0+ntSqG2momhRygaTF16Z++j3SYEipymhkBb4if4rp/Bc9fuvNcDQVQOwxKHr1aVjgSRyxXGMgJPmgQHBPZrd74fH7n0S0OW3vPhZTC0FcSYFebIuhJBQKk5SJlYf7rcZ0TO4Po1LL4cKbKlmAKelX0nWLF9cCgeMlMceo/lNtmwhVu8B05tnIJHCCupu6V8OBhLVcrgJ2h1s0ULO7MvwBdGo5zL0XmP2NaAlS3/POunTl4tQPLs8+CAg9Cw9XmnQ/MatexS/e3T/16MCawuUW+Lw7x2EMZ9/p7lZRGi98KiAkrzgWE1DRyRP7Yl6cVaAtf6/L6C+NkmXkdoTmI5CygCTtbh+pm9h1bd8TzQCOdSloHZAf0ZJRSYomgteuvqSF7WnB2Ihx7EhiQh+RG1BQpXVH3f+K6Xa6uoJ43Zqxgcj81zu9Po4vIMoE2bTO+souPKDTkF8JZi3zun1pWTuWD5HSOn7awPx+nU6uotxjQ4mfHPuNMGAbXfRNfmitu4mQyHLxzj7eKbbWNyV/Fo9SiplkZLXOaq8mA3MYBV6O1Rbtq5id4amHTfaKNGctACYLS8NZ7LCIK6y5sX6Hh9aKBDtSwOF8D68BH2SB0Ywu4j8XbFDGDB1SXsloI3IokUD82gKIl0bkvw0hWJ1mOKHKbfPwmvb+6kvqfSBwB+ig91qVQl/Q5dr77M2fk7wT3pUKtcXPWtuzruDBjjgOhEzs5QQ= 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)(39860400002)(346002)(376002)(136003)(396003)(36840700001)(46966006)(40470700004)(316002)(82740400003)(4326008)(8676002)(478600001)(83380400001)(6916009)(36756003)(70586007)(84970400001)(70206006)(54906003)(40480700001)(44832011)(86362001)(82310400005)(2906002)(5660300002)(40460700003)(356005)(8936002)(81166007)(235185007)(26005)(41300700001)(36860700001)(47076005)(186003)(2616005)(336012)(33964004)(426003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7RNh1xP3GtsWjca8pp8JTLaEE5tqWlcdjl3L7iVTJ9ynykVLJkXybFiiojziM84qLP6Vz+xJzb/+naABnwaSHEptcbUB2fh/fXjiZ/wHqBFtc+1rNMauW34w8sEqMxXc4NxnK1YsNBRQxvcEnw7d4y/sZeZewqGTKuJY0MpjAF+OtmphGGYLpCWZHAit0cFX/TVpKMimJ+j5yn8FDj5vJeUyc5ieZt7/IYHe3QTPwiuAW+768UDqIwKXjMhkFQ+npLkxQOSrnLAZbiI4MjZ1hBmfx2zu1G4bA6u8cZ/B3vFW5WrjjLX15PpgEzbPol6r4C2WgvF3h8gv6eo5av2KXsSnoLvFOPsDtw4jnSg929ewrb8Gw4CPS0csU+0SiAlEssRSsFXL0zrDhNdkPulHyTIgMJApgy6QrOvsvThfVUnxWCBLdLEGWF1Y7abTHMbOsqIpuwEh8CedSp9HzoiytL/BHuEyTtn114Rbsn9SGfQzTEHgCXLXeJ4YCmct7No4xvaY12PwWQANNj8pteaY1Zft8kNCW6sbQSE5X4SvLBybT6CCRaY1XK6P9Iw1TzBjNJRdGgkSVrMdjwbVx3PkfRnlwO7wN61JtAArF1AnbPxn9lY0q3HwkFlYobCoYlawFB7D8qhBRcRwZYcbeQUx1eyM+0ljdW/jBshA4YOq2Brn1M0jC5ZU1nqwkgfGDrxVGLiBK7+6bKTc7uVQs5WMxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7694 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 38c559b8-cb49-4b2c-cc5d-08da7c792913 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /kMo1txpat9lhNddBez40shB6ZAGSZBG4/fCi5u8BWqWDMopA2OjkXGw5mhKbwCKemYQUZA9E6U+66muI4jb9ArXdkfWK5SFUBxL6R5mWb3KtxYSRRucC7GYeLwsC6r0lJw/QwYjj6txjC1cf8LfwcR2ikJxIMBtzyC7xaWskTF75b5k60QEcZnT9d3Jh0eHNuHsZ4cwW7b+zhdb91mzNC/rPO9Pct80+QV8hwSB8vR/+l1OhoZdml7iy1bfVUmjpyFe0mJdiQUQUVT1CifQA5xBMn+pdo/t+Nvlmbjd0uJ5yghH1DxbmfLAj3GFP8fm6dkWHk1qt9bmzr79nhBGWtmhGKh9QD1qv45et6kQr83gz+iS8absSmUWNnhm22MgffrhEKrfYKe8dmOoUzgQ5ptFgTlHA1vJsbXjMu2l3winhKjjHwB6qINKBSrp91qd3cUNw+DaeAC8A8eTiEDktfSTMe7JGf1zQBLZ1hgBkO7C24EycLBBoIJSwdMZW3ziLbK7OSzObaEHhPRJ/0ONZUUt4Mx0AmeOsIbuqQ6PhIpb9B9EE3MrfOcV+iv7xoObbM/gqpNTAtIi9yHLgEFDukrtYV5oW0J5kviahTpJ6qTAS+ky5uS7DS6tD3HTg5oAGxGSVn+C2xSDN8OTIthTp5QHPpwk8cXJtYi/9bpyjCNdh2MT5cISS2xIS1svaGKgwBseWBZShp+XRFZ+NgkS9/BpWbsX702C6kyR7xFCJtacDh96njZx0Xff9OWKDXI5z4tXrlDyYWdzMVmlEFXqfRAVggaSac10VBZft8/lcyHu7TwTEkAsoTVazwHa0w4+kiFmiYt/XQ8xAkwKYqG8gWqQ62hesaHipvf/d/JKz9RRy45ed8d7rcdpIbSRg09K 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)(376002)(346002)(396003)(136003)(39860400002)(46966006)(36840700001)(40470700004)(2906002)(5660300002)(26005)(82740400003)(4326008)(478600001)(54906003)(33964004)(40460700003)(70586007)(6916009)(86362001)(8676002)(36860700001)(36756003)(41300700001)(81166007)(40480700001)(70206006)(186003)(316002)(336012)(82310400005)(84970400001)(83380400001)(426003)(47076005)(2616005)(8936002)(235185007)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:41:56.9198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 103e4a80-cf46-4099-4ddb-08da7c793061 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: VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3199 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, T_SCC_BODY_TEXT_LINE, 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 Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740970623415455837?= X-GMAIL-MSGID: =?utf-8?q?1740970623415455837?= Hi all, this patch enables Branch Target Identification Armv8.1-M Mechanism [1]. This is achieved by using the bti pass made common with Aarch64. The pass iterates through the instructions and adds the necessary BTI instructions at the beginning of every function and at every landing pads targeted by indirect jumps. Best Regards Andrea [1] gcc/ChangeLog 2022-04-07 Andrea Corallo * config.gcc (arm*-*-*): Add 'aarch-bti-insert.o' object. * config/arm/arm-protos.h: Update. * config/arm/arm.cc (aarch_bti_enabled, aarch_bti_j_insn_p) (aarch_pac_insn_p, aarch_gen_bti_c, aarch_gen_bti_j): New functions. * config/arm/arm.md (bti_nop): New insn. * config/arm/t-arm (PASSES_EXTRA): Add 'arm-passes.def'. (aarch-bti-insert.o): New target. * config/arm/unspecs.md (UNSPEC_BTI_NOP): New unspec. * config/arm/aarch-bti-insert.cc (rest_of_insert_bti): Update to verify arch compatibility. * config/arm/arm-passes.def: New file. gcc/testsuite/ChangeLog 2022-04-07 Andrea Corallo * gcc.target/arm/bti-1.c: New testcase. * gcc.target/arm/bti-2.c: Likewise. diff --git a/gcc/config.gcc b/gcc/config.gcc index 2021bdf9d2f..004e1dfa8d8 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -353,7 +353,7 @@ arc*-*-*) ;; arm*-*-*) cpu_type=arm - extra_objs="arm-builtins.o arm-mve-builtins.o aarch-common.o" + extra_objs="arm-builtins.o arm-mve-builtins.o aarch-common.o aarch-bti-insert.o" extra_headers="mmintrin.h arm_neon.h arm_acle.h arm_fp16.h arm_cmse.h arm_bf16.h arm_mve_types.h arm_mve.h arm_cde.h" target_type_format_char='%' c_target_objs="arm-c.o" diff --git a/gcc/config/arm/aarch-bti-insert.cc b/gcc/config/arm/aarch-bti-insert.cc index 2d1d2e334a9..8f045c247bf 100644 --- a/gcc/config/arm/aarch-bti-insert.cc +++ b/gcc/config/arm/aarch-bti-insert.cc @@ -41,6 +41,7 @@ #include "cfgrtl.h" #include "tree-pass.h" #include "cgraph.h" +#include "diagnostic-core.h" /* This pass enables the support for Branch Target Identification Mechanism for Arm/AArch64. This is a security feature introduced in ARMv8.5-A diff --git a/gcc/config/arm/arm-passes.def b/gcc/config/arm/arm-passes.def new file mode 100644 index 00000000000..71d6b563640 --- /dev/null +++ b/gcc/config/arm/arm-passes.def @@ -0,0 +1,21 @@ +/* Arm-specific passes declarations. + Copyright (C) 2022 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 + . */ + +INSERT_PASS_BEFORE (pass_shorten_branches, 1, pass_insert_bti); diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 84764bf27ce..6befb6c4445 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -24,6 +24,8 @@ #include "sbitmap.h" +rtl_opt_pass *make_pass_insert_bti (gcc::context *ctxt); + extern enum unwind_info_type arm_except_unwind_info (struct gcc_options *); extern int use_return_insn (int, rtx); extern bool use_simple_return_p (void); diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 31c6bcdea55..de5a679c92a 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -23368,12 +23368,6 @@ output_probe_stack_range (rtx reg1, rtx reg2) return ""; } -static bool -aarch_bti_enabled () -{ - return false; -} - /* Generate the prologue instructions for entry into an ARM or Thumb-2 function. */ void @@ -32985,6 +32979,58 @@ arm_current_function_pac_enabled_p (void) && !crtl->is_leaf); } +/* Return TRUE if Branch Target Identification Mechanism is enabled. */ +bool +aarch_bti_enabled (void) +{ + return aarch_enable_bti == 1; +} + +/* Check if INSN is a BTI J insn. */ +bool +aarch_bti_j_insn_p (rtx_insn *insn) +{ + if (!insn || !INSN_P (insn)) + return false; + + rtx pat = PATTERN (insn); + return GET_CODE (pat) == UNSPEC_VOLATILE && XINT (pat, 1) == UNSPEC_BTI_NOP; +} + +/* Check if X (or any sub-rtx of X) is a PACIASP/PACIBSP instruction. */ +bool +aarch_pac_insn_p (rtx x) +{ + if (!x || !INSN_P (x)) + return false; + + rtx pat = PATTERN (x); + + if (GET_CODE (pat) == SET) + { + rtx tmp = XEXP (pat, 1); + if (tmp + && GET_CODE (tmp) == UNSPEC + && (XINT (tmp, 1) == UNSPEC_PAC_NOP + || XINT (tmp, 1) == UNSPEC_PACBTI_NOP)) + return true; + } + + return false; +} + +rtx +aarch_gen_bti_c (void) +{ + return gen_bti_nop (); +} + +rtx +aarch_gen_bti_j (void) +{ + return gen_bti_nop (); +} + /* Implement TARGET_SCHED_CAN_SPECULATE_INSN. Return true if INSN can be scheduled for speculative execution. Reject the long-running division and square-root instructions. */ diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 92269a7819a..90c8c1d66f5 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -12913,6 +12913,13 @@ "aut\t%|ip, %|lr, %|sp" [(set_attr "length" "4")]) +(define_insn "bti_nop" + [(unspec_volatile [(const_int 0)] UNSPEC_BTI_NOP)] + "arm_arch7 && arm_arch_cmse" + "bti" + [(set_attr "length" "4") + (set_attr "type" "mov_reg")]) + ;; Vector bits common to IWMMXT, Neon and MVE (include "vec-common.md") ;; Load the Intel Wireless Multimedia Extension patterns diff --git a/gcc/config/arm/t-arm b/gcc/config/arm/t-arm index 041cc6ec045..683342cb528 100644 --- a/gcc/config/arm/t-arm +++ b/gcc/config/arm/t-arm @@ -175,3 +175,13 @@ arm-d.o: $(srcdir)/config/arm/arm-d.cc arm-common.o: arm-cpu-cdata.h driver-arm.o: arm-native.h + +PASSES_EXTRA += $(srcdir)/config/arm/arm-passes.def + +aarch-bti-insert.o: $(srcdir)/config/arm/aarch-bti-insert.cc \ + $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(REGS_H) insn-config.h $(RTL_BASE_H) \ + dominance.h cfg.h cfganal.h $(BASIC_BLOCK_H) $(INSN_ATTR_H) $(RECOG_H) \ + output.h hash-map.h $(DF_H) $(OBSTACK_H) $(TARGET_H) $(RTL_H) \ + $(CONTEXT_H) $(TREE_PASS_H) regrename.h + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(srcdir)/config/arm/aarch-bti-insert.cc diff --git a/gcc/config/arm/unspecs.md b/gcc/config/arm/unspecs.md index dbe243a03f6..78e723a4b3c 100644 --- a/gcc/config/arm/unspecs.md +++ b/gcc/config/arm/unspecs.md @@ -162,6 +162,7 @@ UNSPEC_PAC_NOP ; Represents PAC signing LR UNSPEC_PACBTI_NOP ; Represents PAC signing LR + valid landing pad UNSPEC_AUT_NOP ; Represents PAC verifying LR + UNSPEC_BTI_NOP ; Represent BTI ]) diff --git a/gcc/testsuite/gcc.target/arm/bti-1.c b/gcc/testsuite/gcc.target/arm/bti-1.c new file mode 100644 index 00000000000..230ebb5a1da --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/bti-1.c @@ -0,0 +1,12 @@ +/* Check that GCC does bti instruction. */ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-options "-march=armv8.1-m.main -mthumb -mbranch-protection=bti --save-temps" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-final { scan-assembler "bti" } } */ diff --git a/gcc/testsuite/gcc.target/arm/bti-2.c b/gcc/testsuite/gcc.target/arm/bti-2.c new file mode 100644 index 00000000000..35aef6992e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/bti-2.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* -Os to create jump table. */ +/* { dg-options "-Os" } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-options "-march=armv8.1-m.main -mthumb -mbranch-protection=bti --save-temps" } */ + +extern int f1 (void); +extern int f2 (void); +extern int f3 (void); +extern int f4 (void); +extern int f5 (void); +extern int f6 (void); +extern int f7 (void); +extern int f8 (void); +extern int f9 (void); +extern int f10 (void); + +int (*ptr) (void); + +int +f_jump_table (int y, int n) +{ + int i; + for (i = 0; i < n ;i ++) + { + switch (y) + { + case 0 : ptr = f1; break; + case 1 : ptr = f2; break; + case 2 : ptr = f3; break; + case 3 : ptr = f4; break; + case 4 : ptr = f5; break; + case 5 : ptr = f6; break; + case 6 : ptr = f7; break; + case 7 : ptr = f8; break; + case 8 : ptr = f9; break; + case 9 : ptr = f10; break; + default: break; + } + y += ptr (); + } + return (y == 0)? y+1:4; +} + +int +f_label_address () +{ + static void * addr = &&lab1; + goto *addr; +lab1: + addr = &&lab2; + return 1; +lab2: + addr = &&lab1; + return 2; +} + +/* { dg-final { scan-assembler-times "bti" 15 } } */