From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web10.10261.1583401046213401465 for ; Thu, 05 Mar 2020 01:37:26 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ss/DJhpl; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583401045; 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=t6muHueCLunbjZ0aj8vvBk5P5/cGaK70TjLChEbuWf8=; b=Ss/DJhpl6ellM4hOUvECHKY62u+lPIrAitx9Na/UOSsEn91IMJt2zkSWriw3iHlBv40xtp r/55RbI20SJOymd65wfTvL6eXL7TM940FLGuTJ6QZkGpHATxDTAFFN2+oH3z8Rn6AFmgCC Q/MifKvjOEHKiYatByefCxbeRDMMnzw= 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-438-cLreCITTMr6D7cvCl-VfKA-1; Thu, 05 Mar 2020 04:37:18 -0500 X-MC-Unique: cLreCITTMr6D7cvCl-VfKA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8569800D55; Thu, 5 Mar 2020 09:37:17 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-216.ams2.redhat.com [10.36.117.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC2E08AC30; Thu, 5 Mar 2020 09:37:16 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 03/14] OvmfPkg: introduce QemuLoadImageLib library class To: devel@edk2.groups.io, ard.biesheuvel@linaro.org References: <20200304095233.21046-1-ard.biesheuvel@linaro.org> <20200304095233.21046-4-ard.biesheuvel@linaro.org> From: "Laszlo Ersek" Message-ID: <7dfb1eb8-eb54-d181-914a-912649a5aaa0@redhat.com> Date: Thu, 5 Mar 2020 10:37:16 +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: <20200304095233.21046-4-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/04/20 10:52, 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 > Reviewed-by: Laszlo Ersek > --- > OvmfPkg/Include/Library/QemuLoadImageLib.h | 84 ++++++++++++++++++++ > OvmfPkg/OvmfPkg.dec | 5 ++ > 2 files changed, 89 insertions(+) >=20 > diff --git a/OvmfPkg/Include/Library/QemuLoadImageLib.h b/OvmfPkg/Include= /Library/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 = from > + QEMU's fw_cfg. The kernel will be instructed via its command line to l= oad > + the initrd from the same Simple FileSystem 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. > + @retval EFI_ACCESS_DENIED The underlying LoadImage boot service ca= ll > + returned EFI_SECURITY_VIOLATION, and the= image > + 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 ass= ume a > + different value on return if the image= was > + reloaded. > + > + @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 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 n= ot > + support unload. > + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handl= e. > + > + @return Exit code from the image=E2=80=99s unl= oad function. (1) The above apostrophe (in the "image=E2=80=99s" expression) is U+2019 ("= RIGHT SINGLE QUOTATION MARK"). Please replace it with a normal ASCII 0x27 character (U+0027, "APOSTROPHE") when you push the series. Thanks Laszlo > +**/ > +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= via > + # the command line > + # > + QemuLoadImageLib|Include/Library/QemuLoadImageLib.h > + > ## @libraryclass Serialize (and deserialize) variables > # > SerializeVariablesLib|Include/Library/SerializeVariablesLib.h >=20