From patchwork Tue Apr 11 04:26:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 67605 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 8AEB8385702D for ; Tue, 11 Apr 2023 04:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AEB8385702D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681187345; bh=ct9tZXQlqSyO8ZqFdXRtXIKSM1rhuC2DUeMTiJLar6U=; 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=iTpdlaflAfCkcX3GOYs6D5yAGsZJnQ02o/aQ0cYghIK6ZTCba14krx+tD9kQ1rIVx Vbs6yAmUe/u0r0n/mYUNyNaz8oAly7+qQVhfjc6Ceil5UL9EE4R/Shsetv/uEEjTj7 3kdOpIA2EtOx08sFVeP8ytp+YLiZoJ5BL01VDdHs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2050.outbound.protection.outlook.com [40.107.6.50]) by sourceware.org (Postfix) with ESMTPS id B3C673858C3A for ; Tue, 11 Apr 2023 04:27:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3C673858C3A Received: from AM7PR04CA0020.eurprd04.prod.outlook.com (2603:10a6:20b:110::30) by DU0PR08MB9725.eurprd08.prod.outlook.com (2603:10a6:10:447::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 04:27:15 +0000 Received: from AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:110:cafe::7) by AM7PR04CA0020.outlook.office365.com (2603:10a6:20b:110::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.40 via Frontend Transport; Tue, 11 Apr 2023 04:27:15 +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 AM7EUR03FT047.mail.protection.outlook.com (100.127.140.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 04:27:15 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Tue, 11 Apr 2023 04:27:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6453c00992daa341 X-CR-MTA-TID: 64aa7808 Received: from 4bc938f2af19.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4F06183A-78E0-4415-BAEE-4208E9BEA8C3.1; Tue, 11 Apr 2023 04:27:08 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4bc938f2af19.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Apr 2023 04:27:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VPzoTtRvPNvd0+Ij+PZSbp56uk+Gap7VaQVvaqxy+RrD5PL0juLy72K/VCljhr6Fs1yojzT2oFsk4hBH0SD193cEBAMqenrisNvYPSpA6iuIZAgc0SMrSmaIy7YXMyPDPrelwo1dqMbuAepaJHuRq2hwNmE5trNnjLQzmU/bND7zib3yz/Qpy9WaS6O8PpVFuoDE2Rqdk4975DzZ5DM76LE88mAqcH/NsD+2VxfYvLjFc2H8k1z9Hv1Zn7MEbznQSMYM3hIEz8korP0eDZT9hwV0ggk0MYaFWFKL74egtS2uSPZxE3f2itBE3aNEL4H9P8pFwnHNSTeWBKRhvGjziA== 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=ct9tZXQlqSyO8ZqFdXRtXIKSM1rhuC2DUeMTiJLar6U=; b=SZyvpATcvolc2FFe6TF/sRnS0Z1IXqpXFf4fu7DY5g/3B6ibsV5ky03uqxRwryFH1sy16aqAbxkvJ2y2iCOaq6f1+Ew/nFsTPh0Z/WIiyc1OBX7YDNn/UNvqbyohAOSUhKea/hJaDUHlOqlGELJ4kBo7RwjOCesjfU2jaTpcwJxMLUf85oBtJJRdgF/+6f6Iozt+3nwGEEXt6sEsSmel9FBsw4IJF4IC86/JB0WtE5BJf4U4zf8YtDJtwEyGawy70yfKWig3MmjM+0RCpMdZx8oJi9JyGE+CzupIZV0IOzsF+POoxFYPAM2i2gKHQ+tWQmYJxze0mNnRulKKAQ6JKw== 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 AM6PR10CA0050.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::27) by VE1PR08MB5805.eurprd08.prod.outlook.com (2603:10a6:800:1aa::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 04:27:06 +0000 Received: from AM7EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::a5) by AM6PR10CA0050.outlook.office365.com (2603:10a6:209:80::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.40 via Frontend Transport; Tue, 11 Apr 2023 04:27:05 +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 AM7EUR03FT046.mail.protection.outlook.com (100.127.140.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 04:27:05 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.17; Tue, 11 Apr 2023 04:27:04 +0000 Received: from e129171.arm.com (10.57.80.123) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Tue, 11 Apr 2023 04:27:04 +0000 To: Subject: [PATCH 09/17] [gdb/aarch64] sme: Signal frame support Date: Tue, 11 Apr 2023 05:26:50 +0100 Message-ID: <20230411042658.1852730-10-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411042658.1852730-1-luis.machado@arm.com> References: <20230411042658.1852730-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT046:EE_|VE1PR08MB5805:EE_|AM7EUR03FT047:EE_|DU0PR08MB9725:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c6799d5-29e7-48ad-2286-08db3a45076c 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: eabmN/9Kzy0wpz5MPctktTCXRUUhbUSsaJfGL9w/n7I6VRDGcHll4zgbfU58aO5bJwkw+vtwT/1wPKOuqmJ1RDYoD3ZgKEf926Q35Bu2ZLYZ8TBQC2d7lCMhlCuEnBM0b1qZBCt10i7H2Etx6cg3butF0UVz+BYeCqdGtB2sELYmd9QZmMjszJrlkhEvbhQXl6itxpNpe7x+07xAIcr9khsX+6jxII2Ws5hvPNkc6fF2aIyDu0dEMWO07dm/FCkaGavzEXi7EXpp8vrSdYA/YRy5WofDMnTElHjUq0q4YTR39kg4UgiHLvF9Pb2lXUMqKES9h8lZNh4D/smR44VJ8wxr9vI06Up7PPMRsRKeGgTwb04mB1JgiLpIkhNp5ugPkzCwexNX28psGhtnlNFs2jqSNGDeMQoDfP3GYffpYqCykiQWlYC8XyJ6GmNO7MOrLOxKDobbSpCBUYRvagWZqIQyvaMs418Hsi+dAsYxsMbryWiwZ/ovfJN+Sx9RyXRWikvPAr0FGOLaFGadACNdzT3CZpzyE5zbVr94uQLtGtHJNeW8V4G+GxWwbkzsvIBFI+MIj35cPzANBsOP0e+qSRe3urHdXuVyM3MguIMH88DRS52Ti9sWXkjBolUHN4gU+FYgXmhV9jxllLbNJ7pBjnyb8apMDrZyo5tvLugLAl7Yp8p4PEOEeivdy30jO0ukxdOyPO1ttBsZ9Fv3/ZNoTg== 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)(396003)(376002)(346002)(136003)(39850400004)(451199021)(46966006)(36840700001)(5660300002)(44832011)(8936002)(26005)(1076003)(6666004)(40480700001)(2906002)(83380400001)(47076005)(36756003)(186003)(426003)(336012)(2616005)(81166007)(356005)(82740400003)(86362001)(82310400005)(36860700001)(478600001)(41300700001)(6916009)(70206006)(70586007)(8676002)(7696005)(316002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5805 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e772d7e1-9b7e-45f4-600f-08db3a4501ae X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7s0WxoUJ/tF3YnGUpfAc0khdSD9WJvbDVuyiuqazbF0LW/a/ZrVQL11HBQCgljZyVjqmG1Iw/mJe9XPyvqPxmJzm1H4QyKWEGbEm5YXgiA0DEA50Z7DeenrkC87Yf/oLlAP0nbOVwejOJq5yeUBFC16uDt/O4w1HEzg0/gUrvgginu2EvFIM0lqpTZx2Tmmut/2b7rvsZbVUBj2MWlYc6IKMDAXoM8swCL6LnpPbESEV+avotWbo/E5wxzo0xfQzKxHAACSfLDvVJChYHo15un1qYa9Q3TNtzHA2/umyUf2T5Lse6ybmJIaC0sXWLLNX5SmCvxNOp+SFL1GSb3N9VSgF/bOGDx8LTmzOsVLPK2aQxahOMvtQlf43cysFpBaK1gJ2M6QyPfYcciJyYznvOF8Fdw9rDOPPXh7RWG/h/aamNsVwgcYnZOVm/hLM04bvR3dahZ2NlzFYWybNZUmWe5GVcrqAnFSuqBUUK3bAPbxnBt3+Am2y2Tu2MaD99cU7+Eb4JaPX1Twz/oEBRBpwCkAkpUA4ENZAuQS89xbB/Na57YH2BRizOKNQu9AX3A8LKC170gNE/jSfXo5vvDuh74+C6FiXB5e3OL7H4P2JPKDUihT1fVq5HVk4lvs0auiarOcfYzF3zsBC5R7APj3uvwz76zQhP5ySVQAOAJ/Nk34GCoOhQhp80snqo2zZ8sXHbOJsaUHoHfVlGWuhrEOW3A== 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)(346002)(376002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(478600001)(7696005)(6666004)(26005)(316002)(1076003)(186003)(2906002)(44832011)(70206006)(70586007)(41300700001)(6916009)(8676002)(5660300002)(82310400005)(8936002)(81166007)(47076005)(86362001)(40460700003)(40480700001)(36756003)(83380400001)(82740400003)(2616005)(426003)(336012)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 04:27:15.3957 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c6799d5-29e7-48ad-2286-08db3a45076c 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: AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9725 X-Spam-Status: No, score=-11.9 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.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 ZA/SSVE state on signal frames and how to restore the contents of the registers. There is a new ZA_MAGIC context that the Linux Kernel uses to communicate the ZA register state to gdb. The SVE_MAGIC context has also been adjusted to contain a flag indicating whether it is a SVE or SSVE state. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-tdep.c | 88 +++++++++++++++++++-- gdb/nat/aarch64-scalable-linux-sigcontext.h | 5 +- 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index eecf5bf13bd..1e12a8f0279 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -48,6 +48,7 @@ #include "linux-record.h" #include "arch/aarch64-mte-linux.h" +#include "arch/aarch64-scalable-linux.h" #include "arch-utils.h" #include "value.h" @@ -152,6 +153,7 @@ #define AARCH64_EXTRA_MAGIC 0x45585401 #define AARCH64_FPSIMD_MAGIC 0x46508001 #define AARCH64_SVE_MAGIC 0x53564501 +#define AARCH64_ZA_MAGIC 0x54366345 /* Defines for the extra_context that follows an AARCH64_EXTRA_MAGIC. */ #define AARCH64_EXTRA_DATAP_OFFSET 8 @@ -164,13 +166,23 @@ /* Defines for the sve structure that follows an AARCH64_SVE_MAGIC. */ #define AARCH64_SVE_CONTEXT_VL_OFFSET 8 +#define AARCH64_SVE_CONTEXT_FLAGS_OFFSET 10 #define AARCH64_SVE_CONTEXT_REGS_OFFSET 16 #define AARCH64_SVE_CONTEXT_P_REGS_OFFSET(vq) (32 * vq * 16) #define AARCH64_SVE_CONTEXT_FFR_OFFSET(vq) \ (AARCH64_SVE_CONTEXT_P_REGS_OFFSET (vq) + (16 * vq * 2)) #define AARCH64_SVE_CONTEXT_SIZE(vq) \ (AARCH64_SVE_CONTEXT_FFR_OFFSET (vq) + (vq * 2)) +/* Flag indicating the SVE Context describes streaming mode. */ +#define SVE_SIG_FLAG_SM 0x1 +/* SME constants. */ +#define AARCH64_SME_CONTEXT_SVL_OFFSET 8 +#define AARCH64_SME_CONTEXT_REGS_OFFSET 16 +#define AARCH64_SME_CONTEXT_ZA_SIZE(svq) \ + ((sve_vl_from_vq (svq) * sve_vl_from_vq (svq))) +#define AARCH64_SME_CONTEXT_SIZE(svq) \ + (AARCH64_SME_CONTEXT_REGS_OFFSET + AARCH64_SME_CONTEXT_ZA_SIZE (svq)) /* Read an aarch64_ctx, returning the magic value, and setting *SIZE to the size, or return 0 on error. */ @@ -325,7 +337,10 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, CORE_ADDR section_end = section + AARCH64_SIGCONTEXT_RESERVED_SIZE; CORE_ADDR fpsimd = 0; CORE_ADDR sve_regs = 0; + CORE_ADDR za_state = 0; + uint64_t svcr = 0; uint32_t size, magic; + size_t vq = 0, svq = 0; bool extra_found = false; int num_regs = gdbarch_num_regs (gdbarch); @@ -361,7 +376,7 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, /* Check if the section is followed by a full SVE dump, and set sve_regs if it is. */ gdb_byte buf[4]; - uint16_t vq; + uint16_t flags; if (!tdep->has_sve ()) break; @@ -374,9 +389,23 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, } vq = sve_vq_from_vl (extract_unsigned_integer (buf, 2, byte_order)); - if (vq != tdep->vq) - error (_("Invalid vector length in signal frame %d vs %s."), vq, - pulongest (tdep->vq)); + /* If SME is supported, also read the flags field. It may + indicate if this SVE context is for streaming mode (SSVE). */ + if (tdep->has_sme ()) + { + if (target_read_memory (section + + AARCH64_SVE_CONTEXT_FLAGS_OFFSET, + buf, 2) != 0) + { + section += size; + break; + } + flags = extract_unsigned_integer (buf, 2, byte_order); + + /* Is this SSVE data? If so, enable the SM bit in SVCR. */ + if (flags & SVE_SIG_FLAG_SM) + svcr |= SVCR_SM_BIT; + } if (size >= AARCH64_SVE_CONTEXT_SIZE (vq)) sve_regs = section + AARCH64_SVE_CONTEXT_REGS_OFFSET; @@ -385,6 +414,38 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, break; } + case AARCH64_ZA_MAGIC: + { + if (!tdep->has_sme ()) + { + section += size; + break; + } + + /* Check if the section is followed by a full ZA dump, and set + za_state if it is. */ + gdb_byte buf[2]; + + if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, + buf, 2) != 0) + { + section += size; + break; + } + svq = sve_vq_from_vl (extract_unsigned_integer (buf, 2, + byte_order)); + + if (size >= AARCH64_SME_CONTEXT_SIZE (svq)) + { + za_state = section + AARCH64_SME_CONTEXT_REGS_OFFSET; + /* We have ZA data. Enable the ZA bit in SVCR. */ + svcr |= SVCR_ZA_BIT; + } + + section += size; + break; + } + case AARCH64_EXTRA_MAGIC: { /* Extra is always the last valid section in reserved and points to @@ -423,7 +484,7 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, for (int i = 0; i < 32; i++) { - offset = sve_regs + (i * tdep->vq * 16); + offset = sve_regs + (i * vq * 16); trad_frame_set_reg_addr (this_cache, AARCH64_SVE_Z0_REGNUM + i, offset); trad_frame_set_reg_addr (this_cache, @@ -441,12 +502,12 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, offset); } - offset = sve_regs + AARCH64_SVE_CONTEXT_P_REGS_OFFSET (tdep->vq); + offset = sve_regs + AARCH64_SVE_CONTEXT_P_REGS_OFFSET (vq); for (int i = 0; i < 16; i++) trad_frame_set_reg_addr (this_cache, AARCH64_SVE_P0_REGNUM + i, - offset + (i * tdep->vq * 2)); + offset + (i * vq * 2)); - offset = sve_regs + AARCH64_SVE_CONTEXT_FFR_OFFSET (tdep->vq); + offset = sve_regs + AARCH64_SVE_CONTEXT_FFR_OFFSET (vq); trad_frame_set_reg_addr (this_cache, AARCH64_SVE_FFR_REGNUM, offset); } @@ -462,6 +523,17 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, aarch64_linux_restore_vregs (gdbarch, this_cache, fpsimd); } + if (za_state != 0) + { + /* Restore the ZA state. */ + trad_frame_set_reg_addr (this_cache, tdep->sme_za_regnum, + za_state); + } + + /* If SME is supported, set SVCR as well. */ + if (tdep->has_sme ()) + trad_frame_set_reg_value (this_cache, tdep->sme_svcr_regnum, svcr); + trad_frame_set_id (this_cache, frame_id_build (sp, func)); } diff --git a/gdb/nat/aarch64-scalable-linux-sigcontext.h b/gdb/nat/aarch64-scalable-linux-sigcontext.h index 74407bd266a..18623443744 100644 --- a/gdb/nat/aarch64-scalable-linux-sigcontext.h +++ b/gdb/nat/aarch64-scalable-linux-sigcontext.h @@ -30,7 +30,10 @@ struct sve_context { struct _aarch64_ctx head; __u16 vl; - __u16 __reserved[3]; + /* Holds flags. This field was defined for SME support. Prior to it, + this used to be a reserved 16-bit value. */ + __u16 flags; + __u16 __reserved[2]; }; /*