From nobody Fri Sep 11 05:04:22 2026 X-Original-To: dev-commits-src-main@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 4hh2X72nDQz6rbGx for ; Fri, 11 Sep 2026 05:04:23 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hh2X63jlYz4Bnl for ; Fri, 11 Sep 2026 05:04:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789103062; 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=IjPivv0j7Cv88NTfKfQclvSPKpADkHW9p7EJP4bCy34=; b=t5co/7mVinm+/bEHUfACwG9uDWOobZQvhATka/b8+Ln7a0mWjkX/pYf/q7sTViidsfowHk gZklsD0vueHFNy9OUcjnMguvFLRuBtgJxlDN7e1qe4ZLzwAvYSpEoGfGHi5vc5Qfgvi2Pg ImdOKTjOPDR/OpTxsahlwdYgjPiEbPqe7ReLIHKra3qJmDVgCRzfGh93OvFXRiJHimtEV9 bE9iuFQ/QWZouA2Thh3EltI2xnh+jdNzYCC2Mdynw2IFfrosCGyb/GkpT04+1CVFnmWrZT PlSiBosj4lTQsQFQ1RM2NjSiN//hX31QqjCWDN6JyLiGk6dFG4uDwjP3a09CWA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789103062; b=Q762bnSOSFFWYUo/l3oIAMkOCkG5WDRN2DD10zileDmyFxF8UmNPVEm4U1Qe09nrAEmBX5 T60pe2/+ePfCaoo7VgLjJD3hB+ZBmRWvUcXooR3G/DLGG3mzXNaLvN/jww7DroR0SmqU5w dpAKqaIpED6+Jl8DSQPf5LDldIa6TYHEBm/jXwMsPvtUMuySbHYWjmiMzag5c7I7/Sula5 MQz7oMWP2PGwrXboxheG2gyV1gdJwGWohVeYGXnwAwKaeisMhnu6ggGWlXzcA6pcfpFBbs ZDufNwdipTIPyVd5KL3ChnjA2afTeta4vKZWmLOF1tdy8fPQtBzTyhkrxr0M9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789103062; 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=IjPivv0j7Cv88NTfKfQclvSPKpADkHW9p7EJP4bCy34=; b=rTlLxkdR2xE7Na7FG+jgE+uuEq6q8yQ5RmEfzBwOVV6ePE4lqP5zYRfDqdd9r4kmJB6/cT qHIcyrHl4o2Z3ndKuHfdzpKyotv+NTrfKh4HOPx+N1aZSjI9XzaXGWqMjp48sY3NU8jRwc lK3W958wJgkv5IF9+rkOKqHmMMSt0fyc3K3zY1s7iIGV+Den/LFfyYtVwe9a9WQLQbVkm9 mhteqt56t+Dquq3JSv8IgMt+eaLTqUS4Z4EcCimoUbDFUuzrC5yJUPgABpHoCOTSD/+y5I b1F4+DN9paVUgzCdSkgIvsH/gDbCtQiseQ31P18F76dfy1/lYFhtPQaalw6wcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hh2X62kkxz10WG for ; Fri, 11 Sep 2026 05:04:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3be12 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 11 Sep 2026 05:04:22 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: f1163b9436b7 - main - loader.efi: For ipxe booting, fall back to md when ramdisk fails List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f1163b9436b750f6d141e3db72e9000f9cf8b5e4 Auto-Submitted: auto-generated Date: Fri, 11 Sep 2026 05:04:22 +0000 Message-Id: <6aa38bd6.3be12.52384188@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=f1163b9436b750f6d141e3db72e9000f9cf8b5e4 commit f1163b9436b750f6d141e3db72e9000f9cf8b5e4 Author: Warner Losh AuthorDate: 2026-09-11 04:13:29 +0000 Commit: Warner Losh CommitDate: 2026-09-11 04:15:28 +0000 loader.efi: For ipxe booting, fall back to md when ramdisk fails Some UEFI firmwares do not contain the RamDisk protocol. When this happens, load the file into a md disk instead. This is less desireable than the RamDisk (since that allows better chain-booting options), but sufficient to boot an image as a md device for FreeBSD. While most severs have the RamDisk protocol enabled in their builds, I have two IoT class boards from different manufacturers that do not. Since it works just fine with this fallback, that's preferable. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D59421 --- stand/efi/loader/memdisk.c | 48 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/stand/efi/loader/memdisk.c b/stand/efi/loader/memdisk.c index aa843916c799..a425d628a85f 100644 --- a/stand/efi/loader/memdisk.c +++ b/stand/efi/loader/memdisk.c @@ -9,6 +9,7 @@ */ #include "loader_efi.h" +#include #include #include #include "decompress.h" @@ -110,6 +111,20 @@ download_finish(IN VOID *Context, IN EFI_STATUS Status) decomp_fini(ctx->dctx, EFI_ERROR(Status)); } +static void +fallback_to_md(EFI_PHYSICAL_ADDRESS pa, size_t len) +{ + int unit; + + unit = md_register((void *)(uintptr_t)pa, len, MD_FLAG_KERNEL); + if (unit < 0) { + printf("Could not register downloaded image as an md: %s\n", + strerror(errno)); + return; + } + setenv("uefi_ignore_boot_mgr", "true", 1); +} + static void do_download_ramdisk(CHAR8 *url, bool is_disk) { @@ -120,12 +135,10 @@ do_download_ramdisk(CHAR8 *url, bool is_disk) dl_state *ctx = &dl; Status = BS->LocateProtocol(&ipxeGuid, NULL, (void**)&ipxe_download); - if (EFI_ERROR(Status)) + if (EFI_ERROR(Status)) { + printf("No ipxe download\n"); return; /* most uses won't have this, don't whine */ - Status = BS->LocateProtocol(&ramdiskGuid, NULL, (void**)&ram_disk); - if (EFI_ERROR(Status)) - return; /* XXX whine about it? */ - + } printf("Downloading %s as a %s\n", url, is_disk ? "disk" : "cd"); ctx->in_progress = true; Status = ipxe_download->Start(ipxe_download, url, download_data, download_finish, @@ -152,6 +165,23 @@ do_download_ramdisk(CHAR8 *url, bool is_disk) printf("\nDownloaded %llu bytes, actual size %llu -- registering ramdisk\n", ULL(ctx->size), ULL(decomp_buffer_length(ctx->dctx))); + /* ram_disk will be NULL if this fails */ + BS->LocateProtocol(&ramdiskGuid, NULL, (void**)&ram_disk); + + /* + * If there's no ram_disk protocol installed in this firmware, do the + * next best thing by saving a pointer and using that later. + */ + if (ram_disk == NULL) { + printf("No RamDisk protocol, falling back to md image\n"); + error = fallback_to_md(decomp_buffer(ctx->dctx), decomp_buffer_length(ctx->dctx)); + if (error) { + printf("Failed to register as an MD device\n"); + download_cleanup(ctx); + } + return; + } + /* * Register the RamDisk with UEFI. This registers it so the rest of the * boot loader can see it as a block device. @@ -159,8 +189,12 @@ do_download_ramdisk(CHAR8 *url, bool is_disk) Status = ram_disk->Register(decomp_buffer(ctx->dctx), decomp_buffer_length(ctx->dctx), &disk_type, NULL, &ram_disk_path); if (EFI_ERROR(Status)) { - printf("failed to register ram disk %u\n", (unsigned)Status); - download_cleanup(ctx); + printf("failed to register ram disk %u, falling back to md image\n", (unsigned)Status); + error = fallback_to_md(decomp_buffer(ctx->dctx), decomp_buffer_length(ctx->dctx)); + if (error) { + printf("Failed to register as an MD device\n"); + download_cleanup(ctx); + } return; }