From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2076.outbound.protection.outlook.com [40.107.6.76]) by sourceware.org (Postfix) with ESMTPS id 664BD3858D20 for ; Thu, 7 Sep 2023 15:20:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 664BD3858D20 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=BczB8afK+RjgGTMO4w42hjr23P4EF7xpsp+nJJv6QjU=; b=suZ59KcGjTiK2Hdo8c5xwU2COT3q+X3AjbcomMOl7/W5NhWkE67JhemvNERm0eslMlp3dcELmwlC4nPAPdIEq7fLLsNp1or+vIhsYyLBIwFX0SRAiEu+okyhHEBleaHfQyjkoZipgR+AzjOhEIbAXI54L+OHcLdLbAVE2lclqNA= Received: from AM6PR10CA0005.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:89::18) by AS8PR08MB8037.eurprd08.prod.outlook.com (2603:10a6:20b:573::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Thu, 7 Sep 2023 15:20:31 +0000 Received: from AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:89:cafe::2e) by AM6PR10CA0005.outlook.office365.com (2603:10a6:209:89::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30 via Frontend Transport; Thu, 7 Sep 2023 15:20:31 +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 AM7EUR03FT036.mail.protection.outlook.com (100.127.140.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.28 via Frontend Transport; Thu, 7 Sep 2023 15:20:31 +0000 Received: ("Tessian outbound 5c548696a0e7:v175"); Thu, 07 Sep 2023 15:20:31 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2fae75d60629195b X-CR-MTA-TID: 64aa7808 Received: from 9a2f3287c798.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ED9E0A14-E692-4894-93A2-E9D492D1410A.1; Thu, 07 Sep 2023 15:20:23 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9a2f3287c798.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 07 Sep 2023 15:20:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=My+so05+JKb/MFXhpE4nZiRLyh1xcu+f5xVdq8/iD12ydcSa8Qb1IFKzjLiIR6BfSjYP8Qoj8nCEUnWcQWCv47Cw0h/o24saf/bw6E5yv3IZtAybe/qwZarYWHPKlEYTC/zSb3G3AH8Nx2JJ7HeR+jWQZZ7acdoRxcUwGAVs4HAUr/gPq384U38Zl0rhNV4qfEcnapr1h9jJqx5QIWJnvPErTYrJ749A8MoDsnRj9nZEGkZvG5ayRU/PcND7QgZkm7IZ5pCZ4mCTuCpsQ0eBU9QM9ZBGFw5KnQwyYqR8IVW/PkKWjGAjXkBhRb46zm8typ+jJ77Zl3nsCozYU7HErQ== 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=BczB8afK+RjgGTMO4w42hjr23P4EF7xpsp+nJJv6QjU=; b=KRV5DFEscbAe7d0nqKy1D4HObJI7mKW7Vx4kJcypd7zrZ2kBnVRsNHXx7L0cQLe5tcY5Sj2ms4t+A5JDDF+7ALFWya+eCHaLdrs+O99ffIfmRP8nZjQuSEe1uBVXRdyNyod1TjTWP6atMYFvNEweWL6xwtW3STs5bci6UqX602gQ2Hv55lJm0XWln09JDl+3heUEkqwWZmj/80wwLdJ1zbZYMeZZ6BRXtWJ18k6xNxZTvhra7H+4CuqvhoK7wrxN7WmFoQz8x5hV/byNqS4Gl0FTRDchiehjFY27nIc9Ldh4GLyPoWo99J6b+A5FKINQey8bLlV3mmH3DyoboZVEzw== 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=BczB8afK+RjgGTMO4w42hjr23P4EF7xpsp+nJJv6QjU=; b=suZ59KcGjTiK2Hdo8c5xwU2COT3q+X3AjbcomMOl7/W5NhWkE67JhemvNERm0eslMlp3dcELmwlC4nPAPdIEq7fLLsNp1or+vIhsYyLBIwFX0SRAiEu+okyhHEBleaHfQyjkoZipgR+AzjOhEIbAXI54L+OHcLdLbAVE2lclqNA= Received: from AS4P195CA0047.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::24) by AS8PR08MB10271.eurprd08.prod.outlook.com (2603:10a6:20b:629::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Thu, 7 Sep 2023 15:20:21 +0000 Received: from AM7EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:65a:cafe::ca) by AS4P195CA0047.outlook.office365.com (2603:10a6:20b:65a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30 via Frontend Transport; Thu, 7 Sep 2023 15:20:21 +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 AM7EUR03FT020.mail.protection.outlook.com (100.127.140.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.28 via Frontend Transport; Thu, 7 Sep 2023 15:20:21 +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; Thu, 7 Sep 2023 15:20:21 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 7 Sep 2023 15:20:21 +0000 Received: from e129171.cambridge.arm.com (10.1.32.59) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 7 Sep 2023 15:20:20 +0000 From: Luis Machado To: CC: Subject: [PATCH v5 01/16] [gdb/aarch64] Fix register fetch/store order for native AArch64 Linux Date: Thu, 7 Sep 2023 16:20:03 +0100 Message-ID: <20230907152018.1031257-2-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230907152018.1031257-1-luis.machado@arm.com> References: <20230907152018.1031257-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT020:EE_|AS8PR08MB10271:EE_|AM7EUR03FT036:EE_|AS8PR08MB8037:EE_ X-MS-Office365-Filtering-Correlation-Id: 59adf718-29a9-4df1-7a3b-08dbafb5f9bb 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: yVRkoWHw3RgCqJa5wvob3IBKg/mqkOvt1e7vf/4PAmiHnJDBEvfyn/bUiXA5HLSvFa8Lu2wZZVJfdKrWsDfBWTIA/hQ7HUcAjl32Ps7qEXFbNt3YNMMvzxHtipqc9w9ZUI41nuyYMI245Y6+tIP+Pqe+7+2pPdVCLdrYCrEKbEWqFhISPAerDoskWLy1TvGIhM+nrS9N7zFaS7kjVn6eCAW+kJNogVAQ1gn1qLjxAlllga0OIFWbaQjz3liEPW56pBPTuuvw5AxPQFxP7DXop44DPJwwg+pwKe/lKA64DX5J6SFJvINA1c+yBQqgO93Q3/zCxoNFeD6Q2hOQ9O/jmfiTHuSoMlPm90ZezhEN5lp3nR14NUMWTJSPtwTXkoKm9i1aBjeD0PrvYqYOVkymjCP0lapQcYfMSM82VfxqM9J3i5BTKJtdqS64GwnbUeMQn/I/BCrbTbgac7nZA1oLuBYG1eQbxj4PfOck/LOiDWQfBm/02KFPPb94/VkYOaUCrWMKTx5Q7B+BJOFi24PJjXOO+Qy9aPt3lvbwi7FAdHNKACDziwh7/gvevYI4mwKYHwi0AK2KJXTQDUilxDPhU2mWP/tAGXUp+b3jLbKjL5I+2HuIp7d6t0CP6j99TXv5MTPD6FzCgI1eNUmPjIq3Bpefnf1Jach2IQp/gyl7IefPPJg/vlwnbea5OhyXgZkMJHoGvIzc7hUEE6L+6QET4DH7tr7PLm7LGsbUWqMeo3gTHzCSPsWdgJ66PD6HJMqwZwI7YoXOOI+ntfkOid2bIQ== 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)(136003)(39860400002)(396003)(376002)(82310400011)(186009)(451199024)(1800799009)(40470700004)(36840700001)(46966006)(1076003)(83380400001)(40460700003)(44832011)(8936002)(4326008)(5660300002)(36756003)(8676002)(2906002)(6916009)(41300700001)(316002)(70586007)(70206006)(7696005)(478600001)(6666004)(47076005)(36860700001)(2616005)(356005)(81166007)(82740400003)(86362001)(40480700001)(26005)(336012)(426003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10271 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ddfa6859-38d4-4916-d419-08dbafb5f3dc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wg2Tecw3Z9ONnE5HktAkgBnKuB1RI69/uhmTSa+MEjqFIpCtkn947CKLXIxcJtfxbcCiqsfIWNT0csI40X8EpfpjzbumS+o0hWw1l4paq9IGpyUxYx5vUrG1p8tuIg4vpjh+MYgVRgWntU8BSkL9MX1JyJlK5wswM95SrAVW29w992qQeTp9dCHaaOapZFputxa/N2Udci63wHKvwY2uq7iUuDiyjBEGLxhZ5teYfw5HTg+MSHm191ZxgBE3gciL0acRiZnYTSCGi44j98nLRqSHMkUZgHCnClVLZKaJvw0M+9lgfzmlzUHJ2pANZmWfjM7cS5/FnKpj3yncn/oGp/8hLpBF8YyX8LdWM4eVEhWVk73SI8M+mZ/kP7Y3mdENqg5q/INI5JEa+0NLzlydDg4tWUkT+lHT2Ksq1nJKfVnJYv9g/Vgl+Z7JpSF5xPyJ4H3PXB1Ao3384k2FcjNOcyzKW1EOUAhs1DATJ3YIQUtSf6Fx5eN/NMfWuMeUI13bKJYruxuloYtGYkHNX5ok6iIYQP9t2LSOCDThzwV8f+LNC3NzrthMgLsWl1i9d6gjpx38T142JAoD71S4cM7/V0aiBQWGiailnoivohrPII+mMgI74JrUMS8cY1RiK+rcQodPIPKUKzBI4o30viRB3CVhug8WJQhm67Fctj/+g1iQD5oDijrFd4IlOaaImnzspi6esWmOZVZvF5pk6GlWpWRbLa3cMK2lnMVYIRb7hK53NKHwIBD8p6ZNoVq76lUh 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)(39860400002)(376002)(346002)(136003)(396003)(451199024)(186009)(1800799009)(82310400011)(40470700004)(46966006)(36840700001)(86362001)(82740400003)(81166007)(36756003)(40480700001)(40460700003)(426003)(6666004)(7696005)(5660300002)(44832011)(316002)(2906002)(6916009)(4326008)(8936002)(8676002)(41300700001)(478600001)(336012)(83380400001)(47076005)(36860700001)(70206006)(70586007)(2616005)(107886003)(1076003)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2023 15:20:31.6186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59adf718-29a9-4df1-7a3b-08dbafb5f9bb 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: AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8037 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 List-Id: Updates on v4: - Fix FPCR comparison and other review comments. --- I noticed we don't handle register reads/writes in the best way for native AArch64 Linux. Some registers are fetched/stored even if upper level code told us to fetch a particular register number. Fix this by being more strict about which registers we touch when reading/writing them in the native AArch64 Linux layer. There should be no user-visible changes due to this patch. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-linux-nat.c | 60 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index eeb9761bfe5..8844fc722cf 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -504,6 +504,7 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) aarch64_gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + /* Do we need to fetch all registers? */ if (regno == -1) { fetch_gregs_from_thread (regcache); @@ -521,28 +522,28 @@ aarch64_fetch_registers (struct regcache *regcache, int regno) if (tdep->has_tls ()) fetch_tlsregs_from_thread (regcache); } + /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) fetch_gregs_from_thread (regcache); - else if (tdep->has_sve ()) + /* SVE register? */ + else if (tdep->has_sve () && regno <= AARCH64_SVE_VG_REGNUM) fetch_sveregs_from_thread (regcache); - else + /* FPSIMD register? */ + else if (regno <= AARCH64_FPCR_REGNUM) fetch_fpregs_from_thread (regcache); - - if (tdep->has_pauth ()) - { - if (regno == AARCH64_PAUTH_DMASK_REGNUM (tdep->pauth_reg_base) - || regno == AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base)) - fetch_pauth_masks_from_thread (regcache); - } - - /* Fetch individual MTE registers. */ - if (tdep->has_mte () - && (regno == tdep->mte_reg_base)) + /* PAuth register? */ + else if (tdep->has_pauth () + && (regno == AARCH64_PAUTH_DMASK_REGNUM (tdep->pauth_reg_base) + || regno == AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base))) + fetch_pauth_masks_from_thread (regcache); + /* MTE register? */ + else if (tdep->has_mte () + && (regno == tdep->mte_reg_base)) fetch_mteregs_from_thread (regcache); - - if (tdep->has_tls () - && regno >= tdep->tls_regnum_base - && regno < tdep->tls_regnum_base + tdep->tls_register_count) + /* TLS register? */ + else if (tdep->has_tls () + && regno >= tdep->tls_regnum_base + && regno < tdep->tls_regnum_base + tdep->tls_register_count) fetch_tlsregs_from_thread (regcache); } @@ -592,6 +593,7 @@ aarch64_store_registers (struct regcache *regcache, int regno) aarch64_gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + /* Do we need to store all registers? */ if (regno == -1) { store_gregs_to_thread (regcache); @@ -606,22 +608,26 @@ aarch64_store_registers (struct regcache *regcache, int regno) if (tdep->has_tls ()) store_tlsregs_to_thread (regcache); } + /* General purpose register? */ else if (regno < AARCH64_V0_REGNUM) store_gregs_to_thread (regcache); - else if (tdep->has_sve ()) + /* SVE register? */ + else if (tdep->has_sve () && regno <= AARCH64_SVE_VG_REGNUM) store_sveregs_to_thread (regcache); - else + /* FPSIMD register? */ + else if (regno <= AARCH64_FPCR_REGNUM) store_fpregs_to_thread (regcache); - - /* Store MTE registers. */ - if (tdep->has_mte () - && (regno == tdep->mte_reg_base)) + /* MTE register? */ + else if (tdep->has_mte () + && (regno == tdep->mte_reg_base)) store_mteregs_to_thread (regcache); - - if (tdep->has_tls () - && regno >= tdep->tls_regnum_base - && regno < tdep->tls_regnum_base + tdep->tls_register_count) + /* TLS register? */ + else if (tdep->has_tls () + && regno >= tdep->tls_regnum_base + && regno < tdep->tls_regnum_base + tdep->tls_register_count) store_tlsregs_to_thread (regcache); + + /* PAuth registers are read-only. */ } /* A version of the "store_registers" target_ops method used when running -- 2.25.1