From patchwork Fri May 19 10:24:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69667 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 8E6E6384646E for ; Fri, 19 May 2023 10:26:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E6E6384646E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684491991; bh=FeZxV0cQ0XyAJIP7tX+mk6XHEx+elHRod9JtzFwcMp8=; 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=SmN0oQhMSpph9XlFaOlc2jMxH2YyTKq59c8ri52/2rdnDZ+rs0wf1ko6ivkWBWvJy qeJo0hix9Oho8pc33TrtDezrYovGh27+3DXS8cn2S+7zTJedpKjYZJ/OVopykxg6gt XeHweTljFEt6unAdkbc4UM2mae7TlACkSkylPkMk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2043.outbound.protection.outlook.com [40.107.8.43]) by sourceware.org (Postfix) with ESMTPS id 6463C3858C52 for ; Fri, 19 May 2023 10:25:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6463C3858C52 Received: from AS9PR0301CA0036.eurprd03.prod.outlook.com (2603:10a6:20b:469::14) by GV2PR08MB8004.eurprd08.prod.outlook.com (2603:10a6:150:7e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:22 +0000 Received: from AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:469:cafe::18) by AS9PR0301CA0036.outlook.office365.com (2603:10a6:20b:469::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 AM7EUR03FT055.mail.protection.outlook.com (100.127.141.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:22 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Fri, 19 May 2023 10:25:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 735bba29279b2bec X-CR-MTA-TID: 64aa7808 Received: from da6df998e455.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F318E195-AA75-4D62-85D8-B1C5B6FBEA4E.1; Fri, 19 May 2023 10:25:13 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id da6df998e455.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PWvC6oh7+KZvvDjz2ZlUBfXV49+hLLX5N6TNkeFfMjoEU4NlSDenbFU1n0OHa6jAf8bQIe/8c2aT69BUvmDacQdZS+cPW3vJUTdCTLelfUcfCopGlbweQaaU2oKZ1m8Av5uf2cDWdadmavKde33exKYT+8OLpalMiHDAiRD1Bn2Lza2die4rCxxl1cWuPsXyXrr76POARfoyoFOLO9olPYkXQ7HcrOfselj2F4cXs24HSePkbZh0wwD6mh+gnkyEQRWJLInXIDKwTx7Sp1aH+weTIlb5UIwbJXWz4PcZdHq7ulKFtZGc33+rehkU9SCTI0R7VrmWvV3QvCGuhDEYuw== 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=FeZxV0cQ0XyAJIP7tX+mk6XHEx+elHRod9JtzFwcMp8=; b=FyA13McE0n2W5KqRzha8B+CthKt1oyDXj+/AXAP0K+aMxcozKV/AOWFZATvJPaxVwdmS7aRz3UX2VfxfFGDFajlA5x9ES0BvBq3E3xdDrUEAbJvjvWey8HV6cpUe7LZh7hC2fooMJeY6bQISYsdVdseSoC8460e1mEbWW1K793jSBJh+pF5hvLPNek6CHQGf9SOHsZp8jidH6VHYOtoE4pVLLPQLAxXNh87xE0gDah43T5xYU9KgqKVt710KbHw16L8iCOp37Zfa9kjYPODax+MgQlcGvyBC8Cnnb+1iCjW5ZmwVtMhZ7qmA/AarVKxNhJtXJrJWtmRwAdv4f/AhlA== 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 AS8PR04CA0133.eurprd04.prod.outlook.com (2603:10a6:20b:127::18) by PAXPR08MB6592.eurprd08.prod.outlook.com (2603:10a6:102:158::23) 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:12 +0000 Received: from AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:127:cafe::9) by AS8PR04CA0133.outlook.office365.com (2603:10a6:20b:127::18) 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:12 +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 AM7EUR03FT039.mail.protection.outlook.com (100.127.140.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:12 +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:11 +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:11 +0000 To: Subject: [PATCH v2 01/17] [gdb/aarch64] Fix register fetch/store order for native AArch64 Linux Date: Fri, 19 May 2023 11:24:52 +0100 Message-ID: <20230519102508.14020-2-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: AM7EUR03FT039:EE_|PAXPR08MB6592:EE_|AM7EUR03FT055:EE_|GV2PR08MB8004:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ddce4ef-8bb2-4c37-c20f-08db58535a24 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: kd0tMLIJqUQMEOuNV/KUp3/XJMFLDoWU5oJs0Ocd8JDevY6ToTdLuHanySCmpl0WwvO6YopRuSsjMdgSrnpy39j1vY22xR2+Pi9DMKUnUWHGfDIN35R3hCBesw1B/UbzbRcJU7Aspu73MbIhKVKtSakt2uN6mXSKV70kM+1vDK6acnUz2CGg0rnXRd+T5vwjSI5dr/W17mimgJ5i5j/arsNuJJGqCIhVspog63I4i7E7so0wcMYu+3XYeiNlvNprG8aa6hwB4/1QQLKUgxAnywC2sJzGpJfOrr3WPfLH0MKq5ILddnimBSf0w00Kr6JXK7qRhs9VWjLNq2yGj2pBw0cxX+RIvt/ckYA8iq01RkOFiwvta1KliZ78Lr7fYWo8vtRelsXNVlChbYTuTTNwcCJwIwGyMXll+fgymg6I9a4qHACtTYiOlgtxinc2ZC13k5KQzODrn82vJnWwHO3CVVQ4YopdiQuv+WQm+e7YJO9kdM2cA9sG+lDabRVjXEPL2kFVN2HOGmGKuui6GXNt3VnUOX1QuVz8NQ+U5T21bYWXVPM5faqVPf72fsAPtFNP5XSuyieRHh/KefrWba4se3bGRqeShQ2rM8289tLsP1TwtBlgO1T1z30b8UPkV4+xBxYCE4cF4PCvEheFse398HeT23XnreBoAlf97NoVtLmHYhT3/0H4uC6+E2B9FRwOYaQcnnBlRzqplSEbBniemilXCgPPXcJ/Qnvbe2dZ/85aVQJkINIkg0MCUADgv+hJ13tXVA0eh3Po+iTMxco8PQ== 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)(376002)(136003)(39860400002)(396003)(346002)(451199021)(36840700001)(46966006)(40470700004)(7696005)(6666004)(40480700001)(40460700003)(186003)(1076003)(5660300002)(26005)(44832011)(82310400005)(8936002)(86362001)(6916009)(8676002)(82740400003)(41300700001)(356005)(70206006)(70586007)(81166007)(316002)(336012)(2616005)(426003)(36860700001)(2906002)(36756003)(47076005)(83380400001)(478600001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6592 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 628f55b2-16a8-4ac2-aa52-08db58535437 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JLrsrtGb8LKNH2B9/UGaeeCfBX5BXeuEZtZTb/qLENMBJDpshi3Wmnj/k9WmRYfc07ZLzhzcToT3vmjpJ/3LWHTUITSh7P1w/3tIGn8ovQ0OzXGXWs8xJ+xMFcIjR7AhHv8TZG6AfEb7G6Eh78M7FaFb/jbh77snJY+xplqZ3QX7RI65hC3AJ55H0nIyh8bac0I5sk3jcmz/RmJjILQp6rsrzvqS3tXmn9DaBSPNBvaqMMim+brHF7Va6RlzfLPUHj4WZb/sEG0vi/7uoPL9R4ugqMF9b8F54l8/o4jvlBKoyuaE+9in8F/VuQebixStxQ5TusniHuKePP3eXXv2yGx38FT23ktFu+Y7ziyULxdh24vc/SKhWIcMO4V9Q7vycNHftQKYoi8Z0IbVdDMkfstyUA+7NWSAr/NENsiy4kGzcN30Ne/KJmgQ/s6blap44YvbhyouC9LKbA+0x8HPNNx/PV2TA+W9GAkU1oM5DK84zLtpPlS01DAzJpWlB096/Z2U2dezxIz1EZahEBVyN185zc+NJ4JnLgUKCD4EV4wGh9izn6/MYu0o2JHqK0gk72s2eNxk9VXcY/sM6OISPEaKh/QoHyYtVDuyuDvz7lGPPjDCM711X77a8njzz5t8qCDtomrJhDibvi5vLv5c5L9c+QREB8HQejsJlTRBC50JEiPRqEM3LiTNc/YAaU9/p9Qk5lr/os8AHWrazDt5ZQGU9okTWQyA+klSnyrGWuia46sLPWtMxOQapHxtfr8/ 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)(39860400002)(346002)(376002)(396003)(136003)(451199021)(40470700004)(36840700001)(46966006)(86362001)(36756003)(316002)(70206006)(6916009)(70586007)(478600001)(40480700001)(6666004)(82310400005)(8936002)(8676002)(5660300002)(41300700001)(2906002)(44832011)(81166007)(82740400003)(7696005)(186003)(336012)(426003)(2616005)(26005)(1076003)(36860700001)(47076005)(83380400001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:22.0320 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ddce4ef-8bb2-4c37-c20f-08db58535a24 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: AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8004 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" I noticed we don't handle register reads/writes in the best way for native AArch64 Linux. Some registers are fetched/stored even if upper level code told us to fetch a particular register number. Fix this by being more strict about which registers we touch when reading/writing them in the native AArch64 Linux layer. There should be no user-visible changes due to this patch. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-nat.c | 60 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index ecb2eeb9540..62656a7347b 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -504,6 +504,7 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) aarch64_gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + /* Do we need to fetch all registers? */ if (regno == -1) { fetch_gregs_from_thread (regcache); @@ -521,28 +522,28 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) if (tdep->has_tls ()) fetch_tlsregs_from_thread (regcache); } + /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) fetch_gregs_from_thread (regcache); - else if (tdep->has_sve ()) + /* SVE register? */ + else if (tdep->has_sve () && regno <= AARCH64_SVE_VG_REGNUM) fetch_sveregs_from_thread (regcache); - else + /* FPSIMD register? */ + else if (regno < AARCH64_FPCR_REGNUM) fetch_fpregs_from_thread (regcache); - - if (tdep->has_pauth ()) - { - if (regno == AARCH64_PAUTH_DMASK_REGNUM (tdep->pauth_reg_base) - || regno == AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base)) - fetch_pauth_masks_from_thread (regcache); - } - - /* Fetch individual MTE registers. */ - if (tdep->has_mte () - && (regno == tdep->mte_reg_base)) + /* PAuth register? */ + else if (tdep->has_pauth () + && (regno == AARCH64_PAUTH_DMASK_REGNUM (tdep->pauth_reg_base) + || regno == AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base))) + fetch_pauth_masks_from_thread (regcache); + /* MTE register? */ + else if (tdep->has_mte () + && (regno == tdep->mte_reg_base)) fetch_mteregs_from_thread (regcache); - - if (tdep->has_tls () - && regno >= tdep->tls_regnum_base - && regno < tdep->tls_regnum_base + tdep->tls_register_count) + /* TLS register? */ + else if (tdep->has_tls () + && regno >= tdep->tls_regnum_base + && regno < tdep->tls_regnum_base + tdep->tls_register_count) fetch_tlsregs_from_thread (regcache); } @@ -592,6 +593,7 @@ aarch64_store_registers (struct regcache *regcache, int regno) aarch64_gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + /* Do we need to store all registers? */ if (regno == -1) { store_gregs_to_thread (regcache); @@ -606,22 +608,26 @@ aarch64_store_registers (struct regcache *regcache, int regno) if (tdep->has_tls ()) store_tlsregs_to_thread (regcache); } + /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) store_gregs_to_thread (regcache); - else if (tdep->has_sve ()) + /* SVE register? */ + else if (tdep->has_sve () && regno <= AARCH64_SVE_VG_REGNUM) store_sveregs_to_thread (regcache); - else + /* FPSIMD register? */ + else if (regno < AARCH64_FPCR_REGNUM) store_fpregs_to_thread (regcache); - - /* Store MTE registers. */ - if (tdep->has_mte () - && (regno == tdep->mte_reg_base)) + /* MTE register? */ + else if (tdep->has_mte () + && (regno == tdep->mte_reg_base)) store_mteregs_to_thread (regcache); - - if (tdep->has_tls () - && regno >= tdep->tls_regnum_base - && regno < tdep->tls_regnum_base + tdep->tls_register_count) + /* TLS register? */ + else if (tdep->has_tls () + && regno >= tdep->tls_regnum_base + && regno < tdep->tls_regnum_base + tdep->tls_register_count) store_tlsregs_to_thread (regcache); + + /* PAuth registers are read-only. */ } /* A version of the "store_registers" target_ops method used when running From patchwork Fri May 19 10:24:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69672 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 510683858415 for ; Fri, 19 May 2023 10:27:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 510683858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492054; bh=YTlodG5R6EeR4fWUYbQ+Ry4oaxZ0p8zVgrpOC7kXAmw=; 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=KLsczL9K8d4uMYEoSkJmC1vjVLiQpnZq4CtUoDJmQ3QCy4GQd0mOCm4lIKze0NklZ /e2LlHEkSDziLb9k2GspxwMj9q6YyjM34/5s4VTnMoYYO78TksbkkAyNtBShPT9R0t jnuUB3wh49uvIGVjFARGa1WPbgdz3Etqxhp02RTE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2073.outbound.protection.outlook.com [40.107.104.73]) by sourceware.org (Postfix) with ESMTPS id 744C33857709 for ; Fri, 19 May 2023 10:25:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 744C33857709 Received: from AS9PR06CA0149.eurprd06.prod.outlook.com (2603:10a6:20b:467::31) by AM0PR08MB5522.eurprd08.prod.outlook.com (2603:10a6:208:18c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:29 +0000 Received: from AM7EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:467:cafe::d5) by AS9PR06CA0149.outlook.office365.com (2603:10a6:20b:467::31) 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: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 AM7EUR03FT050.mail.protection.outlook.com (100.127.141.27) 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:29 +0000 Received: ("Tessian outbound e13c2446394c:v136"); Fri, 19 May 2023 10:25:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 341a6c71e85482e5 X-CR-MTA-TID: 64aa7808 Received: from e0f8cc71fb0d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6CBE35B6-3C69-45D4-9406-7FD0A6653EE2.1; Fri, 19 May 2023 10:25:22 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e0f8cc71fb0d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hGNZW8nJ9l2thg5BTDu/g1UIqB4gS8RBlVISZjs/EK+UaiSi1HnBM7RCgDEg5J96d+dhuoGqpyou38HpuPb26/PngYDqvXs/wmDorkc8LoVo0HvXNfjii0N65HxvNnTXwnUCvHlhFlOVOEThR88btKKJzRDGe2pav2cMK4AtGm6O2mZTlU4khOb8PEj2IjvxcPfin0TgP6AneWrWJbjL8qOHSzl5KBjqTSZOz3q1vbWorK3SlzFqiLtnSt893wDDQu7R/6Z5q5bOa6gcW3qLUnXj7yQsdlPt0CAaohm0ot9jTeA3/yT4kBVQhw6k4VZNoPtbYJJxQP/WskNLSXyvrw== 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=YTlodG5R6EeR4fWUYbQ+Ry4oaxZ0p8zVgrpOC7kXAmw=; b=JkE/INMuUL4g8g1iXifkq1yJFPSRO6qeJ894fB1XSC6APKLWvgN6uiL09uFqQKxSgwKyzjxoeSjf0B64GYg5KyuFpX12500zXWOUHJQWJukT5K1lu2LIt2jqGsxcH0NyaPbu2jM5extP6uKy7rSsnPoKaB+cTZ26BlLW2iGsIBRDwi9lDqAdC0BEFX9rooU6BHWWDWkfym/SpElUK5EoQmRliPdROKIAW9N5YVz3ws7fXZRaMSF0BMQk4rPBl5+gYBjyEZrd0t3sFvnWBlgPvKb44xQCIIBlOzx5cqnI5NYEfARSL39V6h/vIsJm9qRFm26pa4ubzir7/QOSOw1z3w== 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 DB6PR0202CA0004.eurprd02.prod.outlook.com (2603:10a6:4:29::14) by GV2PR08MB8677.eurprd08.prod.outlook.com (2603:10a6:150:b9::22) 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:16 +0000 Received: from DBAEUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:29:cafe::84) by DB6PR0202CA0004.outlook.office365.com (2603:10a6:4:29::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Fri, 19 May 2023 10:25:16 +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 DBAEUR03FT057.mail.protection.outlook.com (100.127.142.182) 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:16 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) 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:11 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.23; Fri, 19 May 2023 10:25:11 +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:11 +0000 To: Subject: [PATCH v2 02/17] [gdb/aarch64] refactor: Rename SVE-specific files Date: Fri, 19 May 2023 11:24:53 +0100 Message-ID: <20230519102508.14020-3-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: DBAEUR03FT057:EE_|GV2PR08MB8677:EE_|AM7EUR03FT050:EE_|AM0PR08MB5522:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e1e1bc1-f80d-46d6-1308-08db58535eba 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: lXDKBof5dZUurusRzgAS0ldyRnc1vHvUGKeaarLO9SIM2FDX3n+QNB89EAbnMx709rzshLcVvCP4VbGS8BIAAxgREixhsgvtBpwjOl3U7fcLRHCpG6oL7voMbxwQ2LZ+JV+pzXIFeI/BQwG1Fi3JUrX+lSAnojIJ9HpTWRyXz7SkawKV5UJW3x9WZUFkkZhr2kAosNyEAgfvtd5PMRyFKjXs8lo85fC5Eu0tY1E2BNsQmAI4eii0pOKKmGUm4bFnNtO6L9XZs067LF2FPCJzVAI5dJ7LOzZz/jjHIUBsX8mAkpgZhKjXBmTwSIOjlwCzPZBGSFeplWcwP/1TJRN1mY4A2LBxpC0VjNRAQ/RRcbIZvrZHePDUR3HbGpCQ96jdkJGNL8Tom+dtbZ9SPou4lt1oxnQqy3e/bMsu8N7LKRv6cBe3uMXDZcq/uAXG7itIzqFv83tx5TGzijikNinObm4tqVWWARd0S8cvQqPwy2mMM07r/Et5XDYjJqIZLbV3XneMs3e3Id2gnGoeHxHLHk+HngUFJSgm661dGvGuMTM3arSzSCxipAuBHpCKKbLOnBCI+5fQ253nwqTYSGSqtwsB7zDEFA7xWaJmZD4bFSFfFhlwK9AJ7QSpaXp8ROVLRFiSBwxdLdmWfk3IOonx4Sgbqw5nf02GV6kGTvQC2uwQdaEzHNBbrsDNttwFDLbMrp9tQceGX3vXFv2sZ5oMa3EpYflQJlufmBMsO109whX0V6oZuvZzWIhmnyb9qQxjSHCFllluhq4mGXKhvqwz+w== 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)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(316002)(478600001)(2906002)(6916009)(41300700001)(8936002)(8676002)(44832011)(6666004)(70586007)(70206006)(5660300002)(7696005)(1076003)(26005)(40460700003)(82740400003)(81166007)(186003)(356005)(40480700001)(336012)(36756003)(47076005)(36860700001)(83380400001)(2616005)(82310400005)(86362001)(426003)(2004002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8677 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b9b233a7-0695-4aa6-7a1a-08db585356fa X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FnCSmSysC4rpXADFi1z33dQyZ4qvvIV00uS6CREtL+p611rVUuToy74GKsu7fXQ0rGR/lsH7nLDeBEtR0uHqR0doTC3t+Ookw9tZexPRU1Z3pRGLR9DcSLdpM2QS3y4TprpDgJHkm34ZyaXQv4b4g1fUHp4mqvJcJ3m+6ZMLLm5MiSzqMAfKVGpOgSRC0SwfxrYHzj7U58PpFLLLrEZNYGQ0Ny3ALDRj8NqOFi9ZCIQduWOqn/Nw0JwpJS1wTnjCV/IqR3NqieIIQkfnYN0Li95+9iBw8ie2pJM4NvwHofNoz+aPuOnbPdaghoy6K+Zsp2G4MaMGJe4TdjUWCcO0hhHLxG8wMkPOK9+aZYgZUQi6gOl297R/RatqUZVfTjjcHXbzcVjCM6XeL97be4Lo34/DwqdLid/apYiFwCQcObMHydpHUqwh8j0DSd/gVvkhGGjnKrAEDdF48Mo7zYCTnEqa4T1sdbODDu4/Xj9Gft5gL84I3OBig2ThvucTUqKZ0CkneX6/1iXEeQsdRUzCMlvhkqe2Fba0LV+2OFtaLFTrpviLSqvcg+A5LcheviBZoXwpNSeHi77fcpo4sr2E4tHhS4UUrQFSDPOhDMSYH/6vGqqy25XvYtLxGlDkn5QkKSwvUC6/xVKRWBqOsC6qf5unqVSnnXiMNozu6vohoHgPCKXTunSdVNkP8QWzXVpMNjEaj5q/o65lc8p9B4k0mI5ugqm1u5S3y78mQw59DEfK+MfPjA8KY5oEPvqnVk8o 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)(39860400002)(396003)(136003)(376002)(346002)(451199021)(36840700001)(40470700004)(46966006)(70586007)(70206006)(6916009)(82740400003)(8936002)(8676002)(40480700001)(316002)(478600001)(41300700001)(7696005)(6666004)(40460700003)(2906002)(86362001)(81166007)(26005)(1076003)(44832011)(82310400005)(83380400001)(47076005)(36860700001)(186003)(336012)(426003)(5660300002)(36756003)(2616005)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:29.7058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e1e1bc1-f80d-46d6-1308-08db58535eba 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: AM7EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5522 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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" In preparation to the SME support patches, rename the SVE-specific files to something a bit more meaningful that can be shared with the SME code. In this case, I've renamed the "sve" in the names to "scalable". No functional changes. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/Makefile.in | 2 +- gdb/aarch64-linux-nat.c | 2 +- gdb/configure.nat | 2 +- ...ptrace.c => aarch64-scalable-linux-ptrace.c} | 17 +++++++++-------- ...ptrace.h => aarch64-scalable-linux-ptrace.h} | 11 ++++++----- ...xt.h => aarch64-scalable-linux-sigcontext.h} | 11 +++++++---- gdbserver/Makefile.in | 2 +- gdbserver/configure.srv | 2 +- gdbserver/linux-aarch64-low.cc | 2 +- 9 files changed, 28 insertions(+), 23 deletions(-) rename gdb/nat/{aarch64-sve-linux-ptrace.c => aarch64-scalable-linux-ptrace.c} (96%) rename gdb/nat/{aarch64-sve-linux-ptrace.h => aarch64-scalable-linux-ptrace.h} (90%) rename gdb/nat/{aarch64-sve-linux-sigcontext.h => aarch64-scalable-linux-sigcontext.h} (96%) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 14b5dd0bad6..0b9f33c24dc 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1560,7 +1560,7 @@ HFILES_NO_SRCDIR = \ nat/aarch64-linux.h \ nat/aarch64-linux-hw-point.h \ nat/aarch64-mte-linux-ptrace.h \ - nat/aarch64-sve-linux-ptrace.h \ + nat/aarch64-scalable-linux-ptrace.h \ nat/amd64-linux-siginfo.h \ nat/gdb_ptrace.h \ nat/gdb_thread_db.h \ diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 62656a7347b..0dd9652d001 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -35,7 +35,7 @@ #include "arch/arm.h" #include "nat/aarch64-linux.h" #include "nat/aarch64-linux-hw-point.h" -#include "nat/aarch64-sve-linux-ptrace.h" +#include "nat/aarch64-scalable-linux-ptrace.h" #include "elf/external.h" #include "elf/common.h" diff --git a/gdb/configure.nat b/gdb/configure.nat index aabcdeff989..8d26f521792 100644 --- a/gdb/configure.nat +++ b/gdb/configure.nat @@ -238,7 +238,7 @@ case ${gdb_host} in aarch32-linux-nat.o nat/aarch64-hw-point.o \ nat/aarch64-linux-hw-point.o \ nat/aarch64-linux.o \ - nat/aarch64-sve-linux-ptrace.o \ + nat/aarch64-scalable-linux-ptrace.o \ nat/aarch64-mte-linux-ptrace.o" ;; arc) diff --git a/gdb/nat/aarch64-sve-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c similarity index 96% rename from gdb/nat/aarch64-sve-linux-ptrace.c rename to gdb/nat/aarch64-scalable-linux-ptrace.c index 51146535672..cc43f510892 100644 --- a/gdb/nat/aarch64-sve-linux-ptrace.c +++ b/gdb/nat/aarch64-scalable-linux-ptrace.c @@ -1,4 +1,5 @@ -/* Common target dependent for AArch64 systems. +/* Common target dependent routines for AArch64 Scalable Extensions + (SVE/SME). Copyright (C) 2018-2023 Free Software Foundation, Inc. @@ -22,13 +23,13 @@ #include "gdbsupport/common-defs.h" #include "elf/external.h" #include "elf/common.h" -#include "aarch64-sve-linux-ptrace.h" +#include "aarch64-scalable-linux-ptrace.h" #include "arch/aarch64.h" #include "gdbsupport/common-regcache.h" #include "gdbsupport/byte-vector.h" #include -/* See nat/aarch64-sve-linux-ptrace.h. */ +/* See nat/aarch64-scalable-linux-ptrace.h. */ uint64_t aarch64_sve_get_vq (int tid) @@ -60,7 +61,7 @@ aarch64_sve_get_vq (int tid) return vq; } -/* See nat/aarch64-sve-linux-ptrace.h. */ +/* See nat/aarch64-scalable-linux-ptrace.h. */ bool aarch64_sve_set_vq (int tid, uint64_t vq) @@ -88,7 +89,7 @@ aarch64_sve_set_vq (int tid, uint64_t vq) return true; } -/* See nat/aarch64-sve-linux-ptrace.h. */ +/* See nat/aarch64-scalable-linux-ptrace.h. */ bool aarch64_sve_set_vq (int tid, struct reg_buffer_common *reg_buf) @@ -117,7 +118,7 @@ aarch64_sve_set_vq (int tid, struct reg_buffer_common *reg_buf) return aarch64_sve_set_vq (tid, sve_vq_from_vg (reg_vg)); } -/* See nat/aarch64-sve-linux-ptrace.h. */ +/* See nat/aarch64-scalable-linux-ptrace.h. */ std::unique_ptr aarch64_sve_get_sveregs (int tid) @@ -161,7 +162,7 @@ aarch64_maybe_swab128 (gdb_byte *dst, const gdb_byte *src, size_t size) #endif } -/* See nat/aarch64-sve-linux-ptrace.h. */ +/* See nat/aarch64-scalable-linux-ptrace.h. */ void aarch64_sve_regs_copy_to_reg_buf (struct reg_buffer_common *reg_buf, @@ -250,7 +251,7 @@ aarch64_sve_regs_copy_to_reg_buf (struct reg_buffer_common *reg_buf, } } -/* See nat/aarch64-sve-linux-ptrace.h. */ +/* See nat/aarch64-scalable-linux-ptrace.h. */ void aarch64_sve_regs_copy_from_reg_buf (const struct reg_buffer_common *reg_buf, diff --git a/gdb/nat/aarch64-sve-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h similarity index 90% rename from gdb/nat/aarch64-sve-linux-ptrace.h rename to gdb/nat/aarch64-scalable-linux-ptrace.h index 9539e199d34..2847c4e0263 100644 --- a/gdb/nat/aarch64-sve-linux-ptrace.h +++ b/gdb/nat/aarch64-scalable-linux-ptrace.h @@ -1,4 +1,5 @@ -/* Common target dependent for AArch64 systems. +/* Common target dependent definitions for AArch64 Scalable Extensions + (SVE/SME). Copyright (C) 2018-2023 Free Software Foundation, Inc. @@ -17,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef NAT_AARCH64_SVE_LINUX_PTRACE_H -#define NAT_AARCH64_SVE_LINUX_PTRACE_H +#ifndef NAT_AARCH64_SCALABLE_LINUX_PTRACE_H +#define NAT_AARCH64_SCALABLE_LINUX_PTRACE_H #include #include @@ -32,7 +33,7 @@ #include #ifndef SVE_SIG_ZREGS_SIZE -#include "aarch64-sve-linux-sigcontext.h" +#include "aarch64-scalable-linux-sigcontext.h" #endif /* Indicates whether a SVE ptrace header is followed by SVE registers or a @@ -69,4 +70,4 @@ extern void aarch64_sve_regs_copy_from_reg_buf (const struct reg_buffer_common *reg_buf, void *buf); -#endif /* NAT_AARCH64_SVE_LINUX_PTRACE_H */ +#endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */ diff --git a/gdb/nat/aarch64-sve-linux-sigcontext.h b/gdb/nat/aarch64-scalable-linux-sigcontext.h similarity index 96% rename from gdb/nat/aarch64-sve-linux-sigcontext.h rename to gdb/nat/aarch64-scalable-linux-sigcontext.h index aba3c1595d0..e0120e093a0 100644 --- a/gdb/nat/aarch64-sve-linux-sigcontext.h +++ b/gdb/nat/aarch64-scalable-linux-sigcontext.h @@ -1,4 +1,7 @@ -/* Copyright (C) 2018-2023 Free Software Foundation, Inc. +/* Linux Kernel sigcontext definitions for AArch64 Scalable Extensions + (SVE/SME). + + Copyright (C) 2018-2023 Free Software Foundation, Inc. Contributed by Arm Ltd. This file is part of GDB. @@ -16,8 +19,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef NAT_AARCH64_SVE_LINUX_SIGCONTEXT_H -#define NAT_AARCH64_SVE_LINUX_SIGCONTEXT_H +#ifndef NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H +#define NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H #define SVE_MAGIC 0x53564501 @@ -264,4 +267,4 @@ struct user_sve_header { SVE_PT_SVE_OFFSET + SVE_PT_SVE_SIZE(vq, flags) \ : SVE_PT_FPSIMD_OFFSET + SVE_PT_FPSIMD_SIZE(vq, flags)) -#endif /* NAT_AARCH64_SVE_LINUX_SIGCONTEXT_H */ +#endif /* NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */ diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in index 39cb9e7a151..b597515d428 100644 --- a/gdbserver/Makefile.in +++ b/gdbserver/Makefile.in @@ -218,7 +218,7 @@ SFILES = \ $(srcdir)/../gdb/arch/ppc-linux-common.c \ $(srcdir)/../gdb/arch/riscv.c \ $(srcdir)/../gdb/nat/aarch64-mte-linux-ptrace.c \ - $(srcdir)/../gdb/nat/aarch64-sve-linux-ptrace.c \ + $(srcdir)/../gdb/nat/aarch64-scalable-linux-ptrace.c \ $(srcdir)/../gdb/nat/linux-btrace.c \ $(srcdir)/../gdb/nat/linux-namespaces.c \ $(srcdir)/../gdb/nat/linux-osdata.c \ diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv index f0101994529..f625c808859 100644 --- a/gdbserver/configure.srv +++ b/gdbserver/configure.srv @@ -51,7 +51,7 @@ case "${gdbserver_host}" in srv_tgtobj="$srv_tgtobj arch/aarch64-mte-linux.o" srv_tgtobj="$srv_tgtobj linux-aarch64-tdesc.o" srv_tgtobj="$srv_tgtobj nat/aarch64-mte-linux-ptrace.o" - srv_tgtobj="$srv_tgtobj nat/aarch64-sve-linux-ptrace.o" + srv_tgtobj="$srv_tgtobj nat/aarch64-scalable-linux-ptrace.o" srv_tgtobj="${srv_tgtobj} $srv_linux_obj" srv_linux_regsets=yes srv_linux_thread_db=yes diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 2ed6e95562c..a20a3485ebc 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -44,7 +44,7 @@ #include "linux-aarch32-tdesc.h" #include "linux-aarch64-tdesc.h" #include "nat/aarch64-mte-linux-ptrace.h" -#include "nat/aarch64-sve-linux-ptrace.h" +#include "nat/aarch64-scalable-linux-ptrace.h" #include "tdesc.h" #ifdef HAVE_SYS_REG_H From patchwork Fri May 19 10:24:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69677 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 130483882019 for ; Fri, 19 May 2023 10:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 130483882019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492145; bh=2IeX+1Ufp3cBOq9t463SoQn8dktHmAGuIrwEPFO4CLU=; 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=FqYofVjGx2IA2ld1/DgBF0joYBvRf6fXwKLq3YLIRq40t981sExBFezQkpxZYAJH4 heZpglLTF6UnPpwojRTzsilopw6ADluo4t0JVTvr65CDnOjb7ZNUz11xQaznErZJVi eBgUejfTnBAk2IhSBLyQu9h1OkRCKXfSTE1Had+A= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2060.outbound.protection.outlook.com [40.107.6.60]) by sourceware.org (Postfix) with ESMTPS id 6B4FC3858401 for ; Fri, 19 May 2023 10:25:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B4FC3858401 Received: from AM7PR03CA0012.eurprd03.prod.outlook.com (2603:10a6:20b:130::22) by VI1PR08MB5424.eurprd08.prod.outlook.com (2603:10a6:803:136::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:23 +0000 Received: from AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:130:cafe::52) by AM7PR03CA0012.outlook.office365.com (2603:10a6:20b:130::22) 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:23 +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 AM7EUR03FT058.mail.protection.outlook.com (100.127.140.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:22 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Fri, 19 May 2023 10:25:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d0a1ae8c652fb272 X-CR-MTA-TID: 64aa7808 Received: from 57acbf0fa2bc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CF275D1D-C92F-4E2B-8558-1F8CFED015FE.1; Fri, 19 May 2023 10:25:15 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 57acbf0fa2bc.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=nwmXttP6qHfEc4ND5lmzZ/gdZUqn/Z+5YoMRFzNlRAAJwDhUa6KWucnQvUajWWzLJkvSyXYTO47FRIH8q7owuVq6Fm9qzqB7UBlLZhOcREpzngnBwPJ1SYadBGCpJHJOwqd3dWEpQPRIVjIiE60xkAyD10J3YOn3T8tsDlSCudAtxHWEsUE7wfdx+RMlZATfQiCNHJufLL2uPvPOrsJMmha+KXfd6pYQv+FcasxCNhL+a1nBwN9mS1MAyV55mpWMj2YdnNJvPsMlraI++RWz/smjTXxeY10TWiq6ASWCyaYX3ZncAGzlJ1TVn4uta1zPxZO++E06slKEhtGApVHc8Q== 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=2IeX+1Ufp3cBOq9t463SoQn8dktHmAGuIrwEPFO4CLU=; b=SfoYbzJRbU+R++JEf3M3OSDAS+U/gu5xV41Dm4ZIrXZe1xBh+kujMWlaW/gSUtExwRLPToKpLqZ1M/ah3fK3f7q79SaHbSVuhQ/6n3jmryD5DGXC9o0V2/ACFlKsb0kpGyUlyZSUGPdsMsqKGtqZzGQiUAyIGNcXuxFKsSwPBPAlCvRCUriQdiXpIJOmpbjxr1a9xhKSreRsj2cvcZkOvdXQZgQs0RWXag8FtMYYl9e92tFoyU9sWpdaf06NzlouWcvSL8cUalNTcvykJ83VnC5V2RDPq2ersD2ZbRGZu4UrP/S5R1PgZ4xOu9rau3e7jqFP/6dCjHDRX999JTmigQ== 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 AS9PR05CA0205.eurprd05.prod.outlook.com (2603:10a6:20b:495::12) by PAVPR08MB10332.eurprd08.prod.outlook.com (2603:10a6:102:327::11) 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:12 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:495:cafe::f) by AS9PR05CA0205.outlook.office365.com (2603:10a6:20b:495::12) 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:12 +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:12 +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:11 +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:11 +0000 To: Subject: [PATCH v2 03/17] [gdb/gdbserver] refactor: Simplify SVE interface to read/write registers Date: Fri, 19 May 2023 11:24:54 +0100 Message-ID: <20230519102508.14020-4-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_|PAVPR08MB10332:EE_|AM7EUR03FT058:EE_|VI1PR08MB5424:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c7b9726-d5f0-4f55-7ab7-08db58535aaa 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: X3YBtYyMSlvGz2i3vRsR6llDV70Ts7JhoGv0L3HBFf55CTiHv9T4eZgHCqQstzwHP3W5Np8c0vFjnAcVCVow+8eVWvCX+vvgz03XherNkSmVtUslLrwwoIZi5Dxiju95LTdYUTfUrOsVt9q3ryGa/+52cliBvFli4WiuOt2OCnuwQwkCcbL0mfurUjxTJAfFfLgw4Ap06jJkgZm2qIJpxDhNKqZANN+MbEY/LxDIXl3v6CypZlXoiKpX5tO7fev3yqsoBlXfbGiLkcYbDcAnSVsPrOjvCFpmA62frLRBgCTH6YbXBMeB//nc7qsRK/dz1kTmB2ueWjjg+NlVqh2Cvvrjo8QDmjqAelldKcx/EXnLpEeJffPPD0fTWQG+jo0EDB21IzhZPwIWspIY64MF65aBIfBGiaX+P9SSUG95ewMStbU2JDKz5DAXH9y7mZp9bC9krdk2onRLviskRJlm84OnY9Sx2rr9N71PE6cZKUuAO/OfGZgAsjzM/Z/mSRhKKNNpi2kdzW1Ua1OZnRMrTSANjgH88UDd63AMjzGem2vFlHPugPWpSR9xKDh0XjKWQYxl1z8Nzy3/6ZZLga1KCvCxJIL4AjT49uHgku1lRj8nEO4BHWIYSM81LE2Xp1cjPdjdJYeC0KmrtY8E1nQGIDxz4vnaVPrvH1WeQzLluXyDSNwxkRGC3ZBbTmbA8G+r4tPocNUjrI3oB8D/CS386RZAUL3U+NIU75EAGCctYmGHqxLlHgeeyajpfyLd8kD1BAZ57SJ8E3GGEq4jkS+Csw== 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)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(86362001)(36756003)(70206006)(316002)(70586007)(6916009)(478600001)(40480700001)(82310400005)(426003)(2906002)(5660300002)(30864003)(8676002)(8936002)(6666004)(44832011)(356005)(81166007)(82740400003)(36860700001)(26005)(186003)(83380400001)(47076005)(1076003)(2616005)(41300700001)(336012)(7696005)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB10332 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ac65cfbf-47a9-4569-666b-08db5853546a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ahzgx57p9PAAG2u+OgyGYk9Ys6Rpo1y2aicwIU8OS0QlFqKp1T1jtZZrf4KRpJlr+Aq2045uzxG6tJgLyYswNAwvwiXSGVSp0tyuui/6dxBKj6gzKT1ci3PiU2YdzCZjzzktOA5Y2BZWMa5tU2JrxqTuOcGn/W4AobEHsuyx1J+vp2lhzG/lMWXpRCXHrarIrPgX9reCiZGl+U5zLoea3nzGn5l6G1rAEWKpOsgH08prvqSA8D6YzLmCYgA9rgJ7TMLqqFYtRlwtXWcVhDou7BxqT2c9v00j7yPA4iFo3fHMvQqwQXzoXaKIzHXo+xOyTtueyRaiF/JuRtf2VOz8d/XEkssj/GIgbdwXKG8cz/VYOKfzejRj1NG9kxN+oAPZbEe+jA0yZCOHqzCTbg7y72YqDVyCpna921baVktVpKpgDE7XcjHO3PsyO0ceDtVmlCz5jNhWObbfVqn7AR86tfFByj2ChtenTK4MLspHiG81EVe7fO3ZNkxLepji1aNlON0zJwXXvxTH6ZdjhjvsD9Dt+Be7MNlZafzCiPZ9+Th73zPHtvXsFZs1DtaQ+jOm48R+ZWeVq34pDsr4g2AMrzQ9Yxv02sqVfZLZjN3VFXR5OxH6woXRbu9sPlXeiV+Q0CMBhe42D2obqiMT+xCKSGZKxPbt3/HAMmXfj8+PNpCbpVrtxFchXMsDy2tHLb1tkEDb+rM5dRHW1XlXGdnIpfd773qT6NgtMDErmwBi19xCTSJVpagw+8Fhf7QJ5SuY 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)(136003)(346002)(39850400004)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(26005)(40460700003)(1076003)(7696005)(36860700001)(83380400001)(47076005)(2616005)(40480700001)(336012)(36756003)(426003)(86362001)(82310400005)(186003)(82740400003)(81166007)(44832011)(478600001)(30864003)(2906002)(316002)(8936002)(6916009)(8676002)(41300700001)(5660300002)(70586007)(70206006)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:22.9084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c7b9726-d5f0-4f55-7ab7-08db58535aaa 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: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5424 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" This is a patch in preparation to upcoming patches enabling SME support. It attempts to simplify the gdb/gdbserver shared interface used to read/write SVE registers. Where the current code makes use of unique_ptr, allocating a new buffer by hand and passing a buffer around, this patch makes that code use gdb::byte_vector and passes a reference to this byte vector to the functions, allowing the functions to have ready access to the size of the buffer. It also shares a bit more code between gdb and gdbserver, in particular around handling of ptrace get/set requests for SVE. I think gdbserver could be refactored to handle register reads/writes more like gdb's native layer as opposed to letting the generic linux-low layer do the ptrace calls. This is not very flexible and assumes one size for the responses. If you have something like NT_ARM_SVE, where you can have either FPSIMD or SVE contents, it doesn't work that well. I didn't want to change that interface right now as it is a bit too much work and touches all the targets, some of which I can't easily test. Hence the reason why the buffer the generic linux-now passes down to linux-aarch64-low is unused or ignored. No user-visible changes should happen as part of this refactor other than a slightly reworded warning message. While doing the refactor, I also noticed what seems to be a mistake in checking if the register cache contains active (non-zero) SVE data. For instance, the original code did something like this in aarch64_sve_regs_copy_from_reg_buf: has_sve_state |= reg_buf->raw_compare (AARCH64_SVE_Z0_REGNUM + i reg, sizeof (__int128_t)); "reg" is a zeroed-out buffer that we compare the Z register contents past the first 128 bits. The problem here is that raw_compare returns 1 if the contents compare the same, which means has_sve_state will be true. But if we compared the Z register contents to 0, it means we *do not* have SVE state, and therefore has_sve_state should be false. The consequence of this mistake is that we convert the initial FPSIMD-formatted data we get from ptrace for the NT_ARM_SVE register set to a SVE-formatted one. In the end, this doesn't cause user-visible differences because the values of both the Z and V registers will still be the same. But the logic is not correct. I used the opportunity to fix this, and it gets tested later on by the additional SME tests. I do plan on submitting some SVE-specific tests to make sure we have a bit more coverage in GDB's testsuite. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-nat.c | 30 +--- gdb/nat/aarch64-scalable-linux-ptrace.c | 203 +++++++++++++++--------- gdb/nat/aarch64-scalable-linux-ptrace.h | 28 ++-- gdbserver/linux-aarch64-low.cc | 24 ++- 4 files changed, 175 insertions(+), 110 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 0dd9652d001..a775631e9ec 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -319,9 +319,8 @@ store_fpregs_to_thread (const struct regcache *regcache) static void fetch_sveregs_from_thread (struct regcache *regcache) { - std::unique_ptr base - = aarch64_sve_get_sveregs (regcache->ptid ().lwp ()); - aarch64_sve_regs_copy_to_reg_buf (regcache, base.get ()); + /* Fetch SVE state from the thread and copy it into the register cache. */ + aarch64_sve_regs_copy_to_reg_buf (regcache->ptid ().lwp (), regcache); } /* Store to the current thread the valid sve register @@ -330,28 +329,9 @@ fetch_sveregs_from_thread (struct regcache *regcache) static void store_sveregs_to_thread (struct regcache *regcache) { - int ret; - struct iovec iovec; - int tid = regcache->ptid ().lwp (); - - /* First store vector length to the thread. This is done first to ensure the - ptrace buffers read from the kernel are the correct size. */ - if (!aarch64_sve_set_vq (tid, regcache)) - perror_with_name (_("Unable to set VG register")); - - /* Obtain a dump of SVE registers from ptrace. */ - std::unique_ptr base = aarch64_sve_get_sveregs (tid); - - /* Overwrite with regcache state. */ - aarch64_sve_regs_copy_from_reg_buf (regcache, base.get ()); - - /* Write back to the kernel. */ - iovec.iov_base = base.get (); - iovec.iov_len = ((struct user_sve_header *) base.get ())->size; - ret = ptrace (PTRACE_SETREGSET, tid, NT_ARM_SVE, &iovec); - - if (ret < 0) - perror_with_name (_("Unable to store sve registers")); + /* Fetch SVE state from the register cache and update the thread TID with + it. */ + aarch64_sve_regs_copy_from_reg_buf (regcache->ptid ().lwp (), regcache); } /* Fill GDB's register array with the pointer authentication mask values from diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c index cc43f510892..192eebcda19 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.c +++ b/gdb/nat/aarch64-scalable-linux-ptrace.c @@ -120,28 +120,44 @@ aarch64_sve_set_vq (int tid, struct reg_buffer_common *reg_buf) /* See nat/aarch64-scalable-linux-ptrace.h. */ -std::unique_ptr -aarch64_sve_get_sveregs (int tid) +gdb::byte_vector +aarch64_fetch_sve_regset (int tid) { - struct iovec iovec; uint64_t vq = aarch64_sve_get_vq (tid); if (vq == 0) - perror_with_name (_("Unable to fetch SVE register header")); + perror_with_name (_("Unable to fetch SVE vector length")); /* A ptrace call with NT_ARM_SVE will return a header followed by either a dump of all the SVE and FP registers, or an fpsimd structure (identical to the one returned by NT_FPREGSET) if the kernel has not yet executed any SVE code. Make sure we allocate enough space for a full SVE dump. */ - iovec.iov_len = SVE_PT_SIZE (vq, SVE_PT_REGS_SVE); - std::unique_ptr buf (new gdb_byte[iovec.iov_len]); - iovec.iov_base = buf.get (); + gdb::byte_vector sve_state (SVE_PT_SIZE (vq, SVE_PT_REGS_SVE), 0); + + struct iovec iovec; + iovec.iov_base = sve_state.data (); + iovec.iov_len = sve_state.size (); if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_SVE, &iovec) < 0) perror_with_name (_("Unable to fetch SVE registers")); - return buf; + return sve_state; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +aarch64_store_sve_regset (int tid, const gdb::byte_vector &sve_state) +{ + struct iovec iovec; + iovec.iov_base = (void *) sve_state.data (); + iovec.iov_len = sve_state.size (); + + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_SVE, &iovec) < 0) + perror_with_name (_("Unable to store SVE registers")); + + return true; } /* If we are running in BE mode, byteswap the contents @@ -165,11 +181,13 @@ aarch64_maybe_swab128 (gdb_byte *dst, const gdb_byte *src, size_t size) /* See nat/aarch64-scalable-linux-ptrace.h. */ void -aarch64_sve_regs_copy_to_reg_buf (struct reg_buffer_common *reg_buf, - const void *buf) +aarch64_sve_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf) { - char *base = (char *) buf; - struct user_sve_header *header = (struct user_sve_header *) buf; + gdb::byte_vector sve_state = aarch64_fetch_sve_regset (tid); + + char *base = (char *) sve_state.data (); + struct user_sve_header *header + = (struct user_sve_header *) sve_state.data (); uint64_t vq = sve_vq_from_vl (header->vl); uint64_t vg = sve_vg_from_vl (header->vl); @@ -249,18 +267,33 @@ aarch64_sve_regs_copy_to_reg_buf (struct reg_buffer_common *reg_buf, reg_buf->raw_supply (AARCH64_SVE_FFR_REGNUM, reg); } + + /* At this point we have updated the register cache with the contents of + the NT_ARM_SVE register set. */ } /* See nat/aarch64-scalable-linux-ptrace.h. */ void -aarch64_sve_regs_copy_from_reg_buf (const struct reg_buffer_common *reg_buf, - void *buf) +aarch64_sve_regs_copy_from_reg_buf (int tid, + struct reg_buffer_common *reg_buf) { - struct user_sve_header *header = (struct user_sve_header *) buf; - char *base = (char *) buf; + /* First store the vector length to the thread. This is done first to + ensure the ptrace buffers read from the kernel are the correct size. */ + if (!aarch64_sve_set_vq (tid, reg_buf)) + perror_with_name (_("Unable to set VG register")); + + /* Obtain a dump of SVE registers from ptrace. */ + gdb::byte_vector sve_state = aarch64_fetch_sve_regset (tid); + + struct user_sve_header *header = (struct user_sve_header *) sve_state.data (); uint64_t vq = sve_vq_from_vl (header->vl); + gdb::byte_vector new_state (SVE_PT_SIZE (32, SVE_PT_REGS_SVE), 0); + memcpy (new_state.data (), sve_state.data (), sve_state.size ()); + header = (struct user_sve_header *) new_state.data (); + char *base = (char *) new_state.data (); + /* Sanity check the data in the header. */ if (!sve_vl_valid (header->vl) || SVE_PT_SIZE (vq, header->flags) != header->size) @@ -275,36 +308,40 @@ aarch64_sve_regs_copy_from_reg_buf (const struct reg_buffer_common *reg_buf, resulting in the initialization of SVE state written back to the kernel, which is why we try to avoid it. */ - bool has_sve_state = false; - gdb_byte *reg = (gdb_byte *) alloca (SVE_PT_SVE_ZREG_SIZE (vq)); - struct user_fpsimd_state *fpsimd - = (struct user_fpsimd_state *)(base + SVE_PT_FPSIMD_OFFSET); - - memset (reg, 0, SVE_PT_SVE_ZREG_SIZE (vq)); + /* Buffer (using the maximum size a Z register) used to look for zeroed + out sve state. */ + gdb_byte reg[256]; + memset (reg, 0, sizeof (reg)); /* Check in the reg_buf if any of the Z registers are set after the first 128 bits, or if any of the other SVE registers are set. */ - + bool has_sve_state = false; for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++) { - has_sve_state |= reg_buf->raw_compare (AARCH64_SVE_Z0_REGNUM + i, - reg, sizeof (__int128_t)); - if (has_sve_state) - break; + if (!reg_buf->raw_compare (AARCH64_SVE_Z0_REGNUM + i, reg, + V_REGISTER_SIZE)) + { + has_sve_state = true; + break; + } } if (!has_sve_state) for (int i = 0; i < AARCH64_SVE_P_REGS_NUM; i++) { - has_sve_state |= reg_buf->raw_compare (AARCH64_SVE_P0_REGNUM + i, - reg, 0); - if (has_sve_state) - break; + if (!reg_buf->raw_compare (AARCH64_SVE_P0_REGNUM + i, reg, 0)) + { + has_sve_state = true; + break; + } } if (!has_sve_state) - has_sve_state |= reg_buf->raw_compare (AARCH64_SVE_FFR_REGNUM, - reg, 0); + has_sve_state + = !reg_buf->raw_compare (AARCH64_SVE_FFR_REGNUM, reg, 0); + + struct user_fpsimd_state *fpsimd + = (struct user_fpsimd_state *)(base + SVE_PT_FPSIMD_OFFSET); /* If no SVE state exists, then use the existing fpsimd structure to write out state and return. */ @@ -344,50 +381,74 @@ aarch64_sve_regs_copy_from_reg_buf (const struct reg_buffer_common *reg_buf, if (REG_VALID == reg_buf->get_register_status (AARCH64_FPCR_REGNUM)) reg_buf->raw_collect (AARCH64_FPCR_REGNUM, &fpsimd->fpcr); - return; - } - - /* Otherwise, reformat the fpsimd structure into a full SVE set, by - expanding the V registers (working backwards so we don't splat - registers before they are copied) and using null for everything else. - Note that enough space for a full SVE dump was originally allocated - for base. */ + /* At this point we have collected all the data from the register + cache and we are ready to update the FPSIMD register content + of the thread. */ - header->flags |= SVE_PT_REGS_SVE; - header->size = SVE_PT_SIZE (vq, SVE_PT_REGS_SVE); + /* Fall through so we can update the thread's contents with the + FPSIMD register cache values. */ + } + else + { + /* Otherwise, reformat the fpsimd structure into a full SVE set, by + expanding the V registers (working backwards so we don't splat + registers before they are copied) and using zero for everything + else. + Note that enough space for a full SVE dump was originally allocated + for base. */ + + header->flags |= SVE_PT_REGS_SVE; + header->size = SVE_PT_SIZE (vq, SVE_PT_REGS_SVE); + + memcpy (base + SVE_PT_SVE_FPSR_OFFSET (vq), &fpsimd->fpsr, + sizeof (uint32_t)); + memcpy (base + SVE_PT_SVE_FPCR_OFFSET (vq), &fpsimd->fpcr, + sizeof (uint32_t)); + + for (int i = AARCH64_SVE_Z_REGS_NUM; i >= 0 ; i--) + { + memcpy (base + SVE_PT_SVE_ZREG_OFFSET (vq, i), &fpsimd->vregs[i], + sizeof (__int128_t)); + } - memcpy (base + SVE_PT_SVE_FPSR_OFFSET (vq), &fpsimd->fpsr, - sizeof (uint32_t)); - memcpy (base + SVE_PT_SVE_FPCR_OFFSET (vq), &fpsimd->fpcr, - sizeof (uint32_t)); + /* At this point we have converted the FPSIMD layout to an SVE + layout and copied the register data. - for (int i = AARCH64_SVE_Z_REGS_NUM; i >= 0 ; i--) - { - memcpy (base + SVE_PT_SVE_ZREG_OFFSET (vq, i), &fpsimd->vregs[i], - sizeof (__int128_t)); + Fall through so we can update the thread's contents with the SVE + register cache values. */ } } + else + { + /* We already have SVE state for this thread, so we just need to update + the values of the registers. */ + for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++) + if (REG_VALID == reg_buf->get_register_status (AARCH64_SVE_Z0_REGNUM + + i)) + reg_buf->raw_collect (AARCH64_SVE_Z0_REGNUM + i, + base + SVE_PT_SVE_ZREG_OFFSET (vq, i)); - /* Replace the kernel values with those from reg_buf. */ - - for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++) - if (REG_VALID == reg_buf->get_register_status (AARCH64_SVE_Z0_REGNUM + i)) - reg_buf->raw_collect (AARCH64_SVE_Z0_REGNUM + i, - base + SVE_PT_SVE_ZREG_OFFSET (vq, i)); - - for (int i = 0; i < AARCH64_SVE_P_REGS_NUM; i++) - if (REG_VALID == reg_buf->get_register_status (AARCH64_SVE_P0_REGNUM + i)) - reg_buf->raw_collect (AARCH64_SVE_P0_REGNUM + i, - base + SVE_PT_SVE_PREG_OFFSET (vq, i)); + for (int i = 0; i < AARCH64_SVE_P_REGS_NUM; i++) + if (REG_VALID == reg_buf->get_register_status (AARCH64_SVE_P0_REGNUM + + i)) + reg_buf->raw_collect (AARCH64_SVE_P0_REGNUM + i, + base + SVE_PT_SVE_PREG_OFFSET (vq, i)); + + if (REG_VALID == reg_buf->get_register_status (AARCH64_SVE_FFR_REGNUM)) + reg_buf->raw_collect (AARCH64_SVE_FFR_REGNUM, + base + SVE_PT_SVE_FFR_OFFSET (vq)); + if (REG_VALID == reg_buf->get_register_status (AARCH64_FPSR_REGNUM)) + reg_buf->raw_collect (AARCH64_FPSR_REGNUM, + base + SVE_PT_SVE_FPSR_OFFSET (vq)); + if (REG_VALID == reg_buf->get_register_status (AARCH64_FPCR_REGNUM)) + reg_buf->raw_collect (AARCH64_FPCR_REGNUM, + base + SVE_PT_SVE_FPCR_OFFSET (vq)); + } - if (REG_VALID == reg_buf->get_register_status (AARCH64_SVE_FFR_REGNUM)) - reg_buf->raw_collect (AARCH64_SVE_FFR_REGNUM, - base + SVE_PT_SVE_FFR_OFFSET (vq)); - if (REG_VALID == reg_buf->get_register_status (AARCH64_FPSR_REGNUM)) - reg_buf->raw_collect (AARCH64_FPSR_REGNUM, - base + SVE_PT_SVE_FPSR_OFFSET (vq)); - if (REG_VALID == reg_buf->get_register_status (AARCH64_FPCR_REGNUM)) - reg_buf->raw_collect (AARCH64_FPCR_REGNUM, - base + SVE_PT_SVE_FPCR_OFFSET (vq)); + /* At this point we have collected all the data from the register cache and + we are ready to update the SVE/FPSIMD register contents of the thread. + sve_state should contain all the data in the correct format, ready to be + passed on to ptrace. */ + aarch64_store_sve_regset (tid, new_state); } diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h index 2847c4e0263..3215103c88a 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.h +++ b/gdb/nat/aarch64-scalable-linux-ptrace.h @@ -52,22 +52,28 @@ uint64_t aarch64_sve_get_vq (int tid); bool aarch64_sve_set_vq (int tid, uint64_t vq); bool aarch64_sve_set_vq (int tid, struct reg_buffer_common *reg_buf); -/* Read the current SVE register set using ptrace, allocating space as - required. */ +/* Read the current SVE register set from thread TID and return its data + through a byte vector. */ -extern std::unique_ptr aarch64_sve_get_sveregs (int tid); +extern gdb::byte_vector aarch64_fetch_sve_regset (int tid); -/* Put the registers from linux structure buf into register buffer. Assumes the - vector lengths in the register buffer match the size in the kernel. */ +/* Write the SVE contents from SVE_STATE to thread TID. Return true if + successful and false otherwise. */ -extern void aarch64_sve_regs_copy_to_reg_buf (struct reg_buffer_common *reg_buf, - const void *buf); +extern bool +aarch64_store_sve_regset (int tid, const gdb::byte_vector &sve_state); -/* Put the registers from register buffer into linux structure buf. Assumes the - vector lengths in the register buffer match the size in the kernel. */ +/* Given a thread id TID and a register buffer REG_BUF, update the register + buffer with the SVE state from thread TID. */ extern void -aarch64_sve_regs_copy_from_reg_buf (const struct reg_buffer_common *reg_buf, - void *buf); +aarch64_sve_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf); + +/* Given a thread id TID and a register buffer REG_BUF containing SVE + register data, write the SVE data to thread TID. */ + +extern void +aarch64_sve_regs_copy_from_reg_buf (int tid, + struct reg_buffer_common *reg_buf); #endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */ diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index a20a3485ebc..af2e0fd9c10 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -719,9 +719,18 @@ aarch64_target::low_new_fork (process_info *parent, /* Wrapper for aarch64_sve_regs_copy_to_reg_buf. */ static void -aarch64_sve_regs_copy_to_regcache (struct regcache *regcache, const void *buf) +aarch64_sve_regs_copy_to_regcache (struct regcache *regcache, + ATTRIBUTE_UNUSED const void *buf) { - return aarch64_sve_regs_copy_to_reg_buf (regcache, buf); + /* BUF is unused here since we collect the data straight from a ptrace + request in aarch64_sve_regs_copy_to_reg_buf, therefore bypassing + gdbserver's own call to ptrace. */ + + int tid = lwpid_of (current_thread); + + /* Update the register cache. aarch64_sve_regs_copy_to_reg_buf handles + fetching the NT_ARM_SVE state from thread TID. */ + aarch64_sve_regs_copy_to_reg_buf (tid, regcache); } /* Wrapper for aarch64_sve_regs_copy_from_reg_buf. */ @@ -729,7 +738,16 @@ aarch64_sve_regs_copy_to_regcache (struct regcache *regcache, const void *buf) static void aarch64_sve_regs_copy_from_regcache (struct regcache *regcache, void *buf) { - return aarch64_sve_regs_copy_from_reg_buf (regcache, buf); + int tid = lwpid_of (current_thread); + + /* Update the thread SVE state. aarch64_sve_regs_copy_from_reg_buf + handles writing the SVE/FPSIMD state back to thread TID. */ + aarch64_sve_regs_copy_from_reg_buf (tid, regcache); + + /* We need to return the expected data in BUF, so copy whatever the kernel + already has to BUF. */ + gdb::byte_vector sve_state = aarch64_fetch_sve_regset (tid); + memcpy (buf, sve_state.data (), sve_state.size ()); } /* Array containing all the possible register sets for AArch64/Linux. During From patchwork Fri May 19 10:24:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69671 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 1018B3844053 for ; Fri, 19 May 2023 10:27:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1018B3844053 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492051; bh=yNZxAug8uubWan8UPQH9Jyc937LWQb8s8sO+n+Zf2rg=; 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=f1LBQECpfY0BFZic7f51trQLkbA+kPiF53AAsFP1fdHNwPJO/xV/yfBU7Z9G6h0WN ZdvhEnMU5bpoSo4FqpnVZGJA15MaVc9o7ryLR10YMhpFRktQ21xXg3TLRq5/QWKT58 FsitKDzaKjQbJlQzYQcsCCCpO+/haVjszBL/C6RU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::61e]) by sourceware.org (Postfix) with ESMTPS id B95983858C2F for ; Fri, 19 May 2023 10:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B95983858C2F Received: from DU2PR04CA0248.eurprd04.prod.outlook.com (2603:10a6:10:28e::13) by GV1PR08MB8451.eurprd08.prod.outlook.com (2603:10a6:150:83::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:23 +0000 Received: from DBAEUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::1f) by DU2PR04CA0248.outlook.office365.com (2603:10a6:10:28e::13) 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:23 +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 DBAEUR03FT058.mail.protection.outlook.com (100.127.142.120) 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:23 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Fri, 19 May 2023 10:25:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fc87ba369dc985f7 X-CR-MTA-TID: 64aa7808 Received: from b5b0e54ca8d3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7599BB3F-0E3E-4DEE-8BC7-F4CA8A3A443E.1; Fri, 19 May 2023 10:25:16 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b5b0e54ca8d3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZHz2EKwbZXi7U1baJ4s0D7+Ap4l/laDTbuFw6tau5S38hIFFXRrYko16N+N+ShxvyWxHRs8BAK3p3PbjvdyVT3SLcEsTUsrOXPaJjLzy39kSb13MQSn1Mn/KBardAKjwrOxAdklud23EnK/WI6TSsArsoT6QN+LWzInYdgx0d4c2Ke5zaIFi+U5RkhDPQeE8KcaxVd7ff5pj8GmmckhoMxJzHLT5UD8oSgdJWE5U9wFSAjr4x2AtTDxUUDvUiaz0DpneOZ2TImBNDmgeiWATVszONjPfOjn6QlyOVmrhyNQf2J5AFubHBzoGNachaBf2XlLwpN4vCfqgAauGC3GxuQ== 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=yNZxAug8uubWan8UPQH9Jyc937LWQb8s8sO+n+Zf2rg=; b=S13Wc/ab9l5e/kUpJolNcVxQdF4L4dsgrM+B574nd/ciwvcCKxoBJNnD2hogFudUdokHZIU2VnC8OAzU80JG7A9XOsg2l8PcFsgBEj0xftGEfNO6nLjmHVTp907Rsj5AuVIOgpmGTOkKRhNWC+jiXR0QvvzmuQ8E74i3OcuV9q0A9eflW+uSV8JxNzSWYyKN2sjmrXnchVHmBtJSzFbjgK3M6i7Z3unKSRhIaZW2GhIln60/8S2vCO1ugVqkilH7VizoKBWEKi49l0HTLCe5sztBlP81UkQ8fcJutCy2f/rEC8LuttrgZcL3gYIm5PiZZ040tCep3LDiZlCGRJ8lRg== 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 AS8PR04CA0121.eurprd04.prod.outlook.com (2603:10a6:20b:127::6) by GV2PR08MB9255.eurprd08.prod.outlook.com (2603:10a6:150:e3::10) 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:12 +0000 Received: from AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:127:cafe::58) by AS8PR04CA0121.outlook.office365.com (2603:10a6:20b:127::6) 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:12 +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 AM7EUR03FT039.mail.protection.outlook.com (100.127.140.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:12 +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:11 +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:11 +0000 To: Subject: [PATCH v2 04/17] [gdb/aarch64] sve: Fix return command when using V registers in a SVE-enabled target Date: Fri, 19 May 2023 11:24:55 +0100 Message-ID: <20230519102508.14020-5-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: AM7EUR03FT039:EE_|GV2PR08MB9255:EE_|DBAEUR03FT058:EE_|GV1PR08MB8451:EE_ X-MS-Office365-Filtering-Correlation-Id: 037d0ab1-4da6-4bb0-d44b-08db58535ac4 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: xcMoyVZhfCea6xKFIf/CjwcmfQ2NPkqeDdHnzPvpMDOiPFrGX0Dnx93H5e+g0prYfF5KWgjNaUDxTOyHjir61SSuh1hSdsxuU90Oy1OHa+sKnVDCj4ach5D8qmmAlmT889TpdZw828I4LmAOlIBT47Cy4pvt6FpWPKw2VSQs7nL3ItPf1phvTnTyTMNESLDEEdmWtuhfYNCQl/7b2DJ3JbGBmG9Cps7RCuhb28HP0bE7P8zyKI4+C9ltELCVD1srcUfg9+fuDxhNEn4bpT97XaR8EmnXSCRjXin2A+8f/HAYn8iwiiw/MR020ne3DsSErWqTCYdQma1cx/qoYZb8LzDZWVpN6Cc1VMq7v8eRlZIO0oNgypTiTfODTIxvp5iyOq46wVjMQgmDYwDhvwhD7qiqEfLrJbexUeIuxaj+fTk3II34SIFyIurkJBTBhWn6bgHMhFneRyku5VCXyJHSVnKtJxKOt9yCC7yLMZj03qp79M/24djaqC8+5A49dz2O1LdbjPMf95SJhAaCFOvspwoSQyrDYqKKATkJUiBGeG+ebDb1UQzOS6rmLzM+nnbzjZnfz9ntHrpubAlmKM0Db9zkeZehfwOFsQMFqh+EdfcEbYnETuEYdaPw0P3u/ry7JyPg5+SWUodRANOCELfgv90e4CoFR8s4LQqxWgevJS9aPzb1s9gYJ9DdnImdCmz/fVTUM8Ep39n3gtkgFMiERCFLgcBXYwvL/FD5X4npuit5gIaQZv8cJoxT6xymveoouDU1RGb6VD8xTxWTkQv7ug== 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)(136003)(376002)(39860400002)(346002)(451199021)(36840700001)(46966006)(40470700004)(40460700003)(7696005)(70206006)(6916009)(70586007)(478600001)(316002)(36756003)(47076005)(83380400001)(26005)(426003)(1076003)(2616005)(36860700001)(336012)(186003)(44832011)(2906002)(8676002)(8936002)(82310400005)(40480700001)(81166007)(82740400003)(5660300002)(86362001)(356005)(6666004)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB9255 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 03b8479e-1058-42d9-7d3e-08db5853548d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xOGn68kuM1M8Ymsx6pFHv8svz6Qzn4A15fVHwhq29h5OOPCi6Ablaeuz72aroqDn9ovg6/UF3C+w1oHNba1KkOROPNUv1wBfKUX+hder80OkU7HnWVSMTj9KKP46pvH7Rprpue4iRpXjbfagjyoFu9KxuhyMnkSrYiwV9ruBarcGtVRdtsG33xK439JWPTKv3Y5O+pqaMlglVvRjCiL8r6ATShFU5jMAKrCFbOQbN3QHFUZMiIBU7WjT6lBUkDvA1w/tM5y1LMbSJso5HMEQ2svSHNp8+IRHHqS9VN5BB5mTJ4Yrvg+kVePOwJt0nJSTzz14qnXuxEmcJcWm6H/o/jWuPwRfd0xAxYffcgA7bixILz/uVGeCnrn9IoBjl8HUY6jUBmB888indlxuaxpcHannU97qT9FH3EVWHJCbUV5WjlZR7iQWHAyIeIrgXJc04rUEpXWvbUcznIj7FXVsghAvKCkdQ6Bi8K23xPmSOBFSJj2H9knVmI5cXZtqc7YNBU9DdeE3dr6Tq/lAVlnXLHxpE9RW1jywhaE/3LK0A85nsAc5aas2BaalmYddcQwBiSwVch+P1/yc4PiYXvE0VT5rLA5mJEKhNV+Edyd6vXuByt1ijeehGgDd74V+r54jdHTHeFd/Su5YrO3WxaHE58FsE0+YouliRsS8lybJWPpdKZRouYCq2noNTkeqLbDsQhtVodix5DwMAXzWBgS8pI3Q4nSSI6bB+MANU0+eRyw5jeiG90z72679Ytevd9WW 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)(39860400002)(346002)(376002)(396003)(136003)(451199021)(40470700004)(36840700001)(46966006)(86362001)(36756003)(316002)(70206006)(6916009)(70586007)(478600001)(40480700001)(6666004)(82310400005)(8936002)(8676002)(5660300002)(41300700001)(2906002)(44832011)(81166007)(82740400003)(7696005)(186003)(336012)(426003)(2616005)(26005)(1076003)(36860700001)(47076005)(83380400001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:23.1435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 037d0ab1-4da6-4bb0-d44b-08db58535ac4 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: DBAEUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8451 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, 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" In a target without SVE support, the V registers have a size of 16 bytes, otherwise they may have a size bigger than 16 bytes (depending on the current vector length for the Z registers, as they overlap the V registers). In aarch64-tdep.c:aarch64_store_return_value, the code is laid out in a way that allocates the buffer with the size of the register, but only updates the amount of bytes for the particular type we're returning. This may cause a situation where we have a register size of 32 bytes but are returning a floating point value of 8 bytes. The temporary buffer will therefore have 32 bytes, but we'll only update 8 bytes of it. When we write the entire register back, it will have potentially 24 bytes of garbage in it. Fix this by first reading the original contents of the register and then overriding only the bytes that we need for the return value. Tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-tdep.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 6402b28158e..5a2c924f82d 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2411,6 +2411,11 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, ("write HFA or HVA return value element %d to %s", i + 1, gdbarch_register_name (gdbarch, regno)); + /* Depending on whether the target supports SVE or not, the V + registers may report a size > 16 bytes. In that case, read the + original contents of the register before overriding it with a new + value that has a potential size <= 16 bytes. */ + regs->cooked_read (regno, tmpbuf); memcpy (tmpbuf, valbuf, len > V_REGISTER_SIZE ? V_REGISTER_SIZE : len); regs->cooked_write (regno, tmpbuf); From patchwork Fri May 19 10:24:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69673 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 6DE19388202F for ; Fri, 19 May 2023 10:27:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DE19388202F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492073; bh=iaelJ0ehofR6NJQIinx4SdVGtqMY8ijkQahwWhMdN2U=; 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=KrHu8IqGra3uk/NQ/m5tb6PfhH7YNtFFNGTkrVswM+wCv3OqLo/Yo29d1Nd22rPK8 +RxjbP5f8I6CtQ1XjjphoDvz5i2qaTTM9ggYLjdAvxPu9+R3kGoMUSRq57ugKRXERi 6cPnwFxfrB1ST90f/xWQktGZSm3jRF5BKZETPYFA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by sourceware.org (Postfix) with ESMTPS id 09E533858C39 for ; Fri, 19 May 2023 10:25:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09E533858C39 Received: from AM7PR03CA0007.eurprd03.prod.outlook.com (2603:10a6:20b:130::17) by AS2PR08MB10084.eurprd08.prod.outlook.com (2603:10a6:20b:648::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:25 +0000 Received: from AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:130:cafe::a2) by AM7PR03CA0007.outlook.office365.com (2603:10a6:20b:130::17) 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:25 +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 AM7EUR03FT058.mail.protection.outlook.com (100.127.140.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:25 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Fri, 19 May 2023 10:25:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b74f724a444e3f79 X-CR-MTA-TID: 64aa7808 Received: from 914347cab487.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BF545D02-CED8-41E1-9098-925A1044BDF3.1; Fri, 19 May 2023 10:25:17 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 914347cab487.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YJsf6FN9RsMZrSt1bqnc3krQylHUZCF0Sbjifp0ugM3KzKuK+P+F7oSMNS4A/gVCgZyFkQPfqkGpC6vUnN7oVzD4y3kMWEIHCwxs7LsN/vhQFElBXEhaJO1PSH8svq/lHXJEoTaa7tdRXH8lWzmVxfXU/BjGKlRHM0056BDzSSWmrddL5tnQjU1LCYR9KG5nFjS8Ww6CgqoV7hWLVzXtLrXFZOt2KgNQ2sh5FAujMJU5IIa/byh9jpzSPJv4wXZbWGa5PmrBdvUkQ/FzIlNvNooGcOOjbiJwlpEheWVAmHv6RzPUrRpbgk+F+kz0oclV95OJfDWAodVNQCBQAlWNZA== 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=iaelJ0ehofR6NJQIinx4SdVGtqMY8ijkQahwWhMdN2U=; b=CkPGyQ8wPsB/LyiRQmBCb+MYfESTuYcM3HF2ItlM+m9vcXb/G2RFIgPD8I0gyxvu8PkwP2tV7BgxAe823PypWIahzrbz937MszgORyvg3owuqTpOjWX/3QFpPX9cY1mmC0LeQ9YIog5snrmiAXfa4bxl83y1XSQIBPYAzkagdUuhxwNh+P7wC3pA4R9UfNPi4oDfrxTOKLYwjLwqCxapZOD9TusGcptBf0aWqN/bRJY2tkmav1cvtUdITkmgTAwDFV01BOFa2kPLvuN0HetGI8nl4nC+VoP3zkoy/n5LyOe6OO1IUuZ6zx2/qGUtdf+4IBIRGOEKoJYFEnvLaVtNmg== 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 AS8PR04CA0149.eurprd04.prod.outlook.com (2603:10a6:20b:127::34) by DBAPR08MB5621.eurprd08.prod.outlook.com (2603:10a6:10:1a3::17) 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:13 +0000 Received: from AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:127:cafe::9e) by AS8PR04CA0149.outlook.office365.com (2603:10a6:20b:127::34) 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 AM7EUR03FT039.mail.protection.outlook.com (100.127.140.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:13 +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.23; Fri, 19 May 2023 10:25:12 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.23; Fri, 19 May 2023 10:25:11 +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:11 +0000 To: Subject: [PATCH v2 05/17] [gdb/aarch64] sme: Enable SME registers and pseudo-registers Date: Fri, 19 May 2023 11:24:56 +0100 Message-ID: <20230519102508.14020-6-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: AM7EUR03FT039:EE_|DBAPR08MB5621:EE_|AM7EUR03FT058:EE_|AS2PR08MB10084:EE_ X-MS-Office365-Filtering-Correlation-Id: c647e2fd-4682-43f8-9f74-08db58535bfa 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: 7emk7Mx66h40tnJc38LbZEkLz9KLy2Iz/9ttt7p1Sefv0qvFWXZz7fErPfM5hoPZRNwLnwbFam+7YRUPeLy1Qk1OrRjlUhhuXlENfvKcvKNvjn6eXskuwoAvGRsXFnoAh25AtV1xWdUmGLlJUp9idH3zKctppqP60ESJivGcJa6MV6kOJPzwFLAOFUrQ5HU1bVFm/oG6IAYMgPWyPZAUEhyQiW3EME+tsRSo7Fd5A/q09fYcf6y4y/QsF1bLc021Q7zpcvPcw3X6yyMJjUNTZS/5na0+QlvNHznQCdumzTW3xHV/6BeQKULYt3Y/EhRCLOPgs7zAP4YooCAOOjT3zEIG1NS+SrXftRvq4aB1zHBskMYkQgGDorQiyWj30lCx+s7tfiueuh+Od9vDmSXCQO5Os3MRSEIEidW29zTPkKsi/jtNgojHmtCR2YaU1FtrV4OpKfn7sC8WZ70y/gFEYcwNX1p80refObQ1r3llhHm2BDHDh1oDv4vCJKoCfPmQpMp6RZpi0zgYjOh0DdHAvuKN20pAP4Do/zql9USbQRk6tS73FEaX8mIMASNIffhyWnn86HOiafnz26wBCMwqzTjljzLTSPcYQHQeEWhghidIirrdhOvC+9BXKg80AcMbjUtiH/5+CeuyD/LDqeP8uzuD8TrCtk3OhcxE7kDeSJiveXy/6RRPnTYAOfbW6DN9sUFR3VAGcmjYgesMhD0YuMTbvh2D8iOuQWw6zQW5kPeeFSR6UwT5zEQkdwKHfu5piC638YPzcoYrB7dZ0XL9DBqKwzDcCaa+cypYhZx2MZ0= 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)(376002)(346002)(396003)(39850400004)(136003)(451199021)(36840700001)(46966006)(86362001)(36756003)(316002)(70206006)(478600001)(966005)(6916009)(70586007)(1076003)(82310400005)(40480700001)(8936002)(2906002)(30864003)(7696005)(44832011)(5660300002)(8676002)(6666004)(356005)(82740400003)(81166007)(41300700001)(336012)(36860700001)(426003)(83380400001)(47076005)(26005)(186003)(2616005)(66899021)(2004002)(36900700001)(559001)(579004); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5621 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 49d47871-d7f7-4965-db6e-08db585354cd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4zNQtM04rXsLGEHNtC2iJLAqvl5rdVchRE/Yd2VARqHgxQWEr+n30J3MWw5bYPvT+LRe7L128nmB9ub73OhsW711d1+fhZ2/KLMJDBUoA1hoOcVZWTlT08n0vUQlqVtCQIINCY0g0RVYFv/MdgGczev5HQo41euRdORQhNNA1qmxWzmduRQ5XHbRBFB4oSzOkui+cVxec6vzy2fQzthS3wf8h4q23aa9f4tFoqV+ce57O9NnVP5BcVi112jJqt8xTHiEUhcs/OSYNvstGHXSTB9GkMengpao6bvOhtYezolRfaswdccQsyAB5csCAtFvcmlIiJejCHakjzUajn8F3O9eSc0Edk+1AdnYMkLPSkIK2zdMIbzNT74cYZWmb4jlMDLE6MBSOli3FPHZThS9ke57RNAu995MmeT2by+YsDskobSvW4Btj3aJ9iFABHs8eF369g5mXCKHt8hG0LuIUjqblaZtUuv96LyZUTjkSsITLvcwRw+IL0Qp3YXfBATbymA2iltQmlFpBP5m2ShQaSBOIYEPbtf2YFcxVM/rAKZnl3wDhTOgKD5+Nw/FkTu5GmQ+Oy9bYiRuCkkEAl6Qic2YKJIEWWE6/usz8WtVcMaK/et1dA4pzalIqP2VZ4069jdt1ZZdNDmr4kLsu1nFXiGyTc6uSVXYlD0RAd08I6LE+Kgy70dT+algqY3NGadbozlpP0dMPimWKpFM5ONA+ZuJyxi/Qeuils+LPl0YPn4qwT7OzV32PVm5KCc/lHzFEqzk/OvyH9Q7NOPdSgpteAeN+6Vw2EkGXKBY/e6Hwmo= 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)(39860400002)(346002)(376002)(396003)(136003)(451199021)(40470700004)(36840700001)(46966006)(86362001)(36756003)(316002)(70206006)(6916009)(70586007)(966005)(478600001)(40480700001)(6666004)(82310400005)(8936002)(8676002)(5660300002)(41300700001)(30864003)(2906002)(44832011)(81166007)(82740400003)(7696005)(186003)(336012)(426003)(2616005)(26005)(1076003)(36860700001)(47076005)(83380400001)(66899021)(40460700003)(2004002)(559001)(579004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:25.0957 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c647e2fd-4682-43f8-9f74-08db58535bfa 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: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10084 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, KAM_SHORT, 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" The SME (Scalable Matrix Extension) [1] exposes a new matrix register ZA with variable sizes. It also exposes a new mode called streaming mode. Similarly to SVE, the ZA register size is dictated by a vector length, but the SME vector length is called streaming vetor length. The total size for ZA in a given moment is svl x svl. In streaming mode, the SVE registers have their sizes based on svl rather than the regular vector length (vl). The feature detection is controlled by the HWCAP2_SME bit, but actual support should be validated by attempting a ptrace call for one of the new register sets: NT_ARM_ZA and NT_ARM_SSVE. Due to its large size, the ZA register is exposed as a vector of bytes, but we introduce a number of pseudo-registers that gives various different views into the ZA contents. These can be arranged in a couple categories: tiles and tile slices. Tiles are matrices the same size or smaller than ZA. Tile slices are vectors which map to ZA's rows/columns in different ways. A new dynamic target description is provided containing the ZA register, the SVG register and the SVCR register. The size of ZA, like the SVE vector registers, is based on the vector length register SVG (VG for SVE). This patch enables SME register support for gdb. [1] https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/scalable-matrix-extension-armv9-a-architecture Co-Authored-By: Ezra Sitorus --- gdb/Makefile.in | 4 + gdb/aarch64-linux-nat.c | 101 ++- gdb/aarch64-tdep.c | 719 +++++++++++++++++++- gdb/aarch64-tdep.h | 47 ++ gdb/arch/aarch64-scalable-linux.c | 21 + gdb/arch/aarch64-scalable-linux.h | 38 ++ gdb/arch/aarch64.c | 5 + gdb/arch/aarch64.h | 57 +- gdb/configure.tgt | 1 + gdb/features/aarch64-sme.c | 63 ++ gdb/nat/aarch64-scalable-linux-ptrace.c | 573 +++++++++++++++- gdb/nat/aarch64-scalable-linux-ptrace.h | 109 ++- gdb/nat/aarch64-scalable-linux-sigcontext.h | 57 +- gdbserver/configure.srv | 1 + 14 files changed, 1742 insertions(+), 54 deletions(-) create mode 100644 gdb/arch/aarch64-scalable-linux.c create mode 100644 gdb/arch/aarch64-scalable-linux.h create mode 100644 gdb/features/aarch64-sme.c diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 0b9f33c24dc..fe0de172bbe 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -726,6 +726,7 @@ ALL_64_TARGET_OBS = \ arch/aarch64.o \ arch/aarch64-insn.o \ arch/aarch64-mte-linux.o \ + arch/aarch64-scalable-linux.o \ arch/amd64.o \ arch/riscv.o \ bpf-tdep.o \ @@ -1523,6 +1524,7 @@ HFILES_NO_SRCDIR = \ arch/aarch64.h \ arch/aarch64-insn.h \ arch/aarch64-mte-linux.h \ + arch/aarch64-scalable-linux.h \ arch/arc.h \ arch/arm.h \ arch/i386.h \ @@ -1561,6 +1563,7 @@ HFILES_NO_SRCDIR = \ nat/aarch64-linux-hw-point.h \ nat/aarch64-mte-linux-ptrace.h \ nat/aarch64-scalable-linux-ptrace.h \ + nat/aarch64-scalable-linux-sigcontext.h \ nat/amd64-linux-siginfo.h \ nat/gdb_ptrace.h \ nat/gdb_thread_db.h \ @@ -1626,6 +1629,7 @@ ALLDEPFILES = \ arch/aarch64.c \ arch/aarch64-insn.c \ arch/aarch64-mte-linux.c \ + arch/aarch64-scalable-linux.c \ arch/amd64.c \ arch/arc.c \ arch/arm.c \ diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index a775631e9ec..cb97b205c86 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -55,6 +55,7 @@ #include "arch/aarch64-mte-linux.h" #include "nat/aarch64-mte-linux-ptrace.h" +#include "arch/aarch64-scalable-linux.h" #include @@ -313,8 +314,11 @@ store_fpregs_to_thread (const struct regcache *regcache) } } -/* Fill GDB's register array with the sve register values - from the current thread. */ +/* Fill GDB's REGCACHE with the valid SVE register values from the current + thread. + + This function handles reading data from SVE or SSVE states, depending + on which state is active at the moment. */ static void fetch_sveregs_from_thread (struct regcache *regcache) @@ -323,8 +327,11 @@ fetch_sveregs_from_thread (struct regcache *regcache) aarch64_sve_regs_copy_to_reg_buf (regcache->ptid ().lwp (), regcache); } -/* Store to the current thread the valid sve register - values in the GDB's register array. */ +/* Store the valid SVE register values from GDB's REGCACHE to the current + thread. + + This function handles writing data to SVE or SSVE states, depending + on which state is active at the moment. */ static void store_sveregs_to_thread (struct regcache *regcache) @@ -334,6 +341,41 @@ store_sveregs_to_thread (struct regcache *regcache) aarch64_sve_regs_copy_from_reg_buf (regcache->ptid ().lwp (), regcache); } +/* Fill GDB's REGCACHE with the ZA register set contents from the + current thread. If there is no active ZA registe state, make the + ZA register contents zero. */ + +static void +fetch_za_from_thread (struct regcache *regcache) +{ + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Read ZA state from the thread to the register cache. */ + aarch64_za_regs_copy_to_reg_buf (regcache->ptid ().lwp (), + regcache, + tdep->sme_za_regnum, + tdep->sme_svg_regnum, + tdep->sme_svcr_regnum); +} + +/* Store the NT_ARM_ZA register set contents from GDB's REGCACHE to the current + thread. */ + +static void +store_za_to_thread (struct regcache *regcache) +{ + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Write ZA state from the register cache to the thread. */ + aarch64_za_regs_copy_from_reg_buf (regcache->ptid ().lwp (), + regcache, + tdep->sme_za_regnum, + tdep->sme_svg_regnum, + tdep->sme_svcr_regnum); +} + /* Fill GDB's register array with the pointer authentication mask values from the current thread. */ @@ -488,7 +530,10 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) if (regno == -1) { fetch_gregs_from_thread (regcache); - if (tdep->has_sve ()) + + /* We attempt to fetch SVE registers if there is support for either + SVE or SME (due to the SSVE state of SME). */ + if (tdep->has_sve () || tdep->has_sme ()) fetch_sveregs_from_thread (regcache); else fetch_fpregs_from_thread (regcache); @@ -501,12 +546,16 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) if (tdep->has_tls ()) fetch_tlsregs_from_thread (regcache); + + if (tdep->has_sme ()) + fetch_za_from_thread (regcache); } /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) fetch_gregs_from_thread (regcache); /* SVE register? */ - else if (tdep->has_sve () && regno <= AARCH64_SVE_VG_REGNUM) + else if ((tdep->has_sve () || tdep->has_sme ()) + && regno <= AARCH64_SVE_VG_REGNUM) fetch_sveregs_from_thread (regcache); /* FPSIMD register? */ else if (regno < AARCH64_FPCR_REGNUM) @@ -516,6 +565,10 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) && (regno == AARCH64_PAUTH_DMASK_REGNUM (tdep->pauth_reg_base) || regno == AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base))) fetch_pauth_masks_from_thread (regcache); + /* SME register? */ + else if (tdep->has_sme () && regno >= tdep->sme_reg_base + && regno < tdep->sme_reg_base + 3) + fetch_za_from_thread (regcache); /* MTE register? */ else if (tdep->has_mte () && (regno == tdep->mte_reg_base)) @@ -577,7 +630,10 @@ aarch64_store_registers (struct regcache *regcache, int regno) if (regno == -1) { store_gregs_to_thread (regcache); - if (tdep->has_sve ()) + + /* We attempt to store SVE registers if there is support for either + SVE or SME (due to the SSVE state of SME). */ + if (tdep->has_sve () || tdep->has_sme ()) store_sveregs_to_thread (regcache); else store_fpregs_to_thread (regcache); @@ -587,16 +643,24 @@ aarch64_store_registers (struct regcache *regcache, int regno) if (tdep->has_tls ()) store_tlsregs_to_thread (regcache); + + if (tdep->has_sme ()) + store_za_to_thread (regcache); } /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) store_gregs_to_thread (regcache); /* SVE register? */ - else if (tdep->has_sve () && regno <= AARCH64_SVE_VG_REGNUM) + else if ((tdep->has_sve () || tdep->has_sme ()) + && regno <= AARCH64_SVE_VG_REGNUM) store_sveregs_to_thread (regcache); /* FPSIMD register? */ else if (regno < AARCH64_FPCR_REGNUM) store_fpregs_to_thread (regcache); + /* SME register? */ + else if (tdep->has_sme () && regno >= tdep->sme_reg_base + && regno < tdep->sme_reg_base + 3) + store_za_to_thread (regcache); /* MTE register? */ else if (tdep->has_mte () && (regno == tdep->mte_reg_base)) @@ -784,10 +848,15 @@ aarch64_linux_nat_target::read_description () CORE_ADDR hwcap2 = linux_get_hwcap2 (); aarch64_features features; + /* SVE/SSVE check. Reading VQ may return either the regular vector length + or the streaming vector length, depending on whether streaming mode is + active or not. */ features.vq = aarch64_sve_get_vq (tid); features.pauth = hwcap & AARCH64_HWCAP_PACA; features.mte = hwcap2 & HWCAP2_MTE; features.tls = aarch64_tls_register_count (tid); + /* SME feature check. */ + features.svq = aarch64_za_get_svq (tid); return aarch64_read_description (features); } @@ -890,21 +959,27 @@ aarch64_linux_nat_target::thread_architecture (ptid_t ptid) if (gdbarch_bfd_arch_info (inf->gdbarch)->bits_per_word == 32) return inf->gdbarch; - /* Only return it if the current vector length matches the one in the tdep. */ + /* Only return the inferior's gdbarch if both vq and svq match the ones in + the tdep. */ aarch64_gdbarch_tdep *tdep = gdbarch_tdep (inf->gdbarch); uint64_t vq = aarch64_sve_get_vq (ptid.lwp ()); - if (vq == tdep->vq) + uint64_t svq = aarch64_za_get_svq (ptid.lwp ()); + if (vq == tdep->vq && svq == tdep->sme_svq) return inf->gdbarch; - /* We reach here if the vector length for the thread is different from its + /* We reach here if any vector length for the thread is different from its value at process start. Lookup gdbarch via info (potentially creating a - new one) by using a target description that corresponds to the new vq value - and the current architecture features. */ + new one) by using a target description that corresponds to the new vq/svq + value and the current architecture features. */ const struct target_desc *tdesc = gdbarch_target_desc (inf->gdbarch); aarch64_features features = aarch64_features_from_target_desc (tdesc); features.vq = vq; + /* We cast to uint8_t here because the features struct can get large, and it + is important to store the information in as little storage as + possible. */ + features.svq = (uint8_t) svq; struct gdbarch_info info; info.bfd_arch_info = bfd_lookup_arch (bfd_arch_aarch64, bfd_mach_aarch64); diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 5a2c924f82d..9480ff5e303 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -57,6 +57,8 @@ /* For inferior_ptid and current_inferior (). */ #include "inferior.h" +/* For std::sqrt and std::pow. */ +#include /* A Homogeneous Floating-Point or Short-Vector Aggregate may have at most four members. */ @@ -190,6 +192,43 @@ struct aarch64_prologue_cache trad_frame_saved_reg *saved_regs; }; +/* Holds information used to read/write from/to ZA + pseudo-registers. + + With this information, the read/write code can be simplified so it + deals only with the required information to map a ZA pseudo-register + to the exact bytes into the ZA contents buffer. Otherwise we'd need + to use a lot of conditionals. */ + +struct za_offsets +{ + /* Offset, into ZA, of the starting byte of the pseudo-register. */ + size_t starting_offset; + /* The size of the contiguous chunks of the pseudo-register. */ + size_t chunk_size; + /* The number of pseudo-register chunks contained in ZA. */ + size_t chunks; + /* The offset between each contiguous chunk. */ + size_t stride_size; +}; + +/* Holds data that is helpful to determine the individual fields that make + up the names of the ZA pseudo-registers. It is also very helpful to + determine offsets, stride and sizes for reading ZA tiles and tile + slices. */ + +struct za_pseudo_encoding +{ + /* The slice index (0 ~ svl). Only used for tile slices. */ + uint8_t slice_index; + /* The tile number (0 ~ 15). */ + uint8_t tile_index; + /* Direction (horizontal/vertical). Only used for tile slices. */ + bool horizontal; + /* Qualifier index (0 ~ 4). These map to B, H, S, D and Q. */ + uint8_t qualifier_index; +}; + static void show_aarch64_debug (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) @@ -2141,6 +2180,214 @@ aarch64_vnb_type (struct gdbarch *gdbarch) return tdep->vnb_type; } +/* Return TRUE if REGNUM is a ZA tile slice pseudo-register number. Return + FALSE otherwise. */ + +static bool +is_sme_tile_slice_pseudo_register (struct gdbarch *gdbarch, int regnum) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + gdb_assert (tdep->has_sme ()); + gdb_assert (tdep->sme_svq > 0); + gdb_assert (tdep->sme_pseudo_base <= regnum); + gdb_assert (regnum < tdep->sme_pseudo_base + tdep->sme_pseudo_count); + + if (tdep->sme_tile_slice_pseudo_base <= regnum + && regnum < tdep->sme_tile_slice_pseudo_base + + tdep->sme_tile_slice_pseudo_count) + return true; + + return false; +} + +/* Given REGNUM, a ZA pseudo-register number, return, in ENCODING, the + decoded fields that make up its name. */ + +static void +aarch64_za_decode_pseudos (struct gdbarch *gdbarch, int regnum, + struct za_pseudo_encoding &encoding) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + gdb_assert (tdep->has_sme ()); + gdb_assert (tdep->sme_svq > 0); + gdb_assert (tdep->sme_pseudo_base <= regnum); + gdb_assert (regnum < tdep->sme_pseudo_base + tdep->sme_pseudo_count); + + if (is_sme_tile_slice_pseudo_register (gdbarch, regnum)) + { + /* Calculate the tile slice pseudo-register offset relative to the other + tile slice pseudo-registers. */ + int offset = regnum - tdep->sme_tile_slice_pseudo_base; + + /* Fetch the qualifier. We can have 160 to 2560 possible tile slice + pseudo-registers. Each qualifier (we have 5 of them: B, H, S, D + and Q) covers 32 * svq pseudo-registers, so we divide the offset by + that constant. */ + size_t qualifier = offset / (tdep->sme_svq * 32); + encoding.qualifier_index = qualifier; + + /* Prepare to fetch the direction (d), tile number (t) and slice + number (s). */ + int dts = offset % (tdep->sme_svq * 32); + + /* The direction is represented by the even/odd numbers. Even-numbered + pseudo-registers are horizontal tile slices and odd-numbered + pseudo-registers are vertical tile slices. */ + encoding.horizontal = !(dts & 1); + + /* Fetch the tile number. The tile number is closely related to the + qualifier. B has 1 tile, H has 2 tiles, S has 4 tiles, D has 8 tiles + and Q has 16 tiles. */ + encoding.tile_index = (dts >> 1) & ((1 << qualifier) - 1); + + /* Fetch the slice number. The slice number is closely related to the + qualifier and the svl. */ + encoding.slice_index = dts >> (qualifier + 1); + } + else + { + /* Calculate the tile pseudo-register offset relative to the other + tile pseudo-registers. */ + int offset = regnum - tdep->sme_tile_pseudo_base; + + encoding.qualifier_index = std::floor (std::log2 (offset + 1)); + /* Calculate the tile number. */ + encoding.tile_index = (offset + 1) - (1 << encoding.qualifier_index); + /* Direction and slice index don't get used for tiles. Set them to + 0/false values. */ + encoding.slice_index = 0; + encoding.horizontal = false; + } +} + +/* Return the type for a ZA tile slice pseudo-register based on ENCODING. */ + +static struct type * +aarch64_za_tile_slice_type (struct gdbarch *gdbarch, + const struct za_pseudo_encoding &encoding) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + gdb_assert (tdep->has_sme ()); + gdb_assert (tdep->sme_svq > 0); + + if (tdep->sme_tile_slice_type_q == nullptr) + { + /* Q tile slice type. */ + tdep->sme_tile_slice_type_q + = init_vector_type (builtin_type (gdbarch)->builtin_uint128, + tdep->sme_svq); + /* D tile slice type. */ + tdep->sme_tile_slice_type_d + = init_vector_type (builtin_type (gdbarch)->builtin_uint64, + tdep->sme_svq * 2); + /* S tile slice type. */ + tdep->sme_tile_slice_type_s + = init_vector_type (builtin_type (gdbarch)->builtin_uint32, + tdep->sme_svq * 4); + /* H tile slice type. */ + tdep->sme_tile_slice_type_h + = init_vector_type (builtin_type (gdbarch)->builtin_uint16, + tdep->sme_svq * 8); + /* B tile slice type. */ + tdep->sme_tile_slice_type_b + = init_vector_type (builtin_type (gdbarch)->builtin_uint8, + tdep->sme_svq * 16); + } + + switch (encoding.qualifier_index) + { + case 4: + return tdep->sme_tile_slice_type_q; + case 3: + return tdep->sme_tile_slice_type_d; + case 2: + return tdep->sme_tile_slice_type_s; + case 1: + return tdep->sme_tile_slice_type_h; + case 0: + return tdep->sme_tile_slice_type_b; + default: + error (_("Invalid qualifier index %s for tile slice pseudo register."), + pulongest (encoding.qualifier_index)); + } + + gdb_assert_not_reached ("Unknown qualifier for ZA tile slice register"); +} + +/* Return the type for a ZA tile pseudo-register based on ENCODING. */ + +static struct type * +aarch64_za_tile_type (struct gdbarch *gdbarch, + const struct za_pseudo_encoding &encoding) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + gdb_assert (tdep->has_sme ()); + gdb_assert (tdep->sme_svq > 0); + + if (tdep->sme_tile_type_q == nullptr) + { + struct type *inner_vectors_type; + + /* Q tile type. */ + inner_vectors_type + = init_vector_type (builtin_type (gdbarch)->builtin_uint128, + tdep->sme_svq); + tdep->sme_tile_type_q + = init_vector_type (inner_vectors_type, tdep->sme_svq); + + /* D tile type. */ + inner_vectors_type + = init_vector_type (builtin_type (gdbarch)->builtin_uint64, + tdep->sme_svq * 2); + tdep->sme_tile_type_d + = init_vector_type (inner_vectors_type, tdep->sme_svq * 2); + + /* S tile type. */ + inner_vectors_type + = init_vector_type (builtin_type (gdbarch)->builtin_uint32, + tdep->sme_svq * 4); + tdep->sme_tile_type_s + = init_vector_type (inner_vectors_type, tdep->sme_svq * 4); + + /* H tile type. */ + inner_vectors_type + = init_vector_type (builtin_type (gdbarch)->builtin_uint16, + tdep->sme_svq * 8); + tdep->sme_tile_type_h + = init_vector_type (inner_vectors_type, tdep->sme_svq * 8); + + /* B tile type. */ + inner_vectors_type + = init_vector_type (builtin_type (gdbarch)->builtin_uint8, + tdep->sme_svq * 16); + tdep->sme_tile_type_b + = init_vector_type (inner_vectors_type, tdep->sme_svq * 16); + } + + switch (encoding.qualifier_index) + { + case 4: + return tdep->sme_tile_type_q; + case 3: + return tdep->sme_tile_type_d; + case 2: + return tdep->sme_tile_type_s; + case 1: + return tdep->sme_tile_type_h; + case 0: + return tdep->sme_tile_type_b; + default: + error (_("Invalid qualifier index %s for ZA tile pseudo register."), + pulongest (encoding.qualifier_index)); + } + + gdb_assert_not_reached ("unknown qualifier for tile pseudo-register"); +} + /* Return the type for an AdvSISD V register. */ static struct type * @@ -2573,6 +2820,73 @@ is_w_pseudo_register (struct gdbarch *gdbarch, int regnum) return false; } +/* Return TRUE if REGNUM is a SME pseudo-register number. Return FALSE + otherwise. */ + +static bool +is_sme_pseudo_register (struct gdbarch *gdbarch, int regnum) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (tdep->has_sme () && tdep->sme_pseudo_base <= regnum + && regnum < tdep->sme_pseudo_base + tdep->sme_pseudo_count) + return true; + + return false; +} + +/* Convert ENCODING into a ZA tile slice name. */ + +static const std::string +aarch64_za_tile_slice_name (const struct za_pseudo_encoding &encoding) +{ + gdb_assert (encoding.qualifier_index >= 0); + gdb_assert (encoding.qualifier_index <= 4); + gdb_assert (encoding.tile_index >= 0); + gdb_assert (encoding.tile_index <= 15); + gdb_assert (encoding.slice_index >= 0); + gdb_assert (encoding.slice_index <= 255); + + const char orientation = encoding.horizontal ? 'h' : 'v'; + + const char qualifiers[6] = "bhsdq"; + const char qualifier = qualifiers [encoding.qualifier_index]; + return string_printf ("za%d%c%c%d", encoding.tile_index, orientation, + qualifier, encoding.slice_index); +} + +/* Convert ENCODING into a ZA tile name. */ + +static const std::string +aarch64_za_tile_name (const struct za_pseudo_encoding &encoding) +{ + /* Tiles don't use the slice number and the direction fields. */ + gdb_assert (encoding.qualifier_index >= 0); + gdb_assert (encoding.qualifier_index <= 4); + gdb_assert (encoding.tile_index >= 0); + gdb_assert (encoding.tile_index <= 15); + + const char qualifiers[6] = "bhsdq"; + const char qualifier = qualifiers [encoding.qualifier_index]; + return (string_printf ("za%d%c", encoding.tile_index, qualifier)); +} + +/* Given a SME pseudo-register REGNUM, return its type. */ + +static struct type * +aarch64_sme_pseudo_register_type (struct gdbarch *gdbarch, int regnum) +{ + struct za_pseudo_encoding encoding; + + /* Decode the SME pseudo-register number. */ + aarch64_za_decode_pseudos (gdbarch, regnum, encoding); + + if (is_sme_tile_slice_pseudo_register (gdbarch, regnum)) + return aarch64_za_tile_slice_type (gdbarch, encoding); + else + return aarch64_za_tile_type (gdbarch, encoding); +} + /* Return the pseudo register name corresponding to register regnum. */ static const char * @@ -2693,6 +3007,9 @@ aarch64_pseudo_register_name (struct gdbarch *gdbarch, int regnum) return sve_v_name[p_regnum - AARCH64_SVE_V0_REGNUM]; } + if (is_sme_pseudo_register (gdbarch, regnum)) + return tdep->sme_pseudo_names[regnum - tdep->sme_pseudo_base].c_str (); + /* RA_STATE is used for unwinding only. Do not assign it a name - this prevents it from being read by methods such as mi_cmd_trace_frame_collected. */ @@ -2735,6 +3052,9 @@ aarch64_pseudo_register_type (struct gdbarch *gdbarch, int regnum) if (is_w_pseudo_register (gdbarch, regnum)) return builtin_type (gdbarch)->builtin_uint32; + if (is_sme_pseudo_register (gdbarch, regnum)) + return aarch64_sme_pseudo_register_type (gdbarch, regnum); + if (tdep->has_pauth () && regnum == tdep->ra_sign_state_regnum) return builtin_type (gdbarch)->builtin_uint64; @@ -2767,6 +3087,8 @@ aarch64_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum, else if (tdep->has_sve () && p_regnum >= AARCH64_SVE_V0_REGNUM && p_regnum < AARCH64_SVE_V0_REGNUM + AARCH64_V_REGS_NUM) return group == all_reggroup || group == vector_reggroup; + else if (is_sme_pseudo_register (gdbarch, regnum)) + return group == all_reggroup || group == vector_reggroup; /* RA_STATE is used for unwinding only. Do not assign it to any groups. */ if (tdep->has_pauth () && regnum == tdep->ra_sign_state_regnum) return 0; @@ -2796,6 +3118,122 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch, return result_value; } +/* Helper function for reading/writing ZA pseudo-registers. Given REGNUM, + a ZA pseudo-register number, return, in OFFSETS, the information on positioning + of the bytes that must be read from/written to. */ + +static void +aarch64_za_offsets_from_regnum (struct gdbarch *gdbarch, int regnum, + struct za_offsets &offsets) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + gdb_assert (tdep->has_sme ()); + gdb_assert (tdep->sme_svq > 0); + gdb_assert (tdep->sme_pseudo_base <= regnum); + gdb_assert (regnum < tdep->sme_pseudo_base + tdep->sme_pseudo_count); + + struct za_pseudo_encoding encoding; + + /* Decode the ZA pseudo-register number. */ + aarch64_za_decode_pseudos (gdbarch, regnum, encoding); + + /* Fetch the streaming vector length. */ + size_t svl = sve_vl_from_vq (tdep->sme_svq); + + if (is_sme_tile_slice_pseudo_register (gdbarch, regnum)) + { + if (encoding.horizontal) + { + /* Horizontal tile slices are contiguous ranges of svl bytes. */ + + /* The starting offset depends on the tile index (to locate the tile + in the ZA buffer), the slice index (to locate the slice within the + tile) and the qualifier. */ + offsets.starting_offset + = encoding.tile_index * svl + encoding.slice_index + * (svl >> encoding.qualifier_index); + /* Horizontal tile slice data is contiguous and thus doesn't have + a stride. */ + offsets.stride_size = 0; + /* Horizontal tile slice data is contiguous and thus only has 1 + chunk. */ + offsets.chunks = 1; + /* The chunk size is always svl bytes. */ + offsets.chunk_size = svl; + } + else + { + /* Vertical tile slices are non-contiguous ranges of + (1 << qualifier_index) bytes. */ + + /* The starting offset depends on the tile number (to locate the + tile in the ZA buffer), the slice index (to locate the element + within the tile slice) and the qualifier. */ + offsets.starting_offset + = encoding.tile_index * svl + encoding.slice_index + * (1 << encoding.qualifier_index); + /* The offset between vertical tile slices depends on the qualifier + and svl. */ + offsets.stride_size = svl << (encoding.qualifier_index); + /* The number of chunks depends on svl and the qualifier size. */ + offsets.chunks = svl >> encoding.qualifier_index; + /* The chunk size depends on the qualifier. */ + offsets.chunk_size = 1 << encoding.qualifier_index; + } + } + else + { + /* ZA tile pseudo-register. */ + + /* Starting offset depends on the tile index and qualifier. */ + offsets.starting_offset = (encoding.tile_index) * svl; + /* The offset between tile slices depends on the qualifier and svl. */ + offsets.stride_size = svl << (encoding.qualifier_index); + /* The number of chunks depends on the qualifier and svl. */ + offsets.chunks = svl >> encoding.qualifier_index; + /* The chunk size is always svl bytes. */ + offsets.chunk_size = svl; + } +} + +/* Given REGNUM, a SME pseudo-register number, return its value in RESULT. */ + +static struct value * +aarch64_sme_pseudo_register_read (struct gdbarch *gdbarch, + readable_regcache *regcache, int regnum, + struct value *result) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + gdb_assert (tdep->has_sme ()); + gdb_assert (tdep->sme_svq > 0); + gdb_assert (tdep->sme_pseudo_base <= regnum); + gdb_assert (regnum < tdep->sme_pseudo_base + tdep->sme_pseudo_count); + + /* Fetch the offsets that we need in order to read from the correct blocks + of ZA. */ + struct za_offsets offsets; + aarch64_za_offsets_from_regnum (gdbarch, regnum, offsets); + + /* Fetch the contents of ZA. */ + size_t svl = sve_vl_from_vq (tdep->sme_svq); + gdb::byte_vector za (std::pow (svl, 2)); + regcache->raw_read (tdep->sme_za_regnum, za.data ()); + + /* Copy the requested data. */ + for (int chunks = 0; chunks < offsets.chunks; chunks++) + { + const gdb_byte *source + = za.data () + offsets.starting_offset + chunks * offsets.stride_size; + gdb_byte *destination + = result->contents_raw ().data () + chunks * offsets.chunk_size; + + memcpy (destination, source, offsets.chunk_size); + } + return result; +} + /* Implement the "pseudo_register_read_value" gdbarch method. */ static struct value * @@ -2829,6 +3267,9 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache, return result_value; } + else if (is_sme_pseudo_register (gdbarch, regnum)) + return aarch64_sme_pseudo_register_read (gdbarch, regcache, regnum, + result_value); regnum -= gdbarch_num_regs (gdbarch); @@ -2888,6 +3329,44 @@ aarch64_pseudo_write_1 (struct gdbarch *gdbarch, struct regcache *regcache, regcache->raw_write (v_regnum, reg_buf); } +/* Given REGNUM, a SME pseudo-register number, store the bytes from DATA to the + pseudo-register. */ + +static void +aarch64_sme_pseudo_register_write (struct gdbarch *gdbarch, + struct regcache *regcache, + int regnum, const gdb_byte *data) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + gdb_assert (tdep->has_sme ()); + gdb_assert (tdep->sme_svq > 0); + gdb_assert (tdep->sme_pseudo_base <= regnum); + gdb_assert (regnum < tdep->sme_pseudo_base + tdep->sme_pseudo_count); + + /* Fetch the offsets that we need in order to write to the correct blocks + of ZA. */ + struct za_offsets offsets; + aarch64_za_offsets_from_regnum (gdbarch, regnum, offsets); + + /* Fetch the contents of ZA. */ + size_t svl = sve_vl_from_vq (tdep->sme_svq); + gdb::byte_vector za (std::pow (svl, 2)); + + /* Copy the requested data. */ + for (int chunks = 0; chunks < offsets.chunks; chunks++) + { + const gdb_byte *source = data + chunks * offsets.chunk_size; + gdb_byte *destination + = za.data () + offsets.starting_offset + chunks * offsets.stride_size; + + memcpy (destination, source, offsets.chunk_size); + } + + /* Write back to ZA. */ + regcache->raw_write (tdep->sme_za_regnum, za.data ()); +} + /* Implement the "pseudo_register_write" gdbarch method. */ static void @@ -2915,6 +3394,11 @@ aarch64_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache, regcache->raw_write_part (x_regnum, offset, 4, buf); return; } + else if (is_sme_pseudo_register (gdbarch, regnum)) + { + aarch64_sme_pseudo_register_write (gdbarch, regcache, regnum, buf); + return; + } regnum -= gdbarch_num_regs (gdbarch); @@ -3494,6 +3978,33 @@ aarch64_get_tdesc_vq (const struct target_desc *tdesc) return sve_vq_from_vl (vl); } + +/* Return the svq (streaming vector quotient) used when creating the target + description TDESC. */ + +static uint64_t +aarch64_get_tdesc_svq (const struct target_desc *tdesc) +{ + const struct tdesc_feature *feature_sme; + + if (!tdesc_has_registers (tdesc)) + return 0; + + feature_sme = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme"); + + if (feature_sme == nullptr) + return 0; + + size_t svl_squared = tdesc_register_bitsize (feature_sme, "za"); + + /* We have the total size of the ZA matrix, in bits. Figure out the svl + value. */ + size_t svl = std::sqrt (svl_squared / 8); + + /* Now extract svq. */ + return sve_vq_from_vl (svl); +} + /* Get the AArch64 features present in the given target description. */ aarch64_features @@ -3529,6 +4040,8 @@ aarch64_features_from_target_desc (const struct target_desc *tdesc) features.tls = 1; } + features.svq = aarch64_get_tdesc_svq (tdesc); + return features; } @@ -3648,6 +4161,35 @@ aarch64_remove_non_address_bits (struct gdbarch *gdbarch, CORE_ADDR pointer) return aarch64_remove_top_bits (pointer, mask); } +/* Given NAMES, a vector of strings, initialize it with all the SME + pseudo-register names for the current streaming vector length. */ + +static void +aarch64_initialize_sme_pseudo_names (struct gdbarch *gdbarch, + std::vector &names) +{ + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + gdb_assert (tdep->has_sme ()); + gdb_assert (tdep->sme_tile_slice_pseudo_base > 0); + gdb_assert (tdep->sme_tile_pseudo_base > 0); + + for (int i = 0; i < tdep->sme_tile_slice_pseudo_count; i++) + { + int regnum = tdep->sme_tile_slice_pseudo_base + i; + struct za_pseudo_encoding encoding; + aarch64_za_decode_pseudos (gdbarch, regnum, encoding); + names.push_back (aarch64_za_tile_slice_name (encoding)); + } + for (int i = 0; i < AARCH64_ZA_TILES_NUM; i++) + { + int regnum = tdep->sme_tile_pseudo_base + i; + struct za_pseudo_encoding encoding; + aarch64_za_decode_pseudos (gdbarch, regnum, encoding); + names.push_back (aarch64_za_tile_name (encoding)); + } +} + /* Initialize the current architecture based on INFO. If possible, re-use an architecture from ARCHES, which is a list of architectures already created during this debugging session. @@ -3665,11 +4207,17 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) int first_pauth_regnum = -1, ra_sign_state_offset = -1; int first_mte_regnum = -1, first_tls_regnum = -1; uint64_t vq = aarch64_get_tdesc_vq (info.target_desc); + uint64_t svq = aarch64_get_tdesc_svq (info.target_desc); if (vq > AARCH64_MAX_SVE_VQ) internal_error (_("VQ out of bounds: %s (max %d)"), pulongest (vq), AARCH64_MAX_SVE_VQ); + if (svq > AARCH64_MAX_SVE_VQ) + internal_error (_("Streaming vector quotient (svq) out of bounds: %s" + " (max %d)"), + pulongest (svq), AARCH64_MAX_SVE_VQ); + /* If there is already a candidate, use it. */ for (gdbarch_list *best_arch = gdbarch_list_lookup_by_info (arches, &info); best_arch != nullptr; @@ -3677,15 +4225,21 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { aarch64_gdbarch_tdep *tdep = gdbarch_tdep (best_arch->gdbarch); - if (tdep && tdep->vq == vq) + if (tdep && tdep->vq == vq && tdep->sme_svq == svq) return best_arch->gdbarch; } /* Ensure we always have a target descriptor, and that it is for the given VQ value. */ const struct target_desc *tdesc = info.target_desc; - if (!tdesc_has_registers (tdesc)) - tdesc = aarch64_read_description ({}); + if (!tdesc_has_registers (tdesc) || vq != aarch64_get_tdesc_vq (tdesc) + || svq != aarch64_get_tdesc_svq (tdesc)) + { + aarch64_features features; + features.vq = vq; + features.svq = svq; + tdesc = aarch64_read_description (features); + } gdb_assert (tdesc); feature_core = tdesc_find_feature (tdesc,"org.gnu.gdb.aarch64.core"); @@ -3749,6 +4303,35 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) num_pseudo_regs += 32; /* add the Bn scalar register pseudos */ } + int first_sme_regnum = -1; + int first_sme_pseudo_regnum = -1; + const struct tdesc_feature *feature_sme + = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme"); + if (feature_sme != nullptr) + { + /* Record the first SME register. */ + first_sme_regnum = num_regs; + + valid_p &= tdesc_numbered_register (feature_sme, tdesc_data.get (), + num_regs++, "svg"); + + valid_p &= tdesc_numbered_register (feature_sme, tdesc_data.get (), + num_regs++, "svcr"); + + valid_p &= tdesc_numbered_register (feature_sme, tdesc_data.get (), + num_regs++, "za"); + + /* Record the first SME pseudo register. */ + first_sme_pseudo_regnum = num_pseudo_regs; + + /* Add the ZA tile slice pseudo registers. The number of tile slice + pseudo-registers depend on the svl, and is always a multiple of 5. */ + num_pseudo_regs += (svq << 5) * 5; + + /* Add the ZA tile pseudo registers. */ + num_pseudo_regs += AARCH64_ZA_TILES_NUM; + } + /* Add the TLS register. */ int tls_register_count = 0; if (feature_tls != nullptr) @@ -3862,6 +4445,14 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->tls_regnum_base = first_tls_regnum; tdep->tls_register_count = tls_register_count; + /* Set the SME register set details. The pseudo-registers will be adjusted + later. */ + tdep->sme_reg_base = first_sme_regnum; + tdep->sme_svg_regnum = first_sme_regnum; + tdep->sme_svcr_regnum = first_sme_regnum + 1; + tdep->sme_za_regnum = first_sme_regnum + 2; + tdep->sme_svq = svq; + set_gdbarch_push_dummy_call (gdbarch, aarch64_push_dummy_call); set_gdbarch_frame_align (gdbarch, aarch64_frame_align); @@ -3978,6 +4569,86 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_remove_non_address_bits (gdbarch, aarch64_remove_non_address_bits); + /* SME pseudo-registers. */ + if (tdep->has_sme ()) + { + tdep->sme_pseudo_base = num_regs + first_sme_pseudo_regnum; + tdep->sme_tile_slice_pseudo_base = tdep->sme_pseudo_base; + tdep->sme_tile_slice_pseudo_count = (svq * 32) * 5; + tdep->sme_tile_pseudo_base + = tdep->sme_pseudo_base + tdep->sme_tile_slice_pseudo_count; + tdep->sme_pseudo_count + = tdep->sme_tile_slice_pseudo_count + AARCH64_ZA_TILES_NUM; + + /* The SME ZA pseudo-registers are a set of 160 to 2560 pseudo-registers + depending on the value of svl. + + The tile pseudo-registers are organized around their qualifiers + (b, h, s, d and q). Their numbers are distributed as follows: + + b 0 + h 1~2 + s 3~6 + d 7~14 + q 15~30 + + The naming of the tile pseudo-registers follows the pattern za, + where: + + is the tile number, with the following possible values based on + the qualifiers: + + Qualifier - Allocated indexes + + b - 0 + h - 0~1 + s - 0~3 + d - 0~7 + q - 0~15 + + is the qualifier: b, h, s, d and q. + + The tile slice pseudo-registers are organized around their + qualifiers as well (b, h, s, d and q), but also around their + direction (h - horizontal and v - vertical). + + Even-numbered tile slice pseudo-registers are horizontally-oriented + and odd-numbered tile slice pseudo-registers are vertically-oriented. + + Their numbers are distributed as follows: + + Qualifier - Allocated indexes + + b tile slices - 0~511 + h tile slices - 512~1023 + s tile slices - 1024~1535 + d tile slices - 1536~2047 + q tile slices - 2048~2559 + + The naming of the tile slice pseudo-registers follows the pattern + za, where: + + is the tile number as described for the tile pseudo-registers. + is the direction of the tile slice (h or v) + is the qualifier of the tile slice (b, h, s, d or q) + is the slice number, defined as follows: + + Qualifier - Allocated indexes + + b - 0~15 + h - 0~7 + s - 0~3 + d - 0~1 + q - 0 + + We have helper functions to translate to/from register index from/to + the set of fields that make the pseudo-register names. */ + + /* Build the array of pseudo-register names available for this + particular gdbarch configuration. */ + aarch64_initialize_sme_pseudo_names (gdbarch, tdep->sme_pseudo_names); + } + /* Add standard register aliases. */ for (i = 0; i < ARRAY_SIZE (aarch64_register_aliases); i++) user_reg_add (gdbarch, aarch64_register_aliases[i].name, @@ -3999,6 +4670,48 @@ aarch64_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) gdb_printf (file, _("aarch64_dump_tdep: Lowest pc = 0x%s\n"), paddress (gdbarch, tdep->lowest_pc)); + + /* SME fields. */ + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_type_q = %s\n"), + host_address_to_string (tdep->sme_tile_type_q)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_type_d = %s\n"), + host_address_to_string (tdep->sme_tile_type_d)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_type_s = %s\n"), + host_address_to_string (tdep->sme_tile_type_s)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_type_h = %s\n"), + host_address_to_string (tdep->sme_tile_type_h)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_type_n = %s\n"), + host_address_to_string (tdep->sme_tile_type_b)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_slice_type_q = %s\n"), + host_address_to_string (tdep->sme_tile_slice_type_q)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_slice_type_d = %s\n"), + host_address_to_string (tdep->sme_tile_slice_type_d)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_slice_type_s = %s\n"), + host_address_to_string (tdep->sme_tile_slice_type_s)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_slice_type_h = %s\n"), + host_address_to_string (tdep->sme_tile_slice_type_h)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_slice_type_b = %s\n"), + host_address_to_string (tdep->sme_tile_slice_type_b)); + gdb_printf (file, _("aarch64_dump_tdep: sme_reg_base = %s\n"), + pulongest (tdep->sme_reg_base)); + gdb_printf (file, _("aarch64_dump_tdep: sme_svg_regnum = %s\n"), + pulongest (tdep->sme_svg_regnum)); + gdb_printf (file, _("aarch64_dump_tdep: sme_svcr_regnum = %s\n"), + pulongest (tdep->sme_svcr_regnum)); + gdb_printf (file, _("aarch64_dump_tdep: sme_za_regnum = %s\n"), + pulongest (tdep->sme_za_regnum)); + gdb_printf (file, _("aarch64_dump_tdep: sme_pseudo_base = %s\n"), + pulongest (tdep->sme_pseudo_base)); + gdb_printf (file, _("aarch64_dump_tdep: sme_pseudo_count = %s\n"), + pulongest (tdep->sme_pseudo_count)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_slice_pseudo_base = %s\n"), + pulongest (tdep->sme_tile_slice_pseudo_base)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_slice_pseudo_count = %s\n"), + pulongest (tdep->sme_tile_slice_pseudo_count)); + gdb_printf (file, _("aarch64_dump_tdep: sme_tile_pseudo_base = %s\n"), + pulongest (tdep->sme_tile_pseudo_base)); + gdb_printf (file, _("aarch64_dump_tdep: sme_svq = %s\n"), + pulongest (tdep->sme_svq)); } #if GDB_SELF_TEST diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h index 505e050ba48..9297487a584 100644 --- a/gdb/aarch64-tdep.h +++ b/gdb/aarch64-tdep.h @@ -80,6 +80,22 @@ struct aarch64_gdbarch_tdep : gdbarch_tdep_base struct type *vnb_type = nullptr; struct type *vnv_type = nullptr; + /* Types for SME ZA tiles and tile slices pseudo-registers. */ + struct type *sme_tile_type_q = nullptr; + struct type *sme_tile_type_d = nullptr; + struct type *sme_tile_type_s = nullptr; + struct type *sme_tile_type_h = nullptr; + struct type *sme_tile_type_b = nullptr; + struct type *sme_tile_slice_type_q = nullptr; + struct type *sme_tile_slice_type_d = nullptr; + struct type *sme_tile_slice_type_s = nullptr; + struct type *sme_tile_slice_type_h = nullptr; + struct type *sme_tile_slice_type_b = nullptr; + + /* Vector of names for SME pseudo-registers. The number of elements is + different for each distinct svl value. */ + std::vector sme_pseudo_names; + /* syscall record. */ int (*aarch64_syscall_record) (struct regcache *regcache, unsigned long svc_number) = nullptr; @@ -125,6 +141,37 @@ struct aarch64_gdbarch_tdep : gdbarch_tdep_base /* The W pseudo-registers. */ int w_pseudo_base = 0; int w_pseudo_count = 0; + + /* SME feature fields. */ + + /* Index of the first SME register. This is -1 if SME is not supported. */ + int sme_reg_base = 0; + /* svg register index. */ + int sme_svg_regnum = 0; + /* svcr register index. */ + int sme_svcr_regnum = 0; + /* ZA register index. */ + int sme_za_regnum = 0; + /* Index of the first SME pseudo-register. This is -1 if SME is not + supported. */ + int sme_pseudo_base = 0; + /* Total number of SME pseudo-registers. */ + int sme_pseudo_count = 0; + /* First tile slice pseudo-register index. */ + int sme_tile_slice_pseudo_base = 0; + /* Total number of tile slice pseudo-registers. */ + int sme_tile_slice_pseudo_count = 0; + /* First tile pseudo-register index. */ + int sme_tile_pseudo_base = 0; + /* The streaming vector quotient (svq) for SME, or zero if SME is not + supported. */ + size_t sme_svq = 0; + + /* Return true if the target supports SME, and false otherwise. */ + bool has_sme () const + { + return sme_svq != 0; + } }; const target_desc *aarch64_read_description (const aarch64_features &features); diff --git a/gdb/arch/aarch64-scalable-linux.c b/gdb/arch/aarch64-scalable-linux.c new file mode 100644 index 00000000000..3803acfd9a8 --- /dev/null +++ b/gdb/arch/aarch64-scalable-linux.c @@ -0,0 +1,21 @@ +/* Common Linux arch-specific functionality for AArch64 scalable + extensions: SVE and SME. + + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "arch/aarch64-scalable-linux.h" diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h new file mode 100644 index 00000000000..df1741004ed --- /dev/null +++ b/gdb/arch/aarch64-scalable-linux.h @@ -0,0 +1,38 @@ +/* Common AArch64 Linux arch-specific definitions for the scalable + extensions: SVE and SME. + + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef ARCH_AARCH64_SCALABLE_LINUX_H +#define ARCH_AARCH64_SCALABLE_LINUX_H + +#include "gdbsupport/common-defs.h" + +/* Feature check for Scalable Matrix Extension. */ +#ifndef HWCAP2_SME +#define HWCAP2_SME (1 << 23) +#endif + +/* Streaming mode enabled/disabled bit. */ +#define SVCR_SM_BIT (1 << 0) +/* ZA enabled/disabled bit. */ +#define SVCR_ZA_BIT (1 << 1) +/* Mask including all valid SVCR bits. */ +#define SVCR_BIT_MASK (SVCR_SM_BIT | SVCR_ZA_BIT) + +#endif /* ARCH_AARCH64_SCALABLE_LINUX_H */ diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c index 8644b9afcef..e1f4948aa25 100644 --- a/gdb/arch/aarch64.c +++ b/gdb/arch/aarch64.c @@ -24,6 +24,7 @@ #include "../features/aarch64-sve.c" #include "../features/aarch64-pauth.c" #include "../features/aarch64-mte.c" +#include "../features/aarch64-sme.c" #include "../features/aarch64-tls.c" /* See arch/aarch64.h. */ @@ -57,6 +58,10 @@ aarch64_create_target_description (const aarch64_features &features) if (features.tls > 0) regnum = create_feature_aarch64_tls (tdesc.get (), regnum, features.tls); + if (features.svq) + regnum = create_feature_aarch64_sme (tdesc.get (), regnum, + sve_vl_from_vq (features.svq)); + return tdesc.release (); } diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h index 4b3f1b8eff8..c1cd233c51e 100644 --- a/gdb/arch/aarch64.h +++ b/gdb/arch/aarch64.h @@ -27,15 +27,27 @@ struct aarch64_features { /* A non zero VQ value indicates both the presence of SVE and the - Vector Quotient - the number of 128bit chunks in an SVE Z - register. */ - uint64_t vq = 0; + Vector Quotient - the number of 128-bit chunks in an SVE Z + register. + The maximum value for VQ is 16 (5 bits). */ + uint64_t vq = 0; bool pauth = false; bool mte = false; /* A positive TLS value indicates the number of TLS registers available. */ uint8_t tls = 0; + /* The allowed values for SVQ are the following: + + 0 - SME is not supported/available. + 1 - SME is available, SVL is 16 bytes / 128-bit. + 2 - SME is available, SVL is 32 bytes / 256-bit. + 4 - SME is available, SVL is 64 bytes / 512-bit. + 8 - SME is available, SVL is 128 bytes / 1024-bit. + 16 - SME is available, SVL is 256 bytes / 2048-bit. + + These use at most 5 bits to represent. */ + uint8_t svq = 0; }; inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs) @@ -43,7 +55,8 @@ inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs) return lhs.vq == rhs.vq && lhs.pauth == rhs.pauth && lhs.mte == rhs.mte - && lhs.tls == rhs.tls; + && lhs.tls == rhs.tls + && lhs.svq == rhs.svq; } namespace std @@ -61,6 +74,11 @@ namespace std /* Shift by two bits for now. We may need to increase this in the future if more TLS registers get added. */ h = h << 2 | features.tls; + + /* Make sure the SVQ values are within the limits. */ + gdb_assert (features.svq >= 0); + gdb_assert (features.svq <= 16); + h = h << 5 | (features.svq & 0x5); return h; } }; @@ -171,4 +189,35 @@ enum aarch64_regnum /* Maximum supported VQ value. Increase if required. */ #define AARCH64_MAX_SVE_VQ 16 +/* SME definitions + + Some of these definitions are not found in the Architecture Reference + Manual, but we use them so we can keep a similar standard compared to the + SVE definitions that the Linux Kernel uses. Otherwise it can get + confusing. + + SVL : Streaming Vector Length. + Although the documentation handles SVL in bits, we do it in + bytes to match what we do for SVE. + + The streaming vector length dictates the size of the ZA register and + the size of the SVE registers when in streaming mode. + + SVQ : Streaming Vector Quotient. + The number of 128-bit chunks in an SVE Z register or the size of + each dimension of the SME ZA matrix. + + SVG : Streaming Vector Granule. + The number of 64-bit chunks in an SVE Z register or the size of + half a SME ZA matrix dimension. The SVG definition was added so + we keep a familiar definition when dealing with SVE registers in + streaming mode. */ + +/* The total number of tiles. This is always fixed regardless of the + streaming vector length (svl). */ +#define AARCH64_ZA_TILES_NUM 31 +/* svl limits for SME. */ +#define AARCH64_SME_MIN_SVL 128 +#define AARCH64_SME_MAX_SVL 2048 + #endif /* ARCH_AARCH64_H */ diff --git a/gdb/configure.tgt b/gdb/configure.tgt index d5b7dd1e7d7..47a674201f9 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -146,6 +146,7 @@ aarch64*-*-linux*) # Target: AArch64 linux gdb_target_obs="aarch64-linux-tdep.o arch/aarch64.o\ arch/aarch64-mte-linux.o \ + arch/aarch64-scalable-linux.o \ arch/arm.o arch/arm-linux.o arch/arm-get-next-pcs.o \ arm-tdep.o arm-linux-tdep.o \ glibc-tdep.o linux-tdep.o solib-svr4.o \ diff --git a/gdb/features/aarch64-sme.c b/gdb/features/aarch64-sme.c new file mode 100644 index 00000000000..697a3014093 --- /dev/null +++ b/gdb/features/aarch64-sme.c @@ -0,0 +1,63 @@ +/* Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "gdbsupport/tdesc.h" +#include + +/* This function is NOT auto generated from xml. Create the AArch64 SME + feature into RESULT. SVL is the streaming vector length in bytes. + + The ZA register has a total size of SVL x SVL. + + When in Streaming SVE mode, the effective SVE vector length, VL, is equal + to SVL. */ + +static int +create_feature_aarch64_sme (struct target_desc *result, long regnum, + size_t svl) +{ + struct tdesc_feature *feature; + tdesc_type *element_type; + + feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.sme"); + + /* The SVG register. */ + tdesc_create_reg (feature, "svg", regnum++, 1, nullptr, 64, "int"); + + /* SVCR flags type. */ + tdesc_type_with_fields *type_with_fields + = tdesc_create_flags (feature, "svcr_flags", 8); + tdesc_add_flag (type_with_fields, 0, "SM"); + tdesc_add_flag (type_with_fields, 1, "ZA"); + + /* The SVCR register. */ + tdesc_create_reg (feature, "svcr", regnum++, 1, nullptr, 64, "svcr_flags"); + + /* Byte type. */ + element_type = tdesc_named_type (feature, "uint8"); + /* Vector of bytes. */ + element_type = tdesc_create_vector (feature, "sme_bv", element_type, + svl); + /* Vector of vector of bytes (Matrix). */ + element_type = tdesc_create_vector (feature, "sme_bvv", element_type, + svl); + + /* The following is the ZA register set. */ + tdesc_create_reg (feature, "za", regnum++, 1, nullptr, + std::pow (svl, 2) * 8, "sme_bvv"); + return regnum; +} diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c index 192eebcda19..4c78d788e1a 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.c +++ b/gdb/nat/aarch64-scalable-linux-ptrace.c @@ -1,5 +1,4 @@ -/* Common target dependent routines for AArch64 Scalable Extensions - (SVE/SME). +/* Common native Linux code for the AArch64 scalable extensions: SVE and SME. Copyright (C) 2018-2023 Free Software Foundation, Inc. @@ -28,6 +27,193 @@ #include "gdbsupport/common-regcache.h" #include "gdbsupport/byte-vector.h" #include +#include "arch/aarch64-scalable-linux.h" + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +aarch64_has_sve_state (int tid) +{ + struct user_sve_header header; + + if (!read_sve_header (tid, header)) + return false; + + if ((header.flags & SVE_PT_REGS_SVE) == 0) + return false; + + if (sizeof (header) == header.size) + return false; + + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +aarch64_has_ssve_state (int tid) +{ + struct user_sve_header header; + + if (!read_ssve_header (tid, header)) + return false; + + if ((header.flags & SVE_PT_REGS_SVE) == 0) + return false; + + if (sizeof (header) == header.size) + return false; + + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +aarch64_has_za_state (int tid) +{ + struct user_za_header header; + + if (!read_za_header (tid, header)) + return false; + + if (sizeof (header) == header.size) + return false; + + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +read_sve_header (int tid, struct user_sve_header &header) +{ + struct iovec iovec; + + iovec.iov_len = sizeof (header); + iovec.iov_base = &header; + + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_SVE, &iovec) < 0) + { + /* SVE is not supported. */ + return false; + } + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +write_sve_header (int tid, const struct user_sve_header &header) +{ + struct iovec iovec; + + iovec.iov_len = sizeof (header); + iovec.iov_base = (void *) &header; + + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_SVE, &iovec) < 0) + { + /* SVE is not supported. */ + return false; + } + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +read_ssve_header (int tid, struct user_sve_header &header) +{ + struct iovec iovec; + + iovec.iov_len = sizeof (header); + iovec.iov_base = &header; + + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_SSVE, &iovec) < 0) + { + /* SSVE is not supported. */ + return false; + } + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +write_ssve_header (int tid, const struct user_sve_header &header) +{ + struct iovec iovec; + + iovec.iov_len = sizeof (header); + iovec.iov_base = (void *) &header; + + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_SSVE, &iovec) < 0) + { + /* SSVE is not supported. */ + return false; + } + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +read_za_header (int tid, struct user_za_header &header) +{ + struct iovec iovec; + + iovec.iov_len = sizeof (header); + iovec.iov_base = &header; + + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_ZA, &iovec) < 0) + { + /* ZA is not supported. */ + return false; + } + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +write_za_header (int tid, const struct user_za_header &header) +{ + struct iovec iovec; + + iovec.iov_len = sizeof (header); + iovec.iov_base = (void *) &header; + + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_ZA, &iovec) < 0) + { + /* ZA is not supported. */ + return false; + } + return true; +} + +/* Given VL, the streaming vector length for SME, return true if it is valid + and false otherwise. */ + +static bool +aarch64_sme_vl_valid (size_t vl) +{ + return (vl == 16 || vl == 32 || vl == 64 || vl == 128 || vl == 256); +} + +/* Given VL, the vector length for SVE, return true if it is valid and false + otherwise. SVE_state is true when the check is for the SVE register set. + Otherwise the check is for the SSVE register set. */ + +static bool +aarch64_sve_vl_valid (const bool sve_state, size_t vl) +{ + if (sve_state) + return sve_vl_valid (vl); + + /* We have an active SSVE state, where the valid vector length values are + more restrictive. */ + return aarch64_sme_vl_valid (vl); +} /* See nat/aarch64-scalable-linux-ptrace.h. */ @@ -36,23 +222,25 @@ aarch64_sve_get_vq (int tid) { struct iovec iovec; struct user_sve_header header; - iovec.iov_len = sizeof (header); iovec.iov_base = &header; - /* Ptrace gives the vector length in bytes. Convert it to VQ, the number of - 128bit chunks in a Z register. We use VQ because 128bits is the minimum - a Z register can increase in size. */ - - if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_SVE, &iovec) < 0) + /* Figure out which register set to use for the request. The vector length + for SVE can be different from the vector length for SSVE. */ + bool has_sve_state = !aarch64_has_ssve_state (tid); + if (ptrace (PTRACE_GETREGSET, tid, has_sve_state? NT_ARM_SVE : NT_ARM_SSVE, + &iovec) < 0) { /* SVE is not supported. */ return 0; } + /* Ptrace gives the vector length in bytes. Convert it to VQ, the number of + 128bit chunks in a Z register. We use VQ because 128 bits is the minimum + a Z register can increase in size. */ uint64_t vq = sve_vq_from_vl (header.vl); - if (!sve_vl_valid (header.vl)) + if (!aarch64_sve_vl_valid (has_sve_state, header.vl)) { warning (_("Invalid SVE state from kernel; SVE disabled.")); return 0; @@ -72,15 +260,20 @@ aarch64_sve_set_vq (int tid, uint64_t vq) iovec.iov_len = sizeof (header); iovec.iov_base = &header; - if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_SVE, &iovec) < 0) + /* Figure out which register set to use for the request. The vector length + for SVE can be different from the vector length for SSVE. */ + bool has_sve_state = !aarch64_has_ssve_state (tid); + if (ptrace (PTRACE_GETREGSET, tid, has_sve_state? NT_ARM_SVE : NT_ARM_SSVE, + &iovec) < 0) { - /* SVE is not supported. */ + /* SVE/SSVE is not supported. */ return false; } header.vl = sve_vl_from_vq (vq); - if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_SVE, &iovec) < 0) + if (ptrace (PTRACE_SETREGSET, tid, has_sve_state? NT_ARM_SVE : NT_ARM_SSVE, + &iovec) < 0) { /* Vector length change failed. */ return false; @@ -120,13 +313,108 @@ aarch64_sve_set_vq (int tid, struct reg_buffer_common *reg_buf) /* See nat/aarch64-scalable-linux-ptrace.h. */ +uint64_t +aarch64_za_get_svq (int tid) +{ + struct user_za_header header; + if (!read_za_header (tid, header)) + return 0; + + uint64_t vq = sve_vq_from_vl (header.vl); + + if (!aarch64_sve_vl_valid (false, header.vl)) + { + warning (_("Invalid ZA state from kernel; ZA disabled.")); + return 0; + } + + return vq; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +aarch64_za_set_svq (int tid, uint64_t vq) +{ + struct iovec iovec; + + /* Read the NT_ARM_ZA header. */ + struct user_za_header header; + if (!read_za_header (tid, header)) + { + /* ZA is not supported. */ + return false; + } + + /* If the size is the correct one already, don't update it. If we do + update the streaming vector length, we will invalidate the register + state for ZA, and we do not want that. */ + if (header.vl == sve_vl_from_vq (vq)) + return true; + + /* The streaming vector length is about to get updated. Set the new value + in the NT_ARM_ZA header and adjust the size as well. */ + + header.vl = sve_vl_from_vq (vq); + header.size = sizeof (struct user_za_header); + + /* Update the NT_ARM_ZA register set with the new streaming vector + length. */ + iovec.iov_len = sizeof (header); + iovec.iov_base = &header; + + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_ZA, &iovec) < 0) + { + /* Streaming vector length change failed. */ + return false; + } + + /* At this point we have successfully adjusted the streaming vector length + for the NT_ARM_ZA register set, and it should have no payload + (no ZA state). */ + + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +aarch64_za_set_svq (int tid, const struct reg_buffer_common *reg_buf, + int svg_regnum) +{ + uint64_t reg_svg = 0; + + /* The svg register may not be valid if we've not collected any value yet. + This can happen, for example, if we're restoring the regcache after an + inferior function call, and the svg register comes after the Z + registers. */ + if (reg_buf->get_register_status (svg_regnum) != REG_VALID) + { + /* If svg is not available yet, fetch it from ptrace. The svg value from + ptrace is likely the correct one. */ + uint64_t svq = aarch64_za_get_svq (tid); + + /* If something went wrong, just bail out. */ + if (svq == 0) + return false; + + reg_svg = sve_vg_from_vq (svq); + } + else + reg_buf->raw_collect (svg_regnum, ®_svg); + + return aarch64_za_set_svq (tid, sve_vq_from_vg (reg_svg)); +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + gdb::byte_vector aarch64_fetch_sve_regset (int tid) { uint64_t vq = aarch64_sve_get_vq (tid); if (vq == 0) - perror_with_name (_("Unable to fetch SVE vector length")); + perror_with_name (_("Unable to fetch SVE/SSVE vector length")); /* A ptrace call with NT_ARM_SVE will return a header followed by either a dump of all the SVE and FP registers, or an fpsimd structure (identical to @@ -139,8 +427,10 @@ aarch64_fetch_sve_regset (int tid) iovec.iov_base = sve_state.data (); iovec.iov_len = sve_state.size (); - if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_SVE, &iovec) < 0) - perror_with_name (_("Unable to fetch SVE registers")); + bool has_sve_state = !aarch64_has_ssve_state (tid); + if (ptrace (PTRACE_GETREGSET, tid, has_sve_state? NT_ARM_SVE : NT_ARM_SSVE, + &iovec) < 0) + perror_with_name (_("Unable to fetch SVE/SSVE registers")); return sve_state; } @@ -154,12 +444,87 @@ aarch64_store_sve_regset (int tid, const gdb::byte_vector &sve_state) iovec.iov_base = (void *) sve_state.data (); iovec.iov_len = sve_state.size (); - if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_SVE, &iovec) < 0) - perror_with_name (_("Unable to store SVE registers")); + bool has_sve_state = !aarch64_has_ssve_state (tid); + if (ptrace (PTRACE_SETREGSET, tid, has_sve_state? NT_ARM_SVE : NT_ARM_SSVE, + &iovec) < 0) + perror_with_name (_("Unable to store SVE/SSVE registers")); return true; } +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +gdb::byte_vector +aarch64_fetch_za_regset (int tid) +{ + struct user_za_header header; + if (!read_za_header (tid, header)) + error (_("Failed to read NT_ARM_ZA header.")); + + if (!aarch64_sme_vl_valid (header.vl)) + error (_("Found invalid vector length for NT_ARM_ZA.")); + + struct iovec iovec; + iovec.iov_len = header.size; + gdb::byte_vector za_state (header.size); + iovec.iov_base = za_state.data (); + + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_ZA, &iovec) < 0) + perror_with_name (_("Failed to fetch NT_ARM_ZA register set.")); + + return za_state; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +aarch64_store_za_regset (int tid, const gdb::byte_vector &za_state) +{ + struct iovec iovec; + iovec.iov_len = za_state.size (); + iovec.iov_base = (void *) za_state.data (); + + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_ZA, &iovec) < 0) + perror_with_name (_("Failed to write to the NT_ARM_ZA register set.")); + + return true; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +void +aarch64_initialize_za_regset (int tid) +{ + /* First fetch the NT_ARM_ZA header so we can fetch the streaming vector + length. */ + struct user_za_header header; + if (!read_za_header (tid, header)) + error (_("Failed to read NT_ARM_ZA header.")); + + /* The vector should be default-initialized to zero, and we should account + for the payload as well. */ + std::vector za_new_state (ZA_PT_SIZE (sve_vq_from_vl (header.vl))); + + /* Adjust the header size since we are adding the initialized ZA + payload. */ + header.size = ZA_PT_SIZE (sve_vq_from_vl (header.vl)); + + /* Overlay the modified header onto the new ZA state. */ + const gdb_byte *base = (gdb_byte *) &header; + memcpy (za_new_state.data (), base, sizeof (user_za_header)); + + /* Set the ptrace request up and update the NT_ARM_ZA register set. */ + struct iovec iovec; + iovec.iov_len = za_new_state.size (); + iovec.iov_base = (void *) za_new_state.data (); + + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_ZA, &iovec) < 0) + perror_with_name (_("Failed to initialize the NT_ARM_ZA register set.")); + + /* The NT_ARM_ZA register set should now contain a zero-initialized ZA + payload. */ +} + /* If we are running in BE mode, byteswap the contents of SRC to DST for SIZE bytes. Other, just copy the contents from SRC to DST. */ @@ -452,3 +817,177 @@ aarch64_sve_regs_copy_from_reg_buf (int tid, passed on to ptrace. */ aarch64_store_sve_regset (tid, new_state); } + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +void +aarch64_za_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf, + int za_regnum, int svg_regnum, + int svcr_regnum) +{ + /* Fetch the current ZA state from the thread. */ + gdb::byte_vector za_state = aarch64_fetch_za_regset (tid); + + /* Sanity check. */ + gdb_assert (!za_state.empty ()); + + char *base = (char *) za_state.data (); + struct user_za_header *header = (struct user_za_header *) base; + + /* If we have ZA state, read it. Otherwise, make the contents of ZA + in the register cache all zeroes. This is how we present the ZA + state when it is not initialized. */ + uint64_t svcr_value = 0; + if (aarch64_has_za_state (tid)) + { + /* Sanity check the data in the header. */ + if (!sve_vl_valid (header->vl) + || ZA_PT_SIZE (sve_vq_from_vl (header->vl)) != header->size) + { + error (_("Found invalid streaming vector length in NT_ARM_ZA" + " register set")); + } + + reg_buf->raw_supply (za_regnum, base + ZA_PT_ZA_OFFSET); + svcr_value |= SVCR_ZA_BIT; + } + else + { + size_t za_bytes = header->vl * header->vl; + gdb_byte za_zeroed[za_bytes]; + memset (za_zeroed, 0, za_bytes); + reg_buf->raw_supply (za_regnum, za_zeroed); + } + + /* Handle the svg and svcr registers separately. We need to calculate + their values manually, as the Linux Kernel doesn't expose those + explicitly. */ + svcr_value |= aarch64_has_ssve_state (tid)? SVCR_SM_BIT : 0; + uint64_t svg_value = sve_vg_from_vl (header->vl); + + /* Update the contents of svg and svcr registers. */ + reg_buf->raw_supply (svg_regnum, &svg_value); + reg_buf->raw_supply (svcr_regnum, &svcr_value); + + /* The register buffer should now contain the updated copy of the NT_ARM_ZA + state. */ +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +void +aarch64_za_regs_copy_from_reg_buf (int tid, + struct reg_buffer_common *reg_buf, + int za_regnum, int svg_regnum, + int svcr_regnum) +{ + /* REG_BUF contains the updated ZA state. We need to extract that state + and write it to the thread TID. */ + + + /* First check if there is a change to the streaming vector length. Two + outcomes are possible here: + + 1 - The streaming vector length in the register cache differs from the + one currently on the thread state. This means that we will need to + update the NT_ARM_ZA register set to reflect the new streaming vector + length. + + 2 - The streaming vector length in the register cache is the same as in + the thread state. This means we do not need to update the NT_ARM_ZA + register set for a new streaming vector length, and we only need to + deal with changes to za, svg and svcr. + + None of the two possibilities above imply that the ZA state actually + exists. They only determine what needs to be done with any ZA content + based on the state of the streaming vector length. */ + + /* First fetch the NT_ARM_ZA header so we can fetch the streaming vector + length. */ + struct user_za_header header; + if (!read_za_header (tid, header)) + error (_("Failed to read NT_ARM_ZA header.")); + + /* Fetch the current streaming vector length. */ + uint64_t old_svg = sve_vg_from_vl (header.vl); + + /* Fetch the (potentially) new streaming vector length. */ + uint64_t new_svg; + reg_buf->raw_collect (svg_regnum, &new_svg); + + /* Did the streaming vector length change? */ + bool svg_changed = new_svg != old_svg; + + /* First store the streaming vector length to the thread. This is done + first to ensure the ptrace buffers read from the kernel are the correct + size. If the streaming vector length is the same as the current one, it + won't be updated. */ + if (!aarch64_za_set_svq (tid, reg_buf, svg_regnum)) + error (_("Unable to set svg register")); + + bool has_za_state = aarch64_has_za_state (tid); + + size_t za_bytes = sve_vl_from_vg (old_svg) * sve_vl_from_vg (old_svg); + gdb_byte za_zeroed[za_bytes]; + memset (za_zeroed, 0, za_bytes); + + /* If the streaming vector length changed, zero out the contents of ZA in + the register cache. Otherwise, we will need to update the ZA contents + in the thread with the ZA contents from the register cache, and they will + differ in size. */ + if (svg_changed) + reg_buf->raw_supply (za_regnum, za_zeroed); + + /* When we update svg, we don't automatically initialize the ZA buffer. If + we have no ZA state and the ZA register contents in the register cache are + zero, just return and leave the ZA register cache contents as zero. */ + if (!has_za_state + && reg_buf->raw_compare (za_regnum, za_zeroed, 0)) + { + /* No ZA state in the thread or in the register cache. This was lilely + just an adjustment of the streaming vector length. Let this fall + through and update svcr and svg in the register cache. */ + } + else + { + /* If there is no ZA state but the register cache contains ZA data, we + need to initialize the ZA data through ptrace. First we initialize + all the bytes of ZA to zero. */ + if (!has_za_state + && !reg_buf->raw_compare (za_regnum, za_zeroed, 0)) + aarch64_initialize_za_regset (tid); + + /* From this point onwards, it is assumed we have a ZA payload in + the NT_ARM_ZA register set for this thread, and we need to update + such state based on the contents of the register cache. */ + + /* Fetch the current ZA state from the thread. */ + gdb::byte_vector za_state = aarch64_fetch_za_regset (tid); + + char *base = (char *) za_state.data (); + struct user_za_header *za_header = (struct user_za_header *) base; + uint64_t svq = sve_vq_from_vl (za_header->vl); + + /* Sanity check the data in the header. */ + if (!sve_vl_valid (za_header->vl) + || ZA_PT_SIZE (svq) != za_header->size) + error (_("Invalid vector length or payload size when reading ZA.")); + + /* Overwrite the ZA state contained in the thread with the ZA state from + the register cache. */ + if (REG_VALID == reg_buf->get_register_status (za_regnum)) + reg_buf->raw_collect (za_regnum, base + ZA_PT_ZA_OFFSET); + + /* Write back the ZA state to the thread's NT_ARM_ZA register set. */ + aarch64_store_za_regset (tid, za_state); + } + + /* Update svcr and svg accordingly. */ + uint64_t svcr_value = 0; + svcr_value |= aarch64_has_ssve_state (tid)? SVCR_SM_BIT : 0; + svcr_value |= aarch64_has_za_state (tid)? SVCR_ZA_BIT : 0; + reg_buf->raw_supply (svcr_regnum, &svcr_value); + + /* At this point we have written the data contained in the register cache to + the thread's NT_ARM_ZA register set. */ +} diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h index 3215103c88a..5fac51ca98b 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.h +++ b/gdb/nat/aarch64-scalable-linux-ptrace.h @@ -1,5 +1,5 @@ -/* Common target dependent definitions for AArch64 Scalable Extensions - (SVE/SME). +/* Common native Linux definitions for the AArch64 scalable + extensions: SVE and SME. Copyright (C) 2018-2023 Free Software Foundation, Inc. @@ -31,19 +31,58 @@ result when is included before . */ #include #include - -#ifndef SVE_SIG_ZREGS_SIZE +#include +#include "aarch64-scalable-linux-ptrace.h" #include "aarch64-scalable-linux-sigcontext.h" -#endif /* Indicates whether a SVE ptrace header is followed by SVE registers or a fpsimd structure. */ - #define HAS_SVE_STATE(header) ((header).flags & SVE_PT_REGS_SVE) +/* Return true if there is an active SVE state in TID. + Return false otherwise. */ +bool aarch64_has_sve_state (int tid); + +/* Return true if there is an active SSVE state in TID. + Return false otherwise. */ +bool aarch64_has_ssve_state (int tid); + +/* Return true if there is an active ZA state in TID. + Return false otherwise. */ +bool aarch64_has_za_state (int tid); + +/* Given TID, read the SVE header into HEADER. + + Return true if successful, false otherwise. */ +bool read_sve_header (int tid, struct user_sve_header &header); + +/* Given TID, store the SVE HEADER. + + Return true if successful, false otherwise. */ +bool write_sve_header (int tid, const struct user_sve_header &header); + +/* Given TID, read the SSVE header into HEADER. + + Return true if successful, false otherwise. */ +bool read_ssve_header (int tid, struct user_sve_header &header); + +/* Given TID, store the SSVE HEADER. + + Return true if successful, false otherwise. */ +bool write_ssve_header (int tid, const struct user_sve_header &header); + +/* Given TID, read the ZA header into HEADER. + + Return true if successful, false otherwise. */ +bool read_za_header (int tid, struct user_za_header &header); + +/* Given TID, store the ZA HEADER. + + Return true if successful, false otherwise. */ +bool write_za_header (int tid, const struct user_za_header &header); + /* Read VQ for the given tid using ptrace. If SVE is not supported then zero is returned (on a system that supports SVE, then VQ cannot be zero). */ - uint64_t aarch64_sve_get_vq (int tid); /* Set VQ in the kernel for the given tid, using either the value VQ or @@ -52,28 +91,66 @@ uint64_t aarch64_sve_get_vq (int tid); bool aarch64_sve_set_vq (int tid, uint64_t vq); bool aarch64_sve_set_vq (int tid, struct reg_buffer_common *reg_buf); -/* Read the current SVE register set from thread TID and return its data - through a byte vector. */ +/* Read the streaming mode vq (svq) for the given TID. If the ZA state is not + supported or active, return 0. */ +uint64_t aarch64_za_get_svq (int tid); +/* Set the vector quotient (vq) in the kernel for the given TID using the + value VQ. + + Return true if successful, false otherwise. */ +bool aarch64_za_set_svq (int tid, uint64_t vq); +bool aarch64_za_set_svq (int tid, const struct reg_buffer_common *reg_buf, + int svg_regnum); + +/* Given TID, return the SVE/SSVE data as a vector of bytes. */ extern gdb::byte_vector aarch64_fetch_sve_regset (int tid); -/* Write the SVE contents from SVE_STATE to thread TID. Return true if +/* Write the SVE/SSVE contents from SVE_STATE to TID. Return true if successful and false otherwise. */ +extern bool aarch64_store_sve_regset (int tid, + const gdb::byte_vector &sve_state); -extern bool -aarch64_store_sve_regset (int tid, const gdb::byte_vector &sve_state); +/* Given TID, return the ZA data as a vector of bytes. */ +extern gdb::byte_vector aarch64_fetch_za_regset (int tid); -/* Given a thread id TID and a register buffer REG_BUF, update the register - buffer with the SVE state from thread TID. */ +/* Write ZA_STATE for TID. Return true if successful and false + otherwise. */ +extern bool aarch64_store_za_regset (int tid, const gdb::byte_vector &za_state); +/* Given TID, initialize the ZA register set so the header contains the right + size. The bytes of the ZA register are initialized to zero. */ +extern void aarch64_initialize_za_regset (int tid); + +/* Given a register buffer REG_BUF, update it with SVE/SSVE register data + from SVE_STATE. */ extern void aarch64_sve_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf); -/* Given a thread id TID and a register buffer REG_BUF containing SVE +/* Given a thread id TID and a register buffer REG_BUF containing SVE/SSVE register data, write the SVE data to thread TID. */ - extern void aarch64_sve_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf); +/* Given a thread id TID and a register buffer REG_BUF, update the register + buffer with the ZA state from thread TID. + + ZA_REGNUM, SVG_REGNUM and SVCR_REGNUM are the register numbers for ZA, + SVG and SVCR registers. */ +extern void aarch64_za_regs_copy_to_reg_buf (int tid, + struct reg_buffer_common *reg_buf, + int za_regnum, int svg_regnum, + int svcr_regnum); + +/* Given a thread id TID and a register buffer REG_BUF containing ZA register + data, write the ZA data to thread TID. + + ZA_REGNUM, SVG_REGNUM and SVCR_REGNUM are the register numbers for ZA, + SVG and SVCR registers. */ +extern void +aarch64_za_regs_copy_from_reg_buf (int tid, + struct reg_buffer_common *reg_buf, + int za_regnum, int svg_regnum, + int svcr_regnum); #endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */ diff --git a/gdb/nat/aarch64-scalable-linux-sigcontext.h b/gdb/nat/aarch64-scalable-linux-sigcontext.h index e0120e093a0..74407bd266a 100644 --- a/gdb/nat/aarch64-scalable-linux-sigcontext.h +++ b/gdb/nat/aarch64-scalable-linux-sigcontext.h @@ -22,8 +22,11 @@ #ifndef NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H #define NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H +#ifndef SVE_SIG_ZREGS_SIZE + #define SVE_MAGIC 0x53564501 + struct sve_context { struct _aarch64_ctx head; __u16 vl; @@ -132,7 +135,7 @@ struct sve_context { #define SVE_SIG_CONTEXT_SIZE(vq) (SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq)) -/* SVE/FP/SIMD state (NT_ARM_SVE) */ +/* SVE/FP/SIMD state (NT_ARM_SVE and NT_ARM_SSVE) */ struct user_sve_header { __u32 size; /* total meaningful regset content in bytes */ @@ -242,6 +245,7 @@ struct user_sve_header { (SVE_PT_SVE_PREG_OFFSET(vq, SVE_NUM_PREGS) - \ SVE_PT_SVE_PREGS_OFFSET(vq)) +/* For streaming mode SVE (SSVE) FFR must be read and written as zero. */ #define SVE_PT_SVE_FFR_OFFSET(vq) \ __SVE_SIG_TO_PT(SVE_SIG_FFR_OFFSET(vq)) @@ -267,4 +271,55 @@ struct user_sve_header { SVE_PT_SVE_OFFSET + SVE_PT_SVE_SIZE(vq, flags) \ : SVE_PT_FPSIMD_OFFSET + SVE_PT_FPSIMD_SIZE(vq, flags)) +#endif /* SVE_SIG_ZREGS_SIZE */ + +/* Scalable Matrix Extensions (SME) definitions. */ + +/* Make sure we only define these if the kernel header doesn't. */ +#ifndef ZA_PT_SIZE + +/* ZA state (NT_ARM_ZA) */ +struct user_za_header { + __u32 size; /* total meaningful regset content in bytes */ + __u32 max_size; /* maximum possible size for this thread */ + __u16 vl; /* current vector length */ + __u16 max_vl; /* maximum possible vector length */ + __u16 flags; + __u16 __reserved; +}; + +/* The remainder of the ZA state follows struct user_za_header. The + total size of the ZA state (including header) depends on the + metadata in the header: ZA_PT_SIZE(vq, flags) gives the total size + of the state in bytes, including the header. + + Refer to arch/arm64/include/uapi/asm/sigcontext.h from the Linux kernel + for details of how to pass the correct "vq" argument to these macros. */ + +/* Offset from the start of struct user_za_header to the register data */ +#define ZA_PT_ZA_OFFSET \ + ((sizeof (struct user_za_header) + (__SVE_VQ_BYTES - 1)) \ + / __SVE_VQ_BYTES * __SVE_VQ_BYTES) + +/* The payload starts at offset ZA_PT_ZA_OFFSET, and is of size + ZA_PT_ZA_SIZE(vq, flags). + + The ZA array is stored as a sequence of horizontal vectors ZAV of SVL/8 + bytes each, starting from vector 0. + + Additional data might be appended in the future. + + The ZA matrix is represented in memory in an endianness-invariant layout + which differs from the layout used for the FPSIMD V-registers on big-endian + systems: see sigcontext.h for more explanation. */ + +#define ZA_PT_ZAV_OFFSET(vq, n) \ + (ZA_PT_ZA_OFFSET + ((vq * __SVE_VQ_BYTES) * n)) + +#define ZA_PT_ZA_SIZE(vq) ((vq * __SVE_VQ_BYTES) * (vq * __SVE_VQ_BYTES)) + +#define ZA_PT_SIZE(vq) \ + (ZA_PT_ZA_OFFSET + ZA_PT_ZA_SIZE(vq)) +#endif /* ZA_PT_SIZE */ + #endif /* NAT_AARCH64_SCALABLE_LINUX_SIGCONTEXT_H */ diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv index f625c808859..6edcad03aaf 100644 --- a/gdbserver/configure.srv +++ b/gdbserver/configure.srv @@ -49,6 +49,7 @@ case "${gdbserver_host}" in srv_tgtobj="$srv_tgtobj arch/aarch64-insn.o" srv_tgtobj="$srv_tgtobj arch/aarch64.o" srv_tgtobj="$srv_tgtobj arch/aarch64-mte-linux.o" + srv_tgtobj="$srv_tgtobj arch/aarch64-scalable-linux.o" srv_tgtobj="$srv_tgtobj linux-aarch64-tdesc.o" srv_tgtobj="$srv_tgtobj nat/aarch64-mte-linux-ptrace.o" srv_tgtobj="$srv_tgtobj nat/aarch64-scalable-linux-ptrace.o" From patchwork Fri May 19 10:24:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69664 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 061B83839DD8 for ; Fri, 19 May 2023 10:26:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 061B83839DD8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684491969; bh=vYb9jIFiAPQXRlI8yx8RRVdReDuL6MFfkn9cLTpUkxA=; 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=HcH2mtjJUYVYPnZAvUDwVtpwdhAt8mUQrI+1HaEszcQEs/A5CS6rCM/jJ7SC3BtJh K0AwdzX0ayUtQytmRE9DOIqFShGEaV8wbV4HhzswgS9R5+ecAZQRQebRHuB1Hv9IYL e43Zpul4yVw/Y7m2j1rERr0t7TzntrowBskpgE84= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2084.outbound.protection.outlook.com [40.107.247.84]) by sourceware.org (Postfix) with ESMTPS id A2F4A3858C41 for ; Fri, 19 May 2023 10:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2F4A3858C41 Received: from DUZPR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::8) by AS2PR08MB9896.eurprd08.prod.outlook.com (2603:10a6:20b:5fe::9) 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:21 +0000 Received: from DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c3:cafe::32) by DUZPR01CA0002.outlook.office365.com (2603:10a6:10:3c3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:21 +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:21 +0000 Received: ("Tessian outbound 5154e9d36775:v136"); Fri, 19 May 2023 10:25:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b1537e8f72683189 X-CR-MTA-TID: 64aa7808 Received: from 5513df769913.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 152C4B81-3F7D-4614-B707-F4876990CDAE.1; Fri, 19 May 2023 10:25:14 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5513df769913.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BJgeq6POnwAEJ9HjU6Jy4WbEy6Wcu6iJNMWeCftNkBbjpe/KInlkrtVQocR9J4j73jX5rA+7KVkAGq+IQKHBnXisckGHBTKrjfRkLASkPdupv+RQ4m7XGHIAo/5pgT8BgM8YWlDjNQELJXYYBDLRxdXeWCTJtSdC2Ntc0hqO8N18wHW8I3Vd4a7DeF5n7B8teZpR49xwwHLsq3UTRhjmPBAPryli+eoIZTzy6oTm++N24yI4MMDPnC6/bAe7ddYpIzBYn66WNABcBtJy7EM6cTBCR/husVsjtV9YIwHcmz+s3HnIX3c+1wAgYHiKNQEVcH61N9VJZM1jeHBjIgV4Uw== 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=vYb9jIFiAPQXRlI8yx8RRVdReDuL6MFfkn9cLTpUkxA=; b=UdQIdpw/zrvgu/aBB8DtUyAmLONO01+AM0wRIGHJEdGm0qX2XDDTZvFa1p6N8xbmjeuPX4/GxAltGwR2ELzYeFREKsNQLbAAQGOl/CFBGnkQhJXv6t4DYoMhiLnCGDJsnX12QA3hP8DY8dpjRKK/0Ds+dj/5czto3yKIDNxUwku4Ni2tkGhMbLXUs64AZwBn0b+1R0COajzgZ89ioF4KtS33TZiggEpixxje8bnac3xUQEez1F4WpLRLNDP34TqP2IqyQY+KnHcFmrKBc1pWOheAAwiqTktnNCLNG0icUjDqp9yIGAhs9nhPHlm0bmNOAy92iONBqCARvJ3wbgWwHA== 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 AS9PR05CA0186.eurprd05.prod.outlook.com (2603:10a6:20b:495::35) by AM9PR08MB5988.eurprd08.prod.outlook.com (2603:10a6:20b:283::19) 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:12 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:495:cafe::a8) by AS9PR05CA0186.outlook.office365.com (2603:10a6:20b:495::35) 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:12 +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:12 +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 06/17] [gdbserver/aarch64] refactor: Adjust expedited registers dynamically Date: Fri, 19 May 2023 11:24:57 +0100 Message-ID: <20230519102508.14020-7-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_|AM9PR08MB5988:EE_|DBAEUR03FT044:EE_|AS2PR08MB9896:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c6a320f-fc38-48bf-999f-08db58535997 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: F+pU7XdMeSQUBewRkFpnJddV1BM+CiTaErixtk5eQ8dMgAAGpuLKRp10edWL1Mpyn70fhVieD7VK8lJCJHMU0MqThkA53NzCcJVh4Y8SCxtvOldhAfHEGv1sU7keyfBLzOtUC1zF3IE4L9vbMk/Fa89tn/RgNXTvkHKwd92v7hg2hw6uQKr07mpEgiC8sA1wlGoV3xpL6DaOJ1wFdZFZSPlUoyeYLPrdEDOmY4ylZsJ13sDUfdhqa0tXZIz58WAaZ3dXNKTo9Sxwot2CoaS3Us2LZTgUQuZq/FacEmANjrNzkFD9pFdvsCwE7HLHTS1ORcJq94veYGk2GZ5R/RyMxx8MMTCZEOR3Sw3zmGmSk6FgrWd05JwGPera3itB5AAGqeE8TMvQRelCkLKC5NQhx3NLf7RJFH87+RrIRwrTGcgPlvvvUUZrKgEm5PBET6ZcD0t3X+pLWKIsz9C48DAbgqsxurrfMy6J2mDYXbflH24Soy8rNeCqQGpHtJR4g+c8mu86AzyJ4Rdu/Mggl6140zTniI/Ymm/ocTb67u91DrLYLbo7QnGt+PBq63fYlU+C7DLWHZM8Snkol9LIcufyg1wSPUlQCEGIjwf5x+PudwZDJ2hkUmWmv3Ao7A4kx2cdkijqZzbFh0f+UcuymSa9/rD4huyXVFThfAf2xGhZDEoHyCatbCCfl3prF6khtOgiOp10T4EV3G4WyF7tsneh7Um8wuT879Tf7YI8yEWnHuhU70J9YhEQZ811kq3OLTnpIdJdOUN4MVWtMSdTv/MNIQ== 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)(376002)(346002)(396003)(136003)(451199021)(40470700004)(46966006)(36840700001)(86362001)(36756003)(6916009)(70586007)(316002)(478600001)(70206006)(44832011)(82310400005)(8676002)(7696005)(40480700001)(5660300002)(8936002)(6666004)(2906002)(81166007)(41300700001)(356005)(82740400003)(2616005)(426003)(1076003)(36860700001)(336012)(26005)(83380400001)(47076005)(186003)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB5988 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c30499f5-89c6-4e21-0002-08db585354a6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AQtCoX1ArWDlmmrhiqk4M2zaCF62nBQWBLFyHlYE1iL4a53GS0CAkTodDSAC0vByrPJtKk3ibx3J4qmxE0rVHihPsPPjrTPPDuiVHxbTabjyjNijGEFPn7vO/ZdkAw04y5SLs6ppvC4mhZY5ejvRToZgBlB12S3jYxHachLecvkMBZv+qzk8pDW/wzDe2qL/hOT0LAYHJ6sWhhT0QVFnzFs5G42LcOyL5t2PWN+YWaEGitoC4SHeQ41hXmzH3Zblm76D74MdkdrqSO2orb2KnFF8m7+a9J9EQzcJ6MmLqThBbTTvM+vu0XqJv51WyVysnsMaxZcgMybJgoYPPa1QSHqHTh6GJd0Q0EWz73MiqPn0Yi0bfT+G+UyyeoYMVNgDHHNwl4gwArRhU1qdqzBaCamoC+cj+Z4l+fGiOXQ+yrFovuWhsbEi3X4V/AMeCjhRIj9Ri29G5OYpHut92GSdNkiTFSn/U/DVUpIH/n7eWltSeUg/cZFSL2eCm/qzkhNVNUVXk63r9cTdwb/o61/+bdoSzmd4xDMQ3NsgMnDtBqxbjUnFOsrzn7vhslqoqLn690b6InXmDUfknHY84rE9C9QaV2EUjgojYHj07QHXYgcKtHHQbLw9/eAKivtkkOhI28PWsBFUl33uprT+VbsWDeK3ertN6CK3pa+d6VPAau/aQXQXS0uFJSTueiDtS2fS1WUGPxLAppI+NYWoe4oGI2TQI7w6QhjPNNXmDSwftc+h2NIglLrFDAviDnykL8+4 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)(376002)(346002)(136003)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(86362001)(36756003)(70206006)(316002)(70586007)(6916009)(478600001)(40480700001)(82310400005)(426003)(2906002)(5660300002)(8676002)(8936002)(6666004)(44832011)(81166007)(82740400003)(36860700001)(26005)(186003)(83380400001)(47076005)(1076003)(2616005)(41300700001)(336012)(7696005)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:21.1694 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c6a320f-fc38-48bf-999f-08db58535997 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: AS2PR08MB9896 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" Instead of using static arrays, build the list of expedited registers dynamically using a std::vector. This refactor shouldn't cause any user-visible changes. Regression-tested for aarch64-linux Ubuntu 22.04/20.04. --- gdbserver/linux-aarch64-tdesc.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc index 633134955e5..3c60e1a4db0 100644 --- a/gdbserver/linux-aarch64-tdesc.cc +++ b/gdbserver/linux-aarch64-tdesc.cc @@ -30,6 +30,8 @@ /* All possible aarch64 target descriptors. */ static std::unordered_map tdesc_aarch64_map; +static std::vector expedited_registers; + /* Create the aarch64 target description. */ const target_desc * @@ -44,15 +46,20 @@ aarch64_linux_read_description (const aarch64_features &features) if (tdesc == NULL) { tdesc = aarch64_create_target_description (features); + expedited_registers.clear (); + + /* Configure the expedited registers. By default we include x29, sp and + pc. */ + expedited_registers.push_back ("x29"); + expedited_registers.push_back ("sp"); + expedited_registers.push_back ("pc"); + + if (features.vq > 0) + expedited_registers.push_back ("vg"); - static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL }; - static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc", - "vg", NULL }; + expedited_registers.push_back (nullptr); - if (features.vq == 0) - init_target_desc (tdesc, expedite_regs_aarch64); - else - init_target_desc (tdesc, expedite_regs_aarch64_sve); + init_target_desc (tdesc, (const char **) expedited_registers.data ()); tdesc_aarch64_map[features] = tdesc; } From patchwork Fri May 19 10:24:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69668 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 E49943836E83 for ; Fri, 19 May 2023 10:26:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E49943836E83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492016; bh=IySlSi8SAVUQm7tH+kJiaEYlbgB9B5hd1xSSVL/3Oo0=; 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=ZcjGd+bVNYh8i2hu0yLmk7CW7bjF5M9sy63N16Losv93A6k3THlEmdiQBVTVDqP2H qLQv09gycnaamCHljCU/ekHmWFaN1gMvc2irCCtz97KaIV18JE5z3h6QeWeH9kqVXw MFr/yHefxHkvbkp8DMHgKcFcfTEQM0K3O//eykt0= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by sourceware.org (Postfix) with ESMTPS id 8B18D3858C27 for ; Fri, 19 May 2023 10:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B18D3858C27 Received: from AM7PR03CA0023.eurprd03.prod.outlook.com (2603:10a6:20b:130::33) by DBBPR08MB5995.eurprd08.prod.outlook.com (2603:10a6:10:20b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Fri, 19 May 2023 10:25:24 +0000 Received: from AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:130:cafe::43) by AM7PR03CA0023.outlook.office365.com (2603:10a6:20b:130::33) 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:24 +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 AM7EUR03FT058.mail.protection.outlook.com (100.127.140.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:24 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Fri, 19 May 2023 10:25:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e4a7755dfc3b5a54 X-CR-MTA-TID: 64aa7808 Received: from df1ab71b1be3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 20FB4D32-6003-4D47-B431-F500F8EDDCFB.1; Fri, 19 May 2023 10:25:18 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id df1ab71b1be3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SWgTFJqeVVbJ2ryRKTgmvxr4nlGsGRIajFL77lXF6lfCtc0Z4UOnX5Kg+yKfjHVL//KuXi0UB87wkBjptzsHIpE1Jn7Q6FqGsKGSDGo+frTJ8L5iBAuSaE20y0fKxe6I3cfIQEXxT5C6+/b8qw99+XaolEz+52rSJv5jYL4qfPolROKz8xjGD0lLYiBCWezUgTdFsgmFbEgBxx7hUJ4hnlnkZJ9TBfoJkBCWx92Xr2GX5NtYYBk1YPvr/JK16PM0ByFwZ2qce55gjSU9M9kzw6azLg/fKANJRZJVSOEV3R6SvKYD7SMeYF/AR01OBLnw1YA261m/+cKz8HfN6TOZgg== 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=IySlSi8SAVUQm7tH+kJiaEYlbgB9B5hd1xSSVL/3Oo0=; b=SYGUcgratSEn4d7ZLBIlZ/O/rdrtkJmOHEhA9vZTqqAmh4hVSRyAIxHCbuF2twrpVHOg/4VaZDGoxNctXi8hR+tszA5SA47wBvxOpxueTo+OR6bcyNfUFDGK60NiAZZVi9+9/VC2TFDXIql251QdgzNTgax8YIujkIo2MJ6hfOzbk+gqHNZdO4baXqCThtM8ZYqDRHuFGdj2WczYXalTNl8uxjpr6XShtQMMtlkV+kOJJHureK+kqQxiumghXhMqb9JdU4RxNvTXq1efJOiqNSaog3kUUhrBUZm4C7P9QRMcHQuWABAbYD4Lub7L2t6x54Ogaim6HWoifCsizW5S0Q== 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 AS9PR05CA0182.eurprd05.prod.outlook.com (2603:10a6:20b:495::17) by PAXPR08MB7525.eurprd08.prod.outlook.com (2603:10a6:102:24b::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:13 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:495:cafe::16) by AS9PR05CA0182.outlook.office365.com (2603:10a6:20b:495::17) 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 07/17] [gdbserver/aarch64] sme: Add support for SME Date: Fri, 19 May 2023 11:24:58 +0100 Message-ID: <20230519102508.14020-8-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_|PAXPR08MB7525:EE_|AM7EUR03FT058:EE_|DBBPR08MB5995:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bc3576b-8e23-4dfa-be35-08db58535b53 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: LiXJILC6JPwfSPKAnmFU5lA/7V75tYDQtlFAaeYOkxA4wN/42ysGxhFmxKy86a7O+ql/QMrlPo+GT0K/iSArG4vEoRllpOOoMhQPbNqYgDks7PEWga/vJ2xkfdh5owL0KABM1UNN7++IotfXi4R4CwOIKPh8tIT/chqw5HsY4LZ3W+5jHduODH586/AG2Xoc8LHAtzjDxs2dCsHcVZpFMBfNyW4NITsFDgTbL1Uylx2IeplQF+WSQVLwKdlbsMVQMYNOIUfCcTFHgzrKhzJBImqhURvAJup7yt3I5NYH8PhMaacbfWkfgzHBo4x6vFDQZABPKgrLLetnI/9nZKv6dmN9idcFLwCPTrG0SyK9GLkiZ6knAMI+6egojKQtL3dsn5mnc+sHW6EuKuWfzzG4cZ5pcdO5V/xnrW+sAWEmbzxa+5bhlQef9kfUEiqO6h5juGRZGuPXlO5bYwTCkoAmGaHDzKNihUPPBRUr9KQlQfnj9+urOp8pxd9PGQ+bb7xKUeQSwDKZQbsDWu2KYgjvcjqYnweqYC4DOBIEfZWaCmbHhCialjlSBQOHuTm0g0hrnq6HUnrNgZ1y/36pBdsvM1TuBFE0A6fgcAQanQopzyv9Dge0OLoab2ax4i1z1vmJDyUsg/e0tE37XTFuhl7L0rLzyG7cT+mwbfkfJh/BhR0PVGBtDOlyedtb68vTCgXh0qiBW7NdP43qlnRBXP5qCuoyhHk2KeY0hPRwwXVfx0R2/Bnixx38L+e08+ciOlsm84etK4t10hs0FVirafQ31A== 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)(346002)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(26005)(40460700003)(1076003)(7696005)(36860700001)(83380400001)(47076005)(2616005)(40480700001)(336012)(36756003)(426003)(86362001)(82310400005)(186003)(82740400003)(356005)(81166007)(44832011)(478600001)(2906002)(316002)(8936002)(6916009)(8676002)(41300700001)(5660300002)(70586007)(70206006)(66899021)(6666004)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7525 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e1c229ba-7fc5-429c-6042-08db585354c7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LPBBltq2K3VIeEr1Yh8c+LiJsa/xkOS3jx7VOKVpKNItPmowz26kqtWjm6pr9untatSNxA4bJUdd17IDp0Re2TRWnpTYdFdtIu9/28j9ddy0EvSmNKVA+s4PG4Uwe3LeE3iFneRliQD/0X420ZtwxMNBX4TEC8r1t3uYMbS8DfDrEfgcZWWpT/Z92MYGmh3miH5h2rB7tu36AzsNkNyXFsfzD3fHtNdCNUd2E3cKuX4gnOEaOZkgUpcm9AliUZc8ewh3F3UNKVupb5S6l9vxv5YkxYNiCcDM79AYI9Z+ajO83BojYJ1KO4IjsqO+IyX1OhYQUgeAoBFYaFmoOhnwZHsK1JJ6sgU59zThgqRRbXEbYJkJNJZG+gliu4T8+uQVAp+XxbQt5n4LhffgijIPIWokrpKnzVDzEs8EspxglRjGHcpWtQWNfgNEkZ10ph+somvXmKWFHhnNj4LJVzTKt0S/X03jY4xfsUpVJ0MfUHcBrJBFl/4fgzeq4c7XC3tvwIIl9CjNe2I327AmbSKpwwI1pni7GTwCIxd+D+SCpiyhOteJIxY7B0CVTVS9a7WWfplirRcrhu9sLvDlR/SvrHSpk0gu+NtQJQPwKMil06aZVAz/8SVBNumbYJ/kAWrSrZNxcwqbqywWylocuPucYrSxbWW4MbaQgrxQEBhr85yWaZC/V+QZNkMPPN//CANO4PLNYStcszBtIK1/kL1QoC1PGD9sc7JWj8h+IVETviMj9ZrIhK/77xSI7dipi1dL 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)(39860400002)(136003)(396003)(451199021)(46966006)(36840700001)(40470700004)(70206006)(70586007)(478600001)(316002)(7696005)(6666004)(66899021)(36756003)(41300700001)(83380400001)(5660300002)(6916009)(40460700003)(1076003)(26005)(186003)(8676002)(8936002)(40480700001)(44832011)(2616005)(426003)(36860700001)(47076005)(336012)(2906002)(82740400003)(86362001)(81166007)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:24.0020 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bc3576b-8e23-4dfa-be35-08db58535b53 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: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB5995 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" Enable SME support in gdbserver by adjusting the usual fields. There is not much to this patch because the code is either in gdb or it is shared between gdbserver and gdb. One exception is the bump to gdbserver's PBUFSIZ from 18432 to 131104. Since the ZA register can be quite big (256 * 256 bytes), the g/G remote packet will also become quite big From gdbserver/tdesc.cc:init_target_desc, I estimated the new size should be at least (2 * 256 * 256 + 32), which yields 131104. It is also unlikely we will find a process starting up with SVL set to 256. Ideally we'd adjust the packet size dynamically based on what we need, but for now this should do. Please note we have the same limitation for SME that we have for SVE, and that is the fact gdbserver cannot communicate vector length changes to gdb via the remote protocol. Thiago is working on this improvement, which hopefully will be able to be adapted to SME in an easy way. Co-Authored-By: Ezra Sitorus --- gdbserver/linux-aarch64-low.cc | 74 ++++++++++++++++++++++++++++++++ gdbserver/linux-aarch64-tdesc.cc | 7 +++ gdbserver/server.h | 2 +- 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index af2e0fd9c10..93f5f4bb499 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -41,6 +41,7 @@ #include "gdb_proc_service.h" #include "arch/aarch64.h" #include "arch/aarch64-mte-linux.h" +#include "arch/aarch64-scalable-linux.h" #include "linux-aarch32-tdesc.h" #include "linux-aarch64-tdesc.h" #include "nat/aarch64-mte-linux-ptrace.h" @@ -750,6 +751,66 @@ aarch64_sve_regs_copy_from_regcache (struct regcache *regcache, void *buf) memcpy (buf, sve_state.data (), sve_state.size ()); } +/* Wrapper for aarch64_za_regs_copy_to_reg_buf, to help copying NT_ARM_ZA + state from the thread (BUF) to the register cache. */ + +static void +aarch64_za_regs_copy_to_regcache (struct regcache *regcache, + ATTRIBUTE_UNUSED const void *buf) +{ + /* BUF is unused here since we collect the data straight from a ptrace + request, therefore bypassing gdbserver's own call to ptrace. */ + int tid = lwpid_of (current_thread); + + gdb::optional za_regnum + = find_regno_no_throw (regcache->tdesc, "za"); + gdb::optional svg_regnum + = find_regno_no_throw (regcache->tdesc, "svg"); + gdb::optional svcr_regnum + = find_regno_no_throw (regcache->tdesc, "svcr"); + + gdb_assert (za_regnum.has_value ()); + gdb_assert (svg_regnum.has_value ()); + gdb_assert (svcr_regnum.has_value ()); + + /* Update the register cache. aarch64_za_regs_copy_to_reg_buf handles + fetching the NT_ARM_ZA state from thread TID. */ + aarch64_za_regs_copy_to_reg_buf (tid, regcache, *za_regnum, *svg_regnum, + *svcr_regnum); +} + +/* Wrapper for aarch64_za_regs_copy_from_reg_buf, to help copying NT_ARM_ZA + state from the register cache to the thread (BUF). */ + +static void +aarch64_za_regs_copy_from_regcache (struct regcache *regcache, void *buf) +{ + int tid = lwpid_of (current_thread); + + gdb::optional za_regnum + = find_regno_no_throw (regcache->tdesc, "za"); + gdb::optional svg_regnum + = find_regno_no_throw (regcache->tdesc, "svg"); + gdb::optional svcr_regnum + = find_regno_no_throw (regcache->tdesc, "svcr"); + + gdb_assert (za_regnum.has_value ()); + gdb_assert (svg_regnum.has_value ()); + gdb_assert (svcr_regnum.has_value ()); + + /* Update the thread NT_ARM_ZA state. aarch64_za_regs_copy_from_reg_buf + handles writing the ZA state back to thread TID. */ + aarch64_za_regs_copy_from_reg_buf (tid, regcache, *za_regnum, *svg_regnum, + *svcr_regnum); + + /* We need to return the expected data in BUF, so copy whatever the kernel + already has to BUF. */ + + /* Obtain a dump of ZA from ptrace. */ + gdb::byte_vector za_state = aarch64_fetch_za_regset (tid); + memcpy (buf, za_state.data (), za_state.size ()); +} + /* Array containing all the possible register sets for AArch64/Linux. During architecture setup, these will be checked against the HWCAP/HWCAP2 bits for validity and enabled/disabled accordingly. @@ -772,6 +833,11 @@ static struct regset_info aarch64_regsets[] = 0, EXTENDED_REGS, aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache }, + /* Scalable Matrix Extension (SME) ZA register. */ + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_ZA, + 0, EXTENDED_REGS, + aarch64_za_regs_copy_from_regcache, aarch64_za_regs_copy_to_regcache + }, /* PAC registers. */ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK, 0, OPTIONAL_REGS, @@ -839,6 +905,10 @@ aarch64_adjust_register_sets (const struct aarch64_features &features) if (features.tls > 0) regset->size = AARCH64_TLS_REGISTER_SIZE * features.tls; break; + case NT_ARM_ZA: + if (features.svq > 0) + regset->size = ZA_PT_SIZE (features.svq); + break; default: gdb_assert_not_reached ("Unknown register set found."); } @@ -873,6 +943,10 @@ aarch64_target::low_arch_setup () features.mte = linux_get_hwcap2 (pid, 8) & HWCAP2_MTE; features.tls = aarch64_tls_register_count (tid); + /* Scalable Matrix Extension feature and size check. */ + if (linux_get_hwcap2 (pid, 8) & HWCAP2_SME) + features.svq = aarch64_za_get_svq (tid); + current_process ()->tdesc = aarch64_linux_read_description (features); /* Adjust the register sets we should use for this particular set of diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc index 3c60e1a4db0..b6b622ba4f2 100644 --- a/gdbserver/linux-aarch64-tdesc.cc +++ b/gdbserver/linux-aarch64-tdesc.cc @@ -41,6 +41,11 @@ aarch64_linux_read_description (const aarch64_features &features) error (_("VQ is %" PRIu64 ", maximum supported value is %d"), features.vq, AARCH64_MAX_SVE_VQ); + if (features.svq > AARCH64_MAX_SVE_VQ) + error (_("Streaming svq is %" PRIu8 ", maximum supported value is %d"), + features.svq, + AARCH64_MAX_SVE_VQ); + struct target_desc *tdesc = tdesc_aarch64_map[features]; if (tdesc == NULL) @@ -56,6 +61,8 @@ aarch64_linux_read_description (const aarch64_features &features) if (features.vq > 0) expedited_registers.push_back ("vg"); + if (features.svq > 0) + expedited_registers.push_back ("svg"); expedited_registers.push_back (nullptr); diff --git a/gdbserver/server.h b/gdbserver/server.h index 730ec146530..dc8e04413f1 100644 --- a/gdbserver/server.h +++ b/gdbserver/server.h @@ -104,7 +104,7 @@ extern int in_queued_stop_replies (ptid_t ptid); /* Buffer sizes for transferring memory, registers, etc. Set to a constant value to accomodate multiple register formats. This value must be at least as large as the largest register set supported by gdbserver. */ -#define PBUFSIZ 18432 +#define PBUFSIZ 131104 /* Definition for an unknown syscall, used basically in error-cases. */ #define UNKNOWN_SYSCALL (-1) 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)); From patchwork Fri May 19 10:25:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69675 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 11F89388215E for ; Fri, 19 May 2023 10:28:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11F89388215E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492106; 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=WKG/75Cjsvn4WhW6CX2dkkjEzKQ8rY+l5Wi376eLR2QqNSRzcWTYg56j17vwO3qjE BJJFJS1fF2LbAeGV0gB8A94+lW6tNcrj21AP3D8cmhVeioUgH6jSWr5nlGxevA/Xor COi7wMplfDtcVbNIkpsN2zEeDAkHJxHqZZXuzweU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2056.outbound.protection.outlook.com [40.107.247.56]) by sourceware.org (Postfix) with ESMTPS id 9FF113856DDA for ; Fri, 19 May 2023 10:25:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FF113856DDA Received: from AS9PR05CA0173.eurprd05.prod.outlook.com (2603:10a6:20b:496::7) by DB9PR08MB6377.eurprd08.prod.outlook.com (2603:10a6:10:259::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:30 +0000 Received: from AM7EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:496:cafe::2d) by AS9PR05CA0173.outlook.office365.com (2603:10a6:20b:496::7) 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:30 +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 AM7EUR03FT018.mail.protection.outlook.com (100.127.140.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:30 +0000 Received: ("Tessian outbound 3570909035da:v136"); Fri, 19 May 2023 10:25:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7439f134b79187bb X-CR-MTA-TID: 64aa7808 Received: from 056401805b9d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2A38C693-3D99-4D22-9C17-41D31E8D7339.1; Fri, 19 May 2023 10:25:23 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 056401805b9d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZVO8SwQcQAD5r91N76E/Kk2XughWRoV3JMbqUha31Zn/JbFO775ATanigF/0Yej3/v7Um+rJILSHdKJ+xmSa4niGN/QyFryb1gLBNjYK5AiE3o3QPlWpWzRa9vAOeJ0xGy8EoIpB919WeiG3PqW72dcTD3KT8iLEZjnfvy9bglFyo7/nNmHZ3HvCeX60ficCs/Mx7cqkTNID2yR1OCEmvpVi34C4hyagRSbJTCMpT6+iaBq0w7vvSG3JI2ZB47IytV9QHAuH305CvwsFP3ne4FtKHOk+Yzr6Gw2NnjLJlXclNsF2izoejh26P0SpX+p9MHprvBRhWcT6fCVhbcIkGQ== 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=efVp+EHhJuWNk+iOqRd+PsDtvwTBRm75tPTP0HeMzZB4PdfmmstSzy0q1UPWe0uHdKl5sEMAEWl1DbDWz5zk7jjdMhWhPUp0fjBcQytpvVvf7gwUU9Yn1zygxyJJyYEo09D/nH3D7DNL+/bg6xnROpyGj7qz6gy3PGjkWMy/MxtkHFxmkpekL4gW4Kriw9r0ZObbl+YUQViYWn/ouDdKLqUSYWvdpCJ/H6ebHlFN/WlRFsuaSOKeSEcxSv4NTqIrxXAO7sLgDUCW+FDl/Z3dGqHYJkJddqfbXo8NCUQ82YbbdkYolmGJiQxTSjXRirKrlqCaNFeL4g1eKI9Xo/PGLA== 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 DB6PR0202CA0002.eurprd02.prod.outlook.com (2603:10a6:4:29::12) by DU0PR08MB8615.eurprd08.prod.outlook.com (2603:10a6:10:401::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Fri, 19 May 2023 10:25:20 +0000 Received: from DBAEUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:29:cafe::d0) by DB6PR0202CA0002.outlook.office365.com (2603:10a6:4:29::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:20 +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 DBAEUR03FT057.mail.protection.outlook.com (100.127.142.182) 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:20 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) 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 AZ-NEU-EX03.Arm.com (10.251.24.31) 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.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 09/17] [gdb/aarch64] sme: Signal frame support Date: Fri, 19 May 2023 11:25:00 +0100 Message-ID: <20230519102508.14020-10-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: DBAEUR03FT057:EE_|DU0PR08MB8615:EE_|AM7EUR03FT018:EE_|DB9PR08MB6377:EE_ X-MS-Office365-Filtering-Correlation-Id: 214cc852-0c42-473f-ba3b-08db58535f3c 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: cxlzt32MrHEeLwit8wsxgSskyivmzYNQMbLWiei6it6NUzyEVqwfGaA+9LjSC3ueuEXn+IL8ZryBRKxQNRpcnZkJTTz6wj777G+F2Gtt+BY9lQ6oDzLVzGPFnyGeOGxzyoK/XM+LZobA6Nr3wSP6IQ3J8bK4jFgon4jvHJGz+VpWrL4pjMHYUK4caBWY6oEFcEmG57e3RzZxyOoqSaZpfEJBQzi6Vu/rUDrHonzsntWogBoZlnFlw8k/DlkXvhAZ1XBZGXTXYTSJVDT6KT+1NFowx/+CVIUXiK9UC4BnhaeI+WZoaW20vbAVKonEd9f0sSXdRepW/CTQ0+OjHgE+ygNs3l98OUvqiwaXIwE1iFegdIL5qk9eHrShBuvEi4MgGN9r47bEtRgVRvyy6I3kwRdZFJRQxWfpD2e0MpypR9EToBtFXhYM1Tv7bPtCbBmEgMjr1LoC1Xy7y3ODaDYflohocrlAwSqisHRTCCmk11FQrTMUBgRq/6i+CqSrGslPLyjXEhWLyEukJOeCcezFUlIYI0OUr++JroIGCc2e+MuHghbF/4GeWZgo4lYck8ORF0r0dMfR/ElYCn+4x2SLYBdu9QOKxvbbCpsYrGU24HpjaaUQEkrDZ52caIrJZfb/FZAp/la5K5IWneT/HDeyk9qx6TyjlVXddHyoS2fHlvTl5siKEp7ZYVW2bmWLYmgBAdUVAMYcKb9p7Fz1+iK8mADLFAoPm+jmQvzRY6vB1+kNWhRFET4v4E+BPAKlN/qBZ2bZTQxOjgJOow47iZyv8g== 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)(39860400002)(376002)(136003)(346002)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(426003)(47076005)(186003)(1076003)(336012)(6666004)(478600001)(44832011)(2616005)(26005)(83380400001)(2906002)(8676002)(5660300002)(36756003)(6916009)(8936002)(82740400003)(81166007)(356005)(40460700003)(41300700001)(70206006)(70586007)(82310400005)(40480700001)(316002)(86362001)(7696005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8615 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ff9afe99-4b9b-4be8-1d34-08db5853590e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Rb5Ne4UAtPk8rjtrPf2AuJgbWv8dUtSmKZAiz7Jzz+IE9y3wJfk5cpC28ZbID3zuM6204disax3L3raRuk2/zm12Hms8S+cTOznDYlei760Nwoc2+hD18eH2I78XCsPbV2X4ohNfo4DH8fOWEKtPoytVV5yB56g7lctgpS60TQ2ddW+gCBInCFK/nvRk5DnNtxwg6oNwqpwy0pa8Pg9rHvlM9mk5+3nHIusURbbQDGEUxMHrfSaJ12osc8uikRstV+3ltAWjdOaFSGOULQszNd/CdhyVh6oY9ZakRuca2cr+lyGuhFYANtLnmB+zGXqUQLxyUKHJD12bWMiAbVHjH7KaYar/VjBq0DKyw3Tw29+D0vCP7p1qM2XflXCS2w6XdFJmru2l8b/f+EzNh2DPK3nv8b8WYd0szNcdjOApKwBw6cp/W3IMFGN0QSQAm8QmwARHi7uldR7b3wWH8zldwqkTUcJzu0nygtRxpPz/yLUhe7NktDlyglrTKxOZr2FYVcPaebIfCaQh6WKPfpvgTNmXUpMvMk2OAw0WVl1q4dlgSCOlsSQpE2J2PMefxYWCY8Vz1wq+X6MtGwLaWhP72VsbRDKiia5yYDSQ1ePQdV9gxnB3qLFn5wbu76kx+ainwCew8a3LRM1mjWc1wp4vuEPwTe4gaWOrSE27MgNICx9beXp/qfuY10IUitHcMeRqDdrj8JogxDWC1kpsfPXKguoze6vwFrbretaAs7VP/fH0k/UYMozbNgK5FxwlZm+d 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)(136003)(376002)(396003)(39860400002)(346002)(451199021)(46966006)(40470700004)(36840700001)(478600001)(316002)(5660300002)(44832011)(8936002)(8676002)(41300700001)(6916009)(2906002)(40460700003)(70206006)(70586007)(36860700001)(36756003)(40480700001)(6666004)(7696005)(1076003)(186003)(26005)(82740400003)(86362001)(47076005)(2616005)(81166007)(336012)(82310400005)(426003)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:30.5621 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 214cc852-0c42-473f-ba3b-08db58535f3c 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: AM7EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6377 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" 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]; }; /* From patchwork Fri May 19 10:25:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69666 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 326E03850404 for ; Fri, 19 May 2023 10:26:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 326E03850404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684491985; bh=1BVMpzu9u92Ka7GRyrQIXznALMHz0LmukjpxeZ7n2OA=; 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=PcMBgKkP2y91+aasGvvUsnmWMAJ9ByrlvL37N5TX9JEWiq8r96ldmhQj6FOdOpTS3 WatMu2BYmZLEufwk+07IDT28vjsVSHaxZ96vR1VgTfrq+4AncQKBK9/ZcY69gUeP1i 1g93U8/yUttWQMjuihoZojtV1DiHl41E6zjw/aho= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0631.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::631]) by sourceware.org (Postfix) with ESMTPS id 4CF4E3858C5F for ; Fri, 19 May 2023 10:25:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CF4E3858C5F Received: from DUZPR01CA0068.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c2::18) by GV1PR08MB8450.eurprd08.prod.outlook.com (2603:10a6:150:82::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:22 +0000 Received: from DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c2:cafe::f1) by DUZPR01CA0068.outlook.office365.com (2603:10a6:10:3c2::18) 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 DBAEUR03FT016.mail.protection.outlook.com (100.127.142.204) 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 8b05220b4215:v136"); Fri, 19 May 2023 10:25:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 384607515f6da407 X-CR-MTA-TID: 64aa7808 Received: from 02246e68db93.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BBBAF6C7-FE2E-4376-8333-E3447B912099.1; Fri, 19 May 2023 10:25:16 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 02246e68db93.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nBNaTztbe7R147gEbLn0+VCvIbpfq09fIRheZFoLS8mskQCkrXpkcfK8Qhv4llItCUazNrF1GHMbQatx24X2vJ4MCrMwvtHYmGiVJ/MbOA1Fb9N6u+ecUcq/xwQUxCIWLu3NGZ0/qR97SejWsxsquGNK6Pp5mV+VOQHBCIryk5Sl4tdr1dpEFWC0yQN2FCl1ekFQmqha+BRxQhy5kv/LEyj05ZeAdR1E3jcxBQ5AcCl+nJ5B1VGfPpMtKnl3Xm7SVo3ygbvCxsWQmnlbAxiogezDUYo55vWj4fc5SKeAJEk6o4bGeGSwe/5yvRi36aHy2vAcYJJbDAZI/IzDzEm7ww== 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=1BVMpzu9u92Ka7GRyrQIXznALMHz0LmukjpxeZ7n2OA=; b=hf9ZCyL6QBOZMUyL4pjZHDI6YhwM7JvDREc4lxQHOHgL2FiwJGlcrcop2hMrSOXNfBMSl03neKnlvbA3wtFM5pf31xtgGV2qSEM+NDJJBchUHyoXga44h6ETVqJQxRaBFyR12hVe5BEt730Y02xzdDltgIEEm31r3ajh37m8/uQNtlpQ6cncvjtuUC6dkeHHeY0QgD+pNaf2rP8r8zCD2MBmaXvtpL9dmD+Hjq+5udq5S9HUOghTStyfR4dBsqmN3UomVMlzhq97lt9SFNGdzE7jLNMQUzT33YLU4KGk82FUnwI8A1UC0/aI+YBDDlCLPvFmrKytzONpAd9iJh6Wgg== 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 AS8PR04CA0129.eurprd04.prod.outlook.com (2603:10a6:20b:127::14) by DB4PR08MB8127.eurprd08.prod.outlook.com (2603:10a6:10:382::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:13 +0000 Received: from AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:127:cafe::3f) by AS8PR04CA0129.outlook.office365.com (2603:10a6:20b:127::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: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 AM7EUR03FT039.mail.protection.outlook.com (100.127.140.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 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 10/17] [gdb/aarch64] sme: Fixup sigframe gdbarch when vg/svg changes Date: Fri, 19 May 2023 11:25:01 +0100 Message-ID: <20230519102508.14020-11-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: AM7EUR03FT039:EE_|DB4PR08MB8127:EE_|DBAEUR03FT016:EE_|GV1PR08MB8450:EE_ X-MS-Office365-Filtering-Correlation-Id: 40e31540-0812-441a-ac25-08db58535a19 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: wWB9QMgIrMHg8PUSvI2hXqwLYIMcrOn4ZgRT+5zYxXWn8KJLYx/Bcj4Whq5/59XVRLljhCEK9nex7Ib3rsanyjNkxInM68Ap83y8bY3VgyUKXBc1yVYStG3z4wCPAOg30tLb8+CxrNn1ph9CZ8on6na6ie73GMIX/V/YyyUCoiS+UlAI92kDuPKyUWpAgTHt9E4Bv0A1nXPEtOU1fqwdOBcYQ5uCEV3XE8qG86PXBYt4BWKlaxuUpYBv3WyqzAyByFMXjtMuDtF3Ewm6aBG+lLNlsthYVnAtKUaXT6H7ESqkaqaejymwUFwZT+a4KnPOGZYPmU9e/BoGssuFfxOYI6lWU8c46aMxdUC92hsoU92PXGIq2+mQGlb+oidMR3in6BwENG+WNVnP9bwl79BUbJH7dPAmhPahPKkF22PFjYUYwU7G6hPhsKfg2HMtLdLLkw1dNOR1OSvrjH0+F7icCzm7iFBI6CY9CqpH4glCs4S5ivZUF+Gn01oIR+2RwRezrAU0g0ByVeLi6ijxy4n6Jlep+YWTWNxKVHO+gt78rf7Bxj/Gujfw9DrY+NlGpzYuuz4jUTTkSMEwKJKbCotZoQkckofWlLZVO41i4VtQhsl3sGMtqBjod+M+J0WBcWfbsxedAGsDIi9kX3qNRkqd6kKhBuar5tjjHhYx5ClGX5QMsQEvsnlRJgwK3GfNvk+OiZLFT+6CKIxz0oG2A1h2cR3+pRc85z9LO9SuU1VYUpUoTKExTLE9DpiVZ/sggr4Z 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)(39850400004)(136003)(346002)(451199021)(46966006)(36840700001)(30864003)(426003)(2616005)(47076005)(336012)(2906002)(36860700001)(70586007)(70206006)(8936002)(8676002)(6666004)(83380400001)(44832011)(1076003)(26005)(186003)(41300700001)(5660300002)(316002)(7696005)(6916009)(356005)(66899021)(81166007)(82740400003)(86362001)(478600001)(82310400005)(40480700001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB8127 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7b7bc2ef-1ed1-4b64-5e7c-08db58535534 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VLay+nwAwDCj2lbHR2B2CTnWPkP2LPPNEHKVCalWMFHw04yvzASKYnNzGho2ix3/qlznkfKvezGhQkC0UNIS3OK/VOUKtLNaPt6yaGxfdpXhX89LU5hlAecO2P6y/3K8Is/T+5Va5rHqpj1eMPZbBETlfSbGj9cDE+fPUxGsFs0Ns96CWGmID1gd0wlzBn2FgaceMU/HuCfZBs1oMRy7UVgrpQqrfZCUBsA/E+vT8AtI0r4q2pWd40usmY3kjv6nHq1+gVF+bZL1yPBf0nrd35QXg7e7mc/ilKsljZ6n/td2NuTI3Wh9KsIfxYPcGUDhQSfoluftxOlF9Maqx8qAJwAxrKZBG51eNJpYyHM2se/EOYZCjxV+xAiv5lYNwXm0ZjSFMUyQ6OhWFSWWSPdUHwtM8FExgLHwYv3ExdRck9R2nP8fE7eY6uE1ZGBOP/Tujtm8zdpQVqU1dJS3bXQXW/Gw6nJksG4EFJcxMw8PjssAgcGK5Hi28eMCH7vniX6BJH06BPu9yTsd3OOoVRIm9B3M0hwpcE6ondnCpzL7leoVpkhGOP7/xfRq4jvDdfwT7Y/LXUVGDRY5s4zAtO1yxx9qPmOkxdDp9c3H+t/s7F8eEX3SC2WU2Hi/XoxFCu5ue+01w8qnORK2IGK4ZJgeJSzDBEjn1bCWpAKme4ZfTi141QU9ojCX6jvVohLFxPqCG1WLOQNfAcXbuP8OYuRjoSKzEw1zzy12UG4FgvbLqvBcW53xnBqoPHRAFRPAGqu1 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)(376002)(396003)(136003)(39860400002)(346002)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(66899021)(82310400005)(40480700001)(336012)(2616005)(44832011)(5660300002)(1076003)(26005)(8676002)(86362001)(8936002)(36756003)(47076005)(83380400001)(2906002)(30864003)(36860700001)(478600001)(41300700001)(6916009)(426003)(186003)(316002)(70206006)(70586007)(7696005)(81166007)(6666004)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:22.0062 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40e31540-0812-441a-ac25-08db58535a19 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: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8450 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, 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" With SME, where you have two different vector lengths (vl and svl), it may be the case that the current frame has a set of vector lengths (A) but the signal context has a distinct set of vector lengths (B). In this case, we may run into a situation where GDB attempts to use a gdbarch created for set A, but it is really dealing with a frame that was using set B. This is problematic, specially with SME, because now we have a different number of pseudo-registers and types that gets cached on creation of each gdbarch variation. For AArch64 we really need to be able to use the correct gdbarch for each frame, and I noticed the signal frame (tramp-frame) doesn't have a settable prev_arch field. So it ends up using the default frame_unwind_arch function and eventually calling get_frame_arch (next_frame). That means the previous frame will always have the same gdbarch as the current frame. This patch first refactors the AArch64/Linux signal context code, simplifying it and making it reusable for our purposes of calculating the previous frame's gdbarch. I introduced a struct that holds information that we have found in the signal context, and with which we can make various decisions. Finally, a small change to tramp-frame.c and tramp-frame.h to expose a prev_arch hook that the architecture can set. With this new field, AArch64/Linux can implement a hook that looks at the signal context and infers the gdbarch for the previous frame. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-tdep.c | 279 +++++++++++++++++++++++++++------------ gdb/tramp-frame.c | 1 + gdb/tramp-frame.h | 12 ++ 3 files changed, 206 insertions(+), 86 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 1e12a8f0279..c973a790f62 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -184,6 +184,39 @@ #define AARCH64_SME_CONTEXT_SIZE(svq) \ (AARCH64_SME_CONTEXT_REGS_OFFSET + AARCH64_SME_CONTEXT_ZA_SIZE (svq)) +/* Holds information about the signal frame. */ +struct aarch64_linux_sigframe +{ + /* The stack pointer value. */ + CORE_ADDR sp = 0; + /* The sigcontext address. */ + CORE_ADDR sigcontext_address = 0; + /* The start/end signal frame section addresses. */ + CORE_ADDR section = 0; + CORE_ADDR section_end = 0; + + /* Starting address of the section containing the general purpose + registers. */ + CORE_ADDR gpr_section = 0; + /* Starting address of the section containing the FPSIMD registers. */ + CORE_ADDR fpsimd_section = 0; + /* Starting address of the section containing the SVE registers. */ + CORE_ADDR sve_section = 0; + /* Starting address of the section containing the ZA register. */ + CORE_ADDR za_section = 0; + /* Starting address of the section containing extra information. */ + CORE_ADDR extra_section = 0; + + /* The vector length (SVE or SSVE). */ + ULONGEST vl = 0; + /* The streaming vector length (SSVE/ZA). */ + ULONGEST svl = 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; +}; + /* Read an aarch64_ctx, returning the magic value, and setting *SIZE to the size, or return 0 on error. */ @@ -319,129 +352,115 @@ aarch64_linux_restore_vregs (struct gdbarch *gdbarch, } } -/* Implement the "init" method of struct tramp_frame. */ +/* Given a signal frame THIS_FRAME, read the signal frame information into + SIGNAL_FRAME. */ static void -aarch64_linux_sigframe_init (const struct tramp_frame *self, - frame_info_ptr this_frame, - struct trad_frame_cache *this_cache, - CORE_ADDR func) +aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame, + struct aarch64_linux_sigframe &signal_frame) { - struct gdbarch *gdbarch = get_frame_arch (this_frame); - enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); - CORE_ADDR sigcontext_addr = (sp + AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET - + AARCH64_UCONTEXT_SIGCONTEXT_OFFSET ); - CORE_ADDR section = sigcontext_addr + AARCH64_SIGCONTEXT_RESERVED_OFFSET; - 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; + signal_frame.sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); + signal_frame.sigcontext_address + = signal_frame.sp + AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET + + AARCH64_UCONTEXT_SIGCONTEXT_OFFSET; + signal_frame.section + = signal_frame.sigcontext_address + AARCH64_SIGCONTEXT_RESERVED_OFFSET; + signal_frame.section_end + = signal_frame.section + AARCH64_SIGCONTEXT_RESERVED_SIZE; + + signal_frame.gpr_section + = signal_frame.sigcontext_address + AARCH64_SIGCONTEXT_XO_OFFSET; + + /* Search for all the other sections, stopping at null. */ + CORE_ADDR section = signal_frame.section; + CORE_ADDR section_end = signal_frame.section_end; uint32_t size, magic; - size_t vq = 0, svq = 0; bool extra_found = false; - int num_regs = gdbarch_num_regs (gdbarch); - - /* Read in the integer registers. */ + enum bfd_endian byte_order + = gdbarch_byte_order (get_frame_arch (this_frame)); - for (int i = 0; i < 31; i++) - { - trad_frame_set_reg_addr (this_cache, - AARCH64_X0_REGNUM + i, - sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET - + i * AARCH64_SIGCONTEXT_REG_SIZE); - } - trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM, - sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET - + 31 * AARCH64_SIGCONTEXT_REG_SIZE); - trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, - sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET - + 32 * AARCH64_SIGCONTEXT_REG_SIZE); - - /* Search for the FP and SVE sections, stopping at null. */ while ((magic = read_aarch64_ctx (section, byte_order, &size)) != 0 && size != 0) { switch (magic) { case AARCH64_FPSIMD_MAGIC: - fpsimd = section; - section += size; - break; + { + signal_frame.fpsimd_section = section; + section += size; + break; + } case AARCH64_SVE_MAGIC: { /* Check if the section is followed by a full SVE dump, and set sve_regs if it is. */ gdb_byte buf[4]; - uint16_t flags; - - if (!tdep->has_sve ()) - break; + /* Extract the vector length. */ if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, buf, 2) != 0) { + warning (_("Failed to read the vector length from the SVE " + " signal frame context.")); section += size; break; } - vq = sve_vq_from_vl (extract_unsigned_integer (buf, 2, byte_order)); - /* 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 ()) + signal_frame.vl = extract_unsigned_integer (buf, 2, byte_order); + + /* Extract the flags to check if we are in streaming mode. */ + if (target_read_memory (section + + AARCH64_SVE_CONTEXT_FLAGS_OFFSET, + buf, 2) != 0) { - 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; + warning (_("Failed to read the flags from the SVE signal frame" + " context.")); + section += size; + break; } - if (size >= AARCH64_SVE_CONTEXT_SIZE (vq)) - sve_regs = section + AARCH64_SVE_CONTEXT_REGS_OFFSET; + uint16_t flags = extract_unsigned_integer (buf, 2, byte_order); + /* Is this SSVE data? If so, we are in streaming mode. */ + signal_frame.streaming_mode + = (flags & SVE_SIG_FLAG_SM) ? true : false; + + ULONGEST vq = sve_vq_from_vl (signal_frame.vl); + if (size >= AARCH64_SVE_CONTEXT_SIZE (vq)) + { + signal_frame.sve_section + = section + AARCH64_SVE_CONTEXT_REGS_OFFSET; + } section += size; 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]; + /* Extract the streaming vector length. */ if (target_read_memory (section + AARCH64_SVE_CONTEXT_VL_OFFSET, buf, 2) != 0) { + warning (_("Failed to read the streaming vector length from " + " ZA signal frame context.")); section += size; break; } - svq = sve_vq_from_vl (extract_unsigned_integer (buf, 2, - byte_order)); + + signal_frame.svl = extract_unsigned_integer (buf, 2, byte_order); + ULONGEST svq = sve_vq_from_vl (signal_frame.svl); 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; + signal_frame.za_section + = section + AARCH64_SME_CONTEXT_REGS_OFFSET; + signal_frame.za_payload = true; } - section += size; break; } @@ -457,11 +476,14 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, if (target_read_memory (section + AARCH64_EXTRA_DATAP_OFFSET, buf, 8) != 0) { + warning (_("Failed to read the extra section address from the" + " signal frame context.")); section += size; break; } section = extract_unsigned_integer (buf, 8, byte_order); + signal_frame.extra_section = section; extra_found = true; break; } @@ -477,11 +499,49 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, if (!extra_found && section > section_end) break; } +} + +/* Implement the "init" method of struct tramp_frame. */ + +static void +aarch64_linux_sigframe_init (const struct tramp_frame *self, + frame_info_ptr this_frame, + struct trad_frame_cache *this_cache, + CORE_ADDR func) +{ + /* Read the signal context information. */ + struct aarch64_linux_sigframe signal_frame; + aarch64_linux_read_signal_frame_info (this_frame, signal_frame); + + /* Now we have all the data required to restore the registers from the + signal frame. */ + + /* Restore the general purpose registers. */ + CORE_ADDR offset + = signal_frame.sigcontext_address + AARCH64_SIGCONTEXT_XO_OFFSET; + for (int i = 0; i < 31; i++) + { + trad_frame_set_reg_addr (this_cache, AARCH64_X0_REGNUM + i, offset); + offset += AARCH64_SIGCONTEXT_REG_SIZE; + } + trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM, offset); + offset += AARCH64_SIGCONTEXT_REG_SIZE; + trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, offset); - if (sve_regs != 0) + struct gdbarch *gdbarch = get_frame_arch (this_frame); + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + /* Restore the SVE / FPSIMD registers. */ + if (tdep->has_sve () && signal_frame.sve_section != 0) { - CORE_ADDR offset; + ULONGEST vq = sve_vq_from_vl (signal_frame.vl); + CORE_ADDR sve_regs = signal_frame.sve_section; + + /* Restore VG. */ + trad_frame_set_reg_value (this_cache, AARCH64_SVE_VG_REGNUM, + sve_vg_from_vl (signal_frame.vl)); + int num_regs = gdbarch_num_regs (gdbarch); for (int i = 0; i < 32; i++) { offset = sve_regs + (i * vq * 16); @@ -511,30 +571,75 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, trad_frame_set_reg_addr (this_cache, AARCH64_SVE_FFR_REGNUM, offset); } - if (fpsimd != 0) + /* Restore the FPSIMD registers. */ + if (signal_frame.fpsimd_section != 0) { + CORE_ADDR fpsimd = signal_frame.fpsimd_section; + trad_frame_set_reg_addr (this_cache, AARCH64_FPSR_REGNUM, fpsimd + AARCH64_FPSIMD_FPSR_OFFSET); trad_frame_set_reg_addr (this_cache, AARCH64_FPCR_REGNUM, fpsimd + AARCH64_FPSIMD_FPCR_OFFSET); /* If there was no SVE section then set up the V registers. */ - if (sve_regs == 0) + if (!tdep->has_sve () || signal_frame.sve_section == 0) aarch64_linux_restore_vregs (gdbarch, this_cache, fpsimd); } - if (za_state != 0) + /* Restore the SME registers. */ + if (tdep->has_sme ()) { - /* Restore the ZA state. */ - trad_frame_set_reg_addr (this_cache, tdep->sme_za_regnum, - za_state); + if (signal_frame.za_section != 0) + { + /* Restore the ZA state. */ + trad_frame_set_reg_addr (this_cache, tdep->sme_za_regnum, + signal_frame.za_section); + } + + /* Restore/Reconstruct SVCR. */ + ULONGEST svcr = 0; + svcr |= signal_frame.za_payload ? SVCR_ZA_BIT : 0; + svcr |= signal_frame.streaming_mode ? SVCR_SM_BIT : 0; + trad_frame_set_reg_value (this_cache, tdep->sme_svcr_regnum, svcr); + + /* Restore SVG. */ + trad_frame_set_reg_value (this_cache, tdep->sme_svg_regnum, + sve_vg_from_vl (signal_frame.svl)); } - /* 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 (signal_frame.sp, func)); +} - trad_frame_set_id (this_cache, frame_id_build (sp, func)); +/* Implements the "prev_arch" method of struct tramp_frame. */ + +static struct gdbarch * +aarch64_linux_sigframe_prev_arch (frame_info_ptr this_frame, + void **frame_cache) +{ + struct trad_frame_cache *cache + = (struct trad_frame_cache *) *frame_cache; + + gdb_assert (cache != nullptr); + + struct aarch64_linux_sigframe signal_frame; + aarch64_linux_read_signal_frame_info (this_frame, signal_frame); + + /* The SVE vector length and the SME vector length may change from frame to + frame. Make sure we report the correct architecture to the previous + frame. + + We can reuse the next frame's architecture here, as it should be mostly + the same, except for potential different vg and svg values. */ + const struct target_desc *tdesc + = gdbarch_target_desc (get_frame_arch (this_frame)); + aarch64_features features = aarch64_features_from_target_desc (tdesc); + features.vq = sve_vq_from_vl (signal_frame.vl); + features.svq = (uint8_t) sve_vq_from_vl (signal_frame.svl); + + struct gdbarch_info info; + info.bfd_arch_info = bfd_lookup_arch (bfd_arch_aarch64, bfd_mach_aarch64); + info.target_desc = aarch64_read_description (features); + return gdbarch_find_by_info (info); } static const struct tramp_frame aarch64_linux_rt_sigframe = @@ -551,7 +656,9 @@ static const struct tramp_frame aarch64_linux_rt_sigframe = {0xd4000001, ULONGEST_MAX}, {TRAMP_SENTINEL_INSN, ULONGEST_MAX} }, - aarch64_linux_sigframe_init + aarch64_linux_sigframe_init, + nullptr, /* validate */ + aarch64_linux_sigframe_prev_arch, /* prev_arch */ }; /* Register maps. */ diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c index c69ee6efc2c..94e42e9fec1 100644 --- a/gdb/tramp-frame.c +++ b/gdb/tramp-frame.c @@ -170,5 +170,6 @@ tramp_frame_prepend_unwinder (struct gdbarch *gdbarch, unwinder->stop_reason = default_frame_unwind_stop_reason; unwinder->this_id = tramp_frame_this_id; unwinder->prev_register = tramp_frame_prev_register; + unwinder->prev_arch = tramp_frame->prev_arch; frame_unwind_prepend_unwinder (gdbarch, unwinder); } diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h index fa0241acb2d..563c34ae595 100644 --- a/gdb/tramp-frame.h +++ b/gdb/tramp-frame.h @@ -42,6 +42,13 @@ struct trad_frame_cache; instruction sequence. */ #define TRAMP_SENTINEL_INSN ULONGEST_MAX +/* Assuming the frame chain: (outer) prev <-> this <-> next (inner); + use THIS frame, and implicitly the NEXT frame's register unwind + method, return PREV frame's architecture. */ + +typedef struct gdbarch *(frame_prev_arch_ftype) (frame_info_ptr this_frame, + void **this_prologue_cache); + struct tramp_frame { /* The trampoline's type, some a signal trampolines, some are normal @@ -75,6 +82,11 @@ struct tramp_frame int (*validate) (const struct tramp_frame *self, frame_info_ptr this_frame, CORE_ADDR *pc); + + /* Given the current frame in THIS_FRAME and a frame cache in FRAME_CACHE, + return the architecture of the previous frame. */ + struct gdbarch *(*prev_arch) (frame_info_ptr this_frame, + void **frame_cache); }; void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch, From patchwork Fri May 19 10:25:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69662 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 895F53857C44 for ; Fri, 19 May 2023 10:25:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 895F53857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684491952; bh=v43jB2add7WeYplfqNf1QXEaJ74PsJQfT2dbBozR5MA=; 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=GYE/5qiTMdkcUhmLefGN8Q3WOt9c6kf1j2eLJRkeIEbqXRTmlQdUt9EVwVbOZ0wmY VMBelRkhO7CJKjlwjpXAz7R69oBGoS3ZEHERrOk7fyqgumVO7mvQ3gVOcAux8keqlY YNvOxGazW7wnkXryEF9M0iyMDJeD1yrlvBjD3Nbg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2087.outbound.protection.outlook.com [40.107.247.87]) by sourceware.org (Postfix) with ESMTPS id 675463858D38 for ; Fri, 19 May 2023 10:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 675463858D38 Received: from DB6P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::11) by DB4PR08MB8008.eurprd08.prod.outlook.com (2603:10a6:10:38c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:24 +0000 Received: from DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b8:cafe::e0) by DB6P192CA0001.outlook.office365.com (2603:10a6:4:b8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Fri, 19 May 2023 10:25:24 +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 DBAEUR03FT065.mail.protection.outlook.com (100.127.142.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:24 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Fri, 19 May 2023 10:25:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d025e7f5cbcc7842 X-CR-MTA-TID: 64aa7808 Received: from 3a87434452ad.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 15178B69-F80C-4052-AF7F-44191F0F87F4.1; Fri, 19 May 2023 10:25:17 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3a87434452ad.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TgF4ynhVIX5m/D26t9SnjAtHbO+Pd2T++5E+3xBMqoQngQtCXK7Mgd/JNRssh05fLdzLgx20psf+86kBjhaCxCFdpx9Fu4CpjETUhsbSydTESVZLAjBjQGToQVTr2CYSde2OOZOQLS9zZVbChHqi2j03H+0mFDPU1cKMYNc9cGKAmOKot5ZMMGdm+VGm2QD0yXojixXD+pxbzYDodBDp9X6iVoeh5SIGNawAI2ECV+MVBBraaIh+9+5kCDdhrzmNyql67CK7ItxsKtmGqLyChFZbtfBElzTlEFJPoSD+t5BKESColXzpMaK1gtJbnuIB40NnUYHK8EBj6/j/jXRcgA== 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=v43jB2add7WeYplfqNf1QXEaJ74PsJQfT2dbBozR5MA=; b=HaZwM0GmYT+/9WQZjwXIAxBOg6lRsZPVLi2FGvmxwhipOjxlsSFmF3bHnnXzccUwuddWXyLG/L4IsBTpdmYSIlclRGZTJ6/JrReRuOH3jW3BAeCGaOcYtdvlwowtp6yh0la2qiY9rzyyJrWZ9wS9B1PHYAfLuNhy4479EkXiKk26actRLR06b0J4Bq/U6hLz/KgMwVyZIYQG7RrbiKeND8eETsLMZX6ulUeUtUS96jytSuVfv1uMPyBrYxTaRWQ6uk+nwUFjhT8KdCQYwljGUCLlZvYdJ+cfyOVUP0T2L9Hg28zDgyK1mlVI7uco9Cx4YtII+YuYeZcpXcdX7dlzCg== 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 AS9PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:20b:495::18) by DU2PR08MB7358.eurprd08.prod.outlook.com (2603:10a6:10:2f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:13 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:495:cafe::a4) by AS9PR05CA0209.outlook.office365.com (2603:10a6:20b:495::18) 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 11/17] [gdb/aarch64] sme: Support TPIDR2 signal frame context Date: Fri, 19 May 2023 11:25:02 +0100 Message-ID: <20230519102508.14020-12-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_|DU2PR08MB7358:EE_|DBAEUR03FT065:EE_|DB4PR08MB8008:EE_ X-MS-Office365-Filtering-Correlation-Id: 7956562a-6de0-43b8-fec0-08db58535b4e 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: jVqu+a61S8DZObJqvAKgmL4QxIwQY62a9K7nvidm/lhe3JIfm2rrIgelcT+RYq7v8a9vPPg7wT6QWtnWWZz93PKsWEMnUoUghPBde8/HvbjsXVu/dLk2uhXx0+4aAZ0mtJzKjCycrqSPO3t/bHSvtdVlmd6g8SnrJVvHYmMklatGJ7PST4JnqeBIembeAyqwJY3icDezUrEw3X8a56Wc5LE1Rl+h6yau229HMzbRB2lmEx+0InKGhY61F+3kjTNaqfPwCBp4+16IPB6xlrZ4S5Iodi8QjbiadQKxPwnP3Y50sN6ZIm26YqeZhShWbEFHffF50loWZ7vKDymOY9j9YPBdutzO40cowRHguEuZNa9tEtsK0ZrrpOlWcyrtFuTGMbliNi3OXLiMk188zAbc4C35x9dfQ7sJnen9rvEfHip1i12jCdH9WX8aBSM+ZO5KjUZ1/yDnlMV8qLYBE7sGjAYgfkGH7977lWkMRf77nBA6GpdqLWTLEYarOt7ahZ1+RuYwR7fM9fQ8TLRpImiYHyLCzzMIXyyjzqUPs5az0zTH/Ky6fjNbdr+9f7KVqgoL8DgU0Vu6nXyQtbWyb6tNz7JmN4SjaSSLKh59PfpytP4ssMw5RQE4gGfFtjRPFr9CeYQUfruP990uVfEQ8Cmz7PGzKh0rDQN+TSkcTyitiRmHYrpcjCTQOzy8/+8RznT3Wp9bSs/pj/M6f8Kj8rZ8xWt6PyL6z6XJ+Ax2T32eg/VziHPApxGRu3M7hPAk29oU 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)(346002)(376002)(39850400004)(396003)(136003)(451199021)(46966006)(36840700001)(40480700001)(44832011)(426003)(2616005)(5660300002)(8676002)(8936002)(26005)(1076003)(336012)(36756003)(86362001)(2906002)(47076005)(83380400001)(36860700001)(82310400005)(6916009)(478600001)(41300700001)(186003)(7696005)(70586007)(316002)(70206006)(81166007)(356005)(6666004)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB7358 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 941ebde7-db16-4d24-9369-08db5853553e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7+GpVYqjn9qM71wtyT0NTyNXbVquIMMdE3toEbWpmKD4jXjP3hGBcObqY/zBZ8zkJ9Xc7oSK/7fyKLD7BPwUW6hOo3jbn0iU1l2S2hFLaTGTHwgtsSGfLTVltK9p3ehMnrLNirawYT5NqkSIM8RJ9XkOZysPOyRKDtEOtRllnDw8Q7y95EVvqOWQ4IaGP927t3KRTmlZeN69mgX3tPGCptEwpvG1RVcoKTP6Y/bLegSf0DOl+dL7oCOFEa1vJxaFF97jmoc9U4maNv2K70mCV9N85bTJa6HbR8evQuLIpyg6s+u9UKInPnMTSwPInlWUm+P+J4pHeSvKchkNYYPCg+azno5CaR9MLs3Uftm2C8wdUx96CIc9B92YfzC0FQ21C6mowNFvgbiytcwiTb4wILAxSNAjp4FiXuG7NeRQPdCLGrv61KVGysZ0tkAwsb0iSgh0bPxf6qtbmatK2qfQ7ENpRaoxX+iwZwacj5fp/5N5kFa57mTEWbHL0ccbvuMUj2PhOyCuA6RmCSyglXGTQ0fOh6/hz7rsSaHodxb2+HoivKNzR9v+GEvKhtqjannMYyNZb2a3oIPFgQo5RWHJwE34xLnJ0YJQ1P5uJAXAJcPYYOmNm/6OR6ZPiGK6OoCjbjB4uaHY7odpi3vk6ThJpWuIM90+cIL0dZa8wViAstt5xgeQkwmp0McL5Y9IJwgRPbMUE6Xn31dVCKPKDVSzTWxC6WQV4rkFInKxujVqMtSlzfmHqIXnhTzT2ltXq6so 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)(39850400004)(396003)(376002)(346002)(136003)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(70586007)(70206006)(478600001)(6916009)(316002)(36756003)(86362001)(83380400001)(47076005)(26005)(2616005)(186003)(336012)(426003)(36860700001)(1076003)(5660300002)(41300700001)(8936002)(8676002)(44832011)(2906002)(7696005)(40480700001)(6666004)(82310400005)(81166007)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:24.0334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7956562a-6de0-43b8-fec0-08db58535b4e 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: DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB8008 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" The Linux Kernel defines a separate context for the TPIDR2 register in a signal frame. Handle this additional context in gdb so this register gets restored properly when unwinding through signal frames. The TPIDR2 register is closely related to SME, and is available when SME support is reported. This is tested by testcases that are available in a later patch in the series. Regressions-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-tdep.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index c973a790f62..7ce34ee6846 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -154,6 +154,7 @@ #define AARCH64_FPSIMD_MAGIC 0x46508001 #define AARCH64_SVE_MAGIC 0x53564501 #define AARCH64_ZA_MAGIC 0x54366345 +#define AARCH64_TPIDR2_MAGIC 0x54504902 /* Defines for the extra_context that follows an AARCH64_EXTRA_MAGIC. */ #define AARCH64_EXTRA_DATAP_OFFSET 8 @@ -184,6 +185,9 @@ #define AARCH64_SME_CONTEXT_SIZE(svq) \ (AARCH64_SME_CONTEXT_REGS_OFFSET + AARCH64_SME_CONTEXT_ZA_SIZE (svq)) +/* TPIDR2 register value offset in the TPIDR2 signal frame context. */ +#define AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET 8 + /* Holds information about the signal frame. */ struct aarch64_linux_sigframe { @@ -204,6 +208,8 @@ struct aarch64_linux_sigframe CORE_ADDR sve_section = 0; /* Starting address of the section containing the ZA register. */ 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 extra information. */ CORE_ADDR extra_section = 0; @@ -465,6 +471,13 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame, break; } + case AARCH64_TPIDR2_MAGIC: + { + /* This is context containing the tpidr2 register. */ + signal_frame.tpidr2_section = section; + section += size; + break; + } case AARCH64_EXTRA_MAGIC: { /* Extra is always the last valid section in reserved and points to @@ -607,6 +620,17 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, sve_vg_from_vl (signal_frame.svl)); } + /* Restore the tpidr2 register, if the target supports it and if there is + an entry for it. */ + if (signal_frame.tpidr2_section != 0 && tdep->has_tls () + && tdep->tls_register_count >= 2) + { + /* Restore tpidr2. */ + trad_frame_set_reg_addr (this_cache, tdep->tls_regnum_base + 1, + signal_frame.tpidr2_section + + AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET); + } + trad_frame_set_id (this_cache, frame_id_build (signal_frame.sp, func)); } From patchwork Fri May 19 10:25:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69670 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 C39453882118 for ; Fri, 19 May 2023 10:27:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C39453882118 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492033; bh=Zk+vAdXItRAgvP6lq95RBYRMMmqNxNAaMsimuZiWGKc=; 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=wRgB8kMqaTmy+ORMzgS17ojYqHMHa9Va2/H8uqTDWFHz0+65a5C5ePkAbVSpqZKmL aI1ijGf1P7APXsyq7i2fbV/Tx0Ek0+SI9+rHECAbdUf/zptBp2GVn+Jd6Jf3YYBPAo hDr4s7K+oTHOSruRydH7JlH+hswipkmHt+5th0z0= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2072.outbound.protection.outlook.com [40.107.8.72]) by sourceware.org (Postfix) with ESMTPS id 76EE9385840A for ; Fri, 19 May 2023 10:25:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 76EE9385840A Received: from DUZPR01CA0069.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c2::12) by GV2PR08MB8584.eurprd08.prod.outlook.com (2603:10a6:150:b1::11) 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:30 +0000 Received: from DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c2::4) by DUZPR01CA0069.outlook.office365.com (2603:10a6:10:3c2::12) 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:30 +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 DBAEUR03FT016.mail.protection.outlook.com (100.127.142.204) 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:30 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Fri, 19 May 2023 10:25:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 862a6f489f8f979e X-CR-MTA-TID: 64aa7808 Received: from 0f4dc28aa903.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BFC3A76A-8633-44AC-BA04-800C5D84AADA.1; Fri, 19 May 2023 10:25:22 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0f4dc28aa903.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y/dp6otbzwFk5mBckBMbEiVi6AAxgtS2kwP9FvY3NUk58qxEAjJ/6ZdS61jlCPzFjRS3rqu9R78mdGMQ/w6N9T/vWPdgh48J8YAfKC5GR/5OeTYlQImCMIQEKFutcLfcN63v4WvuNUzSsWZNXXGcuvM7pUbyUZ7vP+BtSwv4/UkNja44ezQKEJmC6tKOw7SpNPq4VKwdlZMSMU5wLPL8Q4DxoaY1+Mwu+L2griqcwxDanubxRP30nMOiFP/B/UtHkiLiMCWP/1ZmFgfyDYN+UIFH0aLnHjqS7ty7QUgWqMHPxusl/wIM0nwlXtKrcYRfQrgv4UAcSKE2GKww769+PA== 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=Zk+vAdXItRAgvP6lq95RBYRMMmqNxNAaMsimuZiWGKc=; b=X8Rl/Wd1YF+Sup/ZDXNvzL6PbPQl1W70j7O8wiw9sBiOo0KzWCzJUXEL8HruXCcKUh5F3enhsIO/ty7lX69wv7WEbxZ0Kn23dqS7dqanxKoy3/uo0FvRzz6ERqsI1WD/DPRaNgRPbSoUBFb9fZSjHvljhm8a3DdBEtkyvGi1FvFmiE4O9l7jb0FLu52qXMBofLjMYw1G/J0eC8dOoUgHn7E2CRf5X4P+p5StTMHTv1BmBK9BZMHQ+ZDtd5iQwuXl6QHt69vHbSdjmQO7peR10wHCufo662iA/jYoJVpz/LCZL4Mk37lCGpvdk4jr2KYa8n0GhqDuF9CL0AAqU+aoxw== 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 DB6PR0202CA0006.eurprd02.prod.outlook.com (2603:10a6:4:29::16) by GV1PR08MB8154.eurprd08.prod.outlook.com (2603:10a6:150:92::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Fri, 19 May 2023 10:25:20 +0000 Received: from DBAEUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:29:cafe::47) by DB6PR0202CA0006.outlook.office365.com (2603:10a6:4:29::16) 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:20 +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 DBAEUR03FT057.mail.protection.outlook.com (100.127.142.182) 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:20 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) 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:13 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.23; Fri, 19 May 2023 10:25:13 +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:13 +0000 To: Subject: [PATCH v2 12/17] [binutils/aarch64] sme: Core file support Date: Fri, 19 May 2023 11:25:03 +0100 Message-ID: <20230519102508.14020-13-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: DBAEUR03FT057:EE_|GV1PR08MB8154:EE_|DBAEUR03FT016:EE_|GV2PR08MB8584:EE_ X-MS-Office365-Filtering-Correlation-Id: 67cfadbd-1f11-4f94-f8ac-08db58535f0d 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: AO/8U8RHdBGoj4U3xZsxj8X1jcM71kw+/1iaHGRX5seTlVlH3NefsN0fw6bNsQmIx3ImqxCZD8EiUk5GxkML+VIQpLqzzzrAr+dHNMOGrsglx9oY8GbzMhPtm3ljovlStEDUK2Fx7Jj54SP37lYT/PVGFmB1hYTxYLPfzM30cYoTo/smY9k6lfSB/6oJgCC2fjjZ19GFPEpbgn4TmJ0xUaX7MRgXY+BffH8U8nem9UDmZLauiE7ISYPTKsfFrUNY6SuN8wYyD0uhUGDVLBPxf+3qnUk1x8u5lWnl0ajg+PTMd5OlRmnoFyVHYgcoJFxrcawmtWlH03ky+pmi9jeZGh6iDG61XIxugNX9zpeAJAKUyLaSfPAg4sd24VZ/XdV1o0rKID9IIJFHQN63QaiAL0ChqCdojkMi1XyIOlii08G6SF9MA81OsKM4n1Za7e01lyuKltAk5Txvrn/p6GXLJluacaELo+YGbjMgTcDKsRcLhEFitNkw35X25/GlAeOpGbVibp2PH0+05ef6JoBD5Boe7KgwwB4kN12ankSGA9M2Bi9N7kBLecUUAw0P5ZtJcBMC7Gt/0JMw3CJKoWUvpg0T4oMa/Xf1nzRo1uZ3r0Tmv/ynwwKmXQ3wTUCeQr+BlsYP63j0vqzE2UKDI4WL2V1lC/U7VejiDyC1DMLbfiS2KfaSUdus4xvdRiQTujSiXqmg1ZGGB1kC7kPuHP37uazG+6UKNFL8wnv8D8eSVctflwiHkxB/Dv12YsFONYvkHAP3JjR8pX7hg7FdzH2EGQ== 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)(346002)(376002)(39860400002)(136003)(396003)(451199021)(46966006)(36840700001)(40470700004)(70206006)(70586007)(478600001)(316002)(7696005)(6666004)(36756003)(41300700001)(5660300002)(6916009)(40460700003)(1076003)(26005)(186003)(8676002)(8936002)(40480700001)(44832011)(2616005)(426003)(36860700001)(47076005)(336012)(2906002)(82740400003)(356005)(86362001)(81166007)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8154 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 117711a4-ad39-4cda-4021-08db58535953 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vyfxgg3IWTcMz6gAIi2xFdoEhvAdUdzlrCaC0U79eHxiFxlrX0fuWj0gWbN9j7ybhCk/6wb/CSkJwfVb1fOge5H85b4cqzcTbOs2RcXgUvc/Vc4vhZH8D6h5+9i7olhM00Ec9/+FbZfke1+r3lIF91dYreTW6ncPWPiOiZr0JaApi5IoU4bb5Aoxlmoj917StwGNl0yPQhpY9DqQA6nY9nbAG/kQtvtTmnvMSBPkFHI8oDM3D5L1RlUVzQEzWQzOrtWRsIEylwMmp37NkB1MHZ+YeJIvZCN25HdvZJ71Hw0pMlcMjTyBZiMmpht7T2O609DA1gxqEmJy0i0+QPkPhjgU4omXjjsosX3m967B02Eq7p1DaQFGsYtTa9f0XFWcaC4tblbdVnZxUa31UFFJd7vRG9C+m+rM0GL0n4EwkEATu8GSrqxGcnvfulq4abIPhRPuPstlTPWlqOK5oFGtVKwb2Ck++fX8CtCstM5kCcBQ3unKf+EjYEeJ9MLKrmOMYcOnjFhUhr7RVmK2NnjqCiQHGLwYMTsB/0FeVvjFpM+LrRrAvaWY6vMis8g4NOmRzJqHO5cQ7J/7D5leTbNdsmNoAEmz/caqDLPT7COoPpRg35E6IQlL3vkZkbwQC6YlWW2/JKBocDRYNlqoTMY5pcVPrXXq7ydQgxwSIKVvv+Lbt5ABWehoLKiS7g6ocm351ohkx6iWtzofZLAOrZCTS2n83Nw4aTxrfJ6Cfe53mZ1EUX1rVA8nB0TEKIExhzT+ 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)(136003)(39860400002)(346002)(376002)(396003)(451199021)(40470700004)(46966006)(36840700001)(478600001)(5660300002)(70206006)(70586007)(2906002)(8936002)(316002)(8676002)(7696005)(6916009)(41300700001)(44832011)(6666004)(26005)(40460700003)(1076003)(82740400003)(186003)(40480700001)(426003)(336012)(47076005)(36756003)(36860700001)(86362001)(82310400005)(2616005)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:30.3338 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67cfadbd-1f11-4f94-f8ac-08db58535f0d 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: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8584 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" From: Ezra Sitorus Add required code to support core file dumps with NT_ARM_ZA and NT_ARM_SSVE register sets in them. These new register sets are dumped when SME is supported. --- bfd/elf-bfd.h | 4 ++++ bfd/elf.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 2a64a1e6a03..d0187231d30 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2924,6 +2924,10 @@ extern char *elfcore_write_aarch_pauth (bfd *, char *, int *, const void *, int); extern char *elfcore_write_aarch_mte (bfd *, char *, int *, const void *, int); +extern char *elfcore_write_aarch_ssve + (bfd *, char *, int *, const void *, int); +extern char *elfcore_write_aarch_za + (bfd *, char *, int *, const void *, int); extern char *elfcore_write_arc_v2 (bfd *, char *, int *, const void *, int); extern char *elfcore_write_riscv_csr diff --git a/bfd/elf.c b/bfd/elf.c index 94954a8fbb9..e59b3f0f5ec 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -10051,6 +10051,18 @@ elfcore_grok_aarch_mte (bfd *abfd, Elf_Internal_Note *note) note); } +static bool +elfcore_grok_aarch_ssve (bfd *abfd, Elf_Internal_Note *note) +{ + return elfcore_make_note_pseudosection (abfd, ".reg-aarch-ssve", note); +} + +static bool +elfcore_grok_aarch_za (bfd *abfd, Elf_Internal_Note *note) +{ + return elfcore_make_note_pseudosection (abfd, ".reg-aarch-za", note); +} + static bool elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note) { @@ -10766,6 +10778,20 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note) else return true; + case NT_ARM_SSVE: + if (note->namesz == 6 + && strcmp (note->namedata, "LINUX") == 0) + return elfcore_grok_aarch_ssve (abfd, note); + else + return true; + + case NT_ARM_ZA: + if (note->namesz == 6 + && strcmp (note->namedata, "LINUX") == 0) + return elfcore_grok_aarch_za (abfd, note); + else + return true; + case NT_GDB_TDESC: if (note->namesz == 4 && strcmp (note->namedata, "GDB") == 0) @@ -12380,6 +12406,34 @@ elfcore_write_aarch_mte (bfd *abfd, size); } +char * +elfcore_write_aarch_ssve (bfd *abfd, + char *buf, + int *bufsiz, + const void *aarch_ssve, + int size) +{ + char *note_name = "LINUX"; + return elfcore_write_note (abfd, buf, bufsiz, + note_name, NT_ARM_SSVE, + aarch_ssve, + size); +} + +char * +elfcore_write_aarch_za (bfd *abfd, + char *buf, + int *bufsiz, + const void *aarch_za, + int size) +{ + char *note_name = "LINUX"; + return elfcore_write_note (abfd, buf, bufsiz, + note_name, NT_ARM_ZA, + aarch_za, + size); +} + char * elfcore_write_arc_v2 (bfd *abfd, char *buf, @@ -12561,6 +12615,10 @@ elfcore_write_register_note (bfd *abfd, return elfcore_write_aarch_pauth (abfd, buf, bufsiz, data, size); if (strcmp (section, ".reg-aarch-mte") == 0) return elfcore_write_aarch_mte (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-aarch-ssve") == 0) + return elfcore_write_aarch_ssve (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-aarch-za") == 0) + return elfcore_write_aarch_za (abfd, buf, bufsiz, data, size); if (strcmp (section, ".reg-arc-v2") == 0) return elfcore_write_arc_v2 (abfd, buf, bufsiz, data, size); if (strcmp (section, ".gdb-tdesc") == 0) From patchwork Fri May 19 10:25:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69663 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 BF4D13856973 for ; Fri, 19 May 2023 10:25:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF4D13856973 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684491958; bh=six1ycyc4SE9sTZ2EOkSRmQWo8Uq64X+oPo5GzoFfbM=; 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=Ce9o9Iv0OcNPL7Z/1RCzcp4iMDWh07K/dx45o6bc5x6axN0TN7ZSHDnQLDYlGo+7U P6N9CnZbULfHkRoPQyqryR54r9damp5iGOFCVqvGXIYMJGuiTRAbT2JL5RRBtEpIH7 xhn41IePeAm8APp0rZMPwQCIPmnrL1xo8E06Y0wI= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2050.outbound.protection.outlook.com [40.107.15.50]) by sourceware.org (Postfix) with ESMTPS id 8ED723858D39 for ; Fri, 19 May 2023 10:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8ED723858D39 Received: from AS8PR07CA0007.eurprd07.prod.outlook.com (2603:10a6:20b:451::6) by VI1PR08MB5439.eurprd08.prod.outlook.com (2603:10a6:803:13b::18) 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:23 +0000 Received: from AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:451:cafe::a9) by AS8PR07CA0007.outlook.office365.com (2603:10a6:20b:451::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Fri, 19 May 2023 10:25:23 +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 AM7EUR03FT061.mail.protection.outlook.com (100.127.140.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Fri, 19 May 2023 10:25:23 +0000 Received: ("Tessian outbound 5154e9d36775:v136"); Fri, 19 May 2023 10:25:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2a9b83cdbfd65479 X-CR-MTA-TID: 64aa7808 Received: from 38f8a476949c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AA3BE481-A7C3-4D80-B4AC-FCCCB4327850.1; Fri, 19 May 2023 10:25:16 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 38f8a476949c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UQG7c8xirhIxag4g+vJl71XUaoiIZRBXn8izUbfeoaOlst+jxhFssJmiVuJ8xU/2V/AWcL9VW96xpvFHJaNrRRwZAmTcoMP49u/iJoDJEdBi73psAAEeTYn51uwKMFJN6lcWQBq5Z6Xa2rhOl9stsGxAyQuZmGPy2Yvq6bjLasc1L+Xk+33+R9KmTKzJrddN42lQxKSrMAXqW2DStMUEW3jeE1ycE0yygzzOyr0Ed00/MuqKUf1hoC4jeVrWTgUOz6QRnkVBZf9kHUbxzK0/3lWOvzKlYVF/GJftgZaGhtm8yD+aSD+UwbSOHYaVoLfpeZMAHVB15rJiFy/ODy7C6Q== 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=six1ycyc4SE9sTZ2EOkSRmQWo8Uq64X+oPo5GzoFfbM=; b=KEsDlWEwT+H1wvHCTiwgaclEg3OAQcuBSh6SelJ3XFgY/K2YRW+28Kjsk4kB7DMwXswtFl+xoyUFNUuPxXz202ndGK0ykUglkjcqgpgD52FUg3wpzmH9mETO5CRobv5zjuE/GtTNX1EG3+NthKvbV4SrweYzPdhK3jxi3efkhcLuSuR8e4DrLcQ9/eEwBNTBlGdSMAoN5xxL85JZcFWtVdhmPGTJnWHoRy5rQCNEqZ8GArcLuyiM+TNiRYuKlq0HgoavSl5qtvVSQBTqWgvROYKmJap6iBAdAGVWYG7+WNMv3iRaw/xhqkMH8PqOIuvrpggcQ/bvQFHx4TpcJb4P0Q== 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 AS9PR05CA0203.eurprd05.prod.outlook.com (2603:10a6:20b:495::13) by GV1PR08MB8380.eurprd08.prod.outlook.com (2603:10a6:150:80::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:14 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:495:cafe::4c) by AS9PR05CA0203.outlook.office365.com (2603:10a6:20b:495::13) 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:14 +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:14 +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:13 +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:13 +0000 To: Subject: [PATCH v2 13/17] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Date: Fri, 19 May 2023 11:25:04 +0100 Message-ID: <20230519102508.14020-14-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_|GV1PR08MB8380:EE_|AM7EUR03FT061:EE_|VI1PR08MB5439:EE_ X-MS-Office365-Filtering-Correlation-Id: d52e006c-68a3-40e7-e348-08db58535af2 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: dZn2RrLOqPUA4QlWbnvOV1iODa24eOUYqrdKyMOGBK3gvFDmzaZcQ4LHpqNdfP6ktqQkM/UI9FTIGQUCjtHZn++53IOwbRpsT/00RuJkc14wJvJPaUNIBlps49oKwwuf3HjM+oUGPWoqXOAD1ERVQ+x3DxjxucBQD2bR1BSQYqly4lG0syTW0830z9ks7Un/FryDQux8qpTRGg+jHp+nTZvLMDZ7cloV0XbT/PNlOh+gQcXUaPG1hxeM9WTk0anM3s+TGW6fS9L+manBA364KW0cYd95rxuUlzSO092pCffjju4LN4BurbXOTtuRnlLLLD+6tblqDfWBn3jyqwZK719Xqw+VGduyxGMn1kkPoVw3ok5z05PvlLvXMmdoIj+Vi+tqLiBSUeF+ktMQOMVxa5HazlhwPRmYeFtwxmNXlRdyb9Oc9oA8nXQpkWJRy53iiqCsC22OlER/I4JgWdIqrV7JCOkvjADGMr0HTmHT7Z6MNnOFGSZ3NUgR/31Nxye1psGRW4RrDW477LiMFUwIsJktDXd3a7IxS7OnomgS/PISyOkUDXza14iD6vXUZ8PrfU1L7+YioNBnCFgfetNmvFelSuDoCPM1vOOtOUi/an2ss9D6Sp8iY/SDwXVVZBZfx4TSovMaTDLwqPc12K+vGnLawU8OqbfG9xJQjabvbffJ7pEL5vc016xgTbKXSrv6SC+4iMIQ8WynHeFrcJCd0IYUQgqhHSRGT2m7ErEe4V93a9WDLVAhlE4nzfanZbTh60XaE6r91EauqOiJSuyEPA558A4n6MxGw5C5sSsh2sY= 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)(396003)(376002)(346002)(451199021)(36840700001)(40470700004)(46966006)(70586007)(70206006)(6916009)(82740400003)(8936002)(8676002)(40480700001)(478600001)(316002)(6666004)(7696005)(41300700001)(40460700003)(2906002)(86362001)(81166007)(356005)(26005)(1076003)(44832011)(47076005)(82310400005)(83380400001)(36756003)(186003)(336012)(426003)(36860700001)(5660300002)(2616005)(41533002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8380 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 64214554-269c-4c5d-df2a-08db5853556b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l1W406PhxV2rd/8r4VnP5pIQEd5TZjmcJ6Q44gyjathddVWbc8pT1LsurCCjil9ZWC0NLKjwHr6WLNfTMgL3/UM+irCO+izr8BkazG17+lKCrQGeqftYG281HmaYXexnc5QdCASCvCNc7U6h+iIwS5W99MhcgsOVk28lLA+/7WDhgKVS+DiXtgF7bRYq1n3NFcrAmjs0wvczyAiadO0fFP4Ndw4bOpNR8W145CXOg82vH+rl3BdFDNkjr/6WdViLv4sCnMfS3IphD7TWkhRR2sdsSu6idd+HwGkC8lFpjTXTi2hoRxe5KgPCy+tfnjJ38dZpUAJ4EkCgN3twPRxOFqG4VlINed02bKkXfjVnYTPJK1D2zL2CHc1sjbk4ix+ROFeHfYapOE+2F+tjW+1xUKuMsPhceyP8V7UP0PTD7Q42jspPdrm/wpqRTRb+b722jSGl+mTQm4Vs2uqmQZhFSkP3nL5Z/VARY633D4GcIone4KgsiiLcbyyhmsWg9g/GBpIhGokpLqGR5k9cSApEFUsX7pSm4RAde90b7He4N0uzv0zf5LAlA+eIpbwRP+2otvANdvWyM+RCIukpNcuMVlqj5xR4A2dwIqsspFiRZ7Am+Lntasj0h8tBbXbTpUfbfyFycktb2NTq/yaBxpcje1Uh9WNlbgEDmYMjfnI6SnCAe/TAYFT83r8MR+4PuTUSQGasDsmt23TEkXAcx7okHtIBb15k9cxI0R+4IbwvamjhKj3vWmjDQ5ZuJIwTS/o79sHBrqP3HFg3BWWXSQ8OdQ== 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)(136003)(39850400004)(346002)(376002)(396003)(451199021)(40470700004)(46966006)(36840700001)(478600001)(5660300002)(70206006)(70586007)(2906002)(8936002)(316002)(8676002)(7696005)(6916009)(41300700001)(44832011)(6666004)(26005)(40460700003)(1076003)(82740400003)(186003)(40480700001)(426003)(336012)(47076005)(83380400001)(36756003)(36860700001)(86362001)(82310400005)(2616005)(81166007)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:23.3829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d52e006c-68a3-40e7-e348-08db58535af2 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: AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5439 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" When we have a core file generated by gdb (via the gcore command), gdb dumps the target description to a note. During loading of that core file, gdb will first try to load that saved target description. This works fine for almost all architectures. But AArch64 has a few dynamically-generated target descriptions/gdbarch depending on the vector length that was in use at the time the core file was generated. The target description gdb dumps to the core file note is the one generated at the time of attachment/startup. If, for example, the SVE vector length changed during execution, this would not reflect on the core file, as gdb would still dump the initial target description. Another issue is that the gdbarch potentially doesn't match the thread's real gdbarch, and so things like the register cache may have different formats and sizes. To address this, fetch the thread's architecture before dumping its register state. That way we will always use the correct target description/gdbarch. --- gdb/linux-tdep.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index b5eee5e108c..7d0976932c6 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -2099,12 +2099,28 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) stop_signal); if (signalled_thr != nullptr) - linux_corefile_thread (signalled_thr, &thread_args); + { + /* On some architectures, like AArch64, each thread can have a distinct + gdbarch (due to scalable extensions), and using the inferior gdbarch + is incorrect. + + Fetch each thread's gdbarch and pass it down to the lower layers so + we can dump the right set of registers. */ + thread_args.gdbarch = target_thread_architecture (signalled_thr->ptid); + linux_corefile_thread (signalled_thr, &thread_args); + } for (thread_info *thr : current_inferior ()->non_exited_threads ()) { if (thr == signalled_thr) continue; + /* On some architectures, like AArch64, each thread can have a distinct + gdbarch (due to scalable extensions), and using the inferior gdbarch + is incorrect. + + Fetch each thread's gdbarch and pass it down to the lower layers so + we can dump the right set of registers. */ + thread_args.gdbarch = target_thread_architecture (thr->ptid); linux_corefile_thread (thr, &thread_args); } From patchwork Fri May 19 10:25: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: 69674 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 17B8B3882031 for ; Fri, 19 May 2023 10:28:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17B8B3882031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492084; bh=LZ2+i3DZIAhYdVLdS8HHfzM9+Lb/trJYF/SR+V1w3lE=; 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=FikFgoZPbJK7K4tn1EXTb+dIcBRcUP/kjBJWsrVS9+FntgqgCWcTsB9qkgtXFWile Y3n+a9Unj70MAQsxGWKOVgOmODe9KPgqT13n9LqKyvNvfYPDrZc/wvRi1iDwAx0nLR 70YOrshL+Za1WPaJ/UVmuM/tIZnNB/W/at8jbCcw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2072.outbound.protection.outlook.com [40.107.20.72]) by sourceware.org (Postfix) with ESMTPS id 3CA123858C62 for ; Fri, 19 May 2023 10:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3CA123858C62 Received: from DB6P192CA0018.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::28) by AS8PR08MB6232.eurprd08.prod.outlook.com (2603:10a6:20b:296::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:27 +0000 Received: from DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b8:cafe::1e) by DB6P192CA0018.outlook.office365.com (2603:10a6:4:b8::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:27 +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 DBAEUR03FT065.mail.protection.outlook.com (100.127.142.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:27 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Fri, 19 May 2023 10:25:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 52972e6688d1994f X-CR-MTA-TID: 64aa7808 Received: from b174decbede1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1C5E4715-74E5-4146-B5A8-BBFBCAF60309.1; Fri, 19 May 2023 10:25:19 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b174decbede1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oYr1MhwtXkM+muUnPcCXR9u95VsiFBGA0MON27m0vn2FV3oGK5TCPhwEKn33OidXKztz7Ar9LLuW/+UZLunvqgV+fPScueM08/Gr0pUccCwatCQndAnXS8kBb+c4f+B6FfpgFsBBW6DfRqfQlTEiGsP7HrLlDZd+E8E+8GCC/SWRtvMjx24g8jVWJZmTxYeZTvk513I/OL/m0otdP5ZgjAm8xNUyBCnHOpbsuTCrJSbEe5hhAduzEA1iIRrOzxFGJhYqn1s3RIaSz08MYiM8Y0gjiUjhXTBr/n9D8pSVY7d1mJP93CRQj3f5vb/79WXsFweyfTN/ICaojAO2ii5rnA== 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=LZ2+i3DZIAhYdVLdS8HHfzM9+Lb/trJYF/SR+V1w3lE=; b=Gj1eROWD52R7TN69pRTcDfqwXO6QJuLRlEK7iVgOTJF47b/4YRx7bATPi4uUlPo321Drenz/F+nYXgy1BgmQ+X11gpUCdNEnrmS4HGNZGmF4nHA2k4nJD7yqy1YEOolb7Jz/ZPfM00xi5d36T+aW/mLxUhnNmGXqtjEYTTPyp+udxUwqX/meYfWt0aSCpCUmZoHY0XO4gU/9R3VXhaM6AjCADPFHqc6+EAAh/vceouzNOULT57jiJ8fO8W+JAe9TRXsWMFn/LObeI3OpnimwUdwLZrkq79e/nWH6xIsF+W4EZpA1GiB325FfOTFSBWyEYY3yCvacc4CLx6oNGC+JHQ== 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 AM9P192CA0009.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::14) by DB9PR08MB6538.eurprd08.prod.outlook.com (2603:10a6:10:23d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:16 +0000 Received: from AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:21d:cafe::5d) by AM9P192CA0009.outlook.office365.com (2603:10a6:20b:21d::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:16 +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 AM7EUR03FT056.mail.protection.outlook.com (100.127.140.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:16 +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:13 +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:13 +0000 To: Subject: [PATCH v2 14/17] [gdb/generic] corefile/bug: Fixup (gcore) core file target description reading order Date: Fri, 19 May 2023 11:25:05 +0100 Message-ID: <20230519102508.14020-15-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: AM7EUR03FT056:EE_|DB9PR08MB6538:EE_|DBAEUR03FT065:EE_|AS8PR08MB6232:EE_ X-MS-Office365-Filtering-Correlation-Id: 626dd51e-8ebb-4ff7-08bf-08db58535d27 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: JIU37ozDIbcVsjgVDVdg6dn2+1f+3yoBo62fV/uTE6Q6370P85LQ2TRmsH55MfHs6R8TpOXL0t+vG6nnqiTiQ5Z5Qx0MS1Ep86pMaFyOP92MHbP0YYpwSEm1f87ePAKU4+626x8AiQHftbDLa5FzvzAP5kkMCIWD8Mshuw80y3U+sYVwzkpgJeKkV7kXQafxMsikZkBpiGMV03SuA4BwwyVE1YWehv7h7KcdWu+kHUjuWWCgvomzTlgqK0VbAXtZyJyWNyvPWBYQDgVb0iA9jE0fI/MGGzHHPAYj3GSeztAzMhr8+s7l+IR3PMx4nGPMVgw1iw09VxMEOX50tYaXpWZFTFB8/czs1SNth65bj1oDxXqtw/napwTTCk93Tbes2OY9EuHVALoXE5Ckr59PvlWTP4994jwBTZBjhAQf83swhTIt0GV4MU/uXJt+MFkRr1SVS+nDbv4h3jO+ej7N8wkFs6NmUTVv7fbYxa+e3ZSa0OppnDDfdA97ldtBGI7/sQEo884MjUBvBSmQrp1nc7ocLmPSRJZecPF2AAmMkSt/ysHemALzLL5YKW6peBClvXNsuLo2B/1/T+gau3LP/G+VrJXnegL2NEgwtNpwDLOiX1AHUKE7o1Fkf3NoO7GE2EEj6ZYAGkTIFgKdax/+JvaaxfLL4B3Ia0NCxH/rcsmGstT61chSbcmOUqxXU94Brsxacrvm5tz68QTANIUqttOTGT15rEAgcuKZBcI/SzyqiJOFsfmfeMff0ELvzl4gyFKdUw2NY0lPp7vZFU2UhgYf2ILIJ1GFc0jhauBeV/0= 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)(346002)(136003)(376002)(39860400002)(396003)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(70586007)(70206006)(478600001)(6916009)(316002)(36756003)(86362001)(83380400001)(47076005)(26005)(2616005)(186003)(336012)(426003)(36860700001)(1076003)(5660300002)(41300700001)(8936002)(8676002)(44832011)(2906002)(7696005)(40480700001)(6666004)(82310400005)(81166007)(356005)(82740400003)(41533002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6538 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 918abbc2-12bc-4fa3-0ad3-08db585356bf X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9ARNxiAMw7yr7Tnm29p1x+27tQdsFpmMTEqGLHlm1oLvhCNlw4c2aZWhTV41HAlcj0FM43e4jE+CYQ7K2ciMxlWxcjJ25K5L551Dvvaq4MhxKZ4bok71HUchWkZ2VuHL/4AfYmYqZlQjPUE1I9qhahqX6GEMPYtOUpUlQTjjLMsGsx7AN+89GSdMhYis3ZrJLmktUA5oeUGtj/d7OOphK3qFMyfupnPh+19hvV2mEZYPCmDQ8eWcK9SjhP6xqQ2FZ+Wk9JptFC0L605K5XYC47ze8L/xTkTXEuG89XSi/Z4XuBxcfh/SaJIs2shSKI+gXuC5pKcOV3RRswrVv3VJZw/z37SLOOfX3LXSZsyaQhy0mjLq8kgGRlVhcKuIrsxMNme5hIz1v8oQ8bAUHkq+LiTEMCw5RoMXsvlB4BhwvTsyrNyHtQw/lpBQlvMeBc9EGRkfk3XEvW2lsO/qoqMA0YAtYWm0pqE7ZaJwToLItFqJvgWZdqsLhZcUncPVsnLQj0Yj12+BS/HmKVLf1sZo/Ys0OlD/Lko5O/D804985evQH2GwrIkJWTIlmXTEphF6/lyfqDqMQOUELx56WBpl1v0PjQSD6JDY4g65yM30Nv2JxMwCr8srBwbZ6VSRr5KmkmXKvAKNoPJgTbvk5pAymCiOgj9I0Z+lyC/5j3kcxZ4ZlNTnN9C6rl7HDLq+1FQKCem87i9aSiNhByjrb9t6JlOE8u+7PgYKBCAI6u2O122+b5Cvr3qkKhMtwAKXDbvy1DqFeJGLdWwsfzQZyIzQIA== 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)(136003)(39860400002)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(336012)(86362001)(36756003)(40480700001)(82310400005)(8936002)(26005)(8676002)(1076003)(2616005)(44832011)(426003)(5660300002)(186003)(316002)(70206006)(6916009)(70586007)(41300700001)(7696005)(478600001)(6666004)(81166007)(82740400003)(47076005)(83380400001)(36860700001)(2906002)(40460700003)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:27.1269 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 626dd51e-8ebb-4ff7-08bf-08db58535d27 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: DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6232 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" Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread can potentially have distinct target descriptions/gdbarches. When loading a gcore-generated core file, at the moment GDB gives priority to the target description dumped to NT_GDB_TDESC. Though technically correct for most target, it doesn't work correctly for AArch64 with SVE or SME support. The correct approach for AArch64/Linux is to rely on the gdbarch_core_read_description hook, so it can figure out the proper target description for a given thread based on the various available register notes. I think this should work for other architectures as well. If not, we may need to adjust things so all architectures get the information that they need for discovering the target description of the core file. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/corelow.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/gdb/corelow.c b/gdb/corelow.c index db489b4280e..e3ad9772869 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1078,6 +1078,21 @@ core_target::thread_alive (ptid_t ptid) const struct target_desc * core_target::read_description () { + /* If the architecture provides a corefile target description hook, use + it now. Even if the core file contains a target description in a note + section, it is not useful for targets that can potentially have distinct + descriptions for each thread. One example is AArch64's SVE/SME + extensions that allow per-thread vector length changes, resulting in + registers with different sizes. */ + if (m_core_gdbarch && gdbarch_core_read_description_p (m_core_gdbarch)) + { + const struct target_desc *result; + + result = gdbarch_core_read_description (m_core_gdbarch, this, core_bfd); + if (result != nullptr) + return result; + } + /* If the core file contains a target description note then we will use that in preference to anything else. */ bfd_size_type tdesc_note_size = 0; @@ -1101,15 +1116,6 @@ core_target::read_description () } } - if (m_core_gdbarch && gdbarch_core_read_description_p (m_core_gdbarch)) - { - const struct target_desc *result; - - result = gdbarch_core_read_description (m_core_gdbarch, this, core_bfd); - if (result != NULL) - return result; - } - return this->beneath ()->read_description (); } From patchwork Fri May 19 10:25:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69669 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 4752A388206B for ; Fri, 19 May 2023 10:27:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4752A388206B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492025; bh=/bV5YknSyCpwG1qVGGm5Xe+n772XkimNn+sW8aZNYdg=; 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=KKj94mP55QGaDipc0y/MN87ySIh72LEftNgc2yLgQwJzdICk7YFrkWstGB5eUxkCi aDDlUPDMszxKmqeyTD/SS72H+1v1o8am4ux5n1BoJ1PHIGcdGJFIC2fsH9DrI+Vlq0 7JhsKKgI7l5N85cH5plYvOrhKwSDCsySM/TlQjLI= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by sourceware.org (Postfix) with ESMTPS id 9D61F3858423 for ; Fri, 19 May 2023 10:25:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D61F3858423 Received: from DUZPR01CA0073.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c2::11) by DB9PR08MB8627.eurprd08.prod.outlook.com (2603:10a6:10:3d1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:27 +0000 Received: from DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c2:cafe::9b) by DUZPR01CA0073.outlook.office365.com (2603:10a6:10:3c2::11) 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:27 +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 DBAEUR03FT016.mail.protection.outlook.com (100.127.142.204) 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:27 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Fri, 19 May 2023 10:25:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ce6c1bbca8c6ebb1 X-CR-MTA-TID: 64aa7808 Received: from f8ffa60670e2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F135E39E-40AF-4506-AB25-4DBD6F2DBBD4.1; Fri, 19 May 2023 10:25:19 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f8ffa60670e2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GEomcsPk0+Zp9lk/5wkqFJm/ZCS9FiIVz6bN7j8gCG2O/nnbFZ57QCyXCd8H8sSKLssp6SMlRNxN4BwvXO5sjLS0t5R4sLzCEeLH/dNN0+w4wsCAWVZsUstTUlkS39jViyVl+GkuHobA+BpTRAdJ5KTA/VNjHP1dnTcVG02cQqndK7FQiTD9BsWWJ9foOFm1chxPtR0RJg907g8LO+xJBAu3zP9IYnyaBK9y5RcTRcOPCDpWOmiLuJv5Afn1QPJNXCbuTcna+gNbMsJpc6OtblnlSYu805gz0VcTU4KmX9KOua2t+EdpIj6x975yGppdSgkUSQ3ooP5FkvqBLmfbrQ== 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=/bV5YknSyCpwG1qVGGm5Xe+n772XkimNn+sW8aZNYdg=; b=fRFuswh+g7dIZWfU/9DxzKSfjVUl+3OrtiH9wStXdVkbcpvTC0hdrzsnFLOHcV+LfMFp1rONEX7/X3GsLKON6MyzEf27gL/sBAMAs4UU4aAVgSR5NxPFqswMtqACCOWlF15mxzl2HJcipvb/QROtXYMACL1K1kuVPxyNDS3GiFZdf/mXc4qTzDc4exdQRy91k8R/NmrlScAYJ9TQ4rrOqKBjrPyk8ENLrDory3exmTZm7hdNvowWCgkUOMwp48PgfMN9Cum5ByN89JlNcVnNmAbWgHR6xUwhKWKXIqXp/4kvOTCbbCpNidKo0p0AjPzOOYbhWG41MlBapdgyu0PO/w== 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 AM9P192CA0004.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::9) by DU0PR08MB9464.eurprd08.prod.outlook.com (2603:10a6:10:42c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:16 +0000 Received: from AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:21d:cafe::92) by AM9P192CA0004.outlook.office365.com (2603:10a6:20b:21d::9) 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:16 +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 AM7EUR03FT056.mail.protection.outlook.com (100.127.140.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:16 +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:13 +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:13 +0000 To: Subject: [PATCH v2 15/17] [gdb/aarch64] sme: Core file support for Linux Date: Fri, 19 May 2023 11:25:06 +0100 Message-ID: <20230519102508.14020-16-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: AM7EUR03FT056:EE_|DU0PR08MB9464:EE_|DBAEUR03FT016:EE_|DB9PR08MB8627:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d82cb10-73bd-4424-ef25-08db58535d35 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: tm3QdnPT0pkUIN/L7iCeasIBQOgsVrFSm5R8oANlfwnLqs+JIGI4hYttF5HDZdMWGPJVWOae2V8yB9KOU6LwEElUv/SFJ1sAPATpDs519pRDnoTHLpGBsnnawYZI9n9q5j9f3cnq/RrcCiV2dN2PLz1WX9DXIrwql0lP7qSAtn9A1g88iXBNQ0TttKyOS2LqGwFGhxvZ0YAOPMk4cF76pyn+cwjoJsb/y4Bu13OVCYrUg0kJrf78pH1gJ9ZTJv6H2S+NAHmitsMP5HGFphPVjRq9qddt8BS5UkeOljLUuAsDC8P5k3sVXM70SX3wXYCty4/mPJyzOnw9LwfPdxDTclJUFc/AWyPRAdhM5UrbncjPBNll3dKu4Q+5IMR0ou4EHPKP8e/v9PqcISTy3Hc7+zf4Gkz4WlUWGHH2lC26InBp+dGJgermYAXRjP1e2z9hs2Jb4p2LnH/to1WN48/C3zM6au61f1WmDnwrGGOzybO3KS4pHIulmZoimA7SiqyS+ad1APXamUimGQjILDVlR5jTNZT752lNIQHTQHaWmfIK31bMklEQ1Ke1vyustVIf989he8Nru6fJoOdQcAuhD2s1AXsb4pvaKSP4mj/aydY9oVHoq4V+nbEyjWKmPzZnN+cCv3osEkFAAt28fkhcdzdGVg6BLnWJ+u7wx24p/3ZN1Cri13rclsi7n+wR7c+55P6NICFY1hVmCEpUnjq25KDCzNknv+6vR+jEghJT6WvdgrmxftBX36pe0ppzxuDb 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)(346002)(376002)(396003)(136003)(451199021)(40470700004)(36840700001)(46966006)(86362001)(36756003)(316002)(70206006)(6916009)(70586007)(478600001)(40480700001)(6666004)(82310400005)(8936002)(8676002)(5660300002)(41300700001)(30864003)(2906002)(44832011)(81166007)(82740400003)(356005)(7696005)(186003)(336012)(426003)(2616005)(26005)(1076003)(36860700001)(47076005)(83380400001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9464 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 78e087ba-b775-44f1-91ff-08db585356e7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MHitpmbl1K58H7jmygY29XU59D/T739puN/mQJO4qFPRYJedYgoGRPI2G4ZduCbFRLiKYrxq8ATdYyHQEkEBWUhdFoEfsI0eFiibNFk03zMyDuqiz0KZuSGa8oQ+orGE2xORBhz3LT4iGNZjpQDYm70E57Nd7kcp/Yq8xEkujybdMTq9IAroQgglfoFQPrtHin1Un5kX9tvX1tICsOS8KWjtIlUMTrCT7WXodO2oJMuePxe7MEyLO9Sk0jTLR7coO0fTW9BkLTvam7/bBBLw5pOCLxNw/Oa8RXtUcBSLMdSauj3BnGTXsuQjKLYGRw3fUx9AFmaG0F6P/61RS2HxkC7pDNigrHTWqdGBBcNGKJEktjEdAtletdOt6dE7sze61t7vxdnNzel7EtPbjODZnNvCiXuI+HrgUgix94ufU183BcgV1CQUBF0/sehKp1V//L4G9aWPAG3kA78zQqH/1df9Do4HS6CVDorV8Vky+kAJYNNWUfnk7CEvyC5KzAUEBe6gVATpbCgaF2BqwjGWuS85DHMZbbfYIVV0m2uccySGXa6PDTzoaYvRz2v9v4tZXkGiF8kD/65XmQDukMLzYVmct9FgKMsKzdfHavPv7263QlULsB9qmLn6S1mZf1l8DzWi+8WOmTcmimaMUTCjqtUB1uLvzEWPGLDAefvbF8IE70XVEQ6ZKxRelUYeKUNu8v9ezjI/Pj67aSTfrwF7cktgS3jdjpyZyt3MeaEa3Lk= 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)(136003)(396003)(39860400002)(376002)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(47076005)(426003)(6666004)(478600001)(7696005)(2616005)(1076003)(26005)(186003)(30864003)(2906002)(336012)(83380400001)(44832011)(5660300002)(8936002)(8676002)(81166007)(36756003)(40460700003)(82740400003)(6916009)(316002)(70586007)(70206006)(86362001)(40480700001)(41300700001)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:27.2246 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d82cb10-73bd-4424-ef25-08db58535d35 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: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB8627 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, KAM_SHORT, 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" This patch enables dumping SME state via gdb's gcore command and also enables gdb to read SME state from a core file generated by the Linux Kernel. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-tdep.c | 532 ++++++++++++++++++++++++++++-- gdb/arch/aarch64-scalable-linux.c | 34 ++ gdb/arch/aarch64-scalable-linux.h | 15 + 3 files changed, 548 insertions(+), 33 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 7ce34ee6846..0bd75daa994 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -57,6 +57,10 @@ #include "elf/common.h" #include "elf/aarch64.h" +#include "arch/aarch64-insn.h" + +/* For std::sqrt */ +#include /* Signal frame handling. @@ -743,50 +747,55 @@ const struct regset aarch64_linux_fpregset = #define SVE_HEADER_FLAG_SVE 1 -/* Get VQ value from SVE section in the core dump. */ +/* Get the vector quotient (VQ) or streaming vector quotient (SVQ) value + from the section named SECTION_NAME. + + Return non-zero if successful and 0 otherwise. */ static uint64_t -aarch64_linux_core_read_vq (struct gdbarch *gdbarch, bfd *abfd) +aarch64_linux_core_read_vq (struct gdbarch *gdbarch, bfd *abfd, + const char *section_name) { - gdb_byte header[SVE_HEADER_SIZE]; - enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - asection *sve_section = bfd_get_section_by_name (abfd, ".reg-aarch-sve"); + gdb_assert (section_name != nullptr); - if (sve_section == nullptr) + asection *section = bfd_get_section_by_name (abfd, section_name); + + if (section == nullptr) { /* No SVE state. */ return 0; } - size_t size = bfd_section_size (sve_section); + size_t size = bfd_section_size (section); /* Check extended state size. */ if (size < SVE_HEADER_SIZE) { - warning (_("'.reg-aarch-sve' section in core file too small.")); + warning (_("'%s' core file section is too small. " + "Expected %s bytes, got %s bytes"), section_name, + pulongest (SVE_HEADER_SIZE), pulongest (size)); return 0; } - if (!bfd_get_section_contents (abfd, sve_section, header, 0, SVE_HEADER_SIZE)) + gdb_byte header[SVE_HEADER_SIZE]; + + if (!bfd_get_section_contents (abfd, section, header, 0, SVE_HEADER_SIZE)) { warning (_("Couldn't read sve header from " - "'.reg-aarch-sve' section in core file.")); + "'%s' core file section."), section_name); return 0; } - uint64_t vl = extract_unsigned_integer (header + SVE_HEADER_VL_OFFSET, - SVE_HEADER_VL_LENGTH, byte_order); - uint64_t vq = sve_vq_from_vl (vl); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + uint64_t vq + = sve_vq_from_vl (extract_unsigned_integer (header + SVE_HEADER_VL_OFFSET, + SVE_HEADER_VL_LENGTH, + byte_order)); - if (vq > AARCH64_MAX_SVE_VQ) - { - warning (_("SVE Vector length in core file not supported by this version" - " of GDB. (VQ=%s)"), pulongest (vq)); - return 0; - } - else if (vq == 0) + if (vq > AARCH64_MAX_SVE_VQ || vq == 0) { - warning (_("SVE Vector length in core file is invalid. (VQ=%s"), + warning (_("SVE/SSVE vector length in core file is invalid." + " (max vq=%d) (detected vq=%s)"), AARCH64_MAX_SVE_VQ, pulongest (vq)); return 0; } @@ -794,14 +803,53 @@ aarch64_linux_core_read_vq (struct gdbarch *gdbarch, bfd *abfd) return vq; } +/* Get the vector quotient (VQ) value from CORE_BFD's sections. + + Return non-zero if successful and 0 otherwise. */ + +static uint64_t +aarch64_linux_core_read_vq_from_sections (struct gdbarch *gdbarch, + bfd *core_bfd) +{ + /* First check if we have a SSVE section. If so, check if it is active. */ + asection *section = bfd_get_section_by_name (core_bfd, ".reg-aarch-ssve"); + + if (section != nullptr) + { + /* We've found a SSVE section, so now fetch its data. */ + gdb_byte header[SVE_HEADER_SIZE]; + + if (bfd_get_section_contents (core_bfd, section, header, 0, + SVE_HEADER_SIZE)) + { + /* Check if the SSVE section has SVE contents. */ + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + uint16_t flags + = extract_unsigned_integer (header + SVE_HEADER_FLAGS_OFFSET, + SVE_HEADER_FLAGS_LENGTH, byte_order); + + if (flags & SVE_HEADER_FLAG_SVE) + { + /* The SSVE state is active, so return the vector length from the + the SSVE section. */ + return aarch64_linux_core_read_vq (gdbarch, core_bfd, + ".reg-aarch-ssve"); + } + } + } + + /* No valid SSVE section. Return the vq from the SVE section (if any). */ + return aarch64_linux_core_read_vq (gdbarch, core_bfd, ".reg-aarch-sve"); +} + /* Supply register REGNUM from BUF to REGCACHE, using the register map in REGSET. If REGNUM is -1, do this for all registers in REGSET. - If BUF is NULL, set the registers to "unavailable" status. */ + If BUF is nullptr, set the registers to "unavailable" status. */ static void -aarch64_linux_supply_sve_regset (const struct regset *regset, - struct regcache *regcache, - int regnum, const void *buf, size_t size) +supply_sve_regset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *buf, size_t size) { gdb_byte *header = (gdb_byte *) buf; struct gdbarch *gdbarch = regcache->arch (); @@ -853,14 +901,89 @@ aarch64_linux_supply_sve_regset (const struct regset *regset, } } +/* Collect an inactive SVE register set state. This is equivalent to a + fpsimd layout. + + Collect the data from REGCACHE to BUF, using the register + map in REGSET. */ + +static void +collect_inactive_sve_regset (const struct regcache *regcache, + void *buf, size_t size, int vg_regnum) +{ + gdb_byte *header = (gdb_byte *) buf; + struct gdbarch *gdbarch = regcache->arch (); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + + gdb_assert (buf != nullptr); + gdb_assert (size > SVE_HEADER_SIZE); + + /* Zero out everything first. */ + memset ((gdb_byte *) buf, 0, SVE_CORE_DUMMY_SIZE); + + /* BUF starts with a SVE header prior to the register dump. */ + + /* Dump the default size of an empty SVE payload. */ + uint32_t real_size = SVE_CORE_DUMMY_SIZE; + store_unsigned_integer (header + SVE_HEADER_SIZE_OFFSET, + SVE_HEADER_SIZE_LENGTH, byte_order, real_size); + + /* Dump a dummy max size. */ + uint32_t max_size = SVE_CORE_DUMMY_MAX_SIZE; + store_unsigned_integer (header + SVE_HEADER_MAX_SIZE_OFFSET, + SVE_HEADER_MAX_SIZE_LENGTH, byte_order, max_size); + + /* Dump the vector length. */ + ULONGEST vg = 0; + regcache->raw_collect (vg_regnum, &vg); + uint16_t vl = sve_vl_from_vg (vg); + store_unsigned_integer (header + SVE_HEADER_VL_OFFSET, SVE_HEADER_VL_LENGTH, + byte_order, vl); + + /* Dump the standard maximum vector length. */ + uint16_t max_vl = SVE_CORE_DUMMY_MAX_VL; + store_unsigned_integer (header + SVE_HEADER_MAX_VL_OFFSET, + SVE_HEADER_MAX_VL_LENGTH, byte_order, + max_vl); + + /* The rest of the fields is zero. */ + uint16_t flags = SVE_CORE_DUMMY_FLAGS; + store_unsigned_integer (header + SVE_HEADER_FLAGS_OFFSET, + SVE_HEADER_FLAGS_LENGTH, byte_order, + flags); + uint16_t reserved = SVE_CORE_DUMMY_RESERVED; + store_unsigned_integer (header + SVE_HEADER_RESERVED_OFFSET, + SVE_HEADER_RESERVED_LENGTH, byte_order, reserved); + + /* We are done with the header part of it. Now dump the register state + in the FPSIMD format. */ + + /* Dump the first 128 bits of each of the Z registers. */ + header += AARCH64_SVE_CONTEXT_REGS_OFFSET; + for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++) + regcache->raw_collect_part (AARCH64_SVE_Z0_REGNUM + i, 0, V_REGISTER_SIZE, + header + V_REGISTER_SIZE * i); + + /* Dump FPSR and FPCR. */ + header += 32 * V_REGISTER_SIZE; + regcache->raw_collect (AARCH64_FPSR_REGNUM, header); + regcache->raw_collect (AARCH64_FPCR_REGNUM, header); + + /* Dump two reserved empty fields of 4 bytes. */ + header += 8; + memset (header, 0, 8); + + /* We should have a FPSIMD-formatted register dump now. */ +} + /* Collect register REGNUM from REGCACHE to BUF, using the register map in REGSET. If REGNUM is -1, do this for all registers in REGSET. */ static void -aarch64_linux_collect_sve_regset (const struct regset *regset, - const struct regcache *regcache, - int regnum, void *buf, size_t size) +collect_sve_regset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *buf, size_t size) { gdb_byte *header = (gdb_byte *) buf; struct gdbarch *gdbarch = regcache->arch (); @@ -875,24 +998,308 @@ aarch64_linux_collect_sve_regset (const struct regset *regset, store_unsigned_integer (header + SVE_HEADER_SIZE_OFFSET, SVE_HEADER_SIZE_LENGTH, byte_order, size); + uint32_t max_size = SVE_CORE_DUMMY_MAX_SIZE; store_unsigned_integer (header + SVE_HEADER_MAX_SIZE_OFFSET, - SVE_HEADER_MAX_SIZE_LENGTH, byte_order, size); + SVE_HEADER_MAX_SIZE_LENGTH, byte_order, max_size); store_unsigned_integer (header + SVE_HEADER_VL_OFFSET, SVE_HEADER_VL_LENGTH, byte_order, sve_vl_from_vq (vq)); + uint16_t max_vl = SVE_CORE_DUMMY_MAX_VL; store_unsigned_integer (header + SVE_HEADER_MAX_VL_OFFSET, SVE_HEADER_MAX_VL_LENGTH, byte_order, - sve_vl_from_vq (vq)); + max_vl); + uint16_t flags = SVE_HEADER_FLAG_SVE; store_unsigned_integer (header + SVE_HEADER_FLAGS_OFFSET, SVE_HEADER_FLAGS_LENGTH, byte_order, - SVE_HEADER_FLAG_SVE); + flags); + uint16_t reserved = SVE_CORE_DUMMY_RESERVED; store_unsigned_integer (header + SVE_HEADER_RESERVED_OFFSET, - SVE_HEADER_RESERVED_LENGTH, byte_order, 0); + SVE_HEADER_RESERVED_LENGTH, byte_order, reserved); /* The SVE register dump follows. */ regcache->collect_regset (regset, regnum, (gdb_byte *) buf + SVE_HEADER_SIZE, size - SVE_HEADER_SIZE); } +/* Supply register REGNUM from BUF to REGCACHE, using the register map + in REGSET. If REGNUM is -1, do this for all registers in REGSET. + If BUF is NULL, set the registers to "unavailable" status. */ + +static void +aarch64_linux_supply_sve_regset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *buf, size_t size) +{ + struct gdbarch *gdbarch = regcache->arch (); + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (tdep->has_sme ()) + { + ULONGEST svcr = 0; + regcache->raw_collect (tdep->sme_svcr_regnum, &svcr); + + /* Is streaming mode enabled? */ + if (svcr & SVCR_SM_BIT) + /* If so, don't load SVE data from the SVE section. The data to be + used is in the SSVE section. */ + return; + } + /* If streaming mode is not enabled, load the SVE regcache data from the SVE + section. */ + supply_sve_regset (regset, regcache, regnum, buf, size); +} + +/* Collect register REGNUM from REGCACHE to BUF, using the register + map in REGSET. If REGNUM is -1, do this for all registers in + REGSET. */ + +static void +aarch64_linux_collect_sve_regset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *buf, size_t size) +{ + struct gdbarch *gdbarch = regcache->arch (); + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + bool streaming_mode = false; + + if (tdep->has_sme ()) + { + ULONGEST svcr = 0; + regcache->raw_collect (tdep->sme_svcr_regnum, &svcr); + + /* Is streaming mode enabled? */ + if (svcr & SVCR_SM_BIT) + { + /* If so, don't dump SVE regcache data to the SVE section. The SVE + data should be dumped to the SSVE section. Dump an empty SVE + block instead. */ + streaming_mode = true; + } + } + + /* If streaming mode is not enabled or there is no SME support, dump the + SVE regcache data to the SVE section. */ + + /* Check if we have an active SVE state (non-zero Z/P/FFR registers). + If so, then we need to dump registers in the SVE format. + + Otherwise we should dump the registers in the FPSIMD format. */ + if (sve_state_is_empty (regcache) || streaming_mode) + collect_inactive_sve_regset (regcache, buf, size, AARCH64_SVE_VG_REGNUM); + else + collect_sve_regset (regset, regcache, regnum, buf, size); +} + +/* Supply register REGNUM from BUF to REGCACHE, using the register map + in REGSET. If REGNUM is -1, do this for all registers in REGSET. + If BUF is NULL, set the registers to "unavailable" status. */ + +static void +aarch64_linux_supply_ssve_regset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *buf, size_t size) +{ + gdb_byte *header = (gdb_byte *) buf; + struct gdbarch *gdbarch = regcache->arch (); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + uint16_t flags = extract_unsigned_integer (header + SVE_HEADER_FLAGS_OFFSET, + SVE_HEADER_FLAGS_LENGTH, + byte_order); + + /* Since SVCR's bits are inferred from the data we have in the header of the + SSVE section, we need to initialize it to zero first, so that it doesn't + carry garbage data. */ + ULONGEST svcr = 0; + regcache->raw_supply (tdep->sme_svcr_regnum, &svcr); + + /* Is streaming mode enabled? */ + if (flags & SVE_HEADER_FLAG_SVE) + { + /* Streaming mode is active, so flip the SM bit. */ + svcr = SVCR_SM_BIT; + regcache->raw_supply (tdep->sme_svcr_regnum, &svcr); + + /* Fetch the SVE data from the SSVE section. */ + supply_sve_regset (regset, regcache, regnum, buf, size); + } +} + +/* Collect register REGNUM from REGCACHE to BUF, using the register + map in REGSET. If REGNUM is -1, do this for all registers in + REGSET. */ + +static void +aarch64_linux_collect_ssve_regset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *buf, size_t size) +{ + struct gdbarch *gdbarch = regcache->arch (); + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ULONGEST svcr = 0; + regcache->raw_collect (tdep->sme_svcr_regnum, &svcr); + + /* Is streaming mode enabled? */ + if (svcr & SVCR_SM_BIT) + { + /* If so, dump SVE regcache data to the SSVE section. */ + collect_sve_regset (regset, regcache, regnum, buf, size); + } + else + { + /* Otherwise dump an empty SVE block to the SSVE section with the + streaming vector length. */ + collect_inactive_sve_regset (regcache, buf, size, tdep->sme_svg_regnum); + } +} + +/* Supply register REGNUM from BUF to REGCACHE, using the register map + in REGSET. If REGNUM is -1, do this for all registers in REGSET. + If BUF is NULL, set the registers to "unavailable" status. */ + +static void +aarch64_linux_supply_za_regset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *buf, size_t size) +{ + gdb_byte *header = (gdb_byte *) buf; + struct gdbarch *gdbarch = regcache->arch (); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + + /* Handle an empty buffer. */ + if (buf == nullptr) + return regcache->supply_regset (regset, regnum, nullptr, size); + + if (size < SVE_HEADER_SIZE) + warning (_("ZA state header size (%s) invalid. Should be at least %s."), + pulongest (size), pulongest (SVE_HEADER_SIZE)); + + /* The ZA register note in a core file can have a couple of states: + + 1 - Just the header without the payload. This means that there is no + ZA data, and we should populate only SVCR and SVG registers on GDB's + side. The ZA data should be marked as unavailable. + + 2 - The header with an additional data payload. This means there is + actual ZA data, and we should populate ZA, SVCR and SVG. */ + + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + /* Populate SVG. */ + ULONGEST svg + = sve_vg_from_vl (extract_unsigned_integer (header + SVE_HEADER_VL_OFFSET, + SVE_HEADER_VL_LENGTH, + byte_order)); + regcache->raw_supply (tdep->sme_svg_regnum, &svg); + + size_t data_size + = extract_unsigned_integer (header + SVE_HEADER_SIZE_OFFSET, + SVE_HEADER_SIZE_LENGTH, byte_order) + - SVE_HEADER_SIZE; + + /* Populate SVCR. */ + bool has_za_payload = (data_size > 0); + ULONGEST svcr; + regcache->raw_collect (tdep->sme_svcr_regnum, &svcr); + + /* If we have a ZA payload, enable bit 2 of SVCR, otherwise clear it. This + register gets updated by the SVE/SSVE-handling functions as well, as they + report the SM bit 1. */ + if (has_za_payload) + svcr |= SVCR_ZA_BIT; + else + svcr &= ~SVCR_ZA_BIT; + + /* Update SVCR in the register buffer. */ + regcache->raw_supply (tdep->sme_svcr_regnum, &svcr); + + /* Populate the register cache with ZA register contents, if we have any. */ + buf = has_za_payload ? (gdb_byte *) buf + SVE_HEADER_SIZE : nullptr; + + /* Update ZA in the register buffer. */ + if (has_za_payload) + regcache->raw_supply (tdep->sme_za_regnum, buf); + else + { + size_t za_bytes = std::pow (sve_vl_from_vg (svg), 2); + gdb_byte za_zeroed[za_bytes]; + memset (za_zeroed, 0, za_bytes); + regcache->raw_supply (tdep->sme_za_regnum, za_zeroed); + } +} + +/* Collect register REGNUM from REGCACHE to BUF, using the register + map in REGSET. If REGNUM is -1, do this for all registers in + REGSET. */ + +static void +aarch64_linux_collect_za_regset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *buf, size_t size) +{ + gdb_assert (buf != nullptr); + + if (size < SVE_HEADER_SIZE) + warning (_("ZA state header size (%s) invalid. Should be at least %s."), + pulongest (size), pulongest (SVE_HEADER_SIZE)); + + /* The ZA register note in a core file can have a couple of states: + + 1 - Just the header without the payload. This means that there is no + ZA data, and we should dump just the header. + + 2 - The header with an additional data payload. This means there is + actual ZA data, and we should dump both the header and the ZA data + payload. */ + + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Determine if we have ZA state from the SVCR register ZA bit. */ + ULONGEST svcr; + regcache->raw_collect (tdep->sme_svcr_regnum, &svcr); + + /* Check the ZA payload. */ + bool has_za_payload = (svcr & SVCR_ZA_BIT) != 0; + size = has_za_payload ? size : SVE_HEADER_SIZE; + + /* Write the size and max_size fields. */ + gdb_byte *header = (gdb_byte *) buf; + enum bfd_endian byte_order = gdbarch_byte_order (regcache->arch ()); + store_unsigned_integer (header + SVE_HEADER_SIZE_OFFSET, + SVE_HEADER_SIZE_LENGTH, byte_order, size); + + uint32_t max_size + = SVE_HEADER_SIZE + std::pow (sve_vl_from_vq (tdep->sme_svq), 2); + store_unsigned_integer (header + SVE_HEADER_MAX_SIZE_OFFSET, + SVE_HEADER_MAX_SIZE_LENGTH, byte_order, max_size); + + /* Output the other fields of the ZA header (vl, max_vl, flags and + reserved). */ + uint64_t svq = tdep->sme_svq; + store_unsigned_integer (header + SVE_HEADER_VL_OFFSET, SVE_HEADER_VL_LENGTH, + byte_order, sve_vl_from_vq (svq)); + + uint16_t max_vl = SVE_CORE_DUMMY_MAX_VL; + store_unsigned_integer (header + SVE_HEADER_MAX_VL_OFFSET, + SVE_HEADER_MAX_VL_LENGTH, byte_order, + max_vl); + + uint16_t flags = SVE_CORE_DUMMY_FLAGS; + store_unsigned_integer (header + SVE_HEADER_FLAGS_OFFSET, + SVE_HEADER_FLAGS_LENGTH, byte_order, flags); + + uint16_t reserved = SVE_CORE_DUMMY_RESERVED; + store_unsigned_integer (header + SVE_HEADER_RESERVED_OFFSET, + SVE_HEADER_RESERVED_LENGTH, byte_order, reserved); + + buf = has_za_payload ? (gdb_byte *) buf + SVE_HEADER_SIZE : nullptr; + + /* Dump the register cache contents for the ZA register to the buffer. */ + regcache->collect_regset (regset, regnum, (gdb_byte *) buf, + size - SVE_HEADER_SIZE); +} + /* Implement the "iterate_over_regset_sections" gdbarch method. */ static void @@ -919,6 +1326,30 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, { 0 } }; + const struct regset aarch64_linux_ssve_regset = + { + sve_regmap, + aarch64_linux_supply_ssve_regset, aarch64_linux_collect_ssve_regset, + REGSET_VARIABLE_SIZE + }; + + /* If SME is supported in the core file, process the SSVE section first, + and the SVE section last. This is because we need information from + the SSVE set to determine if streaming mode is active. If streaming + mode is active, we need to extract the data from the SSVE section. + + Otherwise, if streaming mode is not active, we fetch the data from the + SVE section. */ + if (tdep->has_sme ()) + { + cb (".reg-aarch-ssve", + SVE_HEADER_SIZE + + regcache_map_entry_size (aarch64_linux_fpregmap), + SVE_HEADER_SIZE + regcache_map_entry_size (sve_regmap), + &aarch64_linux_ssve_regset, "SSVE registers", cb_data); + } + + /* Handle the SVE register set. */ const struct regset aarch64_linux_sve_regset = { sve_regmap, @@ -935,6 +1366,29 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, cb (".reg2", AARCH64_LINUX_SIZEOF_FPREGSET, AARCH64_LINUX_SIZEOF_FPREGSET, &aarch64_linux_fpregset, NULL, cb_data); + if (tdep->has_sme ()) + { + /* Setup the register set information for a ZA register set core + dump. */ + + /* Create this on the fly in order to handle the ZA register size. */ + const struct regcache_map_entry za_regmap[] = + { + { 1, tdep->sme_za_regnum, (int) std::pow (sve_vl_from_vq (tdep->sme_svq), 2) } + }; + + const struct regset aarch64_linux_za_regset = + { + za_regmap, + aarch64_linux_supply_za_regset, aarch64_linux_collect_za_regset, + REGSET_VARIABLE_SIZE + }; + + cb (".reg-aarch-za", + SVE_HEADER_SIZE, + SVE_HEADER_SIZE + std::pow (sve_vl_from_vq (tdep->sme_svq), 2), + &aarch64_linux_za_regset, "ZA register", cb_data); + } if (tdep->has_pauth ()) { @@ -1013,7 +1467,16 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, CORE_ADDR hwcap2 = linux_get_hwcap2 (auxv, target, gdbarch); aarch64_features features; - features.vq = aarch64_linux_core_read_vq (gdbarch, abfd); + + /* We need to extract the SVE data from the .reg-aarch-sve section or the + .reg-aarch-ssve section depending on which one was active when the core + file was generated. + + If the SSVE section contains SVE data, then it is considered active. + Otherwise the SVE section is considered active. This guarantees we will + have the correct target description with the correct SVE vector + length. */ + features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd); features.pauth = hwcap & AARCH64_HWCAP_PACA; features.mte = hwcap2 & HWCAP2_MTE; @@ -1027,6 +1490,9 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, features.tls = size / AARCH64_TLS_REGISTER_SIZE; } + features.svq + = aarch64_linux_core_read_vq (gdbarch, abfd, ".reg-aarch-za"); + return aarch64_read_description (features); } diff --git a/gdb/arch/aarch64-scalable-linux.c b/gdb/arch/aarch64-scalable-linux.c index 3803acfd9a8..2e4aa92e36f 100644 --- a/gdb/arch/aarch64-scalable-linux.c +++ b/gdb/arch/aarch64-scalable-linux.c @@ -19,3 +19,37 @@ along with this program. If not, see . */ #include "arch/aarch64-scalable-linux.h" +#include "arch/aarch64.h" +#include "gdbsupport/byte-vector.h" +#include "gdbsupport/common-regcache.h" + +/* See arch/aarch64-scalable-linux.h */ + +bool +sve_state_is_empty (const struct reg_buffer_common *reg_buf) +{ + /* Instead of allocating a buffer with the size of the current vector + length, just use a buffer that is big enough for all cases. */ + gdb_byte zero_buffer[256]; + + /* Zero it out. */ + memset (zero_buffer, 0, 256); + + /* Are any of the Z registers set (non-zero) after the first 128 bits? */ + for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++) + { + if (!reg_buf->raw_compare (AARCH64_SVE_Z0_REGNUM + i, zero_buffer, + V_REGISTER_SIZE)) + return false; + } + + /* Are any of the P registers set (non-zero)? */ + for (int i = 0; i < AARCH64_SVE_P_REGS_NUM; i++) + { + if (!reg_buf->raw_compare (AARCH64_SVE_P0_REGNUM + i, zero_buffer, 0)) + return false; + } + + /* Is the FFR register set (non-zero)? */ + return reg_buf->raw_compare (AARCH64_SVE_FFR_REGNUM, zero_buffer, 0); +} diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h index df1741004ed..cb9d85a9d5d 100644 --- a/gdb/arch/aarch64-scalable-linux.h +++ b/gdb/arch/aarch64-scalable-linux.h @@ -22,6 +22,7 @@ #define ARCH_AARCH64_SCALABLE_LINUX_H #include "gdbsupport/common-defs.h" +#include "gdbsupport/common-regcache.h" /* Feature check for Scalable Matrix Extension. */ #ifndef HWCAP2_SME @@ -35,4 +36,18 @@ /* Mask including all valid SVCR bits. */ #define SVCR_BIT_MASK (SVCR_SM_BIT | SVCR_ZA_BIT) +/* SVE/SSVE-related constants used for an empty SVE/SSVE register set + dumped to a core file. When SME is supported, either the SVE state or + the SSVE state will be empty when it is dumped to a core file. */ +#define SVE_CORE_DUMMY_SIZE 0x220 +#define SVE_CORE_DUMMY_MAX_SIZE 0x2240 +#define SVE_CORE_DUMMY_VL 0x10 +#define SVE_CORE_DUMMY_MAX_VL 0x100 +#define SVE_CORE_DUMMY_FLAGS 0x0 +#define SVE_CORE_DUMMY_RESERVED 0x0 + +/* Return TRUE if the SVE state in the register cache REGCACHE + is empty (zero). Return FALSE otherwise. */ +extern bool sve_state_is_empty (const struct reg_buffer_common *reg_buf); + #endif /* ARCH_AARCH64_SCALABLE_LINUX_H */ From patchwork Fri May 19 10:25:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69678 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 4617438425A6 for ; Fri, 19 May 2023 10:29:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4617438425A6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492147; bh=hpcvx1QSuY6/aIXHjmaUDwJPR7CVY++z9EIn9y2TLUQ=; 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=dacwy2L9q6GRHXOZ4AW4SMS38cMWLhBCzVTHDS9V7ZU8X0vkT1KdYyrj+OfrYq7zN J1nlOPLZfERZmejflsPLnWtHAbVFRmUsMForV0K2z9exn8xpUhkQdizq7vZkHEOyp8 eZDf3rVWZg9GuMYZ+zAcXJAU+hGpixuCHKtgMzjw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2054.outbound.protection.outlook.com [40.107.105.54]) by sourceware.org (Postfix) with ESMTPS id C69933858426 for ; Fri, 19 May 2023 10:25:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C69933858426 Received: from AM7PR03CA0030.eurprd03.prod.outlook.com (2603:10a6:20b:130::40) by GV2PR08MB8100.eurprd08.prod.outlook.com (2603:10a6:150:7a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:27 +0000 Received: from AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:130:cafe::d9) by AM7PR03CA0030.outlook.office365.com (2603:10a6:20b:130::40) 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:27 +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 AM7EUR03FT058.mail.protection.outlook.com (100.127.140.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:27 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Fri, 19 May 2023 10:25:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4ac29ece902337dc X-CR-MTA-TID: 64aa7808 Received: from 44f7d938c9ec.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3E001AFA-CB6D-4505-95A3-A2E2D9094AC4.1; Fri, 19 May 2023 10:25:21 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 44f7d938c9ec.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rd4NWOV3o2rf8QYojJ/u2n8jgoAIYSlCM9784splkZ88X+5Yf0TsrbkeJtr+lQZh57ZtSuo1kaE0zenFMe+CSjb3O2rrrBNWl4vSZCruQoMa69S0mVhhTZtxd+0UuGZabEO8rVHlpJGnyym0XkDfJFABKJk2Xl5ADyWGHhA5NhhACNsK0RjY7tp84sXxSXvZ2iQWzyVl/gDqO9m0xDWB2R4rUPV70kOhL0AqNamhFKhMVWPbUocUhEBgrC8FdcZZ0QcDNnu1lDZBvh38aCV0+S+4mPttLmJtIJLjhuOugqU9MnnCIMHcmcrMWzn2LduEAmzhdm3B6y956w6xAkSV3A== 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=hpcvx1QSuY6/aIXHjmaUDwJPR7CVY++z9EIn9y2TLUQ=; b=VFSEIWA/oWO47YAeSfmlmynaPlHaVETef+6CeB+LEWxu9mYG9UkuKY1/Z9BOhg3QxE3LmBx02tIbeS9D6KvH7JHAqSpnyKFh/OijbpTTR3x5XPZF7QuCSWbaUCcG/pLYgWvXbAeaQUnt52mPVY8IGFbKAzpXGPKBtFd/wK7B5ozjynyMtUqfvxYOUlgR3fFXS/5TjfPrc/Lcwif9XEgxUqLxWeIJRwysEE7dDw95WUnIpoHBesRBE9aRx8XPHNfSF88FKMMsQgU3B5PFeAlydzK1D2VKswm/rH9phajq9Cv/yKI9mxncrHpYOiNWSiI1R0EC58B/1yDTOTRLEz5zyA== 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 AM9P192CA0006.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::11) by AM7PR08MB5333.eurprd08.prod.outlook.com (2603:10a6:20b:104::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:17 +0000 Received: from AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:21d:cafe::28) by AM9P192CA0006.outlook.office365.com (2603:10a6:20b:21d::11) 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:17 +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 AM7EUR03FT056.mail.protection.outlook.com (100.127.140.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:16 +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:13 +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:13 +0000 To: Subject: [PATCH v2 16/17] [gdb/testsuite] sme: Add SVE/SME testcases Date: Fri, 19 May 2023 11:25:07 +0100 Message-ID: <20230519102508.14020-17-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: AM7EUR03FT056:EE_|AM7PR08MB5333:EE_|AM7EUR03FT058:EE_|GV2PR08MB8100:EE_ X-MS-Office365-Filtering-Correlation-Id: d4c2c5bd-8d5d-4a3c-7646-08db58535d3c 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: +Xc5+aJaElrv9f+VYL0LdkUjA1Qw9OXxSzgRmf+Vrx9RuKUeNa+s4YxxBwQwwafVP4nFpbJ7u0eg1O22EGFyXdm230+syAi2BB+gX2Ih0VH/UR9aUoBWBrTvo1ngVtL929X4Jt4Bb43xRfTIqKIeCfCmCKnTYDAd5yVbHeRHtSJN8Oxj3iWvVfaxWuJgpYqwgcleiAar/to68QU1JDo43P+q28Ey6I+EUVtboFvIvHMExn/m3EWyaEaQ7+jmA13CqqdAsFrWQYe8stwWKyJ4lqZTRgSOfbwvZxaXCGztPnJA1SX65m32KyJUsnAQ/jN4kNPwgBj15/BaFiaurbC5qSPgVgzCszBv5rI/fPxkqjJv16Hk1gaut0a2ACA+nZclh/F/AbyZiqcfLkx0iAfXNDJK9z/mwTewc1GUD1n0BOFVhCFtLtIzqgyBGDnDqYPHEvP5YDYTYbLWZmhSMmtiDX4wteyjtnHOFQmTnVRS5EjCCOWgpPfePVzOFvYTx3qY/9tPN/HszryfCOpsSymY2/wDdGg6tx8vtkfVpwlKaEos9A3AwaHl+XO79HJpV/mR+usODarecZTS3SE89AScC2PLolLWvvUnyMjnT4FUGS5tMsOqlkmSLOnl/0WiL4qrwvo2fNcSJsuNscaerynnB0klVaQI3BiHatk0zgi2/WROf28e6189fYVnxIrg1lsQkhVnQl/C/1UADFylLU7ck6JldFzIvrMzvND049amMluzS5hywxI75bSPdhoMvCNj 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)(39850400004)(346002)(396003)(376002)(136003)(451199021)(46966006)(36840700001)(336012)(426003)(36860700001)(83380400001)(478600001)(26005)(1076003)(2616005)(47076005)(186003)(6666004)(7696005)(82310400005)(316002)(81166007)(8676002)(6916009)(8936002)(86362001)(36756003)(356005)(41300700001)(40480700001)(70206006)(70586007)(82740400003)(2906002)(30864003)(44832011)(5660300002)(2004002)(36900700001)(579004)(559001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5333 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: eea88605-3dfd-414f-a266-08db58535719 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3HQERkcZOFttfdjfwpcVp3fOjuG44WsfJXyJ8wE6WpnmXrLx4LXakC90cjps70MqzTa1BjiCkBL9IyKdrCBid0ZWiNXbbMhCyxGnBhcQy94Ag2l41ck5ng+t70a/LfIn/zGGxz7QWUkje9XsosV/q19rstHUyd8XX5XkIOIN9A07ccVflHcZRARGxhCUDnYxE6Oi1geMtdr7DRSuryylwU1AePS5e/bVDYsXUq2VcwRkwevRKe3Ijd4oCCSKMovOZS2Ig93v3kh/4B5rUlY0SjTzkKkdKE1rgiHW7W81CdTz0lWl8+nfWS6/YhyPnLg36IkhnncacLNJ1tH9reM+MeDt/tpkDhUsrrmQyynxlsacQfKbexiLD9RfSuwk23btL82NoOMcHSKwdwUdaSGLN7HmBOXRANMmw1wfgoemUWDgEimjR8YTxOSoYFKqpsoatFVkL2slgwT77zRVqALVPB3Q3fNQKokLAqXnxHNO6Uqn+RagzGQwnfkj56YxykEFM7Z7c2q9ejXwigis+HoRX06Ti3ps7WxSW/tY0o/w8OOUZdAdvZ1dElmtY09VgaUTrgvhkYrwdJNRGkxp/fW/ScrzeMob6Mz9PZ0xaPi1fxIDNaIM3NroeIcIlxqXZCkZBSFBogkC0WGzJ9xP2bFx/PRyG8Px6RjzjK2mhbqTuofrQ+Ga8iSWOnB1bVWQCIe0KDx6JEo0OM2KxSI7br+DK/0/0GESbYc+eK8SEGaESsi6e+/0BXmky+DCSl05/96c 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)(39860400002)(346002)(396003)(136003)(376002)(451199021)(46966006)(36840700001)(40470700004)(478600001)(2906002)(40480700001)(30864003)(7696005)(6666004)(70586007)(70206006)(6916009)(316002)(41300700001)(44832011)(26005)(5660300002)(36860700001)(8936002)(8676002)(1076003)(186003)(40460700003)(81166007)(36756003)(336012)(426003)(2616005)(47076005)(83380400001)(82310400005)(86362001)(82740400003)(2004002)(559001)(579004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:27.1893 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4c2c5bd-8d5d-4a3c-7646-08db58535d3c 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: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8100 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, KAM_SHORT, 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" Add 5 SVE/SME tests to exercise all the new features like reading/writing registers, pseudo-registers, signal frames and core files. - Sanity check for SME: Gives a brief smoke test to make sure the most basic of features are working correctly. - ZA unavailability tests: Validates the behavior/content of the ZA register is correct when no payload is available. It also exercises changing the vector lengths. - ZA Availability tests: These tests exercise reading/writing to all the possible ZA pseudo-registers, and validates the state is correct. - Core file tests: Validates that core file reading and writing works correctly and that all state dumped/loaded is sane. This is exercised for both Linux Kernel core files and gcore core files. - Signal frame tests: Validates the correct restoration of SME/SVE/FPSIMD values across signal frames. Since some of these tests are very lengthy and take a little while to run (under QEMU at the moment), I decided to parallelize them into smaller chunks so we can throw some more CPU power at them so they run faster. I'd still like to add a few more tests to give the testsuite more coverage in the areas of SME/SVE. Hopefully in the near future that will happen. Just a reminder that most of these tests will FAIL when running against gdbserver because all of the tests change the vector length mid-execution in some way. Since gdbserver can't communicate the change of state over RSP to GDB, we will always get wrong state from gdbserver. Co-Authored-By: Ezra Sitorus --- gdb/testsuite/gdb.arch/aarch64-sme-core-0.exp | 18 + gdb/testsuite/gdb.arch/aarch64-sme-core-1.exp | 18 + gdb/testsuite/gdb.arch/aarch64-sme-core-2.exp | 18 + gdb/testsuite/gdb.arch/aarch64-sme-core-3.exp | 18 + gdb/testsuite/gdb.arch/aarch64-sme-core-4.exp | 18 + gdb/testsuite/gdb.arch/aarch64-sme-core.c | 361 +++++++++++++++++ .../gdb.arch/aarch64-sme-core.exp.tcl | 167 ++++++++ .../gdb.arch/aarch64-sme-regs-available-0.exp | 18 + .../gdb.arch/aarch64-sme-regs-available-1.exp | 18 + .../gdb.arch/aarch64-sme-regs-available-2.exp | 18 + .../gdb.arch/aarch64-sme-regs-available-3.exp | 18 + .../gdb.arch/aarch64-sme-regs-available-4.exp | 18 + .../gdb.arch/aarch64-sme-regs-available.c | 184 +++++++++ .../aarch64-sme-regs-available.exp.tcl | 194 +++++++++ .../gdb.arch/aarch64-sme-regs-sigframe-0.exp | 18 + .../gdb.arch/aarch64-sme-regs-sigframe-1.exp | 18 + .../gdb.arch/aarch64-sme-regs-sigframe-2.exp | 18 + .../gdb.arch/aarch64-sme-regs-sigframe-3.exp | 18 + .../gdb.arch/aarch64-sme-regs-sigframe-4.exp | 18 + .../gdb.arch/aarch64-sme-regs-sigframe.c | 368 +++++++++++++++++ .../aarch64-sme-regs-sigframe.exp.tcl | 156 ++++++++ .../aarch64-sme-regs-unavailable-0.exp | 18 + .../aarch64-sme-regs-unavailable-1.exp | 18 + .../aarch64-sme-regs-unavailable-2.exp | 18 + .../aarch64-sme-regs-unavailable-3.exp | 18 + .../aarch64-sme-regs-unavailable-4.exp | 18 + .../gdb.arch/aarch64-sme-regs-unavailable.c | 154 ++++++++ .../aarch64-sme-regs-unavailable.exp.tcl | 162 ++++++++ gdb/testsuite/gdb.arch/aarch64-sme-sanity.c | 249 ++++++++++++ gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp | 72 ++++ gdb/testsuite/lib/aarch64.exp | 372 ++++++++++++++++++ gdb/testsuite/lib/gdb.exp | 63 +++ 32 files changed, 2862 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-core-0.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-core-1.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-core-2.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-core-3.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-core-4.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-core.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-available-0.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-available-1.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-available-2.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-available-3.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-available-4.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-available.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-0.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-1.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-2.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-3.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-4.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-0.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-1.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-2.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-3.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-4.exp create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-sanity.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp create mode 100644 gdb/testsuite/lib/aarch64.exp diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core-0.exp b/gdb/testsuite/gdb.arch/aarch64-sme-core-0.exp new file mode 100644 index 00000000000..c4755346bc8 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core-0.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 0 +set id_end 24 +source $srcdir/$subdir/aarch64-sme-core.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core-1.exp b/gdb/testsuite/gdb.arch/aarch64-sme-core-1.exp new file mode 100644 index 00000000000..6461c47d6b5 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core-1.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 25 +set id_end 49 +source $srcdir/$subdir/aarch64-sme-core.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core-2.exp b/gdb/testsuite/gdb.arch/aarch64-sme-core-2.exp new file mode 100644 index 00000000000..e5bf5bf2b84 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core-2.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 50 +set id_end 74 +source $srcdir/$subdir/aarch64-sme-core.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core-3.exp b/gdb/testsuite/gdb.arch/aarch64-sme-core-3.exp new file mode 100644 index 00000000000..1846c83a63c --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core-3.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 75 +set id_end 99 +source $srcdir/$subdir/aarch64-sme-core.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core-4.exp b/gdb/testsuite/gdb.arch/aarch64-sme-core-4.exp new file mode 100644 index 00000000000..45e69fa8ad5 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core-4.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 100 +set id_end 124 +source $srcdir/$subdir/aarch64-sme-core.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.c b/gdb/testsuite/gdb.arch/aarch64-sme-core.c new file mode 100644 index 00000000000..7d4284b80c8 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.c @@ -0,0 +1,361 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Exercise AArch64's Scalable Vector/Matrix Extension core file generation + for GDB. This includes reading Linux Kernel-generated core files and + writing GDB core files via the gcore command and making sure the contents + are sane. */ + +#include +#include +#include +#include +#include +#include + +#ifndef HWCAP_SVE +#define HWCAP_SVE (1 << 22) +#endif + +#ifndef HWCAP2_SME +#define HWCAP2_SME (1 << 23) +#endif + +#ifndef PR_SVE_SET_VL +#define PR_SVE_SET_VL 50 +#define PR_SVE_GET_VL 51 +#define PR_SVE_VL_LEN_MASK 0xffff +#endif + +#ifndef PR_SME_SET_VL +#define PR_SME_SET_VL 63 +#define PR_SME_GET_VL 64 +#define PR_SME_VL_LEN_MASK 0xffff +#endif + +static void +enable_za () +{ + /* smstart za */ + __asm __volatile (".word 0xD503457F"); +} + +static void +disable_za () +{ + /* smstop za */ + __asm __volatile (".word 0xD503447F"); +} + +static void +enable_sm () +{ + /* smstart sm */ + __asm __volatile (".word 0xD503437F"); +} + +static void +disable_sm () +{ + /* smstop sm */ + __asm __volatile (".word 0xD503427F"); +} + +static void +initialize_fpsimd_state () +{ + char buffer[16]; + + for (int i = 0; i < 16; i++) + buffer[i] = 0x55; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + __asm __volatile ("ldr q0, [x0]"); + __asm __volatile ("ldr q1, [x0]"); + __asm __volatile ("ldr q2, [x0]"); + __asm __volatile ("ldr q3, [x0]"); + __asm __volatile ("ldr q4, [x0]"); + __asm __volatile ("ldr q5, [x0]"); + __asm __volatile ("ldr q6, [x0]"); + __asm __volatile ("ldr q7, [x0]"); + __asm __volatile ("ldr q8, [x0]"); + __asm __volatile ("ldr q9, [x0]"); + __asm __volatile ("ldr q10, [x0]"); + __asm __volatile ("ldr q11, [x0]"); + __asm __volatile ("ldr q12, [x0]"); + __asm __volatile ("ldr q13, [x0]"); + __asm __volatile ("ldr q14, [x0]"); + __asm __volatile ("ldr q15, [x0]"); + __asm __volatile ("ldr q16, [x0]"); + __asm __volatile ("ldr q17, [x0]"); + __asm __volatile ("ldr q18, [x0]"); + __asm __volatile ("ldr q19, [x0]"); + __asm __volatile ("ldr q20, [x0]"); + __asm __volatile ("ldr q21, [x0]"); + __asm __volatile ("ldr q22, [x0]"); + __asm __volatile ("ldr q23, [x0]"); + __asm __volatile ("ldr q24, [x0]"); + __asm __volatile ("ldr q25, [x0]"); + __asm __volatile ("ldr q26, [x0]"); + __asm __volatile ("ldr q27, [x0]"); + __asm __volatile ("ldr q28, [x0]"); + __asm __volatile ("ldr q29, [x0]"); + __asm __volatile ("ldr q30, [x0]"); + __asm __volatile ("ldr q31, [x0]"); +} + +static void +initialize_za_state () +{ + /* zero za */ + __asm __volatile (".word 0xC00800FF"); + + char buffer[256]; + + for (int i = 0; i < 256; i++) + buffer[i] = 0xaa; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize loop boundaries. */ + __asm __volatile ("mov w12, 0"); + __asm __volatile ("mov w17, 256"); + + /* loop: ldr za[w12, 0], [x0] */ + __asm __volatile ("loop: .word 0xe1000000"); + __asm __volatile ("add w12, w12, 1"); + __asm __volatile ("cmp w12, w17"); + __asm __volatile ("bne loop"); +} + +static void +initialize_sve_state () +{ + __asm __volatile ("dup z0.b, -1"); + __asm __volatile ("dup z1.b, -1"); + __asm __volatile ("dup z2.b, -1"); + __asm __volatile ("dup z3.b, -1"); + __asm __volatile ("dup z4.b, -1"); + __asm __volatile ("dup z5.b, -1"); + __asm __volatile ("dup z6.b, -1"); + __asm __volatile ("dup z7.b, -1"); + __asm __volatile ("dup z8.b, -1"); + __asm __volatile ("dup z9.b, -1"); + __asm __volatile ("dup z10.b, -1"); + __asm __volatile ("dup z11.b, -1"); + __asm __volatile ("dup z12.b, -1"); + __asm __volatile ("dup z13.b, -1"); + __asm __volatile ("dup z14.b, -1"); + __asm __volatile ("dup z15.b, -1"); + __asm __volatile ("dup z16.b, -1"); + __asm __volatile ("dup z17.b, -1"); + __asm __volatile ("dup z18.b, -1"); + __asm __volatile ("dup z19.b, -1"); + __asm __volatile ("dup z20.b, -1"); + __asm __volatile ("dup z21.b, -1"); + __asm __volatile ("dup z22.b, -1"); + __asm __volatile ("dup z23.b, -1"); + __asm __volatile ("dup z24.b, -1"); + __asm __volatile ("dup z25.b, -1"); + __asm __volatile ("dup z26.b, -1"); + __asm __volatile ("dup z27.b, -1"); + __asm __volatile ("dup z28.b, -1"); + __asm __volatile ("dup z29.b, -1"); + __asm __volatile ("dup z30.b, -1"); + __asm __volatile ("dup z31.b, -1"); + __asm __volatile ("ptrue p0.b"); + __asm __volatile ("ptrue p1.b"); + __asm __volatile ("ptrue p2.b"); + __asm __volatile ("ptrue p3.b"); + __asm __volatile ("ptrue p4.b"); + __asm __volatile ("ptrue p5.b"); + __asm __volatile ("ptrue p6.b"); + __asm __volatile ("ptrue p7.b"); + __asm __volatile ("ptrue p8.b"); + __asm __volatile ("ptrue p9.b"); + __asm __volatile ("ptrue p10.b"); + __asm __volatile ("ptrue p11.b"); + __asm __volatile ("ptrue p12.b"); + __asm __volatile ("ptrue p13.b"); + __asm __volatile ("ptrue p14.b"); + __asm __volatile ("ptrue p15.b"); + __asm __volatile ("setffr"); +} + +static int get_vl_size () +{ + int res = prctl (PR_SVE_GET_VL, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SVE_GET_VL (%d)", res); + return -1; + } + return (res & PR_SVE_VL_LEN_MASK); +} + +static int get_svl_size () +{ + int res = prctl (PR_SME_GET_VL, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SME_GET_VL (%d)", res); + return -1; + } + return (res & PR_SVE_VL_LEN_MASK); +} + +static int set_vl_size (int new_vl) +{ + int res = prctl (PR_SVE_SET_VL, new_vl, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SVE_SET_VL (%d)", res); + return -1; + } + + res = get_vl_size (); + if (res != new_vl) + { + printf ("Unexpected VL value (%d)", res); + return -1; + } + + return res; +} + +static int set_svl_size (int new_svl) +{ + int res = prctl (PR_SME_SET_VL, new_svl, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SME_SET_VL (%d)", res); + return -1; + } + + res = get_svl_size (); + if (res != new_svl) + { + printf ("Unexpected SVL value (%d)", res); + return -1; + } + + return res; +} + +/* Enable register states based on STATE. + + 0 - FPSIMD + 1 - SVE + 2 - SSVE + 3 - ZA + 4 - ZA and SSVE. */ + +void enable_states (int state) +{ + disable_za (); + disable_sm (); + initialize_fpsimd_state (); + + if (state == 1) + { + initialize_sve_state (); + } + else if (state == 2) + { + enable_sm (); + initialize_sve_state (); + } + else if (state == 3) + { + enable_za (); + initialize_za_state (); + } + else if (state == 4) + { + enable_za (); + enable_sm (); + initialize_sve_state (); + initialize_za_state (); + } + + return; +} + +static int +test_id_to_state (int id) +{ + return id / 25; +} + +static int +test_id_to_vl (int id) +{ + return 16 << ((id / 5) % 5); +} + +static int +test_id_to_svl (int id) +{ + return 16 << (id % 5); +} + +static void +dummy () +{ +} + +int +main (int argc, char **argv) +{ + if (argc > 2) + printf ("Incorrect number of arguments passed to test.\n"); + + if (getauxval (AT_HWCAP) & HWCAP_SVE && getauxval (AT_HWCAP2) & HWCAP2_SME) + { + long test_id = 0; + + /* If we have a test id passed as argument, read it now. */ + if (argc == 2) + test_id = strtol (argv[1], NULL, 0); + + dummy (); /* stop to initialize test_id */ + + int state = test_id_to_state (test_id); + int vl = test_id_to_vl (test_id); + int svl = test_id_to_svl (test_id); + + if (set_vl_size (vl) == -1) + return -1; + if (set_svl_size (svl) == -1) + return -1; + + enable_states (state); + + char *p = 0x0; + *p = 0xff; /* crash point */ + } + else + { + printf ("SKIP: no HWCAP_SVE or HWCAP2_SME on this system\n"); + return -1; + } + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl new file mode 100644 index 00000000000..1fc325d4df7 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl @@ -0,0 +1,167 @@ +# Copyright (C) 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Exercise core file reading/writing in the presence of SME support. +# This test exercises GDB's dumping/loading capability for Linux +# Kernel core files and for gcore core files. + +load_lib aarch64.exp + +# +# Validate that CORE_FILENAME can be read correctly and that the register +# state is sane. +# +proc check_sme_core_file { core_filename state vl svl } { + # Load the core file. + if [gdb_test "core $core_filename" \ + [multi_line \ + "Core was generated by.*\." \ + "Program terminated with signal SIGSEGV, Segmentation fault\." \ + "#0 ${::hex} in main \\(.*\\) at .*" \ + ".*p = 0xff;.* crash point .*"] \ + "load core file"] { + untested "failed to generate core file" + return -1 + } + + check_state $state $vl $svl + + # Check the value of TPIDR2 in the core file. + gdb_test "print/x \$tpidr2" " = 0x1f2f3f4f5f6f7f8f" "tpidr2 contents from core file" +} + +# +# Generate two core files for EXECUTABLE, BINFILE with a test id of ID. +# STATE is the register state, VL is the SVE vector length and SVL is the +# SME vector length. +# One of the core files is generated by the kernel and the other by the +# gcore command. +# +proc generate_sme_core_files { executable binfile id state vl svl} { + # Run the program until the point where we need to adjust the + # test id. + set init_breakpoint "stop to initialize test_id" + gdb_breakpoint [gdb_get_line_number $init_breakpoint] + gdb_continue_to_breakpoint $init_breakpoint + gdb_test_no_output "set test_id = $id" + + # Run the program until just before the crash. + set crash_breakpoint "crash point" + gdb_breakpoint [gdb_get_line_number $crash_breakpoint] + gdb_continue_to_breakpoint $crash_breakpoint + gdb_test_no_output "set print repeats 1" "adjust repeat count pre-crash" + + # Adjust the register to custom values that we will check later when + # loading the core files. + check_state $state $vl $svl + + # Modify tpidr2 so we can validate its value is properly dumped to the + # core files. + gdb_test_no_output "set \$tpidr2 = 0x1f2f3f4f5f6f7f8f" + + # Continue until a crash. + gdb_test "continue" \ + [multi_line \ + "Program received signal SIGSEGV, Segmentation fault\." \ + "${::hex} in main \\(.*\\) at .*" \ + ".*p = 0xff;.* crash point .*"] \ + "run to crash" + + # Generate the gcore core file. + set gcore_filename [standard_output_file "${executable}-${id}-${state}-${vl}-${svl}.gcore"] + set gcore_generated [gdb_gcore_cmd "$gcore_filename" "generate gcore file"] + + # Continue until the end. + gdb_test "continue" "Program terminated with signal SIGSEGV.*" \ + "program terminated with SIGSEGV" + + # Generate a native core file. + set core_filename [core_find ${binfile} {} $id] + set core_generated [expr {$core_filename != ""}] + set native_core_name "${binfile}-${id}-${state}-${vl}-${svl}.core" + remote_exec build "mv $core_filename ${native_core_name}" + set core_filename ${native_core_name} + + # At this point we have a couple core files, the gcore one generated by GDB + # and the native one generated by the Linux Kernel. Make sure GDB can read + # both correctly. + if {$gcore_generated} { + clean_restart ${binfile} + gdb_test_no_output "set print repeats 1" \ + "adjust repeat count post-crash gcore" + + with_test_prefix "gcore corefile" { + check_sme_core_file $gcore_filename $state $vl $svl + } + } else { + fail "gcore corefile not generated" + } + + if {$core_generated} { + clean_restart ${binfile} + + gdb_test_no_output "set print repeats 1" \ + "adjust repeat count post-crash native core" + + with_test_prefix "native corefile" { + check_sme_core_file $core_filename $state $vl $svl + } + } else { + untested "native corefile not generated" + } +} + +# +# Exercise core file reading (kernel-generated core files) and writing +# (gcore command) for test id's ID_START through ID_END. +# +proc test_sme_core_file { id_start id_end } { + set compile_flags {"debug" "macros" "additional_flags=-march=armv8.5-a+sve"} + standard_testfile ${::srcdir}/${::subdir}/aarch64-sme-core.c + set executable "${::testfile}" + if {[prepare_for_testing "failed to prepare" ${executable} ${::srcfile} ${compile_flags}]} { + return -1 + } + set binfile [standard_output_file ${executable}] + + for {set id $id_start} {$id <= $id_end} {incr id} { + set state [test_id_to_state $id] + set vl [test_id_to_vl $id] + set svl [test_id_to_svl $id] + + with_test_prefix "state=${state} vl=${vl} svl=${svl}" { + if ![runto_main] { + untested "could not run to main" + return -1 + } + + generate_sme_core_files ${executable} ${binfile} $id $state $vl $svl + } + } +} + +require is_aarch64_target + +if {![allow_aarch64_sve_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +if {![allow_aarch64_sme_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +test_sme_core_file $id_start $id_end diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-0.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-0.exp new file mode 100644 index 00000000000..b264170c56a --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-0.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 0 +set id_end 4 +source $srcdir/$subdir/aarch64-sme-regs-available.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-1.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-1.exp new file mode 100644 index 00000000000..ac48aa905bc --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-1.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 5 +set id_end 9 +source $srcdir/$subdir/aarch64-sme-regs-available.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-2.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-2.exp new file mode 100644 index 00000000000..0e8f3e311ee --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-2.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 10 +set id_end 14 +source $srcdir/$subdir/aarch64-sme-regs-available.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-3.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-3.exp new file mode 100644 index 00000000000..fabb24c5aad --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-3.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 14 +set id_end 19 +source $srcdir/$subdir/aarch64-sme-regs-available.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-4.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-4.exp new file mode 100644 index 00000000000..5abeabb74c4 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available-4.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 20 +set id_end 24 +source $srcdir/$subdir/aarch64-sme-regs-available.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.c b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.c new file mode 100644 index 00000000000..bf27356908f --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.c @@ -0,0 +1,184 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Exercise various cases of reading/writing ZA contents for AArch64's + Scalable Matrix Extension. */ + +#include +#include +#include +#include +#include +#include + +#ifndef HWCAP_SVE +#define HWCAP_SVE (1 << 22) +#endif + +#ifndef HWCAP2_SME +#define HWCAP2_SME (1 << 23) +#endif + +#ifndef PR_SVE_SET_VL +#define PR_SVE_SET_VL 50 +#define PR_SVE_GET_VL 51 +#define PR_SVE_VL_LEN_MASK 0xffff +#endif + +#ifndef PR_SME_SET_VL +#define PR_SME_SET_VL 63 +#define PR_SME_GET_VL 64 +#define PR_SME_VL_LEN_MASK 0xffff +#endif + +static void +enable_za () +{ + /* smstart za */ + __asm __volatile (".word 0xD503457F"); +} + +static void +disable_za () +{ + /* smstop za */ + __asm __volatile (".word 0xD503447F"); +} + +static int get_vl_size () +{ + int res = prctl (PR_SVE_GET_VL, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SVE_GET_VL (%d)", res); + return -1; + } + return (res & PR_SVE_VL_LEN_MASK); +} + +static int get_svl_size () +{ + int res = prctl (PR_SME_GET_VL, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SME_GET_VL (%d)", res); + return -1; + } + return (res & PR_SVE_VL_LEN_MASK); +} + +static int set_vl_size (int new_vl) +{ + int res = prctl (PR_SVE_SET_VL, new_vl, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SVE_SET_VL (%d)", res); + return -1; + } + + res = get_vl_size (); + if (res != new_vl) + { + printf ("Unexpected VL value (%d)", res); + return -1; + } + + return res; +} + +static int set_svl_size (int new_svl) +{ + int res = prctl (PR_SME_SET_VL, new_svl, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SME_SET_VL (%d)", res); + return -1; + } + + res = get_svl_size (); + if (res != new_svl) + { + printf ("Unexpected SVL value (%d)", res); + return -1; + } + + return res; +} + +static int +test_id_to_vl (int id) +{ + return 16 << ((id / 5) % 5); +} + +static int +test_id_to_svl (int id) +{ + return 16 << (id % 5); +} + +static void +dummy () +{ +} + +int +main (int argc, char **argv) +{ + if (getauxval (AT_HWCAP) & HWCAP_SVE && getauxval (AT_HWCAP2) & HWCAP2_SME) + { + int id_start = ID_START; + int id_end = ID_END; + + for (int id = id_start; id <= id_end; id++) + { + int vl = test_id_to_vl (id); + int svl = test_id_to_svl (id); + + if (set_vl_size (vl) == -1) + return -1; + if (set_svl_size (svl) == -1) + return -1; + + enable_za (); + dummy (); /* stop 1 */ + } + + for (int id = id_start; id <= id_end; id++) + { + int vl = test_id_to_vl (id); + int svl = test_id_to_svl (id); + + /* Make sure the vl/svl is something other than what gdb is about + to set them to. */ + if (set_vl_size (vl == 16? 32 : vl) == -1) + return -1; + if (set_svl_size (svl == 16? 32 : svl) == -1) + return -1; + + disable_za (); + dummy (); /* stop 2 */ + } + } + else + { + printf ("SKIP: no HWCAP_SVE or HWCAP2_SME on this system\n"); + return -1; + } + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl new file mode 100644 index 00000000000..19131819273 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl @@ -0,0 +1,194 @@ +# Copyright (C) 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Exercise reading/writing ZA registers when there is ZA state. + +load_lib aarch64.exp + +# +# Cycle through all ZA registers and pseudo-registers and validate that their +# contents are available for vector length SVL. +# +# Make sure reading/writing to ZA registers work as expected. +# +proc check_regs { mode vl svl } { + # Check VG to make sure it is correct + set expected_vg [expr $vl / 8] + gdb_test "print \$vg" "= ${expected_vg}" + + # Check SVG to make sure it is correct + set expected_svg [expr $svl / 8] + gdb_test "print \$svg" "= ${expected_svg}" + + # If svl is adjusted by prctl, we will have ZA enabled. If gdb is + # adjusting svl, ZA will not be enabled by default. It will only be + # enabled when ZA is written to. + set za_state "= \\\[ ZA \\\]" + if {$mode == "gdb"} { + set za_state "= \\\[ \\\]" + } + + # Check SVCR. + if [gdb_test "print \$svcr" $za_state "svcr before assignments" ] { + fail "incorrect za state" + return -1 + } + + # Check the size of ZA. + set expected_za_size [expr $svl * $svl] + gdb_test "print sizeof \$za" " = $expected_za_size" + + # Check the size of Z0. + gdb_test "print sizeof \$z0" " = $vl" + + # Exercise reading/writing from/to ZA. + initialize_2d_array "\$za" 255 $svl $svl + set pattern [string_to_regexp [2d_array_value_pattern 255 $svl $svl]] + gdb_test "print \$za" " = $pattern" "read back from za" + + # Exercise reading/writing from/to the tile pseudo-registers. + set last_tile 1 + set expected_size [expr $svl * $svl] + set tile_svl $svl + set za_state "= \\\[ ZA \\\]" + foreach_with_prefix granularity {"b" "h" "s" "d" "q"} { + for {set tile 0} {$tile < $last_tile} {incr tile} { + set register_name "\$za${tile}${granularity}" + + # Test the size. + gdb_test "print sizeof ${register_name}" " = ${expected_size}" + + # Test reading/writing + initialize_2d_array $register_name 255 $tile_svl $tile_svl + + # Make sure we have ZA state. + if [gdb_test "print \$svcr" $za_state "svcr after assignment to ${register_name}" ] { + fail "incorrect za state" + return -1 + } + + set pattern [string_to_regexp [2d_array_value_pattern 255 $tile_svl $tile_svl]] + gdb_test "print $register_name" " = $pattern" "read back from $register_name" + } + set last_tile [expr $last_tile * 2] + set expected_size [expr $expected_size / 2] + set tile_svl [expr $tile_svl / 2] + } + + # Exercise reading/writing from/to the tile slice pseudo-registers. + set last_tile 1 + set last_slice $svl + set expected_size $svl + set num_elements $svl + foreach_with_prefix granularity {"b" "h" "s" "d" "q"} { + for {set tile 0} {$tile < $last_tile} {incr tile} { + for {set slice 0} {$slice < $last_slice} {incr slice} { + foreach_with_prefix direction {"h" "v"} { + set register_name "\$za${tile}${direction}${granularity}${slice}" + + # Test the size. + gdb_test "print sizeof ${register_name}" " = ${expected_size}" + + # Test reading/writing + initialize_1d_array $register_name 255 $num_elements + + # Make sure we have ZA state. + if [gdb_test "print \$svcr" $za_state "svcr after assignment of ${register_name}" ] { + fail "incorrect za state" + return -1 + } + + set pattern [string_to_regexp [1d_array_value_pattern 255 $num_elements]] + gdb_test "print $register_name" " = $pattern" "read back from $register_name" + } + } + } + set last_tile [expr $last_tile * 2] + set last_slice [expr ($last_slice / 2)] + set num_elements [expr $num_elements / 2] + } +} + +# +# Cycle through all ZA registers and pseudo-registers and validate their +# contents. +# +proc test_sme_registers_available { id_start id_end } { + + set compile_flags {"debug" "macros"} + lappend compile_flags "additional_flags=-DID_START=${id_start}" + lappend compile_flags "additional_flags=-DID_END=${id_end}" + + standard_testfile ${::srcdir}/${::subdir}/aarch64-sme-regs-available.c + set executable "${::testfile}-${id_start}-${id_end}" + if {[prepare_for_testing "failed to prepare" ${executable} ${::srcfile} ${compile_flags}]} { + return -1 + } + set binfile [standard_output_file ${executable}] + + if ![runto_main] { + untested "could not run to main" + return -1 + } + + gdb_test_no_output "set print repeats 1" + + set prctl_breakpoint "stop 1" + gdb_breakpoint [gdb_get_line_number $prctl_breakpoint] + + for {set id $id_start} {$id <= $id_end} {incr id} { + set vl [test_id_to_vl $id] + set svl [test_id_to_svl $id] + set mode "prctl" + with_test_prefix "$mode, vl=${vl} svl=${svl}" { + # Run the program until it has adjusted svl. + gdb_continue_to_breakpoint $prctl_breakpoint + check_regs $mode $vl $svl + } + } + + set non_prctl_breakpoint "stop 2" + gdb_breakpoint [gdb_get_line_number $non_prctl_breakpoint] + gdb_continue_to_breakpoint $non_prctl_breakpoint + + for {set id $id_start} {$id <= $id_end} {incr id} { + set vl [test_id_to_vl $id] + set svl [test_id_to_svl $id] + set mode "gdb" + with_test_prefix "$mode, vl=${vl} svl=${svl}" { + # Adjust svl via gdb. + set vg_value [expr $vl / 8] + set svg_value [expr $svl / 8] + gdb_test_no_output "set \$vg = ${vg_value}" + gdb_test_no_output "set \$svg = ${svg_value}" + + check_regs $mode $vl $svl + } + } +} + +require is_aarch64_target + +if {![allow_aarch64_sve_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +if {![allow_aarch64_sme_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +test_sme_registers_available $id_start $id_end diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-0.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-0.exp new file mode 100644 index 00000000000..00b29deed98 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-0.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 0 +set id_end 24 +source $srcdir/$subdir/aarch64-sme-regs-sigframe.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-1.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-1.exp new file mode 100644 index 00000000000..991efce4f25 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-1.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 25 +set id_end 49 +source $srcdir/$subdir/aarch64-sme-regs-sigframe.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-2.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-2.exp new file mode 100644 index 00000000000..5bd3cb80861 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-2.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 50 +set id_end 74 +source $srcdir/$subdir/aarch64-sme-regs-sigframe.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-3.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-3.exp new file mode 100644 index 00000000000..6e9cf9e929b --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-3.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 75 +set id_end 99 +source $srcdir/$subdir/aarch64-sme-regs-sigframe.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-4.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-4.exp new file mode 100644 index 00000000000..0a9a11c30a2 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe-4.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 100 +set id_end 124 +source $srcdir/$subdir/aarch64-sme-regs-sigframe.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c new file mode 100644 index 00000000000..4d178ec01f6 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c @@ -0,0 +1,368 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Exercise AArch64's Scalable Vector/Matrix Extension signal frame handling + for GDB. */ + +#include +#include +#include +#include +#include +#include +#include + +#ifndef HWCAP_SVE +#define HWCAP_SVE (1 << 22) +#endif + +#ifndef HWCAP2_SME +#define HWCAP2_SME (1 << 23) +#endif + +#ifndef PR_SVE_SET_VL +#define PR_SVE_SET_VL 50 +#define PR_SVE_GET_VL 51 +#define PR_SVE_VL_LEN_MASK 0xffff +#endif + +#ifndef PR_SME_SET_VL +#define PR_SME_SET_VL 63 +#define PR_SME_GET_VL 64 +#define PR_SME_VL_LEN_MASK 0xffff +#endif + +static int count = 0; + +static void +handler (int sig) +{ + count++; /* handler */ +} + +static void +enable_za () +{ + /* smstart za */ + __asm __volatile (".word 0xD503457F"); +} + +static void +disable_za () +{ + /* smstop za */ + __asm __volatile (".word 0xD503447F"); +} + +static void +enable_sm () +{ + /* smstart sm */ + __asm __volatile (".word 0xD503437F"); +} + +static void +disable_sm () +{ + /* smstop sm */ + __asm __volatile (".word 0xD503427F"); +} + +static void +initialize_fpsimd_state () +{ + char buffer[16]; + + for (int i = 0; i < 16; i++) + buffer[i] = 0x55; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + __asm __volatile ("ldr q0, [x0]"); + __asm __volatile ("ldr q1, [x0]"); + __asm __volatile ("ldr q2, [x0]"); + __asm __volatile ("ldr q3, [x0]"); + __asm __volatile ("ldr q4, [x0]"); + __asm __volatile ("ldr q5, [x0]"); + __asm __volatile ("ldr q6, [x0]"); + __asm __volatile ("ldr q7, [x0]"); + __asm __volatile ("ldr q8, [x0]"); + __asm __volatile ("ldr q9, [x0]"); + __asm __volatile ("ldr q10, [x0]"); + __asm __volatile ("ldr q11, [x0]"); + __asm __volatile ("ldr q12, [x0]"); + __asm __volatile ("ldr q13, [x0]"); + __asm __volatile ("ldr q14, [x0]"); + __asm __volatile ("ldr q15, [x0]"); + __asm __volatile ("ldr q16, [x0]"); + __asm __volatile ("ldr q17, [x0]"); + __asm __volatile ("ldr q18, [x0]"); + __asm __volatile ("ldr q19, [x0]"); + __asm __volatile ("ldr q20, [x0]"); + __asm __volatile ("ldr q21, [x0]"); + __asm __volatile ("ldr q22, [x0]"); + __asm __volatile ("ldr q23, [x0]"); + __asm __volatile ("ldr q24, [x0]"); + __asm __volatile ("ldr q25, [x0]"); + __asm __volatile ("ldr q26, [x0]"); + __asm __volatile ("ldr q27, [x0]"); + __asm __volatile ("ldr q28, [x0]"); + __asm __volatile ("ldr q29, [x0]"); + __asm __volatile ("ldr q30, [x0]"); + __asm __volatile ("ldr q31, [x0]"); +} + +static void +initialize_za_state () +{ + /* zero za */ + __asm __volatile (".word 0xC00800FF"); + + char buffer[256]; + + for (int i = 0; i < 256; i++) + buffer[i] = 0xaa; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize loop boundaries. */ + __asm __volatile ("mov w12, 0"); + __asm __volatile ("mov w17, 256"); + + /* loop: ldr za[w12, 0], [x0] */ + __asm __volatile ("loop: .word 0xe1000000"); + __asm __volatile ("add w12, w12, 1"); + __asm __volatile ("cmp w12, w17"); + __asm __volatile ("bne loop"); +} + +static void +initialize_sve_state () +{ + __asm __volatile ("dup z0.b, -1"); + __asm __volatile ("dup z1.b, -1"); + __asm __volatile ("dup z2.b, -1"); + __asm __volatile ("dup z3.b, -1"); + __asm __volatile ("dup z4.b, -1"); + __asm __volatile ("dup z5.b, -1"); + __asm __volatile ("dup z6.b, -1"); + __asm __volatile ("dup z7.b, -1"); + __asm __volatile ("dup z8.b, -1"); + __asm __volatile ("dup z9.b, -1"); + __asm __volatile ("dup z10.b, -1"); + __asm __volatile ("dup z11.b, -1"); + __asm __volatile ("dup z12.b, -1"); + __asm __volatile ("dup z13.b, -1"); + __asm __volatile ("dup z14.b, -1"); + __asm __volatile ("dup z15.b, -1"); + __asm __volatile ("dup z16.b, -1"); + __asm __volatile ("dup z17.b, -1"); + __asm __volatile ("dup z18.b, -1"); + __asm __volatile ("dup z19.b, -1"); + __asm __volatile ("dup z20.b, -1"); + __asm __volatile ("dup z21.b, -1"); + __asm __volatile ("dup z22.b, -1"); + __asm __volatile ("dup z23.b, -1"); + __asm __volatile ("dup z24.b, -1"); + __asm __volatile ("dup z25.b, -1"); + __asm __volatile ("dup z26.b, -1"); + __asm __volatile ("dup z27.b, -1"); + __asm __volatile ("dup z28.b, -1"); + __asm __volatile ("dup z29.b, -1"); + __asm __volatile ("dup z30.b, -1"); + __asm __volatile ("dup z31.b, -1"); + __asm __volatile ("ptrue p0.b"); + __asm __volatile ("ptrue p1.b"); + __asm __volatile ("ptrue p2.b"); + __asm __volatile ("ptrue p3.b"); + __asm __volatile ("ptrue p4.b"); + __asm __volatile ("ptrue p5.b"); + __asm __volatile ("ptrue p6.b"); + __asm __volatile ("ptrue p7.b"); + __asm __volatile ("ptrue p8.b"); + __asm __volatile ("ptrue p9.b"); + __asm __volatile ("ptrue p10.b"); + __asm __volatile ("ptrue p11.b"); + __asm __volatile ("ptrue p12.b"); + __asm __volatile ("ptrue p13.b"); + __asm __volatile ("ptrue p14.b"); + __asm __volatile ("ptrue p15.b"); + __asm __volatile ("setffr"); +} + +static int get_vl_size () +{ + int res = prctl (PR_SVE_GET_VL, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SVE_GET_VL (%d)", res); + return -1; + } + return (res & PR_SVE_VL_LEN_MASK); +} + +static int get_svl_size () +{ + int res = prctl (PR_SME_GET_VL, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SME_GET_VL (%d)", res); + return -1; + } + return (res & PR_SVE_VL_LEN_MASK); +} + +static int set_vl_size (int new_vl) +{ + int res = prctl (PR_SVE_SET_VL, new_vl, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SVE_SET_VL (%d)", res); + return -1; + } + + res = get_vl_size (); + if (res != new_vl) + { + printf ("Unexpected VL value (%d)", res); + return -1; + } + + return res; +} + +static int set_svl_size (int new_svl) +{ + int res = prctl (PR_SME_SET_VL, new_svl, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SME_SET_VL (%d)", res); + return -1; + } + + res = get_svl_size (); + if (res != new_svl) + { + printf ("Unexpected SVL value (%d)", res); + return -1; + } + + return res; +} + +/* Enable register states based on STATE. + + 0 - FPSIMD + 1 - SVE + 2 - SSVE + 3 - ZA + 4 - ZA and SSVE. */ + +void enable_states (int state) +{ + disable_za (); + disable_sm (); + initialize_fpsimd_state (); + + if (state == 1) + { + initialize_sve_state (); + } + else if (state == 2) + { + enable_sm (); + initialize_sve_state (); + } + else if (state == 3) + { + enable_za (); + initialize_za_state (); + } + else if (state == 4) + { + enable_za (); + enable_sm (); + initialize_sve_state (); + initialize_za_state (); + } + + return; +} + +static int +test_id_to_state (int id) +{ + return (id / 25); +} + +static int +test_id_to_vl (int id) +{ + return 16 << ((id / 5) % 5); +} + +static int +test_id_to_svl (int id) +{ + return 16 << (id % 5); +} + +static void +dummy () +{ +} + +int +main (int argc, char **argv) +{ + if (getauxval (AT_HWCAP) & HWCAP_SVE && getauxval (AT_HWCAP2) & HWCAP2_SME) + { + int id_start = ID_START; + int id_end = ID_END; +#ifdef SIGILL + signal (SIGILL, handler); +#endif + + int signal_count = 0; + for (int id = id_start; id <= id_end; id++) + { + int state = test_id_to_state (id); + int vl = test_id_to_vl (id); + int svl = test_id_to_svl (id); + + if (set_vl_size (vl) == -1) + return -1; + if (set_svl_size (svl) == -1) + return -1; + + signal_count++; + enable_states (state); + dummy (); /* stop before SIGILL */ + __asm __volatile (".word 0xDEADBEEF"); /* illegal instruction */ + while (signal_count != count); + } + } + else + { + printf ("SKIP: no HWCAP_SVE or HWCAP2_SME on this system\n"); + return -1; + } + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl new file mode 100644 index 00000000000..4279cdc6d9b --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl @@ -0,0 +1,156 @@ +# Copyright (C) 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Exercise restoring SME/TPIDR2 state from a signal frame. + +load_lib aarch64.exp + +# +# Validate the state of registers in the signal frame for various states. +# +proc test_sme_registers_sigframe { id_start id_end } { + + set compile_flags {"debug" "macros"} + lappend compile_flags "additional_flags=-march=armv8.5-a+sve" + lappend compile_flags "additional_flags=-DID_START=${id_start}" + lappend compile_flags "additional_flags=-DID_END=${id_end}" + + standard_testfile ${::srcdir}/${::subdir}/aarch64-sme-regs-sigframe.c + set executable "${::testfile}-${id_start}-${id_end}" + if {[prepare_for_testing "failed to prepare" ${executable} ${::srcfile} ${compile_flags}]} { + return -1 + } + set binfile [standard_output_file ${executable}] + + if ![runto_main] { + untested "could not run to main" + return -1 + } + + set sigill_breakpoint "stop before SIGILL" + set handler_breakpoint "handler" + gdb_breakpoint [gdb_get_line_number $sigill_breakpoint] + gdb_breakpoint [gdb_get_line_number $handler_breakpoint] + + for {set id $id_start} {$id <= $id_end} {incr id} { + set state [test_id_to_state $id] + set vl [test_id_to_vl $id] + set svl [test_id_to_svl $id] + + with_test_prefix "state=${state} vl=${vl} svl=${svl}" { + + # Run the program until it has adjusted the svl. + if [gdb_continue_to_breakpoint $sigill_breakpoint] { + return -1 + } + + # Check SVG to make sure it is correct + set expected_svg [expr $svl / 8] + gdb_test "print \$svg" "= ${expected_svg}" + + # Check the size of ZA. + set expected_za_size [expr $svl * $svl] + gdb_test "print sizeof \$za" " = $expected_za_size" + + # Check the value of SVCR. + gdb_test "print \$svcr" [get_svcr_value $state] "svcr before signal" + + # Handle SME ZA initialization and state. + set byte 0 + if { $state == "za" || $state == "za_ssve" } { + set byte 170 + } + + # Set the expected ZA pattern. + set za_pattern [string_to_regexp [2d_array_value_pattern $byte $svl $svl]] + + # Handle SVE/SSVE initialization and state. + set sve_vl $svl + if { $state == "ssve" || $state == "za_ssve" } { + # SVE state comes from SSVE. + set sve_vl $svl + } else { + # SVE state comes from regular SVE. + set sve_vl $vl + } + + # Initialize the SVE state. + set sve_pattern [string_to_regexp [sve_value_pattern $state $sve_vl 85 255]] + for {set row 0} {$row < 32} {incr row} { + set register_name "\$z${row}\.b\.u" + gdb_test "print sizeof $register_name" " = $sve_vl" "size of $register_name" + gdb_test "print $register_name" $sve_pattern "read back from $register_name" + } + + # Print ZA to check its value. + gdb_test "print \$za" $za_pattern "read back from za" + + # Test TPIDR2 restore from signal frame as well. + gdb_test_no_output "set \$tpidr2=0x0102030405060708" + + # Run to the illegal instruction. + if [gdb_test "continue" "Continuing\.\r\n\r\nProgram received signal SIGILL, Illegal instruction\..*in main.*"] { + return + } + + # Skip the illegal instruction. The signal handler will be called after we continue. + gdb_test_no_output "set \$pc=\$pc+4" + # Continue to the signal handler. + if [gdb_continue_to_breakpoint $handler_breakpoint] { + return -1 + } + + # Modify TPIDR2 so it is different from its value past the signal + # frame. + gdb_test_no_output "set \$tpidr2 = 0x0" + + # Select the frame that contains "main". + gdb_test "frame 2" "#2.* main \\\(.*\\\) at.*" + + for {set row 0} {$row < 32} {incr row} { + set register_name "\$z${row}\.b\.u" + gdb_test "print sizeof $register_name" " = $sve_vl" "size of $register_name in the signal frame" + gdb_test "print $register_name" $sve_pattern "$register_name contents from signal frame" + } + + # Check the size of ZA in the signal frame. + set expected_za_size [expr $svl * $svl] + gdb_test "print sizeof \$za" " = $expected_za_size" "size of za in signal frame" + + # Check the value of SVCR in the signal frame. + gdb_test "print \$svcr" [get_svcr_value $state] "svcr from signal frame" + + # Check the value of ZA in the signal frame. + gdb_test "print \$za" $za_pattern "za contents from signal frame" + + # Check the value of TPIDR2 in the signal frame. + gdb_test "print/x \$tpidr2" " = 0x102030405060708" "tpidr2 contents from signal frame" + } + } +} + +require is_aarch64_target + +if {![allow_aarch64_sve_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +if {![allow_aarch64_sme_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +test_sme_registers_sigframe $id_start $id_end diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-0.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-0.exp new file mode 100644 index 00000000000..c758c4862be --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-0.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 0 +set id_end 3 +source $srcdir/$subdir/aarch64-sme-regs-unavailable.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-1.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-1.exp new file mode 100644 index 00000000000..10e27174067 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-1.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 11 +set id_end 15 +source $srcdir/$subdir/aarch64-sme-regs-unavailable.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-2.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-2.exp new file mode 100644 index 00000000000..c1e5e279231 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-2.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 16 +set id_end 19 +source $srcdir/$subdir/aarch64-sme-regs-unavailable.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-3.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-3.exp new file mode 100644 index 00000000000..cbe84dbff9a --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-3.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 20 +set id_end 22 +source $srcdir/$subdir/aarch64-sme-regs-unavailable.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-4.exp b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-4.exp new file mode 100644 index 00000000000..f6f884cb910 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable-4.exp @@ -0,0 +1,18 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +set id_start 23 +set id_end 24 +source $srcdir/$subdir/aarch64-sme-regs-unavailable.exp.tcl diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.c b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.c new file mode 100644 index 00000000000..2dd72ffd5d4 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.c @@ -0,0 +1,154 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Exercise various cases of ZA contents not being available for AArch64's + Scalable Matrix Extension. */ + +#include +#include +#include +#include +#include + +#ifndef HWCAP_SVE +#define HWCAP_SVE (1 << 22) +#endif + +#ifndef HWCAP2_SME +#define HWCAP2_SME (1 << 23) +#endif + +#ifndef PR_SVE_SET_VL +#define PR_SVE_SET_VL 50 +#define PR_SVE_GET_VL 51 +#define PR_SVE_VL_LEN_MASK 0xffff +#endif + +#ifndef PR_SME_SET_VL +#define PR_SME_SET_VL 63 +#define PR_SME_GET_VL 64 +#define PR_SME_VL_LEN_MASK 0xffff +#endif + +static int get_vl_size () +{ + int res = prctl (PR_SVE_GET_VL, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SVE_GET_VL (%d)", res); + return -1; + } + return (res & PR_SVE_VL_LEN_MASK); +} + +static int get_svl_size () +{ + int res = prctl (PR_SME_GET_VL, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SME_GET_VL (%d)", res); + return -1; + } + return (res & PR_SVE_VL_LEN_MASK); +} + +static int set_vl_size (int new_vl) +{ + int res = prctl (PR_SVE_SET_VL, new_vl, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SVE_SET_VL (%d)", res); + return -1; + } + + res = get_vl_size (); + if (res != new_vl) + { + printf ("Unexpected VL value (%d)", res); + return -1; + } + + return res; +} + +static int set_svl_size (int new_svl) +{ + int res = prctl (PR_SME_SET_VL, new_svl, 0, 0, 0, 0); + if (res < 0) + { + printf ("FAILED to PR_SME_SET_VL (%d)", res); + return -1; + } + + res = get_svl_size (); + if (res != new_svl) + { + printf ("Unexpected SVL value (%d)", res); + return -1; + } + + return res; +} + +static int +test_id_to_vl (int id) +{ + return 16 << ((id / 5) % 5); +} + +static int +test_id_to_svl (int id) +{ + return 16 << (id % 5); +} + +static void +dummy () +{ +} + +int +main (int argc, char **argv) +{ + if (getauxval (AT_HWCAP) & HWCAP_SVE && getauxval (AT_HWCAP2) & HWCAP2_SME) + { + int id_start = ID_START; + int id_end = ID_END; + + for (int id = id_start; id <= id_end; id++) + { + int vl = test_id_to_vl (id); + int svl = test_id_to_svl (id); + + if (set_vl_size (vl) == -1) + return -1; + if (set_svl_size (svl) == -1) + return -1; + + dummy (); /* stop 1 */ + } + + dummy (); /* stop 2 */ + } + else + { + printf ("SKIP: no HWCAP_SVE or HWCAP2_SME on this system\n"); + return -1; + } + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl new file mode 100644 index 00000000000..d515fe07b90 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl @@ -0,0 +1,162 @@ +# Copyright (C) 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Exercise the following: +# - Printing ZA registers when there is no ZA state. +# - Setting values of ZA registers when there is no ZA state. +# - Validating ZA state is activated when we write to ZA registers. + +load_lib aarch64.exp + +# +# Validate that the ZA registers have the expected state. +# +proc_with_prefix check_regs { vl svl } { + # Check VG to make sure it is correct + set expected_vg [expr $vl / 8] + gdb_test "print \$vg" "= ${expected_vg}" + + # Check SVG to make sure it is correct + set expected_svg [expr $svl / 8] + gdb_test "print \$svg" "= ${expected_svg}" + + # Make sure there is no SM or ZA state. + if [gdb_test "print \$svcr" "= \\\[ \\\]"] { + fail "incorrect ZA state" + return -1 + } + + # Check the size of ZA. + set expected_za_size [expr $svl * $svl] + gdb_test "print sizeof \$za" " = $expected_za_size" + + # Check the size of Z0. + gdb_test "print sizeof \$z0" " = $vl" + + # Set the expected ZA pattern. + set za_pattern [string_to_regexp [2d_array_value_pattern 0 $svl $svl]] + + # Check ZA. + gdb_test "print \$za" $za_pattern + + # Exercise reading/writing the tile slice pseudo-registers. + set last_tile 1 + set last_slice $svl + set elements $svl + set expected_size $svl + foreach_with_prefix granularity {"b" "h" "s" "d" "q"} { + set pattern [string_to_regexp [1d_array_value_pattern 0 $elements]] + for {set tile 0} {$tile < $last_tile} {incr tile} { + for {set slice 0} {$slice < $last_slice} {incr slice} { + foreach_with_prefix direction {"h" "v"} { + set register_name "\$za${tile}${direction}${granularity}${slice}" + # Test the size. + gdb_test "print sizeof ${register_name}" " = ${expected_size}" + gdb_test "print ${register_name}" $pattern + } + } + } + set last_tile [expr $last_tile * 2] + set last_slice [expr ($last_slice / 2)] + set elements [expr ($elements / 2)] + } + + # Exercise reading/writing the tile pseudo-registers. + set last_tile 1 + set elements $svl + set expected_size [expr $svl * $svl] + foreach_with_prefix granularity {"b" "h" "s" "d" "q"} { + set pattern [string_to_regexp [2d_array_value_pattern 0 $elements $elements]] + for {set tile 0} {$tile < $last_tile} {incr tile} { + set register_name "\$za${tile}${granularity}" + # Test the size. + gdb_test "print sizeof ${register_name}" " = ${expected_size}" + gdb_test "print ${register_name}" $pattern + } + set last_tile [expr $last_tile * 2] + set expected_size [expr $expected_size / 2] + set elements [expr ($elements / 2)] + } +} + +# +# Cycle through all ZA registers and pseudo-registers and validate that their +# contents are unavailable (zeroed out) for vector length SVL. +# +proc test_sme_registers_unavailable { id_start id_end } { + + set compile_flags {"debug" "macros"} + lappend compile_flags "additional_flags=-DID_START=${id_start}" + lappend compile_flags "additional_flags=-DID_END=${id_end}" + + standard_testfile ${::srcdir}/${::subdir}/aarch64-sme-regs-unavailable.c + set executable "${::testfile}-${id_start}-${id_end}" + if {[prepare_for_testing "failed to prepare" ${executable} ${::srcfile} ${compile_flags}]} { + return -1 + } + set binfile [standard_output_file ${executable}] + + if ![runto_main] { + untested "could not run to main" + return -1 + } + + gdb_test_no_output "set print repeats 1" + + set prctl_breakpoint "stop 1" + gdb_breakpoint [gdb_get_line_number $prctl_breakpoint] + + for {set id $id_start} {$id <= $id_end} {incr id} { + set vl [test_id_to_vl $id] + set svl [test_id_to_svl $id] + with_test_prefix "prctl, vl=${vl} svl=${svl}" { + # Run the program until it has adjusted svl. + gdb_continue_to_breakpoint $prctl_breakpoint + check_regs $vl $svl + } + } + + set non_prctl_breakpoint "stop 2" + gdb_breakpoint [gdb_get_line_number $non_prctl_breakpoint] + gdb_continue_to_breakpoint $non_prctl_breakpoint + + for {set id $id_start} {$id <= $id_end} {incr id} { + set vl [test_id_to_vl $id] + set svl [test_id_to_svl $id] + with_test_prefix "non prctl, vl=${vl} svl=${svl}" { + # Adjust vg and svg. + set vg_value [expr $vl / 8] + set svg_value [expr $svl / 8] + gdb_test_no_output "set \$vg = ${vg_value}" + gdb_test_no_output "set \$svg = ${svg_value}" + + check_regs $vl $svl + } + } +} + +require is_aarch64_target + +if {![allow_aarch64_sve_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +if {![allow_aarch64_sme_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +test_sme_registers_unavailable $id_start $id_end diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c new file mode 100644 index 00000000000..694de0626d2 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c @@ -0,0 +1,249 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Sanity test to exercise AArch64's Scalable Vector/Matrix Extension basic + functionality. It cycles through different combinations of state and + initializes different register sets. */ + +#include +#include +#include +#include +#include + +#ifndef HWCAP_SVE +#define HWCAP_SVE (1 << 22) +#endif + +#ifndef HWCAP2_SME +#define HWCAP2_SME (1 << 23) +#endif + +static void +enable_za () +{ + /* smstart za */ + __asm __volatile (".word 0xD503457F"); +} + +static void +disable_za () +{ + /* smstop za */ + __asm __volatile (".word 0xD503447F"); +} + +static void +enable_sm () +{ + /* smstart sm */ + __asm __volatile (".word 0xD503437F"); +} + +static void +disable_sm () +{ + /* smstop sm */ + __asm __volatile (".word 0xD503427F"); +} + +static void +initialize_fpsimd_state () +{ + char buffer[16]; + + for (int i = 0; i < 16; i++) + buffer[i] = 0x55; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + __asm __volatile ("ldr q0, [x0]"); + __asm __volatile ("ldr q1, [x0]"); + __asm __volatile ("ldr q2, [x0]"); + __asm __volatile ("ldr q3, [x0]"); + __asm __volatile ("ldr q4, [x0]"); + __asm __volatile ("ldr q5, [x0]"); + __asm __volatile ("ldr q6, [x0]"); + __asm __volatile ("ldr q7, [x0]"); + __asm __volatile ("ldr q8, [x0]"); + __asm __volatile ("ldr q9, [x0]"); + __asm __volatile ("ldr q10, [x0]"); + __asm __volatile ("ldr q11, [x0]"); + __asm __volatile ("ldr q12, [x0]"); + __asm __volatile ("ldr q13, [x0]"); + __asm __volatile ("ldr q14, [x0]"); + __asm __volatile ("ldr q15, [x0]"); + __asm __volatile ("ldr q16, [x0]"); + __asm __volatile ("ldr q17, [x0]"); + __asm __volatile ("ldr q18, [x0]"); + __asm __volatile ("ldr q19, [x0]"); + __asm __volatile ("ldr q20, [x0]"); + __asm __volatile ("ldr q21, [x0]"); + __asm __volatile ("ldr q22, [x0]"); + __asm __volatile ("ldr q23, [x0]"); + __asm __volatile ("ldr q24, [x0]"); + __asm __volatile ("ldr q25, [x0]"); + __asm __volatile ("ldr q26, [x0]"); + __asm __volatile ("ldr q27, [x0]"); + __asm __volatile ("ldr q28, [x0]"); + __asm __volatile ("ldr q29, [x0]"); + __asm __volatile ("ldr q30, [x0]"); + __asm __volatile ("ldr q31, [x0]"); +} + +static void +initialize_za_state () +{ + /* zero za */ + __asm __volatile (".word 0xC00800FF"); + + char buffer[256]; + + for (int i = 0; i < 256; i++) + buffer[i] = 0xaa; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize loop boundaries. */ + __asm __volatile ("mov w12, 0"); + __asm __volatile ("mov w17, 256"); + + /* loop: ldr za[w12, 0], [x0] */ + __asm __volatile ("loop: .word 0xe1000000"); + __asm __volatile ("add w12, w12, 1"); + __asm __volatile ("cmp w12, w17"); + __asm __volatile ("bne loop"); +} + +static void +initialize_sve_state () +{ + __asm __volatile ("dup z0.b, -1"); + __asm __volatile ("dup z1.b, -1"); + __asm __volatile ("dup z2.b, -1"); + __asm __volatile ("dup z3.b, -1"); + __asm __volatile ("dup z4.b, -1"); + __asm __volatile ("dup z5.b, -1"); + __asm __volatile ("dup z6.b, -1"); + __asm __volatile ("dup z7.b, -1"); + __asm __volatile ("dup z8.b, -1"); + __asm __volatile ("dup z9.b, -1"); + __asm __volatile ("dup z10.b, -1"); + __asm __volatile ("dup z11.b, -1"); + __asm __volatile ("dup z12.b, -1"); + __asm __volatile ("dup z13.b, -1"); + __asm __volatile ("dup z14.b, -1"); + __asm __volatile ("dup z15.b, -1"); + __asm __volatile ("dup z16.b, -1"); + __asm __volatile ("dup z17.b, -1"); + __asm __volatile ("dup z18.b, -1"); + __asm __volatile ("dup z19.b, -1"); + __asm __volatile ("dup z20.b, -1"); + __asm __volatile ("dup z21.b, -1"); + __asm __volatile ("dup z22.b, -1"); + __asm __volatile ("dup z23.b, -1"); + __asm __volatile ("dup z24.b, -1"); + __asm __volatile ("dup z25.b, -1"); + __asm __volatile ("dup z26.b, -1"); + __asm __volatile ("dup z27.b, -1"); + __asm __volatile ("dup z28.b, -1"); + __asm __volatile ("dup z29.b, -1"); + __asm __volatile ("dup z30.b, -1"); + __asm __volatile ("dup z31.b, -1"); + __asm __volatile ("ptrue p0.b"); + __asm __volatile ("ptrue p1.b"); + __asm __volatile ("ptrue p2.b"); + __asm __volatile ("ptrue p3.b"); + __asm __volatile ("ptrue p4.b"); + __asm __volatile ("ptrue p5.b"); + __asm __volatile ("ptrue p6.b"); + __asm __volatile ("ptrue p7.b"); + __asm __volatile ("ptrue p8.b"); + __asm __volatile ("ptrue p9.b"); + __asm __volatile ("ptrue p10.b"); + __asm __volatile ("ptrue p11.b"); + __asm __volatile ("ptrue p12.b"); + __asm __volatile ("ptrue p13.b"); + __asm __volatile ("ptrue p14.b"); + __asm __volatile ("ptrue p15.b"); + __asm __volatile ("setffr"); +} + +/* Enable register states based on STATE. + + 0 - FPSIMD + 1 - SVE + 2 - SSVE + 3 - ZA + 4 - ZA and SSVE. */ + +void enable_states (int state) +{ + disable_za (); + disable_sm (); + initialize_fpsimd_state (); + + if (state == 1) + { + initialize_sve_state (); + } + else if (state == 2) + { + enable_sm (); + initialize_sve_state (); + } + else if (state == 3) + { + enable_za (); + initialize_za_state (); + } + else if (state == 4) + { + enable_za (); + enable_sm (); + initialize_sve_state (); + initialize_za_state (); + } + + return; +} + +void dummy () +{ +} + +int +main (int argc, char **argv) +{ + if (getauxval (AT_HWCAP) & HWCAP_SVE && getauxval (AT_HWCAP2) & HWCAP2_SME) + { + for (int state = 0; state < 5; state++) + { + enable_states (state); + dummy (); /* stop here */ + } + } + else + { + printf ("SKIP: no HWCAP_SVE or HWCAP2_SME on this system\n"); + return -1; + } + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp new file mode 100644 index 00000000000..c96df7543e0 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp @@ -0,0 +1,72 @@ +# Copyright (C) 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Sanity check for AArch64 Scalable Vector/Matrix Extensions functionality. + +load_lib aarch64.exp + +# +# Run a series of basic checks for SVE/SME states. +# +proc sanity_check { vl svl } { + # Run the program until the point where we start initializing the different + # register states. + set state_breakpoint "stop here" + gdb_breakpoint [gdb_get_line_number $state_breakpoint] + + for {set id 0} {$id < 5} {incr id} { + set state [state_id_to_state_string $id] + + with_test_prefix "state=${state} vl=${vl} svl=${svl}" { + gdb_continue_to_breakpoint $state_breakpoint + check_state $state $vl $svl + } + } +} + +require is_aarch64_target + +if {![allow_aarch64_sve_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +if {![allow_aarch64_sme_tests]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +set compile_flags {"debug" "macros" "additional_flags=-march=armv8.5-a+sve"} +standard_testfile +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ${compile_flags}]} { + return -1 +} + +if {![runto_main]} { + return -1 +} + +# Adjust the repeat count for the test. +gdb_test_no_output "set print repeats 1" "adjust repeat count" + +# Fetch both the vector length and the streaming vector length the target +# system is using. We do not force any vector lengths and do not change +# it mid-execution. +set vl [expr [get_valueof "" "\$vg" "0" "fetch value of vl"] * 8] +set svl [expr [get_valueof "" "\$svg" "0" "fetch value of svl"] * 8] + +# Now we are at the point where we can start checking state and moving the +# testcase forward. +sanity_check $vl $svl diff --git a/gdb/testsuite/lib/aarch64.exp b/gdb/testsuite/lib/aarch64.exp new file mode 100644 index 00000000000..076964e2028 --- /dev/null +++ b/gdb/testsuite/lib/aarch64.exp @@ -0,0 +1,372 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +# Support routines for aarch64-specific tests + +# +# Return a regular expression that matches what gdb would print for a +# 1-dimension vector containing ELEMENTS elements of value BYTE. +# +# The pattern is of the form "{BYTE ". +# +proc 1d_array_value_pattern { byte elements } { + set brace_open "{" + set brace_close "}" + + append data $brace_open $byte + if {$elements > 1} { + append data " " + } + append data $brace_close + + verbose -log "1d_array_value_pattern Pattern string is..." + verbose -log $data + return $data +} + +# +# Return a regular expression that matches what gdb would print for a +# 2-dimension vector containing ROWS rows and COLUMNS columns of elements +# of value BYTE. +# +# The pattern is of the form +# "{{BYTE } }". +# +proc 2d_array_value_pattern { byte rows columns } { + set brace_open "{" + set brace_close "}" + + append data $brace_open [1d_array_value_pattern $byte $columns] + if {$rows > 1} { + append data " " + } + append data $brace_close + + verbose -log "2d_array_value_pattern Pattern string is..." + verbose -log $data + return $data +} + +# +# Return a regular expression that matches what gdb would print for a +# SVE Z register of length VL in state STATE. The Z register should be filled +# with BYTE_SVE and the FPSIMD registers should be filled with BYTE_FPSIMD. +# +# The pattern is of the form +# +# {BYTE_FPSIMD } +# +# or +# +# {BYTE_FPSIMD , 0 } +# +# or +# +# {BYTE_SVE } +# +proc sve_value_pattern { state vl byte_fpsimd byte_sve } { + set brace_open "{" + set brace_close "}" + + append data $brace_open + if { $state == "fpsimd" || $state == "za" } { + if { $vl > 16 } { + set sve_repeat_count [expr $vl - 16] + append data "$byte_fpsimd , 0 " + } else { + append data "$byte_fpsimd " + } + } else { + append data "$byte_sve " + } + append data $brace_close + + verbose -log "sve_value_pattern pattern string is..." + verbose -log $data + return $data +} + +# +# Initialize register NAME, a 1-dimension vector, with ELEMENTS elements +# by setting all elements to BYTE. ELEMENTS is limited at 256 for memory +# usage purposes. +# +# The initialization is of the form "{BYTE, BYTE, BYTE ...}". +# +proc initialize_1d_array { name byte elements } { + set brace_open "{" + set brace_close "}" + + append data $brace_open + + # Build the assignment in a single shot. + for {set element 0} {$element < $elements} {incr element} { + # Construct the initializer by appending elements to it. + append data $byte + + # If this isn't the last element, add a comma. + if {[expr $element + 1] < $elements} { + append data ", " + } + } + append data $brace_close + + verbose -log "initialization string is..." + verbose -log $data + gdb_test_no_output "set $name = $data" "write to $name" +} + +# +# Return an initializer string for a 2-dimension vector with ROWS rows and +# COLUMNS columns, initializing all elements to BYTE for register NAME. +# +# COLUMNS is limited to 256 elements for memory usage purposes. +# +# The initialization is of the form "{{BYTE, BYTE}, ..., {BYTE, BYTE}}}". +# +proc initialize_2d_array { name byte rows columns } { + set brace_open "{" + set brace_close "}" + + if {[expr $rows * $columns] <= 256} { + # Build the assignment in a single shot, as we have a maximum of 256 + # elements. + for {set row 0} {$row < $rows} {incr row} { + append data $brace_open + for {set column 0} {$column < $columns} {incr column} { + # Construct the initializer by appending elements to it. + append data $byte + + # If this isn't the last column, add a comma. + if {[expr $column + 1] < $columns} { + append data ", " + } + } + + append data $brace_close + + # If this isn't the last row, add a comma. + if {[expr $row + 1] < $rows} { + append data "," + } + } + + set data $brace_open$data + set data $data$brace_close + + verbose -log "initialization string is..." + verbose -log $data + gdb_test_no_output "set $name = $data" "write to $name" + } else { + # There are too many elements to initialize (more than 256), so we + # will do the initialization row by row. + for {set row 0} {$row < $rows} {incr row} { + initialize_1d_array "$name\[$row\]" $byte $columns + } + } +} + +# +# Return the SVCR value based STATE. +# +proc get_svcr_value { state } { + if { $state == "ssve" } { + return "= \\\[ SM \\\]" + } elseif { $state == "za" } { + return "= \\\[ ZA \\\]" + } elseif { $state == "za_ssve" } { + return "= \\\[ SM ZA \\\]" + } + + return "= \\\[ \\\]" +} + +# +# Return the state string based on STATE +# +proc state_id_to_state_string { state } { + if {$state == 0} { + return "fpsimd" + } elseif {$state == 1} { + return "sve" + } elseif {$state == 2} { + return "ssve" + } elseif {$state == 3} { + return "za" + } elseif {$state == 4} { + return "za_ssve" + } +} + +# +# Given a test ID, return the string representing the register state. +# The state is one of fpsimd, sve, ssve, za and za_ssve. +# +proc test_id_to_state { id } { + set state [expr $id / 25] + + return [state_id_to_state_string $state] +} + +# +# Given a test ID, return the associated vector length. +# +proc test_id_to_vl { id } { + return [expr 16 << (($id / 5) % 5)] +} + +# +# Given a test ID, return the associated streaming vector length. +# +proc test_id_to_svl { id } { + return [expr 16 << ($id % 5)] +} + +# +# Validate the values of the FPSIMD registers. +# +proc check_fpsimd_regs { byte state vl svl} { + set fpsimd_pattern [string_to_regexp [1d_array_value_pattern $byte 16]] + + for {set number 0} {$number < 32} {incr number} { + set register_name "\$v${number}\.b\.u" + gdb_test "print sizeof $register_name" " = 16" + gdb_test "print $register_name" $fpsimd_pattern + } +} + +# +# Validate the values of the SVE registers. +# +proc check_sve_regs { byte state vl svl } { + + # If streaming mode is enabled, the vector length is the streaming + # vector length. + set z_pattern "" + set z_size 0 + if {$state == "ssve" || $state == "za_ssve"} { + set z_pattern [string_to_regexp [1d_array_value_pattern $byte $svl]] + set z_size $svl + } else { + set z_size $vl + + if {$state == "fpsimd" || $state == "za"} { + # If there is no SVE/SSVE state, the contents of the Z/P/FFR registers + # are zero. + if {$vl == 16} { + set z_pattern [string_to_regexp [1d_array_value_pattern $byte $vl]] + } else { + set z_repeats [expr $vl - 16] + set z_pattern [string_to_regexp "{$byte , 0 }"] + } + } else { + set z_pattern [string_to_regexp [1d_array_value_pattern $byte $vl]] + } + } + set p_size [expr $z_size / 8] + + # If there is no SVE/SSVE state, the contents of the Z/P/FFR registers + # are zero. + set p_byte $byte + if {$state == "fpsimd" || $state == "za"} { + set p_byte 0 + } + set p_pattern [string_to_regexp [1d_array_value_pattern $p_byte $p_size]] + + for {set number 0} {$number < 32} {incr number} { + set register_name "\$z${number}\.b\.u" + gdb_test "print sizeof $register_name" " = $z_size" + gdb_test "print $register_name" $z_pattern + } + + for {set number 0} {$number < 16} {incr number} { + set register_name "\$p${number}" + gdb_test "print sizeof $register_name" " = $p_size" + gdb_test "print $register_name" $p_pattern + } + + gdb_test "print \$ffr" $p_pattern +} + +# +# Validate the values of the SME registers. +# +proc check_sme_regs { byte state svl } { + # ZA contents are only available when the ZA state is enabled. Otherwise + # the ZA contents are unavailable (zeroed out). + set za_pattern "" + set expected_za_size [expr $svl * $svl] + + if {$state != "za" && $state != "za_ssve"} { + set byte 0 + } + + set za_pattern [string_to_regexp [2d_array_value_pattern $byte $svl $svl]] + + gdb_test "print sizeof \$za" " = $expected_za_size" + gdb_test "print \$za" $za_pattern +} + +# +# With register STATE, vector length VL and streaming vector length SVL, +# run some register state checks to make sure the values are the expected +# ones +# +proc check_state { state vl svl } { + # The FPSIMD registers are initialized with a value of 0x55 (125) + # for each byte. + # + # The SVE registers are initialized with a value of 0xff (255) for each + # byte, including the predicate registers and FFR. + # + # The SME (ZA) register is initialized with a value of 0xaa (252) for + # each byte. + + # Check VG to make sure it is correct + set expected_vg [expr $vl / 8] + # If streaming mode is enabled, then vg is actually svg. + if {$state == "ssve" || $state == "za_ssve"} { + set expected_vg [expr $svl / 8] + } + gdb_test "print \$vg" " = ${expected_vg}" + + # Check SVG to make sure it is correct + set expected_svg [expr $svl / 8] + gdb_test "print \$svg" " = ${expected_svg}" + + # Check the value of SVCR. + gdb_test "print \$svcr" [get_svcr_value $state] + + # When we have any SVE or SSVE state, the FPSIMD registers will have + # the same values as the SVE/SSVE Z registers. + set fpsimd_byte 85 + if {$state == "sve" || $state == "ssve" || $state == "za_ssve"} { + set fpsimd_byte 255 + } + + set sve_byte 255 + if {$state == "fpsimd" || $state == "za"} { + set sve_byte 85 + } + + # Check FPSIMD registers + check_fpsimd_regs $fpsimd_byte $state $vl $svl + # Check SVE registers + check_sve_regs $sve_byte $state $vl $svl + # Check SME registers + check_sme_regs 170 $state $svl +} + + diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 133d914aff8..7b5c641d0cc 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4085,6 +4085,69 @@ gdb_caching_proc allow_aarch64_sve_tests {} { return $allow_sve_tests } +# Run a test on the target to see if it supports Aarch64 SME extensions. +# Return 0 if so, 1 if it does not. Note this causes a restart of GDB. + +gdb_caching_proc allow_aarch64_sme_tests {} { + global srcdir subdir gdb_prompt inferior_exited_re + + set me "allow_aarch64_sme_tests" + + if { ![is_aarch64_target]} { + return 0 + } + + set compile_flags "{additional_flags=-march=armv8-a+sme}" + + # Compile a test program containing SVE instructions. + set src { + int main() { + asm volatile ("smstart za"); + return 0; + } + } + if {![gdb_simple_compile $me $src executable $compile_flags]} { + # Try again, but with a raw hex instruction so we don't rely on + # assembler support for SME. + + set compile_flags "{additional_flags=-march=armv8-a}" + + # Compile a test program containing SVE instructions. + set src { + int main() { + asm volatile (".word 0xD503457F"); + return 0; + } + } + + if {![gdb_simple_compile $me $src executable $compile_flags]} { + return 0 + } + } + + # Compilation succeeded so now run it via gdb. + clean_restart $obj + gdb_run_cmd + gdb_expect { + -re ".*Illegal instruction.*${gdb_prompt} $" { + verbose -log "\n$me sme support not detected" + set allow_sme_tests 0 + } + -re ".*$inferior_exited_re normally.*${gdb_prompt} $" { + verbose -log "\n$me: sme support detected" + set allow_sme_tests 1 + } + default { + warning "\n$me: default case taken" + set allow_sme_tests 0 + } + } + gdb_exit + remote_file build delete $obj + + verbose "$me: returning $allow_sme_tests" 2 + return $allow_sme_tests +} # A helper that compiles a test case to see if __int128 is supported. proc gdb_int128_helper {lang} { From patchwork Fri May 19 10:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69676 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 AF60A3836E9F for ; Fri, 19 May 2023 10:28:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF60A3836E9F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492113; bh=VIBUNMwddr564ZBDY4z5u75eS6IbkTze4ZkIsJxm0Vw=; 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=atMy49qxT8EGorjebkr+DBDFtUfWwoSaDF18COJQ2BL5P9V3fv+piQoG1dK/2Qweu wSOtsDm29lK13jS13KkCrETvqah4S7FiSZ9yzG5gp8SqD+qRD5XaLjowJ8hrISGvEW vmzWtTR0uyAcRqqDiB6pMnffEjdV8YC1NPW6foy4= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2042.outbound.protection.outlook.com [40.107.247.42]) by sourceware.org (Postfix) with ESMTPS id 674A03858412 for ; Fri, 19 May 2023 10:25:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 674A03858412 Received: from AM7PR03CA0011.eurprd03.prod.outlook.com (2603:10a6:20b:130::21) by GV1PR08MB7985.eurprd08.prod.outlook.com (2603:10a6:150:9f::20) 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:26 +0000 Received: from AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:130:cafe::81) by AM7PR03CA0011.outlook.office365.com (2603:10a6:20b:130::21) 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:26 +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 AM7EUR03FT058.mail.protection.outlook.com (100.127.140.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:26 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Fri, 19 May 2023 10:25:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bba31486d77bf037 X-CR-MTA-TID: 64aa7808 Received: from f441d7add428.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F778EB68-75AD-4150-B7D3-793FD410CE19.1; Fri, 19 May 2023 10:25:19 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f441d7add428.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eIukRAFXHwTTHWJaZSj7RItphXlkoTItbL3vwPhI8FVJI/NqHI383xh9sOsk6BYAKOHNAgjiueZq7/72bWvJZrHWFWC2rwSHv74mQbS/ywhepOUpqRtWji5GKxuyx4F982f0x90PDHf4HRgqTHqe/Idb7BSXRydR/6HLhsg+7j6Cdf4Ymem3Ag+eIYXM73/vdajy6aQM4bzbxGnsOvLeE6jMRDDzB7F5QenkTnPjHc3mu44eKh4rB4zZb8lYeNynAyTftnRiUjLc9ULAvqwasMznlxj2LRmYZdOnPGX85SEEdSthhEc6SieLkf/ioC8N8VYoB26Ib69E+jrM3tGVwg== 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=VIBUNMwddr564ZBDY4z5u75eS6IbkTze4ZkIsJxm0Vw=; b=Hg7faRw9kHB4x6fV9dzJAUKbtGFe2AJURIY2kVp/HdSdHbz8Fh3VYrSlwyaIaMO/Pw/tAxJrK62PTw+Q0McLunZk37Q/IGvvUo1fkX6NsPiOlntS9ksAhCX01W7o3CP9uG/qLVCp3zZCzLVvJ/9yE5MKgA6lnS35vEcs3fkLEJlEOl+9iBviMJxx/b8+L0SxHRIKjrsluBAdgYdhDYXHvvOJ03PD2GdsFV1GQDP2IAQ3lXK3xsmJX2vr4pWRnREEDrna3h7MvuBz038RE+P0pGS204llImWUtu9V+s0fAFae8oNGiNL9wchTtzFeR7hXWBGCvOsvUcRZxn7cGHF6GQ== 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 AM6PR10CA0104.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::45) by AS8PR08MB5974.eurprd08.prod.outlook.com (2603:10a6:20b:298::19) 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:17 +0000 Received: from AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::b0) by AM6PR10CA0104.outlook.office365.com (2603:10a6:209:8c::45) 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:17 +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.6433.7 via Frontend Transport; Fri, 19 May 2023 10:25:17 +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:14 +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:13 +0000 To: Subject: [PATCH v3 17/17] [gdb/docs] sme: Document SME registers and features Date: Fri, 19 May 2023 11:25:08 +0100 Message-ID: <20230519102508.14020-18-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: AM7EUR03FT027:EE_|AS8PR08MB5974:EE_|AM7EUR03FT058:EE_|GV1PR08MB7985:EE_ X-MS-Office365-Filtering-Correlation-Id: 41d768e9-e284-4a91-0bdf-08db58535c8c 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: ctRm4nfcgs1M4Oh0+N9+bK84/1QBnUKFTOlaA0/J/TTKOQEpuhVdnCMOOm/8HC65/4hZP+ZcWmzD85DV3kcXgzyJgQL9IJKgc3VzOMgoFsRsBga9ifmV8OVQWBNFmXTWUSeAKPHwkg6XEHQdIepjX1VKPpfcKB1yVh3LrfzXqWwu7m78mwsrLWLRj33LoWbO2UOxpgrI2hDpKz9dpaaZx/kUT6yVvuUSLFBvMVLYoHKYEq2nZY8B0XZlcddT9Nf+VH3BPf4WjJTW5VGIdzzDw/ujpkRkIPcKz6JHGQzcwcdTa7jis/BXlRKmRxVd8bDSLQqw5JkhPCIYSGpqeDk+EU1JwqwRSQHddO6vIEUJgRt8iBmXvoMb1UyjXnkem4gleerlq0SE54JmMraNHKAVUMp13RdMOOUOOI9GgPq+xsupMX+Tan2TBJa/RZ3WhQGOieTwjHMi63+eKMZg9oqwD8IpGeQqzGwxUJZ0jtkO1TkWetTY9AUYrlq/spGKhdsolfIlo6J+UXXEp6dZHEkVEKoGwogP1lv3MZ1v/87EuRJnlzgqp+NZ2z5bFOWHWKLLM2QeYxyQe8humpg5gCHfPDMQmWtIp9cBD2KjYbOlbsBJXrDmxtmZvZgPQeLomdCg9OJsb1JfZLRTtPnRVSfrd+vBLhi8rK5KYDJweMB8ByiluCWBlPjUpkRiklxbUGYloLzdQb6NXbbCdLs/CQetwAGRb3WtGcm+v3Tfx1dRf6ngEDXlRegumHHfKNVkaljn6W45ByogxVY8E3ICCurHqq7Ie3QX/BM31VLHD+88xHg= 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)(346002)(39860400002)(376002)(136003)(451199021)(36840700001)(46966006)(40470700004)(5660300002)(40460700003)(41300700001)(2906002)(36756003)(47076005)(426003)(36860700001)(83380400001)(2616005)(336012)(356005)(81166007)(1076003)(82310400005)(86362001)(82740400003)(30864003)(8936002)(26005)(44832011)(8676002)(40480700001)(186003)(7696005)(6666004)(70206006)(70586007)(478600001)(6916009)(316002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5974 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 75902b66-e90a-4eb0-3bcc-08db58535728 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uGeMk2nkHA3uS2FF5gg4WrjpxOVzvuv3+TDUIbRZlm9m7AYgk6WiR6jZkCWvI20mOU1AOOz7v8CPvftKvkdYb2ZU+xALZwLy3FeaI6YNV7PNBgSdPqJfNvmwV3ABrze1Kvr6+yLYeH8C7RIW7oswy1l2fhk/9SUxfX8cOBSEPS0frUJoFbREAM3szxtTxjSOBYNDsIyno884v/8uJRLdKewGcWTqIgC1dfNy2UYGP5S+M8xf3D/mvxT2AXSX/GFku/mS5xsrvuNUB38/X+a0LLoIWYJtaZC6OyfW/Xr8a1/S7v31VOYOS3AjcmpLqNHfqCBUrdxULB+4znmxXCcu3lvlTdXrUB+tA4MgNU1INnqTrjwIZLKUOBsWniBtvJ7OdCc4gZceD+opXws3JXSzsDcU2uiPLdOX2r79rJ3azEvr+MAxsYxCLfrVO//QF464GIO5guk/fab8mmDW4Euey6wOMX8Rp1CLr4Fy36RS68p/AEFnc3Bi8q4Ki/cQV+OWwfB/aXqCAZKjEDF0ClhNbeTkX+bINLomq+vAEbwrd7xxEIZHjEqDxF9P3fuV93aQlUJ1KShJ+vQ/J99GxKRJc7gDYQtVzIEr/o2o6VYv17lhFPs+A8FhU4ydSl2JU0rTv4J7rN/2qI7xHnEobioxM24f2W85yGhNtEItQzBoC+DFktWEMDZvoXCKMRJemhj3q9YkpsxEXVlP7p9Q26bQ6emQ8GCsWXg17xAKBAA+J+rbTvmS9CLwB1QQOAnRl10oJy/7EqSpnK1x4wIUA97ksQ== 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)(39860400002)(376002)(346002)(396003)(136003)(451199021)(40470700004)(46966006)(36840700001)(86362001)(36756003)(6916009)(70586007)(316002)(478600001)(70206006)(44832011)(82310400005)(8676002)(7696005)(40480700001)(5660300002)(30864003)(8936002)(6666004)(2906002)(81166007)(41300700001)(82740400003)(2616005)(426003)(1076003)(36860700001)(336012)(26005)(83380400001)(47076005)(186003)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:26.0487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41d768e9-e284-4a91-0bdf-08db58535c8c 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: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7985 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" Updates since v2: - More adjustments based on reviews. - Fixed incorrect number of tile pseudo-registers. - Fixed naming of tile slice pseudo-registers. - More detail about SME and how gdb implements it. - Attempted to clarify the text a bit more. Updates since v1: - Made SME text more thorough. - Adjusted text based on upstream reviews. - Fixed documentation errors (missing itemization for SME registers). Provide documentation for the SME feature and other information that should be useful for users that need to debug a SME-capable target. Reviewed-By: Eli Zaretskii Signed-off-by: Luis Machado Reviewed-By: Eli Zaretskii --- gdb/NEWS | 11 ++ gdb/doc/gdb.texinfo | 249 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 260 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index b82114d80b0..579afde159c 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,17 @@ *** Changes since GDB 13 +* GDB now supports the AArch64 Scalable Matrix Extension (SME), which includes + a new matrix register named ZA, a new thread register TPIDR2 and a new vector + length register SVG (streaming vector granule). GDB also supports tracking + ZA state across signal frames. + + Some features are still under development or are dependent on ABI specs that + are still in alpha stage. For example, manual function calls with ZA state + don't have any special handling, and tracking of SVG changes based on + DWARF information is still not implemented, but there are plans to do so in + the future. + * The AArch64 'org.gnu.gdb.aarch64.pauth' Pointer Authentication feature string has been deprecated in favor of the 'org.gnu.gdb.aarch64.pauth_v2' feature string. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f23bcc5f3f8..5da93b870d9 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26056,6 +26056,224 @@ but the lengths of the @code{z} and @code{p} registers will not change. This is a known limitation of @value{GDBN} and does not affect the execution of the target process. +For SVE, the following definitions are used throughout @value{GDBN}'s source +code and in this document: + +@itemize + +@item +@var{vl}: The vector length, in bytes. It defines the size of each @code{z} +register. +@anchor{vl} +@cindex vl + +@item +@var{vq}: The number of 128 bit units in @var{vl}. This is mostly used +internally by @value{GDBN} and the Linux Kernel. +@anchor{vq} +@cindex vq + +@item +@var{vg}: The number of 64 bit units in @var{vl}. This is mostly used +internally by @value{GDBN} and the Linux Kernel. +@anchor{vg} +@cindex vg + +@end itemize + +@subsubsection AArch64 SME. +@anchor{AArch64 SME} +@cindex SME +@cindex AArch64 SME +@cindex Scalable Matrix Extension + +The Scalable Matrix Extension (@url{https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/scalable-matrix-extension-armv9-a-architecture, @acronym{SME}}) +is an AArch64 architecture extension that expands on the concept of the +Scalable Vector Extension (@url{https://developer.arm.com/documentation/101726/4-0/Learn-about-the-Scalable-Vector-Extension--SVE-/What-is-the-Scalable-Vector-Extension-, @acronym{SVE}}) +by providing a 2-dimensional register @code{za}, which is a square +matrix of variable size, just like SVE provides a group of vector registers of +variable size. + +Similarly to SVE, where the size of each @code{Z} register is directly related +to the vector length (@var{vl} for short), the @acronym{SME} @code{za} matrix +register's size is directly related to the streaming vector length +(@var{svl} for short). @xref{vl} @xref{svl} + +The @code{za} register state can be either active or inactive, if it is not in +use. + +@acronym{SME} also introduces a new execution mode called streaming +@acronym{SVE} mode (streaming mode for short). When streaming mode is +enabled, the program supports execution of @acronym{SVE2} instructions and the +@acronym{SVE} registers will have vector length @var{svl}. When streaming +mode is disabled, the SVE registers have vector length @var{vl}. + +For more information about @acronym{SME} and @acronym{SVE}, please refer to +official @url{https://developer.arm.com/documentation/ddi0487/latest, +architecture documentation}. + +The following definitions are used throughout @value{GDBN}'s source code and +in this document: + +@itemize + +@item +@var{svl}: The streaming vector length, in bytes. It defines the size of each +dimension of the 2-dimensional square @code{za} matrix. The total size of +@code{za} is therefore @var{svl} by @var{svl}. + +When streaming mode is enabled, it defines the size of the @acronym{SVE} +registers as well. +@anchor{svl} +@cindex svl + +@item +@var{svq}: The number of 128 bit units in @var{svl}, also known as streaming +vector granule. This is mostly used internally by @value{GDBN} and the Linux +Kernel. +@anchor{svq} +@cindex svq + +@item +@var{svg}: The number of 64 bit units in @var{svl}. This is mostly used +internally by @value{GDBN} and the Linux Kernel. +@anchor{svg} +@cindex svg + +@end itemize + +When @value{GDBN} is debugging the AArch64 architecture, if the Scalable Matrix +Extension (@acronym{SME}) is present, then @value{GDBN} will make the @code{za} +register available. @value{GDBN} will also make the @var{svg} register and +@code{svcr} pseudo-register available. + +The @code{za} register is a 2-dimensional square @var{svl} by @var{svl} +matrix of bytes. To simplify the representation and access to the @code{za} +register in @value{GDBN}, it is defined as a vector of +@var{svl}x@var{svl} bytes. + +If the user wants to index the @code{za} register as a matrix, it is possible +to reference @code{za} as @code{za[@var{i}][@var{j}]}, where @var{i} is the +row number and @var{j} is the column number. + +The @var{svg} register always contains the streaming vector granule +(@var{svg}) for the current thread. From @var{svg} we can easily derive +the @var{svl} value. + +@anchor{aarch64 sme svcr} +The @code{svcr} pseudo-register (streaming vector control register) is a status +register that holds two state bits: @sc{sm} in bit 0 and @sc{za} in bit 1. + +If the @sc{sm} bit is 1, it means the current thread is in streaming +mode, and the @acronym{SVE} registers will use @var{svl} for their sizes. If +the @sc{sm} bit is 0, the current thread is not in streaming mode, and the +@acronym{SVE} registers will use @var{vl} for their sizes. @xref{vl}. + +If the @sc{za} bit is 1, it means the @code{za} register is being used and +has meaningful contents. If the @sc{za} bit is 0, the @code{za} register is +unavailable and its contents are undefined. + +For convenience and simplicity, if the @sc{za} bit is 0, the @code{za} +register and all of its pseudo-registers will read as zero. + +If @var{svl} changes during the execution of a program, then the @code{za} +register size and the bits in the @code{svcr} pseudo-register will be updated +to reflect it. + +It is possible for users to change @var{svl} during the execution of a +program by modifying the @var{svg} register value. + +Whenever the @var{svg} register is modified with a new value, the +following will be observed: + +@itemize + +@item The @sc{za} and @sc{sm} bits will be cleared in the @code{svcr} +pseudo-register. + +@item The @code{za} register will have a new size and its state will be +cleared, forcing its contents and the contents of all of its pseudo-registers +back to zero. + +@item If the @sc{sm} bit was 1, the @acronym{SVE} registers will be reset to +having their sizes based on @var{vl} as opposed to @var{svl}. If the +@sc{sm} bit was 0 prior to modifying the @var{svg} register, there will be no +observable effect on the @acronym{SVE} registers. + +@end itemize + +The possible values for the @var{svg} register are 2, 4, 8, 16, 32. These +numbers correspond to streaming vector length (@var{svl}) values of 16 +bytes, 32 bytes, 64 bytes, 128 bytes and 256 bytes respectively. + +The minimum size of the @code{za} register is 16 x 16 (256) bytes, and the +maximum size is 256 x 256 (65536) bytes. In streaming mode, with bit @sc{sm} +set, the size of the @code{za} register is the size of all the SVE @code{z} +registers combined. + +The @code{za} register can also be accessed using tiles and tile slices. + +Tile pseudo-registers are square, 2-dimensional sub-arrays of elements within +the @code{za} register. + +There is a total of 31 @code{za} tile pseudo-registers. They are +@code{za0b}, @code{za0h} through @code{za1h}, @code{zas0} through @code{zas3}, +@code{zad0} through @code{zad7} and @code{zaq0} through @code{zaq15}. + +Tile slice pseudo-registers are vectors of horizontally or vertically +contiguous elements within the @code{za} register. + +The tile slice pseudo-registers have the following naming pattern: +@code{za<@var{tile number}><@var{direction}><@var{qualifier}> +<@var{slice number}>}. + +There are up to 16 tiles (0 ~ 15), the direction can be either @code{v} +(vertical) or @code{h} (horizontal), the qualifiers can be @code{b} (byte), +@code{h} (halfword), @code{s} (word), @code{d} (doubleword) and @code{q} +(quadword) and there are up to 256 slices (0 ~ 255) depending on the value +of @var{svl}. The number of slices is the same as the value of @var{svl}. + +The number of available tile slice pseudo-registers can be large. For a +minimum @var{svl} of 16 bytes, there are 5 (number of qualifiers) x +2 (number of directions) x 16 (@var{svl}) pseudo-registers. For the +maximum @var{svl} of 256 bytes, there are 5 x 2 x 256 pseudo-registers. + +When listing all the available registers, users will see the +currently-available @code{za} pseudo-registers. Pseudo-registers that don't +exist for a given @var{svl} value will not be displayed. + +For more information on @acronym{SME} and its terminology, please refer to the +@url{https://developer.arm.com/documentation/ddi0616/aa/, +Arm Architecture Reference Manual Supplement}, The Scalable Matrix Extension +(@acronym{SME}), for Armv9-A. + +Some features are still under development and rely on +@url{https://github.com/ARM-software/acle/releases/latest, ACLE} and +@url{https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst, ABI} +definitions, so there are known limitations to the current @acronym{SME} +support in @value{GDBN}. + +One such example is calling functions in the program being debugged by +@value{GDBN}. Such calls are not @acronym{SME}-aware and thus don't take into +account the @code{svcr} pseudo-register bits nor the @code{za} register +contents. @xref{Calling} + +The @url{https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#the-za-lazy-saving-scheme, +lazy saving scheme} involving the @code{tpidr2} register is not yet supported +by @value{GDBN}, though the @code{tpidr2} register is known and supported +by @value{GDBN}. + +Lastly, an important limitation for @code{gdbserver} is its inability to +communicate @var{svl} changes to @value{GDBN}. This means @code{gdbserver}, +even though it is capable of adjusting its internal caches to reflect a change +in the value of @var{svl} mid-execution, will operate with a potentially +different @var{svl} value compared to @value{GDBN}. This can lead to +@value{GDBN} showing incorrect values for the @code{za} register and +incorrect values for SVE registers (when in streaming mode). + +This is the same limitation we have for the @acronym{SVE} registers, and there +are plans to address this limitation going forward. + @subsubsection AArch64 Pointer Authentication. @cindex AArch64 Pointer Authentication. @anchor{AArch64 PAC} @@ -48116,6 +48334,37 @@ This restriction may be lifted in the future. Extra registers are allowed in this feature, but they will not affect @value{GDBN}. +@subsubsection AArch64 SME registers feature + +The @samp{org.gnu.gdb.aarch64.sme} feature is optional. If present, +it should contain registers @samp{za}, @samp{svg} and @samp{svcr}. +@xref{AArch64 SME} + +@itemize @minus + +@item +@samp{za} is a register represented by a vector of @var{svl}x@var{svl} +bytes. @xref{svl} + +@item +@samp{svg} is a 64-bit register containing the value of @var{svg}. @xref{svg}. + +@item +@samp{svcr} is a 64-bit status pseudo-register with two valid bits. Bit 0 +(@sc{sm}) shows whether the streaming @acronym{SVE} mode is enabled or disabled. +Bit 1 (@sc{za}) shows whether the @code{za} register state is active (in use) or +not. +@xref{aarch64 sme svcr} + +The rest of the unused bits of the @samp{svcr} pseudo-register is undefined +and reserved. Such bits should not be used and may be defined by future +extensions of the architecture. + +@end itemize + +Extra registers are allowed in this feature, but they will not affect +@value{GDBN}. + @node ARC Features @subsection ARC Features @cindex target descriptions, ARC Features