From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 028CE525F for ; Fri, 24 Mar 2023 10:40:13 +0000 (UTC) Received: from relay11.mail.gandi.net (unknown [217.70.178.231]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 2588BD420A for ; Fri, 24 Mar 2023 10:34:43 +0000 (UTC) Received: (Authenticated sender: alex@ghiti.fr) by mail.gandi.net (Postfix) with ESMTPSA id 55EDD100004; Fri, 24 Mar 2023 10:34:27 +0000 (UTC) Message-ID: <877d03e1-b00b-7863-6104-21b42bc63711@ghiti.fr> Date: Fri, 24 Mar 2023 11:34:26 +0100 Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v8 1/3] riscv: Introduce CONFIG_RELOCATABLE Content-Language: en-US To: Nick Desaulniers , =?UTF-8?B?QmrDtnJuIFTDtnBl?= =?UTF-8?Q?l?= Cc: Alexandre Ghiti , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, nathan@kernel.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev References: <20230215143626.453491-1-alexghiti@rivosinc.com> <20230215143626.453491-2-alexghiti@rivosinc.com> <4a6fc7a3-9697-a49b-0941-97f32194b0d7@ghiti.fr> <877cw7dphf.fsf@all.your.base.are.belong.to.us> From: Alexandre Ghiti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Nick, On 3/22/23 19:25, Nick Desaulniers wrote: > On Fri, Feb 24, 2023 at 7:58 AM Björn Töpel wrote: >> Alexandre Ghiti writes: >> >>> +cc linux-kbuild, llvm, Nathan, Nick >>> >>> On 2/15/23 15:36, Alexandre Ghiti wrote: >>>> From: Alexandre Ghiti >>>> >>> I tried a lot of things, but I struggle to understand, does anyone have >>> any idea? FYI, the same problem happens with LLVM. > Off the top of my head, no idea. > > (Maybe as a follow up to this series, I wonder if pursuing > ARCH_HAS_RELR for ARCH=riscv is worthwhile?) IIUC, the goal for using RELR is to reduce the size of a kernel image: right now, this is not my priority, but I'll add that to my todo list because that may be useful to distros. > >> Don't ask me *why*, but adding --emit-relocs to your linker flags solves >> "the NULL .rela.dyn" both for GCC and LLVM. >> >> The downside is that you end up with a bunch of .rela cruft in your >> vmlinux. > There was a patch just this week to use $(OBJCOPY) to strip these from > vmlinux (for x86). Looks like x86 uses --emit-relocs for KASLR: > https://lore.kernel.org/lkml/20230320121006.4863-1-petr.pavlu@suse.com/ That's nice, that would be an interesting intermediate step until we find the issue here as I believe it is important to have the relocations in the init section to save memory. Thanks for your answer Nick, really appreciated, Alex From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5291C6FD1C for ; Fri, 24 Mar 2023 10:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hmHlhTA4lYzFummlZ0B9NIkFQOCr105ZExxsd5CgvkQ=; b=2SedK6SIDAJj2v 9p8df8ov/rR1oDUaJv45N4HI5O+bmaQNQtHmPOhfCojpQgAcLAUeLZBKVruJ9aqrCMVwI7zE3ix/D ThCoVLTK2z3mXA7wqEjirZBFqmlQ3zIMz4wVjv1pgmELZJS5Hr0cM3RAaEEc9Fla5MmHzSLGLwKME YpkT/iq4UrYC2O4j3X1NctcU2dKP8/dPd7xndFM3yGCVxt1GTqH27YLQhXuVwasOkvG04ym7lMV33 Xz4hj2QwfW65Emm2olQ6HMVEikHfSnm9abgwb/LXTkFfYo+bL7/qIWEqa6GkDDH/b1Fb3+eWCotHt egBhkABvziojiPBzfBCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pfekt-004AzS-1H; Fri, 24 Mar 2023 10:34:43 +0000 Received: from relay11.mail.gandi.net ([217.70.178.231]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pfekq-004AyY-1p for linux-riscv@lists.infradead.org; Fri, 24 Mar 2023 10:34:42 +0000 Received: (Authenticated sender: alex@ghiti.fr) by mail.gandi.net (Postfix) with ESMTPSA id 55EDD100004; Fri, 24 Mar 2023 10:34:27 +0000 (UTC) Message-ID: <877d03e1-b00b-7863-6104-21b42bc63711@ghiti.fr> Date: Fri, 24 Mar 2023 11:34:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v8 1/3] riscv: Introduce CONFIG_RELOCATABLE Content-Language: en-US To: Nick Desaulniers , =?UTF-8?B?QmrDtnJuIFTDtnBl?= =?UTF-8?Q?l?= Cc: Alexandre Ghiti , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, nathan@kernel.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev References: <20230215143626.453491-1-alexghiti@rivosinc.com> <20230215143626.453491-2-alexghiti@rivosinc.com> <4a6fc7a3-9697-a49b-0941-97f32194b0d7@ghiti.fr> <877cw7dphf.fsf@all.your.base.are.belong.to.us> From: Alexandre Ghiti In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230324_033441_174542_A4651319 X-CRM114-Status: GOOD ( 15.44 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org SGkgTmljaywKCk9uIDMvMjIvMjMgMTk6MjUsIE5pY2sgRGVzYXVsbmllcnMgd3JvdGU6Cj4gT24g RnJpLCBGZWIgMjQsIDIwMjMgYXQgNzo1OOKAr0FNIEJqw7ZybiBUw7ZwZWwgPGJqb3JuQGtlcm5l bC5vcmc+IHdyb3RlOgo+PiBBbGV4YW5kcmUgR2hpdGkgPGFsZXhAZ2hpdGkuZnI+IHdyaXRlczoK Pj4KPj4+ICtjYyBsaW51eC1rYnVpbGQsIGxsdm0sIE5hdGhhbiwgTmljawo+Pj4KPj4+IE9uIDIv MTUvMjMgMTU6MzYsIEFsZXhhbmRyZSBHaGl0aSB3cm90ZToKPj4+PiBGcm9tOiBBbGV4YW5kcmUg R2hpdGkgPGFsZXhAZ2hpdGkuZnI+Cj4+Pj4KPj4+IEkgdHJpZWQgYSBsb3Qgb2YgdGhpbmdzLCBi dXQgSSBzdHJ1Z2dsZSB0byB1bmRlcnN0YW5kLCBk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MjAxMjEwMDYuNDg2My0xLXBldHIucGF2bHVAc3VzZS5jb20v CgoKVGhhdCdzIG5pY2UsIHRoYXQgd291bGQgYmUgYW4gaW50ZXJlc3RpbmcgaW50ZXJtZWRpYXRl IHN0ZXAgdW50aWwgd2UgCmZpbmQgdGhlIGlzc3VlIGhlcmUgYXMgSSBiZWxpZXZlIGl0IGlzIGlt cG9ydGFudCB0byBoYXZlIHRoZSByZWxvY2F0aW9ucyAKaW4gdGhlIGluaXQgc2VjdGlvbiB0byBz YXZlIG1lbW9yeS4KClRoYW5rcyBmb3IgeW91ciBhbnN3ZXIgTmljaywgcmVhbGx5IGFwcHJlY2lh dGVkLAoKQWxleAoKCgpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fXwpsaW51eC1yaXNjdiBtYWlsaW5nIGxpc3QKbGludXgtcmlzY3ZAbGlzdHMuaW5mcmFkZWFk Lm9yZwpodHRwOi8vbGlzdHMuaW5mcmFkZWFkLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2xpbnV4LXJp c2N2Cg== From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3174C6FD20 for ; Fri, 24 Mar 2023 10:35:24 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Pjdrp6ttlz3fW3 for ; Fri, 24 Mar 2023 21:35:22 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=ghiti.fr (client-ip=2001:4b98:dc4:8::231; helo=relay11.mail.gandi.net; envelope-from=alex@ghiti.fr; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PjdrC6XzCz3cFW for ; Fri, 24 Mar 2023 21:34:51 +1100 (AEDT) Received: (Authenticated sender: alex@ghiti.fr) by mail.gandi.net (Postfix) with ESMTPSA id 55EDD100004; Fri, 24 Mar 2023 10:34:27 +0000 (UTC) Message-ID: <877d03e1-b00b-7863-6104-21b42bc63711@ghiti.fr> Date: Fri, 24 Mar 2023 11:34:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v8 1/3] riscv: Introduce CONFIG_RELOCATABLE Content-Language: en-US To: Nick Desaulniers , =?UTF-8?B?QmrDtnJuIFTDtnBl?= =?UTF-8?Q?l?= References: <20230215143626.453491-1-alexghiti@rivosinc.com> <20230215143626.453491-2-alexghiti@rivosinc.com> <4a6fc7a3-9697-a49b-0941-97f32194b0d7@ghiti.fr> <877cw7dphf.fsf@all.your.base.are.belong.to.us> From: Alexandre Ghiti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Alexandre Ghiti , linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, nathan@kernel.org, Palmer Dabbelt , Nicholas Piggin , Paul Walmsley , linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hi Nick, On 3/22/23 19:25, Nick Desaulniers wrote: > On Fri, Feb 24, 2023 at 7:58 AM Björn Töpel wrote: >> Alexandre Ghiti writes: >> >>> +cc linux-kbuild, llvm, Nathan, Nick >>> >>> On 2/15/23 15:36, Alexandre Ghiti wrote: >>>> From: Alexandre Ghiti >>>> >>> I tried a lot of things, but I struggle to understand, does anyone have >>> any idea? FYI, the same problem happens with LLVM. > Off the top of my head, no idea. > > (Maybe as a follow up to this series, I wonder if pursuing > ARCH_HAS_RELR for ARCH=riscv is worthwhile?) IIUC, the goal for using RELR is to reduce the size of a kernel image: right now, this is not my priority, but I'll add that to my todo list because that may be useful to distros. > >> Don't ask me *why*, but adding --emit-relocs to your linker flags solves >> "the NULL .rela.dyn" both for GCC and LLVM. >> >> The downside is that you end up with a bunch of .rela cruft in your >> vmlinux. > There was a patch just this week to use $(OBJCOPY) to strip these from > vmlinux (for x86). Looks like x86 uses --emit-relocs for KASLR: > https://lore.kernel.org/lkml/20230320121006.4863-1-petr.pavlu@suse.com/ That's nice, that would be an interesting intermediate step until we find the issue here as I believe it is important to have the relocations in the init section to save memory. Thanks for your answer Nick, really appreciated, Alex