[PATCH -fixes] riscv: Fix relocatable kernels with early alternatives using -fno-pie
Alexandre Ghiti
alex at ghiti.fr
Mon May 29 11:51:57 PDT 2023
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 <alexghiti at rivosinc.com>
> | 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 <alexghiti at rivosinc.com>
> | Signed-off-by: Conor Dooley <conor.dooley at microchip.com>
> |
> | 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 at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
More information about the linux-riscv
mailing list