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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1702C77B7E for ; Mon, 29 May 2023 18:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjE2SwL (ORCPT ); Mon, 29 May 2023 14:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjE2SwK (ORCPT ); Mon, 29 May 2023 14:52:10 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DFD6C4 for ; Mon, 29 May 2023 11:52:07 -0700 (PDT) X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr X-GND-Sasl: alex@ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id CFB821BF203; Mon, 29 May 2023 18:52:00 +0000 (UTC) Message-ID: Date: Mon, 29 May 2023 20:51:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH -fixes] riscv: Fix relocatable kernels with early alternatives using -fno-pie Content-Language: en-US To: Conor Dooley Cc: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andreas Schwab , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <20230526154630.289374-1-alexghiti@rivosinc.com> <20230526-clergyman-wriggly-accc659a3fad@spud> <20230526-rockfish-moody-f6d3e71f9d24@spud> <20230527-hyperlink-doctrine-ef22cfcb508a@spud> <20230528-darkness-grandly-6cb9e014391d@spud> <20230528-uneatable-earpiece-3f8673548863@spud> From: Alexandre Ghiti In-Reply-To: <20230528-uneatable-earpiece-3f8673548863@spud> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/05/2023 15:56, Conor Dooley wrote: > On Sun, May 28, 2023 at 03:42:59PM +0200, Alexandre Ghiti wrote: >> Hmmm, it still works for me with both clang and gcc-9. > gcc-9 is a bit of a relic, do you have more recent compilers lying > around? If not, I can try some older compilers at some point. > >> You don't have to do that now but is there a way I could get your compiled >> image? With the sha1 used to build it? Sorry, I don't see what happens, I >> need to get my hands dirty in some debug! > What do you mean by "sha1"? It falls with v6.4-rc1 which is a stable > hash, if that's what you're looking for. > > Otherwise, > https://github.com/ConchuOD/riscv-env/releases/download/v2022.03/vmlinux.bin > (ignore the release crap haha, too lazy to find a proper hosting > mechanism) Ok, I don't get much info without the symbols, can you also provide the vmlinux please? But at least your image does not boot, not during the early boot though because the mmu is enabled. I tried with gcc-12 and it still works fine on my end, so frustrating! > | git show > | commit 3bd124485ed55d8ee6c1ff3532c8f617b24aa6ef (HEAD) > | Author: Alexandre Ghiti > | Date: Fri May 26 17:46:30 2023 +0200 > | > | riscv: Fix relocatable kernels with early alternatives using -fno-pie > | > | Early alternatives are called with the mmu disabled, and then should not > | access any global symbols through the GOT since it requires relocations, > | relocations that we do before but *virtually*. So only use medany code > | model for this early code. > | > | Signed-off-by: Alexandre Ghiti > | Signed-off-by: Conor Dooley > | > | diff --git a/arch/riscv/errata/Makefile b/arch/riscv/errata/Makefile > | index a1055965fbee..7b2637c8c332 100644 > | --- a/arch/riscv/errata/Makefile > | +++ b/arch/riscv/errata/Makefile > | @@ -1,2 +1,6 @@ > | +ifdef CONFIG_RELOCATABLE > | +KBUILD_CFLAGS += -fno-pie > | +endif > | + > | obj-$(CONFIG_ERRATA_SIFIVE) += sifive/ > | obj-$(CONFIG_ERRATA_THEAD) += thead/ > | diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile > | index fbdccc21418a..153864e4f399 100644 > | --- a/arch/riscv/kernel/Makefile > | +++ b/arch/riscv/kernel/Makefile > | @@ -23,6 +23,10 @@ ifdef CONFIG_FTRACE > | CFLAGS_REMOVE_alternative.o = $(CC_FLAGS_FTRACE) > | CFLAGS_REMOVE_cpufeature.o = $(CC_FLAGS_FTRACE) > | endif > | +ifdef CONFIG_RELOCATABLE > | +CFLAGS_alternative.o += -fno-pie > | +CFLAGS_cpufeature.o += -fno-pie > | +endif > | ifdef CONFIG_KASAN > | KASAN_SANITIZE_alternative.o := n > | KASAN_SANITIZE_cpufeature.o := n > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv