From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2044.outbound.protection.outlook.com [40.107.7.44]) by sourceware.org (Postfix) with ESMTPS id 6F19F385840D for ; Wed, 13 Sep 2023 10:18:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F19F385840D 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=Vcqn9AMq0NLjfuq20cMKuWEN7ql10I7cTwO4/k2FL/U=; b=tfqtE8Z2NUV2UGt+hS7TnY6HjVk4DKoSKC2Mrd3M2sFi62jKvRPAI43MbQCL/hnG1B+2wVpY603R/oUXvhEuDu3yVCcvY+pc7gPKDRA18KdN2fB2XjODptbHRVXZqWlTJTQsPgZ73Mp60G5SFaJjFD5FzwHndYuRcycO9Rq0Q7A= Received: from AS8PR04CA0007.eurprd04.prod.outlook.com (2603:10a6:20b:310::12) by DB9PR08MB6745.eurprd08.prod.outlook.com (2603:10a6:10:2a2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19; Wed, 13 Sep 2023 10:18:38 +0000 Received: from AM7EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:310:cafe::9) by AS8PR04CA0007.outlook.office365.com (2603:10a6:20b:310::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:18:36 +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 AM7EUR03FT031.mail.protection.outlook.com (100.127.140.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:18:36 +0000 Received: ("Tessian outbound 30c9f5e988c5:v175"); Wed, 13 Sep 2023 10:18:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 26b328de7a8bb309 X-CR-MTA-TID: 64aa7808 Received: from c3bf54814ab6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1A911310-D028-4C07-A3D1-575098F68B14.1; Wed, 13 Sep 2023 10:18:29 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c3bf54814ab6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 13 Sep 2023 10:18:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hdlhn4R+dqyIO2ojwTqWQBd4gKsZRAinV07twcpPI/7UhJqpRxM/ewgc16RcjQgzVWErkDQxJOqr1C/Nu5lmre3oPBI0ATPwKFor+zBkEuBZvuV7Uw6BefdGQeIMtzX0V6Okzz/wLXJKAc2/HtG3Z0TX/L9P2qGuYZ4TbVXuZUr16qNYgB43WEkKFIlM3iOelGMn/cLaIXpgRQPvwyFqL7jabADG/9Hhk60w0VQt9JvfOQSB+bDDfgF/5JwFc2J2ktcV44MkDkgp2LK15nc8v5CC3oyk6JCnSR1a+KuZF3YYOjk6Z7SRN2Iv9eTENmkye5iLcTeYqjysm2hsrFemhg== 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=Vcqn9AMq0NLjfuq20cMKuWEN7ql10I7cTwO4/k2FL/U=; b=YwRcC9TI4RGfKixATqbCWqWN3j2GFAPcRkgLpc6l+tOXwPPP3Ekg3VTp2O3bfwOCLz9Ey/SnQVQCtQVlVSNqPAuiPuX1HFCl75G7TA7HkLCElhpKUggtLn0vEAYvFyo+fORv4Q9FaJsoQsSnE7zjT/AFAiyw3zGJ0TXqHFVldEpl8er2+kNTXQqSnKXEz+US2+IgSZY6f3NmYr3gyl85uhwN8zW5+ojxh13T8cC4dZzmcGRtuvFZgJolnoFdlq+5b33I37ApaCZng0g34LXH0ikOBTvb2bAKK3JwRCKDjdui8R4v33Oejko6M7n6h3T1lJhj1WuFvyojnRnAXB99Hw== 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=Vcqn9AMq0NLjfuq20cMKuWEN7ql10I7cTwO4/k2FL/U=; b=tfqtE8Z2NUV2UGt+hS7TnY6HjVk4DKoSKC2Mrd3M2sFi62jKvRPAI43MbQCL/hnG1B+2wVpY603R/oUXvhEuDu3yVCcvY+pc7gPKDRA18KdN2fB2XjODptbHRVXZqWlTJTQsPgZ73Mp60G5SFaJjFD5FzwHndYuRcycO9Rq0Q7A= Received: from AS9PR05CA0250.eurprd05.prod.outlook.com (2603:10a6:20b:493::28) by AM8PR08MB5571.eurprd08.prod.outlook.com (2603:10a6:20b:1d0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19; Wed, 13 Sep 2023 10:18:27 +0000 Received: from AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:493:cafe::eb) by AS9PR05CA0250.outlook.office365.com (2603:10a6:20b:493::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:18:27 +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 AM7EUR03FT027.mail.protection.outlook.com (100.127.140.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:18:27 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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; Wed, 13 Sep 2023 10:18:27 +0000 Received: from e129171.arm.com (10.57.66.200) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Wed, 13 Sep 2023 10:18:26 +0000 From: Luis Machado To: CC: , Subject: [PATCH v6 04/17] [gdb/aarch64] sve: Fix return command when using V registers in a SVE-enabled target Date: Wed, 13 Sep 2023 11:18:02 +0100 Message-ID: <20230913101815.178154-5-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230913101815.178154-1-luis.machado@arm.com> References: <20230913101815.178154-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT027:EE_|AM8PR08MB5571:EE_|AM7EUR03FT031:EE_|DB9PR08MB6745:EE_ X-MS-Office365-Filtering-Correlation-Id: 60368d5e-e6f1-473a-f7fb-08dbb442ca7c 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: umvK5cMqYsaAZU/6+PuFP6agkovbufyRBsWcj0d0ChHu2hDnsBsOCUKlaeIYTLuoFCi6XY5rizOi9s56w3yMZFc/7ob85zoWfdpEVRTMB/SJqOYex06EGRNGMgXs2O2mjQQdc0OM2Yu3z5noQW9oni5mc21yi/IMyuwsJVTC5v1py6NAXTEuYdZWNytnfMWNFqprGslwf6gZkdV25uR58+8JVXmTZbZRdZBM07LCIGM+BLQzRDiIYaDB19oE5tEt9uojhnBO7rHgry1/Yu3qL4RFDQxV0G/K2Cj9dcQWdArc249kS6cm4GMn+Y3z1HToVcPCB8QZqFC0FXaJwaPLKxpOn0pZBjBFpNA8Pe5EHgY1amEEH06rQT+OXn2ty7z5DjgT4ZeZFZKVLmd7WO6BEdOEL+N5ZDPE/GDKxyp421iLiKe+sbWfgg76FWxtY9P3PFBuTvVnDE1LDm8GDFKsExTEsz8ZVvPKybraAho4s1O1d286fwhiG19M/VCc5x40SDLV4CCgdWbwAJtKv0UVx6Ju65EM4ypkIhXWepQZUvtrGdX0ziKO1hhR+rtPzi02wc9ZZOWKowVMCkjqyF3wcx45GFNwYffqnqFSNlwQkyqhnbq6FyFeQo5TfVtJHfh07nGUBqEq5OHcPMcSh5tBultLApFlfDBBj+8mesmoopr87GVtdoU9kgeUkyB0aimWY6TFKW0pVf15i5c+PAPRvYL9AcCpZOtNc+0Kihb3kDjIxv0mR2A2kh+RJ1lP3sHtCscCrcS2moUsuwQW8o7bow== 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)(136003)(346002)(376002)(396003)(39860400002)(1800799009)(186009)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(40460700003)(82740400003)(81166007)(86362001)(356005)(40480700001)(36756003)(6666004)(7696005)(2906002)(426003)(1076003)(2616005)(336012)(26005)(70586007)(54906003)(70206006)(6916009)(316002)(41300700001)(8936002)(4326008)(8676002)(478600001)(44832011)(5660300002)(36860700001)(83380400001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5571 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 68987153-8f9a-4788-9b6e-08dbb442c591 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rXNm9AskNrEK5OmMgea4t4aeylDgm6egANdGwfYPIhs18Mf2KC5ZFgFExAMiPzCO/NE7045e3i68kweWWJihx+WwBiv6vQ9G4t2DcFUf2MdqC37odzdfLX8pgzxNIRi0JdZH4me3bClJlRWQwk7/SR6v26pqDpMnhbtNlpeetBqMT0Ry0skiArUfBfuKqHozP/2hBf5VjhYlnquBT5nYlkVDV1FxIew9m+fetlkKwsehj0Xz3O/tI8PdZXC9a9ex1Jt86WfaaALGGWA6HLWnvfArgM17FoCjhU7jHGizzCfnod4JftMg+ch15if2YtcEKGHUNB2S1Ht+R/oz5ZxNDzsMxD9AulOCvOaNf6K3JKK6u1LM5+LrLKyJ/N6sA4ssxBp/w81wGuf3ZUiOUadjRqHcJgsafRH2z8ibfDQI7judRHtBFkX00RueAhoPmr/Fp2ea1PfKWb9dTOA4R5nHTD/ICubdL03TWx/WFHL829Iq0auDAdnQZAqLIRAFIKi05XEJwzPH7VGeAX0x5O2kyq8ecuLwHaiwDmy+kPKzZcm4sD6RKFoWcR01HyUY13X0bplGWyG+5gIORl+pK6//zhGKmeG8TBKSG0QgU0MZ2NyXsFlz7mmHJimB7GJti8dE2zC/2ja7u1+HdotpkvqLUqZAZDasCFcWc+td1DJc0lG97ih00O0oxYPzrqHOBXUsCqAbTIvfz666Okapx0zNXNd8HsBv5FUxINVDaAP3i1UO3za7QH5p8NnUrFt/Ct8n 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)(136003)(346002)(396003)(82310400011)(1800799009)(186009)(451199024)(40470700004)(46966006)(36840700001)(47076005)(41300700001)(36860700001)(83380400001)(6916009)(316002)(40480700001)(6666004)(54906003)(478600001)(336012)(7696005)(426003)(1076003)(70586007)(70206006)(26005)(107886003)(2616005)(2906002)(82740400003)(5660300002)(86362001)(4326008)(8936002)(81166007)(8676002)(40460700003)(44832011)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 10:18:36.0460 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60368d5e-e6f1-473a-f7fb-08dbb442ca7c 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: AM7EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6745 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: In a target without SVE support, the V registers have a size of 16 bytes, otherwise they may have a size bigger than 16 bytes (depending on the current vector length for the Z registers, as they overlap the V registers). In aarch64-tdep.c:aarch64_store_return_value, the code is laid out in a way that allocates the buffer with the size of the register, but only updates the amount of bytes for the particular type we're returning. This may cause a situation where we have a register size of 32 bytes but are returning a floating point value of 8 bytes. The temporary buffer will therefore have 32 bytes, but we'll only update 8 bytes of it. When we write the entire register back, it will have potentially 24 bytes of garbage in it. Fix this by first reading the original contents of the register and then overriding only the bytes that we need for the return value. Tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/aarch64-tdep.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 21dd6c7a38c..b1d7da91754 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2417,6 +2417,11 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, ("write HFA or HVA return value element %d to %s", i + 1, gdbarch_register_name (gdbarch, regno)); + /* Depending on whether the target supports SVE or not, the V + registers may report a size > 16 bytes. In that case, read the + original contents of the register before overriding it with a new + value that has a potential size <= 16 bytes. */ + regs->cooked_read (regno, tmpbuf); memcpy (tmpbuf, valbuf, len > V_REGISTER_SIZE ? V_REGISTER_SIZE : len); regs->cooked_write (regno, tmpbuf); -- 2.25.1