summaryrefslogtreecommitdiffstats
path: root/OvmfPkg
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2020-02-28 23:15:22 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-03-05 19:45:05 +0000
commit0758a8e979be2eb86130c759942afa35b6b2e56d (patch)
tree1432048edddd1ddaf756b30524e158fe17196fde /OvmfPkg
parentefc52d67e1573ce174d301b52fa1577d552c8441 (diff)
downloadedk2-0758a8e979be2eb86130c759942afa35b6b2e56d.tar.gz
edk2-0758a8e979be2eb86130c759942afa35b6b2e56d.tar.bz2
edk2-0758a8e979be2eb86130c759942afa35b6b2e56d.zip
OvmfPkg/QemuKernelLoaderFsDxe: add support for the kernel setup block
On x86, the kernel image consists of a setup block and the actual kernel, and QEMU presents these as separate blobs, whereas on disk (and in terms of PE/COFF image signing), they consist of a single image. So add support to our FS loader driver to expose files via the abstract file system that consist of up to two concatenated blobs, and redefine the kernel file so it consists of the setup and kernel blobs, on every architecture (on non-x86, the setup block is simply 0 bytes and is therefore ignored implicitly) Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2566 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'OvmfPkg')
-rw-r--r--OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c74
1 files changed, 53 insertions, 21 deletions
diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
index dc86a48af3..8ccb198317 100644
--- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
+++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
@@ -34,16 +34,29 @@ typedef enum {
} KERNEL_BLOB_TYPE;
typedef struct {
- FIRMWARE_CONFIG_ITEM CONST SizeKey;
- FIRMWARE_CONFIG_ITEM CONST DataKey;
- CONST CHAR16 * CONST Name;
- UINT32 Size;
- UINT8 *Data;
+ CONST CHAR16 Name[8];
+ struct {
+ FIRMWARE_CONFIG_ITEM CONST SizeKey;
+ FIRMWARE_CONFIG_ITEM CONST DataKey;
+ UINT32 Size;
+ } FwCfgItem[2];
+ UINT32 Size;
+ UINT8 *Data;
} KERNEL_BLOB;
STATIC KERNEL_BLOB mKernelBlob[KernelBlobTypeMax] = {
- { QemuFwCfgItemKernelSize, QemuFwCfgItemKernelData, L"kernel" },
- { QemuFwCfgItemInitrdSize, QemuFwCfgItemInitrdData, L"initrd" },
+ {
+ L"kernel",
+ {
+ { QemuFwCfgItemKernelSetupSize, QemuFwCfgItemKernelSetupData, },
+ { QemuFwCfgItemKernelSize, QemuFwCfgItemKernelData, },
+ }
+ }, {
+ L"initrd",
+ {
+ { QemuFwCfgItemInitrdSize, QemuFwCfgItemInitrdData, },
+ }
+ }
};
STATIC UINT64 mTotalBlobBytes;
@@ -850,12 +863,21 @@ FetchBlob (
)
{
UINT32 Left;
+ UINTN Idx;
+ UINT8 *ChunkData;
//
// Read blob size.
//
- QemuFwCfgSelectItem (Blob->SizeKey);
- Blob->Size = QemuFwCfgRead32 ();
+ Blob->Size = 0;
+ for (Idx = 0; Idx < ARRAY_SIZE (Blob->FwCfgItem); Idx++) {
+ if (Blob->FwCfgItem[Idx].SizeKey == 0) {
+ break;
+ }
+ QemuFwCfgSelectItem (Blob->FwCfgItem[Idx].SizeKey);
+ Blob->FwCfgItem[Idx].Size = QemuFwCfgRead32 ();
+ Blob->Size += Blob->FwCfgItem[Idx].Size;
+ }
if (Blob->Size == 0) {
return EFI_SUCCESS;
}
@@ -872,18 +894,28 @@ FetchBlob (
DEBUG ((DEBUG_INFO, "%a: loading %Ld bytes for \"%s\"\n", __FUNCTION__,
(INT64)Blob->Size, Blob->Name));
- QemuFwCfgSelectItem (Blob->DataKey);
-
- Left = Blob->Size;
- do {
- UINT32 Chunk;
-
- Chunk = (Left < SIZE_1MB) ? Left : SIZE_1MB;
- QemuFwCfgReadBytes (Chunk, Blob->Data + (Blob->Size - Left));
- Left -= Chunk;
- DEBUG ((DEBUG_VERBOSE, "%a: %Ld bytes remaining for \"%s\"\n",
- __FUNCTION__, (INT64)Left, Blob->Name));
- } while (Left > 0);
+
+ ChunkData = Blob->Data;
+ for (Idx = 0; Idx < ARRAY_SIZE (Blob->FwCfgItem); Idx++) {
+ if (Blob->FwCfgItem[Idx].DataKey == 0) {
+ break;
+ }
+ QemuFwCfgSelectItem (Blob->FwCfgItem[Idx].DataKey);
+
+ Left = Blob->FwCfgItem[Idx].Size;
+ while (Left > 0) {
+ UINT32 Chunk;
+
+ Chunk = (Left < SIZE_1MB) ? Left : SIZE_1MB;
+ QemuFwCfgReadBytes (Chunk, ChunkData + Blob->FwCfgItem[Idx].Size - Left);
+ Left -= Chunk;
+ DEBUG ((DEBUG_VERBOSE, "%a: %Ld bytes remaining for \"%s\" (%d)\n",
+ __FUNCTION__, (INT64)Left, Blob->Name, (INT32)Idx));
+ }
+
+ ChunkData += Blob->FwCfgItem[Idx].Size;
+ }
+
return EFI_SUCCESS;
}