From patchwork Mon Sep 18 21:27:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 76333 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 38EC73853556 for ; Mon, 18 Sep 2023 21:32:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38EC73853556 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072720; bh=GHcNSVKCHQZjgVJIHNBq1Hhrad3G0ENes5nRf8nn2Q8=; 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=aV1mMDd0hH45FRpuFW929+Xzp7m7/VE/KnVgLVGJ26+1RE1bbBwckxq27B+Vq9Oov mtUH6+y51ElT4ReMhy1y5EjYRag4mXVWyg0cbEv8AjdcX6ssuv+hey8Qi5BIOcIRql N3+q+d4lBIW5kSCc1VtS9DU9RDVWONneaAnpir9c= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2065.outbound.protection.outlook.com [40.107.6.65]) by sourceware.org (Postfix) with ESMTPS id 576763856969 for ; Mon, 18 Sep 2023 21:27:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 576763856969 Received: from AS9PR06CA0040.eurprd06.prod.outlook.com (2603:10a6:20b:463::23) by PAWPR08MB9066.eurprd08.prod.outlook.com (2603:10a6:102:342::22) 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:29 +0000 Received: from AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:463:cafe::d9) by AS9PR06CA0040.outlook.office365.com (2603:10a6:20b:463::23) 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:29 +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 AM7EUR03FT025.mail.protection.outlook.com (100.127.140.199) 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:29 +0000 Received: ("Tessian outbound 1eb4e931b055:v175"); Mon, 18 Sep 2023 21:27:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 518faae3960f5408 X-CR-MTA-TID: 64aa7808 Received: from 3b701515c38c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FBCA0A63-A638-47F5-88D6-4900763083AD.1; Mon, 18 Sep 2023 21:27:21 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3b701515c38c.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=hrT8h9CgzOfDvuLfSZ3INb7GQlB/x/W+PzjftPxG3YC3jZRw27colpxDcYzrcQTHp0GtB7JHBYxOXifC2jxhG5bIl+fuURf9L5/fJeDycD//+x9HMj8Z19mtHgH16cojIpYpexQFwoj3ouk/+I142IEIjLYD/2ZQLrZMuxZ7Vk6eY9NqJeQce4cS+CK9zTmQdr2Kbml5HNdxhZOGsAT+BrfC3cjBtdVMga23It0t2xTbF4E2/D8yeCKv3Mj2PlM/3qtAMU5jA9E9Oo+526dNopdAU23gR6S1wYZQLIem7709QHCh/vYwEqlIj5+rEWtdlAauh30cNcVn4XpN5TumFg== 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=GHcNSVKCHQZjgVJIHNBq1Hhrad3G0ENes5nRf8nn2Q8=; b=AbdCg1+ezX8/6pzuwzAIPBRyMQw0clS5eY4+Ah+rRwUVqm23V8zgTn0W4cd8hT+cJXUSlGs8F0qC0DckiZdkMSYsstvpdX1UVwAOLwBGYHkufAgID53URQ1MT7LDSgAbNeqHu8uiTBP4i9nltoeYVmZI5+krQ3caHsk+ctoAKXmUL8CMRByRdNBVmixKjZK9lp0fEaWkmFKCG+rG7nNApXrsmw4Yz5iviO1vMWjJkqM54wqw/hKJD9WUjHOTdQURw6ML3RXpt04dy1JzSUe0oHvjFf0jbzvmgoTRY2sC2Klyslchn+f890hNkRnCtb6Nw1gfqg/SAq/4IXus0dXCIw== 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 AS9P251CA0015.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:50f::29) by DB4PR08MB9192.eurprd08.prod.outlook.com (2603:10a6:10:3fb::6) 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:19 +0000 Received: from AM7EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:50f:cafe::c8) by AS9P251CA0015.outlook.office365.com (2603:10a6:20b:50f::29) 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:19 +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 AM7EUR03FT032.mail.protection.outlook.com (100.127.140.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.15 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-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; 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:18 +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:18 +0000 To: CC: Subject: [PATCH v5 3/6] [gdb/aarch64] sme2: signal frame support Date: Mon, 18 Sep 2023 22:27:05 +0100 Message-ID: <20230918212708.660213-4-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: AM7EUR03FT032:EE_|DB4PR08MB9192:EE_|AM7EUR03FT025:EE_|PAWPR08MB9066:EE_ X-MS-Office365-Filtering-Correlation-Id: e7c69488-6df5-47be-7d8b-08dbb88e0fb4 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: uoX0AYF1hU3IPViPXOZumkt7RxUyfiUajdPvxjb/Rl6VNnX+abB2csiOgcE+ag2Hh+gZOjn4QFsrpFUeD5lYv7dVqUcnP/rrrWdNS8cZNH1l+iYCYFx5tS0mM++cClV+UYY8VQ4koj0L0uAzezZ8YF2/M1D7UCTzrBCFC++x6/tbH6agDHIhjnVSiu0a3wd9VTcQTK+1hfO6nRSRPGiWabgBdRCKsrZw9xSnRTAxl9vamOwj+YDGXfj7Y9+YlvVdfM/bCANS58IrTZA+1NOO7KSpHQjWXn5JHr5EFp+C2RkzyaebKK8t+3il57S9uKXo/QCA7V/fOTSjAo/xavu/XKHnua9NwN3qoyluvg9fwJVlUX1i5QT8JGI92i/LXo7X/Q2xSI6H/oZInXTxhLqfJJYTXO4Gj2ix74oVCO0x02lJzsMSsnLkkU8D1xL33CrYxQc2nMvA+Ctrz889QUULUHvllO9y/9MivTiWrd1Kmu6CheFIdHDjALovnDwuubqxhZxoK8kBRX4Zc7orv/Zzqn5rqJ+BPr9W8NR835+wjo4ZpMozShW3tblxhH1X7qnf47RZk//0VKCm3tYCrSJXZVFyAeoZDtnNBxm8h2GPFsZngV58gepp6iCIoNErsJkF1CZErezqOGrjiovWshZgYWaYQK79loQW8PJmFCbPJ5KDCAWlcoAtXAHGSWwxWhtKodbtFUv2jidpiPW1LQR4y3OA2ovVhukyDv4T667PfUUCVwKVBm6nR6rsGqkm2Jd9 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)(396003)(39850400004)(136003)(346002)(376002)(1800799009)(451199024)(186009)(82310400011)(36840700001)(46966006)(44832011)(5660300002)(4326008)(7696005)(8936002)(8676002)(316002)(41300700001)(6916009)(70586007)(70206006)(478600001)(6666004)(2906002)(1076003)(83380400001)(26005)(2616005)(336012)(426003)(47076005)(36860700001)(36756003)(40480700001)(81166007)(82740400003)(356005)(86362001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9192 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: fe9278f4-3329-4595-18f5-08dbb88e09ef X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X9WwvUjCDBTLCoDAiy0MDmm5ogOq/SzSry7FXyIpY7/KZkTP5PjuByC/45RadnseC/wZy6E0jF6kIUbWD/TpVc0OTrHPxqlgwtwL8i5W3UI99N6YAuBMCSReOXkrI8ZWmplpTXoszhGbtRfFeW9CW5POF7dilURxfGmfplLafOQ7xx7qxH1+wX3nOtHJPsyGp2q0luvtTzw/rfl4A4DiPhv2rpBt5c7yak+21Jmahc4fyW/elcdixHnx231c89e1MWHPVsbi/r2vtFjPLFcXdxk4yTv0g31xgsIrNZhvvQ1NX22moLw3gqS+Yzvx52z7bG42jcpo85T/455ebyvYIw24TtZMH8wmK/9i1/w6nFG+1BtZZlu8Gr5RBCabGS+FkrZZ/bQdlLdNOV1KRiQOrU6gRKubct/HCSxQqqMYxkZPhjxpp4k6AIHH55/prXpVfwT6re3k0op/QV4/YQ6DyBd+LfElsOsHFq91ah+yziAhy+WihgO0S6X5ys7BEy/fg2CwNPd018LyJQuHPL9GJxAG4qhRU04E6ArlZX/xbshFlwjqrrGXwwHy4qmccyTPo9CLF4+pwNf1CyLRKn7sEVFgefi6F4cF4AYsuEFTUSVfsW4llejk7UBp7JLNEmah9XbBavepmb0jMZjqyTH1bPtdbyvziHV0YVRUV8gw8B+aG8lyVxr8UixZjjpwYZoix0Gx6rc/CdCRBpVJf2rS69WVTpNKkctMkczyHQ6FH4ZjBGajTI+4g6/mTXyXS+7g 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)(346002)(376002)(136003)(39860400002)(396003)(1800799009)(82310400011)(186009)(451199024)(36840700001)(46966006)(40470700004)(81166007)(26005)(82740400003)(2616005)(8936002)(8676002)(1076003)(4326008)(40460700003)(107886003)(83380400001)(36860700001)(2906002)(36756003)(47076005)(426003)(336012)(40480700001)(5660300002)(44832011)(86362001)(7696005)(6666004)(478600001)(6916009)(316002)(70206006)(70586007)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:29.0942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e7c69488-6df5-47be-7d8b-08dbb88e0fb4 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: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9066 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 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" 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. Reviewed-by: Thiago Jung Bauermann --- 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 21efa42b2e6..41629902f49 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