From nobody Thu Apr 30 17:53:39 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g61xb2cgCz6bwcG for ; Thu, 30 Apr 2026 17:53:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g61xb1trdz3pLd for ; Thu, 30 Apr 2026 17:53:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777571619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8fvoY4luL7j2rw2crPORMvHN3IRMG0RHDVLx5VJpZ3A=; b=dxzoIKiMU00XlH8WgNFOzHNlHkp0yKjLCNH9oGePj090IzH726UkA3ys0cpn5CTEHV8KgD ZgIaZa7BBZJfc4yuF620o4EB/6nOn5DdbqvUs/H9/JHKzncEcgmuIB5GVmfa0tgJgcEjyn j4YrFM9naxDw1n6C/JmQi4+6QNJ6AY/qV5CmSzjdA/gRnH04C2UAau7KPUMDPv//r/Qxo4 WMssx0HgrlRPLK2nHv/7f0DF5VkTUq+MwF64T40/8Cc3xeQos62ANlFzLVbtj7jGzmRkp6 wRMysUh1wVW54ddSZrHfb8TkWvEmoJqGITsuaFZ6xL0zVcWBwOZ902Nq0yTQdQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777571619; a=rsa-sha256; cv=none; b=aiw2R4VT1IHzOrgKH75k2sPxXP+eiiTCJzKx9zBOYZguiGfHsM4qjDSY7N53vNocN9MdxJ o2BhoiH8Ay/M8lm33Y4Axt9atJnqtOA5/ah836C+tcExE3pLRm8XpaIVRFvrKidTfcwwI2 CsagKpMq7vxhHGU/8/TYd8cxXkWtcOgylWe82NPItUtF2LD6Xll8nt2LxTKzbEk7g0PLA5 eZPNv9QurENbbfp0NWh3xgHn5gWSpK2Lcpg9WQEGcSVnvBzHvgK1sgyyJ/2YjYdDT8oxnv 5bDITk57OsJFkyJR75FQIqPES3VymswEk/kZhcwE4iQ0RR3z0IN+Do7pCdxaDA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777571619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8fvoY4luL7j2rw2crPORMvHN3IRMG0RHDVLx5VJpZ3A=; b=ItOM3/5IkvTZHGDd2Dh9Q+wVqAOqN6oBCeRbnCn8Behv9txeMFV+iAT0wEYvWGSkbSkrLR cWlXImhE3V4YzmyjG/SvTlIUCVPqLr04rLQq88YOG184+y9HA84uKIFz3hp/4Elmy/hngw Hub3mPHjNHzCFOliYZyhJPlXgAtJz5r5XgFPy9uoLi1OeGq+yPuzdRfc+tjbhzxdj1+0qS xqOwO6oTkdcvGFtssgtKimShTQDO6Wo+xiWCUZ2XrmDBPFij+EFB7qF5NYfhHnhLfd153A 0bzCXz2fkPagX+3mLD6xjrYvb3otxAo/CPNOFpo9NvKUhK7jv1RCjrISlBxRVQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g61xb1MHGz6s3 for ; Thu, 30 Apr 2026 17:53:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3321e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 30 Apr 2026 17:53:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: b7dae28f364c - stable/13 - loader.efi: Defer efi_translate(e_entry) until after bi_load List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b7dae28f364c05627132abf61a91cf82123b4672 Auto-Submitted: auto-generated Date: Thu, 30 Apr 2026 17:53:39 +0000 Message-Id: <69f39723.3321e.bac8dac@gitrepo.freebsd.org> The branch stable/13 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=b7dae28f364c05627132abf61a91cf82123b4672 commit b7dae28f364c05627132abf61a91cf82123b4672 Author: Jessica Clarke AuthorDate: 2026-04-17 14:20:12 +0000 Commit: Jessica Clarke CommitDate: 2026-04-30 17:53:04 +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 99ee498b1b65..1b4e0f596478 100644 --- a/stand/efi/loader/arch/arm/exec.c +++ b/stand/efi/loader/arch/arm/exec.c @@ -72,9 +72,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); if ((error = bi_load(fp->f_args, &modulep, &kernend, true)) != 0) { @@ -87,6 +84,8 @@ __elfN(arm_exec)(struct preloaded_file *fp) dev_cleanup(); + 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 43c935f4e0a9..8c466e29b04c 100644 --- a/stand/efi/loader/arch/arm64/exec.c +++ b/stand/efi/loader/arch/arm64/exec.c @@ -125,7 +125,6 @@ elf64_exec(struct preloaded_file *fp) return(EFTYPE); ehdr = (Elf_Ehdr *)&(md->md_data); - entry = efi_translate(ehdr->e_entry); efi_time_fini(); err = bi_load(fp->f_args, &modulep, &kernendp, true); @@ -136,6 +135,8 @@ elf64_exec(struct preloaded_file *fp) dev_cleanup(); + 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 686a42028608..4d7a183aa0fc 100644 --- a/stand/efi/loader/arch/riscv/exec.c +++ b/stand/efi/loader/arch/riscv/exec.c @@ -59,9 +59,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); if ((error = bi_load(fp->f_args, &modulep, &kernend, true)) != 0) { @@ -75,6 +72,8 @@ __elfN(exec)(struct preloaded_file *fp) */ dev_cleanup(); + entry = efi_translate(e->e_entry); + (*entry)((void *)modulep); panic("exec returned"); }