From patchwork Fri Jun 30 13:48:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 71917 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 1388F3882035 for ; Fri, 30 Jun 2023 13:50:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1388F3882035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688133033; bh=7zTSjgXm/SiaIPl8zQo0Qfr/ZZ3e65NHF8tnY3a02wI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=w2MemD261CCIA4X4vIc4i1+TUDpk8B5ezKp6OHVD9kqEnZ4ioH7ibiob/lp61PXq0 qL7AzNZendnSSPTISIE0hyTOAPdsHhC+OG0g02VlUbZ9MnSi41V10DXdRzltKQS/0v MGMSRXfv8SLOqKocQAu1bbiklfNvbS1/iv35Q0Uk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by sourceware.org (Postfix) with ESMTPS id E40CB3884585 for ; Fri, 30 Jun 2023 13:49:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E40CB3884585 Received: from DB9PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:1d8::12) by AS8PR08MB6343.eurprd08.prod.outlook.com (2603:10a6:20b:337::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:49:05 +0000 Received: from DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d8:cafe::8a) by DB9PR01CA0007.outlook.office365.com (2603:10a6:10:1d8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:49:05 +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 DBAEUR03FT061.mail.protection.outlook.com (100.127.143.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.10 via Frontend Transport; Fri, 30 Jun 2023 13:49:05 +0000 Received: ("Tessian outbound 7c913606c6e6:v142"); Fri, 30 Jun 2023 13:49:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 858093083f40b3a8 X-CR-MTA-TID: 64aa7808 Received: from d408c57c4b40.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2FD90B6D-CE14-4AEB-85B2-941BE7965BB5.1; Fri, 30 Jun 2023 13:48:57 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d408c57c4b40.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:48:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SDBq5AJPJEd4lP7mD4NzRiKEyL6LbslmQA9hwYadKoKC1ZQ27cKS8dpPhwQqdB0DQ+0ED12/ScnY7YDL8sTcYcTE4INiBX13BWnxvlMEyKGHXKLpeeYgnbQ4qucg9dS5ngsIG+nEbouLq/yuh/I5d70iMgiRRxxFL2v2h7qcEhB2/r1tJxm5I1MLll4WyBkESVsxiHA+OLwiPgRtaKK5v2h7KbJeV7Mxc6RX4kheETJf9tgQhMimKZ94lCmGZvhZbbAVRtDNs9eaqHT7sIlcvMS2Kj9rZo03fTNNTKDOC2Ii1in8FbtLjKJpE7py0V8To9D/qUa9mgd27TgF4rvIFg== 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=7zTSjgXm/SiaIPl8zQo0Qfr/ZZ3e65NHF8tnY3a02wI=; b=nd9grBoJ+lLqpA2Y7eX9ckeu7E8vnpckc0aRdd95yJUD1bkfGZh8JAB9Th0gFBerKK+pfNRQfanqYTXy1jQkhDYGUu1srm+TKQY81lNO2v5X5SUvMWq5svkI2Jhlrmq6PhZU1J40RWmqql5ze4HfcviLnEasj/ZuaxD+wm3vhpW+FCje2YgM8Ocb2BAwqLfsNK/JgOzydWuGlhnebfJK1hMhlTa2tz7b1DEwNPkKRzLHKoszgYMTcfCqJudsmgkV44tEJJgKvZLGDCBIfPCfVwKpCKHTA1UzCyQl16GcQs6NTb+TJWb4mAaJyN//CW1chNbcYS5t7IooN7q8TQfa2A== 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 AS8PR05CA0020.eurprd05.prod.outlook.com (2603:10a6:20b:311::25) by DB5PR08MB10064.eurprd08.prod.outlook.com (2603:10a6:10:48e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:48:55 +0000 Received: from AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:311:cafe::1) by AS8PR05CA0020.outlook.office365.com (2603:10a6:20b:311::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:55 +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 AM7EUR03FT063.mail.protection.outlook.com (100.127.140.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:48:54 +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; Fri, 30 Jun 2023 13:48:53 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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; Fri, 30 Jun 2023 13:48:53 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:48:53 +0000 To: Subject: [PATCH 3/6] [gdb/aarch64] sme2: signal frame support Date: Fri, 30 Jun 2023 14:48:41 +0100 Message-ID: <20230630134844.1238445-4-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134844.1238445-1-luis.machado@arm.com> References: <20230630134844.1238445-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT063:EE_|DB5PR08MB10064:EE_|DBAEUR03FT061:EE_|AS8PR08MB6343:EE_ X-MS-Office365-Filtering-Correlation-Id: a7332441-4673-406a-1575-08db7970c511 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: evxWOp4dDuUJ609tiivf/0rANXEZIbY5W3qHOSz+UAmb1verVvnspLQfjh7c4GEjOyTcDhpsGHPyEkEsXRi6GFI4arzsxxrY0PjuTiN0jsDUOIpn1PRCDdE0MNdxjy7ExKw4zzgTxZpmnwN0naoOQaDk1dgbE1BmRJCa/vFMrSjRxcTf2maW49FvRZCJRXSpgA4gF/oafJn2d6Xfy26bYfgp6tMcZA6nQj1/PIhyQyTm3N9nJwbxpsj8hl/Al+8Fa8Lnb30WV2UZGPHDKLFyebze3tYMsAEApmS1sY3h59wPZuK5mQ93WmN7y1KzlkxPh6/zUPf6IHlJxa0qpJt/D07AIhoQrgRXU0aPwP1FPAtL83F8SelVZvQRdQ30sVGAYmASXebyJuP2/3jWHmvvR0Hjoz/6Op2BoaWLmIComBcF/r4ihmNdETvIaRJjKpjmrvPQXa0kjXy/DHednqIbc0r0Yob6BTzZW6CzGjGrvAdMalyK1vpX2/DU32sLSFiOFIuccHONctKerw/8KCRCZ1nt5VR8fz3Rxs+KQDIm5z/xEmLuqsyDOKWVbJ7gTrr1ZIRPFHoDMv6C46uMs+Tc8soEwJ/bhL4rg8EGWlNNDpK7GDdf1huxlpYVgQ4hEFGLTUoskBocShQTnNHqQjFmZCgyUOXbByXTmwlmk31NR5c8bS1+MliKxOEJxbTBWcuhL0g9Ibs6129nXvBHW8dJ6KT9p/SlyWXg9C4kbj4DPcZRI1SX1cpKt4bS3SC5vLkkLd1BfHTkEKruJVS1adiOzg== 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:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(8936002)(8676002)(5660300002)(44832011)(70586007)(70206006)(6916009)(2906002)(316002)(41300700001)(478600001)(47076005)(36860700001)(40460700003)(6666004)(7696005)(40480700001)(1076003)(336012)(2616005)(426003)(83380400001)(36756003)(186003)(26005)(81166007)(356005)(82740400003)(82310400005)(86362001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB10064 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 704a0a34-1a28-4566-11c0-08db7970bef9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xEQU2+CmrKUC1wIQYPc1vqaVUlYtf8IjE3WKhxpk1M3s0cBA6MUzRE2Lvl1w5QueqPh+M30BPVtTIAwTcar8ft89fpsxzWpam0KVyPGW1mwRtNn0r4ynON4LIGer/jgOT0In3jomfOYARllv/oe1NdJDCuOkwdvj+V7gug8sCEMlm6JKx1xHfZkFsKC5+CUONhM4FRru7bvzWKmqPj/3k3uY8zqM9fxqUM06a/ah/O2E5b2BURf26xTmq3uaHfkKRq0xmDTdXMWFGEdaBfTUgV5DkCAGkQ85OxPsxjyn/cvqj61J+R/OgE1KOJAF/JRMP/sykAL8ihJbkisG7+vNWYJzXfjHpvfdyAqthlSCDTDNvg1FPbKfInqITK7ALMgqnEx3Unqngq2oOcyE99IyrlElj+Wz7NEVgHqJ5nKFLMTO0J80Us76U62TYw/kt0KZffJASVQY7SE8Ju1He3jKIJR/5F/emG1t19RwmCfOA4gSBVUNki1n5AIOtLLq8rX4fvrdCn82650kIyiq4W6j1gKFpVmp+yHuFPAbdCVM0SpanWEYM3PwThhw57Jvdy1KIn6HM5LJJK6QnLFA4BY1oVKGUxJ8HKB3ypQkmpYlt0mRXFk5f4JsDgvPvUHTb9UXO3au8wzUdpiRixfHZsRFPvbjzLuRy0kYcYxWxM57a56vaP0rTIvufgFwCmPDe8Spb6JM2GYexv3nmdR4ru1t43rwxFNlwszVop7MRdnp7EPo6yhVbDtK/bfq2vjb1rZ3 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:(13230028)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199021)(36840700001)(46966006)(40470700004)(186003)(6666004)(8676002)(8936002)(44832011)(478600001)(26005)(70586007)(70206006)(6916009)(1076003)(316002)(86362001)(7696005)(5660300002)(81166007)(82740400003)(40460700003)(2906002)(2616005)(82310400005)(40480700001)(47076005)(336012)(426003)(83380400001)(36756003)(36860700001)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:49:05.2586 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7332441-4673-406a-1575-08db7970c511 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: DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6343 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, T_SCC_BODY_TEXT_LINE, 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.29 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" 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 0bd75daa994..1fe35de6079 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 @@ -479,6 +495,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; } @@ -516,6 +559,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. */ @@ -622,6 +671,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