From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id ED88B3858D3C for ; Sun, 27 Aug 2023 01:32:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED88B3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6bca66e6c44so1742646a34.0 for ; Sat, 26 Aug 2023 18:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693099955; x=1693704755; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=lIJKAYdysdxFkkOxaCOZ0ZaWqQpP2rIMrgPHAnbu4j8=; b=FwKwIESQnHTtCAQmaG55VWOHZkI80nyaR55USRH2Wr+w2qrNYZLhL8KpHoUG83PYxE GWXJUrfMXu0eJQEtNuOcOADYdXrJNFeVeuksF7Mx4i5gWore96JS8QFfXgg60kI1zoDy 5jABEDeBcY/HkdWodYNpjpv7bqyDlkZ7aWnyUjQEo2PWdQDIvAJ5AjFUZLs38BMPIR/K /8xzjPZr3lGbTREPJSYicBNwhYPR8B9wZegAYmLO6vTXy6rvae94vRSiadrzbiXHkCuC gfLJBX6O/PW86CRd058XSlwwJHYE8aojkkw63/szydYiGpLFehfY3+ed8SCtBJGEupPL K/Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693099955; x=1693704755; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lIJKAYdysdxFkkOxaCOZ0ZaWqQpP2rIMrgPHAnbu4j8=; b=kUBOterJSmyWGovK24cO9o4474wSn4/zNneN3QpEiYvIwxo8uSFNH5gI/nmpt34b4v fy30uRn8wNrgPapFVBznd1wUBa8VImlS6oiBbtuXsEPTyJmN+onPn6VD32MIIV6DUxe3 QWPPzxJe5ADVsDssAFzieRaEqMpU9r+C9Nt0xRGzSpo2TVxzA0Rp1P4P64rNKSqTSO2A ZN2Ci33uPi2tufOsOku7BxYZzc3dG1mr64DEGzJSbCJzKVg3m1EJWv8zCnSKfeQ9gZOe lhgZHfn3gSrBBFiAR/dqKRyS1Z9fuygoilQfbKCD9E7ILPiaDybqvW7up6CBv+sZT8gm Yv7g== X-Gm-Message-State: AOJu0YxBE6AlsuqUrRtu+zyuK3ASyJrc/EbRnGS+YRHvHz84mJLFUVvx 3580hOU8ZYezWH7pWT+SWoFJGQLxOkQbwSroI6s= X-Google-Smtp-Source: AGHT+IEawRygSkKDHrwDmoTUljoOiOWvZcvhMWWcapNBY2yd144eKW8xo/B5Uj+JqMAGy2LydsyEHA== X-Received: by 2002:a9d:7d98:0:b0:6b9:1af3:3307 with SMTP id j24-20020a9d7d98000000b006b91af33307mr10153838otn.17.1693099955256; Sat, 26 Aug 2023 18:32:35 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:32e5:4bbf:ada3:7bf7]) by smtp.gmail.com with ESMTPSA id i6-20020a056830010600b006b4281cf424sm2205265otp.4.2023.08.26.18.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Aug 2023 18:32:34 -0700 (PDT) References: <20230822112130.1513216-1-luis.machado@arm.com> <20230822112130.1513216-8-luis.machado@arm.com> User-agent: mu4e 1.10.5; emacs 28.2 From: Thiago Jung Bauermann To: Luis Machado Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v4 07/16] [gdbserver/aarch64] sme: Add support for SME In-reply-to: <20230822112130.1513216-8-luis.machado@arm.com> Date: Sat, 26 Aug 2023 22:32:32 -0300 Message-ID: <87y1hxjmmn.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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: 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. > + > + /* 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 ()); > +} -- Thiago