From patchwork Mon Sep 18 21:27:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 76330 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 83DFF383C9B7 for ; Mon, 18 Sep 2023 21:31:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83DFF383C9B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072674; bh=yCSTnitgciZ1+wToWthHQgVxd6MZEl6/DXie3haVkPA=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=KxcVDP3HISEa8RbMBzoOaLiT/YBZrqWEGuwSL0rShlGTnyEzveuxkKuEMBk9hU/E2 pMJ7kUzujJmrf0KH6J4z5L1/Hnx1G0dbotyEY/Imd9EdBvE8NDO7OTRHBeYxpg7eRw AhxAovK0jyxaf7JEgVCB9bZ1oVSSBTN7F5q7Gauc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2078.outbound.protection.outlook.com [40.107.247.78]) by sourceware.org (Postfix) with ESMTPS id 6F25E3857713 for ; Mon, 18 Sep 2023 21:27:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F25E3857713 Received: from AM6P192CA0093.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::34) by AS4PR08MB7686.eurprd08.prod.outlook.com (2603:10a6:20b:505::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:28 +0000 Received: from AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8d:cafe::ea) by AM6P192CA0093.outlook.office365.com (2603:10a6:209:8d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:28 +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 AM7EUR03FT029.mail.protection.outlook.com (100.127.140.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.15 via Frontend Transport; Mon, 18 Sep 2023 21:27:28 +0000 Received: ("Tessian outbound 30c9f5e988c5:v175"); Mon, 18 Sep 2023 21:27:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d2539744d47b2b87 X-CR-MTA-TID: 64aa7808 Received: from a12335c20551.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 42A5D1C8-864D-4552-8A50-CE1EF5B91D1B.1; Mon, 18 Sep 2023 21:27:21 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a12335c20551.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oU79GlfJg91HrpA2arz8gDQ7z7EfiUV9HXZALSEyM+SIWotW0uN/LqGg7mqDPIM3bqikonmQX67qPPBVIaCIAlLhamro1CtdpNsYRKLxj8iEwV/MoEPzY5kgDdc8c/RtIVkJs6bkYgrXnQxRBEB2+rXL9dDjAHe6wn3ozzTSUvvh1cMcS9scVtNY/EIs/eURE6JnILAVuZ23cbglklVvD5F/wwXB3Ks7HoP6j8PCliPhYo4ISBNUwBM0JcIWH9YmZu/Y60TN/IzjjNPPyhpiOkXnJzvmquuwOiq3fv3jGcqc5baJVYcnTlQ5iU6Phm1gMMz77uT/o8mFKHHjDl5LRg== 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=yCSTnitgciZ1+wToWthHQgVxd6MZEl6/DXie3haVkPA=; b=iueVZDgdMBmvFfMDq6b0QstbTtCQPbpZHxUzgLXikuzk/VEVOgyE/IoZXeb5csLElNTnm8Q+atPqx64yyK0eTz7P+mzoWCOc1C7pFlrzy8VyHALDSwLoRBfA6KOjlEHObY5tzhnW53sjHPyEC47cCCgno4dYSZnrfE4vQ7xr/z0zeXRx3qpF1IqcPzipGPxCMKmqU4w23MwU2AbTFHGKO09XWMwGSPuAR4ebcwExEKMhxw2jolplQKU0g1MduaUVa/+LCSh3wV0oi1DRcEGwQFwwVAd+fOtPDmkEDQWkRJQauCasZo1rTSYkGsVRLvE7y5ksMEiqT9iWD5chBllJKw== 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 AS8P251CA0021.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::18) by DU2PR08MB10038.eurprd08.prod.outlook.com (2603:10a6:10:49c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 21:27:20 +0000 Received: from AM7EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::88) by AS8P251CA0021.outlook.office365.com (2603:10a6:20b:2f2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 21:27:20 +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 AM7EUR03FT040.mail.protection.outlook.com (100.127.140.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +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; Mon, 18 Sep 2023 21:27:19 +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; Mon, 18 Sep 2023 21:27:19 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +0000 To: CC: Subject: [PATCH v5 5/6] [gdb/testsuite] sme2: Extend SME tests to include SME2 Date: Mon, 18 Sep 2023 22:27:07 +0100 Message-ID: <20230918212708.660213-6-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212708.660213-1-luis.machado@arm.com> References: <20230918212708.660213-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT040:EE_|DU2PR08MB10038:EE_|AM7EUR03FT029:EE_|AS4PR08MB7686:EE_ X-MS-Office365-Filtering-Correlation-Id: 61bdc694-79f2-4b45-af84-08dbb88e0f34 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: 1ZexVtYHng+28lacuY/G6ek7taenYplxOneTCPkxX13m9UYMVGMivyuqRFlgLDliKDcolqBc0tMSsNSXaKKBODjPmfYuHon/gz9UMzVMz9weOsL5c+Y3oc8oBFD/E4gOymM5W/5wR42q3mFNDVZqkX2owW0MyJOmmItjjyKGquHwPMIYmjU5btduS2YNluC2iqAkj9Af4Pc0Mj9xlnHfq73ZrgnCDHY4fmCQ/dRlWT1WPpqswjenfXg9vmWuRN2jsu/eJJfuGPR7V9ldz9vrRbsp7qA6bqLEWXtRQ2Y6mKhFqDly5e4RmjEU1CIyBbwg91413+oURlYNZ+LtHYvjNMp9fsiKm+MR/zwTpHIugkE6f9LaeXxljShY4SggROR1gUf+OIGKhNfulsAU8yaR+n09G7B/9cViiSl+dJn6164M7Pn1UU2KMR977vf6iRjt98+ca5ct/z9Qs7w8C4BpRhUB7X4vUOkXXuUx1vili3xOEBQB6W0XDwQKVlsu6/zfH4rnX5v1C5xGkfNY42++mpYp/XizqbzMrMkUZd8KeQDEjlMqZkWqzb9iSw4K43eQ+wpWZXhDrp38xNgajG7S8+aXSpVlr+qIWVyRm0TBMob7UhFJyPPnHzzWKrMn1oJiNfr3IepAdOdmW/A9d2fpMDhlfGkXmDHWmR2Tzu3mq+Ra98GXEnj0oK+XYTi2e+jFeMVQCGe6NdzrQDIz8vXw+tTQCo+nZcQFAMQwPfBSlyc= 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)(39850400004)(136003)(346002)(376002)(396003)(1800799009)(186009)(82310400011)(451199024)(36840700001)(46966006)(7696005)(6666004)(83380400001)(82740400003)(356005)(81166007)(86362001)(36860700001)(47076005)(36756003)(2616005)(426003)(336012)(1076003)(40480700001)(26005)(30864003)(70586007)(6916009)(316002)(70206006)(41300700001)(2906002)(44832011)(5660300002)(8936002)(8676002)(4326008)(478600001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB10038 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b746dd61-2962-4b10-ccf5-08dbb88e0a48 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u7NyDS/rLdSlA7bxBd7RvVxmkyG5PAlu6776tB+xMprWBkKkNMsYAltXHrSIBTsLWxcRWnAaBNl5pJ3ahUVcaHOnnEyRk20i7935NOdh2jWIfre9ZUzpJiyK/1B4XpKPnvAeE9RG0/LObVEXqSzt5npUT680ruurY5fn+gKtVAHzkZLlpXHYuGMWKkk/3A+oFamLx0MMmUdg077USPJyBCap2fRKrgu5PdNI7IzUWLtbJKvt/XSZPjphQGnNYHCoW8xaNqa2zTxJPAmp8CHHnGfDIAgTVVJaXL/IsGqBkPuB/ShReXM9dHpORE2OznRIE4g0EFgPdcY11s4TNIAH21rx2WyqguF3OTGJMCTadPItRSPBTzWLmKPJX7xJZm4C4YtLm8KDd8tLovDdOXLw6vY76WUFXfJ+C6kjW1Q/tAx7F4Wjj2rTh9n6bYZnlfKZA2KYuhmN1/fhot8Bct8ziM6ew7My1DBs+LjfIJw5qDcHIhA86wja0XGcaO3Eka7aT9OZDEZYkRKW2wq80ssowpy6H3fuKhO8h8KEzkn0ce05Q14x6eYOPLkZiPC0/KgI0Qec8NDVOhaWXTL2ZB4NI0Ju433c34SFz8LtDWS4xOyKYTUol6/ZP6ditDzcp2A8aJ4ltmBPkwtZTUMOm3slDQA95hZmWPFTigs6c6vzZ2aEgFv8FljDXflku79O30gtgP+AD9zFED6xuk2qLm1ql5rwkd5a8Stmp1uwmGgBbWQ= 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)(136003)(346002)(39860400002)(396003)(376002)(82310400011)(186009)(1800799009)(451199024)(36840700001)(46966006)(40470700004)(81166007)(26005)(82740400003)(2616005)(8936002)(8676002)(4326008)(1076003)(40460700003)(107886003)(83380400001)(36860700001)(2906002)(36756003)(30864003)(47076005)(426003)(336012)(5660300002)(40480700001)(44832011)(86362001)(7696005)(478600001)(6666004)(6916009)(316002)(70206006)(70586007)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:28.2253 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61bdc694-79f2-4b45-af84-08dbb88e0f34 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: AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7686 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, 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.30 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" v3: - Removed duplicate function from aarch64.exp that is already in aarch64-scalable.exp. v2: - Updated to use the new naming/organization of the test support files. --- 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. Reviewed-by: Thiago Jung Bauermann --- 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-scalable.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 851e6e31ec3..ef76ef94269 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 71637f9cdc1..f62559554f9 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-scalable.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 c062e200edf..e2234c06697 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl @@ -98,10 +98,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. @@ -168,6 +170,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 1a5ebf1cdaa..326d09bdbce 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-scalable.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-scalable.exp b/gdb/testsuite/lib/aarch64-scalable.exp index 5512fcb9d1c..f77daec2308 100644 --- a/gdb/testsuite/lib/aarch64-scalable.exp +++ b/gdb/testsuite/lib/aarch64-scalable.exp @@ -186,6 +186,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 @@ -200,6 +212,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] @@ -234,6 +249,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 + } + } +}