From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2082.outbound.protection.outlook.com [40.107.8.82]) by sourceware.org (Postfix) with ESMTPS id F3309385E007 for ; Wed, 13 Sep 2023 10:19:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F3309385E007 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VWQwUJpctbQhDcUQ4j73gR9DeCD5HJSl2d/icrK+Oh0=; b=lclBCMzX+uJpkxBNQKcX+kjPIaekkKyMGBhoL7RvR1trjCCM2Ni/wex8IIpOf80KxW1ZzhhetoEGw9zDoXl4j0CE1woGm/6/pGzOkslRghKN3+/5PWYVnwv08MNhp3cw9l1bwN+OmxgW0IVkmEFI1ZKxwOicYA+YxN+8qj6YFZI= Received: from AS9PR06CA0626.eurprd06.prod.outlook.com (2603:10a6:20b:46e::35) by DBAPR08MB5734.eurprd08.prod.outlook.com (2603:10a6:10:1aa::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.38; Wed, 13 Sep 2023 10:18:59 +0000 Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46e:cafe::d5) by AS9PR06CA0626.outlook.office365.com (2603:10a6:20b:46e::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35 via Frontend Transport; Wed, 13 Sep 2023 10:18:59 +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 AM7EUR03FT004.mail.protection.outlook.com (100.127.140.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.17 via Frontend Transport; Wed, 13 Sep 2023 10:18:58 +0000 Received: ("Tessian outbound d084e965c4eb:v175"); Wed, 13 Sep 2023 10:18:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3fd5f255aa1541dc X-CR-MTA-TID: 64aa7808 Received: from ee0248f5c8d6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B453CE99-A855-4E4C-84BF-0FBB4E8694FD.1; Wed, 13 Sep 2023 10:18:51 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ee0248f5c8d6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 13 Sep 2023 10:18:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D9OU5NPDsiBxDDajReBui3Cpe28cmjyn5lLmQoCtXBkoVgqQPmEhxzQ72tre5DLIBby64uaIucrctjZtq5M6aUtUMCL+xsd2HhPM/1uZnYxrhcEKxsIkdvRd81iEtrOB5Pjh5AnAtg7peV8CM5A2wfrtdUHh3Y9WA9paRsxDSTqJVABwsnn+YQf3DZwuw73A0vp8CQA4nqBxbXI9Urw6oclp62MpW7XR2djmYBxWLoicwnx+XWh4xGf19KlBwbM309m6Fl6dKLLjljHYpfXQUFFfLHLxdr/j3qBC8jdbyUhj3uyuIce5BQSrMWm4l02cvoig5nhf5clFAx0M2K4SCg== 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=VWQwUJpctbQhDcUQ4j73gR9DeCD5HJSl2d/icrK+Oh0=; b=C//Za2TvkMcQPSLJfM2ChG3q4xTBb+FMsdeS15nOvZWkN0ACIFkZO/rQ6G4kpgntslQCji9vjWQhmSihjrqgR/DsQ2oycErj59g1AKkPMFVUISjRq9wBOTaWk+BBXvZeTPJuTcuy9MBqaQOtYHJTSj/VYzcZPlyM2XdUTkPHUN4mNP7lA7QkwOQbidsBJ7myLOt8UTrsRCrww1Bt+GOb7Fn1mo+/rvLEh9PSsuiR856yM+YwyY8ez9LlAPKI/2qzskhRc5vgXcbUY6dRTjbjQdlVUI2GtIQDhTcCkjfjcGzIa0KOjG4F+2D3n5wScn1N/ZKWjB2wC82pJAjzhNveyg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VWQwUJpctbQhDcUQ4j73gR9DeCD5HJSl2d/icrK+Oh0=; b=lclBCMzX+uJpkxBNQKcX+kjPIaekkKyMGBhoL7RvR1trjCCM2Ni/wex8IIpOf80KxW1ZzhhetoEGw9zDoXl4j0CE1woGm/6/pGzOkslRghKN3+/5PWYVnwv08MNhp3cw9l1bwN+OmxgW0IVkmEFI1ZKxwOicYA+YxN+8qj6YFZI= Received: from AM5PR0101CA0033.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::46) by VI1PR08MB5519.eurprd08.prod.outlook.com (2603:10a6:803:133::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19; Wed, 13 Sep 2023 10:18:46 +0000 Received: from AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:16:cafe::f9) by AM5PR0101CA0033.outlook.office365.com (2603:10a6:206:16::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:18:45 +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 AM7EUR03FT061.mail.protection.outlook.com (100.127.140.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:18:45 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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; Wed, 13 Sep 2023 10:18:45 +0000 Received: from e129171.arm.com (10.57.66.200) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Wed, 13 Sep 2023 10:18:45 +0000 From: Luis Machado To: CC: Subject: [PATCH v4 4/6] [gdb/aarch64] sme2: Core file support for ZT register set Date: Wed, 13 Sep 2023 11:18:38 +0100 Message-ID: <20230913101840.179101-5-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230913101840.179101-1-luis.machado@arm.com> References: <20230913101840.179101-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT061:EE_|VI1PR08MB5519:EE_|AM7EUR03FT004:EE_|DBAPR08MB5734:EE_ X-MS-Office365-Filtering-Correlation-Id: f6051c6a-dad2-44f7-2989-08dbb442d820 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: IGWcNGfzcP7Z1KPV/o/c314ri+twlLzHZ2BLtjn8iGr9CC/Jz0C9mCJ+Mk06b1ybQyVfbmk77UuLy4cVE2YpiubjzuxcDSEtn6cEOn5ams1Oobuf3R4F/DbvCOvnDdkgwuy/ks/synFjvcguePxPSFiJAYkmd8xkf3Odfbbs1L1lFRcUq+AZ74EEvBtsS67cJ5fakR3zXa6Ruc1d7eIoBEr7OGK9ij2LgabE9HiC17a9KNM+eOrZMYBsw1DWRcbXgdB7MUCEPLkeGnpg40SyW8bMhm+OI4PpR7BzhjBe3fLNSYrnW/LT/PZSTXId2g4oREo+EnTtbItfFNtEFdo6jeFE5vFeRAdnST8Io8+2+yAy3AadxcjbTX9B1gE0PEoRjHrVxR3CHBGHOZcQKbbMCUBvFQEZAEeCtn98qlpUMKgutfgIn30jezGreDcxbfO77CISbSn1mWwkz3f9RyeeaJ88rbszi+9pjmirPnBrxzEd/irNoaI5VYUP8Yb8Y6/7clJB1ziDUGZM0vKAi1XWaE0qA4fIndNp5z97YJdHy8DhTH+MOEba/Uq8jxVMSNtchwTpowZi/00sj/IOQ+4MX9SeYKwq+VNAJ/9GoVRNvCmXHWnuKAwGXIMsln765zhIjXoXs7L2jTHgWu/l3cM7dReHwxndfDIb/YIUuvtB2oD2PaT8nm6X2VHxis/knpiH7ZW49fvAEFLtMoLheXZmm2A9IqSmulOuMr8T5HEd9HE2zGXWbHuyuYZcZkXr7Yx/ X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199024)(1800799009)(186009)(82310400011)(36840700001)(46966006)(40480700001)(7696005)(6666004)(478600001)(36860700001)(47076005)(81166007)(82740400003)(356005)(2906002)(83380400001)(336012)(426003)(1076003)(2616005)(26005)(36756003)(86362001)(70206006)(6916009)(316002)(41300700001)(8676002)(4326008)(70586007)(8936002)(44832011)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5519 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 38bb5ccd-dd29-4d11-4f96-08dbb442d05e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uyJJhXeOvoSAMbbXhvMCiCnKKJmO4g/XkJjk+N1V0GCfK8DXXO+qV1T8kIKZNpDdqJPCtnt8sFbEGO9+W6ig5hesBPkzzuF34tlmwqjmubc5t+Y514t3vsL0AME0PHGXQbXvdYxljqwi2AMk1Wdew806kaGNtM9jjdvEY0iQPTI8kwU4qS0w4sCDc2ev2S0Z21bD+eWrRnSTl1Q7PI/G6owR5enEvrLgCCA9TmpVhkjBYRD7leS887XH0dsHxdhejXUkgPFe/FnJbXpmjAUcTs9jvvx3B3JsJSoU8xewb9okyHOVI00XaWNidglL2LRxqjNGU+Ti6AoRfUEmrnR7KypCZI7ecuzWB1qbYWx7pnAwXjXxPovI+iQKfN9AKFgZqot68R+xICMJfMdJ+eZfVYUkJ7FeEVJ40jGXwkop/xDMGMRoHHvl5HD3GJFXOaYAfXAItaUkDv9vyubSt6AON/THbNovmZa/Wo9U3PiKeZH5/bP+YODxo8HAZ5QmtBUVqMqABgtbt8xfAarHk0TODmmbJvjVqxH1zFYDHoEVjqOSOrcSR/A3PT4yLzOSqG0T3XY83qFleIVTlWliVPiZ0UcNCo8lRSy/PkmjiNAKAUfbcjUT1LRWg3FFXmOew+DE6YsPaMgLgTzCEaFVMNUVSF9vQms0AvuK/UgiQEFnTALSt1H/Iox/4Ab5FpQs3CQEbQp+4JKKZSVgD/ka/+VsSDajgK2pS0BLqK8V4QSCiqB9Og2dE/z36tQuFAszOdse X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(396003)(346002)(136003)(376002)(451199024)(186009)(82310400011)(1800799009)(40470700004)(36840700001)(46966006)(8676002)(4326008)(8936002)(86362001)(40480700001)(44832011)(5660300002)(40460700003)(2906002)(36756003)(83380400001)(426003)(7696005)(81166007)(336012)(6666004)(82740400003)(478600001)(6916009)(26005)(107886003)(2616005)(316002)(70586007)(70206006)(1076003)(47076005)(41300700001)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 10:18:58.9416 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6051c6a-dad2-44f7-2989-08dbb442d820 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: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5734 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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: v3: - Assert the buffer size is capable of holding data we need to read/write. -- 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 | 87 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index cc485d4c5b3..eca593179bd 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1373,6 +1373,56 @@ 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. */ + + /* Make sure the buffer contains at least the expected amount of data we are + supposed to get. */ + gdb_assert (size >= AARCH64_SME2_ZT0_SIZE); + + /* 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. */ + + /* Make sure the buffer can hold the data we need to return. */ + gdb_assert (size >= AARCH64_SME2_ZT0_SIZE); + 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 @@ -1461,6 +1511,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 ()) @@ -1566,6 +1640,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); } -- 2.25.1