From patchwork Mon Sep 18 21:26:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 76325 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 D8A053872C17 for ; Mon, 18 Sep 2023 21:30:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8A053872C17 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695072611; bh=0lvMPLWmM2b1RL2bR4i0X6K+4NBJJD30jsq6B25iMVk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jJN79yD3jily2iBxlfJtC8ZFUTaOUBp5GAOMkZfLX2yxq5bkiQWbw5SZ7oS6REGdE b4oTyjlsRC7ngXngLR4K1m1Rlm4Py9GseDcxZ2kRCnIKt3tAT3azpjv+mQQBzJYBQj IoHZBFTXnPEz4wlqwMZsvcd2fggYdrT62AYt6x2M= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2058.outbound.protection.outlook.com [40.107.20.58]) by sourceware.org (Postfix) with ESMTPS id 40601385840D for ; Mon, 18 Sep 2023 21:27:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40601385840D Received: from AM6PR10CA0032.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:89::45) by DU2PR08MB7374.eurprd08.prod.outlook.com (2603:10a6:10:2f2::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:19 +0000 Received: from AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:89:cafe::9c) by AM6PR10CA0032.outlook.office365.com (2603:10a6:209:89::45) 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 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 AM7EUR03FT047.mail.protection.outlook.com (100.127.140.69) 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:18 +0000 Received: ("Tessian outbound 1eb4e931b055:v175"); Mon, 18 Sep 2023 21:27:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e6855c966f11ea32 X-CR-MTA-TID: 64aa7808 Received: from e09ae13c50ea.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C383B6E6-D98E-4AE6-B8E2-568B1323892A.1; Mon, 18 Sep 2023 21:27:12 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e09ae13c50ea.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b/a7mMe3rss/6/UaaeXUgsxTfeXY6jxKed5QkwDrZ+8qjKH9OmMnG+2OqBsZnpkDPqDyiQ2c+JFIlz54/eppf1oPgonFxyPzCWs/OBujEVCsGdCB88yIbv1/Z9Arb/JfeyMkC/L2qRrbvh7M5+JHxiJU5lY1KnugsaMiiYU+zmYscE+/1QybiISgz40aBh9REUS6Kl6AYmWBV7GqN83z+YxyAhZog/C7EYsGj8Scax3YMA9+pn2Iuw5V2C7/R8oC17ZLXjtGvBkAcRGpZ+GOdUtYOQIachYdwTZI9qJsfbNXioqlPpvt4SuFydYA6LPI4kwHyVt8mLlj5ojTTVb9VA== 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=0lvMPLWmM2b1RL2bR4i0X6K+4NBJJD30jsq6B25iMVk=; b=cXsLqPHRQZG2WBd3A6D0rYdu/CxNZw5lNfn8dHwOL9rWV/9LyWZzL9vasJ2W+DwOfYeXyxvb3em+DY1Qvw+gcGcApQjzLw0F56CREfvE+2YMAj1PvSWQbiYxGMRxWtRO3cPujdSvdj8pDWNBK8MIJ0OhdJZalHKTcwryPCT7Svhf6/jKGMUngZ68Lgy5O1fdfaLjdcBne66KUD2h0WdBs1iMuxSHEZOkCxCr0YiX5dOMgJJi1BBqRQtxugkwc0ZwpinzJJ6Og8uzlPcAUx4wdMwFELU1ScQldddlkQ3tRsfnbbJoOlN4W1ysuWb0fAQJYMUZz06ENj50ntA7lyxi8Q== 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 AS8PR05CA0024.eurprd05.prod.outlook.com (2603:10a6:20b:311::29) by GV2PR08MB8097.eurprd08.prod.outlook.com (2603:10a6:150:75::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.24; Mon, 18 Sep 2023 21:27:08 +0000 Received: from AM7EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:311:cafe::50) by AS8PR05CA0024.outlook.office365.com (2603:10a6:20b:311::29) 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:07 +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 AM7EUR03FT064.mail.protection.outlook.com (100.127.140.127) 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:07 +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:06 +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:06 +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:05 +0000 To: Subject: [PATCH v7 12/18] [gdb/aarch64] sme: Support TPIDR2 signal frame context Date: Mon, 18 Sep 2023 22:26:45 +0100 Message-ID: <20230918212651.660141-13-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212651.660141-1-luis.machado@arm.com> References: <20230918212651.660141-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT064:EE_|GV2PR08MB8097:EE_|AM7EUR03FT047:EE_|DU2PR08MB7374:EE_ X-MS-Office365-Filtering-Correlation-Id: f967298d-bebb-42ff-00df-08dbb88e0993 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: Und+BbOOh4+P9to/5BOOxnWDaIg+P2q8SQ38J5488NlJ5S9s2N0Zz6hD+8Zj1esdwNhgqpf0P648NRYwYK37JOJAJ+aQO7LlKAD7dQVxVPEuWsDv/1sPNfOPaDtvj8uBYGmAOEvEyXmLTuk8KbdMWjRh0tZqtnPIn5BPUlY/IYVW8opwNd4SeQ4Bh3vPDjMBYCJPw0umBRjSM9BjnuNsI/PUQqz2NFap64wa5lTqc98D/kymnyujM9dPo/qLvPf7qsfKfsXSuXFI3uBM5Efuns2kA0S0zNmzBElDRsnxDmvXFq+3bYO1G3qeI83XRtcQr3HZ1fvICAtekOujtpNmbAlfphKARXNaCfxODg83tScC5sQ6LfxcldbU7HaoDOhFMCkboId3o6SyHJS+LkX3iRrpBM9GTtx5d/7qmn2oci9sTM519RecfseC+e9pyuVy8d6danzcLDgI8Rl6Ag1l4l3tcSCEvbNggUHba1gESNygVB4WF2pVoCbZlzS/CFePNnc8gk0xFKMwHxWfkddQG9cLYOTm/tUX4IbqzbmL8qWpgyl3PNPvpz9k0CKEXWWEitiTeMSvKMmuadrkv5vChwFMJ5HnMlhbrICRbWTCzbcXcd2uRU46IgSLvfbJYgAIAdX0CGsrIHiX6sAtLbu14wYoH5qXDV/NVH2zK18qw9zIlwvxUdD+eTupCNO3oZX4Wz5i2Z/blPcV162KtTPsOhxgJqOQ5k27w1Pg7GTS7TKwdwDQqlYVYUWPoH/Z6spTfmYPzb8ZgLncBxZ2U/DPkQ== 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)(376002)(396003)(136003)(346002)(451199024)(1800799009)(186009)(82310400011)(36840700001)(46966006)(40470700004)(6666004)(7696005)(83380400001)(82740400003)(36756003)(40460700003)(86362001)(81166007)(40480700001)(356005)(36860700001)(1076003)(26005)(2616005)(47076005)(2906002)(426003)(336012)(478600001)(44832011)(8936002)(8676002)(6916009)(4326008)(5660300002)(41300700001)(316002)(70586007)(70206006)(54906003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8097 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6b9f7148-5924-4315-4bee-08dbb88e02ef X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Px6hga1ihyLqonRaG6uaQQXe61S4tXKt7SeOUB1sPBXHuvasaW7dcobKVUIV2wgVgYc+w4geqYMwmLN4sLwJXPTEbq/7hee/OP9gd2S3B40qbjxqDe/CQ3xwvxlvxzmFxOkSwn9OhYqagX3nss/j4GIZhnWCld4Mtb/TlV7SqtuA1oPbN+CrMxqsIJ8/GoHBN5LgDcwXkBGN4z1bx4PDyu5sNcWjyb3NM6CKSF6PfvGxN7/FVzYLA1fixA1xSjY2/hMB8bnzbTKoEIYLxt/lg+MvbSqOtqMAc83s5OEgfWDDIS7wrl+hbBfg5Qvs7bwKdkujdtl72QU1QktF0QTGYnt0SZYdlEB+Dry9+U6+l3befJMbf4ekRPh90oPM6/scFv+GJyPPCmSfreZfjG8Th7qbx0Rf0DghStKoJmXRQRrPROrY3YfglP8YeDgEJIjpXd9fhTQ3a89UMF3iN4G7S2hHWjRUMleHiiBx+3rRHeaiP2IEoWsvIPK2mV+DSE/OqOo1f1UhFdmeXcY7W4B10ez3VCV1tpuCYPIxHgtECrXMDD7+okyf0ap55L4HbThWT0qMEeqRbHtfIFpokLSb0hGchFKCasb3B1wRviSQsFv7wCYbozjHYBuNZfwK3sd4hNz3LW3EySpqK7et7dgHuUD5g5EycvkGQWGJyS+BwQ726pr6HYUmSYc3NTnHMPmybRxC/YW8dISkYCSdmZTkgyhfp6da+bAdHRbpOQZ5vJIcrHopk9ozNZKhFRzoDvVq 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)(39850400004)(396003)(376002)(346002)(136003)(1800799009)(186009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(107886003)(47076005)(1076003)(2616005)(336012)(426003)(44832011)(5660300002)(4326008)(8936002)(8676002)(7696005)(82740400003)(36860700001)(83380400001)(26005)(478600001)(6666004)(81166007)(40480700001)(316002)(70586007)(70206006)(41300700001)(54906003)(6916009)(86362001)(36756003)(2906002)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:18.7927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f967298d-bebb-42ff-00df-08dbb88e0993 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: AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB7374 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 Cc: thiago.bauermann@linaro.org 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. Reviewed-by: Thiago Jung Bauermann --- 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 39855844ad0..47e5e1db641 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; @@ -464,6 +470,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 @@ -605,6 +618,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)); }