From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2064.outbound.protection.outlook.com [40.107.20.64]) by sourceware.org (Postfix) with ESMTPS id 01BEF385B537 for ; Wed, 13 Sep 2023 10:18:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01BEF385B537 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=q5vrj8ktj432r0ugimtXonRWp3o8W6iKhIYZKJ+/G0w=; b=dNRIWAcvdcaH7N6aVdlBI6eQFm56R+GuCdJN+Ylp+GUyvecMonGfpmXB4BjP4SUCtytDAmGRUfqMoAABBhrccb6uLDxdHybu2gcDn1sBySYS/Gft0bED8tD9s3kUc8sLxlXpNIShcjeX0gOyrh+2wD+JvcKUPL3f/bAfjeazBZ4= Received: from AS9PR05CA0103.eurprd05.prod.outlook.com (2603:10a6:20b:498::34) by AS8PR08MB7941.eurprd08.prod.outlook.com (2603:10a6:20b:539::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.37; Wed, 13 Sep 2023 10:18:56 +0000 Received: from AM7EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:498::4) by AS9PR05CA0103.outlook.office365.com (2603:10a6:20b:498::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.37 via Frontend Transport; Wed, 13 Sep 2023 10:18:56 +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 AM7EUR03FT052.mail.protection.outlook.com (100.127.140.214) 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:56 +0000 Received: ("Tessian outbound 169aaa6bf2b7:v175"); Wed, 13 Sep 2023 10:18:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 054a587ba2d9b32d X-CR-MTA-TID: 64aa7808 Received: from 3df79dd8e722.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 25BBE7C8-0445-4A31-AD2C-2A9539FECA8D.1; Wed, 13 Sep 2023 10:18:50 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3df79dd8e722.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 13 Sep 2023 10:18:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wrivz/LZdlU6J+a9cYE/VaT9GokTfbuB9tPPEknoGpcGSjW998uxizlQQqxpAwOUPE+dbYnrIGcEVzy14MNZ0tN1p6LeyabrQu28ZofjAeJf/COtQ4tyw0KUw2xasJmNvXNzLoEUSVvO/JM/dRVYt+d+JArhBKS0/1vuBajSeZnf7GvXbZnaUTc6VsWLOYSnVyBDlW8JAnbJ/owBTLUd7VulvuD5Q0IDpTR8OmgTpGlMfHoElsVnmF9NIv5nr5LwV0F3FKw+mKhhEepnyKFzfZIy8aeD1N8swZeq/1VJ3lFW67d0XEj87R423+xeM4JYqSthIpmKXvPXDyWqZOf6ZA== 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=q5vrj8ktj432r0ugimtXonRWp3o8W6iKhIYZKJ+/G0w=; b=EZOJoKC+uXNNHsOGi6BLX6aTkFsJShTy8YX3lldNmqigyLfIx8UHvVAOM8wVdLzLIGwLwpkrFSX7InQRl9JCKaur5f3NzMvx6GDRORKyfoommeTMRh6xOcoALvNCRl94+HXnmeZVSRGDquhO301yzHuOzNhknw3/ZVqJMkRXTbFwM/xDd2V2kIfKaRii/Q26iCQsW7YnxDrksLDkr8qR68joEt02B0znxGgtrbkMf83mKC5LURK3BzBOHDTik6sqEQ2t9wrAhCqEZhmspXrd3ughthP+OJi7AOCQ7BtIsKwhJmsWXAOvn12HlV8nPM4b6pFttpcM1eIGLOwIteSFRQ== 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=q5vrj8ktj432r0ugimtXonRWp3o8W6iKhIYZKJ+/G0w=; b=dNRIWAcvdcaH7N6aVdlBI6eQFm56R+GuCdJN+Ylp+GUyvecMonGfpmXB4BjP4SUCtytDAmGRUfqMoAABBhrccb6uLDxdHybu2gcDn1sBySYS/Gft0bED8tD9s3kUc8sLxlXpNIShcjeX0gOyrh+2wD+JvcKUPL3f/bAfjeazBZ4= Received: from AS9PR05CA0064.eurprd05.prod.outlook.com (2603:10a6:20b:499::14) by AM0PR08MB5505.eurprd08.prod.outlook.com (2603:10a6:208:18e::11) 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 AM7EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:499:cafe::ff) by AS9PR05CA0064.outlook.office365.com (2603:10a6:20b:499::14) 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:46 +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 AM7EUR03FT045.mail.protection.outlook.com (100.127.140.150) 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:46 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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; Wed, 13 Sep 2023 10:18:44 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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; Wed, 13 Sep 2023 10:18:44 +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:44 +0000 From: Luis Machado To: CC: Subject: [PATCH v4 2/6] [gdbserver/aarch64] sme2: Enable SME2 support in gdbserver Date: Wed, 13 Sep 2023 11:18:36 +0100 Message-ID: <20230913101840.179101-3-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: AM7EUR03FT045:EE_|AM0PR08MB5505:EE_|AM7EUR03FT052:EE_|AS8PR08MB7941:EE_ X-MS-Office365-Filtering-Correlation-Id: 21af4102-9aea-42ef-d54c-08dbb442d6a3 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: a0u+xgntN32oT5I5nD0ddWLINij2ZzqO2MovOy4VBtBEssC8D6xN6VX4aX1+9tbjWrUq2XRNhWiGeMRY0tCrrtU3ynRLzvK4/EUaGH/754bT2L3VOtWxXkIdWB3TVrzwaqezK6YTh7/hzFlAjIG1whk5iMt3hpXrII1sLUi+daLJSnJfcm8x0JR5NtKnB5c+vuTgPKW9AZ69L3Xpy0y8r8v3WPOYHDEAg5ZevHQ8c6zT3i3MLp2dDkFbQwd/zpeBUoySgVqf2TRX6DuCuoeV7AX6ywB9fnDlnk4pLh/I6ZZRdzPAZOE+CUJ1d/qllIUqJH9RxicjhAXTI9onHx58sH0/3u7ZaNXFllcvzrtwgAxVPH3qEpKSyy4Cd1Sm48oxniJcmCjkO6S50nCDTGL/kze7PqYZ6qDkqIzaFhpgjbPiBNDFH8GQqrdaHdT0xvO1Og2SVUl7pXmO3HbEr+pvB25f9UUBDAlGsHX/URHWkHvdEMIKRvi0zyTs91uQyq9Dixl6c56DJIQVRfvo8km5wHWdhisOnx1ZZZywasC8OVmOPAOP7BOXVDBgWjGI/aZqcn448ygYJq4wJOsXToIa6Z8PFxep+rjqMIrFkradQfII7R3DChqSHimUahaBFJgHuc4dLKzO30NZMORXXiE8jkuOO1R8+EbIR2P0yngF99HFQzTB0hlK0k2MclDPnSkKy4JMkrvo/gBeDowg4T11GrnkVMccEpxWE/KYi2xSck68sy+jFU0CVSlDhNIPkRxzGNc7QaE2okeEc9n9SpqOJQ== 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)(39860400002)(136003)(396003)(376002)(82310400011)(1800799009)(186009)(451199024)(46966006)(36840700001)(40470700004)(7696005)(6666004)(478600001)(83380400001)(26005)(1076003)(336012)(2906002)(426003)(44832011)(70206006)(70586007)(6916009)(2616005)(316002)(4326008)(8936002)(5660300002)(8676002)(47076005)(41300700001)(40460700003)(36860700001)(86362001)(36756003)(356005)(40480700001)(82740400003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5505 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d6f52865-31f3-43e4-375d-08dbb442d0a7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F3qszXApRRqorQaD7FhQmhZhvZhmGOwd/iAAygiGHIZQ3zSkPR9XKJbsU0MG6cpfcSLclH2yXJnFXz12Qk5NreLvU/fK2Lha7Dv+Bcn/OLtEy7ZKF21DQUxG5mV7l5MwTVPQPaDtML+3BfGDunE87TaMzLviDle+EvpAuPHX594VHYyyQN8TE4toaUs/hQ6WyMZNuzUI8cWuG539hZEaoY3Q/Crlpaxw3gYlOlT1wnootM8UN9oUEgXUUCwWQynswY61YOANgq0TQd/yYMlpGo+WlFYqOWOhTG07TwP3EK9Gmi89Wy8vqwUh6M0rg8Xneoz18xWrhIno5AVTUcs821u4e6QkE5fYK4MNNCXX/qmBcVifyV0pnQIVKHwOZNkvW1PbexPf1fuLh01aV8v/WHHp8rmPK89tmWwK6onJ3V/xHFULSXR4kk9gchPop7kDIYZHrsrYaqQOK+loKHtBzuxckhS5D5xlsysGXtLE454JeIxMoSZWLLO/KHdpp9N2gb1mkNpearpuunD8Z6+0U7HYYn19UCRkGzFRPEJ0aaE96GmI3Nhpb6FZJnTrmRmMLKbABQteR212WTScb3W3+U5rOSNuANSXz6PpxnoBa8b5iw28xB704WilAMK2RcU6uFImPKbJyzMwd3F98NzvXP6aD6rlEKTBDx+VjeeHPkytX3zV/CF/LZFWJzS/j+ASoay2NLmmhZW5haWUK9PZzukvARUwXEfvq9/A16CSJdwU6GRqs2c90CYqF+JyJzsx 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)(396003)(346002)(376002)(136003)(39860400002)(1800799009)(82310400011)(451199024)(186009)(46966006)(36840700001)(40470700004)(426003)(336012)(107886003)(47076005)(44832011)(5660300002)(4326008)(8676002)(8936002)(6666004)(7696005)(82740400003)(2616005)(26005)(36860700001)(1076003)(83380400001)(478600001)(81166007)(70586007)(316002)(6916009)(40480700001)(70206006)(41300700001)(36756003)(86362001)(2906002)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 10:18:56.4334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21af4102-9aea-42ef-d54c-08dbb442d6a3 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: AM7EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7941 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: - Use find_regno instead of find_regno_no_throw. - Changed literal to use ZT0 size constant. -- 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 | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index e887e39b1c2..d9df731fd1e 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -797,6 +797,46 @@ 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); + + int zt_regnum = find_regno (regcache->tdesc, "zt0"); + + /* 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); + + int zt_regnum = find_regno (regcache->tdesc, "za"); + + /* 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. @@ -824,6 +864,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, @@ -895,6 +940,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 = AARCH64_SME2_ZT0_SIZE; + break; default: gdb_assert_not_reached ("Unknown register set found."); } @@ -933,6 +982,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 -- 2.25.1