From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) by sourceware.org (Postfix) with ESMTPS id D52E03857713 for ; Mon, 18 Sep 2023 21:27:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D52E03857713 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=iCETcDpaCaaJdYb2L8yoKjyzHEIo4Vqb4DDvG7hzG5Q=; b=BP+J+vQEvK3icepzT2J41QtsnQtloodQZixyaVbXIRuue5yCvvpeJFlbbuKFff8ArfgMeRHjT09ZsQRjjHkWSlf1eLjXIOzzmgQWRdEXwfec3cdkjPtqXFgfA1rRjiIa5+n8niy9s4bUcK+D9pRD26XQOaq0Txz8hcCEk698vvE= Received: from DUZPR01CA0170.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::28) by AS8PR08MB8874.eurprd08.prod.outlook.com (2603:10a6:20b:5b8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:12 +0000 Received: from DBAEUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::b9) by DUZPR01CA0170.outlook.office365.com (2603:10a6:10:4b3::28) 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:11 +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 DBAEUR03FT025.mail.protection.outlook.com (100.127.142.226) 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:11 +0000 Received: ("Tessian outbound 30c9f5e988c5:v175"); Mon, 18 Sep 2023 21:27:11 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 404f9a431713f1bd X-CR-MTA-TID: 64aa7808 Received: from d9a271e6ed10.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9C2EBFB7-D967-4FD1-823A-E27858DD784F.1; Mon, 18 Sep 2023 21:27:04 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d9a271e6ed10.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O4LiZSTDajMS+aVxouORstkvo+I64wuFdhxBpD9Wh5Rj823hNPUS+l+Ad0WILZrnt7NBDvvVEcWxKkQvZOtcfaiZ5jemz93buyyKgm5M5BurtK+a5ZifaZgFnqnJwHDeSlB1r8AVdLgMbswcX+lajHQAovCZeXNJVW1DpEs1f4cdSExseYhMWQZkedMY/xho/OEq/X6gt4zSGT2k2LES9UR4Jq3qI4AdHyf4xX2LOgDdCnnk6L/HgVEVovwTUDktrRhVDbNFdJWKcLHx1JWXuSwLuUHVxpenYItmT29u7rajMH9S8zWpLEWjtLLcvNsi26dKE72yjQO2qbEkSh/2FQ== 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=iCETcDpaCaaJdYb2L8yoKjyzHEIo4Vqb4DDvG7hzG5Q=; b=cBDOSC1RL2zgfalYa9nyusMx1ueavXB6856oLRLbY3NQHTMY8ZUTHmsDSVheERDAkCYsK84MHyAszeJgtgU6PuJAg3fxLI5+gsPi6+AA5Kkw6HG7iPi+ZOriYnJ2PXfG47ao0gW5DTt2fxWg8RQ8J20n/pL1ujvagTD5EFzPOKU0oSO750Wc71MwQgByak+yxSNKOlL2EmlnU7cvAhytfo49bNw2Zt742unlt7ALCMCpwjdBxER2UKL/qBtHQFPGll/akhys1eL0RZw6pTEyWVHshaI8MgnY+1gswzeXU3zx9TAo/WbBrZ/A7u/MLi7ig+ggXW55KgoTKu11plq78Q== 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=iCETcDpaCaaJdYb2L8yoKjyzHEIo4Vqb4DDvG7hzG5Q=; b=BP+J+vQEvK3icepzT2J41QtsnQtloodQZixyaVbXIRuue5yCvvpeJFlbbuKFff8ArfgMeRHjT09ZsQRjjHkWSlf1eLjXIOzzmgQWRdEXwfec3cdkjPtqXFgfA1rRjiIa5+n8niy9s4bUcK+D9pRD26XQOaq0Txz8hcCEk698vvE= Received: from AM6P193CA0136.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::41) by DU0PR08MB8373.eurprd08.prod.outlook.com (2603:10a6:10:40a::12) 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:02 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::5a) by AM6P193CA0136.outlook.office365.com (2603:10a6:209:85::41) 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:02 +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.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:02 +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:01 +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:01 +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:01 +0000 From: Luis Machado To: CC: , Subject: [PATCH v7 01/18] [gdb/aarch64] Fix register fetch/store order for native AArch64 Linux Date: Mon, 18 Sep 2023 22:26:34 +0100 Message-ID: <20230918212651.660141-2-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT009:EE_|DU0PR08MB8373:EE_|DBAEUR03FT025:EE_|AS8PR08MB8874:EE_ X-MS-Office365-Filtering-Correlation-Id: a4ce32d8-df59-41e9-d2f4-08dbb88e0573 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: x/6elwL0Jv8iQGUqM2KOqQVWm1lfIKnWteXSBqP1ewoTQF4oVuZQe2/Yp3Iu+KGawBp3NqYOlcwzcK6JSvpZPFl1octIVXckn+CTrvXHMTn6MIQgFlX2iiBhuabjpADgIumxFU9pyzuiUXqQ9nln3dqseJPBwv9R8RJkG1lIslVlI9uCOcOia5g6TYuej6f5ZGmcSrzh4qEWGBvWIPY3wN7AyqgiBRs+mfOj+HFF+biraBiewuEdXnCePKBV4to/O9ADfRxHjeIqvsAsPsJIhq/200lieSwG47MMh4+85a7Zcb6v6kTAN3dJlcps6dcNCJvS9rzec49bi5pRLZz8GddahMBVYSY+avFrXEa1P/GdT2K5/YQ5ZNCD8JLqV2S1WNwhB7GI+cpfHi/a6KUB4mscTU/8YBOHjBYTLswG+F0RSvwNBmlf+CnAbC+LEICo6OVb3fStRnpa5rJoN13ziomxt05o4uCkD0gkItmaeEBYb9qyePYqmBhX1/CTFmKwHLT10LKDE4PbfVQw9ZqH9iEdPybi5hJIyT28C9e7DoXWrq4sJ9SD6lvDClenuXgiPtfk0/B7rzV3pI22K0+90+b7dPX9diEo/vRvU2PgWaT9uU18TkiT06597AAtET+2AIfVoFF3cfE8UiS2WzeFtW4mZlMOCGvtkXeu4OyzQnvC11Hkvr+SA58a9zmaFNKpQTRE2PVc32xjVg9biKsHwhv6idlyMG49xmBWberixwm55qqeYEN0rRTsBjAeBH3dbs3wlyfXinajNi7938dRfg== 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)(136003)(376002)(346002)(396003)(82310400011)(186009)(1800799009)(451199024)(36840700001)(40470700004)(46966006)(36756003)(40480700001)(40460700003)(7696005)(2616005)(6666004)(2906002)(478600001)(1076003)(5660300002)(83380400001)(86362001)(336012)(426003)(26005)(6916009)(316002)(70206006)(70586007)(54906003)(41300700001)(4326008)(8676002)(8936002)(44832011)(81166007)(356005)(82740400003)(47076005)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8373 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ae81ab17-4660-400d-92cc-08dbb88dff8e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cSkoduVrfU9MEEr6sNhZSLQKdf7XVZKD/VG/oNT+LDeb08nO67ulHyMZ+T92wzVs6+WUH1kkY7QrgxPArk6OeK0UIjbK2rg+gFBCGR2M/k4+rL1WN7pkfchaW/t/rBIIY6wW2WCjt0bP6Oi9fBLtEPxbdsEtO99OCe6/wny52GfvXgmUDmK8TK0W9uO3vS2UyWxhWVf2RZUCtDKlfBiSYOANoJLxRXX1vNxLfSCzhjkP+n2FP/W8+2ugnD/jKIkEjAjpReNFNazGjCmT6Irqe+8MrZJPJi/lPIGObemowedIIv7fpO1+JkIZBID5BZ04iMvKJNK/PjPk99UKlVtfn/z2h0h5EXSYRH8bPT7lRo3RQqMFhh0OW7d1rUGZsgfgxyAFokUtIap2ZV9ZXU+pS41ddpAxBf8pruZR13IX8wYsyn8lg0pQyZJGeGXxVm8t687DQlD89C95hpqDX9ScVtEYUWQVzsV5XdEbyGWYZRSx0PsECHTfdWsOQI36DPPLBg+KcJxKsqpJQZ96PXJ1wHlm3c/U5PLDeaRzNGv2INa8tEz4DZge5dZd1jYIFC3VYY63skKoCrv/1ZC+1/f5fi4WVzt2rvQZaOt21bOLeicGglslekDWuOwpkpG/+bN4osCJeqsP6flcgIQGk7XJcwbTwdjUnXLb9FriPZBpIaJjsyFRTFvRowD0IjIz7SED0hAmRtMO+hOO2hVwNVzyhxbSIWx4cyrJUsTWKyWGVOubMBsVOvRK7FX5/Ngxa7UQ 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)(396003)(346002)(136003)(1800799009)(82310400011)(186009)(451199024)(46966006)(40470700004)(36840700001)(54906003)(478600001)(70586007)(70206006)(316002)(26005)(336012)(426003)(1076003)(7696005)(2616005)(6666004)(6916009)(40480700001)(8676002)(41300700001)(44832011)(8936002)(5660300002)(4326008)(2906002)(82740400003)(81166007)(86362001)(83380400001)(47076005)(107886003)(36756003)(36860700001)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:11.9400 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4ce32d8-df59-41e9-d2f4-08dbb88e0573 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: DBAEUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8874 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. Reviewed-by: Thiago Jung Bauermann --- 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