From patchwork Fri Jan 20 17:27:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Parvathaneni X-Patchwork-Id: 46536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp328388wrn; Fri, 20 Jan 2023 09:28:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwwW0pUJUApM14bAdU+AwLoFA3NAYkwCjy8/4ZbKsm3Co874rpJDbCgDG2seikUrxLA3i9 X-Received: by 2002:a05:6402:5024:b0:49d:1c3a:b5fb with SMTP id p36-20020a056402502400b0049d1c3ab5fbmr17472900eda.28.1674235721657; Fri, 20 Jan 2023 09:28:41 -0800 (PST) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v19-20020a056402349300b0049e18f00785si19254279edc.24.2023.01.20.09.28.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 09:28:41 -0800 (PST) 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=DwTEhLMy; 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 2677C385B511 for ; Fri, 20 Jan 2023 17:28:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2677C385B511 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674235704; bh=3sjTuSCbr1zSQl//4rq2PuyXoRzRbi3x6WL3KCrKG1M=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=DwTEhLMytSnoxuKmyWIUF+9bpC1CDIg75w05YyNUpzR6xM3XYWwSZOSV89haN7U2S j2IoiIP/QZYQ/Qm0AiC7CNKBhHu+oPSdHXu/X2tyZ9Am+qTrypRJuA3dGe53pBsC0p yvU/rf4r5VcRhh3FFhXCwD3NMKowR2EVEIOvE72M= 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-vi1eur05on2066.outbound.protection.outlook.com [40.107.21.66]) by sourceware.org (Postfix) with ESMTPS id 622323858407 for ; Fri, 20 Jan 2023 17:27:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 622323858407 Received: from DB3PR06CA0015.eurprd06.prod.outlook.com (2603:10a6:8:1::28) by AS4PR08MB8094.eurprd08.prod.outlook.com (2603:10a6:20b:589::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27; Fri, 20 Jan 2023 17:27:33 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:8:1:cafe::5c) by DB3PR06CA0015.outlook.office365.com (2603:10a6:8:1::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.25 via Frontend Transport; Fri, 20 Jan 2023 17:27:33 +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 DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Fri, 20 Jan 2023 17:27:33 +0000 Received: ("Tessian outbound 43b0faad5a68:v132"); Fri, 20 Jan 2023 17:27:33 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 364ff605c23c3ead X-CR-MTA-TID: 64aa7808 Received: from 2e85245a0cd4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 98347402-8D23-4606-B909-C6AFAE16A7F5.1; Fri, 20 Jan 2023 17:27:26 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2e85245a0cd4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 20 Jan 2023 17:27:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J0EqOlplfn/q60OZdpw9QsQmQzODQryYnS3rNHnGkGd4h+v4LW+KGqTeCn6MKfI+2zcr2+jKNVNhURqf1TIzv+GMAUmOlPoZ8AkagYys4lbM9LNnol48opKvdfheMZx+U1jYBqgXPO5+ecfiEPTGJG7TySwO6WVvCTP+1K4WbrPyr8czQ62DUqZok+u0Db4iFvwMzVlU1Vz31IeTlDcS77Dy8tAyQ+MFDiAgfr+CV24U3NbA17irgNEJGe3+9y3oP3u9O69bY/chaKv9+DhGjtsdVwxnIBElQ7NeyjMBdmvU1wGpKGe9PJyPp44jw1xruBTOwwXMFNOV7uTuxL92Rw== 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=3sjTuSCbr1zSQl//4rq2PuyXoRzRbi3x6WL3KCrKG1M=; b=M5btRp2aJZKpt+TahEiTtbPG/WJbkTU8v5LGemxKfvXcs5rl4Ie+BmZ9sehWt/b+1EX6MFYm5aRt0qN2rJcP4/V5M+x8hkGqWJkop/IxRVoCJZy4DqjNfcjU3utmW+JaCDM/4WKO7wDzhd4/5oZe4e/tHspKRl3LCEuWsJn1d2dHDx/VIQAJ2OtW7uCsmUFhKwIB4Vf3LTfvTzVadmy9J/zgQ0GEtYRsaoEuypIp05lmB2b3JO36yx4bCw1hIpNGil9i8L2yWgb6vl4XBFEDDJVs0oWjXKLtv7be1jMfErOlgNyQKEuwAMxEtjujl2INN3B48ny7RYRrt7+U3BL1uA== 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 DUZPR01CA0222.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b4::29) by AS8PR08MB9573.eurprd08.prod.outlook.com (2603:10a6:20b:61b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27; Fri, 20 Jan 2023 17:27:25 +0000 Received: from DBAEUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b4:cafe::74) by DUZPR01CA0222.outlook.office365.com (2603:10a6:10:4b4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27 via Frontend Transport; Fri, 20 Jan 2023 17:27:25 +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 DBAEUR03FT051.mail.protection.outlook.com (100.127.142.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Fri, 20 Jan 2023 17:27:25 +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.16; Fri, 20 Jan 2023 17:27:24 +0000 Received: from e120703.arm.com (10.2.81.20) 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.16 via Frontend Transport; Fri, 20 Jan 2023 17:27:24 +0000 MIME-Version: 1.0 To: CC: , , Subject: [PATCH v2][GCC] arm: Add support for new frame unwinding instruction "0xb5". Date: Fri, 20 Jan 2023 17:27:24 +0000 Message-ID: <1202edce-cd9c-45a2-a47c-7145bfdebae4@AZ-NEU-EX04.Arm.com> X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT051:EE_|AS8PR08MB9573:EE_|DBAEUR03FT037:EE_|AS4PR08MB8094:EE_ X-MS-Office365-Filtering-Correlation-Id: fd6e57a6-d38a-453a-a745-08dafb0b9d82 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: yoLabnjGZr3nAnJMGvcSGrk7dJCKQqx3VlNzYx2zk9r72Ye5HzzcaeYaUujh1BAAJw6ylcgj7crr40wIk3bw32Zr2EddPp8R7a2fkGTHkiveZEIh+AcPZlojoadV51VGwLmPHTGsYol2E7GrJj1t3IOhSMFusJNtNegoobea3OKDNfddkg66g4Rhf97m4Tgwf0/nyS8/Yd9GkmIcHaNoZl+7umKTYn81ceRI8dPR8Ziz1FRZ6jwhZrsjqtWe2uE4SmjCA/roFQgkshKeV48qq6mW8fzdtD3WZXrf3d6q1aY3TQ7uVKZINuAxhfppqsCRAZuNciQnS0PhAZN4wdQggymTJFZeiE20NQGFVwxdJLLbUONCKy1247Wf9/J2jxHEknimY0nkEs601J4TFMCfxnEzSL8N1XLLUUqjOS4OohjlhNqeVezLuW9FGNwWs0isLfpG/KBgEVWjasgGtSnfxrnI7pNYHrpphMob44eJtk/A1Q7VrmPEr6gT5xwJAn8u02FOztMHwIL7as/fLF3nZKvp8vGXF5KPM8J0PU5pbSMoT3ICivrO7RO/26lcKHhcGLH0IMlyqIlHJ8qSBQJJLGGykYUUL9SQFEuC3hmm9yHMGkTH8htvddtJbR1ADN+XYobz+AhYW4OChffyRx0tTXyYxbmaC0u2nlKyJFFcfc1mEcJf4I9fyLDcHLCABac8//oq34/uHoQcCLwo6brZClb0ZcSzGSvJmIttYHIjU5FPP1qikYLed3EhdF6wwm/WTkJZvEaJ/USyjpdXU/ZzuQ== 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:(13230022)(4636009)(396003)(136003)(376002)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(40460700003)(86362001)(31696002)(316002)(336012)(47076005)(426003)(54906003)(82310400005)(83380400001)(966005)(478600001)(33964004)(186003)(26005)(8936002)(82740400003)(356005)(2906002)(40480700001)(5660300002)(4326008)(81166007)(8676002)(235185007)(44832011)(6916009)(36860700001)(70206006)(70586007)(41300700001)(31686004)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9573 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0f14a434-05e1-4447-86e4-08dafb0b98c2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EDMLKEKyD9mzb8OI4s3qXyuOIu0owWGTtW7gFGpzvRJkX/n4T8pVXbKLNyZVI1TQh9pojzH8eJ067KR5F/nX0+YaCeZ1+HDsL5UCutX61nYM/GAGQQ4+TO6BHtTWPhvIX8IdM2DPj5tYe+o4VgJrhaFbIw6LUizLqOdiuW/p1B7UOQ1cvFeg1+feShu8LwTx8ZV1KZz1me8wXawIdHq3L+3pRpFrMwjBy77+JKk4LMiIo3Jl7MeUug3+tKaU36WUXap0Zjv9ejwjtlo3eJNStlHo+YVgQ/ZMlSvXk8Grpjs3uWk6H52tiilgaHKxb9kIYAi/pxvM1F6YW3ami1YTjbPfbNE9Pi9XRInJvWaSuKydbVl/x3Q86n3vvLEAJEnGdFA/8uFCqB70sqhA4WYkeq1/4d34WDC70qMKX7V0RAXhcgfi8Wi/eqmRDnJsI68enspgOqE3h/OXbo/gEzNCJvDJazvblRhq/dp6Mo/xDXz5b9gOexj+/q6n1/zJa1QXJMeYyZIyAN7/BTp9ASIAM+NxAwh721FBaipyChYae+ygRrbayxXnNu6kkNtKx758fcmfvvoIQQxQocOCtiXIv0YM8b0zimwwOaJgDjEnJhxjbjKnP/1BZmkoZkqiil052416WOhhTHY3LSGTyej3Ptw2K6VrVBPiTVh3ly0CKChIqsDsE8ir8dnviKcVy2b3QOmHLj1bWNe0eN+KsCuuFA/YLJPoGN6YZExYosSqVmM= 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:(13230022)(4636009)(39860400002)(346002)(376002)(136003)(396003)(451199015)(40470700004)(36840700001)(46966006)(31686004)(426003)(83380400001)(31696002)(86362001)(336012)(54906003)(6916009)(40460700003)(81166007)(44832011)(70206006)(70586007)(8676002)(4326008)(40480700001)(2906002)(41300700001)(36860700001)(8936002)(478600001)(82310400005)(316002)(966005)(47076005)(5660300002)(235185007)(82740400003)(186003)(26005)(33964004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2023 17:27:33.2143 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd6e57a6-d38a-453a-a745-08dafb0b9d82 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: DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8094 X-Spam-Status: No, score=-12.9 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 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: Srinath Parvathaneni via Gcc-patches From: Srinath Parvathaneni Reply-To: Srinath Parvathaneni 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?1749105233390697901?= X-GMAIL-MSGID: =?utf-8?q?1755563396074664777?= Hi, This patch adds support for Arm frame unwinding instruction "0xb5" [1]. When an exception is taken and "0xb5" instruction is encounter during runtime stack-unwinding, we use effective vsp as modifier in pointer authentication. On completion of stack unwinding if "0xb5" instruction is not encountered then CFA will be used as modifier in pointer authentication. [1] https://github.com/ARM-software/abi-aa/releases/download/2022Q3/ehabi32.pdf Regression tested on arm-none-eabi target and found no regressions. Ok for master? Regards, Srinath. gcc/ChangeLog: 2022-11-09 Srinath Parvathaneni * libgcc/config/arm/pr-support.c (__gnu_unwind_execute): Decode opcode "0xb5". ############### Attachment also inlined for ease of reply ############### diff --git a/libgcc/config/arm/pr-support.c b/libgcc/config/arm/pr-support.c index e48854587c667a959aa66ccc4982231f63333ecc..1fbc41e17c227c21af1937344ded2a7fd80e61df 100644 --- a/libgcc/config/arm/pr-support.c +++ b/libgcc/config/arm/pr-support.c @@ -107,7 +107,9 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) _uw op; int set_pc; int set_pac = 0; + int set_pac_sp = 0; _uw reg; + _uw sp; set_pc = 0; for (;;) @@ -124,10 +126,11 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) #if defined(TARGET_HAVE_PACBTI) if (set_pac) { - _uw sp; _uw lr; _uw pac; - _Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp); + if (!set_pac_sp) + _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); @@ -259,6 +262,14 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) continue; } + /* Use current VSP as modifier in PAC validation. */ + if (op == 0xb5) + { + _Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp); + set_pac_sp = 1; + continue; + } + if ((op & 0xfc) == 0xb4) /* Obsolete FPA. */ return _URC_FAILURE; diff --git a/libgcc/config/arm/pr-support.c b/libgcc/config/arm/pr-support.c index e48854587c667a959aa66ccc4982231f63333ecc..1fbc41e17c227c21af1937344ded2a7fd80e61df 100644 --- a/libgcc/config/arm/pr-support.c +++ b/libgcc/config/arm/pr-support.c @@ -107,7 +107,9 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) _uw op; int set_pc; int set_pac = 0; + int set_pac_sp = 0; _uw reg; + _uw sp; set_pc = 0; for (;;) @@ -124,10 +126,11 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) #if defined(TARGET_HAVE_PACBTI) if (set_pac) { - _uw sp; _uw lr; _uw pac; - _Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp); + if (!set_pac_sp) + _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); @@ -259,6 +262,14 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) continue; } + /* Use current VSP as modifier in PAC validation. */ + if (op == 0xb5) + { + _Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp); + set_pac_sp = 1; + continue; + } + if ((op & 0xfc) == 0xb4) /* Obsolete FPA. */ return _URC_FAILURE;