From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web09.14560.1583158086672073165 for ; Mon, 02 Mar 2020 06:08:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=baC0MZhV; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583158085; 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: in-reply-to:in-reply-to:references:references; bh=5YLaf8W6umOOjzUHA3cvgNmQGJvTJ+0AwmiSEjGxSX0=; b=baC0MZhVxG7AOu9tnfqJvzMFwx3rebx/qg1XgrRCKWHppl32MI0+5a+vQsZzjZMe/zRAAx CsTp+yhKZgSnLqWYPjz/IgV55WPN/5CeRVuKpBa7DtEDR827K14YXM/ziQK/jNKruul8OP p2jFv2ptnZfp+UlhMwtf26dAo+v/CZo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-g8nOI3ZWP3-fLaHGpbMLyQ-1; Mon, 02 Mar 2020 09:08:02 -0500 X-MC-Unique: g8nOI3ZWP3-fLaHGpbMLyQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9B001922962; Mon, 2 Mar 2020 14:08:00 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-197.ams2.redhat.com [10.36.117.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C06D5C548; Mon, 2 Mar 2020 14:07:59 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 03/13] OvmfPkg: introduce QemuLoadImageLib library class To: devel@edk2.groups.io, ard.biesheuvel@linaro.org References: <20200302072936.29221-1-ard.biesheuvel@linaro.org> <20200302072936.29221-4-ard.biesheuvel@linaro.org> From: "Laszlo Ersek" Message-ID: Date: Mon, 2 Mar 2020 15:07:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200302072936.29221-4-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable On 03/02/20 08:29, Ard Biesheuvel wrote: > 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. >=20 > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2566 > Signed-off-by: Ard Biesheuvel > --- > OvmfPkg/Include/Library/QemuLoadImageLib.h | 78 ++++++++++++++++++++ > OvmfPkg/OvmfPkg.dec | 5 ++ > 2 files changed, 83 insertions(+) >=20 > diff --git a/OvmfPkg/Include/Library/QemuLoadImageLib.h b/OvmfPkg/Include= /Library/QemuLoadImageLib.h > new file mode 100644 > index 000000000000..304853096593 > --- /dev/null > +++ b/OvmfPkg/Include/Library/QemuLoadImageLib.h > @@ -0,0 +1,78 @@ > +/** @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 = from > + QEMU's fw_cfg. The kernel will be instructed via its command line to l= oad > + the initrd from the same Simple FileSystem. (1) ... "where the kernel was loaded from". > + > + @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. > + > + @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] ImageHandle Handle of image to be started. > + > + @retval EFI_INVALID_PARAMETER ImageHandle is either an invalid image= handle > + or the image has already been initiali= zed with > + StartImage > + @retval EFI_SECURITY_VIOLATION The current platform policy specifies = that the > + image should not be started. > + > + @return Error codes returned by the started im= age. > + On success, the function doesn't retur= n. > +**/ > +EFI_STATUS > +EFIAPI > +QemuStartKernelImage ( > + IN 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 n= ot > + support unload. > + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handl= e. (2) Please append: @return Exit code from the image=92s unload function. > + > +**/ > +EFI_STATUS > +EFIAPI > +QemuUnloadKernelImage ( > + IN EFI_HANDLE ImageHandle > + ); > + > +#endif > diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec > index d88778600517..26f977bad795 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= via > + # the command line > + # > + QemuLoadImageLib|Include/Library/QemuLoadImageLib.h > + > ## @libraryclass Serialize (and deserialize) variables > # > SerializeVariablesLib|Include/Library/SerializeVariablesLib.h >=20 With (1) and (2) updated: Reviewed-by: Laszlo Ersek