From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2064.outbound.protection.outlook.com [40.107.21.64]) by sourceware.org (Postfix) with ESMTPS id 633663858C2B for ; Wed, 30 Aug 2023 10:37:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 633663858C2B 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=E5SUfTei6yf1TwDwOM1QEbnsCQpNqTwoMXf3WZYBq7Q=; b=cP7pzpS9yyC68pHTlFjHBiPR1EvvACMgvlycAlQEziFk3BPH9vFgJfR8K7y0iHe2dXoC66Bxkz0kVyxJYFNZdDejRlw+yayXXtxqMRxwwUTWhfcaFT10rVWdmPuAjOrzNGK2cX4v0UrvFMzEYynGDRFqsZu9ThsjiopE5nQWL1U= Received: from DB8PR09CA0036.eurprd09.prod.outlook.com (2603:10a6:10:a0::49) by DB9PR08MB7843.eurprd08.prod.outlook.com (2603:10a6:10:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Wed, 30 Aug 2023 10:37:23 +0000 Received: from DBAEUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:a0:cafe::50) by DB8PR09CA0036.outlook.office365.com (2603:10a6:10:a0::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20 via Frontend Transport; Wed, 30 Aug 2023 10:37: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 DBAEUR03FT062.mail.protection.outlook.com (100.127.142.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20 via Frontend Transport; Wed, 30 Aug 2023 10:37:23 +0000 Received: ("Tessian outbound 169aaa6bf2b7:v175"); Wed, 30 Aug 2023 10:37:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 23353c5f4ea7457c X-CR-MTA-TID: 64aa7808 Received: from 60c3da2b539a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FC743805-EFE5-49B5-8D30-4B5063FEA488.1; Wed, 30 Aug 2023 10:37:16 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 60c3da2b539a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 30 Aug 2023 10:37:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k+DZ8A/U/NWDgw8PkVu/Cu627wKunjvyME33L6cNLezndqXIe1MyNcmemZS0ten63iEU3SW1KRGqRYjBCg7EebuhhmraCzsfEnCneW718jev9PEfzLwMmDcXD4uX37VpGWaOdq1CYNbOXbbbt1SFSPBwvQJeKKAHvqf/f1rHJpkRuKFadoYWcd8UsMGY3uyGggM2jB85dAO/IUZHIkRCbECaoWBdEsNlkNXBGsVac5SkG1hjVcpY7xuUSsIadKdMqzx3a4K6C1uIkgV+lI59uuYEW4L2UqbSTrw9EhHdWLrrIcZfyReS9t6IDp1ch++jhA0Ll0v4a9JI4ugynJvptA== 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=E5SUfTei6yf1TwDwOM1QEbnsCQpNqTwoMXf3WZYBq7Q=; b=cWx/7mK7utPx4jkBFgWB5HhglyIg5mS9vpugcYhT6hngPRxqXLRC5RhnocHiqU6Px4HUA5HZIZ5esNE3tWhAHpcNBwi2Wg/SrH33Qf1E3O8DNUOvkoJTtnLU40eWtiYYNDCjQyhwvSjCIrjG5lQVR4XsDkns0w3Kh7Kg1ETlYNcG3BQFWzVfYML3pvh/sncUmpn53TkgyMRgbAq3Hb9y2d4jJ/dI4AieCNElJjKY5zxXp8WYuWY5CisXGCwhwLUSGO8KqT/GGMiS5K4ID2ckAzuPPHBmm5cGbvHtdxh3KEgJUf0738GIChzIiOP5Xvk5BmAKa5iF4bgKRij7guAEzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; 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=E5SUfTei6yf1TwDwOM1QEbnsCQpNqTwoMXf3WZYBq7Q=; b=cP7pzpS9yyC68pHTlFjHBiPR1EvvACMgvlycAlQEziFk3BPH9vFgJfR8K7y0iHe2dXoC66Bxkz0kVyxJYFNZdDejRlw+yayXXtxqMRxwwUTWhfcaFT10rVWdmPuAjOrzNGK2cX4v0UrvFMzEYynGDRFqsZu9ThsjiopE5nQWL1U= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AS2PR08MB8877.eurprd08.prod.outlook.com (2603:10a6:20b:5e6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Wed, 30 Aug 2023 10:37:15 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7743:60fe:4859:2df2]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7743:60fe:4859:2df2%6]) with mapi id 15.20.6699.034; Wed, 30 Aug 2023 10:37:15 +0000 Message-ID: Date: Wed, 30 Aug 2023 11:37:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v4 07/16] [gdbserver/aarch64] sme: Add support for SME Content-Language: en-US To: Thiago Jung Bauermann Cc: gdb-patches@sourceware.org References: <20230822112130.1513216-1-luis.machado@arm.com> <20230822112130.1513216-8-luis.machado@arm.com> <87y1hxjmmn.fsf@linaro.org> From: Luis Machado In-Reply-To: <87y1hxjmmn.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO3P265CA0013.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:bb::18) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS2PR08MB8877:EE_|DBAEUR03FT062:EE_|DB9PR08MB7843:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a7ae4ac-acbb-43b2-056d-08dba9451882 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: +GD+voDJFTOxzdLgXhzDgLJEhL+WnodWYrrvfJWbu/okWi7XBcswRvAdGdotBIma7tlu41dxxY9l9FjA53syr50eiyJH0bCS0MLnXhVqiBxg39RvDEO3weFy5zHi5iRyAwKa/17qgdekbkowu7knlRFx2WZL0rp1Y1bAPZtj/izBdi+nsa9svtiiwsJoiXWQtixPWvX9oxC9lwO7vAsKU9BoETeHrgvvB2rXIJkfEAaTLFtTTz/9DX/c5IkHivxHbbwIQqeXULNDP7Dps4x+Bb8RcTW5sClGYovEw3aS8/U5RJQHIQ51SH8aleaJ1cW01BNFjz/PUEfvnYcW4vtcmN+uw40/GWUsNu1H8H2tpxzpytm5BsC/SAWU/CeZwphdlP00FVwv4WcyIApW1HSF4iSEYqyIKC2NITlLAOjbJz3ZCV/9BWfHiwiSKrGog5YNAI3YambW8eRoaWTPNGp47sg3ct0dTj5/rKRPGlj3Xu3zcDJjZH026p6ZXMfdqIvn3B5Nw9OkeluOU7nrx+CdKICAEWFvLv1YeKS1HpAH5iE/lJaWuzUCD/Y0+j+DBinukXyfHTcNZf3tPP3GTXiQFm//OyHr5oL9x1tCsmFcyG/hKb3ss8UbYB062nj22Qk5Bc6n0lMDTDCSg89Cafk/AA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(396003)(136003)(346002)(366004)(186009)(451199024)(1800799009)(31686004)(2906002)(66946007)(4326008)(66556008)(36756003)(66476007)(44832011)(6916009)(316002)(41300700001)(8676002)(5660300002)(8936002)(6506007)(38100700002)(31696002)(53546011)(6666004)(6512007)(6486002)(2616005)(86362001)(26005)(478600001)(83380400001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8877 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 89d7c3a9-8eb8-4833-0711-08dba94513b2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MKjxQ9H1Nb+/Ow1WQwujGBmfAGK6lJZK6RRMVMcncg46bYrlrtiU/14iRMG76ABPmBjGHb2qqlT4qVAMXt3Yy+fOdIWzjis1tKG5d87b4jNNUFpXKHVEmzT0TgHSdoU1kzbcWXUar44i5L5d7tOigmq0UyAwaMwUhK+BNBjUcADzSXYojkO1zvQEhvHcF3H3nJA+XREystWCf6Dgx6RoA0DbVdkaSP0wtXj10RNn0SYRw/hv3fQptmwuXCY56xIv0CLppqNiHde8tft+EprTZSPW6Qf92xsanIHJW3Sz92Zlhw5rF3eWzRA8MDf2ccsbbnBblzjEOlvCuDBF4HxBtX+OyFjfziHjqqbLNGvLuGBHREvp8JiFvDzv8xqAAXVDr5Wwy8DtQOcz+Gwp6YARsVsdyI2wocp+JgPGI8fHJ7L8cZV6yTIP85vvhPJfAx7rh9SzL3X9SX0YAMZ8paKzcsNEOR1KFf3wa9a6xeiyXxNfnExMmgLBiMHcxDi8/Fss7U0zxRQAqLmBdLqOKOxOkON4gZ7ryU9hYSgB0rTSs/NvXRvlnEC+ToFylALtLU2QXV7eiNIbTI3fqSpaurt+gmDW5ZzoyvEaRvOcU5YI9LnIu2vwTcL1i1jg+h5lx9UXgzQeAtrSiKA5BRSq4UOT+QChP3+m98X1ArUJb599p3LsI5hiDswFUkiZcZTca4EIYaZ+LMnqZzmLHS6ki6zTUR7ImFUArBZa0ShGsduIpdmY8WjYznoL2yyFOV1zcpPB6oU1J+Ga14qxyXTjc3gdGA== 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)(39860400002)(376002)(396003)(136003)(186009)(1800799009)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(36756003)(2906002)(70206006)(70586007)(316002)(40480700001)(41300700001)(40460700003)(53546011)(6512007)(36860700001)(44832011)(6506007)(6486002)(5660300002)(6666004)(26005)(336012)(31686004)(47076005)(83380400001)(2616005)(31696002)(86362001)(82740400003)(356005)(8936002)(81166007)(8676002)(478600001)(6862004)(4326008)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2023 10:37:23.2068 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a7ae4ac-acbb-43b2-056d-08dba9451882 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: DBAEUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7843 X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,NICE_REPLY_A,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: On 8/27/23 02:32, Thiago Jung Bauermann wrote: > > Hello Luis, > > After reviewing the SME2 patches, I spotted this suggestion that > I didn't notice when I reviewed v3. Sorry about that again. > > Luis Machado writes: > >> +/* Wrapper for aarch64_za_regs_copy_to_reg_buf, to help copying NT_ARM_ZA >> + state from the thread (BUF) to the register cache. */ >> + >> +static void >> +aarch64_za_regs_copy_to_regcache (struct regcache *regcache, >> + ATTRIBUTE_UNUSED const void *buf) >> +{ >> + /* BUF is unused here since we collect the data straight from a ptrace >> + request, therefore bypassing gdbserver's own call to ptrace. */ >> + int tid = lwpid_of (current_thread); >> + >> + gdb::optional za_regnum >> + = find_regno_no_throw (regcache->tdesc, "za"); >> + gdb::optional svg_regnum >> + = find_regno_no_throw (regcache->tdesc, "svg"); >> + gdb::optional svcr_regnum >> + = find_regno_no_throw (regcache->tdesc, "svcr"); >> + >> + gdb_assert (za_regnum.has_value ()); >> + gdb_assert (svg_regnum.has_value ()); >> + gdb_assert (svcr_regnum.has_value ()); > > By changing to find_regno() then this gdb_assert() becomes unnecessary. > Well spotted. I've changed both of these now to call find_regno. >> + >> + /* Update the register cache. aarch64_za_regs_copy_to_reg_buf handles >> + fetching the NT_ARM_ZA state from thread TID. */ >> + aarch64_za_regs_copy_to_reg_buf (tid, regcache, *za_regnum, *svg_regnum, >> + *svcr_regnum); >> +} >> + >> +/* Wrapper for aarch64_za_regs_copy_from_reg_buf, to help copying NT_ARM_ZA >> + state from the register cache to the thread (BUF). */ >> + >> +static void >> +aarch64_za_regs_copy_from_regcache (struct regcache *regcache, void *buf) >> +{ >> + int tid = lwpid_of (current_thread); >> + >> + gdb::optional za_regnum >> + = find_regno_no_throw (regcache->tdesc, "za"); >> + gdb::optional svg_regnum >> + = find_regno_no_throw (regcache->tdesc, "svg"); >> + gdb::optional svcr_regnum >> + = find_regno_no_throw (regcache->tdesc, "svcr"); >> + >> + gdb_assert (za_regnum.has_value ()); >> + gdb_assert (svg_regnum.has_value ()); >> + gdb_assert (svcr_regnum.has_value ()); > > Same comment about find_regno(). > >> + >> + /* Update the thread NT_ARM_ZA state. aarch64_za_regs_copy_from_reg_buf >> + handles writing the ZA state back to thread TID. */ >> + aarch64_za_regs_copy_from_reg_buf (tid, regcache, *za_regnum, *svg_regnum, >> + *svcr_regnum); >> + >> + /* We need to return the expected data in BUF, so copy whatever the kernel >> + already has to BUF. */ >> + >> + /* Obtain a dump of ZA from ptrace. */ >> + gdb::byte_vector za_state = aarch64_fetch_za_regset (tid); >> + memcpy (buf, za_state.data (), za_state.size ()); >> +} > Thanks for the reviews!