From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2068.outbound.protection.outlook.com [40.107.241.68]) by sourceware.org (Postfix) with ESMTPS id 9FC093870F2D for ; Fri, 30 Jun 2023 13:46:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FC093870F2D 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=ct9tZXQlqSyO8ZqFdXRtXIKSM1rhuC2DUeMTiJLar6U=; b=uNiZZd5F6uaGEPYyx18+UzCmqoFdu7hOgAvlrCu14MRbZxea0XJyzTjlfErfH20ddtxoiJ2JX0dzTDb1xIk1V8g3EPEhPUuAibCktqOvuELFvQd4P2aWliMWfFCak01+irgxiyEnhNwmT84ZopYrp+QEMZnhKkpoieUqYBoK+is= Received: from AS9PR05CA0069.eurprd05.prod.outlook.com (2603:10a6:20b:499::29) by DB9PR08MB6635.eurprd08.prod.outlook.com (2603:10a6:10:254::12) 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:46:43 +0000 Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:499:cafe::b9) by AS9PR05CA0069.outlook.office365.com (2603:10a6:20b:499::29) 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:46:43 +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.6565.13 via Frontend Transport; Fri, 30 Jun 2023 13:46:42 +0000 Received: ("Tessian outbound 546d04a74417:v142"); Fri, 30 Jun 2023 13:46:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 757240d3f8db64d5 X-CR-MTA-TID: 64aa7808 Received: from f9c7b96372ff.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1D36EBCD-6AFB-4AFC-AE47-E2AF35163DD6.1; Fri, 30 Jun 2023 13:46:36 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f9c7b96372ff.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:46:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q0sjPpAuN4LpNvDOrAOP3H1BAf/egtbFwbx0aG4eSGC9V8rCrFU9sWSJ8SOxTm/YayJwulPvTkVazNNh8nZ85H4jBnIpyrJWVJANwtMA2BFotBz2mIDqSsWd/3Z2S/VKFypBW2mLLXQY24cob6AXZ53slEN3+p+SBtKlwvJPfW4OJUYCLrYyFESfYbrcseeS1E5lSkX4VX4JOK416otJ+IQtTJEhiurAipl4ixMMvviPKBiKothi8eIAawlG9NRakYw4PIjUAOB7uIuN1GHcj2dwrgUG7Lf6Z/4pK6Lmm6HBZxqQlxoLO4YKdIVpYHLJypg+C+N+f4mfzix8No2yFg== 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=DgkCoDpoQuNGXeebCi0jDfV+KDe5mDRioWVWDb7+M66qOCbImNem17boAK9mUg0ZF+TurIajGUlx5xWc5+Pt6DGxQNYMWlj9udXDMBz577/etcxIoP9pean0fjoASRI1VdmdOLtieY6GIvEHdeuRmS4I57Cr3nhbsMzzHjCFVyRCs/dkrLIfTfmrafAZDUn3bU+4lNkmd+RkswN7Aoi40Q+e55RBstqRSXxwAvxm0DIJn3k1TdkFvkh0ouuLsTQ2UHo01I2e2mpkGN00Vw7o1vfzZksmu6Zw0/7jsL844LidGGyOK5A0aYpeTSM/TeCgRDl5WxYlfA83Er57C8B0IQ== 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=ct9tZXQlqSyO8ZqFdXRtXIKSM1rhuC2DUeMTiJLar6U=; b=uNiZZd5F6uaGEPYyx18+UzCmqoFdu7hOgAvlrCu14MRbZxea0XJyzTjlfErfH20ddtxoiJ2JX0dzTDb1xIk1V8g3EPEhPUuAibCktqOvuELFvQd4P2aWliMWfFCak01+irgxiyEnhNwmT84ZopYrp+QEMZnhKkpoieUqYBoK+is= Received: from AS9PR04CA0132.eurprd04.prod.outlook.com (2603:10a6:20b:531::27) by DB3PR08MB10333.eurprd08.prod.outlook.com (2603:10a6:10:436::10) 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:46:35 +0000 Received: from AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:531:cafe::ba) by AS9PR04CA0132.outlook.office365.com (2603:10a6:20b:531::27) 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:46:34 +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 AM7EUR03FT014.mail.protection.outlook.com (100.127.140.163) 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:46:34 +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.27; Fri, 30 Jun 2023 13:46:33 +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:46:33 +0000 From: Luis Machado To: Subject: [PATCH v3 09/16] [gdb/aarch64] sme: Signal frame support Date: Fri, 30 Jun 2023 14:46:09 +0100 Message-ID: <20230630134616.1238105-10-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134616.1238105-1-luis.machado@arm.com> References: <20230630134616.1238105-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT014:EE_|DB3PR08MB10333:EE_|AM7EUR03FT004:EE_|DB9PR08MB6635:EE_ X-MS-Office365-Filtering-Correlation-Id: d16cc999-213b-4e89-c5f8-08db79707035 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: 1TGfBzInzVtummRcr6cPJIx+kYjGBtFgROWOnWcInrbxeITpZdKNXaPgT0yDfnIwwg0yLKm0IoMrJ1S04QPvNODtz6nq+5uMZPyOZp7J6EABHcZ8wP9zC8JJ1xpUYtpp3vH2f2/HsYQ/UJj1bZkfG771IcE2tubi9A7IXycp4kDsyYPWmAJ7YYzMYl+/lqT+3B1WkigTR3pnlvIHsjehl7dOwoFK8fk/GyqUAVQ/weJ8/1HRf/eKu0HGgn2W7uNLbkgXynvHpzmnCcy+RsMDEdP4n5Rwkxn53Q3/R/Ysp6IwtvuouZxoVxhKifVGikuWP2/VVqjDgCurEobqRsAY4RzGi1oKj/d8IaaO2FYtF//+d4hP5vA0Ux2vtN9ZxKxYNds6WbuqXmpDHNZwYg2O7DPC31c9TH9wPvVRr+D3gp/x24v31mKWmcXG/s14ucCtx4ZWEY0qZ0kKEml1T5D9R/K/xzlR9ayauBcvpHRX+46HyNE5nZ3w4z83x8XD7ASR7rpjcBLIlSqS7n4TWwqWmPSRgeJUmEWA1bTjFa3EE2Q/cGmNxHEwSH4Bn3JCA77CkfYorE9VH+EaBjcPYyXhRXgBpDZJGOpWXS8kMhU5fpsGcndJD6IX6APxqJIB6JRwbmw2m6DsqWTuzGLCUNyx3qB/pQTi3XeSqENU8H3tmvs09RsKAOlv5ZUVtUUoINvpzdVUGJDnOT8PGxDAqOOqw+Xqyhs2wnwlduSePUn8eWQ/XL1DdiXVd818XqJ/P7Rz7iySrtd/f5Jnz70nHdSLxw== 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)(136003)(346002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(316002)(70586007)(6666004)(478600001)(70206006)(6916009)(86362001)(36756003)(47076005)(426003)(83380400001)(186003)(26005)(2616005)(336012)(36860700001)(82310400005)(1076003)(2906002)(44832011)(5660300002)(41300700001)(8676002)(8936002)(7696005)(40480700001)(356005)(81166007)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB10333 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7f16c3b6-7446-4d08-2f0f-08db79706b68 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /pVtTi7799BxvCf7j/nFUMgxEos+QPFsXebsvDkgMZ4uaN6JzwWzd39V4SbB9Zf3/dlkBJkJFDmWJ3shFqqsBHkRIU2rW+XBZgNdFY31t36mj8OefGOoDknqMS9IvCK9WXvN+Arh+LYs2MbEPB4c2xqLI0wqYVgvS9Q3OPp7dnpF3+K8/zoym/wxrgL3plV8HLX5DyABblWfTPSHgAlAUvvN8FiJztABPwyvosLQrrQAVcgSf3vUuZ4T5bAg9qU6d8AC/aaKBJi2ANFZgPTyiI1JjVsbJGAdn09D9rh4Zrbl7EQMwJyE3mhyGfWGZ0RPP8WtP3wNMn4NPAwIcxZqwlIWADr1FHwLhdvahWv3XooMpw0hSR98m9KW0prQMU/v/37Ut0H0QURsoK1iCguVVz/4vAbLHyuzlqeKZvZ4yeB0/E0cHT+dz7ipP5ZYNAHNgqTLiG4lgu4IoTySny+4sQ5+rkp2SHwGBleCrDrXPFLVVu/69edT4ZyM6hrACnz9mqjEDNSBBp57bP78SOdVpXYvcTqcgSUHiBrARxzmyEFkJ7w8byNinxzTffFGpLqRDXVymC94BdnmX2zsAcxLy3SDSWWUTWB/VRPNii/Z673RDZtWfXFuvaOvqZAERqTMYn4+UJ644LouCv2gLNAscC/j/rwmDupEXJCY9tHVG+VwNOmuS/iqgsJ/CfSLLjNjOxPZQylWIVv7X0gf3v3e2lPyJ8PG3Ozn90pr9Mszxx7G4PGWRl3eGmAQS5/eBpKn 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)(396003)(39860400002)(136003)(346002)(376002)(451199021)(46966006)(36840700001)(40470700004)(86362001)(36756003)(478600001)(70586007)(70206006)(1076003)(6916009)(6666004)(7696005)(40480700001)(82310400005)(8676002)(316002)(8936002)(41300700001)(44832011)(5660300002)(2906002)(81166007)(82740400003)(83380400001)(26005)(186003)(426003)(47076005)(36860700001)(2616005)(336012)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:46:42.8302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d16cc999-213b-4e89-c5f8-08db79707035 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: DB9PR08MB6635 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 List-Id: 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]; }; /* -- 2.25.1