From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +NfNITkd1WTQLj0AWB0awg (envelope-from ) for ; Thu, 10 Aug 2023 13:24:09 -0400 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=hPsCkcNd; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 810FE1E0BB; Thu, 10 Aug 2023 13:24:09 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7356C1E028 for ; Thu, 10 Aug 2023 13:24:07 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0001B3858020 for ; Thu, 10 Aug 2023 17:24:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0001B3858020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691688247; bh=sFpZL/3eilu1u9uFTaffok5Lp1a2n41gMaTDjQGUS0Y=; h=References:In-Reply-To:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=hPsCkcNd1ayRLzmyPGR716x55K36hlcqoOrwsjrvgP2Sawu/CA1VNw5krqIML2Gf0 rCjGChlK5Ta3K3dmIiLvX/J2+8PufGhSNTR7tl7w9e4NZh2ox10ktJrG6H3Rei7pgO Dc4mm5ccwo5L4j3OKRGdLyla5jxwKCiThTp0gBFM= Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 164503858CDB for ; Thu, 10 Aug 2023 17:23:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 164503858CDB Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4fe58faa5cfso1780885e87.3 for ; Thu, 10 Aug 2023 10:23:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691688226; x=1692293026; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sFpZL/3eilu1u9uFTaffok5Lp1a2n41gMaTDjQGUS0Y=; b=iUwsAKsKAwTU/Yi2hdmKjq4HkhydgN0y2R/4tXJ5D+zKzTozJkka6ScC5pe1YFkqjA n2yIXo0wG2stbWrJepuYQBOBDB5c4MGL0id++D0iWXOz9Fy/KooAaWkOnzzCzytG9KZH gMh9SHFtllBy2FPTjMvJliIiSEQtKYOeVoqnwP4ZxFJpKPDtiisnVxBVN97eqJ0bwRiH m3GRvqtkOlDusZGE43CFAQDozGGByqes1rC5Rw7ZGUE6KjFgRmMbtdgSQ/z1lPz4VxCq 3HqwKloSfHGoS2Mi65uRGSYGDGmV6SBKGXM5ZiCHw7ftQrT14Elnzyg04Il9ZsYjqx4I d8OQ== X-Gm-Message-State: AOJu0YwE6v3x8WHqpMcu34+z0DPe2jbcAXau8QfYPBviyoKlQlt9oRtC 1ZYCOsA1yPSz/MZ59bP4pa/fxL8vL5mhadL/rRJTkw== X-Google-Smtp-Source: AGHT+IEXWGUPPaLyDt3apt2NNXmeQIsimShn+Pmdh9/q+nOb39YlJ5R8dIS0nQ7448blRDwcpVp74rQ0kawtt5VS4jw= X-Received: by 2002:ac2:4a62:0:b0:4fe:c98:789a with SMTP id q2-20020ac24a62000000b004fe0c98789amr2249633lfp.37.1691688226402; Thu, 10 Aug 2023 10:23:46 -0700 (PDT) MIME-Version: 1.0 References: <20230803230110.904724-1-greg.savin@sifive.com> <20230810103510.GA2509@hsinchu26> In-Reply-To: Date: Fri, 11 Aug 2023 01:23:34 +0800 Message-ID: Subject: Re: [PATCH] RISC-V: support for vector register accesses via ptrace() in RISC-V Linux native To: "Maciej W. Rozycki" Cc: Greg Savin , Greentime Hu , Oleg Nesterov , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, gdb-patches@sourceware.org, Andrew Burgess Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 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 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: Andy Chiu via Gdb-patches Reply-To: Andy Chiu Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On Thu, Aug 10, 2023 at 9:55=E2=80=AFPM Maciej W. Rozycki wrote: > > On Thu, 10 Aug 2023, Maciej W. Rozycki wrote: > > > > Does it make sense to you if we encapsulate this with a hwprobe sysca= ll? > > > e.g provide a hwprobe entry to get system's VLENB. We will have to > > > increase and rearrange the buffer for NT_RISCV_VECTOR if we want to u= se > > > ptrace as the entry point for this purpose. I am not very sure if it'= d be > > > too late to do though. > > > > No, how do you expect it to work with a core dump (that can be examine= d > > on a different system, or with a cross-debugger)? You need to change t= he > > API I'm afraid; it's unusable anyway. It's a pity the toolchain commun= ity > > wasn't consulted if you weren't sure how to design the interface. Bett= er > > yet it would have been to implement the GDB side before the kernel part > > has been committed. I just took some look into the code and here is what I came up with. Actually, you know VLENB in a core dump file. The size of NT_RISCV_VECTOR in a core dump file just equals sizeof(struct __riscv_v_ext_state), which is 40B, plus VLENB * 32. So, the debugger can actually calculate VLENB and resolve placement of V registers by subtracting 40 from the size of NT_RISCV_VECTOR in a core dump file. On the other hand, ptrace is not so lucky. The kernel will return the min of either user specified size or the maximum Vector size. It is still safe if we consider SMP with the same VLENB across cores though, which is an assumption made on Linux. We just need a way to get VLENB on the system. > > NB since this stuff went in with v6.5-rc1 and v6.5 hasn't been released > you can still back out the problematic change as no one is expected to us= e > RC stuff in production. Alternatively you can redefine NT_RISCV_VECTOR > for a corrected ABI, but I think it shouldn't be necessary. You just nee= d > to act quickly as I guess there may be 1-2 further v6.5 RCs only and you > have to get with that to Linus right away. We can have a release or two > without NT_RISCV_VECTOR support for the otherwise included vector stuff, > it shouldn't be a big deal. There just won't be support for the debug > API. > > CC-ing Linux ptrace/RISC-V maintainers now to bring their attention. > > Maciej Thanks, Andy