From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2050.outbound.protection.outlook.com [40.107.20.50]) by sourceware.org (Postfix) with ESMTPS id D87E13836E9E for ; Tue, 22 Aug 2023 11:22:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D87E13836E9E 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=Sb+O2hkbTczV+bkP9SXG9IU7TEC8/libZBRB73tct60=; b=7HNDuWl1WzjL/POvieAS5jRvOTse9OMlsUDLHidZCHus5oGxDAqQsnTUikCNog24+93fAgq5yxjiXzAyGDaC7tpJD4Kks1qujdvDls+2xxcthQirohS+lWHLtPrS6Y1dh5ybIrg+pDhidF4cu5ofy9cL3QcbFMO0XkUYZQPcai4= Received: from DUZPR01CA0344.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b8::9) by DU0PR08MB8908.eurprd08.prod.outlook.com (2603:10a6:10:464::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Tue, 22 Aug 2023 11:21:58 +0000 Received: from DBAEUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b8:cafe::ca) by DUZPR01CA0344.outlook.office365.com (2603:10a6:10:4b8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Tue, 22 Aug 2023 11:21:58 +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 DBAEUR03FT042.mail.protection.outlook.com (100.127.142.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.15 via Frontend Transport; Tue, 22 Aug 2023 11:21:58 +0000 Received: ("Tessian outbound 5c548696a0e7:v175"); Tue, 22 Aug 2023 11:21:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e4df24efa6161f67 X-CR-MTA-TID: 64aa7808 Received: from 46864cec6829.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 46E5B8E6-EE4A-491B-8486-627D5B95CA2F.1; Tue, 22 Aug 2023 11:21:51 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 46864cec6829.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 22 Aug 2023 11:21:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LkjLCkhZdtO0ic60LlDArliHeMdNbEp1RzNetsD64Vmk3oRIzfWb9owME8rbPrcVRupa/JdR5PwJqquPBFrLEoCUFpzu2uGanUj/cA5pkpNM0CFmTWa2W6geQO1GwuVm4nsf0U7WlPh7uxsKAnE2KOlp2QPC2quRx6iWkr6PiSqZHe/Ii5b6wgUbin0kTLWYluHY9DNnvd0a7ho8mg8FvckYENLfjL8BM8tBx0SktfXEavhfqPRFVb/uuVVkGkh52x2a//3c83jpd/Q5DrXk0S3LcjsHghXvd6TPwfGh/iqyi5lxWaYwNJkgXMi9BP0+YGZX5BGVie28BgcFlBY9+g== 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=Sb+O2hkbTczV+bkP9SXG9IU7TEC8/libZBRB73tct60=; b=MnUoARlFJMBPbstkqtP0Wk2M26VhPONG5Ik/9y2yw3g5n6o26NGg+31uqh9skl8fs77a0DSmYe9vcnlRuenipYIaf0JuejElx0COIHbsRcXQSRNEAWZW46jGM/DHlAb3UbFu+ydqmU47I67kVoFMQlHgxOxjBQY4lflsyn12VukmamsIKblN6g953+tMegVR/8BkmsRsLzEITUvLhE+jsSPI4cgIZpY1fTOPmJ/BENd3U6lqtr4MIrxtFyUMDrN5j8M1G35UYQtxnaOr5sW705+zjCQ9NoM3CUT1XOsBprPvMHH+8/+5k87FcN/zNU0otvb+XYcWyJK4WiuLqEVGAQ== 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=Sb+O2hkbTczV+bkP9SXG9IU7TEC8/libZBRB73tct60=; b=7HNDuWl1WzjL/POvieAS5jRvOTse9OMlsUDLHidZCHus5oGxDAqQsnTUikCNog24+93fAgq5yxjiXzAyGDaC7tpJD4Kks1qujdvDls+2xxcthQirohS+lWHLtPrS6Y1dh5ybIrg+pDhidF4cu5ofy9cL3QcbFMO0XkUYZQPcai4= Received: from AS9PR06CA0756.eurprd06.prod.outlook.com (2603:10a6:20b:484::12) by DBAPR08MB5606.eurprd08.prod.outlook.com (2603:10a6:10:1a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 11:21:50 +0000 Received: from AM7EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:484:cafe::c3) by AS9PR06CA0756.outlook.office365.com (2603:10a6:20b:484::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Tue, 22 Aug 2023 11:21:49 +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 AM7EUR03FT034.mail.protection.outlook.com (100.127.140.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6723.15 via Frontend Transport; Tue, 22 Aug 2023 11:21:49 +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; Tue, 22 Aug 2023 11:21:46 +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; Tue, 22 Aug 2023 11:21:46 +0000 Received: from e129171.cambridge.arm.com (10.1.34.58) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Tue, 22 Aug 2023 11:21:46 +0000 From: Luis Machado To: CC: Subject: [PATCH v2 3/6] [gdb/aarch64] sme2: signal frame support Date: Tue, 22 Aug 2023 12:21:41 +0100 Message-ID: <20230822112144.1513268-4-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230822112144.1513268-1-luis.machado@arm.com> References: <20230822112144.1513268-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT034:EE_|DBAPR08MB5606:EE_|DBAEUR03FT042:EE_|DU0PR08MB8908:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bddd934-edc0-44cd-28df-08dba301ff8b 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: g+p4QUgpuUCYQV/wgJlCchhAXhS9Jp132vyH5OeAZU3LOG92bDNbKGgYR2rYaYSzCl4XVJzHmUWHdPpVJfj+icVwrjkVNBszGLl6RXMWvBFz3Gcm+3l9QAjWn+E0c6FgmQ+pF5Iklvx0QtEFZ+QC3R3ID1n23eUEjQaRsZJXNt5u5HyOqDWfpI0IVcI1EKbjQQ/wsX/LOIovOwLQFfcDFYQPx+OcaF4CzCQR+jFsHD6mgmeretzBoOQ60/6PAXeybFZCZ409hM3g9ZFlCdy8t4U2RKTi6ciZwscB+uUU5zBWZpDYpImxnPz99mcagZgxWd0Ba/ez+n/jIebHvjqwhbaj8X680LL+ieA/I3S47q1CdrLw0gcrbDiU5zQ1jLiDJtnMzTmeFE9RpWV1tLh4SpheSSySOE1z4VV/8wlk4kiWiONNvo3QfZML/WXPxSWsGa5rg7CYhfKhhVp2xqN0IIKZaCbfhaA06bRHTm49P10RjhW8kCUcJhGK322UL/wDpIt5m+g5UwheL5JmQZZ5pzGRM6HReu2JnTcGk4OZsUX2O1b1wUGeTO+8A2fh2P3hetYFHlWH9Mf7xxRQFl1uHfz/YMhheSbi0e5Ke1at7zrIvKN+zf/zo5OItm4QhSQetAy4pJ40rYPnhvdsq3CwH4AHFGhA7PVFCJDh5Yo+tulHjurqfIukjxM/OPJRwCqpg1275uxRS2405bF21o7qRxaYjX7cQYeTcs6lBU0dxxqz6duwP2r3scxgvMdazxbo 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)(136003)(376002)(396003)(39850400004)(346002)(1800799009)(186009)(451199024)(82310400011)(36840700001)(46966006)(6916009)(316002)(70586007)(70206006)(8676002)(8936002)(2616005)(4326008)(36756003)(41300700001)(1076003)(82740400003)(356005)(81166007)(478600001)(6666004)(40480700001)(83380400001)(2906002)(86362001)(47076005)(7696005)(36860700001)(336012)(44832011)(426003)(5660300002)(26005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5606 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7a0dae01-41b6-4ade-76e8-08dba301fab7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gZvG6hOp6cEyf38XfQxMtO6NC171OyeElGuG7NlNooNzskx0/81rAS4ipKBvP7QQwkeYChh9SQz+s6xdUjxA+Em0+ke6Zxs+go64t27mRKnojA/J3/HGUnAVjxFMOum9/i3u6x6t3CTwyIIdiF3+dXPSY/oZS9DPxsj6fH7pkVmzBkmOE6j2jK97H0jo9D/MdylFu50Yk3hv5vnzGMfotvJbTfRvDzlAriz2e+gTq1tihXtOT1ErqsJq03W2gqhqER0/fzvUeyOaXSWzKGsqampKKQ1kWjectZG+mXHl0sQNg9iBPYnIH65608kRtEEJkq4kn5prCOGrb9pyvsUNrOCzsSl6ScZsjknlEHwutHvp85ij7uSCUs3/8ZjKZaG468xMUj8xar6WAtmtMfpQrUlVmqAZbBAiW63nIFw5GcF1NZAXR3x3S6SOF0ufHIAcz6tquxR67YQFrbrKKMwzvzxNZE0NYqy8/vtOSW+gAffWBaW+CBS1kpP05NFbJmNKGlUNhITZVBTgwIk55KtcMlCFTtkjkONAQZK9QM8v224LtaxkYXkb1fjd7hDJ9RF1bQiQg/ju6jp726HcaJFgk/R4OsvaggxZLr3wfWasTBPvzmhszoHy4+hj/yDYvmg66heuJVDqhsDKKGMEYUzxbo8Dr/CeJc+rD/bL9aWI/ZZRx0GXTDGYiboI2vaUL7gcxuAY5f035hPgQ9LjTVcTd3iMfTAZOhxX9hjyhnFZucFyDL3+FSGcgEMrUyMNfQiO 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)(376002)(396003)(39860400002)(346002)(1800799009)(186009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(6916009)(316002)(70586007)(70206006)(8676002)(8936002)(2616005)(107886003)(4326008)(36756003)(40460700003)(41300700001)(1076003)(82740400003)(81166007)(478600001)(6666004)(40480700001)(83380400001)(2906002)(86362001)(47076005)(7696005)(36860700001)(336012)(44832011)(426003)(5660300002)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 11:21:58.0661 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bddd934-edc0-44cd-28df-08dba301ff8b 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: DBAEUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8908 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: 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 fe3a55361c2..8b0b4d32971 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 @@ -478,6 +494,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; } @@ -515,6 +558,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. */ @@ -620,6 +669,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 -- 2.25.1