From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web12.12578.1583415975462209453 for ; Thu, 05 Mar 2020 05:46:15 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=qFo4RuQE; spf=pass (domain: linaro.org, ip: 209.85.221.66, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f66.google.com with SMTP id x7so7111242wrr.0 for ; Thu, 05 Mar 2020 05:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nDP6uCyFUqbmKjmkSfGnQk88MSp74/B06wtpgRrT/20=; b=qFo4RuQE8LIaL5EdcChF+HRJv5WQYGohxxLqFiCK13BG1KGsn7MUs34IbPUi16y9dQ S+r55c6ltAKQ85hP2LZhOxYii0Qyrw8iDNfGUS5hU0u9YQVvEYj/sh5Pyfk4eKtu33aO 7WpMtncv41tu85tb7fVGJDEXFclYre9qYVqWn+KXhhX/8B8Cl7dfBwsqkVGwZvtAz+xC RUTCB20lHxcrZas3ZH17dDPL7FMs0jJSHk3kUVDx0ExmBAUvBBRSK3YRzO3hKqfuo55S jGJPXiWw/p6LsGrHtTRP/qgJZpYT0Pl1QAp2EYX+jMACZXfH9C90Mr7suSIcR2Qr8VWr A9hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nDP6uCyFUqbmKjmkSfGnQk88MSp74/B06wtpgRrT/20=; b=TriBigd24VRW5aCHjzqxzOYKDWvlf9U0JFGyGyPR3uHPGewuBRasLSB7fKIjyiOqZk LLGLNTof3xR8YveuqURVTOzET9Uf6VyuPVeYhO9E/Fj4i9c+hvztilN9iROZxS9YGarg lPQofkdeaDtYUXcbfV+g8mRKdy2GnLuRHlqahm3uMCiIq5M/ma+3CLJIYwPm1D0so3nD BEuhmVyNoD+0Zvcxne2LGl7e+GUIrias277NC1QJsBcVKWYen5NVh5R/3qv2inxCbOmt nj/zA9umX4dB/Nvs8ImLqsqly1W4squj0S9yf6EYPLqO4gCQIyTT4iqGpwclJE+fSxTh Vurw== X-Gm-Message-State: ANhLgQ0mlMwCX6f0hwBfZDb5PVtRMsuC8xpZx+k7DAQPQ0Nv1RHaLJ21 GUW6Xgwdi6WSTtyo5SskrtQLbd3epo/dGA== X-Google-Smtp-Source: ADFU+vuI71Mmqe/Up0omth0cslkU6IOuFwbBef3hdG6qjxe01gTzmyV+d5bYZc1Sdl0qhqiGp2o8wA== X-Received: by 2002:adf:e7c8:: with SMTP id e8mr10199899wrn.298.1583415973588; Thu, 05 Mar 2020 05:46:13 -0800 (PST) Return-Path: Received: from e123331-lin.home ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id m19sm9278701wmc.34.2020.03.05.05.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 05:46:12 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, Ard Biesheuvel Subject: [PATCH v3 03/14] OvmfPkg: introduce QemuLoadImageLib library class Date: Thu, 5 Mar 2020 14:45:56 +0100 Message-Id: <20200305134607.20125-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200305134607.20125-1-ard.biesheuvel@linaro.org> References: <20200305134607.20125-1-ard.biesheuvel@linaro.org> 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=2566 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/Library/QemuLoadImageLib.h new file mode 100644 index 000000000000..746b74f73c40 --- /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 load + 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 call + 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 assume 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 initialized 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 image. + 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's unload 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 + ## @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 -- 2.17.1