From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2046.outbound.protection.outlook.com [40.107.6.46]) by sourceware.org (Postfix) with ESMTPS id 8F6DC385B513 for ; Tue, 22 Aug 2023 11:21:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F6DC385B513 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=ZOPi7WGyWxXrTdZXsi2NEorP5bRKWZLNeMRstsSsDjw=; b=ov53zkPLfb3fYaVKWuvEf9CBmBld5wK7BAZuio7rg3/zJWdmWHzimXoBZxU4t0zz3jgFNqCj56F/qTBAsIj5y7+bM/0I72Jvekt6NYmEXmWvmoXA8TTJbp3SJBHMq3PPCmeTPvNjfVf39Lw0ZJFd0eCCP8JEYkanSLyXSjt3hdE= Received: from DB8PR04CA0009.eurprd04.prod.outlook.com (2603:10a6:10:110::19) by DB9PR08MB6395.eurprd08.prod.outlook.com (2603:10a6:10:254::14) 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:48 +0000 Received: from DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:110:cafe::cc) by DB8PR04CA0009.outlook.office365.com (2603:10a6:10:110::19) 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:48 +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 DBAEUR03FT010.mail.protection.outlook.com (100.127.142.78) 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:48 +0000 Received: ("Tessian outbound d084e965c4eb:v175"); Tue, 22 Aug 2023 11:21:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 465c4ae671033286 X-CR-MTA-TID: 64aa7808 Received: from 5ffbff813b4e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0F7B569E-B710-4957-B780-4E50842328DD.1; Tue, 22 Aug 2023 11:21:41 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5ffbff813b4e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 22 Aug 2023 11:21:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qexchvbssuh9nzUWaWzQAK14HrpXRY3doq42OMvElK9hrqbA9liGV2fgzOTAqwRgx78lBn83GBldhm7yj+rQ7sKdOuVxr4ZDFqlcYt+M/I8t1weve7kb/Ad+TQPFn5D5stlWaFmBJ8cK10jjleACpdZEYTbXbVkTugpGcGqaxWtZHGL/bOwwdRr5nXo8z0RCpQDv2RCXxiNH7IUYibKgQkusDFOY8rH6BQOMB9fMVbJW0juT+ErtoHOC60aLx8CPJHMUsqt2jEpbixrgp1bII1CP5Ulf7sOOgkLjB6JrAF+doqtUFis0HXs4aMafz29bnx8WCKt66do38FIrf9zIBg== 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=ZOPi7WGyWxXrTdZXsi2NEorP5bRKWZLNeMRstsSsDjw=; b=ipvbxmoTVW6KwbKH8iNhJlrShV28JbZHAAWdHX2WezlDspWzJL9YjTuazGHvt/49kN2tFqUMGk7FMVTuajmcfgY0ucNG3WL88B/vTyuNd+nSB2eAI5IxmOb2bZARxlPbbbxorNFkBj1IkSyddwAIe9XyqbEc3U1whHBaabroTq8QL5tBIBmABky2+1Np8Lu47EcPJgheIzfzX7q3P2PKj5kimNHmGlfiLqeJ8ZwTmrcj8eyLj0fKuQeCXk4c2xVmayuAnxcy8E+3CQ4v1Rxti0t2jmyRFwGl9N1yvx29DI59MhPBRHANCJRbYY6zp9S1cFKastPLYdm7jPO5loEBEg== 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=ZOPi7WGyWxXrTdZXsi2NEorP5bRKWZLNeMRstsSsDjw=; b=ov53zkPLfb3fYaVKWuvEf9CBmBld5wK7BAZuio7rg3/zJWdmWHzimXoBZxU4t0zz3jgFNqCj56F/qTBAsIj5y7+bM/0I72Jvekt6NYmEXmWvmoXA8TTJbp3SJBHMq3PPCmeTPvNjfVf39Lw0ZJFd0eCCP8JEYkanSLyXSjt3hdE= Received: from AS9PR07CA0016.eurprd07.prod.outlook.com (2603:10a6:20b:46c::27) by DB9PR08MB8625.eurprd08.prod.outlook.com (2603:10a6:10:3d3::13) 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:39 +0000 Received: from AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::79) by AS9PR07CA0016.outlook.office365.com (2603:10a6:20b:46c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Tue, 22 Aug 2023 11:21:39 +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 AM7EUR03FT027.mail.protection.outlook.com (100.127.140.124) 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:39 +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:37 +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:37 +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:37 +0000 From: Luis Machado To: CC: Subject: [PATCH v4 09/16] [gdb/aarch64] sme: Signal frame support Date: Tue, 22 Aug 2023 12:21:23 +0100 Message-ID: <20230822112130.1513216-10-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230822112130.1513216-1-luis.machado@arm.com> References: <20230822112130.1513216-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT027:EE_|DB9PR08MB8625:EE_|DBAEUR03FT010:EE_|DB9PR08MB6395:EE_ X-MS-Office365-Filtering-Correlation-Id: ff19a983-99b2-4f28-5403-08dba301f9a6 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: gyadtIGbhjXYWwZeRBz4L4vBuj8HiD9m/li5vZIJWAFk8rXO8oft0pPq6Nk5mkrWbe/G/zV+fnjh5eC1nTxOWJgv8DXWQg2NjJ9cbmy695pCTkK/n9UQJLZCXu/sr5LAySOWC5sFEDrWyVamxaoe0Bd425bLONdzy2hWD5+06SjJ54ZmtPVtlFjkzU0IgX8AEhDHf1zLV17tnVsOxIa/AtCvQbaMT+v5sfrdZc1AkiV8vskJF95z4jhtquKzsLvmUueBKWX2ZhI9bpg63bwSpixSPxq8/IXyq0yVNtl2B6cBTS3yWO+wxIM1Xxi2XdxTfsuGNMMAC48NcGw6y8Uvd3gtwoEx2TfXmlhAKZ3cGvdXaN8LKYvqsiAq+R3DBq12uz+1NQyLIUlH2LCdhTA09phCk9kLvV+tnx23oYEIbYe6BdOLt8++p4WGOkzXneMQku/a0QKjaaYXmC2jAcBPuFzEFfpxq/hmr7aNbaelYXclpL4HfA/RQPt4O0MIfdEghcTkbvHE4BAoids4y7Zf2spmuflxmzro4tdGQR9l0ygFTbd3+9SYsZZAzi0Kub6xzbycLgJIGuu1MnzGJZ7mpwjjdbltvZOTaseN7Br/xfllfr/COlCNkikM4FxbQZaZ2iCZHvetRAI1I4IsBCCTD8lqMl2jRqj+a20ZLmuiSjJvfD6WMzLtHo3QSksr7WWZhn8INEsjmYVHOIJAP9KAsQFnd+AjXsNy4oRQSXBbzOSPJoRibRLLR4zJyautAYaFD9RZIQcAmkVx8tEgUbzBtg== 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)(39860400002)(346002)(1800799009)(186009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(6916009)(316002)(70586007)(70206006)(8676002)(8936002)(2616005)(4326008)(36756003)(40460700003)(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: DB9PR08MB8625 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e015d7f5-29fd-420f-92f9-08dba301f458 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Lpiy62/N9+vq13j9R50VhjMLtw/iEvRxKFtIvfoAebBhHVu8ppypU/ohPt8nO3R0vGbcqFQG6VtE7vWL8vLjbpjKtba58W4c+Qy45P6pKxBcpehtChdP2+7FpjjqZGzMFlD4Pl/+iw9I0cvOP6CZvPxf2ZXGoTrTQALBOOzhJAkxT8AO4kXJpEIy/rNywFYA6+e3xEnDcjav3qoCAuddj4O/9M1lVxEDdZtpgEJrLY03EfpV0eok7c5MZks88xmdACCC3sCL1lIyMfROTg6D95Jx0nQsuQaGE/A6czkWbQwnf3BymoQafC3cek3TZYcZPfB5eCJ4ArInqWdfC+lMtMR3vOQrXZoWTPBMOvZZOf3XD2v2VjaGnJ6L6gZlPQZb1pSnnGLho3UU0PkxsMFcL5C8Dhnucc5nnSffoWC4lXjQcL/A2CCmDlF0rLxEk9GHi1HvMSfYv57iO7juO494oZ1eXFwKt4VYooizsQa8Cc4iIjRWCbCs4xi5m47J1tbI0NNfh8rnIY8WwLt4tkYeQKfuSU7/vsJYZ2E9+swPeGwjap/OkwORl8yoLjXNG0WATW8+dhMrX+neangDvwAwmSx5tKqslyP3OiukC1LYaX+o0ybv9ndWYkauCJSFli9yf/Ccj59hJGLtlpAi/CJ8zeVB3u1SgBYCvmLMWaPYsWCl9NOzMQniHGPqH8D/L1wkyeVmUcE50e35UmNd4W+wYaJtoTE7ngTe2WJucdZ3idTktl3hfVJxuU10aCldNAds 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)(376002)(396003)(346002)(136003)(39860400002)(186009)(1800799009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(107886003)(1076003)(426003)(2616005)(26005)(336012)(47076005)(86362001)(81166007)(40480700001)(36756003)(36860700001)(82740400003)(40460700003)(83380400001)(41300700001)(316002)(8936002)(8676002)(70206006)(70586007)(2906002)(5660300002)(4326008)(44832011)(6666004)(7696005)(6916009)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 11:21:48.1622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff19a983-99b2-4f28-5403-08dba301f9a6 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: DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6395 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 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 bdd5cb05c10..f76d1888072 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. */ @@ -324,7 +336,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); @@ -360,7 +375,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; @@ -373,9 +388,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; @@ -384,6 +413,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_SME_CONTEXT_SVL_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 @@ -422,7 +483,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, @@ -440,12 +501,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); } @@ -461,6 +522,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