From patchwork Mon Sep 18 21:27: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: 76332 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 56AA8385CCAB for ; Mon, 18 Sep 2023 21:31:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56AA8385CCAB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072679; bh=tH9VOeSpmcdELbvoodAZ/TZSotkwj8TIIHnxDNyTZmI=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=L6pwxRxERv9tyc6kc/NVMqp3w3RBf95SMgZGwTiDdQGiz7HlqeI0v7B3+3ro3b3XY HKI6vUC1XocGJSeuJVnhEyNmuzzQNWknKCxmsBOdvQV5+G57nAwponGWbptJIseWVD DHv2PxDw0VXmxnu8tJI5Kdwc/ODyzXUR/eiFUNjw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2045.outbound.protection.outlook.com [40.107.20.45]) by sourceware.org (Postfix) with ESMTPS id 11F3F3857725 for ; Mon, 18 Sep 2023 21:27:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 11F3F3857725 Received: from AS9PR06CA0247.eurprd06.prod.outlook.com (2603:10a6:20b:45f::14) by PR3PR08MB5722.eurprd08.prod.outlook.com (2603:10a6:102:8f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:28 +0000 Received: from AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45f:cafe::88) by AS9PR06CA0247.outlook.office365.com (2603:10a6:20b:45f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 21:27:28 +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 AM7EUR03FT039.mail.protection.outlook.com (100.127.140.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:28 +0000 Received: ("Tessian outbound 0b7d6027328f:v175"); Mon, 18 Sep 2023 21:27:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 536513f698a1d462 X-CR-MTA-TID: 64aa7808 Received: from 0ae0d5504fc9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6A641630-E0C3-4BD9-AF90-0C67D0759E20.1; Mon, 18 Sep 2023 21:27:21 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0ae0d5504fc9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NxMVlX7nihOJi5OFetDFqtJdKftE59w5YqA0B9cWvft973K+jHYzHw5e3tZuKJgEW/IATyQ/CdJlIuE/5KMVpOCDyRZzb9Fg6nBwy/kpSZeGsNv15eQaIlCfItNAbB2akUX+Za0cRs1Yz7s5kyW1vEW08TQNOQJo1lEL0Q+cJB/gASYtgESv251O368j3u9OpcU1GMgt+F7/FRLAmjs08UsdQLeivBmPV3TXZxGQ55WMLICE6m2KSBcMMrHcYEoOvKVaCiIV8jEMFFkbFi5yuLK0QaC4I1pMxK/KzoKm6Duzi2xb/gnAVnVb+fW0xFWQgAKRwRTa0NhqclAwt1vsZw== 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=tH9VOeSpmcdELbvoodAZ/TZSotkwj8TIIHnxDNyTZmI=; b=eh7ZMi4fYhm8UiQ3B52guE/9/veVpfUFvczE0vZ1KhaKrz8ik2yEPTxT8qNFNVV3CpMM+vngrY6xJYReJOX84ND0k5m9rgYck/z9PZozHOaNVlTeo9VWiX33x6bmVAUQ9JvRbJxBO18QvXbnALeNWdGmVra2uwVvwWGJ3M991DqQm5XjycqAqpOX7kLJ3qdcpcR6dmM6M6SzkVXzT2PCw4awOgGcyRc+3CggnCsYHqVsfO1eeHHdJMgfM4yyKAB87q8UyKNmprBJUujAm2eOkyxy+L3xLFJS1qxOyEt2nCj6NdPoVig4TYGrEE+IljIqy7ElXepb7efF2LxFZARuaQ== 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 AS8P251CA0018.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::25) by AS8PR08MB10149.eurprd08.prod.outlook.com (2603:10a6:20b:63f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 21:27:18 +0000 Received: from AM7EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::63) by AS8P251CA0018.outlook.office365.com (2603:10a6:20b:2f2::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:18 +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 AM7EUR03FT040.mail.protection.outlook.com (100.127.140.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:18 +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.27; Mon, 18 Sep 2023 21:27:18 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Sep 2023 21:27:18 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:17 +0000 To: CC: Subject: [PATCH v5 1/6] [gdb/aarch64] sme2: Enable SME2 for AArch64 gdb on Linux Date: Mon, 18 Sep 2023 22:27:03 +0100 Message-ID: <20230918212708.660213-2-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212708.660213-1-luis.machado@arm.com> References: <20230918212708.660213-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT040:EE_|AS8PR08MB10149:EE_|AM7EUR03FT039:EE_|PR3PR08MB5722:EE_ X-MS-Office365-Filtering-Correlation-Id: 45c3e057-16a6-4c60-a576-08dbb88e0f40 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: 4hIQdN0pF2JPhapGb+8g44jl/VdZ5x3/aXrqJhoYUWJrMdtMndQ9zbhAVeEOugbcRsTkC1VFKJVnCH2B2VLjKFewZCh2hh6eaDWCpkwk3HgtLlnQUb9mYxgHgY5f32VuqjIFgmcaAmXxqAVBUo3HS7ZqZ6SVk7AtrtMuabFzbYjCTQwqsEBQZymm6H7kInFgHZqtw2FM1t6jUK4SgrKBBRyTyNGi3bcbOGgq51JfFOIETMKDprYK6d0gW9EjN9x+gLjcWRXwL5R9POoYJ6uyU1yw3G9skZVBJ35NGUwRWtnJJnsmaYXX1hqjQIL/9KXhSctkMu6MAQXINm00EqCTmzFjuc0/bIRP/GK0VVRLVXMMJnP4wD5ylGiT1avlj7QLCMzr5qA6arB4PQeCZJGcL8XU8Kww3cxfeXE3LfmEolkoy+ZZIK6HxUCYIsqdxb9cS87/6mkayAUuGPRBi9vOvVhl5OMnWFJaUbmw/gWrtJS3ifwcNKC76kZ/V2RWFkfziD53RZWL2X94yhh0PmRPhGVaEvA4SEChE7lv38TQMoybhHYnTb3nGKyWuuk1dTr2ItccrSd/kfyScpurjtZirzjl1gve1HQhoulioBeuefuPtla2HficLEaSG6kyr+1sdGbK8dpW4SIgRqD7NlI8iCfgaT5S20rVeIsgeE0PGlceDHEspKIzyn9jvpM4c54QZSRWGepw1KLsnHXEUysicdxWI9yzKOM8/YsXmbF2GrHpDY6NDjTW9sK7uIokuEsJ8SYyILvihe0fiAtwT62YUQ== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199024)(186009)(1800799009)(82310400011)(40470700004)(36840700001)(46966006)(41300700001)(4326008)(6916009)(316002)(70206006)(70586007)(5660300002)(8676002)(8936002)(44832011)(478600001)(30864003)(2906002)(6666004)(2616005)(26005)(426003)(336012)(83380400001)(1076003)(86362001)(47076005)(36860700001)(82740400003)(81166007)(356005)(40480700001)(36756003)(40460700003)(7696005)(2004002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10149 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 226d4985-5dad-4c8a-9dfc-08dbb88e0974 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jh4CQbbQf+AfxFOJFLOkl6JjkwLWr/pLoCoLxsxKUTUWQ9g+5pBb6+4qCuNQgoEAxQ/YlTZcws5KVLeObvuVraVCH/cT9ctQTJqjHQO8JiMBeCR5tUkeuoFQpe4tFU1OJk7+yRpfYrZwPsuFh5UYxFmLUZVZzkdqevPC2pNiazzJVM/qkBpT48lbmOI7GnVqtIDyA4Nm/p7uS2Xq5HPQ6/HAlzN2U0fzyNmzdIqDteimgbUv7tVRtossRHFOJ8oFkWJCArRadIGsqIchzJHeZ/Iz7xEnIi0tKKHtUZTiExfHN2h3kqBR1rnwq2eQhCvq3HumHIZyABQX60LbsdEp56dBwhV2//MwizGtq4F0k/qFpM2Wth6vAZjop+DpUpAFyKrRQn2nk5pyt235k4hXX6nRH8xHedmnYQ/P/thHxuwHHSZ0esJf92YROm/WTqNJ3MHW9vEyxdp0HX15EEqWb6D6g9JzZg96a0lrVdT9W2rI3bsniK6ccYyVxdPi9zgvMaBvq6ZDyXvGuNyUnv1JCyU3KHQVbO0MNH/bgBeeahfSASFyMCybaFXUdjKa6bDnyGVItEhB92YWCdze07vrvHth+p3VBjUGlZVdMTbIT0eNOiL+ptTb9q2O83UAqZGOBJIbACkYIAWMsYlMNKPOVU+eNbf+j3bjF+pIDFmJ0vp6Joc6H3rFkZaeaIInUKyjFemYbVtLYSEZX/24NdSa7iHHK/sfJOUxAjGWCz7pu5p9Wws1OzwIxzJLxUdqQNOO X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199024)(1800799009)(82310400011)(186009)(46966006)(40470700004)(36840700001)(36756003)(40480700001)(40460700003)(336012)(26005)(426003)(107886003)(1076003)(2616005)(30864003)(2906002)(5660300002)(44832011)(86362001)(82740400003)(4326008)(8936002)(8676002)(6916009)(47076005)(316002)(81166007)(41300700001)(70206006)(70586007)(36860700001)(6666004)(83380400001)(478600001)(7696005)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:28.3037 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45c3e057-16a6-4c60-a576-08dbb88e0f40 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: AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5722 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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" v3: - Adjust function comment about the use of regcache's thread. --- SME2 defines a new 512-bit register named ZT0, and it is only available if SME is also supported. The ZT0 state is valid only if the SVCR ZA bit is enabled. Otherwise its contents are empty (0). The target description is dynamic and gets generated at runtime based on the availability of the feature. Validated under Fast Models. Reviewed-by: Thiago Jung Bauermann --- gdb/aarch64-linux-nat.c | 49 +++++++++ gdb/aarch64-tdep.c | 21 ++++ gdb/aarch64-tdep.h | 10 ++ gdb/arch/aarch64-scalable-linux.h | 6 ++ gdb/arch/aarch64.c | 4 + gdb/arch/aarch64.h | 12 ++- gdb/features/aarch64-sme2.c | 43 ++++++++ gdb/nat/aarch64-scalable-linux-ptrace.c | 134 ++++++++++++++++++++++++ gdb/nat/aarch64-scalable-linux-ptrace.h | 26 +++++ 9 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 gdb/features/aarch64-sme2.c diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index d7fcef5a0db..c1d59b5d77c 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -376,6 +376,37 @@ store_za_to_thread (struct regcache *regcache) tdep->sme_svcr_regnum); } +/* Fill GDB's REGCACHE with the ZT register set contents from the + thread associated with REGCACHE. If there is no active ZA register state, + make the ZT register contents zero. */ + +static void +fetch_zt_from_thread (struct regcache *regcache) +{ + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Read ZT state from the thread to the register cache. */ + aarch64_zt_regs_copy_to_reg_buf (regcache->ptid ().lwp (), + regcache, + tdep->sme2_zt0_regnum); +} + +/* Store the NT_ARM_ZT register set contents from GDB's REGCACHE to the + thread associated with REGCACHE. */ + +static void +store_zt_to_thread (struct regcache *regcache) +{ + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Write ZT state from the register cache to the thread. */ + aarch64_zt_regs_copy_from_reg_buf (regcache->ptid ().lwp (), + regcache, + tdep->sme2_zt0_regnum); +} + /* Fill GDB's register array with the pointer authentication mask values from the current thread. */ @@ -549,6 +580,9 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) if (tdep->has_sme ()) fetch_za_from_thread (regcache); + + if (tdep->has_sme2 ()) + fetch_zt_from_thread (regcache); } /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) @@ -569,6 +603,9 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) else if (tdep->has_sme () && regno >= tdep->sme_reg_base && regno < tdep->sme_reg_base + 3) fetch_za_from_thread (regcache); + /* SME2 register? */ + else if (tdep->has_sme2 () && regno == tdep->sme2_zt0_regnum) + fetch_zt_from_thread (regcache); /* MTE register? */ else if (tdep->has_mte () && (regno == tdep->mte_reg_base)) @@ -646,6 +683,9 @@ aarch64_store_registers (struct regcache *regcache, int regno) if (tdep->has_sme ()) store_za_to_thread (regcache); + + if (tdep->has_sme2 ()) + store_zt_to_thread (regcache); } /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) @@ -661,6 +701,8 @@ aarch64_store_registers (struct regcache *regcache, int regno) else if (tdep->has_sme () && regno >= tdep->sme_reg_base && regno < tdep->sme_reg_base + 3) store_za_to_thread (regcache); + else if (tdep->has_sme2 () && regno == tdep->sme2_zt0_regnum) + store_zt_to_thread (regcache); /* MTE register? */ else if (tdep->has_mte () && (regno == tdep->mte_reg_base)) @@ -861,6 +903,10 @@ aarch64_linux_nat_target::read_description () /* SME feature check. */ features.svq = aarch64_za_get_svq (tid); + /* Check for SME2 support. */ + if ((hwcap2 & HWCAP2_SME2) || (hwcap2 & HWCAP2_SME2P1)) + features.sme2 = supports_zt_registers (tid); + return aarch64_read_description (features); } @@ -981,6 +1027,9 @@ aarch64_linux_nat_target::thread_architecture (ptid_t ptid) features.vq = vq; features.svq = svq; + /* Check for the SME2 feature. */ + features.sme2 = supports_zt_registers (ptid.lwp ()); + struct gdbarch_info info; info.bfd_arch_info = bfd_lookup_arch (bfd_arch_aarch64, bfd_mach_aarch64); info.target_desc = aarch64_read_description (features); diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 8e7259a6f42..eaae2d91047 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -4048,6 +4048,10 @@ aarch64_features_from_target_desc (const struct target_desc *tdesc) features.svq = aarch64_get_tdesc_svq (tdesc); + /* Check for the SME2 feature. */ + features.sme2 = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme2") + != nullptr); + return features; } @@ -4310,6 +4314,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } int first_sme_regnum = -1; + int first_sme2_regnum = -1; int first_sme_pseudo_regnum = -1; const struct tdesc_feature *feature_sme = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme"); @@ -4336,6 +4341,19 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Add the ZA tile pseudo registers. */ num_pseudo_regs += AARCH64_ZA_TILES_NUM; + + /* Now check for the SME2 feature. SME2 is only available if SME is + available. */ + const struct tdesc_feature *feature_sme2 + = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme2"); + if (feature_sme2 != nullptr) + { + /* Record the first SME2 register. */ + first_sme2_regnum = num_regs; + + valid_p &= tdesc_numbered_register (feature_sme2, tdesc_data.get (), + num_regs++, "zt0"); + } } /* Add the TLS register. */ @@ -4459,6 +4477,9 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->sme_za_regnum = first_sme_regnum + 2; tdep->sme_svq = svq; + /* Set the SME2 register set details. */ + tdep->sme2_zt0_regnum = first_sme2_regnum; + set_gdbarch_push_dummy_call (gdbarch, aarch64_push_dummy_call); set_gdbarch_frame_align (gdbarch, aarch64_frame_align); diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h index 9297487a584..9e4d1a59734 100644 --- a/gdb/aarch64-tdep.h +++ b/gdb/aarch64-tdep.h @@ -172,6 +172,16 @@ struct aarch64_gdbarch_tdep : gdbarch_tdep_base { return sme_svq != 0; } + + /* Index of the SME2 ZT0 register. This is -1 if SME2 is not + supported. */ + int sme2_zt0_regnum = -1; + + /* Return true if the target supports SME2, and false otherwise. */ + bool has_sme2 () const + { + return sme2_zt0_regnum > 0; + } }; const target_desc *aarch64_read_description (const aarch64_features &features); diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h index cb9d85a9d5d..0f59ddb40b2 100644 --- a/gdb/arch/aarch64-scalable-linux.h +++ b/gdb/arch/aarch64-scalable-linux.h @@ -29,6 +29,12 @@ #define HWCAP2_SME (1 << 23) #endif +/* Feature check for Scalable Matrix Extension 2. */ +#ifndef HWCAP2_SME2 +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#endif + /* Streaming mode enabled/disabled bit. */ #define SVCR_SM_BIT (1 << 0) /* ZA enabled/disabled bit. */ diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c index e1f4948aa25..c93d602c66c 100644 --- a/gdb/arch/aarch64.c +++ b/gdb/arch/aarch64.c @@ -25,6 +25,7 @@ #include "../features/aarch64-pauth.c" #include "../features/aarch64-mte.c" #include "../features/aarch64-sme.c" +#include "../features/aarch64-sme2.c" #include "../features/aarch64-tls.c" /* See arch/aarch64.h. */ @@ -62,6 +63,9 @@ aarch64_create_target_description (const aarch64_features &features) regnum = create_feature_aarch64_sme (tdesc.get (), regnum, sve_vl_from_vq (features.svq)); + if (features.sme2) + regnum = create_feature_aarch64_sme2 (tdesc.get (), regnum); + return tdesc.release (); } diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h index c1cd233c51e..65c6205115e 100644 --- a/gdb/arch/aarch64.h +++ b/gdb/arch/aarch64.h @@ -48,6 +48,9 @@ struct aarch64_features These use at most 5 bits to represent. */ uint8_t svq = 0; + + /* Whether SME2 is supported. */ + bool sme2 = false; }; inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs) @@ -56,7 +59,8 @@ inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs) && lhs.pauth == rhs.pauth && lhs.mte == rhs.mte && lhs.tls == rhs.tls - && lhs.svq == rhs.svq; + && lhs.svq == rhs.svq + && lhs.sme2 == rhs.sme2; } namespace std @@ -79,6 +83,9 @@ namespace std gdb_assert (features.svq >= 0); gdb_assert (features.svq <= 16); h = h << 5 | (features.svq & 0x5); + + /* SME2 feature. */ + h = h << 1 | features.sme2; return h; } }; @@ -220,4 +227,7 @@ enum aarch64_regnum #define AARCH64_SME_MIN_SVL 128 #define AARCH64_SME_MAX_SVL 2048 +/* Size of the SME2 ZT0 register in bytes. */ +#define AARCH64_SME2_ZT0_SIZE 64 + #endif /* ARCH_AARCH64_H */ diff --git a/gdb/features/aarch64-sme2.c b/gdb/features/aarch64-sme2.c new file mode 100644 index 00000000000..a14b98fae9d --- /dev/null +++ b/gdb/features/aarch64-sme2.c @@ -0,0 +1,43 @@ +/* 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" + +/* This function is NOT auto generated from xml. Create the AArch64 SME2 + feature into RESULT. + + The ZT0 register is only available when the SME ZA register is + available. */ + +static int +create_feature_aarch64_sme2 (struct target_desc *result, long regnum) +{ + struct tdesc_feature *feature; + tdesc_type *element_type; + + feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.sme2"); + + /* Byte type. */ + element_type = tdesc_named_type (feature, "uint8"); + + /* Vector of 64 bytes. */ + element_type = tdesc_create_vector (feature, "sme2_bv", element_type, 64); + + /* The following is the ZT0 register, with 512 bits (64 bytes). */ + tdesc_create_reg (feature, "zt0", regnum++, 1, nullptr, 512, "sme2_bv"); + return regnum; +} diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c index d3a50ed0c81..dc0e45fa91e 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.c +++ b/gdb/nat/aarch64-scalable-linux-ptrace.c @@ -519,10 +519,75 @@ aarch64_initialize_za_regset (int tid) if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_ZA, &iovec) < 0) perror_with_name (_("Failed to initialize the NT_ARM_ZA register set.")); + if (supports_zt_registers (tid)) + { + /* If this target supports SME2, upon initializing ZA, we also need to + initialize the ZT registers with 0 values. Do so now. */ + gdb::byte_vector zt_new_state (AARCH64_SME2_ZT0_SIZE, 0); + aarch64_store_zt_regset (tid, zt_new_state); + } + /* The NT_ARM_ZA register set should now contain a zero-initialized ZA payload. */ } +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +gdb::byte_vector +aarch64_fetch_zt_regset (int tid) +{ + /* Read NT_ARM_ZT. This register set is only available if + the ZA bit is non-zero. */ + gdb::byte_vector zt_state (AARCH64_SME2_ZT0_SIZE); + + struct iovec iovec; + iovec.iov_len = AARCH64_SME2_ZT0_SIZE; + iovec.iov_base = zt_state.data (); + + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_ZT, &iovec) < 0) + perror_with_name (_("Failed to fetch NT_ARM_ZT register set.")); + + return zt_state; +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +void +aarch64_store_zt_regset (int tid, const gdb::byte_vector &zt_state) +{ + gdb_assert (zt_state.size () == AARCH64_SME2_ZT0_SIZE + || zt_state.size () == 0); + + /* We need to be mindful of writing data to NT_ARM_ZT. If the ZA bit + is 0 and we write something to ZT, it will flip the ZA bit. + + Right now this is taken care of by callers of this function. */ + struct iovec iovec; + iovec.iov_len = zt_state.size (); + iovec.iov_base = (void *) zt_state.data (); + + /* Write the contents of ZT_STATE to the NT_ARM_ZT register set. */ + if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_ZT, &iovec) < 0) + perror_with_name (_("Failed to write to the NT_ARM_ZT register set.")); +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +bool +supports_zt_registers (int tid) +{ + gdb_byte zt_state[AARCH64_SME2_ZT0_SIZE]; + + struct iovec iovec; + iovec.iov_len = AARCH64_SME2_ZT0_SIZE; + iovec.iov_base = (void *) zt_state; + + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_ZT, &iovec) < 0) + return false; + + return true; +} + /* 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. */ @@ -989,3 +1054,72 @@ aarch64_za_regs_copy_from_reg_buf (int tid, /* At this point we have written the data contained in the register cache to the thread's NT_ARM_ZA register set. */ } + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +void +aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf, + int zt_regnum) +{ + /* If we have ZA state, read the ZT state. Otherwise, make the contents of + ZT in the register cache all zeroes. This is how we present the ZT + state when it is not initialized (ZA not active). */ + if (aarch64_has_za_state (tid)) + { + /* Fetch the current ZT state from the thread. */ + gdb::byte_vector zt_state = aarch64_fetch_zt_regset (tid); + + /* Sanity check. */ + gdb_assert (!zt_state.empty ()); + + /* Copy the ZT data to the register buffer. */ + reg_buf->raw_supply (zt_regnum, zt_state.data ()); + } + else + { + /* Zero out ZT. */ + gdb::byte_vector zt_zeroed (AARCH64_SME2_ZT0_SIZE, 0); + reg_buf->raw_supply (zt_regnum, zt_zeroed.data ()); + } + + /* The register buffer should now contain the updated copy of the NT_ARM_ZT + state. */ +} + +/* See nat/aarch64-scalable-linux-ptrace.h. */ + +void +aarch64_zt_regs_copy_from_reg_buf (int tid, + struct reg_buffer_common *reg_buf, + int zt_regnum) +{ + /* Do we have a valid ZA state? */ + bool valid_za = aarch64_has_za_state (tid); + + /* Is the register buffer contents for ZT all zeroes? */ + gdb::byte_vector zt_bytes (AARCH64_SME2_ZT0_SIZE, 0); + bool zt_is_all_zeroes + = reg_buf->raw_compare (zt_regnum, zt_bytes.data (), 0); + + /* If ZA state is valid or if we have non-zero data for ZT in the register + buffer, we will invoke ptrace to write the ZT state. Otherwise we don't + have to do anything here. */ + if (valid_za || !zt_is_all_zeroes) + { + if (!valid_za) + { + /* ZA state is not valid. That means we need to initialize the ZA + state prior to writing the ZT state. */ + aarch64_initialize_za_regset (tid); + } + + /* Extract the ZT data from the register buffer. */ + reg_buf->raw_collect (zt_regnum, zt_bytes.data ()); + + /* Write the ZT data to thread TID. */ + aarch64_store_zt_regset (tid, zt_bytes); + } + + /* At this point we have (potentially) written the data contained in the + register cache to the thread's NT_ARM_ZT register set. */ +} diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h index d609933801d..69c9982b009 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.h +++ b/gdb/nat/aarch64-scalable-linux-ptrace.h @@ -120,6 +120,16 @@ extern void aarch64_store_za_regset (int tid, const gdb::byte_vector &za_state); size. The bytes of the ZA register are initialized to zero. */ extern void aarch64_initialize_za_regset (int tid); +/* Given TID, return the NT_ARM_ZT register set data as a vector of bytes. */ +extern gdb::byte_vector aarch64_fetch_zt_regset (int tid); + +/* Write ZT_STATE for TID. */ +extern void aarch64_store_zt_regset (int tid, const gdb::byte_vector &zt_state); + +/* Return TRUE if thread TID supports the NT_ARM_ZT register set. + Return FALSE otherwise. */ +extern bool supports_zt_registers (int tid); + /* Given a register buffer REG_BUF, update it with SVE/SSVE register data from SVE_STATE. */ extern void @@ -151,4 +161,20 @@ aarch64_za_regs_copy_from_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, update the register + buffer with the ZT register set state from thread TID. + + ZT_REGNUM is the register number for ZT0. */ +extern void +aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf, + int zt_regnum); + +/* Given a thread id TID and a register buffer REG_BUF containing the ZT + register set state, write the ZT data to thread TID. + + ZT_REGNUM is the register number for ZT0. */ +extern void +aarch64_zt_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf, + int zt_regnum); #endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */ From patchwork Mon Sep 18 21:27: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: 76327 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 BF6403847EDE for ; Mon, 18 Sep 2023 21:30:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF6403847EDE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072636; bh=NAjUGKfGd/S1Wga1XY7h9Ygncqi2NQB4atL8HJQsWcs=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Q6oPeeRJ+WqEPxU25G2xhp7fyBptkkMfmxeIL1upRfXTobFAHZI4NAuroV9nrz5Bw xhefNLy6walnoYTX4Z2DFhRvF7mDVqKhZzqS9CO/uslYj3nsZLV4l52H8WHxR50c4X xfNG8c7iZ88eNtLhMiJFbbeD/gMO6MKf3CPgf3lc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2045.outbound.protection.outlook.com [40.107.247.45]) by sourceware.org (Postfix) with ESMTPS id A40043856DF2 for ; Mon, 18 Sep 2023 21:27:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A40043856DF2 Received: from AS9PR0301CA0008.eurprd03.prod.outlook.com (2603:10a6:20b:468::17) by AS8PR08MB8802.eurprd08.prod.outlook.com (2603:10a6:20b:5bc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.23; Mon, 18 Sep 2023 21:27:29 +0000 Received: from AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:468:cafe::ee) by AS9PR0301CA0008.outlook.office365.com (2603:10a6:20b:468::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27: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 AM7EUR03FT035.mail.protection.outlook.com (100.127.141.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:28 +0000 Received: ("Tessian outbound c99fbc01d472:v175"); Mon, 18 Sep 2023 21:27:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 607186af4bac4125 X-CR-MTA-TID: 64aa7808 Received: from ca92e906c455.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0CB8AFD9-8A14-4534-AB54-51721CF22559.1; Mon, 18 Sep 2023 21:27:21 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ca92e906c455.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IvTrDymc/pT9sXZdQ5/0wLUft7lWOSaDpp2RNljRkPb6C9yfCc/LiNj+NsKplm1AKHw45mpAEfafEMtdOBadAkgn4eNF9GzbL6aZcmeIwDaWkEDheOg7i4CfUs4GPBzy74gjInKOK8hyF7oUSjcEpC5MtJCaUvZzD7OT8TJaG22NQDY0+jtojt2vhvMP+CEGRch/4trRWuOliuCp84iqiuErP5Avk++DFMjeG7Oy5nTX+ocwPTviOaGz9uUv/LLU2tkWSxWFG9a7ZHCWaBmJMsCR3RxNeJdQX1l8H6ctHUhmeX3L0TcJ6B4v1b50IKdJYB4JmQ2P3LTV0JwS9DnZKA== 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=NAjUGKfGd/S1Wga1XY7h9Ygncqi2NQB4atL8HJQsWcs=; b=RfEGKruT5PhYvJNe9DA0S4epAPYHsuU7xOwii2c9dbA3vRz8AHZpzp8UeJmospR1LgFjwR+B0ApjGW04vyVrh/WAA9VjhkXxBKhi8rRtGgut+z35l5frKpZz6GVL2xbzsvrO7LWEzWlbAjbQ8S03QtXzzhyUyUjT1Sk1cPRxa2ZEdVkVtMSx4HO15cUyn4ndLj6xHlt3jtuZOy6UgD6yNPhz7m0G9jBxLaHoacd9sOMmeCMw6wuSFYZQmRX6738AVb/Panm7xoZeP0ujpCCC0mFfQNAV4F3peQ428m05tZ2fto7mXZC1B8sDvJn14EWpFQSQlpPRy3pfMvdiwuTbxA== 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 AS8P251CA0008.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::26) by GV2PR08MB8269.eurprd08.prod.outlook.com (2603:10a6:150:b9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:19 +0000 Received: from AM7EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::b2) by AS8P251CA0008.outlook.office365.com (2603:10a6:20b:2f2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +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 AM7EUR03FT040.mail.protection.outlook.com (100.127.140.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:18 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.27; Mon, 18 Sep 2023 21:27:18 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:18 +0000 To: CC: Subject: [PATCH v5 2/6] [gdbserver/aarch64] sme2: Enable SME2 support in gdbserver Date: Mon, 18 Sep 2023 22:27:04 +0100 Message-ID: <20230918212708.660213-3-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212708.660213-1-luis.machado@arm.com> References: <20230918212708.660213-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT040:EE_|GV2PR08MB8269:EE_|AM7EUR03FT035:EE_|AS8PR08MB8802:EE_ X-MS-Office365-Filtering-Correlation-Id: 2185c178-8a9d-4457-378c-08dbb88e0fa7 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: 9beURE6S3Ec6iLHVcdB7Cmt7YImIQe2DQq0zJgn/O/vIjn5HLe8U/hBUIF5xaDR396caQqG5CwzxhG8/mo4oB84c/+TrCtT7+zxdPBxcQz4FK4NekOdWuxzITp/logYCX4jZG6XbLb5XekuS2tL69Nj0DI0JqZqTx5UgA7OgSsgIEo6BXLfknkBKX44vanXXk5NHQIp/vC5A4ymCSW7BGebnIOAfozrRHE2VK+bMXO8Umgkq2NUyiRfpBSjbSElzOu7vzhZExehSTEGCo5Uie696O6B/qWsRKnJZAjiI0YpuOA1hAGPGLtSH8PWlsXZZZVt0Nv1no25ab+J0JdizNPPv9sOg4wVsomaRJlsw4TB8kApgQFDmgMZw2PZ9Q2Gv4WfuQOaTNIzdHkHu+sUxVjm2EsuYwsb5kPeGNaS+NkcP7z7oWWdzcORTIjFSXMSdNah5ieaC+Oq7CR7o+ytzVds5UMyPB2nwCZ+cGBNM3wEwJnxbvWD2BZdrZXYnNq1Hh4Y19VnLx2plTq+Uqx4eAxOoqyIzCw++TtvOQxCXdPeXOGYG2XmdIpNCYGs6lqXn0kGOYWiU3A9T/38jWaFnxiwRi+7sNIKxyvsnsbvNiDQsrVqjBmVH5MJoJg/o/9xfczQEg3VyHb5tDJNGLZhv2tL3PSDmgn2d37suMEi0hgh7k2bepMpRDLNa5mhZUTInT6i6mSjpyEBKkY2jjfYgg47Je4skrLy8DxH6gTozHS/XpUl73l8aIoOZ7N3r6xiqia28cquc9Wl0+2sScnsDWQ== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(136003)(39860400002)(376002)(82310400011)(451199024)(186009)(1800799009)(40470700004)(36840700001)(46966006)(7696005)(6666004)(478600001)(2616005)(1076003)(26005)(336012)(426003)(2906002)(47076005)(5660300002)(316002)(70206006)(70586007)(6916009)(41300700001)(8676002)(8936002)(44832011)(356005)(40460700003)(82740400003)(36860700001)(36756003)(4326008)(86362001)(40480700001)(81166007)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8269 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 559f9b3e-9ed4-4896-9c35-08dbb88e0993 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G9FiPuhhOxookWuC9WNOQykUv4vTPmmyBhnlmW8JEnZZWb/1ZXMvfFc6rj5D10IKVDQej/TpV9xJH2he0bfYd74NV7c2lRDihehvQXuA1/AdT3fevJG5A71w2jOrrmOojMZ0y0z+Fwj1Q+xFoMBz84gJlUiryIGWFwMjVK4gu5bU6RdOk41XSE41ksn+sn6FUkSa7LUHL9rB1joy+LlXrav53c/reslZVYcDe9QkXqDknmRbs33+gdTBP7a2SYrcXYPMSGrVwOamYE1ZjWTqqqjWi7Fvdpn+tlKxHvXsoLM10pZxe3mnDSJL1QwlpyZjR9ytbTMljEAMaqu3p0Msaag8U18tIeNw81BzfMOv9v/BbwIjCr88tQb61oDmtdfd+4e0woMJlkhn3ZlcsksrD9s6+H0KNvx7rhy7xL29fZ1w38Wz5yqutiBnrzBJQNJ8TEuYVM0RswUhoHJUbABnmd/4+TioMES9yoMooLOMXDw7a2mz329FWCxNoehkCJixZa3KwdBMxmyjxOlhUFkUisoSKwTnHl/kJENypHVoy69FwTlpg+tvCIDi0/DDYPRoa435EcZm9z5gt3azK1k4jmqbIFo9hU1NUN3NdiffL2X2Yt5euIdB39N0alAWee6dYb9XEHYhXjDFByx3vpPiT3WbD4542Gg/Ke4heEO0/2mYgEBbjmxpBuZt8w0K9EOUozV/jMGbrajykVU262Uno1KT3fcT41CIUmfaOMotF67gu/U2FADRy5jVST3Q9x1u X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(346002)(396003)(136003)(451199024)(1800799009)(186009)(82310400011)(36840700001)(46966006)(40470700004)(6666004)(7696005)(40480700001)(5660300002)(40460700003)(86362001)(36860700001)(81166007)(36756003)(82740400003)(26005)(107886003)(2616005)(336012)(47076005)(2906002)(426003)(83380400001)(478600001)(1076003)(8936002)(316002)(8676002)(4326008)(6916009)(41300700001)(44832011)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:28.9915 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2185c178-8a9d-4457-378c-08dbb88e0fa7 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: AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8802 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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" v5: - Fixed register name typo za -> zt0. v3: - Use find_regno instead of find_regno_no_throw. - Changed literal to use ZT0 size constant. --- This patch teaches gdbserver about the SME2 and the ZT0 register. Since most of the code used by gdbserver for SME2 is shared with gdb, this is a rather small patch that reuses most of the code put in place for native AArch64 Linux. Validated under Fast Models. --- gdbserver/linux-aarch64-low.cc | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index e887e39b1c2..fcbe7bb64d7 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -797,6 +797,46 @@ aarch64_za_regs_copy_from_regcache (struct regcache *regcache, void *buf) memcpy (buf, za_state.data (), za_state.size ()); } +/* Wrapper for aarch64_zt_regs_copy_to_reg_buf, to help copying NT_ARM_ZT + state from the thread (BUF) to the register cache. */ + +static void +aarch64_zt_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); + + int zt_regnum = find_regno (regcache->tdesc, "zt0"); + + /* Update the register cache. aarch64_zt_regs_copy_to_reg_buf handles + fetching the NT_ARM_ZT state from thread TID. */ + aarch64_zt_regs_copy_to_reg_buf (tid, regcache, zt_regnum); +} + +/* Wrapper for aarch64_zt_regs_copy_from_reg_buf, to help copying NT_ARM_ZT + state from the register cache to the thread (BUF). */ + +static void +aarch64_zt_regs_copy_from_regcache (struct regcache *regcache, void *buf) +{ + int tid = lwpid_of (current_thread); + + int zt_regnum = find_regno (regcache->tdesc, "zt0"); + + /* Update the thread NT_ARM_ZT state. aarch64_zt_regs_copy_from_reg_buf + handles writing the ZT state back to thread TID. */ + aarch64_zt_regs_copy_from_reg_buf (tid, regcache, zt_regnum); + + /* We need to return the expected data in BUF, so copy whatever the kernel + already has to BUF. */ + + /* Obtain a dump of NT_ARM_ZT from ptrace. */ + gdb::byte_vector zt_state = aarch64_fetch_zt_regset (tid); + memcpy (buf, zt_state.data (), zt_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. @@ -824,6 +864,11 @@ static struct regset_info aarch64_regsets[] = 0, EXTENDED_REGS, aarch64_za_regs_copy_from_regcache, aarch64_za_regs_copy_to_regcache }, + /* Scalable Matrix Extension 2 (SME2) ZT registers. */ + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_ZT, + 0, EXTENDED_REGS, + aarch64_zt_regs_copy_from_regcache, aarch64_zt_regs_copy_to_regcache + }, /* PAC registers. */ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK, 0, OPTIONAL_REGS, @@ -895,6 +940,10 @@ aarch64_adjust_register_sets (const struct aarch64_features &features) if (features.svq > 0) regset->size = ZA_PT_SIZE (features.svq); break; + case NT_ARM_ZT: + if (features.sme2) + regset->size = AARCH64_SME2_ZT0_SIZE; + break; default: gdb_assert_not_reached ("Unknown register set found."); } @@ -933,6 +982,14 @@ aarch64_target::low_arch_setup () if (linux_get_hwcap2 (pid, 8) & HWCAP2_SME) features.svq = aarch64_za_get_svq (tid); + /* Scalable Matrix Extension 2 feature check. */ + CORE_ADDR hwcap2 = linux_get_hwcap2 (pid, 8); + if ((hwcap2 & HWCAP2_SME2) || (hwcap2 & HWCAP2_SME2P1)) + { + /* Make sure ptrace supports NT_ARM_ZT. */ + features.sme2 = supports_zt_registers (tid); + } + current_process ()->tdesc = aarch64_linux_read_description (features); /* Adjust the register sets we should use for this particular set of From patchwork Mon Sep 18 21:27: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: 76333 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 38EC73853556 for ; Mon, 18 Sep 2023 21:32:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38EC73853556 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072720; bh=GHcNSVKCHQZjgVJIHNBq1Hhrad3G0ENes5nRf8nn2Q8=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=aV1mMDd0hH45FRpuFW929+Xzp7m7/VE/KnVgLVGJ26+1RE1bbBwckxq27B+Vq9Oov mtUH6+y51ElT4ReMhy1y5EjYRag4mXVWyg0cbEv8AjdcX6ssuv+hey8Qi5BIOcIRql N3+q+d4lBIW5kSCc1VtS9DU9RDVWONneaAnpir9c= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2065.outbound.protection.outlook.com [40.107.6.65]) by sourceware.org (Postfix) with ESMTPS id 576763856969 for ; Mon, 18 Sep 2023 21:27:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 576763856969 Received: from AS9PR06CA0040.eurprd06.prod.outlook.com (2603:10a6:20b:463::23) by PAWPR08MB9066.eurprd08.prod.outlook.com (2603:10a6:102:342::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:29 +0000 Received: from AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:463:cafe::d9) by AS9PR06CA0040.outlook.office365.com (2603:10a6:20b:463::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 21:27: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 AM7EUR03FT025.mail.protection.outlook.com (100.127.140.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.15 via Frontend Transport; Mon, 18 Sep 2023 21:27:29 +0000 Received: ("Tessian outbound 1eb4e931b055:v175"); Mon, 18 Sep 2023 21:27:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 518faae3960f5408 X-CR-MTA-TID: 64aa7808 Received: from 3b701515c38c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FBCA0A63-A638-47F5-88D6-4900763083AD.1; Mon, 18 Sep 2023 21:27:21 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3b701515c38c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hrT8h9CgzOfDvuLfSZ3INb7GQlB/x/W+PzjftPxG3YC3jZRw27colpxDcYzrcQTHp0GtB7JHBYxOXifC2jxhG5bIl+fuURf9L5/fJeDycD//+x9HMj8Z19mtHgH16cojIpYpexQFwoj3ouk/+I142IEIjLYD/2ZQLrZMuxZ7Vk6eY9NqJeQce4cS+CK9zTmQdr2Kbml5HNdxhZOGsAT+BrfC3cjBtdVMga23It0t2xTbF4E2/D8yeCKv3Mj2PlM/3qtAMU5jA9E9Oo+526dNopdAU23gR6S1wYZQLIem7709QHCh/vYwEqlIj5+rEWtdlAauh30cNcVn4XpN5TumFg== 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=GHcNSVKCHQZjgVJIHNBq1Hhrad3G0ENes5nRf8nn2Q8=; b=AbdCg1+ezX8/6pzuwzAIPBRyMQw0clS5eY4+Ah+rRwUVqm23V8zgTn0W4cd8hT+cJXUSlGs8F0qC0DckiZdkMSYsstvpdX1UVwAOLwBGYHkufAgID53URQ1MT7LDSgAbNeqHu8uiTBP4i9nltoeYVmZI5+krQ3caHsk+ctoAKXmUL8CMRByRdNBVmixKjZK9lp0fEaWkmFKCG+rG7nNApXrsmw4Yz5iviO1vMWjJkqM54wqw/hKJD9WUjHOTdQURw6ML3RXpt04dy1JzSUe0oHvjFf0jbzvmgoTRY2sC2Klyslchn+f890hNkRnCtb6Nw1gfqg/SAq/4IXus0dXCIw== 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 AS9P251CA0015.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:50f::29) by DB4PR08MB9192.eurprd08.prod.outlook.com (2603:10a6:10:3fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 21:27:19 +0000 Received: from AM7EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:50f:cafe::c8) by AS9P251CA0015.outlook.office365.com (2603:10a6:20b:50f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +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 AM7EUR03FT032.mail.protection.outlook.com (100.127.140.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.15 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Sep 2023 21:27:19 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Sep 2023 21:27:18 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:18 +0000 To: CC: Subject: [PATCH v5 3/6] [gdb/aarch64] sme2: signal frame support Date: Mon, 18 Sep 2023 22:27:05 +0100 Message-ID: <20230918212708.660213-4-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212708.660213-1-luis.machado@arm.com> References: <20230918212708.660213-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT032:EE_|DB4PR08MB9192:EE_|AM7EUR03FT025:EE_|PAWPR08MB9066:EE_ X-MS-Office365-Filtering-Correlation-Id: e7c69488-6df5-47be-7d8b-08dbb88e0fb4 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: uoX0AYF1hU3IPViPXOZumkt7RxUyfiUajdPvxjb/Rl6VNnX+abB2csiOgcE+ag2Hh+gZOjn4QFsrpFUeD5lYv7dVqUcnP/rrrWdNS8cZNH1l+iYCYFx5tS0mM++cClV+UYY8VQ4koj0L0uAzezZ8YF2/M1D7UCTzrBCFC++x6/tbH6agDHIhjnVSiu0a3wd9VTcQTK+1hfO6nRSRPGiWabgBdRCKsrZw9xSnRTAxl9vamOwj+YDGXfj7Y9+YlvVdfM/bCANS58IrTZA+1NOO7KSpHQjWXn5JHr5EFp+C2RkzyaebKK8t+3il57S9uKXo/QCA7V/fOTSjAo/xavu/XKHnua9NwN3qoyluvg9fwJVlUX1i5QT8JGI92i/LXo7X/Q2xSI6H/oZInXTxhLqfJJYTXO4Gj2ix74oVCO0x02lJzsMSsnLkkU8D1xL33CrYxQc2nMvA+Ctrz889QUULUHvllO9y/9MivTiWrd1Kmu6CheFIdHDjALovnDwuubqxhZxoK8kBRX4Zc7orv/Zzqn5rqJ+BPr9W8NR835+wjo4ZpMozShW3tblxhH1X7qnf47RZk//0VKCm3tYCrSJXZVFyAeoZDtnNBxm8h2GPFsZngV58gepp6iCIoNErsJkF1CZErezqOGrjiovWshZgYWaYQK79loQW8PJmFCbPJ5KDCAWlcoAtXAHGSWwxWhtKodbtFUv2jidpiPW1LQR4y3OA2ovVhukyDv4T667PfUUCVwKVBm6nR6rsGqkm2Jd9 X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(39850400004)(136003)(346002)(376002)(1800799009)(451199024)(186009)(82310400011)(36840700001)(46966006)(44832011)(5660300002)(4326008)(7696005)(8936002)(8676002)(316002)(41300700001)(6916009)(70586007)(70206006)(478600001)(6666004)(2906002)(1076003)(83380400001)(26005)(2616005)(336012)(426003)(47076005)(36860700001)(36756003)(40480700001)(81166007)(82740400003)(356005)(86362001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9192 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: fe9278f4-3329-4595-18f5-08dbb88e09ef X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X9WwvUjCDBTLCoDAiy0MDmm5ogOq/SzSry7FXyIpY7/KZkTP5PjuByC/45RadnseC/wZy6E0jF6kIUbWD/TpVc0OTrHPxqlgwtwL8i5W3UI99N6YAuBMCSReOXkrI8ZWmplpTXoszhGbtRfFeW9CW5POF7dilURxfGmfplLafOQ7xx7qxH1+wX3nOtHJPsyGp2q0luvtTzw/rfl4A4DiPhv2rpBt5c7yak+21Jmahc4fyW/elcdixHnx231c89e1MWHPVsbi/r2vtFjPLFcXdxk4yTv0g31xgsIrNZhvvQ1NX22moLw3gqS+Yzvx52z7bG42jcpo85T/455ebyvYIw24TtZMH8wmK/9i1/w6nFG+1BtZZlu8Gr5RBCabGS+FkrZZ/bQdlLdNOV1KRiQOrU6gRKubct/HCSxQqqMYxkZPhjxpp4k6AIHH55/prXpVfwT6re3k0op/QV4/YQ6DyBd+LfElsOsHFq91ah+yziAhy+WihgO0S6X5ys7BEy/fg2CwNPd018LyJQuHPL9GJxAG4qhRU04E6ArlZX/xbshFlwjqrrGXwwHy4qmccyTPo9CLF4+pwNf1CyLRKn7sEVFgefi6F4cF4AYsuEFTUSVfsW4llejk7UBp7JLNEmah9XbBavepmb0jMZjqyTH1bPtdbyvziHV0YVRUV8gw8B+aG8lyVxr8UixZjjpwYZoix0Gx6rc/CdCRBpVJf2rS69WVTpNKkctMkczyHQ6FH4ZjBGajTI+4g6/mTXyXS+7g X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(376002)(136003)(39860400002)(396003)(1800799009)(82310400011)(186009)(451199024)(36840700001)(46966006)(40470700004)(81166007)(26005)(82740400003)(2616005)(8936002)(8676002)(1076003)(4326008)(40460700003)(107886003)(83380400001)(36860700001)(2906002)(36756003)(47076005)(426003)(336012)(40480700001)(5660300002)(44832011)(86362001)(7696005)(6666004)(478600001)(6916009)(316002)(70206006)(70586007)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:29.0942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e7c69488-6df5-47be-7d8b-08dbb88e0fb4 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: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9066 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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 ZT state on signal frames and how to restore the contents of the registers. There is a new ZT_MAGIC context that the Linux Kernel uses to communicate the ZT register state to gdb. As mentioned before, the ZT state should only be available when the ZA state is available. Validated under Fast Models. Reviewed-by: Thiago Jung Bauermann --- gdb/aarch64-linux-tdep.c | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 21efa42b2e6..41629902f49 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -159,6 +159,7 @@ #define AARCH64_SVE_MAGIC 0x53564501 #define AARCH64_ZA_MAGIC 0x54366345 #define AARCH64_TPIDR2_MAGIC 0x54504902 +#define AARCH64_ZT_MAGIC 0x5a544e01 /* Defines for the extra_context that follows an AARCH64_EXTRA_MAGIC. */ #define AARCH64_EXTRA_DATAP_OFFSET 8 @@ -192,6 +193,14 @@ /* TPIDR2 register value offset in the TPIDR2 signal frame context. */ #define AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET 8 +/* SME2 (ZT) constants. */ +/* Offset of the field containing the number of registers in the SME2 signal + context state. */ +#define AARCH64_SME2_CONTEXT_NREGS_OFFSET 8 +/* Offset of the beginning of the register data for the first ZT register in + the signal context state. */ +#define AARCH64_SME2_CONTEXT_REGS_OFFSET 16 + /* Holds information about the signal frame. */ struct aarch64_linux_sigframe { @@ -214,6 +223,8 @@ struct aarch64_linux_sigframe 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 the ZT registers. */ + CORE_ADDR zt_section = 0; /* Starting address of the section containing extra information. */ CORE_ADDR extra_section = 0; @@ -221,10 +232,15 @@ struct aarch64_linux_sigframe ULONGEST vl = 0; /* The streaming vector length (SSVE/ZA). */ ULONGEST svl = 0; + /* Number of ZT registers in this context. */ + unsigned int zt_register_count = 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; + /* True if we have a ZT entry in the signal context, false otherwise. */ + bool zt_available = false; }; /* Read an aarch64_ctx, returning the magic value, and setting *SIZE to the @@ -478,6 +494,33 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame, { /* This is context containing the tpidr2 register. */ signal_frame.tpidr2_section = section; + section += size; + break; + } + case AARCH64_ZT_MAGIC: + { + gdb_byte buf[2]; + + /* Extract the number of ZT registers available in this + context. */ + if (target_read_memory (section + AARCH64_SME2_CONTEXT_NREGS_OFFSET, + buf, 2) != 0) + { + warning (_("Failed to read the number of ZT registers from the " + "ZT signal frame context.")); + section += size; + break; + } + + signal_frame.zt_register_count + = extract_unsigned_integer (buf, 2, byte_order); + + /* This is a context containing the ZT registers. This should only + exist if we also have the ZA context. The presence of the ZT + context without the ZA context is invalid. */ + signal_frame.zt_section = section; + signal_frame.zt_available = true; + section += size; break; } @@ -515,6 +558,12 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame, if (!extra_found && section > section_end) break; } + + /* Sanity check that if the ZT entry exists, the ZA entry must also + exist. */ + if (signal_frame.zt_available && !signal_frame.za_payload) + error (_("While reading signal context information, found a ZT context " + "without a ZA context, which is invalid.")); } /* Implement the "init" method of struct tramp_frame. */ @@ -620,6 +669,22 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, /* Restore SVG. */ trad_frame_set_reg_value (this_cache, tdep->sme_svg_regnum, sve_vg_from_vl (signal_frame.svl)); + + /* Handle SME2 (ZT). */ + if (tdep->has_sme2 () + && signal_frame.za_section != 0 + && signal_frame.zt_register_count > 0) + { + /* Is ZA state available? */ + gdb_assert (svcr & SVCR_ZA_BIT); + + /* Restore the ZT state. For now we assume that we only have + a single ZT register. If/When more ZT registers appear, we + should update the code to handle that case accordingly. */ + trad_frame_set_reg_addr (this_cache, tdep->sme2_zt0_regnum, + signal_frame.zt_section + + AARCH64_SME2_CONTEXT_REGS_OFFSET); + } } /* Restore the tpidr2 register, if the target supports it and if there is From patchwork Mon Sep 18 21:27: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: 76326 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 B432F386BFC3 for ; Mon, 18 Sep 2023 21:30:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B432F386BFC3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072624; bh=Ke+g0IVu8QlLFFiRhSHdpWa317RKoDCc2CsIUDwRIsU=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=v5cfP6No2u13XQsu8G1QqYnWkKSMsaZ2/Pgr1VD02FnKxqK0xwe65gK2aFidEvYUn lNzgdiubhGTKnMabvW2OAnJgNCJxf/DNLesKts23IlOsfKurVW4sJjEsR4nagWGbun EAz2Ycm7eFIgJodve5ITm+JrEW/1VB7jZrN/sD8A= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2063.outbound.protection.outlook.com [40.107.105.63]) by sourceware.org (Postfix) with ESMTPS id 4C46B385700B for ; Mon, 18 Sep 2023 21:27:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C46B385700B Received: from AS9PR06CA0262.eurprd06.prod.outlook.com (2603:10a6:20b:45f::16) by AS4PR08MB8119.eurprd08.prod.outlook.com (2603:10a6:20b:58b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:29 +0000 Received: from AM7EUR03FT003.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45f:cafe::ed) by AS9PR06CA0262.outlook.office365.com (2603:10a6:20b:45f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 21:27: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 AM7EUR03FT003.mail.protection.outlook.com (100.127.140.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:29 +0000 Received: ("Tessian outbound b5a0f4347031:v175"); Mon, 18 Sep 2023 21:27:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fc3e23c58b0ca9bd X-CR-MTA-TID: 64aa7808 Received: from fbb314aded84.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 31E3DC63-66EA-4BA0-96F5-2025E4CDFE77.1; Mon, 18 Sep 2023 21:27:22 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fbb314aded84.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LRxBr+C3IVTqe+oF1nlE7z0Iqa1e4ZJ+bvb+qvIKyjax4NOqsm0/1EHybAuyLU4JrYgBmt9nXZiAzxaVCpYIFEn2THVpXtz14ApzFFGtGLdi1WtwCu+ogtBIJ1GCbVNHt/L33XptIxV7cyuQDj7/mwyeT707iLiiGt6Z0ykuIYOa8wsf5YJslWEo3fC8/P5tsdC5colvqBIdpXKrODRCaoOb/gY1b5i7xWcEqhpBeGaL7UFkT39GhCvWKSB5uv89Ewxf0oJN9XtmU/PmT/Ec1OO2C8r/3HE4mUtQplR64xUkwHH2lalPxGojNGlK8d9qqWj4QgIo4aBQLgsx1KL4iQ== 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=Ke+g0IVu8QlLFFiRhSHdpWa317RKoDCc2CsIUDwRIsU=; b=Zb+FQAmjyi5MAgnViBQGJCmqh79jq/hfo1FhH8qzb5xR1432bGqUR4Qu+NrKF8QyLGSlJ1/vvt411xfvAMAGfpcwAczYciL12Zo4MTaj92N7AFHrmuJROhwo9Y4J+LwK2QuwL4Buf++2UXbHDEwAre3NtDKiSv5mmtKhQREuPr+eTrNEZrztJIQhiRkSFHNS13sOYYAXEOrtMkjptmjdwr7RoWF1iifqvK/1tHG21oL3NfEdKu3KrMEUJ+iyfFycXY/CljLuRyTKcTIpOdxZks4MwHyS9zCHeGVlgdamwUZTE+kwFjuBqvpnPCRD351KmdhSsJAZMo9pv3VydCOlGQ== 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 AS8P251CA0028.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::24) by AS8PR08MB9219.eurprd08.prod.outlook.com (2603:10a6:20b:5a2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:19 +0000 Received: from AM7EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::23) by AS8P251CA0028.outlook.office365.com (2603:10a6:20b:2f2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +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 AM7EUR03FT040.mail.protection.outlook.com (100.127.140.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.27; Mon, 18 Sep 2023 21:27:19 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:18 +0000 To: CC: Subject: [PATCH v5 4/6] [gdb/aarch64] sme2: Core file support for ZT register set Date: Mon, 18 Sep 2023 22:27:06 +0100 Message-ID: <20230918212708.660213-5-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212708.660213-1-luis.machado@arm.com> References: <20230918212708.660213-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT040:EE_|AS8PR08MB9219:EE_|AM7EUR03FT003:EE_|AS4PR08MB8119:EE_ X-MS-Office365-Filtering-Correlation-Id: bb27439e-7786-4814-0ee8-08dbb88e1021 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: wPAAIiBqYjVLy8cp0tBaRn0h/od7neUrZoXCd/mB94K7oPa+o3uzbZic2pGb9HY/G+ShHiFF/i1dhuDZbaJkMIXew2P/0Od2s1kJTr/uR1VDHbDPTdQZto/UgM+REXk3A8YoJtd3BEPxKReBLly0IKSiixc0Z78G7pP/+xcedlnTE8Ca7ph5lCSi+zH/ADbs9+ADc//KZXeE9/zyb+H9NuCqjkPV6tq9guv34QmdZfk01/oUoJV2E1HfuAsHCtPfg+OKQ7ca3r8vW26w8Y58NCQUaCWvoLFGtVOe0QpZzjHwTK+ClC/QfZ2DLP5yQTUNd2cxaqV3WEQ6B7i7LPTl+c148NOBVgxMT6UW2vpzptaCpOfMTWPASfiSmqUBCVxI1Wov+SnCjANWpaqRW7x7XV86bsGwUajHUgwKY/jKzeyP6HA/HjTOp3Hz9aWaHJlM0yoKgxwrZq1H85OzP+HEceJ0/vHh9FyKD1CR5O5cDg6tjUeL8nwpOD/CMIMRPTB+txlm9I75WdRjCnjDwESqZUVHoVeqquQbO1WfuJhMpdt5W8mYGgJg5/3GIkraFRE2i4c3twndC5G6anBUjfMaywLtvqT1yWQI4XE3zU3vgf1FYw3P0X0DrYlc5kFe76vbt08LTRBZLqlG7ZvgswrVhxcpfzko9SPeT90qXd/KxCGlCNp005n7u26Ayb1KaXfBgqQkh79ahVk5r/x07cIAKkKbcy95HT0i2UcBTnSpbpnXq8CILQhlo++oK5Fapinzh6rY0UWvAbhFDhzXeJWoEw== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(82310400011)(186009)(1800799009)(451199024)(40470700004)(36840700001)(46966006)(7696005)(6666004)(83380400001)(478600001)(26005)(1076003)(2616005)(47076005)(336012)(426003)(2906002)(44832011)(70586007)(70206006)(6916009)(316002)(8676002)(5660300002)(4326008)(8936002)(40460700003)(41300700001)(36860700001)(40480700001)(36756003)(356005)(82740400003)(86362001)(81166007)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9219 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT003.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 34b1875c-c067-4fed-456b-08dbb88e0a20 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R7pXgoWyLMNklKxnjcvxS9xCBLvEHTIncP3r3wzNysusiOOmXMR4Wvg2FBCIynM+R68r1o7aMDSKO0YvTfMfgQpEe7pUuHPLN+svhVGg4eJj7mM1SlzkjsbCnik1+9YEp/daRjxKi3G4InLEm63aT4q8yIBKJ7csLrnQgUVfT+8ig4H9mZ2hz/CDfEKm0rxe0ohYtYtZ5bTIPW+VxbWElMS82nPkbVNpcQy0VcY3NvNbL/H90gsd7FZkCPyU53QMuFQCZoXjEg5h8YSTX8kv8nZF0cfpv8juMKMNBYnTZsvCemsmeUmEBhAT3dLEbA/lXYugpRz25punZcinXpsp9TOImeF+SrNCpVFst2sGlN/+GSoIcLAzrypWW+4Da/3M1glu81dSbZ99wH/fl/ifgLRMhXNwQRkErggrdmpEha1QsrNTXHAmnEapuB8lngvqyZWBQcDvkP9sbDFUC0Aow/YRkStdF6pWzPZq3lT7AHMEQSHQ0qRgNEGXxHmoQDwV3orvJCZXjNIH3Hm0xhEISaMevOgutM5R0/0t/qsAY9s8T0IFjxFIpRAfKCPtkTb4VF7gCOvy2lt3lJrGEbxd8IxIqMbyQpxhDnSnQLS/B78tw2jNBCJHFHhCV6ecp73MXgLth2APyUjB9Wk9WdimYY3PSBxjVDGBpxdXyR4i9sXoJ5oRwJynk+sRbg90e9TXYxqdOd9M+REA64LKomlcltwLxWe3fha901sEfXylYdlXYIGit8VLPqQ8u8zV9gkZ X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(136003)(39860400002)(346002)(396003)(451199024)(82310400011)(1800799009)(186009)(46966006)(40470700004)(36840700001)(40480700001)(5660300002)(44832011)(7696005)(86362001)(316002)(41300700001)(70206006)(70586007)(6666004)(478600001)(6916009)(2616005)(8936002)(26005)(81166007)(82740400003)(8676002)(2906002)(36860700001)(36756003)(426003)(47076005)(336012)(107886003)(40460700003)(1076003)(4326008)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:29.8057 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb27439e-7786-4814-0ee8-08dbb88e1021 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: AM7EUR03FT003.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8119 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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" v3: - Assert the buffer size is capable of holding data we need to read/write. --- This patch adds support for ZT register dumps/reads for core files. The ZT register is available when the SME2 feature is advertised as available by the Linux Kernel. Unlike the enablement for SME1 and the ZA register, support for SME2 is rather simple given the fixed size of the ZT0 register. Validated on the Fast Models. Reviewed-by: Thiago Jung Bauermann --- gdb/aarch64-linux-tdep.c | 87 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 41629902f49..f1fcce9b9eb 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1373,6 +1373,56 @@ aarch64_linux_collect_za_regset (const struct regset *regset, 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_zt_regset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *buf, size_t size) +{ + /* Read the ZT register note from a core file into the register buffer. */ + + /* Make sure the buffer contains at least the expected amount of data we are + supposed to get. */ + gdb_assert (size >= AARCH64_SME2_ZT0_SIZE); + + /* Handle an empty buffer. */ + if (buf == nullptr) + return regcache->supply_regset (regset, regnum, nullptr, size); + + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Supply the ZT0 register contents. */ + regcache->raw_supply (tdep->sme2_zt0_regnum, buf); +} + +/* 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_zt_regset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *buf, size_t size) +{ + /* Read the ZT register contents from the register buffer into the core + file section. */ + + /* Make sure the buffer can hold the data we need to return. */ + gdb_assert (size >= AARCH64_SME2_ZT0_SIZE); + gdb_assert (buf != nullptr); + + aarch64_gdbarch_tdep *tdep + = gdbarch_tdep (regcache->arch ()); + + /* Dump the register cache contents for the ZT register to the buffer. */ + regcache->collect_regset (regset, tdep->sme2_zt0_regnum, buf, + AARCH64_SME2_ZT0_SIZE); +} + /* Implement the "iterate_over_regset_sections" gdbarch method. */ static void @@ -1461,6 +1511,30 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, SVE_HEADER_SIZE, SVE_HEADER_SIZE + std::pow (sve_vl_from_vq (tdep->sme_svq), 2), &aarch64_linux_za_regset, "ZA register", cb_data); + + /* Handle SME2 (ZT) as well, which is only available if SME is + available. */ + if (tdep->has_sme2 ()) + { + const struct regcache_map_entry zt_regmap[] = + { + { 1, tdep->sme2_zt0_regnum, AARCH64_SME2_ZT0_SIZE } + }; + + /* We set the register set size to REGSET_VARIABLE_SIZE here because + in the future there might be more ZT registers. */ + const struct regset aarch64_linux_zt_regset = + { + zt_regmap, + aarch64_linux_supply_zt_regset, aarch64_linux_collect_zt_regset, + REGSET_VARIABLE_SIZE + }; + + cb (".reg-aarch-zt", + AARCH64_SME2_ZT0_SIZE, + AARCH64_SME2_ZT0_SIZE, + &aarch64_linux_zt_regset, "ZT registers", cb_data); + } } if (tdep->has_pauth ()) @@ -1566,6 +1640,19 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, features.svq = aarch64_linux_core_read_vq (gdbarch, abfd, ".reg-aarch-za"); + /* Are the ZT registers available? */ + if (bfd_get_section_by_name (abfd, ".reg-aarch-zt") != nullptr) + { + /* Check if ZA is also available, otherwise this is an invalid + combination. */ + if (bfd_get_section_by_name (abfd, ".reg-aarch-za") != nullptr) + features.sme2 = true; + else + warning (_("While reading core file sections, found ZT registers entry " + "but no ZA register entry. The ZT contents will be " + "ignored")); + } + return aarch64_read_description (features); } From patchwork Mon Sep 18 21:27: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: 76330 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 83DFF383C9B7 for ; Mon, 18 Sep 2023 21:31:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83DFF383C9B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072674; bh=yCSTnitgciZ1+wToWthHQgVxd6MZEl6/DXie3haVkPA=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=KxcVDP3HISEa8RbMBzoOaLiT/YBZrqWEGuwSL0rShlGTnyEzveuxkKuEMBk9hU/E2 pMJ7kUzujJmrf0KH6J4z5L1/Hnx1G0dbotyEY/Imd9EdBvE8NDO7OTRHBeYxpg7eRw AhxAovK0jyxaf7JEgVCB9bZ1oVSSBTN7F5q7Gauc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2078.outbound.protection.outlook.com [40.107.247.78]) by sourceware.org (Postfix) with ESMTPS id 6F25E3857713 for ; Mon, 18 Sep 2023 21:27:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F25E3857713 Received: from AM6P192CA0093.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::34) by AS4PR08MB7686.eurprd08.prod.outlook.com (2603:10a6:20b:505::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:28 +0000 Received: from AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8d:cafe::ea) by AM6P192CA0093.outlook.office365.com (2603:10a6:209:8d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:28 +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 AM7EUR03FT029.mail.protection.outlook.com (100.127.140.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.15 via Frontend Transport; Mon, 18 Sep 2023 21:27:28 +0000 Received: ("Tessian outbound 30c9f5e988c5:v175"); Mon, 18 Sep 2023 21:27:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d2539744d47b2b87 X-CR-MTA-TID: 64aa7808 Received: from a12335c20551.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 42A5D1C8-864D-4552-8A50-CE1EF5B91D1B.1; Mon, 18 Sep 2023 21:27:21 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a12335c20551.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oU79GlfJg91HrpA2arz8gDQ7z7EfiUV9HXZALSEyM+SIWotW0uN/LqGg7mqDPIM3bqikonmQX67qPPBVIaCIAlLhamro1CtdpNsYRKLxj8iEwV/MoEPzY5kgDdc8c/RtIVkJs6bkYgrXnQxRBEB2+rXL9dDjAHe6wn3ozzTSUvvh1cMcS9scVtNY/EIs/eURE6JnILAVuZ23cbglklVvD5F/wwXB3Ks7HoP6j8PCliPhYo4ISBNUwBM0JcIWH9YmZu/Y60TN/IzjjNPPyhpiOkXnJzvmquuwOiq3fv3jGcqc5baJVYcnTlQ5iU6Phm1gMMz77uT/o8mFKHHjDl5LRg== 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=yCSTnitgciZ1+wToWthHQgVxd6MZEl6/DXie3haVkPA=; b=iueVZDgdMBmvFfMDq6b0QstbTtCQPbpZHxUzgLXikuzk/VEVOgyE/IoZXeb5csLElNTnm8Q+atPqx64yyK0eTz7P+mzoWCOc1C7pFlrzy8VyHALDSwLoRBfA6KOjlEHObY5tzhnW53sjHPyEC47cCCgno4dYSZnrfE4vQ7xr/z0zeXRx3qpF1IqcPzipGPxCMKmqU4w23MwU2AbTFHGKO09XWMwGSPuAR4ebcwExEKMhxw2jolplQKU0g1MduaUVa/+LCSh3wV0oi1DRcEGwQFwwVAd+fOtPDmkEDQWkRJQauCasZo1rTSYkGsVRLvE7y5ksMEiqT9iWD5chBllJKw== 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 AS8P251CA0021.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::18) by DU2PR08MB10038.eurprd08.prod.outlook.com (2603:10a6:10:49c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 21:27:20 +0000 Received: from AM7EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::88) by AS8P251CA0021.outlook.office365.com (2603:10a6:20b:2f2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 21:27: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 AM7EUR03FT040.mail.protection.outlook.com (100.127.140.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +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.27; Mon, 18 Sep 2023 21:27:19 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Sep 2023 21:27:19 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +0000 To: CC: Subject: [PATCH v5 5/6] [gdb/testsuite] sme2: Extend SME tests to include SME2 Date: Mon, 18 Sep 2023 22:27:07 +0100 Message-ID: <20230918212708.660213-6-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212708.660213-1-luis.machado@arm.com> References: <20230918212708.660213-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT040:EE_|DU2PR08MB10038:EE_|AM7EUR03FT029:EE_|AS4PR08MB7686:EE_ X-MS-Office365-Filtering-Correlation-Id: 61bdc694-79f2-4b45-af84-08dbb88e0f34 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: 1ZexVtYHng+28lacuY/G6ek7taenYplxOneTCPkxX13m9UYMVGMivyuqRFlgLDliKDcolqBc0tMSsNSXaKKBODjPmfYuHon/gz9UMzVMz9weOsL5c+Y3oc8oBFD/E4gOymM5W/5wR42q3mFNDVZqkX2owW0MyJOmmItjjyKGquHwPMIYmjU5btduS2YNluC2iqAkj9Af4Pc0Mj9xlnHfq73ZrgnCDHY4fmCQ/dRlWT1WPpqswjenfXg9vmWuRN2jsu/eJJfuGPR7V9ldz9vrRbsp7qA6bqLEWXtRQ2Y6mKhFqDly5e4RmjEU1CIyBbwg91413+oURlYNZ+LtHYvjNMp9fsiKm+MR/zwTpHIugkE6f9LaeXxljShY4SggROR1gUf+OIGKhNfulsAU8yaR+n09G7B/9cViiSl+dJn6164M7Pn1UU2KMR977vf6iRjt98+ca5ct/z9Qs7w8C4BpRhUB7X4vUOkXXuUx1vili3xOEBQB6W0XDwQKVlsu6/zfH4rnX5v1C5xGkfNY42++mpYp/XizqbzMrMkUZd8KeQDEjlMqZkWqzb9iSw4K43eQ+wpWZXhDrp38xNgajG7S8+aXSpVlr+qIWVyRm0TBMob7UhFJyPPnHzzWKrMn1oJiNfr3IepAdOdmW/A9d2fpMDhlfGkXmDHWmR2Tzu3mq+Ra98GXEnj0oK+XYTi2e+jFeMVQCGe6NdzrQDIz8vXw+tTQCo+nZcQFAMQwPfBSlyc= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39850400004)(136003)(346002)(376002)(396003)(1800799009)(186009)(82310400011)(451199024)(36840700001)(46966006)(7696005)(6666004)(83380400001)(82740400003)(356005)(81166007)(86362001)(36860700001)(47076005)(36756003)(2616005)(426003)(336012)(1076003)(40480700001)(26005)(30864003)(70586007)(6916009)(316002)(70206006)(41300700001)(2906002)(44832011)(5660300002)(8936002)(8676002)(4326008)(478600001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB10038 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b746dd61-2962-4b10-ccf5-08dbb88e0a48 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u7NyDS/rLdSlA7bxBd7RvVxmkyG5PAlu6776tB+xMprWBkKkNMsYAltXHrSIBTsLWxcRWnAaBNl5pJ3ahUVcaHOnnEyRk20i7935NOdh2jWIfre9ZUzpJiyK/1B4XpKPnvAeE9RG0/LObVEXqSzt5npUT680ruurY5fn+gKtVAHzkZLlpXHYuGMWKkk/3A+oFamLx0MMmUdg077USPJyBCap2fRKrgu5PdNI7IzUWLtbJKvt/XSZPjphQGnNYHCoW8xaNqa2zTxJPAmp8CHHnGfDIAgTVVJaXL/IsGqBkPuB/ShReXM9dHpORE2OznRIE4g0EFgPdcY11s4TNIAH21rx2WyqguF3OTGJMCTadPItRSPBTzWLmKPJX7xJZm4C4YtLm8KDd8tLovDdOXLw6vY76WUFXfJ+C6kjW1Q/tAx7F4Wjj2rTh9n6bYZnlfKZA2KYuhmN1/fhot8Bct8ziM6ew7My1DBs+LjfIJw5qDcHIhA86wja0XGcaO3Eka7aT9OZDEZYkRKW2wq80ssowpy6H3fuKhO8h8KEzkn0ce05Q14x6eYOPLkZiPC0/KgI0Qec8NDVOhaWXTL2ZB4NI0Ju433c34SFz8LtDWS4xOyKYTUol6/ZP6ditDzcp2A8aJ4ltmBPkwtZTUMOm3slDQA95hZmWPFTigs6c6vzZ2aEgFv8FljDXflku79O30gtgP+AD9zFED6xuk2qLm1ql5rwkd5a8Stmp1uwmGgBbWQ= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(39860400002)(396003)(376002)(82310400011)(186009)(1800799009)(451199024)(36840700001)(46966006)(40470700004)(81166007)(26005)(82740400003)(2616005)(8936002)(8676002)(4326008)(1076003)(40460700003)(107886003)(83380400001)(36860700001)(2906002)(36756003)(30864003)(47076005)(426003)(336012)(5660300002)(40480700001)(44832011)(86362001)(7696005)(478600001)(6666004)(6916009)(316002)(70206006)(70586007)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:28.2253 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61bdc694-79f2-4b45-af84-08dbb88e0f34 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: AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7686 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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" v3: - Removed duplicate function from aarch64.exp that is already in aarch64-scalable.exp. v2: - Updated to use the new naming/organization of the test support files. --- Reusing the SME tests, this patch introduces additional tests to exercise reading/writing ZT0, availability of the register set, signal context reading for ZT0 and also core file generation. Reviewed-by: Thiago Jung Bauermann --- gdb/testsuite/gdb.arch/aarch64-sme-core.c | 32 +++++++++++++- .../gdb.arch/aarch64-sme-core.exp.tcl | 2 +- .../aarch64-sme-regs-available.exp.tcl | 17 +++++++ .../gdb.arch/aarch64-sme-regs-sigframe.c | 32 +++++++++++++- .../aarch64-sme-regs-sigframe.exp.tcl | 13 +++++- .../aarch64-sme-regs-unavailable.exp.tcl | 12 +++++ gdb/testsuite/gdb.arch/aarch64-sme-sanity.c | 32 +++++++++++++- gdb/testsuite/lib/aarch64-scalable.exp | 44 +++++++++++++++++++ 8 files changed, 176 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.c b/gdb/testsuite/gdb.arch/aarch64-sme-core.c index d71d18ebd3b..fcb14670e0d 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-core.c +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.c @@ -35,6 +35,11 @@ #define HWCAP2_SME (1 << 23) #endif +#ifndef HWCAP2_SME2 +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#endif + #ifndef PR_SVE_SET_VL #define PR_SVE_SET_VL 50 #define PR_SVE_GET_VL 51 @@ -145,6 +150,27 @@ initialize_za_state () __asm __volatile ("bne loop"); } +static void +initialize_zt_state () +{ + unsigned long hwcap2 = getauxval (AT_HWCAP2); + + if (!(hwcap2 & HWCAP2_SME2) && !(hwcap2 & HWCAP2_SME2P1)) + return; + + char buffer[64]; + + for (int i = 0; i < 64; i++) + buffer[i] = 0xff; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize ZT0. */ + /* ldr zt0, x0 */ + __asm __volatile (".word 0xe11f8000"); +} + static void initialize_tpidr2 () { @@ -273,8 +299,8 @@ static int set_svl_size (int new_svl) 0 - FPSIMD 1 - SVE 2 - SSVE - 3 - ZA - 4 - ZA and SSVE. */ + 3 - ZA (+ SME2 ZT0) + 4 - ZA and SSVE (+ SME2 ZT0). */ void enable_states (int state) { @@ -295,6 +321,7 @@ void enable_states (int state) { enable_za (); initialize_za_state (); + initialize_zt_state (); } else if (state == 4) { @@ -302,6 +329,7 @@ void enable_states (int state) enable_sm (); initialize_sve_state (); initialize_za_state (); + initialize_zt_state (); } return; diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl index 851e6e31ec3..ef76ef94269 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl @@ -13,7 +13,7 @@ # 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. +# Exercise core file reading/writing in the presence of SME and SME2 support. # This test exercises GDB's dumping/loading capability for Linux # Kernel core files and for gcore core files. diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl index 71637f9cdc1..f62559554f9 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl @@ -14,6 +14,7 @@ # along with this program. If not, see . # Exercise reading/writing ZA registers when there is ZA state. +# Exercise reading/writing to ZT0 when there is ZA state available. load_lib aarch64-scalable.exp @@ -119,6 +120,22 @@ proc check_regs { mode vl svl } { set last_slice [expr ($last_slice / 2)] set num_elements [expr $num_elements / 2] } + + # Exercise reading/writing from/to SME2 registers. + if [is_sme2_available] { + # The target supports SME2. + set zt_size 64 + gdb_test "print sizeof \$zt0" " = $zt_size" + + # Initially, when ZA is activated, ZT0 will be all zeroes. + set zt_pattern [string_to_regexp [1d_array_value_pattern 0 $zt_size]] + gdb_test "print \$zt0" " = $zt_pattern" "validate zeroed zt0" + + # Validate that writing to ZT0 does the right thing. + initialize_1d_array "\$zt0" 255 $zt_size + set zt_pattern [string_to_regexp [1d_array_value_pattern 255 $zt_size]] + gdb_test "print \$zt0" " = $zt_pattern" "read back from zt0" + } } # diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c index 9bc3e9c16fc..8f0827cf83a 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.c @@ -34,6 +34,11 @@ #define HWCAP2_SME (1 << 23) #endif +#ifndef HWCAP2_SME2 +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#endif + #ifndef PR_SVE_SET_VL #define PR_SVE_SET_VL 50 #define PR_SVE_GET_VL 51 @@ -152,6 +157,27 @@ initialize_za_state () __asm __volatile ("bne loop"); } +static void +initialize_zt_state () +{ + unsigned long hwcap2 = getauxval (AT_HWCAP2); + + if (!(hwcap2 & HWCAP2_SME2) && !(hwcap2 & HWCAP2_SME2P1)) + return; + + char buffer[64]; + + for (int i = 0; i < 64; i++) + buffer[i] = 0xff; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize ZT0. */ + /* ldr zt0, x0 */ + __asm __volatile (".word 0xe11f8000"); +} + static void initialize_sve_state () { @@ -271,8 +297,8 @@ static int set_svl_size (int new_svl) 0 - FPSIMD 1 - SVE 2 - SSVE - 3 - ZA - 4 - ZA and SSVE. */ + 3 - ZA (+ SME2 ZT0) + 4 - ZA and SSVE (+ SME2 ZT0). */ void enable_states (int state) { @@ -293,6 +319,7 @@ void enable_states (int state) { enable_za (); initialize_za_state (); + initialize_zt_state (); } else if (state == 4) { @@ -300,6 +327,7 @@ void enable_states (int state) enable_sm (); initialize_sve_state (); initialize_za_state (); + initialize_zt_state (); } return; diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl index c062e200edf..e2234c06697 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl @@ -98,10 +98,12 @@ proc test_sme_registers_sigframe { id_start id_end } { # Check the value of SVCR. gdb_test "print \$svcr" [get_svcr_value $state] "svcr before signal" - # Handle SME ZA initialization and state. + # Handle SME ZA and SME2 initialization and state. set byte 0 + set sme2_byte 0 if { $state == "za" || $state == "za_ssve" } { set byte 170 + set sme2_byte 255 } # Set the expected ZA pattern. @@ -168,6 +170,15 @@ proc test_sme_registers_sigframe { id_start id_end } { # Check the value of TPIDR2 in the signal frame. gdb_test "print/x \$tpidr2" " = 0x102030405060708" "tpidr2 contents from signal frame" + + # Check the value of SME2 ZT0 in the signal frame. + if [is_sme2_available] { + # The target supports SME2. + set zt_size 64 + gdb_test "print sizeof \$zt0" " = $zt_size" + set zt_pattern [string_to_regexp [1d_array_value_pattern $sme2_byte $zt_size]] + gdb_test "print \$zt0" " = $zt_pattern" "zt contents from signal frame" + } } } } diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl index 1a5ebf1cdaa..326d09bdbce 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl +++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl @@ -17,6 +17,7 @@ # - 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. +# - Validate that reading ZT0 without an active ZA state works as expected. load_lib aarch64-scalable.exp @@ -89,6 +90,17 @@ proc_with_prefix check_regs { vl svl } { set expected_size [expr $expected_size / 2] set elements [expr ($elements / 2)] } + + # Exercise reading from SME2 registers. + if [is_sme2_available] { + # The target supports SME2. + set zt_size 64 + gdb_test "print sizeof \$zt0" " = $zt_size" + + # If ZA is not active, ZT0 will always be zero. + set zt_pattern [string_to_regexp [1d_array_value_pattern 0 $zt_size]] + gdb_test "print \$zt0" " = $zt_pattern" + } } # diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c index 694de0626d2..71b46b17855 100644 --- a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c +++ b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.c @@ -33,6 +33,11 @@ #define HWCAP2_SME (1 << 23) #endif +#ifndef HWCAP2_SME2 +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#endif + static void enable_za () { @@ -131,6 +136,27 @@ initialize_za_state () __asm __volatile ("bne loop"); } +static void +initialize_zt_state () +{ + unsigned long hwcap2 = getauxval (AT_HWCAP2); + + if (!(hwcap2 & HWCAP2_SME2) && !(hwcap2 & HWCAP2_SME2P1)) + return; + + char buffer[64]; + + for (int i = 0; i < 64; i++) + buffer[i] = 0xff; + + __asm __volatile ("mov x0, %0\n\t" \ + : : "r" (buffer)); + + /* Initialize ZT0. */ + /* ldr zt0, x0 */ + __asm __volatile (".word 0xe11f8000"); +} + static void initialize_sve_state () { @@ -190,8 +216,8 @@ initialize_sve_state () 0 - FPSIMD 1 - SVE 2 - SSVE - 3 - ZA - 4 - ZA and SSVE. */ + 3 - ZA (+ SME2 ZT0) + 4 - ZA and SSVE (+ SME2 ZT0). */ void enable_states (int state) { @@ -212,6 +238,7 @@ void enable_states (int state) { enable_za (); initialize_za_state (); + initialize_zt_state (); } else if (state == 4) { @@ -219,6 +246,7 @@ void enable_states (int state) enable_sm (); initialize_sve_state (); initialize_za_state (); + initialize_zt_state (); } return; diff --git a/gdb/testsuite/lib/aarch64-scalable.exp b/gdb/testsuite/lib/aarch64-scalable.exp index 5512fcb9d1c..f77daec2308 100644 --- a/gdb/testsuite/lib/aarch64-scalable.exp +++ b/gdb/testsuite/lib/aarch64-scalable.exp @@ -186,6 +186,18 @@ proc check_sme_regs { byte state svl } { gdb_test "print \$za" $za_pattern } +# +# Validate the values of the SME2 registers. +# +proc check_sme2_regs { byte } { + # The size of the ZT registers should always be fixed to 64 bytes. + set zt_size 64 + gdb_test "print sizeof \$zt0" " = $zt_size" + # Check that we have the expected pattern of bytes for the ZT registers. + set zt_pattern [string_to_regexp [1d_array_value_pattern $byte $zt_size]] + gdb_test "print \$zt0" $zt_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 @@ -200,6 +212,9 @@ proc check_state { state vl svl } { # # The SME (ZA) register is initialized with a value of 0xaa (170) for # each byte. + # + # The SME2 (ZT) registers are initialized with a value of 0xff (255) for + # each byte. # Check VG to make sure it is correct set expected_vg [expr $vl / 8] @@ -234,6 +249,35 @@ proc check_state { state vl svl } { check_sve_regs $sve_byte $state $vl $svl # Check SME registers check_sme_regs 170 $state $svl + + # Check SME2 registers + if [is_sme2_available] { + # The SME2 ZT0 register will always be zero, except when ZA is active. + set sme2_byte 0 + if {$state == "za" || $state == "za_ssve"} { + set sme2_byte 255 + } + + # The target supports SME2, so check the ZT register values. + check_sme2_regs $sme2_byte + } } +# +# Return 1 if SME2 is available (meaning the ZT0 register exists). +# Return 0 otherwise. +# +proc is_sme2_available { } { + # Does the ZT0 register exist? + gdb_test_multiple "print \$zt0" "" { + -re " = void.*${::gdb_prompt} $" { + # SME2 is not available. + return 0 + } + -re " = {.*}\r\n${::gdb_prompt} $" { + # SME2 is available. + return 1 + } + } +} From patchwork Mon Sep 18 21:27: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: 76335 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 C68B93842277 for ; Mon, 18 Sep 2023 21:32:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C68B93842277 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072752; bh=v03NClzRSGU2y/U6mPu9/SEVy9w6XsTcfVgskWWpRao=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=HS26UD42k0hpk7DNWnNCazcXhGShjxPJnvm+0DaYDmGABjHcIrZ738f1UBqtOAgIq QYNc5HyRs7AMLwGuf6JhDIrMvbpoeLXqE0fNmsg52NxrXnWCFTNjVxtBcWVZohpUiT GKm05jWek+eS8gROIhic3aFuzcNOYkqRINdjAzC8= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2067.outbound.protection.outlook.com [40.107.104.67]) by sourceware.org (Postfix) with ESMTPS id 13F7C3857703 for ; Mon, 18 Sep 2023 21:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13F7C3857703 Received: from AS4P190CA0013.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:5de::15) by PAVPR08MB9843.eurprd08.prod.outlook.com (2603:10a6:102:31f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 21:27:34 +0000 Received: from AM7EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:5de:cafe::94) by AS4P190CA0013.outlook.office365.com (2603:10a6:20b:5de::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:33 +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 AM7EUR03FT045.mail.protection.outlook.com (100.127.140.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:33 +0000 Received: ("Tessian outbound 169aaa6bf2b7:v175"); Mon, 18 Sep 2023 21:27:33 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1a2b4b904cc18a2f X-CR-MTA-TID: 64aa7808 Received: from 216c9b1f73e1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 98CB37F6-9C95-4D27-AF89-DCDA2A58E7C7.1; Mon, 18 Sep 2023 21:27:26 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 216c9b1f73e1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CTbW9fGDLuCSmhv8vqdAZK38ze7YsUojNP+d4Bk/4csfmx1Cqq98NOSALdPj4+U++iINr/MLe8grbbKqNTml0+oSVzTQaZgCSuXjLdwY01tiUNvT4z55zVJNw0DgWlAMjCOs7qU/NFix4T27crO7omaxJqPJKqrWP+S8U3mnlnKdhacljUNk50e5m3FfLWAhvWaU4tGB6xaj3MSaSJZIjbXtwqi62CD0K6zjRHkA35kVazpW+sWBnuB+UctiChr+kZsjFqyqDYgeHPZBAjXyQ3ZCZpBcmfE+Slf7RoOSOfAATlDjlTo5cIiIGPeNWqLNU8941CKNgrwJBHVYZjdOGg== 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=v03NClzRSGU2y/U6mPu9/SEVy9w6XsTcfVgskWWpRao=; b=Z1ouvI3YpwutcRuDZyS2s2SRVwzo8I+fkMmGOGtxPndNkjwv+aBxLTq/N7iigaZUbTB1yj0V255As9W1Y9TUdLpxShBUQdMU2M11IbeIrOJ31SSuPbv+L7EbiPWg8vtBi+7PXEhcQTS1iwmu6r2768Xg1d2iy5QqdUWP6giXaIMt5izdf8S2bpkrvEMHtMe0ErPb7lVICLho238n9uegtlNs7PsevXvz77KvpbCGnx/KxhmTZFxw+cUgqE1P100l7SsyH7EheHbhFqDRUX+F8I7nXkGA1JYWiNyHMVlPuTKtkEKue4NXbxrbYnriDcoLp6IbegNUSFr9cdt53V2Z+A== 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 AS8P251CA0022.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::6) by AS8PR08MB7743.eurprd08.prod.outlook.com (2603:10a6:20b:524::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:20 +0000 Received: from AM7EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::6a) by AS8P251CA0022.outlook.office365.com (2603:10a6:20b:2f2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27: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 AM7EUR03FT040.mail.protection.outlook.com (100.127.140.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:20 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.27; Mon, 18 Sep 2023 21:27:19 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:19 +0000 To: CC: Subject: [PATCH v5 6/6] [gdb/docs] sme2: Document SME2 registers and features Date: Mon, 18 Sep 2023 22:27:08 +0100 Message-ID: <20230918212708.660213-7-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212708.660213-1-luis.machado@arm.com> References: <20230918212708.660213-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT040:EE_|AS8PR08MB7743:EE_|AM7EUR03FT045:EE_|PAVPR08MB9843:EE_ X-MS-Office365-Filtering-Correlation-Id: bd5d93ae-797a-4d23-51bd-08dbb88e129d 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: v6OdhR1il28G1+e3xgZcCuLG01as9yJlDFeFeF9A1lbSrUgCJqS/NNB2TibbjHBWdxZzTxAB+H8G22GUcF2TtWt/3FlhL2YLog9vLVyDjHndbVVc12Ypo5/oKOHOAI5nr9W8Irapc8fg6r+0apVmFOfhkidB5yZdrYrai9RdiosDzoDYVeXekCb4aTksFj6VabF+lXkyNwDriDlG4kUKaxCZOSkoVQ2cj0/PACewvGTwrQ8vrYXU/47aUhr2qkiSqhglNNPViBxW5ZqiHH3z0MJ0ERc04B+/mzdYFl28Xh8yEiGQxzrfjq2LK5kurSNFF60TTYHQC2/OawAyY4IOshQjUkdIRheCLTl/v51mwnktCTsOx+HKJVk2k7L176maMIENVQStENCYInKOO4aCHtcdOwGVxcKAv76iujUg1l4jc1XB5EudbFHOvJ8QmQr+V1Nf5bzdMOU6VPYF0j3hIT1dfo+tubD/Bf0drqQ0x0kcOUnu7k83RlMraY6zF1rvLUFz/QmJR6et75HaIQGpctG2GDeMSElkZanaWGX11O/mPAXChXog/72oC4velSXyLjo8RvGNoxSdMHs+dYlmo4M1w6lnTIFcN59SkAOY3XC8mC7XRn60D2HP6YmgUtAFxMwXMg0eniKqiD/cgAP2GLGeu5cfVj7QvxphJkqxRqQ4Y990OhNA/eJsmKW7hWrJZzX4lOemdDVKpy5IxSVZbsj5MDr/kOYdmW6Cn34DZl/0i0gfvgIupTjHVOpAHj4sSkkNPxeovUBeY5V4eDza0g== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(346002)(136003)(39860400002)(376002)(82310400011)(451199024)(186009)(1800799009)(40470700004)(36840700001)(46966006)(6666004)(7696005)(83380400001)(478600001)(1076003)(26005)(2616005)(47076005)(336012)(426003)(2906002)(316002)(44832011)(70206006)(6916009)(70586007)(41300700001)(5660300002)(8676002)(356005)(8936002)(4326008)(40460700003)(40480700001)(36756003)(36860700001)(86362001)(82740400003)(81166007)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7743 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e7c740dd-1f47-4c57-8e09-08dbb88e0a8b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NQLEbTZFc1bMXmQvvwxLLlFZ2JTnf8ejntnjJ2wbfK1ABImQpdjGTV+DyhBayIwSj498Qh5MvZgt71FUWp+wUcaHdTFMtFh1G8+S2We4W+JfknV/NzFuE1kapCcUoksUH8vAUUyz44t3iB1pAfxkNfg8K737ukYWYSuhD23TIx+09HjL67P847MjHb9U9DjQpz7vseiseOzAOfBDCuKTkz7SjCvKbatKd4xHWZhU00p4rGHQKHUtLMYFeKFdYB8H/w5Q0ev0W8alk+30zy8oh0ygW++ijnTSkHsxSsuw/+7kH7LMWqW84Inqb8PIIzOYqDbwjAKcd0sWH5FhjI4eo9T+I0sxhzH9aqyB1esnLGzITJanqwY8INURxWARkzWiVmTEK4u5o3BPo+pcp56SkaN5Ise35BS23g45nRu3d2aw3VNR2UX8rXNgWUguunHxuLXjoAd8VKY4QFtjvHfb8H7h4eBSw0dQ3vkzjvElP56GE53M1Gc7X8PpRpCb7f7s4yvVBaCqssQYKe2aOJm7ZM9Eka1j6WtS4ycvS92VTTNJ93keY1aYhB87KizUX1zPmVYdwHH0unbouw4XyJPEdYylZtP3CljajC/ZIl+qWtIMjmNVuP4x/HpJQr/QQx/IIf2pjsvZj/XijFZ8ZgvyuS5MskXge8kmQblyWsn8fdc8ll6/J5qkycMQOvA3sCI9KqPJxQAeJWUL5vvoSUyL4iDrONnum6WpD9XWM4e0l74= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(136003)(376002)(39860400002)(396003)(82310400011)(1800799009)(186009)(451199024)(40470700004)(36840700001)(46966006)(6916009)(86362001)(70586007)(70206006)(316002)(44832011)(82740400003)(2906002)(81166007)(36756003)(41300700001)(36860700001)(5660300002)(478600001)(47076005)(6666004)(7696005)(4326008)(8676002)(8936002)(1076003)(40460700003)(107886003)(83380400001)(26005)(426003)(336012)(2616005)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:33.9598 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd5d93ae-797a-4d23-51bd-08dbb88e129d 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: AM7EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9843 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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" v3: - Fixed formatting. - Fixed period after xfer. --- Document changes introduced by gdb's SME2 support. Reviewed-By: Eli Zaretskii Reviewed-by: Thiago Jung Bauermann --- gdb/NEWS | 3 +++ gdb/doc/gdb.texinfo | 65 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 525ab15e7a6..c83daa82d09 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,9 @@ *** Changes since GDB 13 +* GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which + includes a new 512 bit lookup table register named ZT0. + * 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 diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b5a61aa8973..b5c79ed617a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26361,6 +26361,50 @@ 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 SME2. +@anchor{AArch64 SME2} +@cindex SME2 +@cindex AArch64 SME2 +@cindex Scalable Matrix Extension 2 + +The Scalable Matrix Extension 2 is an AArch64 architecture extension that +further expands the @acronym{SME} extension with the following: + +@itemize + +@item The ability to address the @code{ZA} array through groups of +one-dimensional @code{ZA} array vectors, as opposed to @code{ZA} tiles +with 2 dimensions. + +@item Instructions to operate on groups of @acronym{SVE} @code{Z} registers and +@code{ZA} array vectors. + +@item A new 512 bit @code{ZT0} lookup table register, for data decompression. + +@end itemize + +When @value{GDBN} is debugging the AArch64 architecture, if the Scalable Matrix +Extension 2 (@acronym{SME2}) is present, then @value{GDBN} will make the +@code{ZT0} register available. + +The @code{ZT0} register is only considered active when the @code{ZA} register +state is active, therefore when the @sc{za} bit of the @code{SVCR} is 1. + +When the @sc{za} bit of @code{SVCR} is 0, that means the @code{ZA} register +state is not active, which means the @code{ZT0} register state is also not +active. + +When @code{ZT0} is not active, it is comprised of zeroes, just like @code{ZA}. + +Similarly to the @code{ZA} register, if the @code{ZT0} state is not active and +the user attempts to modify its value such that any of its bytes is non-zero, +then @value{GDBN} will initialize the @code{ZA} register state as well, which +means the @code{SVCR} @sc{za} bit gets set to 1. + +For more information about @acronym{SME2}, please refer to the +official @url{https://developer.arm.com/documentation/ddi0487/latest, +architecture documentation}. + @subsubsection AArch64 Pointer Authentication. @cindex AArch64 Pointer Authentication. @anchor{AArch64 PAC} @@ -48605,6 +48649,27 @@ extensions of the architecture. Extra registers are allowed in this feature, but they will not affect @value{GDBN}. +The @samp{org.gnu.gdb.aarch64.sme} feature is required when the target also +reports support for the @samp{org.gnu.gdb.aarch64.sme2} feature. + +@subsubsection AArch64 SME2 registers feature + +The @samp{org.gnu.gdb.aarch64.sme2} feature is optional. If present, +then the @samp{org.gnu.gdb.aarch64.sme} feature must also be present. The +@samp{org.gnu.gdb.aarch64.sme2} feature should contain the following: +@xref{AArch64 SME2}. + +@itemize @minus + +@item +@code{ZT0} is a register of 512 bits (64 bytes). It is defined as a vector +of bytes. + +@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