From patchwork Fri Jun 30 13:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 71919 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 5FA6B3882AC7 for ; Fri, 30 Jun 2023 13:51:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FA6B3882AC7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688133062; bh=BLSNFbMo/FDpmVtL80bWt83pzdICO9vtdVS9G2zBZlA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vo4ad1udR1SoeaHMB06LMO00hDLiBEM0ep6ZtVRi57vlZ1EbnRYoYRQNAPw8Maxe4 yDwAEcWKSDjE1NoVaelC9OY5Zl1GH6XxXV+hsvV8DV59U3e8DOZCKnR5aGKhtYo2QY TsN7czuOS1MOzC02KGJSLR9Zn5KlZ9wLFy5W/dqk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2040.outbound.protection.outlook.com [40.107.20.40]) by sourceware.org (Postfix) with ESMTPS id 4EF923883019 for ; Fri, 30 Jun 2023 13:49:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4EF923883019 Received: from DU2PR04CA0177.eurprd04.prod.outlook.com (2603:10a6:10:2b0::32) by AS2PR08MB10295.eurprd08.prod.outlook.com (2603:10a6:20b:647::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:49:03 +0000 Received: from DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b0:cafe::91) by DU2PR04CA0177.outlook.office365.com (2603:10a6:10:2b0::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:03 +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 DBAEUR03FT015.mail.protection.outlook.com (100.127.142.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.13 via Frontend Transport; Fri, 30 Jun 2023 13:49:03 +0000 Received: ("Tessian outbound 52217515e112:v142"); Fri, 30 Jun 2023 13:49:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 04b0f2e5b6ddde89 X-CR-MTA-TID: 64aa7808 Received: from cb7ea1b77fbf.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FCA69A6C-DD6C-4C51-AA47-CFAF4EDA4342.1; Fri, 30 Jun 2023 13:48:56 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cb7ea1b77fbf.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:48:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GCD99+pDxu+9xpj729vvh/EloHpvow73gOA3tyQIg6+Kd3PSDJBbFd6oQT6KxW5v/hUkiQpxVHLWYtJy5IOfyBBxO17LE1GAWXABAeqCyAVoXHgXf622VYgGMvIJmLuPjlM5x1V+gqV3MbudgvrEfn7weg9TI8dDroUD9mCT3Z5U/CAMED3gp9+N+27/hHSlExWdMpkLnfrXliNCw1FM8CHc+jQ3357hn1CqFtbr7fiU1wztkSYtNOxuHg0uKuJyvT1aAPIqm5Lg9OJvo6ab9WWHcWJU8hn2fbgds49lRmOhE4U9GnPhxWPTzqGtM+gQpGvX7sjBlmgM1oMuLdZGOw== 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=BLSNFbMo/FDpmVtL80bWt83pzdICO9vtdVS9G2zBZlA=; b=ns0+HWRCEGk9u/vnyynrRnJyw4uH+bepTK6tsn4xhScT1HOQquidHtJc++iqyNlPnzFNMZfKtTcuTNhJ1Q64eSMCXXZevPokTXTb+nW7ZQxNSFLC8xBsXWrlofsl77sy+sUQGZPDbRzwpHG+Tn0nqMi2OveN+aFOT+RTq5xpcKRyKxAKejp3wEC7XHTD8qbOH1+ZhaXxUhzs/KOJMjkqe8xv0u7V7ZNhJeXph5/u0Mv3TteVb1+hruSkF0ekmZiQ3Qp5BSa67bOy83BYFrto1UzRwcuxeecDr9+TAa4+ZEl2orPNWGlri8ELLJ4Nl3kS34a9o29LVCkosIy4m04wOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.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 DB6PR0301CA0083.eurprd03.prod.outlook.com (2603:10a6:6:30::30) by DU0PR08MB9345.eurprd08.prod.outlook.com (2603:10a6:10:41d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:48:53 +0000 Received: from DBAEUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::d3) by DB6PR0301CA0083.outlook.office365.com (2603:10a6:6:30::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +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 DBAEUR03FT029.mail.protection.outlook.com (100.127.142.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.27; Fri, 30 Jun 2023 13:48:53 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:48:52 +0000 To: Subject: [PATCH 1/6] [gdb/aarch64] sme2: Enable SME2 for AArch64 gdb on Linux Date: Fri, 30 Jun 2023 14:48:39 +0100 Message-ID: <20230630134844.1238445-2-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134844.1238445-1-luis.machado@arm.com> References: <20230630134844.1238445-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT029:EE_|DU0PR08MB9345:EE_|DBAEUR03FT015:EE_|AS2PR08MB10295:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c05bc02-eb7d-43f0-861f-08db7970c421 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: eCEqe8IDZdhVncOCHXqlrLIwK5dtcGU+dDxDpjTSO/r4SCGvrfxrvGVXxKPlwxKYf/Ln/BraoCj1eX0hcZGKbmkwA2YBP4NJ5JTYHjLHCKm5cUqjeckYj3a1ZseGOs2LUE5CuDxJHmYzxIOUZSAfuyZYamq/ySoAqcv7KIe9V4zkXBqOoowtasZRF5Q2FDhgn7dJrEAjdCbQzRlOjtey2S9BGFMGZnC6qZ8gd7A/HeizCrzk4N0nAEXagN6hHmsGs1hqm65qr3N0SvReRgPs6JSzgWL/tsM3vfX0lwEFEhgTdxo76CamnLhuv5HNiDcRuCRnbnyDbaINoT73FB1KGo5Ri/SSTCELbEjm0mskSwEsEERTeQNL9IJgkX8PGEOSHF/EUCsakBzPEX61nHoGkewju3qs2BnRhVWz2mPWXKgLmFpLaDPrx8uvY7oER+0zWOW26EuqxrHCiGEFi0t7uE9s4b8CggvYYV3KVMNbdLpHGqCy/GCTQJ6a4tiYUdLQzBXeMTp7d6xBWIezxM6et1D+UUg0aoQDshANCi94bscgxMgOadSqvm9CXReofZnqbGiRFZruSlEsdw6NG+tBRRGxvljo6uR/9DNLVsDglrxKvrsG9zI9WOeJTKK3KJNaKw+taPhYPMFO0njd/j7yvxJEOTCZpY/T60G6T0yRMXk3vgnhGyd99NNM7EhxOEaV9CU6kLyJ0Xp/FMMNJjO8jbi0RJiODfgExztUi2RhiPfkCssyRhc0hHcdPZnYhuqx9BTUkpcvx+BvC6kEeLn+Jw== 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:(13230028)(4636009)(39860400002)(376002)(396003)(136003)(346002)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(1076003)(26005)(2906002)(186003)(83380400001)(30864003)(86362001)(6666004)(82740400003)(8936002)(36756003)(8676002)(316002)(6916009)(478600001)(47076005)(2616005)(426003)(81166007)(336012)(7696005)(356005)(44832011)(70206006)(70586007)(41300700001)(40460700003)(5660300002)(40480700001)(36860700001)(2004002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9345 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c7ff794f-109f-4da5-7f35-08db7970be05 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lUyhakQ6IWhcww7YhxDkDvF6H3UAElwJUY+MEFjZ7AiMZPd4G8n4YiaQAZpBtNmpkZBZA0qKK2YiMiWBaeoqjrVlt93F2nIKejG3tk4Ez/AEHZTDLcuPy77/O4+SUfC2ktSLquJ5q5v4u+zhnuZniD2p4aUByvrp7ZUV9nRVeTW8Qbpze6+3XFDU4GSVokQbaxsjm5L11Nys+KIHzpamHp8u9rA/z49wLd8fopGYXwdqDmLFXhLhXO2bp+dzhnhuFBO/VI9Cy3rqjWTnqGG2d0eai/Wi27i3rA02j9PHmHh3a9F1g9NRjGz+eEXZCJDk7LERRNjfRA6tNIjz/2h8Ny2Md/A1ePz9+AERIZc0RgUDDV6y9aw0jc9h8oL3MIIpfRVStPbA7cW1sMUuN3CRWK4SHxX3YBAemcg4M20j2BMzB7fbZh14zfSGGDWZDKXphfzKl9RpjxrFzKLL925RiSNhaqg9SR4EiqxNtslbL2QdO1eWUs80g+5lCs6jyyjeda7q79aPbWsz3WxsAF+7uB+rvBGa9B4laVBawSvZCkiEHkBbD5qdNQN27rxWcrkNbrg/ElRkGNrwbY5LvibMHHegdvdhecAVMHBnTwd7H0EFsCEBW8rILKgKftIEK8irUqpbETzAYK8/jnOEkbm1EV3kGDitWDvj4sdCHhZHW3bm/aRjbwd5o1D1enpzt4CyIaKewlaHhrKB6uE2X/lUXlxzWIghz5u4oW1hQnOa/UwvsUcACf9Sg3Lc5BDGROqm 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:(13230028)(4636009)(346002)(396003)(136003)(39860400002)(376002)(451199021)(36840700001)(46966006)(40470700004)(2616005)(81166007)(82740400003)(186003)(1076003)(83380400001)(40480700001)(36860700001)(47076005)(426003)(26005)(336012)(44832011)(30864003)(41300700001)(5660300002)(8936002)(8676002)(2906002)(36756003)(7696005)(316002)(70206006)(86362001)(6666004)(70586007)(478600001)(6916009)(40460700003)(82310400005)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:49:03.6730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c05bc02-eb7d-43f0-861f-08db7970c421 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: DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10295 X-Spam-Status: No, score=-11.8 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" SME2 defines a new 512-bit register named ZT0, and it is only available if SME is also supported. The ZT0 state is valid only if the SVCR ZA bit is enabled. Otherwise its contents are empty (0). The target description is dynamic and gets generated at runtime based on the availability of the feature. Validated under Fast Models. --- gdb/aarch64-linux-nat.c | 49 +++++++++ gdb/aarch64-tdep.c | 21 ++++ gdb/aarch64-tdep.h | 10 ++ gdb/arch/aarch64-scalable-linux.h | 6 ++ gdb/arch/aarch64.c | 4 + gdb/arch/aarch64.h | 12 ++- gdb/features/aarch64-sme2.c | 43 ++++++++ gdb/nat/aarch64-scalable-linux-ptrace.c | 136 ++++++++++++++++++++++++ gdb/nat/aarch64-scalable-linux-ptrace.h | 27 +++++ 9 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 gdb/features/aarch64-sme2.c diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index cb97b205c86..86b93c23e8b 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -376,6 +376,37 @@ store_za_to_thread (struct regcache *regcache) tdep->sme_svcr_regnum); } +/* Fill GDB's REGCACHE with the ZT register set contents from the + current thread. If there is no active ZA register state, make the + ZT register contents zero. */ + +static void +fetch_zt_from_thread (struct regcache *regcache) +{ + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Read ZT state from the thread to the register cache. */ + aarch64_zt_regs_copy_to_reg_buf (regcache->ptid ().lwp (), + regcache, + tdep->sme2_zt0_regnum); +} + +/* Store the NT_ARM_ZT register set contents from GDB's REGCACHE to the current + thread. */ + +static void +store_zt_to_thread (struct regcache *regcache) +{ + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Write ZT state from the register cache to the thread. */ + aarch64_zt_regs_copy_from_reg_buf (regcache->ptid ().lwp (), + regcache, + tdep->sme2_zt0_regnum); +} + /* Fill GDB's register array with the pointer authentication mask values from the current thread. */ @@ -549,6 +580,9 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) if (tdep->has_sme ()) fetch_za_from_thread (regcache); + + if (tdep->has_sme2 ()) + fetch_zt_from_thread (regcache); } /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) @@ -569,6 +603,9 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) else if (tdep->has_sme () && regno >= tdep->sme_reg_base && regno < tdep->sme_reg_base + 3) fetch_za_from_thread (regcache); + /* SME2 register? */ + else if (tdep->has_sme2 () && regno == tdep->sme2_zt0_regnum) + fetch_zt_from_thread (regcache); /* MTE register? */ else if (tdep->has_mte () && (regno == tdep->mte_reg_base)) @@ -646,6 +683,9 @@ aarch64_store_registers (struct regcache *regcache, int regno) if (tdep->has_sme ()) store_za_to_thread (regcache); + + if (tdep->has_sme2 ()) + store_zt_to_thread (regcache); } /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) @@ -661,6 +701,8 @@ aarch64_store_registers (struct regcache *regcache, int regno) else if (tdep->has_sme () && regno >= tdep->sme_reg_base && regno < tdep->sme_reg_base + 3) store_za_to_thread (regcache); + else if (tdep->has_sme2 () && regno == tdep->sme2_zt0_regnum) + store_zt_to_thread (regcache); /* MTE register? */ else if (tdep->has_mte () && (regno == tdep->mte_reg_base)) @@ -858,6 +900,10 @@ aarch64_linux_nat_target::read_description () /* SME feature check. */ features.svq = aarch64_za_get_svq (tid); + /* Check for SME2 support. */ + if ((hwcap2 & HWCAP2_SME2) || (hwcap2 & HWCAP2_SME2P1)) + features.sme2 = supports_zt_registers (tid); + return aarch64_read_description (features); } @@ -981,6 +1027,9 @@ aarch64_linux_nat_target::thread_architecture (ptid_t ptid) possible. */ features.svq = (uint8_t) svq; + /* Check for the SME2 feature. */ + features.sme2 = supports_zt_registers (ptid.lwp ()); + struct gdbarch_info info; info.bfd_arch_info = bfd_lookup_arch (bfd_arch_aarch64, bfd_mach_aarch64); info.target_desc = aarch64_read_description (features); diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 64cbcc12282..5b912fd6dff 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -4048,6 +4048,10 @@ aarch64_features_from_target_desc (const struct target_desc *tdesc) features.svq = aarch64_get_tdesc_svq (tdesc); + /* Check for the SME2 feature. */ + features.sme2 = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme2") + != nullptr); + return features; } @@ -4310,6 +4314,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } int first_sme_regnum = -1; + int first_sme2_regnum = -1; int first_sme_pseudo_regnum = -1; const struct tdesc_feature *feature_sme = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme"); @@ -4336,6 +4341,19 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Add the ZA tile pseudo registers. */ num_pseudo_regs += AARCH64_ZA_TILES_NUM; + + /* Now check for the SME2 feature. SME2 is only available if SME is + available. */ + const struct tdesc_feature *feature_sme2 + = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme2"); + if (feature_sme2 != nullptr) + { + /* Record the first SME2 register. */ + first_sme2_regnum = num_regs; + + valid_p &= tdesc_numbered_register (feature_sme2, tdesc_data.get (), + num_regs++, "zt0"); + } } /* Add the TLS register. */ @@ -4459,6 +4477,9 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->sme_za_regnum = first_sme_regnum + 2; tdep->sme_svq = svq; + /* Set the SME2 register set details. */ + tdep->sme2_zt0_regnum = first_sme2_regnum; + set_gdbarch_push_dummy_call (gdbarch, aarch64_push_dummy_call); set_gdbarch_frame_align (gdbarch, aarch64_frame_align); diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h index 9297487a584..9e4d1a59734 100644 --- a/gdb/aarch64-tdep.h +++ b/gdb/aarch64-tdep.h @@ -172,6 +172,16 @@ struct aarch64_gdbarch_tdep : gdbarch_tdep_base { return sme_svq != 0; } + + /* Index of the SME2 ZT0 register. This is -1 if SME2 is not + supported. */ + int sme2_zt0_regnum = -1; + + /* Return true if the target supports SME2, and false otherwise. */ + bool has_sme2 () const + { + return sme2_zt0_regnum > 0; + } }; const target_desc *aarch64_read_description (const aarch64_features &features); diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h index cb9d85a9d5d..0f59ddb40b2 100644 --- a/gdb/arch/aarch64-scalable-linux.h +++ b/gdb/arch/aarch64-scalable-linux.h @@ -29,6 +29,12 @@ #define HWCAP2_SME (1 << 23) #endif +/* Feature check for Scalable Matrix Extension 2. */ +#ifndef HWCAP2_SME2 +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#endif + /* Streaming mode enabled/disabled bit. */ #define SVCR_SM_BIT (1 << 0) /* ZA enabled/disabled bit. */ diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c index e1f4948aa25..c93d602c66c 100644 --- a/gdb/arch/aarch64.c +++ b/gdb/arch/aarch64.c @@ -25,6 +25,7 @@ #include "../features/aarch64-pauth.c" #include "../features/aarch64-mte.c" #include "../features/aarch64-sme.c" +#include "../features/aarch64-sme2.c" #include "../features/aarch64-tls.c" /* See arch/aarch64.h. */ @@ -62,6 +63,9 @@ aarch64_create_target_description (const aarch64_features &features) regnum = create_feature_aarch64_sme (tdesc.get (), regnum, sve_vl_from_vq (features.svq)); + if (features.sme2) + regnum = create_feature_aarch64_sme2 (tdesc.get (), regnum); + return tdesc.release (); } diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h index c1cd233c51e..65c6205115e 100644 --- a/gdb/arch/aarch64.h +++ b/gdb/arch/aarch64.h @@ -48,6 +48,9 @@ struct aarch64_features These use at most 5 bits to represent. */ uint8_t svq = 0; + + /* Whether SME2 is supported. */ + bool sme2 = false; }; inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs) @@ -56,7 +59,8 @@ inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs) && lhs.pauth == rhs.pauth && lhs.mte == rhs.mte && lhs.tls == rhs.tls - && lhs.svq == rhs.svq; + && lhs.svq == rhs.svq + && lhs.sme2 == rhs.sme2; } namespace std @@ -79,6 +83,9 @@ namespace std gdb_assert (features.svq >= 0); gdb_assert (features.svq <= 16); h = h << 5 | (features.svq & 0x5); + + /* SME2 feature. */ + h = h << 1 | features.sme2; return h; } }; @@ -220,4 +227,7 @@ enum aarch64_regnum #define AARCH64_SME_MIN_SVL 128 #define AARCH64_SME_MAX_SVL 2048 +/* Size of the SME2 ZT0 register in bytes. */ +#define AARCH64_SME2_ZT0_SIZE 64 + #endif /* ARCH_AARCH64_H */ diff --git a/gdb/features/aarch64-sme2.c b/gdb/features/aarch64-sme2.c new file mode 100644 index 00000000000..a14b98fae9d --- /dev/null +++ b/gdb/features/aarch64-sme2.c @@ -0,0 +1,43 @@ +/* Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GDB. + + This program 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 of the License, or + (at your option) any later version. + + This program 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 this program. If not, see . */ + +#include "gdbsupport/tdesc.h" + +/* This function is NOT auto generated from xml. Create the AArch64 SME2 + feature into RESULT. + + The ZT0 register is only available when the SME ZA register is + available. */ + +static int +create_feature_aarch64_sme2 (struct target_desc *result, long regnum) +{ + struct tdesc_feature *feature; + tdesc_type *element_type; + + feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.sme2"); + + /* Byte type. */ + element_type = tdesc_named_type (feature, "uint8"); + + /* Vector of 64 bytes. */ + element_type = tdesc_create_vector (feature, "sme2_bv", element_type, 64); + + /* The following is the ZT0 register, with 512 bits (64 bytes). */ + tdesc_create_reg (feature, "zt0", regnum++, 1, nullptr, 512, "sme2_bv"); + return regnum; +} diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c index 4c78d788e1a..1e3dffe2e9c 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.c +++ b/gdb/nat/aarch64-scalable-linux-ptrace.c @@ -521,10 +521,77 @@ aarch64_initialize_za_regset (int tid) if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_ZA, &iovec) < 0) perror_with_name (_("Failed to initialize the NT_ARM_ZA register set.")); + if (supports_zt_registers (tid)) + { + /* If this target supports SME2, upon initializing ZA, we also need to + initialize the ZT registers with 0 values. Do so now. */ + gdb::byte_vector zt_new_state (AARCH64_SME2_ZT0_SIZE, 0); + aarch64_store_zt_regset (tid, zt_new_state); + } + /* The NT_ARM_ZA register set should now contain a zero-initialized ZA payload. */ } +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +gdb::byte_vector +aarch64_fetch_zt_regset (int tid) +{ + /* Read NT_ARM_ZT. This register set is only available if + the ZA bit is non-zero. */ + gdb::byte_vector zt_state (AARCH64_SME2_ZT0_SIZE); + + struct iovec iovec; + iovec.iov_len = AARCH64_SME2_ZT0_SIZE; + iovec.iov_base = zt_state.data (); + + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_ZT, &iovec) < 0) + perror_with_name (_("Failed to fetch NT_ARM_ZT register set.")); + + return zt_state; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +aarch64_store_zt_regset (int tid, const gdb::byte_vector &zt_state) +{ + gdb_assert (zt_state.size () == AARCH64_SME2_ZT0_SIZE + || zt_state.size () == 0); + + /* We need to be mindful of writing data to NT_ARM_ZT. If the ZA bit + is 0 and we write something to ZT, it will flip the ZA bit. + + Right now this is taken care of by callers of this function. */ + struct iovec iovec; + iovec.iov_len = zt_state.size (); + iovec.iov_base = (void *) zt_state.data (); + + /* Write the contents of ZT_STATE to the NT_ARM_ZT register set. */ + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_ZT, &iovec) < 0) + perror_with_name (_("Failed to write to the NT_ARM_ZT register set.")); + + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +supports_zt_registers (int tid) +{ + gdb_byte zt_state[AARCH64_SME2_ZT0_SIZE]; + + struct iovec iovec; + iovec.iov_len = AARCH64_SME2_ZT0_SIZE; + iovec.iov_base = (void *) zt_state; + + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_ZT, &iovec) < 0) + return false; + + return true; +} + /* If we are running in BE mode, byteswap the contents of SRC to DST for SIZE bytes. Other, just copy the contents from SRC to DST. */ @@ -991,3 +1058,72 @@ aarch64_za_regs_copy_from_reg_buf (int tid, /* At this point we have written the data contained in the register cache to the thread's NT_ARM_ZA register set. */ } + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +void +aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf, + int zt_regnum) +{ + /* If we have ZA state, read the ZT state. Otherwise, make the contents of + ZT in the register cache all zeroes. This is how we present the ZT + state when it is not initialized (ZA not active). */ + if (aarch64_has_za_state (tid)) + { + /* Fetch the current ZT state from the thread. */ + gdb::byte_vector zt_state = aarch64_fetch_zt_regset (tid); + + /* Sanity check. */ + gdb_assert (!zt_state.empty ()); + + /* Copy the ZT data to the register buffer. */ + reg_buf->raw_supply (zt_regnum, zt_state.data ()); + } + else + { + /* Zero out ZT. */ + gdb::byte_vector zt_zeroed (AARCH64_SME2_ZT0_SIZE, 0); + reg_buf->raw_supply (zt_regnum, zt_zeroed.data ()); + } + + /* The register buffer should now contain the updated copy of the NT_ARM_ZT + state. */ +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +void +aarch64_zt_regs_copy_from_reg_buf (int tid, + struct reg_buffer_common *reg_buf, + int zt_regnum) +{ + /* Do we have a valid ZA state? */ + bool valid_za = aarch64_has_za_state (tid); + + /* Is the register buffer contents for ZT all zeroes? */ + gdb::byte_vector zt_bytes (AARCH64_SME2_ZT0_SIZE, 0); + bool zt_is_all_zeroes + = reg_buf->raw_compare (zt_regnum, zt_bytes.data (), 0); + + /* If ZA state is valid or if we have non-zero data for ZT in the register + buffer, we will invoke ptrace to write the ZT state. Otherwise we don't + have to do anything here. */ + if (valid_za || !zt_is_all_zeroes) + { + if (!valid_za) + { + /* ZA state is not valid. That means we need to initialize the ZA + state prior to writing the ZT state. */ + aarch64_initialize_za_regset (tid); + } + + /* Extract the ZT data from the register buffer. */ + reg_buf->raw_collect (zt_regnum, zt_bytes.data ()); + + /* Write the ZT data to thread TID. */ + aarch64_store_zt_regset (tid, zt_bytes); + } + + /* At this point we have (potentially) written the data contained in the + register cache to the thread's NT_ARM_ZT register set. */ +} diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h index 5fac51ca98b..0de7cc1fac5 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.h +++ b/gdb/nat/aarch64-scalable-linux-ptrace.h @@ -122,6 +122,17 @@ extern bool aarch64_store_za_regset (int tid, const gdb::byte_vector &za_state); size. The bytes of the ZA register are initialized to zero. */ extern void aarch64_initialize_za_regset (int tid); +/* Given TID, return the NT_ARM_ZT register set data as a vector of bytes. */ +extern gdb::byte_vector aarch64_fetch_zt_regset (int tid); + +/* Write ZT_STATE for TID. Return true if successful and false + otherwise. */ +extern bool aarch64_store_zt_regset (int tid, const gdb::byte_vector &zt_state); + +/* Return TRUE if thread TID supports the NT_ARM_ZT register set. + Return FALSE otherwise. */ +extern bool supports_zt_registers (int tid); + /* Given a register buffer REG_BUF, update it with SVE/SSVE register data from SVE_STATE. */ extern void @@ -153,4 +164,20 @@ aarch64_za_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf, int za_regnum, int svg_regnum, int svcr_regnum); + +/* Given a thread id TID and a register buffer REG_BUF, update the register + buffer with the ZT register set state from thread TID. + + ZT_REGNUM is the register number for ZT0. */ +extern void +aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf, + int zt_regnum); + +/* Given a thread id TID and a register buffer REG_BUF containing the ZT + register set state, write the ZT data to thread TID. + + ZT_REGNUM is the register number for ZT0. */ +extern void +aarch64_zt_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf, + int zt_regnum); #endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */ From patchwork Fri Jun 30 13:48:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 71915 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 BB7D83882AED for ; Fri, 30 Jun 2023 13:50:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB7D83882AED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688133003; bh=zyVI21hROLrQFPxcXLHoSKx2fmf3tneSGap8gHkv+Yc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DjqSDbOhizsiMUc28jX0UKdeD/Y4sqz9OQt/5C8iyN8GBuCzXJ1dLIfTHYl8FiBlG SP80+aljmVflRXf3eKBhGFCEtUzG+i9g2EMMZej5BWAlpPp6VzWVRSBcXQhAf/kknT PlYijaEa+4tYGTRf553RjVqEucdnvgsEvYEpR4KU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2089.outbound.protection.outlook.com [40.107.105.89]) by sourceware.org (Postfix) with ESMTPS id 9E2253836EA4 for ; Fri, 30 Jun 2023 13:49:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E2253836EA4 Received: from DU2PR04CA0200.eurprd04.prod.outlook.com (2603:10a6:10:28d::25) by AM9PR08MB6260.eurprd08.prod.outlook.com (2603:10a6:20b:283::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:49:03 +0000 Received: from DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28d:cafe::ec) by DU2PR04CA0200.outlook.office365.com (2603:10a6:10:28d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:03 +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 DBAEUR03FT033.mail.protection.outlook.com (100.127.142.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:03 +0000 Received: ("Tessian outbound d6c4ee3ba1eb:v142"); Fri, 30 Jun 2023 13:49:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c6ecc9e74c3ffbca X-CR-MTA-TID: 64aa7808 Received: from a41d7a73a78f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8DCEACC5-353A-48D5-A910-0413B5D86218.1; Fri, 30 Jun 2023 13:48:56 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a41d7a73a78f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:48:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BU1pAklcY0V6ecK9cvK8Z8L8VTCSUkKzPsIe/ODrz+eXI/Lwb9iAvZLB4ul7bhBZXESofor9RiK3NvQbr61OiEpLGwihIRcMYj6APcBamgI7wYWVE1a3o6P9yN8f7k8ttw/7ASMiLaGLcMlOm7I6C5L49IiPC0tq0Tapf01OZWiZQOXkQHrZxHOFeqGNmMap7ri3FnGjfva+voxXaeNwNVkKWEzNT5hJvD7szlCfx3qi7a0TR714VLuVPfhgtYU1MuZFz/TEM2dXns3KfeebKhjhPZjHb/wi6lw59GSuKGFfyPoTcawhQlZt8xepZQ+uBu5eKH1vcIX2eq6yKoFVuw== 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=zyVI21hROLrQFPxcXLHoSKx2fmf3tneSGap8gHkv+Yc=; b=W3FqE8ouZD9n6v5WVMmfnOsrN1/I+cBdZE0Wv2oC8LJYJZgBU/nnPAL+SzEh6psI8IMNu9u9fUNaNUJJ8kD9WD1r0ZZL7oRNyt4rXWd80AVMEtBLgNroLS9PGbnptLu84mZnN4nIqRJmpFCknUgZA+NtNxnFTCF1VPwMD8gkH40Y3TY+IwgCENpEiTXTFxveWK2e1fuV5WGuV63WwMd9QklLfOC8jT3ep6IW3w//Xa7Imbt8vq2AvSmbDPGjqR1lUdTWHDDiapxHfVhGtq8K/3Jnrswig19db3uM5QPxJAM4y6gYZFOuJgYCW1qFNresOh3CaH0aoihZqo5DBsCQSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.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 DB6PR0301CA0090.eurprd03.prod.outlook.com (2603:10a6:6:30::37) by GV2PR08MB8512.eurprd08.prod.outlook.com (2603:10a6:150:c2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:48:53 +0000 Received: from DBAEUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::e8) by DB6PR0301CA0090.outlook.office365.com (2603:10a6:6:30::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +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 DBAEUR03FT029.mail.protection.outlook.com (100.127.142.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.27; Fri, 30 Jun 2023 13:48:53 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +0000 To: Subject: [PATCH 2/6] [gdbserver/aarch64] sme2: Enable SME2 support in gdbserver Date: Fri, 30 Jun 2023 14:48:40 +0100 Message-ID: <20230630134844.1238445-3-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134844.1238445-1-luis.machado@arm.com> References: <20230630134844.1238445-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT029:EE_|GV2PR08MB8512:EE_|DBAEUR03FT033:EE_|AM9PR08MB6260:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f15b1c8-e319-4e7c-9f82-08db7970c401 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: 0kXFwXWZFr84jCk9Mh59/VRHkfqxtCOabaTo3P5pJ0b33BhY9+oz3mQHpa/aYlOAaNVwfB+p8H1UGK+OGW9Z04H02KR/vk6aGfVJDJ7Kv1JZ6/Lbc7kMgFmZa0S0Qn+ipk3X41aJphCZvXNOlKU9EowU7BJj57GEPcZSdZj2VIEhkfvsDnSWYPdYkYDEhOfZOM6U0hyB8cVQwU5T0fFGZoke3AxNq1kDgRl46KAR2/lXVT4Ar7l3Jst9/m85PI7USwUPfJTWo3Z44dNKaQxPvcxVa/worn73Ld6Hd0dNwgmo/FCxG9h2Y29IusmSLROdzR7o4hAvdZevszNTkSzjuFl4ve9X/vl7PE10/H6UjsuqNEyqbfUY2YNJc0EmeLxZTzetOTRA8cnugL4naunuOKzwC6FQ9i1lBHke9nC4QnmRhJY4/s+6PWcGIo5tVP5Meww6u0OZJ3u+bRJj80qU+UpuzmP2BZYlVOEyVjFU/vWpWizg+glheR96ZNXRRfNhdCwOHSzirQ4uBbVelxOLX8lPIQuU3YiVAq7C9F9h9ugcMlc1WKrTQ6Z7nIM9BoMhoEtr9SgQRAHktzALBcSWTIXI/9G41y3gT/t3J3RpR7m74Ng3bMp/4rg+YXfyetdw0EBcOLQdfGHGzGEgFn2JmEsJR310rUim02HasIReKj2dmdjaPBYvEUMHLmVbb03+mpCjL//miSC8rhyH8j4GEj3Bgp1ULYBfDMrShx1A7H+5NInctcU/FQW73nIqUHN+WCk8njNg2vS1Ur0ELL14QA== 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:(13230028)(4636009)(376002)(396003)(136003)(346002)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(40460700003)(41300700001)(316002)(47076005)(83380400001)(82310400005)(86362001)(336012)(36860700001)(426003)(186003)(26005)(1076003)(44832011)(2616005)(2906002)(82740400003)(356005)(81166007)(40480700001)(5660300002)(36756003)(8676002)(8936002)(70586007)(7696005)(478600001)(6916009)(70206006)(6666004)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8512 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4ba9d1ce-ef1e-4630-a417-08db7970be2b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g+jhd9yiWZzpukS8KdrXQAPooFTu0pJ/4JhbQuqQg70izNAO6GYoaPaF41+9EG97kyVGjJACUVhxcnd3omKsUtZ20l1x8tmoPNdmyslmhaqd/o+auISEZXpBN02WDRyCp7joLqBPOzfcdVDqlUSQhGxtODXI58K8c4ApEdjdS5HfUJpe8F0EZykUDFkMDUmvo/m4OfmxiGh+KE/85XVw5vFSfkQHlQqfxIyvdWwvOfMJJd9nsPryXoslRKqe1HGhe5Z/jBJRcsRNXdU++qaeMBDNQEqpnoMJEQeg3NlO56kYvOG4hQAdfXmeZBTRkMsLGQbk4aUyQC7XTjpjcSIw2SyAwW2ac1gHcud+EjViX7N9QnL/Mo6w1tucTYaX86z0zzaaND77yCOV70+lF0vmMYiqDb4jlkv++RG284HxjUFbQgMRq46CpgxS2/WiHg5c89hHPsivIAb08QlCGJz7U/+XTwyNyh7Dws8YRogw9w2IR0Vutp8Lb/eLCl9Z0i//jkKAV9bH2boqWKn6tmJGLmhY6zHBOac7jVTtjXZYEEtzrO83XTBSvPc6yvV+Ei/buJXOJxkOp+3N+b9he5OqeaZf8JwCAUKJk83XOujOrjV10CKVWIJRVKYaFVb3jHaRdSuvORBPQFKcECVDVKZ3aMpzmWRMThM0iqI03Rsrc4oXDZFOYwrPvg1+o7ogUwViS/FduEq3TctthSZb6UOfoQwVHpQezQC6Zn4Y9f00S99mLR7AjoMLIVruC7OIzeJl 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:(13230028)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(316002)(40460700003)(41300700001)(83380400001)(426003)(82310400005)(36860700001)(86362001)(186003)(44832011)(26005)(2616005)(1076003)(336012)(2906002)(82740400003)(81166007)(40480700001)(47076005)(5660300002)(36756003)(8676002)(8936002)(6666004)(7696005)(6916009)(478600001)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:49:03.4639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f15b1c8-e319-4e7c-9f82-08db7970c401 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: DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6260 X-Spam-Status: No, score=-11.8 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, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This patch teaches gdbserver about the SME2 and the ZT0 register. Since most of the code used by gdbserver for SME2 is shared with gdb, this is a rather small patch that reuses most of the code put in place for native AArch64 Linux. Validated under Fast Models. --- gdbserver/linux-aarch64-low.cc | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 95688480c3d..783053e359b 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -811,6 +811,52 @@ aarch64_za_regs_copy_from_regcache (struct regcache *regcache, void *buf) memcpy (buf, za_state.data (), za_state.size ()); } +/* Wrapper for aarch64_zt_regs_copy_to_reg_buf, to help copying NT_ARM_ZT + state from the thread (BUF) to the register cache. */ + +static void +aarch64_zt_regs_copy_to_regcache (struct regcache *regcache, + ATTRIBUTE_UNUSED const void *buf) +{ + /* BUF is unused here since we collect the data straight from a ptrace + request, therefore bypassing gdbserver's own call to ptrace. */ + int tid = lwpid_of (current_thread); + + gdb::optional zt_regnum + = find_regno_no_throw (regcache->tdesc, "zt0"); + + gdb_assert (zt_regnum.has_value ()); + + /* Update the register cache. aarch64_zt_regs_copy_to_reg_buf handles + fetching the NT_ARM_ZT state from thread TID. */ + aarch64_zt_regs_copy_to_reg_buf (tid, regcache, *zt_regnum); +} + +/* Wrapper for aarch64_zt_regs_copy_from_reg_buf, to help copying NT_ARM_ZT + state from the register cache to the thread (BUF). */ + +static void +aarch64_zt_regs_copy_from_regcache (struct regcache *regcache, void *buf) +{ + int tid = lwpid_of (current_thread); + + gdb::optional zt_regnum + = find_regno_no_throw (regcache->tdesc, "za"); + + gdb_assert (zt_regnum.has_value ()); + + /* Update the thread NT_ARM_ZT state. aarch64_zt_regs_copy_from_reg_buf + handles writing the ZT state back to thread TID. */ + aarch64_zt_regs_copy_from_reg_buf (tid, regcache, *zt_regnum); + + /* We need to return the expected data in BUF, so copy whatever the kernel + already has to BUF. */ + + /* Obtain a dump of NT_ARM_ZT from ptrace. */ + gdb::byte_vector zt_state = aarch64_fetch_zt_regset (tid); + memcpy (buf, zt_state.data (), zt_state.size ()); +} + /* Array containing all the possible register sets for AArch64/Linux. During architecture setup, these will be checked against the HWCAP/HWCAP2 bits for validity and enabled/disabled accordingly. @@ -838,6 +884,11 @@ static struct regset_info aarch64_regsets[] = 0, EXTENDED_REGS, aarch64_za_regs_copy_from_regcache, aarch64_za_regs_copy_to_regcache }, + /* Scalable Matrix Extension 2 (SME2) ZT registers. */ + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_ZT, + 0, EXTENDED_REGS, + aarch64_zt_regs_copy_from_regcache, aarch64_zt_regs_copy_to_regcache + }, /* PAC registers. */ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK, 0, OPTIONAL_REGS, @@ -909,6 +960,10 @@ aarch64_adjust_register_sets (const struct aarch64_features &features) if (features.svq > 0) regset->size = ZA_PT_SIZE (features.svq); break; + case NT_ARM_ZT: + if (features.sme2) + regset->size = 64; + break; default: gdb_assert_not_reached ("Unknown register set found."); } @@ -947,6 +1002,14 @@ aarch64_target::low_arch_setup () if (linux_get_hwcap2 (pid, 8) & HWCAP2_SME) features.svq = aarch64_za_get_svq (tid); + /* Scalable Matrix Extension 2 feature check. */ + CORE_ADDR hwcap2 = linux_get_hwcap2 (pid, 8); + if ((hwcap2 & HWCAP2_SME2) || (hwcap2 & HWCAP2_SME2P1)) + { + /* Make sure ptrace supports NT_ARM_ZT. */ + features.sme2 = supports_zt_registers (tid); + } + current_process ()->tdesc = aarch64_linux_read_description (features); /* Adjust the register sets we should use for this particular set of From patchwork Fri Jun 30 13:48:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 71917 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 1388F3882035 for ; Fri, 30 Jun 2023 13:50:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1388F3882035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688133033; bh=7zTSjgXm/SiaIPl8zQo0Qfr/ZZ3e65NHF8tnY3a02wI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=w2MemD261CCIA4X4vIc4i1+TUDpk8B5ezKp6OHVD9kqEnZ4ioH7ibiob/lp61PXq0 qL7AzNZendnSSPTISIE0hyTOAPdsHhC+OG0g02VlUbZ9MnSi41V10DXdRzltKQS/0v MGMSRXfv8SLOqKocQAu1bbiklfNvbS1/iv35Q0Uk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by sourceware.org (Postfix) with ESMTPS id E40CB3884585 for ; Fri, 30 Jun 2023 13:49:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E40CB3884585 Received: from DB9PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:1d8::12) by AS8PR08MB6343.eurprd08.prod.outlook.com (2603:10a6:20b:337::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:49:05 +0000 Received: from DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d8:cafe::8a) by DB9PR01CA0007.outlook.office365.com (2603:10a6:10:1d8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:05 +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 DBAEUR03FT061.mail.protection.outlook.com (100.127.143.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.10 via Frontend Transport; Fri, 30 Jun 2023 13:49:05 +0000 Received: ("Tessian outbound 7c913606c6e6:v142"); Fri, 30 Jun 2023 13:49:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 858093083f40b3a8 X-CR-MTA-TID: 64aa7808 Received: from d408c57c4b40.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2FD90B6D-CE14-4AEB-85B2-941BE7965BB5.1; Fri, 30 Jun 2023 13:48:57 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d408c57c4b40.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:48:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SDBq5AJPJEd4lP7mD4NzRiKEyL6LbslmQA9hwYadKoKC1ZQ27cKS8dpPhwQqdB0DQ+0ED12/ScnY7YDL8sTcYcTE4INiBX13BWnxvlMEyKGHXKLpeeYgnbQ4qucg9dS5ngsIG+nEbouLq/yuh/I5d70iMgiRRxxFL2v2h7qcEhB2/r1tJxm5I1MLll4WyBkESVsxiHA+OLwiPgRtaKK5v2h7KbJeV7Mxc6RX4kheETJf9tgQhMimKZ94lCmGZvhZbbAVRtDNs9eaqHT7sIlcvMS2Kj9rZo03fTNNTKDOC2Ii1in8FbtLjKJpE7py0V8To9D/qUa9mgd27TgF4rvIFg== 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=7zTSjgXm/SiaIPl8zQo0Qfr/ZZ3e65NHF8tnY3a02wI=; b=nd9grBoJ+lLqpA2Y7eX9ckeu7E8vnpckc0aRdd95yJUD1bkfGZh8JAB9Th0gFBerKK+pfNRQfanqYTXy1jQkhDYGUu1srm+TKQY81lNO2v5X5SUvMWq5svkI2Jhlrmq6PhZU1J40RWmqql5ze4HfcviLnEasj/ZuaxD+wm3vhpW+FCje2YgM8Ocb2BAwqLfsNK/JgOzydWuGlhnebfJK1hMhlTa2tz7b1DEwNPkKRzLHKoszgYMTcfCqJudsmgkV44tEJJgKvZLGDCBIfPCfVwKpCKHTA1UzCyQl16GcQs6NTb+TJWb4mAaJyN//CW1chNbcYS5t7IooN7q8TQfa2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.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 AS8PR05CA0020.eurprd05.prod.outlook.com (2603:10a6:20b:311::25) by DB5PR08MB10064.eurprd08.prod.outlook.com (2603:10a6:10:48e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:48:55 +0000 Received: from AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:311:cafe::1) by AS8PR05CA0020.outlook.office365.com (2603:10a6:20b:311::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:55 +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 AM7EUR03FT063.mail.protection.outlook.com (100.127.140.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:54 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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; Fri, 30 Jun 2023 13:48:53 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 30 Jun 2023 13:48:53 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +0000 To: Subject: [PATCH 3/6] [gdb/aarch64] sme2: signal frame support Date: Fri, 30 Jun 2023 14:48:41 +0100 Message-ID: <20230630134844.1238445-4-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134844.1238445-1-luis.machado@arm.com> References: <20230630134844.1238445-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT063:EE_|DB5PR08MB10064:EE_|DBAEUR03FT061:EE_|AS8PR08MB6343:EE_ X-MS-Office365-Filtering-Correlation-Id: a7332441-4673-406a-1575-08db7970c511 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: evxWOp4dDuUJ609tiivf/0rANXEZIbY5W3qHOSz+UAmb1verVvnspLQfjh7c4GEjOyTcDhpsGHPyEkEsXRi6GFI4arzsxxrY0PjuTiN0jsDUOIpn1PRCDdE0MNdxjy7ExKw4zzgTxZpmnwN0naoOQaDk1dgbE1BmRJCa/vFMrSjRxcTf2maW49FvRZCJRXSpgA4gF/oafJn2d6Xfy26bYfgp6tMcZA6nQj1/PIhyQyTm3N9nJwbxpsj8hl/Al+8Fa8Lnb30WV2UZGPHDKLFyebze3tYMsAEApmS1sY3h59wPZuK5mQ93WmN7y1KzlkxPh6/zUPf6IHlJxa0qpJt/D07AIhoQrgRXU0aPwP1FPAtL83F8SelVZvQRdQ30sVGAYmASXebyJuP2/3jWHmvvR0Hjoz/6Op2BoaWLmIComBcF/r4ihmNdETvIaRJjKpjmrvPQXa0kjXy/DHednqIbc0r0Yob6BTzZW6CzGjGrvAdMalyK1vpX2/DU32sLSFiOFIuccHONctKerw/8KCRCZ1nt5VR8fz3Rxs+KQDIm5z/xEmLuqsyDOKWVbJ7gTrr1ZIRPFHoDMv6C46uMs+Tc8soEwJ/bhL4rg8EGWlNNDpK7GDdf1huxlpYVgQ4hEFGLTUoskBocShQTnNHqQjFmZCgyUOXbByXTmwlmk31NR5c8bS1+MliKxOEJxbTBWcuhL0g9Ibs6129nXvBHW8dJ6KT9p/SlyWXg9C4kbj4DPcZRI1SX1cpKt4bS3SC5vLkkLd1BfHTkEKruJVS1adiOzg== 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:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(8936002)(8676002)(5660300002)(44832011)(70586007)(70206006)(6916009)(2906002)(316002)(41300700001)(478600001)(47076005)(36860700001)(40460700003)(6666004)(7696005)(40480700001)(1076003)(336012)(2616005)(426003)(83380400001)(36756003)(186003)(26005)(81166007)(356005)(82740400003)(82310400005)(86362001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB10064 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 704a0a34-1a28-4566-11c0-08db7970bef9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xEQU2+CmrKUC1wIQYPc1vqaVUlYtf8IjE3WKhxpk1M3s0cBA6MUzRE2Lvl1w5QueqPh+M30BPVtTIAwTcar8ft89fpsxzWpam0KVyPGW1mwRtNn0r4ynON4LIGer/jgOT0In3jomfOYARllv/oe1NdJDCuOkwdvj+V7gug8sCEMlm6JKx1xHfZkFsKC5+CUONhM4FRru7bvzWKmqPj/3k3uY8zqM9fxqUM06a/ah/O2E5b2BURf26xTmq3uaHfkKRq0xmDTdXMWFGEdaBfTUgV5DkCAGkQ85OxPsxjyn/cvqj61J+R/OgE1KOJAF/JRMP/sykAL8ihJbkisG7+vNWYJzXfjHpvfdyAqthlSCDTDNvg1FPbKfInqITK7ALMgqnEx3Unqngq2oOcyE99IyrlElj+Wz7NEVgHqJ5nKFLMTO0J80Us76U62TYw/kt0KZffJASVQY7SE8Ju1He3jKIJR/5F/emG1t19RwmCfOA4gSBVUNki1n5AIOtLLq8rX4fvrdCn82650kIyiq4W6j1gKFpVmp+yHuFPAbdCVM0SpanWEYM3PwThhw57Jvdy1KIn6HM5LJJK6QnLFA4BY1oVKGUxJ8HKB3ypQkmpYlt0mRXFk5f4JsDgvPvUHTb9UXO3au8wzUdpiRixfHZsRFPvbjzLuRy0kYcYxWxM57a56vaP0rTIvufgFwCmPDe8Spb6JM2GYexv3nmdR4ru1t43rwxFNlwszVop7MRdnp7EPo6yhVbDtK/bfq2vjb1rZ3 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:(13230028)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199021)(36840700001)(46966006)(40470700004)(186003)(6666004)(8676002)(8936002)(44832011)(478600001)(26005)(70586007)(70206006)(6916009)(1076003)(316002)(86362001)(7696005)(5660300002)(81166007)(82740400003)(40460700003)(2906002)(2616005)(82310400005)(40480700001)(47076005)(336012)(426003)(83380400001)(36756003)(36860700001)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:49:05.2586 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7332441-4673-406a-1575-08db7970c511 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: DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6343 X-Spam-Status: No, score=-11.8 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, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Teach gdb about the ZT state on signal frames and how to restore the contents of the registers. There is a new ZT_MAGIC context that the Linux Kernel uses to communicate the ZT register state to gdb. As mentioned before, the ZT state should only be available when the ZA state is available. Validated under Fast Models. --- gdb/aarch64-linux-tdep.c | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 0bd75daa994..1fe35de6079 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -159,6 +159,7 @@ #define AARCH64_SVE_MAGIC 0x53564501 #define AARCH64_ZA_MAGIC 0x54366345 #define AARCH64_TPIDR2_MAGIC 0x54504902 +#define AARCH64_ZT_MAGIC 0x5a544e01 /* Defines for the extra_context that follows an AARCH64_EXTRA_MAGIC. */ #define AARCH64_EXTRA_DATAP_OFFSET 8 @@ -192,6 +193,14 @@ /* TPIDR2 register value offset in the TPIDR2 signal frame context. */ #define AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET 8 +/* SME2 (ZT) constants. */ +/* Offset of the field containing the number of registers in the SME2 signal + context state. */ +#define AARCH64_SME2_CONTEXT_NREGS_OFFSET 8 +/* Offset of the beginning of the register data for the first ZT register in + the signal context state. */ +#define AARCH64_SME2_CONTEXT_REGS_OFFSET 16 + /* Holds information about the signal frame. */ struct aarch64_linux_sigframe { @@ -214,6 +223,8 @@ struct aarch64_linux_sigframe CORE_ADDR za_section = 0; /* Starting address of the section containing the TPIDR2 register. */ CORE_ADDR tpidr2_section = 0; + /* Starting address of the section containing the ZT registers. */ + CORE_ADDR zt_section = 0; /* Starting address of the section containing extra information. */ CORE_ADDR extra_section = 0; @@ -221,10 +232,15 @@ struct aarch64_linux_sigframe ULONGEST vl = 0; /* The streaming vector length (SSVE/ZA). */ ULONGEST svl = 0; + /* Number of ZT registers in this context. */ + unsigned int zt_register_count = 0; + /* True if we are in streaming mode, false otherwise. */ bool streaming_mode = false; /* True if we have a ZA payload, false otherwise. */ bool za_payload = false; + /* True if we have a ZT entry in the signal context, false otherwise. */ + bool zt_available = false; }; /* Read an aarch64_ctx, returning the magic value, and setting *SIZE to the @@ -479,6 +495,33 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame, { /* This is context containing the tpidr2 register. */ signal_frame.tpidr2_section = section; + section += size; + break; + } + case AARCH64_ZT_MAGIC: + { + gdb_byte buf[2]; + + /* Extract the number of ZT registers available in this + context. */ + if (target_read_memory (section + AARCH64_SME2_CONTEXT_NREGS_OFFSET, + buf, 2) != 0) + { + warning (_("Failed to read the number of ZT registers from the " + "ZT signal frame context.")); + section += size; + break; + } + + signal_frame.zt_register_count + = extract_unsigned_integer (buf, 2, byte_order); + + /* This is a context containing the ZT registers. This should only + exist if we also have the ZA context. The presence of the ZT + context without the ZA context is invalid. */ + signal_frame.zt_section = section; + signal_frame.zt_available = true; + section += size; break; } @@ -516,6 +559,12 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame, if (!extra_found && section > section_end) break; } + + /* Sanity check that if the ZT entry exists, the ZA entry must also + exist. */ + if (signal_frame.zt_available && !signal_frame.za_payload) + error (_("While reading signal context information, found a ZT context " + "without a ZA context, which is invalid.")); } /* Implement the "init" method of struct tramp_frame. */ @@ -622,6 +671,22 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, /* Restore SVG. */ trad_frame_set_reg_value (this_cache, tdep->sme_svg_regnum, sve_vg_from_vl (signal_frame.svl)); + + /* Handle SME2 (ZT). */ + if (tdep->has_sme2 () + && signal_frame.za_section != 0 + && signal_frame.zt_register_count > 0) + { + /* Is ZA state available? */ + gdb_assert (svcr & SVCR_ZA_BIT); + + /* Restore the ZT state. For now we assume that we only have + a single ZT register. If/When more ZT registers appear, we + should update the code to handle that case accordingly. */ + trad_frame_set_reg_addr (this_cache, tdep->sme2_zt0_regnum, + signal_frame.zt_section + + AARCH64_SME2_CONTEXT_REGS_OFFSET); + } } /* Restore the tpidr2 register, if the target supports it and if there is From patchwork Fri Jun 30 13:48:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 71911 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 79DBD382A2FC for ; Fri, 30 Jun 2023 13:49:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79DBD382A2FC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688132974; bh=5hLoNf//iWrYujK6bRav9I4sG+LTJ8+bODMg6B06qtQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=rFYtHpk0wqFEz3l5mSgJeS+em29/o76SycjyB9SwaBKhupZSOvf+4Ga5VxORhELXm I8J4VdBaJdK2CNlTY2OftAt6gNyFDHfdyb7fB8oRBHEG2/Tu/on5Z8cEJe38/phWbw BzM9lNa6qCv8gbMA4dBX0FaKemncHU7Boz9MtAAc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2068.outbound.protection.outlook.com [40.107.6.68]) by sourceware.org (Postfix) with ESMTPS id DE132388217F for ; Fri, 30 Jun 2023 13:49:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE132388217F Received: from DB8PR03CA0017.eurprd03.prod.outlook.com (2603:10a6:10:be::30) by AS8PR08MB8297.eurprd08.prod.outlook.com (2603:10a6:20b:537::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 13:49:02 +0000 Received: from DBAEUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:be:cafe::f0) by DB8PR03CA0017.outlook.office365.com (2603:10a6:10:be::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:02 +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 DBAEUR03FT050.mail.protection.outlook.com (100.127.142.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:02 +0000 Received: ("Tessian outbound c08fa2e31830:v142"); Fri, 30 Jun 2023 13:49:02 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d1ac8617c86977b7 X-CR-MTA-TID: 64aa7808 Received: from f8e2ffd9c364.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E08823C2-0BD4-4AF1-B022-02D277F3E5E8.1; Fri, 30 Jun 2023 13:48:55 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f8e2ffd9c364.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:48:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hMkG1DTvMRitOGIyltHfPmmavVlHQ5st9NYy2EaM3UXxzwyaatCugd5YbitzgKterfZ8he8F/IHR7GWiCRCYa1qpYTAoVT1OZOlXveXX0DmYcFaRSvFlxzJKz1wwkFxFlwzl5t6kCdQZqhy0Ek8J2MJdGR2yVMyEf3kiKmDiMdQjMXTBx55YpJi1rUFRaHOc3kKd4oP2JUkoKc9b+MsCtEJSwANhAuLY4fVp4ysa5Smsm9Zb+EdAKIRIN1PeYakt355/y+yv3sGvbStlNuKbA2K0sGYsEfhzbRx5GgdkGIpMoOApnKnphJjg/0AqCGmzkYaLYcUtLMPW2UY3TFdbIw== 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=5hLoNf//iWrYujK6bRav9I4sG+LTJ8+bODMg6B06qtQ=; b=RNfXjixMX/6WV9OPUCTF99xB54RQ/ZdDrRjesFafIsg8a5ep0EBMFneHSwl2gWWq4XO4uy7MCWK5fhAr4YBy0r7tweUVd/JVwcMPbTUl5tqxFITXX5JO5b2PKQTnZctEviOL9s2zDFpgmKO11jYFoDH17XYfVnex9/1i7wttR7Si0gVrWrLRFsolX6SkyKrKVm9uNCjPJCNXLJFfrMI4yFuJTJzy7hJJnnBM3YFU6X9TjmHLX6UrTQAiYQrKVvyFfsYgmM/pskEsV9+vZPUQBzuIY2v/VNMo0iE6mHRmdtZpzlNRRDfW72n+orCODDSTSmIxrP2f2Bfw5z4eMnsbpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.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 DB6PR0301CA0094.eurprd03.prod.outlook.com (2603:10a6:6:30::41) by AS1PR08MB7538.eurprd08.prod.outlook.com (2603:10a6:20b:482::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 13:48:54 +0000 Received: from DBAEUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::2a) by DB6PR0301CA0094.outlook.office365.com (2603:10a6:6:30::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:54 +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 DBAEUR03FT029.mail.protection.outlook.com (100.127.142.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:54 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.27; Fri, 30 Jun 2023 13:48:53 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +0000 To: Subject: [PATCH 4/6] [gdb/aarch64] sme2: Core file support for ZT register set Date: Fri, 30 Jun 2023 14:48:42 +0100 Message-ID: <20230630134844.1238445-5-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134844.1238445-1-luis.machado@arm.com> References: <20230630134844.1238445-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT029:EE_|AS1PR08MB7538:EE_|DBAEUR03FT050:EE_|AS8PR08MB8297:EE_ X-MS-Office365-Filtering-Correlation-Id: a48c82f4-2361-41ea-8f0c-08db7970c372 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: RPRfK5uxXdjNU3pWBW0GtTsW3d1UaYkKyF+tzmwPo5E1fPVVCErdHV6C67Hszgihpi/3uB6oWRNZ6cWIPyI4yi93C2r9tj5ylad90ZXV4xcNtw+4WPONpmFhZKDPHsoHiB1Du9DFVGLcTSe2fv2l8Lq0VEDCuhvF8nAO+Up1e5dVXw8lL3wMJYuGxWgNF3eKRLhvP1bh8hqOL1vOmEWI59DLTp95TeEQTwBplMfIPYJ6P/dv23KC0cBc48aopv5YDjZedCWekQkRiN6iEWOCTX4mg3QuH1QiWU9wNDxGV/Qj2WV4aHUiOM17I1OZYIYDq7BWDxono8vOO+F8GC9SnMTf7C8IDX/2Z2U7yU4diGKFYUOND3nfB4pS2XaZjsUrv/ljk1pVOVtEydxCTnBw3oE+ez6zlnSOXyPKVC2pR7X3IxXdMDGokdDpxSjxF6ciRSTCPI1X5tC7nyXYnIYRW65YyIbX36J2zd4S22LKgTEpSRyz8KKgGCmJa9o6CSAFsvJOPpVfxXq2G8TpnxF0oYHhKY74f6zxnexOnLRLXcFnLIYc9unps0Xx8diQ0kOaIVK47GrqfgP3CKS5xDK1vfuf1x8lYl3ZCUIqGQ1Jp7yKXGC358uSgNzDIPt+PqLqu38+70/KNak4mQ9tQR3IxZPx+GzUIgN2xM0FC6iNsFxUevk6Z9w/ZBfnqpkGRgR7jjDr50z2cfJ/kyM6NxIyWooDeq+qTKVEZpQ3qWiC7NKnHNh4n0YdjMFyRfV3s0NEaGpOKD5GGHHh9yicCdz/vg== 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:(13230028)(4636009)(376002)(39860400002)(396003)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(81166007)(82740400003)(356005)(47076005)(83380400001)(426003)(36860700001)(86362001)(36756003)(478600001)(70586007)(7696005)(40460700003)(6666004)(2616005)(41300700001)(70206006)(316002)(8936002)(8676002)(1076003)(336012)(186003)(26005)(6916009)(82310400005)(44832011)(5660300002)(2906002)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR08MB7538 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4588b3dc-947b-4efd-3dbf-08db7970be67 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E7kje5GVCd3vZE2Ri/GvkGwxBwrN8uFi34VctPhtg9T4o3zN6EmJLe5px3MTFRHFVjsiCCKVHTyz+/jqvBqM5gCiOLnKGUxP594wzX08FvseGuvoJP45flEFeP3ngOq4LSSO/DRiSawewU/Pyy8yUXZiZBwda9hXaPp4eSNGAtR01JJnOn8yy4iW8Uo49kBufQHQuh75reu2c/bFBrnJJLryV4gUBV6AMcJv7C1/l5ecLLQYvnaBzKE7B1I6aCBajwcooNPsd1F/J+9WNNjr7sEMVPXoVi5gLLS/edOmW/s88WoVzFQHZCagCSFqUk9y8AQvnSeNRi+A2TsryKx6cNyZFQW/qoLZqo5gp/WKb43NyWvXuW6cUNEq9rbYVcueVU4xo/DctEuxn8mpRWUJkx5+c3TNvbTAe6YZdwaQQgcMMGR3gUjY4ZdcxuDLMuzEBTxDihqGS8Li+rvrex3ICNWfY05Trgiw6J/3/YVYSfJX588zyPYg7yK7H2C4O0lztcweQB/9j/vmyt9K19SuUlocqsVH2Op2QbH2AkrAwWKhdK6eyr6GgSfqVNQqt1AWorBsCKDdkmsOAtOM/KEvWAHh4rogK00o1+mPz7toHYGjMaaVOYp5devuA6b+2gFUCyW+4MDhelZEj6ASkQjVzkECwqmHn45VnGICqv+H5wG4GVo3/kaLhs2rl9q5R5zUKVJnOoYvuVZPpYrFls6w2LupY/0zyUk1WoPsxwEhmNyznWVrTfeSKS5AyNyg/Uzv 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:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(40470700004)(46966006)(36840700001)(44832011)(5660300002)(6916009)(478600001)(70206006)(316002)(36756003)(70586007)(8936002)(8676002)(2906002)(6666004)(26005)(40460700003)(36860700001)(41300700001)(82310400005)(7696005)(186003)(40480700001)(426003)(336012)(47076005)(1076003)(86362001)(82740400003)(81166007)(83380400001)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:49:02.5420 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a48c82f4-2361-41ea-8f0c-08db7970c372 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: DBAEUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8297 X-Spam-Status: No, score=-11.8 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, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This patch adds support for ZT register dumps/reads for core files. The ZT register is available when the SME2 feature is advertised as available by the Linux Kernel. Unlike the enablement for SME1 and the ZA register, support for SME2 is rather simple given the fixed size of the ZT0 register. Validated on the Fast Models. --- gdb/aarch64-linux-tdep.c | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 1fe35de6079..1d62ac54d5b 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1365,6 +1365,50 @@ aarch64_linux_collect_za_regset (const struct regset *regset, size - SVE_HEADER_SIZE); } +/* Supply register REGNUM from BUF to REGCACHE, using the register map + in REGSET. If REGNUM is -1, do this for all registers in REGSET. + If BUF is NULL, set the registers to "unavailable" status. */ + +static void +aarch64_linux_supply_zt_regset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *buf, size_t size) +{ + /* Read the ZT register note from a core file into the register buffer. */ + + /* Handle an empty buffer. */ + if (buf == nullptr) + return regcache->supply_regset (regset, regnum, nullptr, size); + + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Supply the ZT0 register contents. */ + regcache->raw_supply (tdep->sme2_zt0_regnum, buf); +} + +/* Collect register REGNUM from REGCACHE to BUF, using the register + map in REGSET. If REGNUM is -1, do this for all registers in + REGSET. */ + +static void +aarch64_linux_collect_zt_regset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *buf, size_t size) +{ + /* Read the ZT register contents from the register buffer into the core + file section. */ + + gdb_assert (buf != nullptr); + + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Dump the register cache contents for the ZT register to the buffer. */ + regcache->collect_regset (regset, tdep->sme2_zt0_regnum, buf, + AARCH64_SME2_ZT0_SIZE); +} + /* Implement the "iterate_over_regset_sections" gdbarch method. */ static void @@ -1453,6 +1497,30 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, SVE_HEADER_SIZE, SVE_HEADER_SIZE + std::pow (sve_vl_from_vq (tdep->sme_svq), 2), &aarch64_linux_za_regset, "ZA register", cb_data); + + /* Handle SME2 (ZT) as well, which is only available if SME is + available. */ + if (tdep->has_sme2 ()) + { + const struct regcache_map_entry zt_regmap[] = + { + { 1, tdep->sme2_zt0_regnum, AARCH64_SME2_ZT0_SIZE } + }; + + /* We set the register set size to REGSET_VARIABLE_SIZE here because + in the future there might be more ZT registers. */ + const struct regset aarch64_linux_zt_regset = + { + zt_regmap, + aarch64_linux_supply_zt_regset, aarch64_linux_collect_zt_regset, + REGSET_VARIABLE_SIZE + }; + + cb (".reg-aarch-zt", + AARCH64_SME2_ZT0_SIZE, + AARCH64_SME2_ZT0_SIZE, + &aarch64_linux_zt_regset, "ZT registers", cb_data); + } } if (tdep->has_pauth ()) @@ -1558,6 +1626,19 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, features.svq = aarch64_linux_core_read_vq (gdbarch, abfd, ".reg-aarch-za"); + /* Are the ZT registers available? */ + if (bfd_get_section_by_name (abfd, ".reg-aarch-zt") != nullptr) + { + /* Check if ZA is also available, otherwise this is an invalid + combination. */ + if (bfd_get_section_by_name (abfd, ".reg-aarch-za") != nullptr) + features.sme2 = true; + else + warning (_("While reading core file sections, found ZT registers entry " + "but no ZA register entry. The ZT contents will be " + "ignored")); + } + return aarch64_read_description (features); } From patchwork Fri Jun 30 13:48:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 71918 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 BBEB73882645 for ; Fri, 30 Jun 2023 13:50:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBEB73882645 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688133040; bh=YF0DAGV3cRBxH8u3KAyC3fA5NwUco12p1hlPlj5TFtw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AaeiiSrFrDi29rLcKa6oypO6bPYwNL83qzYFB6SdOWna+6snflOQfgmmsRvcMFtzL krDU8u/O+d7PA0MSW3Uv3A7FL5C9Tl6H6GEYGjyCbjLqT+24LFT52VkSqLYiuDCUAG /B6F3M2OsP6DUBABugx5F7Z0T2plwc2g8TrDy12c= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2087.outbound.protection.outlook.com [40.107.20.87]) by sourceware.org (Postfix) with ESMTPS id 293883884598 for ; Fri, 30 Jun 2023 13:49:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 293883884598 Received: from DU2PR04CA0198.eurprd04.prod.outlook.com (2603:10a6:10:28d::23) by AS8PR08MB8565.eurprd08.prod.outlook.com (2603:10a6:20b:568::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 13:49:05 +0000 Received: from DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28d:cafe::e0) by DU2PR04CA0198.outlook.office365.com (2603:10a6:10:28d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:05 +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 DBAEUR03FT033.mail.protection.outlook.com (100.127.142.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:05 +0000 Received: ("Tessian outbound d6c4ee3ba1eb:v142"); Fri, 30 Jun 2023 13:49:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7840ed9cd422b210 X-CR-MTA-TID: 64aa7808 Received: from c03d9f0ac955.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C804B39D-AD32-4019-884C-E7455DCD18F8.1; Fri, 30 Jun 2023 13:48:58 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c03d9f0ac955.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:48:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QjnKuw9J2fvNB9k/8SvDTE7K7qsLxMAlpWrez9YxJazgPjPAqa7j7hqreXLyFJx/5QnA3sNgydg7iX9un4IwFoQLH9V9OWe3Uo5H89U5A7iL8VqPYv99rrxPePMTVSqj3rJnPLvarKOi6qyJIsa9unL72Po65ANohsKs6QfQXMef8qz8gw2+8JNxpSvalPfFVbMSkwbklmB3u1zIZ7oeuDvhSdER5Cu6NsiFg2nvuj+mjeV8KIchzeAkYHXN4BJH/h+m1kWFI1d76OmhVLmjvapk+SKDly2mN1Xt8hnQcL2AAC6GJupPK2/aFrZ0CptttoOMC0evpk3vyUjhFU3tpw== 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=YF0DAGV3cRBxH8u3KAyC3fA5NwUco12p1hlPlj5TFtw=; b=JjmhODZ4nW5iiR70ENOH6bhab7OAX2LHxr2Wm8gOxKPuh2lTM7Bm21bp1bzjgsQ01EGq1d1EuLFDdYI9x8QxI5TtdRjydIh7bZ1LbRP75f8e6l4D3DvB1JSYUNa/+19QeIZZQm/Z//HO+mWcUp6ciSN/NDNqWeR4zWYHR/85is4ydCHm2hDfC5eAVA2Q398X7xIeLT6VxMMgMe/EdD2iiXx/lVJc6IwSjc7EV2IGmHx2vDG8vsrB/Qq9nOYkWFfuAFO3b7j2OmXvg7O/u98DAm3m20i+jNRi3SedAxMMFhMZ0tNGPgOJOC7HHX13jO+XAaV3b+/JaKy8ndgdXC0rLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.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 AS8PR05CA0007.eurprd05.prod.outlook.com (2603:10a6:20b:311::12) by GV2PR08MB9160.eurprd08.prod.outlook.com (2603:10a6:150:e0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:48:56 +0000 Received: from AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:311:cafe::be) by AS8PR05CA0007.outlook.office365.com (2603:10a6:20b:311::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:55 +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 AM7EUR03FT063.mail.protection.outlook.com (100.127.140.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:55 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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; Fri, 30 Jun 2023 13:48:54 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 30 Jun 2023 13:48:54 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +0000 To: Subject: [PATCH 5/6] [gdb/testsuite] sme2: Extend SME tests to include SME2 Date: Fri, 30 Jun 2023 14:48:43 +0100 Message-ID: <20230630134844.1238445-6-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134844.1238445-1-luis.machado@arm.com> References: <20230630134844.1238445-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT063:EE_|GV2PR08MB9160:EE_|DBAEUR03FT033:EE_|AS8PR08MB8565:EE_ X-MS-Office365-Filtering-Correlation-Id: c683cf2c-3174-45bd-76cf-08db7970c543 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: 352McGZ8utFT7hnDtr06f61SvftyDEdLZfbNpYVgfi2UwVyGnLPfyle9uHTRBvyc5meBSS36wX2nYymhhe3BoKpiSp3vMHcMRN19HGQLqMXM1yor/dnhEsWL7pGGXBMVgoDgkxJlwh+k2TbZjsPPF9BmXsjFT5SoLPEP4YU6cdqPWbssd0fmRnskcAclAueJVTFWvnB7IFo8fKlbe0AUPGDZa+c/NqQFXufz2fiMXZJ4VKW7es17S9ndTFvosC6HCHsN5Rh9FPhiTGTPsd/Zk3Tp7oX4htmpBJl3Z24exg6bTBNsk2UEh/aQ59VECM1uItEvrBG9viKsaeJh4Ly1a9TsZU5lniUlZNaYVqS684JD08GaN9kFU/wBZORwhO+xC2GaN3bpnajGgpL3Zj8V5i3tGMV5clWFjYSMNSVUk9VtDVSAr5w2uKJi836qBs5bnaoc+rSUoweUDm7SlEzRkEDGyp7MxeNQYp0xRA5bBYMsFaL3BnqgiuiP/VeZ8x20Ne6tAeny7KuY3TtdmK/TUtzPPyHOb2hPGc+fgUeCnktnupdUXv0/Q/eeVo/yOdymspk235IgZ/8nQJ8dvvKif6XmOCej1N47OMfZijkHuWOpAvyDZHzml7g23z+NIvmdLwrgjC0239oOXcBJ5HFoIY8sXgx+sW5e7OxoCu2LszKAT/5UxvyJaztBZC6C+t53m+MMvIp45pGFOTcTyRvDWQ/xkvnn+/fgs7yNttLGIz3gZEz0D7L16sYRqwNNUQmD 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:(13230028)(4636009)(39860400002)(136003)(346002)(396003)(376002)(451199021)(36840700001)(46966006)(40470700004)(6666004)(478600001)(8676002)(8936002)(36756003)(5660300002)(7696005)(70206006)(70586007)(6916009)(40460700003)(316002)(41300700001)(40480700001)(356005)(81166007)(47076005)(186003)(44832011)(30864003)(1076003)(2616005)(26005)(336012)(426003)(83380400001)(82310400005)(86362001)(36860700001)(2906002)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB9160 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 79b99f41-7332-4456-348f-08db7970bf3e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kqrMijON0jNGv80x1PrI0Ow+tWfMWdcMs/ldfmWw1LhXXbE9iytDqjjsGDes1AjrGv6epaZy2IOhxS6wNQZeTar9esLSxfDEhNjKTGQ+6w9WWRAJViG5obnqfHU4tz8yIHoZK7aNb2gicED3bbWG9f+kvWtQlqrRVuUXRjt376NpB4orTd0tiPnc1kN0JkprAGd0vLkMuiXcOSwlOIDQr9+XpTjsCMQj1ql7W1v4z+r+8M4BbhkTpVvedXdH4av/N8fnvmM5lbL9uN+85GhHSeK85EPBSFTfgh3FPQ+89TCeZEDPe8EPF7ZgwzFJGaAUUgfyGQiZtcq8AYSeGCzq/s03tUbq+VOETvGQc0TlASzi8MphV3fuxph7ODKzS350dQ3jPkRfPfneO9ITCtoligvl2qmnpKPiF4mRJfRhq7/D4lrrMdwmyX/fBzd8RpGodsAc1qPFlxymS8X+Lj3ss2406fZtSxSCu9JNsdyWmskY5/2467VoB//AyssnbrkyyydgMdATYVjhOdUMxGQ1s98zrgeFfC/aZXhPRSa7cU26MipuvuJ3MpAfGg8ByxNK7H4GUrob2Jk2kIpW8T8z0SMntrg+7gbIszG+zrlrXV21liWU0wpCBTO3sAUzuCvtvXyrjp0DwVHGDMmuY1/10uX8DGCegxNlMp0DnY68Kh6UXsb/ENOYzr0qt7Sgpb74r5Vys3KrmFmTZ5HA0kc7X6YvsmLSLz66Lj3AOGi1XyI= 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:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(40470700004)(36840700001)(46966006)(44832011)(5660300002)(6916009)(478600001)(70206006)(316002)(36756003)(70586007)(8936002)(8676002)(2906002)(6666004)(26005)(40460700003)(36860700001)(30864003)(41300700001)(82310400005)(7696005)(186003)(40480700001)(426003)(336012)(47076005)(1076003)(86362001)(82740400003)(81166007)(83380400001)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:49:05.5888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c683cf2c-3174-45bd-76cf-08db7970c543 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: DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8565 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, KAM_NUMSUBJECT, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Reusing the SME tests, this patch introduces additional tests to exercise reading/writing ZT0, availability of the register set, signal context reading for ZT0 and also core file generation. --- gdb/testsuite/gdb.arch/aarch64-sme-core.c | 32 +++++++++++++- .../gdb.arch/aarch64-sme-core.exp.tcl | 2 +- .../aarch64-sme-regs-available.exp.tcl | 17 +++++++ .../gdb.arch/aarch64-sme-regs-sigframe.c | 32 +++++++++++++- .../aarch64-sme-regs-sigframe.exp.tcl | 13 +++++- .../aarch64-sme-regs-unavailable.exp.tcl | 12 +++++ gdb/testsuite/gdb.arch/aarch64-sme-sanity.c | 32 +++++++++++++- gdb/testsuite/lib/aarch64.exp | 44 +++++++++++++++++++ 8 files changed, 176 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.c b/gdb/testsuite/gdb.arch/aarch64-sme-core.c index d71d18ebd3b..fcb14670e0d 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-core.c +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.c @@ -35,6 +35,11 @@ #define HWCAP2_SME (1 << 23) #endif +#ifndef HWCAP2_SME2 +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#endif + #ifndef PR_SVE_SET_VL #define PR_SVE_SET_VL 50 #define PR_SVE_GET_VL 51 @@ -145,6 +150,27 @@ initialize_za_state () __asm __volatile ("bne loop"); } +static void +initialize_zt_state () +{ + unsigned long hwcap2 = getauxval (AT_HWCAP2); + + if (!(hwcap2 & HWCAP2_SME2) && !(hwcap2 & HWCAP2_SME2P1)) + return; + + char buffer[64]; + + for (int i = 0; i < 64; i++) + buffer[i] = 0xff; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize ZT0. */ + /* ldr zt0, x0 */ + __asm __volatile (".word 0xe11f8000"); +} + static void initialize_tpidr2 () { @@ -273,8 +299,8 @@ static int set_svl_size (int new_svl) 0 - FPSIMD 1 - SVE 2 - SSVE - 3 - ZA - 4 - ZA and SSVE. */ + 3 - ZA (+ SME2 ZT0) + 4 - ZA and SSVE (+ SME2 ZT0). */ void enable_states (int state) { @@ -295,6 +321,7 @@ void enable_states (int state) { enable_za (); initialize_za_state (); + initialize_zt_state (); } else if (state == 4) { @@ -302,6 +329,7 @@ void enable_states (int state) enable_sm (); initialize_sve_state (); initialize_za_state (); + initialize_zt_state (); } return; diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl index ed229982d7c..f4435a172f1 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -# Exercise core file reading/writing in the presence of SME support. +# Exercise core file reading/writing in the presence of SME and SME2 support. # This test exercises GDB's dumping/loading capability for Linux # Kernel core files and for gcore core files. diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl index 635588777ec..c76d2f68933 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl @@ -14,6 +14,7 @@ # along with this program. If not, see . # Exercise reading/writing ZA registers when there is ZA state. +# Exercise reading/writing to ZT0 when there is ZA state available. load_lib aarch64.exp @@ -119,6 +120,22 @@ proc check_regs { mode vl svl } { set last_slice [expr ($last_slice / 2)] set num_elements [expr $num_elements / 2] } + + # Exercise reading/writing from/to SME2 registers. + if [is_sme2_available] { + # The target supports SME2. + set zt_size 64 + gdb_test "print sizeof \$zt0" " = $zt_size" + + # Initially, when ZA is activated, ZT0 will be all zeroes. + set zt_pattern [string_to_regexp [1d_array_value_pattern 0 $zt_size]] + gdb_test "print \$zt0" " = $zt_pattern" "validate zeroed zt0" + + # Validate that writing to ZT0 does the right thing. + initialize_1d_array "\$zt0" 255 $zt_size + set zt_pattern [string_to_regexp [1d_array_value_pattern 255 $zt_size]] + gdb_test "print \$zt0" " = $zt_pattern" "read back from zt0" + } } # diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c index 9bc3e9c16fc..8f0827cf83a 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c @@ -34,6 +34,11 @@ #define HWCAP2_SME (1 << 23) #endif +#ifndef HWCAP2_SME2 +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#endif + #ifndef PR_SVE_SET_VL #define PR_SVE_SET_VL 50 #define PR_SVE_GET_VL 51 @@ -152,6 +157,27 @@ initialize_za_state () __asm __volatile ("bne loop"); } +static void +initialize_zt_state () +{ + unsigned long hwcap2 = getauxval (AT_HWCAP2); + + if (!(hwcap2 & HWCAP2_SME2) && !(hwcap2 & HWCAP2_SME2P1)) + return; + + char buffer[64]; + + for (int i = 0; i < 64; i++) + buffer[i] = 0xff; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize ZT0. */ + /* ldr zt0, x0 */ + __asm __volatile (".word 0xe11f8000"); +} + static void initialize_sve_state () { @@ -271,8 +297,8 @@ static int set_svl_size (int new_svl) 0 - FPSIMD 1 - SVE 2 - SSVE - 3 - ZA - 4 - ZA and SSVE. */ + 3 - ZA (+ SME2 ZT0) + 4 - ZA and SSVE (+ SME2 ZT0). */ void enable_states (int state) { @@ -293,6 +319,7 @@ void enable_states (int state) { enable_za (); initialize_za_state (); + initialize_zt_state (); } else if (state == 4) { @@ -300,6 +327,7 @@ void enable_states (int state) enable_sm (); initialize_sve_state (); initialize_za_state (); + initialize_zt_state (); } return; diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl index 0a9eae7dc5e..a1553deaab3 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl @@ -90,10 +90,12 @@ proc test_sme_registers_sigframe { id_start id_end } { # Check the value of SVCR. gdb_test "print \$svcr" [get_svcr_value $state] "svcr before signal" - # Handle SME ZA initialization and state. + # Handle SME ZA and SME2 initialization and state. set byte 0 + set sme2_byte 0 if { $state == "za" || $state == "za_ssve" } { set byte 170 + set sme2_byte 255 } # Set the expected ZA pattern. @@ -160,6 +162,15 @@ proc test_sme_registers_sigframe { id_start id_end } { # Check the value of TPIDR2 in the signal frame. gdb_test "print/x \$tpidr2" " = 0x102030405060708" "tpidr2 contents from signal frame" + + # Check the value of SME2 ZT0 in the signal frame. + if [is_sme2_available] { + # The target supports SME2. + set zt_size 64 + gdb_test "print sizeof \$zt0" " = $zt_size" + set zt_pattern [string_to_regexp [1d_array_value_pattern $sme2_byte $zt_size]] + gdb_test "print \$zt0" " = $zt_pattern" "zt contents from signal frame" + } } } } diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl index 69c70ae87b3..0f0045cb827 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl @@ -17,6 +17,7 @@ # - Printing ZA registers when there is no ZA state. # - Setting values of ZA registers when there is no ZA state. # - Validating ZA state is activated when we write to ZA registers. +# - Validate that reading ZT0 without an active ZA state works as expected. load_lib aarch64.exp @@ -89,6 +90,17 @@ proc_with_prefix check_regs { vl svl } { set expected_size [expr $expected_size / 2] set elements [expr ($elements / 2)] } + + # Exercise reading from SME2 registers. + if [is_sme2_available] { + # The target supports SME2. + set zt_size 64 + gdb_test "print sizeof \$zt0" " = $zt_size" + + # If ZA is not active, ZT0 will always be zero. + set zt_pattern [string_to_regexp [1d_array_value_pattern 0 $zt_size]] + gdb_test "print \$zt0" " = $zt_pattern" + } } # diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c index 694de0626d2..71b46b17855 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c +++ b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c @@ -33,6 +33,11 @@ #define HWCAP2_SME (1 << 23) #endif +#ifndef HWCAP2_SME2 +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#endif + static void enable_za () { @@ -131,6 +136,27 @@ initialize_za_state () __asm __volatile ("bne loop"); } +static void +initialize_zt_state () +{ + unsigned long hwcap2 = getauxval (AT_HWCAP2); + + if (!(hwcap2 & HWCAP2_SME2) && !(hwcap2 & HWCAP2_SME2P1)) + return; + + char buffer[64]; + + for (int i = 0; i < 64; i++) + buffer[i] = 0xff; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize ZT0. */ + /* ldr zt0, x0 */ + __asm __volatile (".word 0xe11f8000"); +} + static void initialize_sve_state () { @@ -190,8 +216,8 @@ initialize_sve_state () 0 - FPSIMD 1 - SVE 2 - SSVE - 3 - ZA - 4 - ZA and SSVE. */ + 3 - ZA (+ SME2 ZT0) + 4 - ZA and SSVE (+ SME2 ZT0). */ void enable_states (int state) { @@ -212,6 +238,7 @@ void enable_states (int state) { enable_za (); initialize_za_state (); + initialize_zt_state (); } else if (state == 4) { @@ -219,6 +246,7 @@ void enable_states (int state) enable_sm (); initialize_sve_state (); initialize_za_state (); + initialize_zt_state (); } return; diff --git a/gdb/testsuite/lib/aarch64.exp b/gdb/testsuite/lib/aarch64.exp index 031ffa68373..84189976663 100644 --- a/gdb/testsuite/lib/aarch64.exp +++ b/gdb/testsuite/lib/aarch64.exp @@ -319,6 +319,18 @@ proc check_sme_regs { byte state svl } { gdb_test "print \$za" $za_pattern } +# +# Validate the values of the SME2 registers. +# +proc check_sme2_regs { byte } { + # The size of the ZT registers should always be fixed to 64 bytes. + set zt_size 64 + gdb_test "print sizeof \$zt0" " = $zt_size" + # Check that we have the expected pattern of bytes for the ZT registers. + set zt_pattern [string_to_regexp [1d_array_value_pattern $byte $zt_size]] + gdb_test "print \$zt0" $zt_pattern +} + # # With register STATE, vector length VL and streaming vector length SVL, # run some register state checks to make sure the values are the expected @@ -333,6 +345,9 @@ proc check_state { state vl svl } { # # The SME (ZA) register is initialized with a value of 0xaa (170) for # each byte. + # + # The SME2 (ZT) registers are initialized with a value of 0xff (255) for + # each byte. # Check VG to make sure it is correct set expected_vg [expr $vl / 8] @@ -367,6 +382,35 @@ proc check_state { state vl svl } { check_sve_regs $sve_byte $state $vl $svl # Check SME registers check_sme_regs 170 $state $svl + + # Check SME2 registers + if [is_sme2_available] { + # The SME2 ZT0 register will always be zero, except when ZA is active. + set sme2_byte 0 + if {$state == "za" || $state == "za_ssve"} { + set sme2_byte 255 + } + + # The target supports SME2, so check the ZT register values. + check_sme2_regs $sme2_byte + } } +# +# Return 1 if SME2 is available (meaning the ZT0 register exists). +# Return 0 otherwise. +# +proc is_sme2_available { } { + # Does the ZT0 register exist? + gdb_test_multiple "print \$zt0" "" { + -re " = void.*${::gdb_prompt} $" { + # SME2 is not available. + return 0 + } + -re " = {.*}\r\n${::gdb_prompt} $" { + # SME2 is available. + return 1 + } + } +} From patchwork Fri Jun 30 13:48:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 71921 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 817ED388200B for ; Fri, 30 Jun 2023 13:51:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 817ED388200B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688133112; bh=9v1Vbv//ndlYgo1/M287BdBKVTG5TnmczxCBzx8P0Mc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XWvonjvZG0Boz+LzREh+ycKAh1bGTZbipfTZtK+GxZpfs+uOexqKQQs1TRtIMlDI+ YoKRQHRm9/OZ1khwcHb+A4Uy6gmydXZ6gmZ9dvoK29IsjjHQcRxE7Pol/11OfEkoNG EIYQ3ZVodYUd5wI/a9isZgb2Su4h/dr0Q/g7CRBg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2044.outbound.protection.outlook.com [40.107.7.44]) by sourceware.org (Postfix) with ESMTPS id A1B2A3883029 for ; Fri, 30 Jun 2023 13:49:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1B2A3883029 Received: from AS8PR07CA0057.eurprd07.prod.outlook.com (2603:10a6:20b:459::34) by AS8PR08MB6152.eurprd08.prod.outlook.com (2603:10a6:20b:298::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:49:03 +0000 Received: from AM7EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:459:cafe::c1) by AS8PR07CA0057.outlook.office365.com (2603:10a6:20b:459::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.10 via Frontend Transport; Fri, 30 Jun 2023 13:49:03 +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 AM7EUR03FT041.mail.protection.outlook.com (100.127.140.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:03 +0000 Received: ("Tessian outbound 52217515e112:v142"); Fri, 30 Jun 2023 13:49:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 333c70093e195f15 X-CR-MTA-TID: 64aa7808 Received: from efffbc587a03.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 39934167-A88D-40BA-8DC7-ACDF8DE1D4B6.1; Fri, 30 Jun 2023 13:48:56 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id efffbc587a03.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:48:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZDO2e240Ctbd5698uhAOeDWZCDd10r3scwdbFipbLrHk+sGLh4kYShHZN1336/wG3KbU2zdyG3YkBT4H+f25DEVTK/xPk0RXfcvGmR69u/QW+6RHZd1xlHmChqhoONznnzMjZGT6qT0WufjEkvc7kn+na5U8wPo6XpQb07luhvVxh5tRrkqtvP4f69IPWsi/CyEKBWfT8whG5c7bHXIduuRW/9A33N+SihmSbKIPDweAz5J5QzAb1l7Kj+S39weNYu4spT8YjEG/URJZgWZ5YCYvs0kdHhyHb+nRlXbH5FUQt5MYZbtncf8WQLk/cQ9R24pkpOEqgrGkiKKnWdrnyQ== 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=9v1Vbv//ndlYgo1/M287BdBKVTG5TnmczxCBzx8P0Mc=; b=mxKyj0P356wYkfzPbP11RYsUXQk40Mq390tyrsjJtprGzBD6C48fM+viCouMRc+Nb/o2dBQ1vtSHYpwlAX+RPiXoiIsliENRmnyjUrfwO6wcA3IMJlFB3rH4M0VvY+FgCqZZIki1p8+M6cfBvJYSK8+jDs7ZzC1gr7M74q+HsAWH2D6I5sYceSigVW9uUmD98rexICoDlIETfoEiV4aXtsIVyiaGzjZDtW4Yrzi37sKmBonEx1G4erJfc+ApWZ+S7yxrM/MXzUq9KdwVNRoNVOP3p1ezu5n9C2Y0rTn+wURZGA/7b7+5yRntEZcURLWKIe50/ETu8TQDUowCP13Avw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.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 DB6PR0301CA0082.eurprd03.prod.outlook.com (2603:10a6:6:30::29) by DU0PR08MB9909.eurprd08.prod.outlook.com (2603:10a6:10:403::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.35; Fri, 30 Jun 2023 13:48:54 +0000 Received: from DBAEUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::c7) by DB6PR0301CA0082.outlook.office365.com (2603:10a6:6:30::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:54 +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 DBAEUR03FT029.mail.protection.outlook.com (100.127.142.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:54 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.27; Fri, 30 Jun 2023 13:48:54 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:48:54 +0000 To: Subject: [PATCH 6/6] [gdb/docs] sme2: Document SME2 registers and features Date: Fri, 30 Jun 2023 14:48:44 +0100 Message-ID: <20230630134844.1238445-7-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134844.1238445-1-luis.machado@arm.com> References: <20230630134844.1238445-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT029:EE_|DU0PR08MB9909:EE_|AM7EUR03FT041:EE_|AS8PR08MB6152:EE_ X-MS-Office365-Filtering-Correlation-Id: cbfb3924-8ceb-4169-7106-08db7970c43a 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: ZXVSxwKFWwAY2QdD6IVqJouiFaqhx0HfCaznnxJyts1soh2IsN9USs1Nz6BRGM06pyeKpa0s1bEr1WCnOmOr15uXbmjp2vKFn/jC8Fz8I20uqls8GFQbB16/5l30LWr2XBoPUQY5vtALIZ0hnopd78oPNGETsk+CTC8XdMTpmTRLH7Km4gbr1LNp0LZw4xv+G/MZ2ALIIv1TgL1LTORIdpMNSTX9bWFG/7zk+dfk8W6QIA68sqzGMBFcxoI7ErzAekjqdhSI9B1nmiGNuQgQ9NivIKr40/Jws2RKxBIlJkWSUEFhQseTe8Z13hPRtulBvGLzFssxV2lgzUG9BUOOCJd6+PcOq1hRmMvzZoWeirlPteRpe2vopSnrxxyyGlS03mSTLl7vtQELf6w8/vRUjV4xpEo7ghJO4C/t7WmwG1D8kiMtVZIsfpVqRGqP+kROMR06Lkoavwwbn5mjoAdgbd67GYYjRHSrtkrqpwSW2jwWaV3xr0onC55/G7ArIM87ySgHOX6vht25nau9IwE/nKPxRpMu/LQwI2vk4oATURHlJ/RwwywiUQojPtJF9Ws+rItxmupOOH2pVWKj/RrPfA/+EPz+ysEAd9+iiNAwJnGvjjCC5fYq5Q0IX/XON3dl6Pu5Y6OhQFe5gP1ZoTbVYruevMoVD/aOTf6PAeGYYxtZ0qwJVq0ft5HRqlvZ9hW5pBb21GQclIT5VtWtw1oao6Y1XbbkLwx8TJTNkAhPcK5fCfwArNeXxYw3/geLFdB9b3v/rBtZ1G0lTw7dxiSM7Q== 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:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(40470700004)(36840700001)(46966006)(44832011)(5660300002)(6916009)(478600001)(70206006)(316002)(36756003)(70586007)(8936002)(8676002)(2906002)(6666004)(26005)(40460700003)(36860700001)(41300700001)(82310400005)(7696005)(186003)(40480700001)(426003)(336012)(47076005)(1076003)(356005)(86362001)(82740400003)(81166007)(83380400001)(2616005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9909 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8220e9b0-8bad-4ac8-212f-08db7970beef X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 479PtWWTjyu/ey3pdsxhszyspYk9O/WLTH2+h4Iy4OfugzTNlsqsbkinP8kGcTRk/V0on1Phy6uMUsMQEQUgL5cF90edOfV3B7+tXMXUtIVyJ/iyG/LaQtQh9qnVeDu0xp8eOvhBeoooXdhXLjOEU/ozicH9wCBWaqQbySwC4/FJR1bXZ5CaDnA7doX5pGgbfIQmbGJN1oIKz05EbrDGa5cB4c3cM51VEkbVXteLAaQcDwArfEJB6Qxzl+MI+ncSmCaWpdByFIlGw7xZZOOcKThhtKoG2Dbv/f8lm7+dCjLaB+kNARqNoJ8YfuHmbN68tMZqTSHMm9V8bynhnhA/N8fsdESdadsxJiBI+A0sdYjIF7IJMrTQLri3hMwCkblsnd9cvw9emVD9dxSPH8gAN06Meo8uhC2Luxfv788fIRxX2M1t4yPlwX7uxZdCF9wdkhsX6pug3D2jJsEyEOwGfg5s+x+dcWofA+hrTTE/088oL0cXZuMnqvce9OJk5m/3S2I71tS6P0YHVSjCUAfBJfBnoEen4Dfn2tLQIr95cp/1J45o7s2Tos1WNoWKKLmRKvR1QPRT5ear7iiyCe8P2t6ZPrkdyLBHZMlSKxiIrokJOJU5f9BOMUgwqm2mSOojsoIhwXOnCPwDdjBBVSLPYIR9W776vHaif8Kl4w7wpZYuTl2U/GBkZgAbWOlr6ab3+OWJ/D6deefEE3kJWkyyRI9s2z/neNqUkkk/S9Zpf8Y= 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:(13230028)(4636009)(376002)(396003)(136003)(346002)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(40460700003)(41300700001)(316002)(47076005)(83380400001)(82310400005)(86362001)(336012)(36860700001)(426003)(186003)(26005)(1076003)(44832011)(2616005)(2906002)(82740400003)(81166007)(40480700001)(5660300002)(36756003)(8676002)(8936002)(70586007)(7696005)(478600001)(6916009)(70206006)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:49:03.7894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbfb3924-8ceb-4169-7106-08db7970c43a 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: AM7EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6152 X-Spam-Status: No, score=-11.8 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, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Document changes introduced by gdb's SME2 support. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 3 +++ gdb/doc/gdb.texinfo | 65 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 720008a5d97..3ab9ae4765e 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,9 @@ *** Changes since GDB 13 +* GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which + includes a new 512 bit lookup table register named ZT0. + * GDB now supports the AArch64 Scalable Matrix Extension (SME), which includes a new matrix register named ZA, a new thread register TPIDR2 and a new vector length register SVG (streaming vector granule). GDB also supports tracking diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 758c9632217..6ab14c01cb8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26291,6 +26291,50 @@ incorrect values for SVE registers (when in streaming mode). This is the same limitation we have for the @acronym{SVE} registers, and there are plans to address this limitation going forward. +@subsubsection AArch64 SME2. +@anchor{AArch64 SME2} +@cindex SME2 +@cindex AArch64 SME2 +@cindex Scalable Matrix Extension 2 + +The Scalable Matrix Extension 2 is an AArch64 architecture extension that +further expands the @acronym{SME} extension with the following: + +@itemize + +@item The ability to address the @code{ZA} array through groups of +one-dimensional @code{ZA} array vectors, as opposed to @code{ZA} tiles +with 2 dimensions. + +@item Instructions to operate on groups of @acronym{SVE} @code{Z} registers and +@code{ZA} array vectors. + +@item A new 512 bit @code{ZT0} lookup table register, for data decompression. + +@end itemize + +When @value{GDBN} is debugging the AArch64 architecture, if the Scalable Matrix +Extension 2 (@acronym{SME2}) is present, then @value{GDBN} will make the +@code{ZT0} register available. + +The @code{ZT0} register is only considered active when the @code{ZA} register +state is active, therefore when the @sc{za} bit of the @code{SVCR} is 1. + +When the @sc{za} bit of @code{SVCR} is 0, that means the @code{ZA} register +state is not active, which means the @code{ZT0} register state is also not +active. + +When @code{ZT0} is not active, it is comprised of zeroes, just like @code{ZA}. + +Similarly to the @code{ZA} register, if the @code{ZT0} state is not active and +the user attempts to modify its value such that any of its bytes is non-zero, +then @value{GDBN} will initialize the @code{ZA} register state as well, which +means the @code{SVCR} @sc{za} bit gets set to 1. + +For more information about @acronym{SME2}, please refer to the +official @url{https://developer.arm.com/documentation/ddi0487/latest, +architecture documentation}. + @subsubsection AArch64 Pointer Authentication. @cindex AArch64 Pointer Authentication. @anchor{AArch64 PAC} @@ -48445,6 +48489,27 @@ extensions of the architecture. Extra registers are allowed in this feature, but they will not affect @value{GDBN}. +The @samp{org.gnu.gdb.aarch64.sme} feature is required when the target also +reports support for the @samp{org.gnu.gdb.aarch64.sme2} feature. + +@subsubsection AArch64 SME2 registers feature + +The @samp{org.gnu.gdb.aarch64.sme2} feature is optional. If present, +then the @samp{org.gnu.gdb.aarch64.sme} feature must also be present. The +@samp{org.gnu.gdb.aarch64.sme2} feature should contain the following: +@xref{AArch64 SME2} + +@itemize @minus + +@item +@code{ZT0} is a register of 512 bits (64 bytes). It is defined as a vector +of bytes. + +@end itemize + +Extra registers are allowed in this feature, but they will not affect +@value{GDBN}. + @node ARC Features @subsection ARC Features @cindex target descriptions, ARC Features