From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=e/KfDY8r; spf=pass (domain: linaro.org, ip: 209.85.128.68, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wm1-f68.google.com with SMTP id g134so1242314wme.3 for ; Wed, 04 Mar 2020 01:52:45 -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 :mime-version:content-transfer-encoding; bh=h0PLaG4/3purdp4MOm7ghdF+VbFcGGImY1rBtOqtmY8=; b=e/KfDY8r90S/bW2+zhNxYb2zLhedRFM6tuarJMFCSl6N+p3SycAoeLDp5gLONkCjQy 0u9X+eXymVIqfjJQs24VuGz2LVK84wJIyCIKyEFdklLKRJcD5noxBizXAIJ/aDAgJwOu +iFEaqa6ye9rJfC5Pq4bntWoLrZoVlHRFN4XSKVQ1LrbDPO4YwlzhCFGdoY5oIeN7dXK Z7s1KXYfaVFrhDmLqVYP5Y1xJpooqglqPDNKyVPvKtb3+tlz263B54YXVFws4XX2xPap kNnHdMxaLy9ejKO47ch64kXFCCZcRJAy1yp/c2g7y5u118eimEmSs8Mi88fa1FIfMNVQ 1pRQ== 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:mime-version:content-transfer-encoding; bh=h0PLaG4/3purdp4MOm7ghdF+VbFcGGImY1rBtOqtmY8=; b=s2TjmPpi7lLWoOMek8a/DxHHJlXLtgIes0np7VlmQ1d379dbyGpooJk1zzJ1MtOAAi LhWIlBr6oLYC/pfWhwnM7HE2vyDfTYUaRvjsKq8DPiYswdHGdpLUX1Fw8rUusGW1kYgh W1HiWUu5yb072kXZEaZdBCrRCzsU+Fr2xLgA1RNFili7em9vhnc5nLzqivVfypvWEmNN JMcNrKy6zrvu22PfArXzljjTxXPvjj56PcuU1ftH9gRVqGZ13Km6lBtFrcVL78Aa/ijU cjNJbM4sL5jlsTvX5Yn5fwqazA1pZ17AnAprmWYuJXuacOogfXp/5cCs5k5ewTYf+n4Y 8wDA== X-Gm-Message-State: ANhLgQ2O0VYeRrfKJSvr0PR1DnEbWKD6tTMMpHsJTRcsG1DKx5URbW4z GmHDpDYxLMbeZPtKkdOv3eCFaSs3ioZt3A== 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) Return-Path: 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: [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> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200304095233.21046-1-ard.biesheuvel@linaro.org> References: <20200304095233.21046-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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..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 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