From nobody Mon Feb 9 20:12:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+55394+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55394+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1583315580; cv=none; d=zohomail.com; s=zohoarc; b=QyVJ842MHI4+ivtPDJI36/ybrDL4+tjIHZkIIO61z8FdxloAnm65dMi2aAaFAK/ITTbMfSFAYo6h1BtGtblfoOFeXN1484DQ0TAV52HXDEqBWp44qphtKgg9zETcXQrV72dAVRj+odurgQjfkBAA47WB4va1of1FkINvS+pW91c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583315580; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=CPh1RFy89gVunvEoyQhmlfK4JHsiKBX7Q4Sl/jY5QCE=; b=kH7vOjhhLI29svSW9EVfvwpRWHhvEqTe6orGAszZFsdHIBXeK4g9amt5T1dorfgvbBQS2kHxjR7hPy7lda/7ljtUX1JPiolWdPSrAgl3p45imWjwzIvocWEGdXFAMDkIcvaVQaQDGT59LPIWRwggp34YQSh5FRsMj1/U3XYPKpk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55394+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1583315580897259.7653287165308; Wed, 4 Mar 2020 01:53:00 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0XDCYY1788612xfUhxmXQw3Y; Wed, 04 Mar 2020 01:53:00 -0800 X-Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web09.9063.1583315579305877939 for ; Wed, 04 Mar 2020 01:52:59 -0800 X-Received: by mail-wm1-f66.google.com with SMTP id m3so1168501wmi.0 for ; Wed, 04 Mar 2020 01:52:59 -0800 (PST) X-Gm-Message-State: RS0C866chbVnBEQuR4bdZV0Sx1787277AA= X-Google-Smtp-Source: ADFU+vtxKpTA58QLgyx0HlBUSdj0Hrv8csrZ5b05WlY/4XS7iYGfFXlcTRHww2zWEnGDMZtYvGPA9g== X-Received: by 2002:a7b:c1cf:: with SMTP id a15mr2981555wmj.152.1583315577429; Wed, 04 Mar 2020 01:52:57 -0800 (PST) X-Received: from e123331-lin.home ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id v16sm20781095wrp.84.2020.03.04.01.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 01:52:56 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH v2 13/14] OvmfPkg/QemuKernelLoaderFsDxe: add support for new Linux initrd device path Date: Wed, 4 Mar 2020 10:52:32 +0100 Message-Id: <20200304095233.21046-14-ard.biesheuvel@linaro.org> In-Reply-To: <20200304095233.21046-1-ard.biesheuvel@linaro.org> References: <20200304095233.21046-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1583315580; bh=u10bmY7Z0EFb8tIvDgWnhuENqIvDdEQ0cdUoH94CjBY=; h=Cc:Date:From:Reply-To:Subject:To; b=oPwmpYra7IbYAd9BPwq5CdqOmN8NHhMO2C/tcmSI6gBn0vC6RFlnAf8Jxqzefwc359T iNU9CONreSEiJwROLNgAbXraHPTw7WzyaHe29+G24fsAlmWXnGOffUckM3RWCxWtpswH1 86IK4pmJw3n2RLjs0kuDDZw1/dmmRGbzfP0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Linux v5.7 will introduce a new method to load the initial ramdisk (initrd) from the loader, using the LoadFile2 protocol installed on a special vendor GUIDed media device path. Add support for this to our QEMU command line kernel/initrd loader. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2566 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c | 79 +++++++++++++= +++++++ OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf | 2 + 2 files changed, 81 insertions(+) diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c b/OvmfPk= g/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c index 8ccb1983170c..f43b4c0db0ec 100644 --- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c +++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c @@ -13,15 +13,18 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include #include #include +#include #include =20 // @@ -84,6 +87,19 @@ STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mFileSystemDev= icePath =3D { } }; =20 +STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mInitrdDevicePath =3D { + { + { + MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, + { sizeof (VENDOR_DEVICE_PATH) } + }, + LINUX_EFI_INITRD_MEDIA_GUID + }, { + END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, + { sizeof (EFI_DEVICE_PATH_PROTOCOL) } + } +}; + // // The "file in the EFI stub filesystem" abstraction. // @@ -839,6 +855,48 @@ STATIC CONST EFI_SIMPLE_FILE_SYSTEM_PROTOCOL mFileSyst= em =3D { StubFileSystemOpenVolume }; =20 +STATIC +EFI_STATUS +EFIAPI +InitrdLoadFile2 ( + IN EFI_LOAD_FILE2_PROTOCOL *This, + IN EFI_DEVICE_PATH_PROTOCOL *FilePath, + IN BOOLEAN BootPolicy, + IN OUT UINTN *BufferSize, + IN VOID *Buffer OPTIONAL + ) +{ + CONST KERNEL_BLOB *InitrdBlob =3D &mKernelBlob[KernelBlobTypeInitrd]; + + ASSERT (InitrdBlob->Size > 0); + + if (BootPolicy) { + return EFI_UNSUPPORTED; + } + + if (BufferSize =3D=3D NULL || !IsDevicePathValid (FilePath, 0)) { + return EFI_INVALID_PARAMETER; + } + + if (FilePath->Type !=3D END_DEVICE_PATH_TYPE || + FilePath->SubType !=3D END_ENTIRE_DEVICE_PATH_SUBTYPE) { + return EFI_NOT_FOUND; + } + + if (Buffer =3D=3D NULL || *BufferSize < InitrdBlob->Size) { + *BufferSize =3D InitrdBlob->Size; + return EFI_BUFFER_TOO_SMALL; + } + + CopyMem (Buffer, InitrdBlob->Data, InitrdBlob->Size); + + *BufferSize =3D InitrdBlob->Size; + return EFI_SUCCESS; +} + +STATIC CONST EFI_LOAD_FILE2_PROTOCOL mInitrdLoadFile2 =3D { + InitrdLoadFile2, +}; =20 // // Utility functions. @@ -949,6 +1007,7 @@ QemuKernelLoaderFsDxeEntrypoint ( KERNEL_BLOB *KernelBlob; EFI_STATUS Status; EFI_HANDLE FileSystemHandle; + EFI_HANDLE InitrdLoadFile2Handle; =20 if (!QemuFwCfgIsAvailable ()) { return EFI_NOT_FOUND; @@ -993,8 +1052,28 @@ QemuKernelLoaderFsDxeEntrypoint ( goto FreeBlobs; } =20 + if (KernelBlob[KernelBlobTypeInitrd].Size > 0) { + InitrdLoadFile2Handle =3D NULL; + Status =3D gBS->InstallMultipleProtocolInterfaces (&InitrdLoadFile2Han= dle, + &gEfiDevicePathProtocolGuid, &mInitrdDevicePath, + &gEfiLoadFile2ProtocolGuid, &mInitrdLoadFile2, + NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: InstallMultipleProtocolInterfaces(): %r\n", + __FUNCTION__, Status)); + goto UninstallFileSystemHandle; + } + } + return EFI_SUCCESS; =20 +UninstallFileSystemHandle: + Status =3D gBS->UninstallMultipleProtocolInterfaces (FileSystemHandle, + &gEfiDevicePathProtocolGuid, &mFileSystemDevicePat= h, + &gEfiSimpleFileSystemProtocolGuid, &mFileSystem, + NULL); + ASSERT_EFI_ERROR (Status); + FreeBlobs: while (BlobType > 0) { CurrentBlob =3D &mKernelBlob[--BlobType]; diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf b/Ovmf= Pkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf index 5ba88063def0..7b35adb8e034 100644 --- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf +++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf @@ -28,6 +28,7 @@ [LibraryClasses] BaseLib BaseMemoryLib DebugLib + DevicePathLib MemoryAllocationLib QemuFwCfgLib UefiBootServicesTableLib @@ -42,6 +43,7 @@ [Guids] =20 [Protocols] gEfiDevicePathProtocolGuid ## PRODUCES + gEfiLoadFile2ProtocolGuid ## PRODUCES gEfiSimpleFileSystemProtocolGuid ## PRODUCES =20 [Depex] --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#55394): https://edk2.groups.io/g/devel/message/55394 Mute This Topic: https://groups.io/mt/71722807/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-