From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::62a]) by sourceware.org (Postfix) with ESMTPS id 4DC173858C5E for ; Tue, 14 Mar 2023 14:23:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DC173858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r/8QlW5pmrwAgXZUoBsa4vJhsxIbblel5iHY+xSKJQw=; b=IxQGxLUYZrVXVwMTZGvMhO7Iyy3H6C3JjhoePE2c+KkazPDKrpGzmtuuEtO/CzJInBvlnizzsCRqXrYY2Fah5XfAzG3P07u1mRJlZ/gqQGO2zpEQGJcriAb8ZmoDJvH7mzzAmIAlNtkZs+/qjQwbVr8JJT1Cd1j5/noaAeIHt6I= Received: from FR2P281CA0054.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:93::8) by AS8PR08MB7863.eurprd08.prod.outlook.com (2603:10a6:20b:52b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Tue, 14 Mar 2023 14:23:02 +0000 Received: from VI1EUR03FT065.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:93:cafe::d3) by FR2P281CA0054.outlook.office365.com (2603:10a6:d10:93::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.25 via Frontend Transport; Tue, 14 Mar 2023 14:23:02 +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 VI1EUR03FT065.mail.protection.outlook.com (100.127.144.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6199.11 via Frontend Transport; Tue, 14 Mar 2023 14:23:01 +0000 Received: ("Tessian outbound f2a8d6d66d12:v135"); Tue, 14 Mar 2023 14:23:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f80ea089f80775c5 X-CR-MTA-TID: 64aa7808 Received: from 3a96579fb268.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D951FB11-C522-408B-BE3F-A5743FF8FFA1.1; Tue, 14 Mar 2023 14:22:55 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3a96579fb268.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 14 Mar 2023 14:22:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YaKQuOkap65he1+YugmE6oDgyx84nhUQqEAtUaqaXL/oJPsrdmuym4el7zcfSmijV9+dWg+Aj0PcJZOB2vfpkAn52OQzVmj5DmfnfJCr11hV03ckVpeEaS0rkFYQki+U/lg9xWIbfMTWLvgg4xUx47WliRShdUYj9dGPAKW8LKkTSoSVc6in4wPJqg4LUbU1DlbRVQG7NagfwwOaOWjXCyOvUwoP7cSdAc8aevSETHO8L1L3M+Nvnqlt3AnCF4EB5Zl6jEA5fwWaa8wmP8+aslWUz9Qcv00Z4znDvYs32l4QwWrHTFIkbtebZOt9PN9iGEdLV2Zg2BEsWFzNBMh0Pg== 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=r/8QlW5pmrwAgXZUoBsa4vJhsxIbblel5iHY+xSKJQw=; b=bwu7UanQPu42JnicFtnMcvKifDH/NrO3u3o1I9xqW82MADqor3Y+HcV+csicOxic6TbPvwFXhtYK814jjChynigIbHPAD4V18XdQzbBINoeVwh4LzqqieBDUVr//bGytemo/+KJh/i1ta7ucNzDGTing1DTtwXoF3VW2hNCRKDE82NEgCxpjTjGTuL6I8PGSII/7PLcZmSJhZlTVfG69oV1S9OgRkFyFY2giN6OhfUYsNpoUI3Stzg9+q5UcFtd6a9rYPDTe6laH4OegsqU+ycGG7tnpEBvA/Qrcb7w0wl40DYoAUZ7P2mv5cHkvJfFkp++9wVUjOBYE5pXWRbONGA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r/8QlW5pmrwAgXZUoBsa4vJhsxIbblel5iHY+xSKJQw=; b=IxQGxLUYZrVXVwMTZGvMhO7Iyy3H6C3JjhoePE2c+KkazPDKrpGzmtuuEtO/CzJInBvlnizzsCRqXrYY2Fah5XfAzG3P07u1mRJlZ/gqQGO2zpEQGJcriAb8ZmoDJvH7mzzAmIAlNtkZs+/qjQwbVr8JJT1Cd1j5/noaAeIHt6I= Received: from DB9PR06CA0009.eurprd06.prod.outlook.com (2603:10a6:10:1db::14) by PA4PR08MB7571.eurprd08.prod.outlook.com (2603:10a6:102:270::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Tue, 14 Mar 2023 14:22:48 +0000 Received: from DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1db:cafe::cb) by DB9PR06CA0009.outlook.office365.com (2603:10a6:10:1db::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.27 via Frontend Transport; Tue, 14 Mar 2023 14:22:48 +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 DBAEUR03FT022.mail.protection.outlook.com (100.127.142.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6199.11 via Frontend Transport; Tue, 14 Mar 2023 14:22:48 +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.17; Tue, 14 Mar 2023 14:22:47 +0000 Received: from e129171.arm.com (10.122.37.245) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Tue, 14 Mar 2023 14:22:46 +0000 From: Luis Machado To: Subject: [PATCH] [aarch64] tpidr2: Fix erroneous detection logic for TPIDR2 Date: Tue, 14 Mar 2023 14:22:44 +0000 Message-ID: <20230314142244.210512-1-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT022:EE_|PA4PR08MB7571:EE_|VI1EUR03FT065:EE_|AS8PR08MB7863:EE_ X-MS-Office365-Filtering-Correlation-Id: 36eaa82a-78a0-4a03-eb36-08db24979e7f 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: 7nOpu8ztRvNKc/5h3HIeqQ5SEGOkoesmxCQyD3qXzWUGb+ZLisw0FGLhVUqlW3KO3nISjmg6GskfyauFAXcMjJpdRv55acZtWdnJ9ODSjo6uDaOpdJRF/O8kTjwd3jhyRrXcvA+YWmsE4ZRXsrDZwWqw0n4mo0m1dGd3wRYneANiHPbO5d8jk64/L1Fymn0MHX/7tjYgzEWkpySX1y+J8cHwt53hrCYdWH1eimHM8v/dPh/Xdp0BGIjYc07fQq01X3NQzGLgb+kpGfknkfSFNEuZaq1W/v+mnwSMrCeiuOXtsEJbKYPFj/1m6FMtbDdDNz3gFQNdBZX0RuDBSUzkLtOYxqxo9PVE49MguG+k7oew9cTvyFsQcZEORAcpzvh7Yys0dgie1bqWCWCR6MsHFpm6siq1ub9bU4QevYfyeCs4JFpgiVMjssaYGOsDyrM72TPnWYDp7L8Cpqu6pFA4DMVXQMKcGx4yZCelwI0hoA7lF1WNeDhnQcHbCWWwq5y9hVy4rSvOd+E4eyAlf7sHwwQrUNPRcBEVq7yTnHjgofgr1myAdvW/bhGru7iayuh2t1GEFjwFYaDSHF6njBPQ3ZLCAN6mC/V0gUYqZuh45WY+4dLQrZyus9gmNv+GkRoVJ5kjeRKMjzRu/WqhUhd7GF2Hl5K6aCmJS68sQ9kpML5snLj3rL2oCl+jg5AyfekclIs6qplqqmT6MDq2Lc/SNLh8XNz0deH187I8QyPf1E8= 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:(13230025)(4636009)(376002)(396003)(39860400002)(346002)(136003)(451199018)(40470700004)(46966006)(36840700001)(40460700003)(478600001)(41300700001)(8936002)(8676002)(6916009)(70586007)(70206006)(86362001)(82310400005)(356005)(36756003)(36860700001)(81166007)(40480700001)(82740400003)(7696005)(1076003)(26005)(186003)(5660300002)(336012)(2906002)(316002)(44832011)(83380400001)(2616005)(426003)(47076005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7571 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VI1EUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 865d94d6-1471-4899-1f49-08db2497965e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IroQTjhEa6zeo5Z3+xD/mehTfDoO/mBGrXs1IXVQg+HvoqCmHgInEH8aVUEvse1RiM/VWeARnTN3B1KECxCiSjsjIlDlfcQLW+pLwna7SUKi/HjiGaUNx13pqTeUiHAD+Md+tdcgWeYE5r/wMrDoFztg5sJQTxgnTfIQFN00t4LFG9bnRE2V1Mi68zKG+DXRv0euIOA9rNL2utVPN0IEyEp6+jw3h4Zem+fFvVAIsa1JxPG44/czAcTUMmjkfnO61upg7U/JaWow75R2E9UtWeOi3qfPxjMUzmzMTe8DWFytBYWEyU41FgHisPu7Kqz1vsTtiZBhSUDkyw2agH+QXasUiAh3xvAYg3h7/8f5A4q6RNJ3xBtq2o7A8ImUNnew3lXmhXZ9v83nnqApc2+Z0yVNPIcLZqqv4S+izVZFaAUlbm8uTe2Ex+mvE1BoWcSIbDk+RX+diEpI9CzWW9qAPutiC2agBC/H+TmXnclZgZMSYh6J1b7v2N57bNgbmXfTASkft15llTEQF098cU9GEtRa1KFFqfxtl/DX+8mpmQmrR45l44FO+9ilt6Kma6xZBzbnT+JzCpEYNpfvu/cN4nh3xOQvSh9DfkJSnnaxRtFHarSFHupesm3vbqkUaSJt/VqRuXGpWshsNC5ikJkmahjXRmN1trB1fkE7lS4Yb0bgI2YsVJtV1cZgNc4pyC0lArmosqZM/+G2Jm8GyZwpWQ== 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:(13230025)(4636009)(396003)(39860400002)(136003)(346002)(376002)(451199018)(40470700004)(36840700001)(46966006)(86362001)(81166007)(82310400005)(478600001)(36756003)(8676002)(36860700001)(82740400003)(40480700001)(40460700003)(70206006)(6916009)(8936002)(41300700001)(316002)(1076003)(44832011)(2906002)(70586007)(5660300002)(336012)(47076005)(426003)(83380400001)(2616005)(186003)(7696005)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2023 14:23:01.9808 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36eaa82a-78a0-4a03-eb36-08db24979e7f 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: VI1EUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7863 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_NUMSUBJECT,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 List-Id: The detection logic for TPIDR2 was implemented incorrectly. Originally the detection was supposed to be through a ptrace error code, but in reality, for backwards compatibility, the detection should be based on the size of the returned iovec. For instance, if a target supports both TPIDR and TPIDR2, ptrace will return a iovec size of 16. If a target only supports TPIDR and not TPIDR2, it will return a iovec size of 8, even if we asked for 16 bytes. This patch fixes this issue in code that is shared between gdb and gdbserver, therefore both gdb and gdbserver are fixed. Tested on AArch64/Linux Ubuntu 20.04. --- gdb/nat/aarch64-linux.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gdb/nat/aarch64-linux.c b/gdb/nat/aarch64-linux.c index 6c8a78f1729..a84faf1cfbf 100644 --- a/gdb/nat/aarch64-linux.c +++ b/gdb/nat/aarch64-linux.c @@ -261,13 +261,13 @@ aarch64_tls_register_count (int tid) iovec.iov_base = tls_regs; iovec.iov_len = sizeof (tls_regs); - /* Attempt to read both TPIDR and TPIDR2. If the request fails, it means - the Linux Kernel does not support TPIDR2. - - Otherwise the Linux Kernel supports both TPIDR and TPIDR2. */ + /* Attempt to read both TPIDR and TPIDR2. If ptrace returns less data than + we are expecting, that means it doesn't support all the registers. From + the iovec length, figure out how many TPIDR registers the target actually + supports. */ if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_TLS, &iovec) != 0) - return 1; + return 0; - /* TPIDR2 is available as well. */ - return 2; + /* Calculate how many TPIDR registers we have. */ + return iovec.iov_len / sizeof (uint64_t); } -- 2.25.1