* [PATCH] riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped
@ 2025-12-30 13:39 Vivian Wang
2025-12-30 17:44 ` Han Gao
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Vivian Wang @ 2025-12-30 13:39 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Alexey Gladkov, Masahiro Yamada,
Nicolas Schier
Cc: Han Gao, linux-riscv, linux-kernel, linux-kbuild, stable,
Vivian Wang
Since commit 4b47a3aefb29 ("kbuild: Restore pattern to avoid stripping
.rela.dyn from vmlinux") vmlinux has .rel*.dyn preserved. Therefore, use
vmlinux to produce Image, not vmlinux.unstripped.
Doing so fixes booting a RELOCATABLE=y Image with kexec. The problem is
caused by this chain of events:
- Since commit 3e86e4d74c04 ("kbuild: keep .modinfo section in
vmlinux.unstripped"), vmlinux.unstripped gets a .modinfo section.
- The .modinfo section has SHF_ALLOC, so it ends up in Image, at the end
of it.
- The Image header's image_size field does not expect to include
.modinfo and does not account for it, since it should not be in Image.
- If .modinfo is large enough, the file size of Image ends up larger
than image_size, which eventually leads to it failing
sanity_check_segment_list().
Using vmlinux instead of vmlinux.unstripped means that the unexpected
.modinfo section is gone from Image, fixing the file size problem.
Cc: stable@vger.kernel.org
Fixes: 3e86e4d74c04 ("kbuild: keep .modinfo section in vmlinux.unstripped")
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
---
arch/riscv/boot/Makefile | 4 ----
1 file changed, 4 deletions(-)
diff --git a/arch/riscv/boot/Makefile b/arch/riscv/boot/Makefile
index bfc3d0b75b9b..5301adf5f3f5 100644
--- a/arch/riscv/boot/Makefile
+++ b/arch/riscv/boot/Makefile
@@ -31,11 +31,7 @@ $(obj)/xipImage: vmlinux FORCE
endif
-ifdef CONFIG_RELOCATABLE
-$(obj)/Image: vmlinux.unstripped FORCE
-else
$(obj)/Image: vmlinux FORCE
-endif
$(call if_changed,objcopy)
$(obj)/Image.gz: $(obj)/Image FORCE
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251230-riscv-vmlinux-not-unstripped-30ec0c930fd2
Best regards,
--
Vivian "dramforever" Wang
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped
2025-12-30 13:39 [PATCH] riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped Vivian Wang
@ 2025-12-30 17:44 ` Han Gao
2025-12-30 20:03 ` Nathan Chancellor
2025-12-31 0:30 ` Paul Walmsley
2 siblings, 0 replies; 4+ messages in thread
From: Han Gao @ 2025-12-30 17:44 UTC (permalink / raw)
To: Vivian Wang
Cc: Han Gao, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nathan Chancellor, Alexey Gladkov,
Masahiro Yamada, Nicolas Schier, linux-riscv, linux-kernel,
linux-kbuild, stable
> On Dec 30, 2025, at 21:39, Vivian Wang <wangruikang@iscas.ac.cn> wrote:
>
> Since commit 4b47a3aefb29 ("kbuild: Restore pattern to avoid stripping
> .rela.dyn from vmlinux") vmlinux has .rel*.dyn preserved. Therefore, use
> vmlinux to produce Image, not vmlinux.unstripped.
>
> Doing so fixes booting a RELOCATABLE=y Image with kexec. The problem is
> caused by this chain of events:
>
> - Since commit 3e86e4d74c04 ("kbuild: keep .modinfo section in
> vmlinux.unstripped"), vmlinux.unstripped gets a .modinfo section.
> - The .modinfo section has SHF_ALLOC, so it ends up in Image, at the end
> of it.
> - The Image header's image_size field does not expect to include
> .modinfo and does not account for it, since it should not be in Image.
> - If .modinfo is large enough, the file size of Image ends up larger
> than image_size, which eventually leads to it failing
> sanity_check_segment_list().
>
> Using vmlinux instead of vmlinux.unstripped means that the unexpected
> .modinfo section is gone from Image, fixing the file size problem.
>
> Cc: stable@vger.kernel.org
> Fixes: 3e86e4d74c04 ("kbuild: keep .modinfo section in vmlinux.unstripped")
> Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
> ---
> arch/riscv/boot/Makefile | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/arch/riscv/boot/Makefile b/arch/riscv/boot/Makefile
> index bfc3d0b75b9b..5301adf5f3f5 100644
> --- a/arch/riscv/boot/Makefile
> +++ b/arch/riscv/boot/Makefile
> @@ -31,11 +31,7 @@ $(obj)/xipImage: vmlinux FORCE
>
> endif
>
> -ifdef CONFIG_RELOCATABLE
> -$(obj)/Image: vmlinux.unstripped FORCE
> -else
> $(obj)/Image: vmlinux FORCE
> -endif
> $(call if_changed,objcopy)
>
> $(obj)/Image.gz: $(obj)/Image FORCE
>
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20251230-riscv-vmlinux-not-unstripped-30ec0c930fd2
>
> Best regards,
> --
> Vivian "dramforever" Wang
Tested-by: Han Gao <gaohan@iscas.ac.cn>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped
2025-12-30 13:39 [PATCH] riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped Vivian Wang
2025-12-30 17:44 ` Han Gao
@ 2025-12-30 20:03 ` Nathan Chancellor
2025-12-31 0:30 ` Paul Walmsley
2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2025-12-30 20:03 UTC (permalink / raw)
To: Vivian Wang
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Alexey Gladkov, Masahiro Yamada, Nicolas Schier, Han Gao,
linux-riscv, linux-kernel, linux-kbuild, stable
On Tue, Dec 30, 2025 at 09:39:17PM +0800, Vivian Wang wrote:
> Since commit 4b47a3aefb29 ("kbuild: Restore pattern to avoid stripping
> .rela.dyn from vmlinux") vmlinux has .rel*.dyn preserved. Therefore, use
> vmlinux to produce Image, not vmlinux.unstripped.
>
> Doing so fixes booting a RELOCATABLE=y Image with kexec. The problem is
> caused by this chain of events:
>
> - Since commit 3e86e4d74c04 ("kbuild: keep .modinfo section in
> vmlinux.unstripped"), vmlinux.unstripped gets a .modinfo section.
> - The .modinfo section has SHF_ALLOC, so it ends up in Image, at the end
> of it.
> - The Image header's image_size field does not expect to include
> .modinfo and does not account for it, since it should not be in Image.
> - If .modinfo is large enough, the file size of Image ends up larger
> than image_size, which eventually leads to it failing
> sanity_check_segment_list().
>
> Using vmlinux instead of vmlinux.unstripped means that the unexpected
> .modinfo section is gone from Image, fixing the file size problem.
>
> Cc: stable@vger.kernel.org
> Fixes: 3e86e4d74c04 ("kbuild: keep .modinfo section in vmlinux.unstripped")
> Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Yes, this seems reasonable. I suspect this could have been done after
commit e9d86b8e17e7 ("scripts: Do not strip .rela.dyn section") in 6.15
since it has the same effect that 4b47a3aefb29 does but there was no
visible problem.
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
> arch/riscv/boot/Makefile | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/arch/riscv/boot/Makefile b/arch/riscv/boot/Makefile
> index bfc3d0b75b9b..5301adf5f3f5 100644
> --- a/arch/riscv/boot/Makefile
> +++ b/arch/riscv/boot/Makefile
> @@ -31,11 +31,7 @@ $(obj)/xipImage: vmlinux FORCE
>
> endif
>
> -ifdef CONFIG_RELOCATABLE
> -$(obj)/Image: vmlinux.unstripped FORCE
> -else
> $(obj)/Image: vmlinux FORCE
> -endif
> $(call if_changed,objcopy)
>
> $(obj)/Image.gz: $(obj)/Image FORCE
>
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20251230-riscv-vmlinux-not-unstripped-30ec0c930fd2
>
> Best regards,
> --
> Vivian "dramforever" Wang
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped
2025-12-30 13:39 [PATCH] riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped Vivian Wang
2025-12-30 17:44 ` Han Gao
2025-12-30 20:03 ` Nathan Chancellor
@ 2025-12-31 0:30 ` Paul Walmsley
2 siblings, 0 replies; 4+ messages in thread
From: Paul Walmsley @ 2025-12-31 0:30 UTC (permalink / raw)
To: Vivian Wang
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Nathan Chancellor, Alexey Gladkov, Masahiro Yamada,
Nicolas Schier, Han Gao, linux-riscv, linux-kernel, linux-kbuild,
stable
On Tue, 30 Dec 2025, Vivian Wang wrote:
> Since commit 4b47a3aefb29 ("kbuild: Restore pattern to avoid stripping
> .rela.dyn from vmlinux") vmlinux has .rel*.dyn preserved. Therefore, use
> vmlinux to produce Image, not vmlinux.unstripped.
>
> Doing so fixes booting a RELOCATABLE=y Image with kexec.
Thanks, queued for v6.19-rc.
- Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-31 0:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-30 13:39 [PATCH] riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped Vivian Wang
2025-12-30 17:44 ` Han Gao
2025-12-30 20:03 ` Nathan Chancellor
2025-12-31 0:30 ` Paul Walmsley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox