From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2059.outbound.protection.outlook.com [40.107.22.59]) by sourceware.org (Postfix) with ESMTPS id BA1133870C26 for ; Fri, 30 Jun 2023 13:46:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA1133870C26 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=oOrmhnhUpY60G6Tf6ivMBJjhpysdr2VCVgU8WKtdn5PCIwCRJcQf20z84DR5FvUlFlrkSs9Bf0OUvJDziS5d2QOvp6mt844TYhNdgX2YdEujyE2z2xUoW8xoVis0QT+PeFYj64MYsa0ENsaCu10iaGIFPtiek3SpKMK167C5UjQ= Received: from AM6P191CA0083.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::24) by VI1PR08MB5536.eurprd08.prod.outlook.com (2603:10a6:803:13b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 13:46:42 +0000 Received: from AM7EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8a:cafe::37) by AM6P191CA0083.outlook.office365.com (2603:10a6:209:8a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:46:42 +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 AM7EUR03FT053.mail.protection.outlook.com (100.127.140.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:46:42 +0000 Received: ("Tessian outbound e2424c13b707:v142"); Fri, 30 Jun 2023 13:46:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6d306d7211985ec7 X-CR-MTA-TID: 64aa7808 Received: from c08ff99f169e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 76339732-8AD7-4E1C-8451-2B18B41D37EA.1; Fri, 30 Jun 2023 13:46:35 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c08ff99f169e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:46:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CvO9VD5bIcxJBcVQeb7Gez8dbq415Fp/jneUi1yT7Xv8yoJblopiJajf8pDU7xKoS14tRQz3PMr2oOlrc4zcOHi/JFUTFkHB4hxtm628Ic/iarH96VqDZsg789xp43k/zohKpQwae8i57RI/zwe3vP3jSNdQh+SKemk4UAbCDqk53exh29TxK3O6Cd0voer/wcIA1qUy6z4Aq06ZpqPDeqN+/9lIll2lhXnjUsUo98+x/J79tWpCPAYYAUXncvmKRHJ091CCxiHeLMEA56RpFCzv4nsJPPyZnbNc0/gc/OvPqHJpwtmiYnEtT0l6fWWdsVG0dCiQFyEVnwCTn9MkcA== 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=RHTifSBnJ62kvuGz2qv/rV5Qv3BGgwE081Ej5X339OIwJrPOJUHDGNkBNZEQ7hNjzxP3vx1CIlouZXzy8TclFgeWG9DO9s9awc4m4Skg7vBT4tGpqZEyEH0pa7LnuTgscCKjzumQAXguavu4jHcDrIFpSWLvCuhoTb6exoBTuunNW8iPf0ILl18W09xKnLvd0UJfup9Hq9msOVULfNHk9VMBC2En5+OYtXo8MZie4njWVFpn+V8aYncd9S034IAG/QQMYfbHQ/gxeV0ejY2LJ85LSjxMRRHI25Fjill63yuKnxJn2vswM6roJvE1hXyl7FIrCnG1OuommOJPVin74Q== 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=oOrmhnhUpY60G6Tf6ivMBJjhpysdr2VCVgU8WKtdn5PCIwCRJcQf20z84DR5FvUlFlrkSs9Bf0OUvJDziS5d2QOvp6mt844TYhNdgX2YdEujyE2z2xUoW8xoVis0QT+PeFYj64MYsa0ENsaCu10iaGIFPtiek3SpKMK167C5UjQ= Received: from AS9PR04CA0127.eurprd04.prod.outlook.com (2603:10a6:20b:531::21) by PAVPR08MB9529.eurprd08.prod.outlook.com (2603:10a6:102:315::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 30 Jun 2023 13:46:33 +0000 Received: from AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:531:cafe::42) by AS9PR04CA0127.outlook.office365.com (2603:10a6:20b:531::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:46:33 +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 AM7EUR03FT014.mail.protection.outlook.com (100.127.140.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:46:33 +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; Fri, 30 Jun 2023 13:46:32 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:46:32 +0000 From: Luis Machado To: Subject: [PATCH v3 04/16] [gdb/aarch64] sve: Fix return command when using V registers in a SVE-enabled target Date: Fri, 30 Jun 2023 14:46:04 +0100 Message-ID: <20230630134616.1238105-5-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134616.1238105-1-luis.machado@arm.com> References: <20230630134616.1238105-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT014:EE_|PAVPR08MB9529:EE_|AM7EUR03FT053:EE_|VI1PR08MB5536:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e4e0302-1fa0-4a72-9ea8-08db79706fcc 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: nTfmeqG/TB8Xu/2bM1oksBz+1BXyeZPWMolNiigvRpu16SYfVszlRp8NpTsif36XrLJbYq7HoZYoDZV6sKcTJFwAipWibeg446SpciZHN2Xsw0M1rG4tp4vRunDsd2GbqK2CxnaFCAsTGpVwEPVc/eJ07rd0egYI6DtOKPgFauHsIDs9OzbExW0f7nRgAJDvE5D0BErKQnjKhtkd4ZNq5RDONPUE70Veg3EbdSRF85PMLNolQkBXXQEq5lOt7NeVMy73LD74wmCDngtvWP9E+phbP+CUZQhNGUoG7TXiaP3B2cLNR9Wk96eStiYfSJtOolDWMUSTh4dC9gGDlmcSEdZBDiXoJyZvxSzwID2NQo1VIoLcFm95CRItZjcE1tmSJqUF0BWslhE8D3LGCr39F/2uAkBIm70/93+UDE+n7PjCrvHbbD7jqGJd7CXulVb1ioB3YDPKWu/qbEtqjTAv1ChbLfEpblZMk/Lmu5YGyAMgNseJreY6NhqBig0PML5g0219hY+IA6CNJbwpulLiJaQ5jq28cYH0kp72TZ+nYlWPXXy3bu0EkBCYty5T8FzvEezdJSO8ATG9fWM8l//SJIeOrSpbLFqqbsCQ12doDQpKuEOgMVrygI0eh/6I8DfV1SVnBTsLuH4qz4HqCUvLm5bIEoOim26BUZEumY//gxMVYL0fRea57Dd8ejehj+ty6rrNUbwDYgSmQYwmMbUpRyBWGhzpU3ylm55xPAJqXSKyHbYxnj7K5WkHih03Y16vLTftEUFvFK8MB+HZp/xJMQ== 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)(396003)(346002)(39860400002)(136003)(451199021)(46966006)(36840700001)(40470700004)(5660300002)(1076003)(44832011)(70586007)(316002)(36756003)(478600001)(6916009)(70206006)(8936002)(8676002)(86362001)(2906002)(26005)(40460700003)(41300700001)(36860700001)(40480700001)(7696005)(6666004)(82310400005)(356005)(186003)(336012)(426003)(47076005)(82740400003)(83380400001)(81166007)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9529 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cdb9487a-288e-4906-03ab-08db79706a75 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OxsivUL5Y2+4Rtk3H4tYMkHp7GUbU0+/kFrQ9L3PuiTun9AQU6S1GXhJwjaIK6+gc+LbJWt4zJTCWHw0fS6bHsS2Dt01EHFS+lzzU44ZStnVn6ue20ebY+H7AlMiXGH5So9cs+ZRw1vc8HJCIaOTbADZgcazRtgmsB1Ni32Rijqcj9V1kfojjnPMId3jlucpzNHDMXo7ZtR8RKI9zSN5zEZXVL8YAQgyCaYAI1CawKeJDevzidvDjTPKwMvD2rctIzKB2/IOp2YKyd5x7Ue/+CfZV9qekmRI26I7uW5rS+3lI05u8UdcU4+SrVgMPGitbyIDLpCAMBlMUWdNW0/ZcaDwERwNrMDxmzjFDuZij47SM6k0c7wbVyLCmhf88jaB5/qFHcUu9ROmvsP02y18ZnEY/iUrTrgv4pIa5KeuRq2/9QQDayXkvLqu89cD+1Cmc9zIFOto1iVRtnD4K3Cltted90uGEh9Aj50bvPLYYY0pHSRilotjplbQZb+lP9JAuiP1fCOYrbJQxGs86E2Rs4Elr2W6tYCYpou8zMelTFsOHv4onS4ePHK5mB+EtAVdLVahfQ5dVEN2tM6xt/hG32X1cagV1lciUzRE6Fkb81xeE8MQGRV8BpkQzlr3lnerTUz5azOI6ZKTrGZNhUEASqMFDJlb40CyJJrY6difrSxb441W5PU9AR41brG4DbxvR/Oe+gsW63vL02qKKXyV/UqHmlh3f1kCZpAxY76KsUVEjkhn3KSG9rVwFeJQrDi5 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)(136003)(346002)(396003)(39860400002)(376002)(451199021)(46966006)(36840700001)(40470700004)(186003)(2906002)(70206006)(5660300002)(26005)(6666004)(7696005)(82740400003)(336012)(36756003)(82310400005)(316002)(6916009)(8676002)(86362001)(478600001)(81166007)(47076005)(2616005)(426003)(1076003)(70586007)(41300700001)(44832011)(8936002)(83380400001)(40460700003)(36860700001)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:46:42.1411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e4e0302-1fa0-4a72-9ea8-08db79706fcc 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: AM7EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5536 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,T_SCC_BODY_TEXT_LINE,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