From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2075.outbound.protection.outlook.com [40.107.241.75]) by sourceware.org (Postfix) with ESMTPS id CF1963858D35 for ; Thu, 7 Sep 2023 15:20:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CF1963858D35 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=qjXkt1IckSgGYOC71cdOdjtBAc4erg2nljlQY7l1SQZQmn8gkSYqEfSpgo4wiOA1RiaF+svgyF3dj4APXsUPVP4ixVA21o/w4PmITR3cJml1WJv41uQEgUPoc8A+E9AHAO7k2UKHq33Y3uInTafgQMwlzj9OrcckaIhsq/oVDGQ= Received: from AS9PR05CA0139.eurprd05.prod.outlook.com (2603:10a6:20b:497::31) by PA4PR08MB6238.eurprd08.prod.outlook.com (2603:10a6:102:e8::9) 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:32 +0000 Received: from AM7EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:497:cafe::56) by AS9PR05CA0139.outlook.office365.com (2603:10a6:20b:497::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34 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 AM7EUR03FT064.mail.protection.outlook.com (100.127.140.127) 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 Received: ("Tessian outbound b5a0f4347031:v175"); Thu, 07 Sep 2023 15:20:31 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2a120edae51092e7 X-CR-MTA-TID: 64aa7808 Received: from 363507a8876b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D2464D4D-7FB8-4F7A-8AEB-F884C1DCFE92.1; Thu, 07 Sep 2023 15:20:24 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 363507a8876b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 07 Sep 2023 15:20:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AiKRUJHB9y1kPQIoEHz+jqAvV7KDcG965pOaelE0D1BwewgsgVxMV5a8sCPURohTzfKiVa9VAabu13p9aCx9Ihixabkpez/pvjfh11Td1X6Z2WFHfdB+8nyAqRtoplqnND+joLn5WkKYVhP0IlWBUWl9X1+8Z35v3ijgn+MUvk308pTf8W/QDbNVgp1mRCmGi6QBanjBeA49fIsag+WrljMKYaRSm8HaWfKIcaXblXw2Nj05HjBvl73HNaOPv2N3XnvVJ/9lk1RSZtPJJ0oUjeh7jnXf03cr8OmnljttlNJVc9Oy6FcprMf7r9RJK4BqEUFIjTbRsX/QeN9toV6x5Q== 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=miiuzzZtdaBMGrUpwa7gb4IKpYAF2ElkS9K9LrE8Q2+YPpP5VHQDWc1EkVByw4HBMkJHWFLPVVtDQHQoh0bjYKDcgXBVKP+3yDfPie79x+kUgWIqoWZ/cjR6xZgxVagfIfARQT7efcfKRSm1xXv6DqunCnuVz/FKcqBaTDxbJcqQX3gnp1dZyGQgxbJWRUjiBEok78fS22u3UktUKP5wHxdmjrG5szi6PY3cyV3Vs0pgR8cjhUzsAQDVxASR1bxk4K2aYWo/0prpLz9Ctid50xrphB1CikDz50qMc7owze+XY0TnwEsftGePdrieCbSriiacTwaa4/8z/BMTnqtC3A== 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=qjXkt1IckSgGYOC71cdOdjtBAc4erg2nljlQY7l1SQZQmn8gkSYqEfSpgo4wiOA1RiaF+svgyF3dj4APXsUPVP4ixVA21o/w4PmITR3cJml1WJv41uQEgUPoc8A+E9AHAO7k2UKHq33Y3uInTafgQMwlzj9OrcckaIhsq/oVDGQ= Received: from AM6P191CA0050.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::27) by DBAPR08MB5767.eurprd08.prod.outlook.com (2603:10a6:10:1a7::20) 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:22 +0000 Received: from AM7EUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:7f:cafe::f1) by AM6P191CA0050.outlook.office365.com (2603:10a6:209:7f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34 via Frontend Transport; Thu, 7 Sep 2023 15:20:22 +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 AM7EUR03FT054.mail.protection.outlook.com (100.127.140.133) 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:22 +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.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:21 +0000 From: Luis Machado To: CC: Subject: [PATCH v5 04/16] [gdb/aarch64] sve: Fix return command when using V registers in a SVE-enabled target Date: Thu, 7 Sep 2023 16:20:06 +0100 Message-ID: <20230907152018.1031257-5-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: AM7EUR03FT054:EE_|DBAPR08MB5767:EE_|AM7EUR03FT064:EE_|PA4PR08MB6238:EE_ X-MS-Office365-Filtering-Correlation-Id: af05e3a1-8f8f-48f4-b764-08dbafb5f9da 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: QD8RD4kjkp5Homq1NGGVLLe8hRiCmnsnBwGt/D8I33WiKGOlj4VD6TxpJbUdPFQbPIoKbhsmroK+1r9JHMYumh3wBgyX3/KJ0MgACwVWoxnCfnE8q2scUyFbky5IuhFIuZtFBmlZbq258XfaNhBlvq2prZc4Pouyh3p/5YhwqBocecqhk+W+2rKZWW5OPOfR55x5L7LA047EdEOXLHbvJYBBfR18ubGbnCRK90VE6L1spyr4dZsB06jyeU0gRSju7lSexTvVyBo0XbBgw7tl4SnIrbk+8PmzMdrjOCbBTRERX5eRMC+Nkl1293kW8+oO0v/hGQTXm+DXPp5Wv6BPqt4mcwWXFO320lbMy4eaaTyqG9Ls99PVA2vxgzOOdMcV3P8gwyhBd1xD7hHCoCH6weIxaf9MhM4h/zMTpmgFQAGTr3Iv3EPjGLXlS6FkoNNUWl4YhKwVKQrpN5bMHrEaa/0kEjlED8X8ukRfEB/FEh9izfAADYFDcufLfZ33VNwl7wkiOh/Cc0U3eQ12YergUaRcH0IPcUxjTEcZrbjodkJjXZscPUuOPXh3dbG2TsjZoGupsz5ZS29eK5M6Ut+78TIzIed9oySeYkcemnjlUQ8tmuRx0Ki9HY6VXllwOPdBeo1Aqbx8A/AL5LtTlTeM7jF1Kzr9UH6uqR71EWXYjSH6DLpkp1eXWgbA8dOLMmkNuf08X+JAwXMyFd67dotomLvZzYDVOXQuXM6rRDQNQDEjvgSv/4T/OI9itww0TAjU 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)(376002)(396003)(136003)(346002)(39860400002)(186009)(82310400011)(1800799009)(451199024)(36840700001)(46966006)(81166007)(356005)(82740400003)(40480700001)(36756003)(86362001)(478600001)(2906002)(6666004)(7696005)(4326008)(8936002)(8676002)(5660300002)(44832011)(70586007)(316002)(6916009)(70206006)(41300700001)(47076005)(83380400001)(36860700001)(336012)(26005)(426003)(1076003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5767 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 9e771079-afed-40cb-08c3-08dbafb5f439 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nHhKRGd6vC3tvZB0E/0AvuVP7n9TZlAdNhiIjOFQ36hGL9tkaXWDbniv+NeMbZKsyWza/0Si8Y/nW63S3Obrd0Ty8xnN4ZlRbAMcTv3GAE4u3lsJBFbnu9qPlugHnsLTmdhalipIbKNA/m4X+7F/qH2gDIcCfKrbAUsAz0gxJY0vjgyUVbrvXotIXzXBUi3QR9vlvNKOWvjDbtv4wZSOKqSiCvzyuBQoZH4A2whtoTuQ2gvrVqbBkLlbvgHulhJNKZeYRy8AITQYylXfBoDC+Fq4m7KSJPOcL7Q2xkZN616ieeuaXsPBEfgqW7rUum/lbVqyIhBxk8k4CqCIKKyQNMTGKrdPUASYaBPcXMc2RpszZzPIh2/bWcBRDKdTkBukcC2NP7Ri3Jpibjt9MCsdnPTEg2NDRHn/xn1iAbP/6+YthMpgngOkFozL2YlLgE2dkKU/Uroqc0EknFrZBX/KeHZM9rzJsEdlN4lN8r0fDEmNjmu/rRTnCeBCm/vRJe1rRb+F1tr02H3xgTmDRLgAx/P0H07FOlwSsVoAgsZuJmpwL+GGHRZaj4dmYjjWvcp3l8OwIsw+C7ty1IqfaGo5qTQUA7TrVhFoB5pVsVcy/pFTfH1NPASj8J0eEhCnXR1ifowznLOmJoHVxT+h00Pc4XagB56pRw3ajF5s+rlKR4CibZCwtTrU7fPwqtzXzGQnFSPau+sawYzX9yvD7Lk58eLQH3yQ1AUqAe5X90XEWeNfqkExq+aA9wni5bYWaMGW 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)(346002)(136003)(39860400002)(396003)(376002)(186009)(1800799009)(82310400011)(451199024)(46966006)(40470700004)(36840700001)(8676002)(6666004)(7696005)(83380400001)(1076003)(70206006)(478600001)(336012)(26005)(2906002)(316002)(426003)(44832011)(6916009)(41300700001)(70586007)(8936002)(5660300002)(4326008)(2616005)(40460700003)(40480700001)(107886003)(36756003)(47076005)(86362001)(36860700001)(82740400003)(81166007);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2023 15:20:31.8234 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af05e3a1-8f8f-48f4-b764-08dbafb5f9da 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: AM7EUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6238 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