From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2056.outbound.protection.outlook.com [40.107.104.56]) by sourceware.org (Postfix) with ESMTPS id 2830F3853D17 for ; Wed, 13 Sep 2023 10:19:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2830F3853D17 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=ELbwlc5d1Qae9P3rESTyZHwo2+q367Po762Kf4FUWkw=; b=mO/eWUo4MMY6Anrdg7r9v0D+9uQlkDyaiS8QX7dfdFbDpKgcoU72qXNR7/eYpO10wOgDAkyS08vgEsEflNDH5JSs4LUQUhimugqXe0BlKLJYKb0Jd7i7YRYg0ooMje3sNt1Shj23h3woItl7i2txC9AEq3PaLdjoR/AA1lJWTuc= Received: from AS9PR06CA0625.eurprd06.prod.outlook.com (2603:10a6:20b:46e::16) by GV1PR08MB7729.eurprd08.prod.outlook.com (2603:10a6:150:50::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Wed, 13 Sep 2023 10:18:55 +0000 Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46e:cafe::6e) by AS9PR06CA0625.outlook.office365.com (2603:10a6:20b:46e::16) 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:55 +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:54 +0000 Received: ("Tessian outbound d084e965c4eb:v175"); Wed, 13 Sep 2023 10:18:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9c3e2e747c6c63c8 X-CR-MTA-TID: 64aa7808 Received: from 4fa353f609b4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D08E2F33-FFDD-4E3B-A67C-0258D063D2B8.1; Wed, 13 Sep 2023 10:18:48 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4fa353f609b4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 13 Sep 2023 10:18:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aAFEzgql1XVqQ4h2CQDXbrNR4/XyCgDcWwEMdNBU1Nax+W/1ChCAkdBiMdG8KSoBDRiTZLy0Fh2AUpfWs2CPVvPPe3uHSohF73o8eRtrv4qCsN170MKWTAsbor3WROrPGcQxBQKbNzkZu4RMF186wENtNQT+X9v+kCq+li8TfRMWnoS55U5kggY5d2MZZqqE/EO31fHmejl0unSaZwwyev1BSMt01RCE8MOG+0L7KqWTzkIzIxBN9FQlU89W4Rlu+d2rDbjTzh1HRmElGqniSTmHdeFKZtK0HL2O59gowyKNhDJy2ScAPJHyq1MefuigzNz0SUL3AAw1anDG5qCWxQ== 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=ELbwlc5d1Qae9P3rESTyZHwo2+q367Po762Kf4FUWkw=; b=oVdVIXysQEPr4N0VzT16eN7Ph7X5ss8UL6HG7teihoj1v8xyS3xOCehnBl9wdfihEIiS6PqhJTaTXudiZBezmD2pckSw/OFAYQx7rQz5dt1fatwxTgAqe0m+jc7xy/YuoUsIYk5oEy5Ve7Ubmh+U0RzLrKqTdoCpWI+GoE7S2uxabEl6winiFkX/Z7M6rvRUF9hodTuxWebj6uaXe5cRLtXouRTeTaLVYfzVcX6g4doh2MACz3LUcmxKwUeLkifZ4oizQiUdFMIS9wF4nlWnBVWwAk6FQ1OSzYYZouvfG+pFF7dtFVIpA61VeVjoz9k2+tyXENlDTc+8bt5XWtXd7A== 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=ELbwlc5d1Qae9P3rESTyZHwo2+q367Po762Kf4FUWkw=; b=mO/eWUo4MMY6Anrdg7r9v0D+9uQlkDyaiS8QX7dfdFbDpKgcoU72qXNR7/eYpO10wOgDAkyS08vgEsEflNDH5JSs4LUQUhimugqXe0BlKLJYKb0Jd7i7YRYg0ooMje3sNt1Shj23h3woItl7i2txC9AEq3PaLdjoR/AA1lJWTuc= Received: from AM5PR0101CA0005.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::18) by AM8PR08MB5713.eurprd08.prod.outlook.com (2603:10a6:20b:1dc::24) 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::cb) by AM5PR0101CA0005.outlook.office365.com (2603:10a6:206:16::18) 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 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:46 +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; Wed, 13 Sep 2023 10:18:45 +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: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 5/6] [gdb/testsuite] sme2: Extend SME tests to include SME2 Date: Wed, 13 Sep 2023 11:18:39 +0100 Message-ID: <20230913101840.179101-6-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_|AM8PR08MB5713:EE_|AM7EUR03FT004:EE_|GV1PR08MB7729:EE_ X-MS-Office365-Filtering-Correlation-Id: 72c9d38e-20e9-4c62-ed22-08dbb442d5b1 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: WzQX5wjLZQgBeHBzn9HTZjOPpkaSnKNVz1IFF5pTW3JAmKcG3gBh/iVJt/hQTuvJmH9werjhTT5xW8a8qd29Kgq/ABDTnY1PXE4wTheaqhPdvFb8LKHbAtNUDDaVdYyP84nY5GcX/oaNUw+VDXCwETGFWeaMChmEH6CPNi0IlardkKXjRx7U+9LeYfNq7d1zx7hl8yB2aohZiGOIvRNDzPFzM5XgoJdZw6w1YXLmx24XFoGIkpdHlgCbw8m/DVBKjDnVQTvOuBRQt/4gT88sqFSG18x1vN1nf+nJ0PSGYAfLyud1ELhmQRwzbFbebjsJVxsiNnI4xl2cvrypkCHjaJU8IZdgXUnfkr2WFm54rzqj+8khXpdFAXhNg2JzkoUUeDnu1AFAm8gFS0GIFSuw8ioN8LRPLhjZOIzeQxrjZOfC2/PpBJM+108ZLmrir8OoL3nOhumOO5slurJmqB62hGLfejMISj+8/LQadIUyOfq1lke/3PgR0kXqZgIozLX2gO18I9YHDnpaq3wt6t5wjBxT5CETw43kQIRLCwT6A7ChV37DCkL4z6gYZhP6m7EPbSMHhuvGUHeBiUVzqA3QrsZ3S3jVLgf9fm6H+28KM5lrrOGLt7+ktJCwxiCcjZLJ1yEgAgfHq0lTh/m+DFu6fmmCO+jTpEzFD3FT0wrHvFIF/2bB6CAIxW61lWZTSU+f33koc4pJ6EbdhaXm78efqHNKClIPfBt1+gKIBJ5lJQ/YIIumxuk1AmhBccLN/1YyzDHfk86C3pygpXZ3h2pJpQ== 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)(376002)(39860400002)(136003)(396003)(346002)(1800799009)(186009)(451199024)(82310400011)(46966006)(36840700001)(40470700004)(6666004)(7696005)(40460700003)(36756003)(86362001)(356005)(82740400003)(81166007)(40480700001)(36860700001)(26005)(1076003)(2906002)(30864003)(336012)(426003)(2616005)(478600001)(83380400001)(5660300002)(4326008)(47076005)(8676002)(41300700001)(8936002)(70206006)(6916009)(44832011)(70586007)(316002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5713 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 980aa0af-c6f5-42fc-d6aa-08dbb442d086 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NW+4CgsLExIf9/oLJUjVDUZNnfrtXLL3gkLuOvuUto68yu7aqfxmFjGt52hz/Htu9r+ozCX2Qhvr7HEsio1Q6u6PBunebODq6KsmX5aUDiTKQMhz3eEUc80WTocQFqrWwKFBT1TsxO1l4G7/Xzy5pBGE2H07pDOZpcVYZP2hwngeS7SBFP/quPkUDbO5nNHUv8wm2BPxMvyw2EslT+9vuviwtN1qLxG5omnFPHBjM8SG6uI7nd+zMcY8/cDeQrGZSnbMCrMUHN9rUvNBmwwjmv556qutwsa4QeVGdA6cVb1DRglrv5Ofz1ScP9xtNTW3niO7lebbdYQjdpB8bM+NXKz5pdFZIQTqOnZCqKQ0vU3E5kPnVJJTdtm7P12TrmFHSNWqSatNrDZYIoC9+Y+k1rR3SD5h0+KnqFhLv9Lw4UQlE1uSVai9dBPTPTbA5/dL1QbeYyaN8UcjyTJZIP9pfo39IM4wdqF+GTWMV2NBjS1xpASjcitnBgFWkOb9oY8zF4U6x6PSFNSzvRuG6P1zVZe4cMM+nMCPXbS+zQuvHd1j9PSLdagAT0adz+tIjTVcmMbhXBNPil74rjVx/Yjmez1lieCFPUgR9vQTRPzl2fHnvl2wPnh8Wc5VBplTURuINVerngF0XLxaRaBu2aKyyCzIQ9/3+aWKSRPGRduMwRWQqs0Wo5Pg0Klw+LndQbjL/F0vFdGrLqQa9QeaFFCjYHQNWnSrxJvJB82lVGbtWM0= 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)(136003)(346002)(376002)(396003)(451199024)(82310400011)(186009)(1800799009)(40470700004)(46966006)(36840700001)(2906002)(70586007)(6666004)(47076005)(36860700001)(7696005)(478600001)(70206006)(44832011)(83380400001)(40460700003)(26005)(336012)(1076003)(2616005)(426003)(30864003)(8676002)(107886003)(5660300002)(8936002)(4326008)(6916009)(316002)(41300700001)(36756003)(40480700001)(82740400003)(86362001)(81166007);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 10:18:54.8324 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72c9d38e-20e9-4c62-ed22-08dbb442d5b1 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: GV1PR08MB7729 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,KAM_DMARC_NONE,KAM_NUMSUBJECT,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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: - 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. --- 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 35e3d981e10..d387dd11a0e 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 ad3f0ee1dcc..74aeeb46684 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 c2962417f70..30c7adb4db6 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 41d65c523f3..402996826b7 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 + } + } +} -- 2.25.1