From nobody Tue Feb 10 04:15:29 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+55384+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+55384+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1583315567; cv=none; d=zohomail.com; s=zohoarc; b=DTFdPkF0KtT9vqrOZqxA1ZiAMIr9eShVyleZCd98pv6woVNdnOwGfz+sfBd4NACz3Ma6TqBLxc1hymQIFhe5t2orVuXCTW+PxyJPAaaMnzSagshV8iXE45aUggq3Cv8+x4ScXJZNR5cy1Ac/zEKl2TJ29qkW7yjl/zfLtX60fuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583315567; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=cpWrcFnAzuhad8nhHM4yKUQ/cPCM5jcy76ulEb1BA90=; b=fs+88bZ7T0vQY8Q+jI9HUICloTZC/Mw0psGdXOEWRPZkRZ3p+P1EHlFLfX8uWMjoAH3qQ8Tuf25mMX97Y2DEFsgvJ8oMEun48Wv4+Z5MfGILZc5DlAD9YR3weu8aWgExhvBxisxiThDbH1tjoK6cUwFnORqsZZ0nzS0WlFk14B8= 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+55384+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 1583315567311303.0778194668279; Wed, 4 Mar 2020 01:52:47 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id xfCkYY1788612x83smBLzYrL; Wed, 04 Mar 2020 01:52:46 -0800 X-Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.groups.io with SMTP id smtpd.web12.9094.1583315565544914308 for ; Wed, 04 Mar 2020 01:52:45 -0800 X-Received: by mail-wm1-f68.google.com with SMTP id g134so1242314wme.3 for ; Wed, 04 Mar 2020 01:52:45 -0800 (PST) X-Gm-Message-State: 1rcfH7mQ33gpTXvFXHoe9rzHx1787277AA= X-Google-Smtp-Source: ADFU+vuwqYbZtoPEqnJYaDb9h4YQz/ovemEX8/EJNDIa/RC6WxM51R40wE1Ve5tzqg0eundhZNZ2vA== X-Received: by 2002:a1c:9a51:: with SMTP id c78mr2855595wme.130.1583315563665; Wed, 04 Mar 2020 01:52:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 01:52:42 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH v2 03/14] OvmfPkg: introduce QemuLoadImageLib library class Date: Wed, 4 Mar 2020 10:52:22 +0100 Message-Id: <20200304095233.21046-4-ard.biesheuvel@linaro.org> In-Reply-To: <20200304095233.21046-1-ard.biesheuvel@linaro.org> References: <20200304095233.21046-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1583315566; bh=UGHI2EINCX8E9oDiprfO+EHVCdecSZO5lmPHTjTeFm0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=EvPUTkQfi7e2k4smX1NN6GQ22Fsk8ctFUkONtdCEC0ziRgvYj6vaWHw6PPT11w2oRKW RV67OPMIUijDXaSQkn9zoP4YIwpfZXqfferhMhjkXl9QV7CWn7yqiY+RJmG86QbRMLCLw GXK7WSwLb5GWw7+HNykgK9HQwnAnJX/u7HQ= X-ZohoMail-DKIM: pass (identity @groups.io) Introduce the QemuLoadImageLib library class that we will instantiate to load the kernel image passed via the QEMU command line using the standard LoadImage boot service. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2566 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/Library/QemuLoadImageLib.h | 84 ++++++++++++++++++++ OvmfPkg/OvmfPkg.dec | 5 ++ 2 files changed, 89 insertions(+) diff --git a/OvmfPkg/Include/Library/QemuLoadImageLib.h b/OvmfPkg/Include/L= ibrary/QemuLoadImageLib.h new file mode 100644 index 000000000000..694905a6421b --- /dev/null +++ b/OvmfPkg/Include/Library/QemuLoadImageLib.h @@ -0,0 +1,84 @@ +/** @file + Load a kernel image and command line passed to QEMU via + the command line + + Copyright (C) 2020, Arm, Limited. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef QEMU_LOAD_IMAGE_LIB_H__ +#define QEMU_LOAD_IMAGE_LIB_H__ + +#include +#include + +#include + +/** + Download the kernel, the initial ramdisk, and the kernel command line fr= om + QEMU's fw_cfg. The kernel will be instructed via its command line to load + the initrd from the same Simple FileSystem where the kernel was loaded f= rom. + + @param[out] ImageHandle The image handle that was allocated for + loading the image + + @retval EFI_SUCCESS The image was loaded successfully. + @retval EFI_NOT_FOUND Kernel image was not found. + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + @retval EFI_PROTOCOL_ERROR Unterminated kernel command line. + @retval EFI_ACCESS_DENIED The underlying LoadImage boot service call + returned EFI_SECURITY_VIOLATION, and the i= mage + was unloaded again. + + @return Error codes from any of the underlying + functions. +**/ +EFI_STATUS +EFIAPI +QemuLoadKernelImage ( + OUT EFI_HANDLE *ImageHandle + ); + +/** + Transfer control to a kernel image loaded with QemuLoadKernelImage () + + @param[in,out] ImageHandle Handle of image to be started. May assum= e a + different value on return if the image w= as + reloaded. + + @retval EFI_INVALID_PARAMETER ImageHandle is either an invalid image h= andle + or the image has already been initialize= d with + StartImage + @retval EFI_SECURITY_VIOLATION The current platform policy specifies th= at the + image should not be started. + + @return Error codes returned by the started imag= e. + On success, the function doesn't return. +**/ +EFI_STATUS +EFIAPI +QemuStartKernelImage ( + IN OUT EFI_HANDLE *ImageHandle + ); + +/** + Unloads an image loaded with QemuLoadKernelImage (). + + @param ImageHandle Handle that identifies the image to be + unloaded. + + @retval EFI_SUCCESS The image has been unloaded. + @retval EFI_UNSUPPORTED The image has been started, and does not + support unload. + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + + @return Exit code from the image=E2=80=99s unloa= d function. +**/ +EFI_STATUS +EFIAPI +QemuUnloadKernelImage ( + IN EFI_HANDLE ImageHandle + ); + +#endif diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index a21b279d140a..055caaa43041 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -58,6 +58,11 @@ [LibraryClasses] # QemuBootOrderLib|Include/Library/QemuBootOrderLib.h =20 + ## @libraryclass Load a kernel image and command line passed to QEMU v= ia + # the command line + # + QemuLoadImageLib|Include/Library/QemuLoadImageLib.h + ## @libraryclass Serialize (and deserialize) variables # SerializeVariablesLib|Include/Library/SerializeVariablesLib.h --=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 (#55384): https://edk2.groups.io/g/devel/message/55384 Mute This Topic: https://groups.io/mt/71722796/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-