Date: Thu, 30 Apr 2026 17:43:06 +0000 From: Jessica Clarke <jrtc27@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: bf7eaff8df4f - stable/15 - loader.efi: Defer efi_translate(e_entry) until after bi_load Message-ID: <69f394aa.303d7.b9d1de8@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=bf7eaff8df4fafcdc3e45127a7c690f170f1edb7 commit bf7eaff8df4fafcdc3e45127a7c690f170f1edb7 Author: Jessica Clarke <jrtc27@FreeBSD.org> AuthorDate: 2026-04-17 14:20:12 +0000 Commit: Jessica Clarke <jrtc27@FreeBSD.org> CommitDate: 2026-04-30 17:42:29 +0000 loader.efi: Defer efi_translate(e_entry) until after bi_load bi_load itself loads various things into the staging area which can cause it to grow, which may result in the staging area moving, including the kernel. Therefore the address we get for the kernel entry point prior to bi_load may not be correct afterwards when we actually call it, and so we must defer the translation. On arm and riscv (but not arm64, which predates both of them in loader.efi and did not gain a copy of arm's added printf when arm support was added) we also printf this entry point to the console, which we can no longer do since bi_load calls ExitBootServices, so remove this printf that, in practice, seems to not be so useful, given nobody ever felt the need to add it to arm64. If anyone really feels this is an important printf to have then bi_load will need to be split so we can call printf after all the loading and potential reallocation of the staging area, but before ExitBootServices is called. We may also want to make this code more uniform and shared between the three architectures here, since there isn't much architecture-specific about this (and something like the RISC-V boot hart protocol could easily be made an MD hook). Reviewed by: imp Fixes: 0cafabf97fae ("Add support for arm64 to loader.efi and boot1.efi") Fixes: ea7796a9ae6b ("EFI: don't call printf after ExitBootServices, since it uses Boot Services") Fixes: 2192efc03bc4 ("RISC-V boot1.efi and loader.efi support") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56431 (cherry picked from commit ab1d659e78e454995b7c2b4566e035269b215e48) --- stand/efi/loader/arch/arm/exec.c | 5 ++--- stand/efi/loader/arch/arm64/exec.c | 3 ++- stand/efi/loader/arch/riscv/exec.c | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/stand/efi/loader/arch/arm/exec.c b/stand/efi/loader/arch/arm/exec.c index 3963b6c0104b..71516569763d 100644 --- a/stand/efi/loader/arch/arm/exec.c +++ b/stand/efi/loader/arch/arm/exec.c @@ -69,9 +69,6 @@ __elfN(arm_exec)(struct preloaded_file *fp) efi_time_fini(); - entry = efi_translate(e->e_entry); - - printf("Kernel entry at %p...\n", entry); printf("Kernel args: %s\n", fp->f_args); /* @@ -85,6 +82,8 @@ __elfN(arm_exec)(struct preloaded_file *fp) return (error); } + entry = efi_translate(e->e_entry); + (*entry)((void *)modulep); panic("exec returned"); } diff --git a/stand/efi/loader/arch/arm64/exec.c b/stand/efi/loader/arch/arm64/exec.c index 89e2ad7521a8..d0a5e26c8b3b 100644 --- a/stand/efi/loader/arch/arm64/exec.c +++ b/stand/efi/loader/arch/arm64/exec.c @@ -67,7 +67,6 @@ elf64_exec(struct preloaded_file *fp) return(EFTYPE); ehdr = (Elf_Ehdr *)&(md->md_data); - entry = efi_translate(ehdr->e_entry); /* * we have to cleanup here because net_cleanup() doesn't work after @@ -82,6 +81,8 @@ elf64_exec(struct preloaded_file *fp) return (err); } + entry = efi_translate(ehdr->e_entry); + /* Clean D-cache under kernel area and invalidate whole I-cache */ clean_addr = (vm_offset_t)efi_translate(fp->f_addr); clean_size = (vm_offset_t)efi_translate(kernendp) - clean_addr; diff --git a/stand/efi/loader/arch/riscv/exec.c b/stand/efi/loader/arch/riscv/exec.c index a53fbd9442b0..5689d41c54aa 100644 --- a/stand/efi/loader/arch/riscv/exec.c +++ b/stand/efi/loader/arch/riscv/exec.c @@ -81,9 +81,6 @@ __elfN(exec)(struct preloaded_file *fp) efi_time_fini(); - entry = efi_translate(e->e_entry); - - printf("Kernel entry at %p...\n", entry); printf("Kernel args: %s\n", fp->f_args); /* @@ -97,6 +94,8 @@ __elfN(exec)(struct preloaded_file *fp) return (error); } + entry = efi_translate(e->e_entry); + (*entry)((void *)modulep); panic("exec returned"); }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69f394aa.303d7.b9d1de8>
