From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aDM7ARBPZ2QCmQ4AWB0awg (envelope-from ) for ; Fri, 19 May 2023 06:27:28 -0400 Received: by simark.ca (Postfix, from userid 112) id 0174D1E11E; Fri, 19 May 2023 06:27:27 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Fq84eMuE; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6108D1E111 for ; Fri, 19 May 2023 06:27:27 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DD0143836E93 for ; Fri, 19 May 2023 10:27:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD0143836E93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684492046; bh=yNZxAug8uubWan8UPQH9Jyc937LWQb8s8sO+n+Zf2rg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Fq84eMuEaUL4GhjHNBVF9vygpsXwFbKSWccl7UWvgUDtnGgkIhTBn85KYHmPu6O2d 81yscH1nzHNIYoyOpcxZboDkaiQWWHhDHkdL6FzmKiVbe2AB6dyRHivRnjymXnX86b LPnI+CQSIXQxnvPbxqdNOED4mti9arP7xqIf8AP0= Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::61e]) by sourceware.org (Postfix) with ESMTPS id B95983858C2F for ; Fri, 19 May 2023 10:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B95983858C2F Received: from DU2PR04CA0248.eurprd04.prod.outlook.com (2603:10a6:10:28e::13) by GV1PR08MB8451.eurprd08.prod.outlook.com (2603:10a6:150:83::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:23 +0000 Received: from DBAEUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::1f) by DU2PR04CA0248.outlook.office365.com (2603:10a6:10:28e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:23 +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 DBAEUR03FT058.mail.protection.outlook.com (100.127.142.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 10:25:23 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Fri, 19 May 2023 10:25:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fc87ba369dc985f7 X-CR-MTA-TID: 64aa7808 Received: from b5b0e54ca8d3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7599BB3F-0E3E-4DEE-8BC7-F4CA8A3A443E.1; Fri, 19 May 2023 10:25:16 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b5b0e54ca8d3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZHz2EKwbZXi7U1baJ4s0D7+Ap4l/laDTbuFw6tau5S38hIFFXRrYko16N+N+ShxvyWxHRs8BAK3p3PbjvdyVT3SLcEsTUsrOXPaJjLzy39kSb13MQSn1Mn/KBardAKjwrOxAdklud23EnK/WI6TSsArsoT6QN+LWzInYdgx0d4c2Ke5zaIFi+U5RkhDPQeE8KcaxVd7ff5pj8GmmckhoMxJzHLT5UD8oSgdJWE5U9wFSAjr4x2AtTDxUUDvUiaz0DpneOZ2TImBNDmgeiWATVszONjPfOjn6QlyOVmrhyNQf2J5AFubHBzoGNachaBf2XlLwpN4vCfqgAauGC3GxuQ== 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=yNZxAug8uubWan8UPQH9Jyc937LWQb8s8sO+n+Zf2rg=; b=S13Wc/ab9l5e/kUpJolNcVxQdF4L4dsgrM+B574nd/ciwvcCKxoBJNnD2hogFudUdokHZIU2VnC8OAzU80JG7A9XOsg2l8PcFsgBEj0xftGEfNO6nLjmHVTp907Rsj5AuVIOgpmGTOkKRhNWC+jiXR0QvvzmuQ8E74i3OcuV9q0A9eflW+uSV8JxNzSWYyKN2sjmrXnchVHmBtJSzFbjgK3M6i7Z3unKSRhIaZW2GhIln60/8S2vCO1ugVqkilH7VizoKBWEKi49l0HTLCe5sztBlP81UkQ8fcJutCy2f/rEC8LuttrgZcL3gYIm5PiZZ040tCep3LDiZlCGRJ8lRg== 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 Received: from AS8PR04CA0121.eurprd04.prod.outlook.com (2603:10a6:20b:127::6) by GV2PR08MB9255.eurprd08.prod.outlook.com (2603:10a6:150:e3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18; Fri, 19 May 2023 10:25:12 +0000 Received: from AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:127:cafe::58) by AS8PR04CA0121.outlook.office365.com (2603:10a6:20b:127::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:12 +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 AM7EUR03FT039.mail.protection.outlook.com (100.127.140.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:12 +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.23; Fri, 19 May 2023 10:25:11 +0000 Received: from e129171.cambridge.arm.com (10.1.37.65) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Fri, 19 May 2023 10:25:11 +0000 To: Subject: [PATCH v2 04/17] [gdb/aarch64] sve: Fix return command when using V registers in a SVE-enabled target Date: Fri, 19 May 2023 11:24:55 +0100 Message-ID: <20230519102508.14020-5-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519102508.14020-1-luis.machado@arm.com> References: <20230519102508.14020-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT039:EE_|GV2PR08MB9255:EE_|DBAEUR03FT058:EE_|GV1PR08MB8451:EE_ X-MS-Office365-Filtering-Correlation-Id: 037d0ab1-4da6-4bb0-d44b-08db58535ac4 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: xcMoyVZhfCea6xKFIf/CjwcmfQ2NPkqeDdHnzPvpMDOiPFrGX0Dnx93H5e+g0prYfF5KWgjNaUDxTOyHjir61SSuh1hSdsxuU90Oy1OHa+sKnVDCj4ach5D8qmmAlmT889TpdZw828I4LmAOlIBT47Cy4pvt6FpWPKw2VSQs7nL3ItPf1phvTnTyTMNESLDEEdmWtuhfYNCQl/7b2DJ3JbGBmG9Cps7RCuhb28HP0bE7P8zyKI4+C9ltELCVD1srcUfg9+fuDxhNEn4bpT97XaR8EmnXSCRjXin2A+8f/HAYn8iwiiw/MR020ne3DsSErWqTCYdQma1cx/qoYZb8LzDZWVpN6Cc1VMq7v8eRlZIO0oNgypTiTfODTIxvp5iyOq46wVjMQgmDYwDhvwhD7qiqEfLrJbexUeIuxaj+fTk3II34SIFyIurkJBTBhWn6bgHMhFneRyku5VCXyJHSVnKtJxKOt9yCC7yLMZj03qp79M/24djaqC8+5A49dz2O1LdbjPMf95SJhAaCFOvspwoSQyrDYqKKATkJUiBGeG+ebDb1UQzOS6rmLzM+nnbzjZnfz9ntHrpubAlmKM0Db9zkeZehfwOFsQMFqh+EdfcEbYnETuEYdaPw0P3u/ry7JyPg5+SWUodRANOCELfgv90e4CoFR8s4LQqxWgevJS9aPzb1s9gYJ9DdnImdCmz/fVTUM8Ep39n3gtkgFMiERCFLgcBXYwvL/FD5X4npuit5gIaQZv8cJoxT6xymveoouDU1RGb6VD8xTxWTkQv7ug== 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)(396003)(136003)(376002)(39860400002)(346002)(451199021)(36840700001)(46966006)(40470700004)(40460700003)(7696005)(70206006)(6916009)(70586007)(478600001)(316002)(36756003)(47076005)(83380400001)(26005)(426003)(1076003)(2616005)(36860700001)(336012)(186003)(44832011)(2906002)(8676002)(8936002)(82310400005)(40480700001)(81166007)(82740400003)(5660300002)(86362001)(356005)(6666004)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB9255 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 03b8479e-1058-42d9-7d3e-08db5853548d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xOGn68kuM1M8Ymsx6pFHv8svz6Qzn4A15fVHwhq29h5OOPCi6Ablaeuz72aroqDn9ovg6/UF3C+w1oHNba1KkOROPNUv1wBfKUX+hder80OkU7HnWVSMTj9KKP46pvH7Rprpue4iRpXjbfagjyoFu9KxuhyMnkSrYiwV9ruBarcGtVRdtsG33xK439JWPTKv3Y5O+pqaMlglVvRjCiL8r6ATShFU5jMAKrCFbOQbN3QHFUZMiIBU7WjT6lBUkDvA1w/tM5y1LMbSJso5HMEQ2svSHNp8+IRHHqS9VN5BB5mTJ4Yrvg+kVePOwJt0nJSTzz14qnXuxEmcJcWm6H/o/jWuPwRfd0xAxYffcgA7bixILz/uVGeCnrn9IoBjl8HUY6jUBmB888indlxuaxpcHannU97qT9FH3EVWHJCbUV5WjlZR7iQWHAyIeIrgXJc04rUEpXWvbUcznIj7FXVsghAvKCkdQ6Bi8K23xPmSOBFSJj2H9knVmI5cXZtqc7YNBU9DdeE3dr6Tq/lAVlnXLHxpE9RW1jywhaE/3LK0A85nsAc5aas2BaalmYddcQwBiSwVch+P1/yc4PiYXvE0VT5rLA5mJEKhNV+Edyd6vXuByt1ijeehGgDd74V+r54jdHTHeFd/Su5YrO3WxaHE58FsE0+YouliRsS8lybJWPpdKZRouYCq2noNTkeqLbDsQhtVodix5DwMAXzWBgS8pI3Q4nSSI6bB+MANU0+eRyw5jeiG90z72679Ytevd9WW 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)(39860400002)(346002)(376002)(396003)(136003)(451199021)(40470700004)(36840700001)(46966006)(86362001)(36756003)(316002)(70206006)(6916009)(70586007)(478600001)(40480700001)(6666004)(82310400005)(8936002)(8676002)(5660300002)(41300700001)(2906002)(44832011)(81166007)(82740400003)(7696005)(186003)(336012)(426003)(2616005)(26005)(1076003)(36860700001)(47076005)(83380400001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:23.1435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 037d0ab1-4da6-4bb0-d44b-08db58535ac4 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: DBAEUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8451 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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 6402b28158e..5a2c924f82d 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2411,6 +2411,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