From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id DB2443858D32; Thu, 10 Aug 2023 20:00:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB2443858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4RMHpd1B6tz4RQK; Thu, 10 Aug 2023 20:00:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RMHpd021Hz4bJJ; Thu, 10 Aug 2023 20:00:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691697625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=svbyTQksyKeyE58jVfnZbf9OIqOi32PrIqFUSd60GQw=; b=sNGi6xdStMO+KrkCA1NEaf9HfFLaA6/zrXJCBmXZTpo8t1X8dL3fiPckF9uW8+LAL3LhJK oJ9j7OfLXISNmSf0peT3xGGIgogSOz94o+UaiywYDyWUWdIpQio0P1bvZ0P8GqtfeFji/6 +yiZewoGO04Qm+dhHjNIfJDpQLstTfiTNoZVJsw6wLTS15/dhGYmdSTgu3bWN6qoJym1Ja a21EhSNTzeKwhkfMLXgd1269HHTnluMMz0bNPGXM1gWPuGW+DojNdm6QejFJLcnI2FfgKs w6T5cMDN/vGTqXeMx3Ex7L9paxu7hGftyglipREFTUGID71F73MuA+Xbc67+wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691697625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=svbyTQksyKeyE58jVfnZbf9OIqOi32PrIqFUSd60GQw=; b=SrPPIZy1eZEJQXRl+d6NtQ+ZtcM9uPfr0vIOT8rGV0l8R9nWCYFXUKihyFmlCLrICzqFwz 9n48kPWsIbAPPUCMCCXPoEdLWNa1y+vGngQonjYWq7dxBb5iJMRSXfLyrs/Z0Sk34rdfMG kDYV5U2EDt9Ls1RV1vZpabAJTqc48Fo3uF+CDdVFUUxRQjp5//W5j1fRKZhkLAKTvZAp+m xfAls6O8JTWoZq8OC/AphiPut6hnzJKO0QYjDoPullE3FLCTJUnqJwj8QqRE0JMKFXBWxz yp69ph3X7lAWSOT1DgSEZvkrM9aQpkV54RZWIpLlx/2KlCcun5ubqk6ycdf0iQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691697625; a=rsa-sha256; cv=none; b=j5V18BQP/iLhn/WoFNZpTyTqaIjIuwp4wWwRjb2cAtrexn1fM0IH74yUFJMbIaqgMZP6OZ Uwo9BcyrSjvQmCiupf9YT/qCekDmBhYqPO9x49cBLSEHOPk+wcLZvTwJIx/kS44AjTtFtW XroKzQK5/8b/rnsNLQrAK6A9iSTlLf01usadjMBXbm4dKLmeUKdOYC8Px6FGaxX9vlwmYn di9ph77KnRro7egzO7wPuEG21lajmST3/RwVZB4BmI0JMzxkVg7ifdCgmDIn+O1uJbMz9y V3oghLcleR5KmrN85qbrDd4AHQE67D2q79iVfZ9WkflrXySaLfbHbbugrdKuAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from [IPV6:2601:648:8683:a9e0:150d:72a2:f4e9:31b5] (unknown [IPv6:2601:648:8683:a9e0:150d:72a2:f4e9:31b5]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RMHpc1z57z9s0; Thu, 10 Aug 2023 20:00:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Thu, 10 Aug 2023 13:00:22 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] Re-map value of NT_RISCV_CSR to not collide with the value of NT_RISCV_VECTOR in Linux kernel header file 'include/uapi/linux/elf.h' Content-Language: en-US To: Greg Savin Cc: gdb-patches@sourceware.org, binutils@sourceware.org, palmer@dabbelt.com, greentime.hu@sifive.com, Andrew Burgess References: <20230809175337.1108580-1-greg.savin@sifive.com> <40cf6dfd-7948-095f-249a-9bac83ff923c@FreeBSD.org> From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,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: On 8/10/23 11:56 AM, Greg Savin wrote: > Initially I tried reusing 0x900 for NT_RISCV_VECTOR, and leaving > NT_RISCV_CSR in place with its original 0x900 value, and this was resulting > in compile errors of "duplicate case values within a switch statement." So > I figured having duplicate NT_* values was a "no no" at least in the > standards of the GDB project. I'm guessing that particular compile error > can be treated as a warning, but that GDB intentionally chooses compile > flags to treat the duplicate case values as a hard error (?) Probably in this case the switch statement needs to take the note name into context. For example, libbfd's note parsing code calls different helper routines for "FreeBSD" vs "NetBSD" vs "LINUX" core notes where each of these helpers has its own switch statement on NT_* values. The switch statement checking NT_RISCV_CSR is probably not done in a context specific to "GDB". > --Greg > > On Thu, Aug 10, 2023 at 11:39 AM John Baldwin wrote: > >> On 8/9/23 10:53 AM, Greg Savin via Gdb-patches wrote: >>> Linux kernel's file 'include/uapi/linux/elf.h' declares the value 0x900 >>> for NT_RISCV_VECTOR, and does not have a definition for NT_RISCV_CSR, nor >>> does it use the value 0x901 for any note type. This patch is intended >>> as a way to resolve the disagreement/collision between Linux and >> binutils, >>> over the meaning of 0x900 in the context of note types. >>> >>> --- >>> include/elf/common.h | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/include/elf/common.h b/include/elf/common.h >>> index ffa6b60bd2b..0bbe245519e 100644 >>> --- a/include/elf/common.h >>> +++ b/include/elf/common.h >>> @@ -713,7 +713,7 @@ >>> /* note name must be "LINUX". */ >>> #define NT_LARCH_LBT 0xa04 /* LoongArch Binary >> Translation registers */ >>> /* note name must be "CORE". */ >>> -#define NT_RISCV_CSR 0x900 /* RISC-V Control and >> Status Registers */ >>> +#define NT_RISCV_CSR 0x901 /* RISC-V Control and >> Status Registers */ >>> /* note name must be "LINUX". */ >>> #define NT_SIGINFO 0x53494749 /* Fields of siginfo_t. */ >>> #define NT_FILE 0x46494c45 /* Description of mapped >> files. */ >> >> If there aren't any active uses of NT_RISCV_CSR "in the wild", then it >> might be >> better to just remove it entirely? >> >> It looks like commit e214f8db56f65531b0a5ec296c42339dcaa5af31 adding >> LoongArch >> constants inadvertently changed the comment for this note from "CORE" (a >> binutils note) to "LINUX" (a Linux kernel note). >> >> The log message adding NT_RISCV_CSR is clearer (though the comment in >> common.h >> is wrong and should be "GDB" it seems): >> >> commit db6092f3aec43ea4d10efc5ff74274f04cdc0ad6 >> Author: Andrew Burgess >> Date: Fri Nov 27 14:04:16 2020 +0000 >> >> bfd/binutils: add support for RISC-V CSRs in core files >> >> Adds support for including RISC-V control and status registers into >> core files. >> >> The value for the define NT_RISCV_CSR is set to 0x900, this >> corresponds to a patch I have proposed for the Linux kernel here: >> >> >> http://lists.infradead.org/pipermail/linux-riscv/2020-December/003910.html >> >> As I have not yet heard if the above patch will be accepted into the >> kernel or not I have set the note name string to "GDB", and the note >> type to NT_RISCV_CSR. >> >> This means that if the above patch is rejected from the kernel, and >> the note type number 0x900 is assigned to some other note type, we >> will still be able to distinguish between the GDB produced >> NT_RISCV_CSR, and the kernel produced notes, where the name would be >> set to "CORE". >> >> Seems like the kernel patch died on the vine (no responses to the patch). >> GDB does support writing this out still though via the ".reg.riscv-csr" >> pseudo section, so changing this would break debugging bare metal core >> dumps. You can however, just re-use 0x900 for NT_RISCV_VECTOR without >> this patch. The different note name is sufficient to differentiate the >> two. >> >> -- >> John Baldwin >> >> > -- John Baldwin