From patchwork Fri May 19 10:24:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69665 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 7207F3854148 for ; Fri, 19 May 2023 10:26:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7207F3854148 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684491984; bh=l3sTrWt3zt4R2K1XxJ4chAwQCbni0Ko2G1UmubF2PYk=; 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=oMyrOBk3oQvMTIivNeg4BqocrywV8b5oIvpfZP4XREl3StxOqCtpsQiCV+2GddmWY UnNw32l/45tSefhcHO808rY+KHmYdT/BqYSKeaKxGc9SBu4LBUzkmnd/rITxiMHodd biTVDFfEjRVxKrOEtUtUKwnfEfnAGCHrZjrgZYUU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2048.outbound.protection.outlook.com [40.107.249.48]) by sourceware.org (Postfix) with ESMTPS id 0994B3858D28 for ; Fri, 19 May 2023 10:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0994B3858D28 Received: from DUZPR01CA0012.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::14) by DU0PR08MB9800.eurprd08.prod.outlook.com (2603:10a6:10:443::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Fri, 19 May 2023 10:25:22 +0000 Received: from DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c3:cafe::22) by DUZPR01CA0012.outlook.office365.com (2603:10a6:10:3c3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:22 +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 DBAEUR03FT044.mail.protection.outlook.com (100.127.142.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 10:25:22 +0000 Received: ("Tessian outbound 5154e9d36775:v136"); Fri, 19 May 2023 10:25:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d26bcf7c19d29b30 X-CR-MTA-TID: 64aa7808 Received: from 75c5879b33b1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 39FA5765-C51A-4E36-929B-A248A0220423.1; Fri, 19 May 2023 10:25:15 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 75c5879b33b1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cR370xaJjpK3RExh8rdm8J5Kgtcq+y8K0xT5U3bd4HKtCP52Zp5PPKD3XGUBnbQYWDcjhvT4qVEcO8s6GfvdoTgZVJHu0IwZ4rQmPGraKcbCZfbwrAGl+o723K+lGfZjaJ7rvDKTOgRyZAXcLA3AWvPw7SCvm33Hx1r1H22Bh3fTT8Zli37GdklHFitC+xb2yAxEv4bn+iJZq4fjUGCwan0UcphMRNGfQI3Tjcdhtp3OJzPUx3P1Ao3XzSu5ACE8goBTjEbWkszXj4IcANWGHu7F219RBNxEcmAWpupprzYSrZWlj++1NyTRQsvyPN9aAxxV2l3Wyibq3qrimJ8zHg== 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=l3sTrWt3zt4R2K1XxJ4chAwQCbni0Ko2G1UmubF2PYk=; b=L2SOOZ8cMuFVk3ugjoQzgp7eKEegwbfY++iDRfYy/L7mW/U65WHQ6V2rpy2Hmb8poEm6nkz53Y3o9GIf42giQgvrQn4pJrxRiQU7XFcY6zw8oY/rUxibsLQ93JHnZiChptTKdz616UvHvLJE1RfJlhyo1TTXcCazchRhzmLMANqdrCrWAkk2mSo/WrWmmuOU/5/FV2U9UbNdgCUwFdJ1EIPzrtsG4VkovYN5zaqfd1NYPjTlvjrhHjuTov9Nj6GGjuMZ06hRz0E0wQX6JySFiE6ymxs4GKhfLW0En0QIQbc+FEc5IYF1kbDhjjLnbpMbNAb4XklXKWITQBIxseBjgg== 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 AS9PR05CA0184.eurprd05.prod.outlook.com (2603:10a6:20b:495::20) by PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18; Fri, 19 May 2023 10:25:13 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:495:cafe::86) by AS9PR05CA0184.outlook.office365.com (2603:10a6:20b:495::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:13 +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 AM7EUR03FT009.mail.protection.outlook.com (100.127.140.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 10:25:13 +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.23; Fri, 19 May 2023 10:25:12 +0000 Received: from e129171.cambridge.arm.com (10.1.37.65) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Fri, 19 May 2023 10:25:12 +0000 To: Subject: [PATCH v2 08/17] [gdb/aarch64] sve: Fix signal frame z/v register restore Date: Fri, 19 May 2023 11:24:59 +0100 Message-ID: <20230519102508.14020-9-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519102508.14020-1-luis.machado@arm.com> References: <20230519102508.14020-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT009:EE_|PAWPR08MB8982:EE_|DBAEUR03FT044:EE_|DU0PR08MB9800:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e7e102e-03db-454e-595b-08db58535a43 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: U6GBm0BXRM9zpJWQ5tN+At9SwAoNATuWRagzQCh8kPf7ZMxFJbQvL8tp8ZvdMl4cX2mX/sNBL6mWSQd35FGDNg7pA6FIqFRt0C4yvvjBYBZSpwmp/sYIO7PK9G09EH33KreMtBHNZCy73fbyURkfX9nZ6n37owPDlecta0hAPkME60Hco5EZtX1nOXTYTQoEIIXXWSwPFf8kAfM6TUWocHnOlq8h/H/hLkvL4j/+f5CD+nZARu0WC3fajUhy5oFJORWGfRY2SVOferq2hYe8DIxqu4VZP/q7UUx1Cb4om+fDFxbUvqXv44kvJ+nOI1kWmHdSlYYLuHC/JSS48TkyixciKC05qBbqEDU3duTwFLTkIXi/Cj2g93H6yJQhOKtNB5Mj0a1YFY7JRB62kdnC8kW1/gXsp7cuNxszxMn19t/DIosQf0SFk5njxlzyznDZx3qmA42YxsMeUR+esUj+sj096iVxwrv3wQCVcZlKN+nfWwCK04PrZ4UslI51frBi0T86vqWRGPkcu/pCYkDEf0nT1RClF9IpYT5Uib12GPpXIMWIoVZaJNZ2/UE4Xb9ZAOPB+TC9/x7/Z2AXE5WiFly7vd3HR75q/lkNOT1Ki1uyZ9YKMz23d9klZnQXwfTZUczKQ7yY/TNFzpdbQWyC5c56WeMvcml94TiyuTIuVdKoD/StML5oXofjhRVE2drj/cGqqDo1kPLRHXJ+WHQTNaE/r5ON/N0fTqt8hN1Q3NTwAJYb4GdFs8qicJ0fanjEOx9HYcU3mUnPvvpv2Bb9kA== 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)(136003)(376002)(396003)(346002)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(70206006)(316002)(6916009)(478600001)(86362001)(36756003)(47076005)(70586007)(83380400001)(336012)(186003)(1076003)(36860700001)(2616005)(26005)(426003)(7696005)(40480700001)(2906002)(41300700001)(5660300002)(8676002)(44832011)(6666004)(8936002)(82310400005)(82740400003)(81166007)(356005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB8982 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f44de86e-24dc-40a8-f9de-08db58535502 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 70bDFcVWoxA3Nt/3T/Gn80RQUP5ncPhRltuqa2o+lFxijU7nF+ftnYnBxwx7pEadqMqMYNL2ePaLEfW863VvZvidcRWjUNArRCbT2CA1dwukAGi38dfYbDqISH7sPAkQLOQVrhV4Km3v6w/+55lEAzvC7zdMlFU3sfloVTC7uuw6UHGhA4rPX/45oa9h8MS6Miv5RIFziI/K2xwiTE8OnR0N6VCDY3a+/5vRal1vWvBRyM6IGq3x9ybhzFd8TIULZBvti3MyikVwjIYbM7xYV3T+lpXVZAb2ZFP+eFq9gTMw0A8IFFjOjdsahT1R+uEJpKRQlweHlz++Wf6kXP55zJxR7cDYATBA6xNI3z0SNd5VcdN6EZ0T3b9bN8X8gadkOwO9Y5RSg5htWyHXH0ITPQaQGvQoiH8IhkQa/Tuud85Qb0bm/C/ZB048wKpT8jA72R9Zlp5X/0HmCoB5eEYXVAnuA1Qlo44M1pfFnLLAMYnqo6VrhoZSMsMQa8JKA345jceSg0323O6MfmesSRMkz2ob9kYvEvKOmTj1lCZpt2fyUKk7bRytP/FZAar38+Is3ttdeDyaAVLZohnYdQV9ziCbZwlrvhiNSFEUVtUPd1PKPe+h0Xn97QzjusrU1+rRPyTC8t3erWy/ULj9SADjk5NqVsZC88wGEWlRfAaB+wQTg1q8pS1LfXFozRhrdo08G++hnx2yyUADwkgjsjlxOrN0NnVefHq4IYxBAABahf/mTtsLT6EVdzEjVIQZHX2T 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)(39860400002)(376002)(396003)(136003)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(1076003)(26005)(70586007)(44832011)(186003)(36860700001)(426003)(2616005)(47076005)(83380400001)(336012)(5660300002)(70206006)(316002)(6916009)(8936002)(8676002)(41300700001)(7696005)(6666004)(40480700001)(2906002)(86362001)(36756003)(478600001)(82310400005)(82740400003)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:22.2637 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e7e102e-03db-454e-595b-08db58535a43 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: DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9800 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, 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" While doing some SME work, I ran into the situation where the Z register contents restored from a signal frame are incorrect if the signal frame only contains fpsimd state and no sve state. This happens because we only restore the v register values in that case, and don't do anything for the z registers. Fix this by initializing the z registers to 0 and then copying over the overlapping part of the v registers to the z registers. While at it, refactor the code a bit to simplify it and make it smaller. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-tdep.c | 108 +++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index b183a3c9a38..eecf5bf13bd 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -196,14 +196,13 @@ read_aarch64_ctx (CORE_ADDR ctx_addr, enum bfd_endian byte_order, /* Given CACHE, use the trad_frame* functions to restore the FPSIMD registers from a signal frame. - VREG_NUM is the number of the V register being restored, OFFSET is the - address containing the register value, BYTE_ORDER is the endianness and - HAS_SVE tells us if we have a valid SVE context or not. */ + FPSIMD_CONTEXT is the address of the signal frame context containing FPSIMD + data. */ static void -aarch64_linux_restore_vreg (struct trad_frame_cache *cache, int num_regs, - int vreg_num, CORE_ADDR offset, - enum bfd_endian byte_order, bool has_sve) +aarch64_linux_restore_vregs (struct gdbarch *gdbarch, + struct trad_frame_cache *cache, + CORE_ADDR fpsimd_context) { /* WARNING: SIMD state is laid out in memory in target-endian format. @@ -215,11 +214,22 @@ aarch64_linux_restore_vreg (struct trad_frame_cache *cache, int num_regs, 2 - If the target is little endian, then SIMD state is little endian, so no byteswap is needed. */ - if (byte_order == BFD_ENDIAN_BIG) + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + int num_regs = gdbarch_num_regs (gdbarch); + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + for (int i = 0; i < 32; i++) { + CORE_ADDR offset = (fpsimd_context + AARCH64_FPSIMD_V0_OFFSET + + (i * AARCH64_FPSIMD_VREG_SIZE)); + gdb_byte buf[V_REGISTER_SIZE]; - if (target_read_memory (offset, buf, V_REGISTER_SIZE) != 0) + /* Read the contents of the V register. */ + if (target_read_memory (offset, buf, V_REGISTER_SIZE)) + error (_("Failed to read fpsimd register from signal context.")); + + if (byte_order == BFD_ENDIAN_BIG) { size_t size = V_REGISTER_SIZE/2; @@ -234,50 +244,67 @@ aarch64_linux_restore_vreg (struct trad_frame_cache *cache, int num_regs, store_unsigned_integer (buf + size , size, BFD_ENDIAN_LITTLE, u64); /* Now we can store the correct bytes for the V register. */ - trad_frame_set_reg_value_bytes (cache, AARCH64_V0_REGNUM + vreg_num, + trad_frame_set_reg_value_bytes (cache, AARCH64_V0_REGNUM + i, {buf, V_REGISTER_SIZE}); trad_frame_set_reg_value_bytes (cache, num_regs + AARCH64_Q0_REGNUM - + vreg_num, {buf, Q_REGISTER_SIZE}); + + i, {buf, Q_REGISTER_SIZE}); trad_frame_set_reg_value_bytes (cache, num_regs + AARCH64_D0_REGNUM - + vreg_num, {buf, D_REGISTER_SIZE}); + + i, {buf, D_REGISTER_SIZE}); trad_frame_set_reg_value_bytes (cache, num_regs + AARCH64_S0_REGNUM - + vreg_num, {buf, S_REGISTER_SIZE}); + + i, {buf, S_REGISTER_SIZE}); trad_frame_set_reg_value_bytes (cache, num_regs + AARCH64_H0_REGNUM - + vreg_num, {buf, H_REGISTER_SIZE}); + + i, {buf, H_REGISTER_SIZE}); trad_frame_set_reg_value_bytes (cache, num_regs + AARCH64_B0_REGNUM - + vreg_num, {buf, B_REGISTER_SIZE}); + + i, {buf, B_REGISTER_SIZE}); - if (has_sve) + if (tdep->has_sve ()) trad_frame_set_reg_value_bytes (cache, num_regs + AARCH64_SVE_V0_REGNUM - + vreg_num, {buf, V_REGISTER_SIZE}); + + i, {buf, V_REGISTER_SIZE}); } - return; - } + else + { + /* Little endian, just point at the address containing the register + value. */ + trad_frame_set_reg_addr (cache, AARCH64_V0_REGNUM + i, offset); + trad_frame_set_reg_addr (cache, num_regs + AARCH64_Q0_REGNUM + i, + offset); + trad_frame_set_reg_addr (cache, num_regs + AARCH64_D0_REGNUM + i, + offset); + trad_frame_set_reg_addr (cache, num_regs + AARCH64_S0_REGNUM + i, + offset); + trad_frame_set_reg_addr (cache, num_regs + AARCH64_H0_REGNUM + i, + offset); + trad_frame_set_reg_addr (cache, num_regs + AARCH64_B0_REGNUM + i, + offset); - /* Little endian, just point at the address containing the register - value. */ - trad_frame_set_reg_addr (cache, AARCH64_V0_REGNUM + vreg_num, offset); - trad_frame_set_reg_addr (cache, num_regs + AARCH64_Q0_REGNUM + vreg_num, - offset); - trad_frame_set_reg_addr (cache, num_regs + AARCH64_D0_REGNUM + vreg_num, - offset); - trad_frame_set_reg_addr (cache, num_regs + AARCH64_S0_REGNUM + vreg_num, - offset); - trad_frame_set_reg_addr (cache, num_regs + AARCH64_H0_REGNUM + vreg_num, - offset); - trad_frame_set_reg_addr (cache, num_regs + AARCH64_B0_REGNUM + vreg_num, - offset); - - if (has_sve) - trad_frame_set_reg_addr (cache, num_regs + AARCH64_SVE_V0_REGNUM - + vreg_num, offset); + if (tdep->has_sve ()) + trad_frame_set_reg_addr (cache, num_regs + AARCH64_SVE_V0_REGNUM + + i, offset); + } + if (tdep->has_sve ()) + { + /* If SVE is supported for this target, zero out the Z + registers then copy the first 16 bytes of each of the V + registers to the associated Z register. Otherwise the Z + registers will contain uninitialized data. */ + std::vector z_buffer (tdep->vq * 16); + + /* We have already handled the endianness swap above, so we don't need + to worry about it here. */ + memcpy (z_buffer.data (), buf, V_REGISTER_SIZE); + trad_frame_set_reg_value_bytes (cache, + AARCH64_SVE_Z0_REGNUM + i, + {z_buffer.data (), + z_buffer.size ()}); + } + } } /* Implement the "init" method of struct tramp_frame. */ @@ -432,16 +459,7 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, /* If there was no SVE section then set up the V registers. */ if (sve_regs == 0) - { - for (int i = 0; i < 32; i++) - { - CORE_ADDR offset = (fpsimd + AARCH64_FPSIMD_V0_OFFSET - + (i * AARCH64_FPSIMD_VREG_SIZE)); - - aarch64_linux_restore_vreg (this_cache, num_regs, i, offset, - byte_order, tdep->has_sve ()); - } - } + aarch64_linux_restore_vregs (gdbarch, this_cache, fpsimd); } trad_frame_set_id (this_cache, frame_id_build (sp, func));