From patchwork Fri May 19 10:25:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 69662 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 895F53857C44 for ; Fri, 19 May 2023 10:25:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 895F53857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684491952; bh=v43jB2add7WeYplfqNf1QXEaJ74PsJQfT2dbBozR5MA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GYE/5qiTMdkcUhmLefGN8Q3WOt9c6kf1j2eLJRkeIEbqXRTmlQdUt9EVwVbOZ0wmY VMBelRkhO7CJKjlwjpXAz7R69oBGoS3ZEHERrOk7fyqgumVO7mvQ3gVOcAux8keqlY YNvOxGazW7wnkXryEF9M0iyMDJeD1yrlvBjD3Nbg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2087.outbound.protection.outlook.com [40.107.247.87]) by sourceware.org (Postfix) with ESMTPS id 675463858D38 for ; Fri, 19 May 2023 10:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 675463858D38 Received: from DB6P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::11) by DB4PR08MB8008.eurprd08.prod.outlook.com (2603:10a6:10:38c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:24 +0000 Received: from DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b8:cafe::e0) by DB6P192CA0001.outlook.office365.com (2603:10a6:4:b8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Fri, 19 May 2023 10:25:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT065.mail.protection.outlook.com (100.127.142.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 10:25:24 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Fri, 19 May 2023 10:25:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d025e7f5cbcc7842 X-CR-MTA-TID: 64aa7808 Received: from 3a87434452ad.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 15178B69-F80C-4052-AF7F-44191F0F87F4.1; Fri, 19 May 2023 10:25:17 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3a87434452ad.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TgF4ynhVIX5m/D26t9SnjAtHbO+Pd2T++5E+3xBMqoQngQtCXK7Mgd/JNRssh05fLdzLgx20psf+86kBjhaCxCFdpx9Fu4CpjETUhsbSydTESVZLAjBjQGToQVTr2CYSde2OOZOQLS9zZVbChHqi2j03H+0mFDPU1cKMYNc9cGKAmOKot5ZMMGdm+VGm2QD0yXojixXD+pxbzYDodBDp9X6iVoeh5SIGNawAI2ECV+MVBBraaIh+9+5kCDdhrzmNyql67CK7ItxsKtmGqLyChFZbtfBElzTlEFJPoSD+t5BKESColXzpMaK1gtJbnuIB40NnUYHK8EBj6/j/jXRcgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v43jB2add7WeYplfqNf1QXEaJ74PsJQfT2dbBozR5MA=; b=HaZwM0GmYT+/9WQZjwXIAxBOg6lRsZPVLi2FGvmxwhipOjxlsSFmF3bHnnXzccUwuddWXyLG/L4IsBTpdmYSIlclRGZTJ6/JrReRuOH3jW3BAeCGaOcYtdvlwowtp6yh0la2qiY9rzyyJrWZ9wS9B1PHYAfLuNhy4479EkXiKk26actRLR06b0J4Bq/U6hLz/KgMwVyZIYQG7RrbiKeND8eETsLMZX6ulUeUtUS96jytSuVfv1uMPyBrYxTaRWQ6uk+nwUFjhT8KdCQYwljGUCLlZvYdJ+cfyOVUP0T2L9Hg28zDgyK1mlVI7uco9Cx4YtII+YuYeZcpXcdX7dlzCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from AS9PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:20b:495::18) by DU2PR08MB7358.eurprd08.prod.outlook.com (2603:10a6:10:2f1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:13 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:495:cafe::a4) by AS9PR05CA0209.outlook.office365.com (2603:10a6:20b:495::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT009.mail.protection.outlook.com (100.127.140.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 10:25:13 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 19 May 2023 10:25:12 +0000 Received: from e129171.cambridge.arm.com (10.1.37.65) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Fri, 19 May 2023 10:25:12 +0000 To: Subject: [PATCH v2 11/17] [gdb/aarch64] sme: Support TPIDR2 signal frame context Date: Fri, 19 May 2023 11:25:02 +0100 Message-ID: <20230519102508.14020-12-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519102508.14020-1-luis.machado@arm.com> References: <20230519102508.14020-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT009:EE_|DU2PR08MB7358:EE_|DBAEUR03FT065:EE_|DB4PR08MB8008:EE_ X-MS-Office365-Filtering-Correlation-Id: 7956562a-6de0-43b8-fec0-08db58535b4e x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: jVqu+a61S8DZObJqvAKgmL4QxIwQY62a9K7nvidm/lhe3JIfm2rrIgelcT+RYq7v8a9vPPg7wT6QWtnWWZz93PKsWEMnUoUghPBde8/HvbjsXVu/dLk2uhXx0+4aAZ0mtJzKjCycrqSPO3t/bHSvtdVlmd6g8SnrJVvHYmMklatGJ7PST4JnqeBIembeAyqwJY3icDezUrEw3X8a56Wc5LE1Rl+h6yau229HMzbRB2lmEx+0InKGhY61F+3kjTNaqfPwCBp4+16IPB6xlrZ4S5Iodi8QjbiadQKxPwnP3Y50sN6ZIm26YqeZhShWbEFHffF50loWZ7vKDymOY9j9YPBdutzO40cowRHguEuZNa9tEtsK0ZrrpOlWcyrtFuTGMbliNi3OXLiMk188zAbc4C35x9dfQ7sJnen9rvEfHip1i12jCdH9WX8aBSM+ZO5KjUZ1/yDnlMV8qLYBE7sGjAYgfkGH7977lWkMRf77nBA6GpdqLWTLEYarOt7ahZ1+RuYwR7fM9fQ8TLRpImiYHyLCzzMIXyyjzqUPs5az0zTH/Ky6fjNbdr+9f7KVqgoL8DgU0Vu6nXyQtbWyb6tNz7JmN4SjaSSLKh59PfpytP4ssMw5RQE4gGfFtjRPFr9CeYQUfruP990uVfEQ8Cmz7PGzKh0rDQN+TSkcTyitiRmHYrpcjCTQOzy8/+8RznT3Wp9bSs/pj/M6f8Kj8rZ8xWt6PyL6z6XJ+Ax2T32eg/VziHPApxGRu3M7hPAk29oU X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(346002)(376002)(39850400004)(396003)(136003)(451199021)(46966006)(36840700001)(40480700001)(44832011)(426003)(2616005)(5660300002)(8676002)(8936002)(26005)(1076003)(336012)(36756003)(86362001)(2906002)(47076005)(83380400001)(36860700001)(82310400005)(6916009)(478600001)(41300700001)(186003)(7696005)(70586007)(316002)(70206006)(81166007)(356005)(6666004)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB7358 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 941ebde7-db16-4d24-9369-08db5853553e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7+GpVYqjn9qM71wtyT0NTyNXbVquIMMdE3toEbWpmKD4jXjP3hGBcObqY/zBZ8zkJ9Xc7oSK/7fyKLD7BPwUW6hOo3jbn0iU1l2S2hFLaTGTHwgtsSGfLTVltK9p3ehMnrLNirawYT5NqkSIM8RJ9XkOZysPOyRKDtEOtRllnDw8Q7y95EVvqOWQ4IaGP927t3KRTmlZeN69mgX3tPGCptEwpvG1RVcoKTP6Y/bLegSf0DOl+dL7oCOFEa1vJxaFF97jmoc9U4maNv2K70mCV9N85bTJa6HbR8evQuLIpyg6s+u9UKInPnMTSwPInlWUm+P+J4pHeSvKchkNYYPCg+azno5CaR9MLs3Uftm2C8wdUx96CIc9B92YfzC0FQ21C6mowNFvgbiytcwiTb4wILAxSNAjp4FiXuG7NeRQPdCLGrv61KVGysZ0tkAwsb0iSgh0bPxf6qtbmatK2qfQ7ENpRaoxX+iwZwacj5fp/5N5kFa57mTEWbHL0ccbvuMUj2PhOyCuA6RmCSyglXGTQ0fOh6/hz7rsSaHodxb2+HoivKNzR9v+GEvKhtqjannMYyNZb2a3oIPFgQo5RWHJwE34xLnJ0YJQ1P5uJAXAJcPYYOmNm/6OR6ZPiGK6OoCjbjB4uaHY7odpi3vk6ThJpWuIM90+cIL0dZa8wViAstt5xgeQkwmp0McL5Y9IJwgRPbMUE6Xn31dVCKPKDVSzTWxC6WQV4rkFInKxujVqMtSlzfmHqIXnhTzT2ltXq6so X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230028)(4636009)(39850400004)(396003)(376002)(346002)(136003)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(70586007)(70206006)(478600001)(6916009)(316002)(36756003)(86362001)(83380400001)(47076005)(26005)(2616005)(186003)(336012)(426003)(36860700001)(1076003)(5660300002)(41300700001)(8936002)(8676002)(44832011)(2906002)(7696005)(40480700001)(6666004)(82310400005)(81166007)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:24.0334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7956562a-6de0-43b8-fec0-08db58535b4e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB8008 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The Linux Kernel defines a separate context for the TPIDR2 register in a signal frame. Handle this additional context in gdb so this register gets restored properly when unwinding through signal frames. The TPIDR2 register is closely related to SME, and is available when SME support is reported. This is tested by testcases that are available in a later patch in the series. Regressions-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-tdep.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index c973a790f62..7ce34ee6846 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -154,6 +154,7 @@ #define AARCH64_FPSIMD_MAGIC 0x46508001 #define AARCH64_SVE_MAGIC 0x53564501 #define AARCH64_ZA_MAGIC 0x54366345 +#define AARCH64_TPIDR2_MAGIC 0x54504902 /* Defines for the extra_context that follows an AARCH64_EXTRA_MAGIC. */ #define AARCH64_EXTRA_DATAP_OFFSET 8 @@ -184,6 +185,9 @@ #define AARCH64_SME_CONTEXT_SIZE(svq) \ (AARCH64_SME_CONTEXT_REGS_OFFSET + AARCH64_SME_CONTEXT_ZA_SIZE (svq)) +/* TPIDR2 register value offset in the TPIDR2 signal frame context. */ +#define AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET 8 + /* Holds information about the signal frame. */ struct aarch64_linux_sigframe { @@ -204,6 +208,8 @@ struct aarch64_linux_sigframe CORE_ADDR sve_section = 0; /* Starting address of the section containing the ZA register. */ CORE_ADDR za_section = 0; + /* Starting address of the section containing the TPIDR2 register. */ + CORE_ADDR tpidr2_section = 0; /* Starting address of the section containing extra information. */ CORE_ADDR extra_section = 0; @@ -465,6 +471,13 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame, break; } + case AARCH64_TPIDR2_MAGIC: + { + /* This is context containing the tpidr2 register. */ + signal_frame.tpidr2_section = section; + section += size; + break; + } case AARCH64_EXTRA_MAGIC: { /* Extra is always the last valid section in reserved and points to @@ -607,6 +620,17 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, sve_vg_from_vl (signal_frame.svl)); } + /* Restore the tpidr2 register, if the target supports it and if there is + an entry for it. */ + if (signal_frame.tpidr2_section != 0 && tdep->has_tls () + && tdep->tls_register_count >= 2) + { + /* Restore tpidr2. */ + trad_frame_set_reg_addr (this_cache, tdep->tls_regnum_base + 1, + signal_frame.tpidr2_section + + AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET); + } + trad_frame_set_id (this_cache, frame_id_build (signal_frame.sp, func)); }