From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2079.outbound.protection.outlook.com [40.107.104.79]) by sourceware.org (Postfix) with ESMTPS id D55EE3858D38 for ; Tue, 11 Apr 2023 04:27:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D55EE3858D38 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=FeZxV0cQ0XyAJIP7tX+mk6XHEx+elHRod9JtzFwcMp8=; b=OIqZZq/9pNbcszcDrROBd+mYn70kXSAtRVODWtAMK8aiKwRsY3Ewl077Q2koUlm8o016BS87NLHauwmw+al/W7jnpRhNjQ95W4L3JQ8ZaPtJUivadstOX/BrVrRJ3XplUiTPSbGEPOPtNL17dGf1vKtCUnefzmPD0a6hIahJBNI= Received: from DB6P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:4:cb::26) by AS2PR08MB10054.eurprd08.prod.outlook.com (2603:10a6:20b:649::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 04:27:13 +0000 Received: from DBAEUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:cb:cafe::ba) by DB6P195CA0016.outlook.office365.com (2603:10a6:4:cb::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 04:27:13 +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 DBAEUR03FT039.mail.protection.outlook.com (100.127.142.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 04:27:13 +0000 Received: ("Tessian outbound e13c2446394c:v136"); Tue, 11 Apr 2023 04:27:13 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 11d45866009c1a5d X-CR-MTA-TID: 64aa7808 Received: from 635d2772ba43.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1EE65A86-6FBB-42FE-A548-7CF9CA9260BB.1; Tue, 11 Apr 2023 04:27:06 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 635d2772ba43.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Apr 2023 04:27:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K2PGzBnRd5vdOJM3uAtTJsJoIRnoTfzujbWhhrd70ScKM+TPKTjbqAt+VRcw+TRJhVnrfUf7bz3ZuX3rckxHGWUOb4nJMmHqGWvSZeex2Sai3ek5OTmT/xX1k6b6u/+IO6wxBe6pfZ9UGA56zAiMP6jL+iUpYwp9+Nt6NjJlUI9FMl1NfWi80IPQkROq6GMWL9UFxSLf7ij6VBuiLLvXP89RIDb7CXiCEl2fc9PnKwXynX0pJn8Cw/z/qX5SIwtyrZk/hJ99WwlpN+zvKtZHBkXcctCaNn82zQz4nPRH/7gNtCZXCnDRttM0pQqqSsxh1PP5rcSTJ5wq3fvSxBNUYg== 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=FeZxV0cQ0XyAJIP7tX+mk6XHEx+elHRod9JtzFwcMp8=; b=oO5yflkRiWAzPoYxgW1yKRk+Ydg8v3Yl/QbuZDqEFOMa25c4NzYBCneqgakzi9Ppze+ZllWyHviDgpP2FaM41y7vWDlmIVj3l5k7PG4kwYeZM5NUJ57c2or2aZYebhvo4r1wfNcM4EPAMDHOp16Vh9VbooMBH+PPHVS4vZGg7Jhg13jouPn3oea13Y+TYWocHkE4m+3gd90mE/sTkQiriS/PgNcpxa8pxKiP1m0DSBEhsqqr3nOkhU3WoJ1LQizp8mOXW8dNcyL250yQ1SpjO2WYtgFtc/V9R2gqjT1bJZGnb618SZc42ST0ozKBIcg3zmfMTL2jwj/Nd6PusikYMA== 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=FeZxV0cQ0XyAJIP7tX+mk6XHEx+elHRod9JtzFwcMp8=; b=OIqZZq/9pNbcszcDrROBd+mYn70kXSAtRVODWtAMK8aiKwRsY3Ewl077Q2koUlm8o016BS87NLHauwmw+al/W7jnpRhNjQ95W4L3JQ8ZaPtJUivadstOX/BrVrRJ3XplUiTPSbGEPOPtNL17dGf1vKtCUnefzmPD0a6hIahJBNI= Received: from AM3PR05CA0122.eurprd05.prod.outlook.com (2603:10a6:207:2::24) by GV2PR08MB8342.eurprd08.prod.outlook.com (2603:10a6:150:c0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 04:27:03 +0000 Received: from AM7EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:207:2:cafe::f5) by AM3PR05CA0122.outlook.office365.com (2603:10a6:207:2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.40 via Frontend Transport; Tue, 11 Apr 2023 04:27:03 +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 AM7EUR03FT053.mail.protection.outlook.com (100.127.140.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.25 via Frontend Transport; Tue, 11 Apr 2023 04:27:03 +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, 11 Apr 2023 04:27:02 +0000 Received: from e129171.arm.com (10.57.80.123) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Tue, 11 Apr 2023 04:27:02 +0000 From: Luis Machado To: Subject: [PATCH 01/17] [gdb/aarch64] Fix register fetch/store order for native AArch64 Linux Date: Tue, 11 Apr 2023 05:26:42 +0100 Message-ID: <20230411042658.1852730-2-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411042658.1852730-1-luis.machado@arm.com> References: <20230411042658.1852730-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT053:EE_|GV2PR08MB8342:EE_|DBAEUR03FT039:EE_|AS2PR08MB10054:EE_ X-MS-Office365-Filtering-Correlation-Id: 83122cbe-3a24-459c-8c53-08db3a45061c 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: CwPqXR25ABtwqzQwZJpQMX71u0JVNxamIb+GrjZt0Za1UNzJITY6fwAOdLjsSmu9wPhyaxHUkK13wOcawNxiUim2iSWkCmT3sgc2RB61e5syZZziLra6GRoz8paCc9ey+Yedl9EzQ7GlTBHI1OUoX8XXHnzkJaieRJm3129p83o+NTX+yOu5Um6haBo5fgnHSbdaRpVPWTqNumu02Q1qg8w+KMrpu4U/V/hhTK+enu2HADaS94KMCsrtSPCkJIz5/KErHMeBEz+wzwSYhui+BEe3lSLypYdd27tOXKjphpPr23OF7EjTgufBXccZzj4lZ8mlKSU3+1O4Jwu0+U+CVodmo6VUxkZcLtKKCQxbX6UzNvI6aPc3ZpFd05gDWV+7WNUEXqCzpSIY2+fRRrpBOtV9DFXQEpMmkU59gIzkg62FAqL55gV//dT5Q9GnD7gollLFyf3eDZuxkS/29e38+494ES2PgNBDbfRry2QTv7SbwSBBYZ++dKjhk2iOztYhP1YkvXMccw6W+7q0GfS2OmosiHukA+ZaRfOS7MGM/EEvsyCqeZI+VOrxY/GZL7Z1pTi3jMLSdvKP6FS+DGJ36eogvTQZD28sCTRkYZwnYYtHlJe/4y0+ATf7/lJht/4HYxMrc4c24oxa+aHKd+SCHNlXz/zxMADw7Am8SiYXSB3BT8fdiWMbsEl6KK5jHS/Gg2SBnv8Onwkp/y6wxoIQAQ== 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)(376002)(136003)(39860400002)(346002)(396003)(451199021)(36840700001)(46966006)(2906002)(356005)(81166007)(40480700001)(86362001)(83380400001)(44832011)(336012)(26005)(82740400003)(186003)(1076003)(2616005)(426003)(316002)(5660300002)(6666004)(8936002)(41300700001)(36756003)(82310400005)(478600001)(6916009)(70206006)(8676002)(70586007)(47076005)(7696005)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8342 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 18542fa2-f90f-4c1c-7f6f-08db3a450009 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KqsGhWjlbxkHySP/p5XkaUBaYoh7KI/Ppmi+KwS9luuI5C3pkX6V8gw3OQ2xtplSz3IwG4zle3aMCuOFoe93jpamOhCMjUMuYkD9ViDeJr2GH3u0qxkdQj28f0HIR0ywwUqNW0zOU4cGy5ug9aF6ynL0SRrF9q9PD9VsZlaXNgZOT13SRim5uIQQwr7SHXrX6q74bgD12rkwDGs34bwXJ1+zgOxLyniz4xVGuHQap48NaCF6uEiwyulcVznwT/tUP2mqjftB/pTB53l2PCNmi9HnSIvHCf+E7MtrfmIavp4duGoz3LaerwKPD3aCxZo4Tagz0pE39qQSKMZRDctOOSPgyzk28AZaf1wRMpFowpv3R2AK18/J5nhjs96uViRI56SHII2NW7AvH76ytgJsrV+Sji7JNL5IIBRx/jP9ydBojXPcC8hsLVN337NroI3rO6c6pVq77RAImymH+PNpE1Dv4UbuE2lqDeqT2YBEESXrIKKinJCP0AzAizg8wjqbooJ/9MyciCZCwjJOM2XMRgh4KrtpVeSiAyKwPUllM24QLAw9e6tyqzlqeLVObZt6whDenaxv1g17QUOjK7Fbrhfszec29b20EIkUV3Clt8fLAZNeJ4JxZdIGcNjVbt1HxtokEhukTryyRLgSSai3Vuqf1funJzyJFW1+y3yWG33uauSiO91aIJkRQvJHIVpfkHG/bctcksEjLydi1/+MMA== 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)(346002)(376002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(478600001)(7696005)(6666004)(26005)(316002)(1076003)(186003)(2906002)(44832011)(70206006)(70586007)(41300700001)(6916009)(8676002)(5660300002)(82310400005)(8936002)(81166007)(47076005)(86362001)(40460700003)(40480700001)(36756003)(83380400001)(82740400003)(2616005)(426003)(336012)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 04:27:13.2745 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83122cbe-3a24-459c-8c53-08db3a45061c 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: DBAEUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10054 X-Spam-Status: No, score=-12.4 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 List-Id: 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 ecb2eeb9540..62656a7347b 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