Re: git: ba94d7574972 - main - stand/common/load_elf: Do kernel module relocations for PPC
Date: Tue, 28 Apr 2026 21:45:39 UTC
hi,
This somehow breaks booting in pseries VMs in virtualised ppc64 on
qemu, both ppc64be and ppc64le.
The loader gets through a bunch of kernel loading and then hangs
before it jumps into the kernel.
-adrian
On Sat, 18 Apr 2026 at 05:08, Lexi Winter <ivy@freebsd.org> wrote:
>
> The branch main has been updated by ivy:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=ba94d75749721fae999f756cb227638f9d4398a8
>
> commit ba94d75749721fae999f756cb227638f9d4398a8
> Author: Lexi Winter <ivy@FreeBSD.org>
> AuthorDate: 2026-04-18 12:07:10 +0000
> Commit: Lexi Winter <ivy@FreeBSD.org>
> CommitDate: 2026-04-18 12:07:10 +0000
>
> stand/common/load_elf: Do kernel module relocations for PPC
>
> reloc_ptr() skips relocations for the kernel module, because on most
> platforms the kernel is ET_EXEC and this is not required. On PPC,
> the kernel is ET_DYN and we need to relocate here, otherwise the
> module metadata will not be loaded properly and the kernel module
> will have an incorrect version, preventing module dependencies from
> resolving.
>
> This fixes loading kernel modules from loader.conf on powerpc.
>
> Diagnosed by: jrtc27
> Reviewed by: jrtc27, adrian
> Sponsored by: https://www.patreon.com/bsdivy
> Differential Revision: https://reviews.freebsd.org/D56457
> ---
> stand/common/load_elf.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c
> index 10131f7ccb88..a6ea60c74b84 100644
> --- a/stand/common/load_elf.c
> +++ b/stand/common/load_elf.c
> @@ -1282,10 +1282,11 @@ __elfN(reloc_ptr)(struct preloaded_file *mp, elf_file_t ef,
> int error;
>
> /*
> - * The kernel is already relocated, but we still want to apply
> - * offset adjustments.
> + * On most platforms, the kernel is already relocated, but we still
> + * want to apply offset adjustments. For PowerPC, the kernel is
> + * ET_DYN rather than ET_EXEC and we still need to relocate here.
> */
> - if (ef->kernel)
> + if (ef->kernel && ef->ehdr->e_type != ET_DYN)
> return (EOPNOTSUPP);
>
> for (n = 0; n < ef->relsz / sizeof(r); n++) {
>