From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 5D1923858C78; Thu, 10 Aug 2023 18:39:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D1923858C78 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 4RMG1J115Gz4GK8; Thu, 10 Aug 2023 18:39:32 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 4RMG1J06szz4WNK; Thu, 10 Aug 2023 18:39:32 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691692772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YY6f4c94msEvkFWkdfzt+HK2+CT4l9vQy4B+YVs5SRI=; b=uSrOGPqncrzV5z7joAoyRF/aDQRuPYB/q2ZkJP1kfKm7SNADVQUEmxVq3I6aIWR9QkQKnR ymUMo7QQAUi8bFP1Ed7jy2MTTsRj2ffKS//u8+5pZGiU2F/iFmJdFA6fgc2cSQSc5n+mEL mNeBpm88I/jYZJMdPgQkfg1ctSf8Y+QuX1I1CvymqNnJEG/GqcMeARQg0Fb5/EYhKQst+1 OhnEfhMGmHKrkKp+cGVQurBkp2vqsajzpdwBeiCXsLcOwAEG883P8sTrnhrj3qY4LXP5CJ BD4j12iKDyWC0MZ9lQezOxjS5kdDLpMnzI1GV69iW9Hqk4aWj9Ni/5FKjqY+Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691692772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YY6f4c94msEvkFWkdfzt+HK2+CT4l9vQy4B+YVs5SRI=; b=t/XCuth3qwVr3RfYz2ndewi4jxWSY0WAQoGm/eIZuG8X+gjm/8zQtEJUpJYnfJr7t8VGRv /UeonMldr4ZcNaRw5n1m0gKxDNuiLcRLkjXH7GmFAj5Vk/jwC6fa5ysJ+vlcXgib0EGAs4 YqEGmBbCucX1ps6L2nxWfgbaTzVTbYpYNvdurGOFZpwdCDWzR6CmY6TeEn01ckHZALikEj 2BUpenq+iC+g+pgKiyAP43caVM2KseKmMK0UHowbmLeBWt1Br9Xd2n97Przn8pS2zxogm7 oHEpYmF3Zj4sRRYA0OzJyRJiEu0HgQcgaaCfgsjqJwmlgdZ6uP/LQ5mK5QwqPQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691692772; a=rsa-sha256; cv=none; b=MCK+XQgq9HrYEQmOt9z1FYL55ze/v8v9DPoseX05GzC75XbMJilA3Bs291dSmmmxP9wlck wJ8zOE79Sumv2W2K6M0yuy8hySz+6vHnWqjFknbJFs/Kf7AZ5L7r6Vqae80PlNCdRQxgfi 3doQCtrRPhJhEGt9/Of5mLfrg0Vv/Vv4sUg76iVrrlnn+655X8MK8CD4pCoUtkhoaRwi4G bM3r6QNmpIImw8iEN6gYLXNPKOk4NFXBEp2Fi6oEaxO4mYjSRQoArHOejwMezglHnQusKj yy9giMigHJUttEWRQ9sTHFuqeyVJjBaj8IQMryEUYDzKO9bnzYO4DsNklmSMyw== 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 4RMG1H1rbNz8mL; Thu, 10 Aug 2023 18:39:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <40cf6dfd-7948-095f-249a-9bac83ff923c@FreeBSD.org> Date: Thu, 10 Aug 2023 11:39:25 -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 Content-Language: en-US To: Greg Savin , gdb-patches@sourceware.org, binutils@sourceware.org, palmer@dabbelt.com, greentime.hu@sifive.com, Andrew Burgess References: <20230809175337.1108580-1-greg.savin@sifive.com> From: John Baldwin 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' In-Reply-To: <20230809175337.1108580-1-greg.savin@sifive.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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/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