From nobody Mon Feb 9 23:01:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+55389+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55389+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1583315574; cv=none; d=zohomail.com; s=zohoarc; b=ZoDHc2sKKMuY2mkVyu8ZZlk9yADnbpsoOT8KuvY+CSOtyhv5qTSHWM+tOwFPFVa1fPp2AAxkJvACj3O4Ym7pPq2Iv9SO7BIKePljl8qNTOljZAwAtaZBlNGRtJIQ8UyouS3JZzCu6+Db68PDDB5zY4EGv8dlrBu1WIbVt0ux2vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583315574; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=ndZMYYsKUIIQflv2KkxwTEnB521hX0ERhpNIdQDrVs4=; b=bVXnUBUnHaF9u4MucdpYzyqryQHv/aTiLQynHdL9qfJ5ev8veYv7xhkNmHMJo5Qec/9Dv2Nwmtn6D0uEkBq1JY1EjBnWYvq0aY6S59GQ70cHp8lpyda75Xh9cgfer0qBwEYuTes29kDMEk/PF8t3Pocv/7Qseyw8VcYz0DWTbGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55389+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1583315574449312.4509410249084; Wed, 4 Mar 2020 01:52:54 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id AuOkYY1788612xJO0NxAsxKP; Wed, 04 Mar 2020 01:52:53 -0800 X-Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web09.9060.1583315572695641681 for ; Wed, 04 Mar 2020 01:52:53 -0800 X-Received: by mail-wr1-f66.google.com with SMTP id j7so1532197wrp.13 for ; Wed, 04 Mar 2020 01:52:52 -0800 (PST) X-Gm-Message-State: Qe49xzz6EJ8sXG8Ajq00AjDex1787277AA= X-Google-Smtp-Source: ADFU+vudhfFmsmiPpcsb88/S70ibfw5wZI+lZARIu037pNSJyPkzJ2bDCcoaDLGZX6dqlAUdjOoRQA== X-Received: by 2002:adf:eec3:: with SMTP id a3mr3447518wrp.170.1583315570925; Wed, 04 Mar 2020 01:52:50 -0800 (PST) X-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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 01:52:49 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH v2 08/14] OvmfPkg/QemuKernelLoaderFsDxe: add support for the kernel setup block Date: Wed, 4 Mar 2020 10:52:27 +0100 Message-Id: <20200304095233.21046-9-ard.biesheuvel@linaro.org> In-Reply-To: <20200304095233.21046-1-ard.biesheuvel@linaro.org> References: <20200304095233.21046-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1583315573; bh=Ye5rDcsFsY6pR0rgBKQfx7tKE5OHN2XilFdUXO7Jg+U=; h=Cc:Date:From:Reply-To:Subject:To; b=GAjipdV1Lf3Ht9tlL4y6hAHAuSCkr11opTEmXQG+4n0AUaa5FJH4c0GUnITjPDpfvcr 8O9UGSGuPt2A0mPqRDYuTcFas/uLLqWPtgmXaHdA5rRwnj40dUgHtpiX/G3PPCf0i+XkZ fukL+BEsKuqKsH94OGKjAuXh63THSfZubBU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=3D2566 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c | 74 ++++++++++++++-= ----- 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c b/OvmfPk= g/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c index dc86a48af378..8ccb1983170c 100644 --- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c +++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c @@ -34,16 +34,29 @@ typedef enum { } KERNEL_BLOB_TYPE; =20 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; =20 STATIC KERNEL_BLOB mKernelBlob[KernelBlobTypeMax] =3D { - { QemuFwCfgItemKernelSize, QemuFwCfgItemKernelData, L"kernel" = }, - { QemuFwCfgItemInitrdSize, QemuFwCfgItemInitrdData, L"initrd" = }, + { + L"kernel", + { + { QemuFwCfgItemKernelSetupSize, QemuFwCfgItemKernelSetupData, }, + { QemuFwCfgItemKernelSize, QemuFwCfgItemKernelData, }, + } + }, { + L"initrd", + { + { QemuFwCfgItemInitrdSize, QemuFwCfgItemInitrdData, }, + } + } }; =20 STATIC UINT64 mTotalBlobBytes; @@ -850,12 +863,21 @@ FetchBlob ( ) { UINT32 Left; + UINTN Idx; + UINT8 *ChunkData; =20 // // Read blob size. // - QemuFwCfgSelectItem (Blob->SizeKey); - Blob->Size =3D QemuFwCfgRead32 (); + Blob->Size =3D 0; + for (Idx =3D 0; Idx < ARRAY_SIZE (Blob->FwCfgItem); Idx++) { + if (Blob->FwCfgItem[Idx].SizeKey =3D=3D 0) { + break; + } + QemuFwCfgSelectItem (Blob->FwCfgItem[Idx].SizeKey); + Blob->FwCfgItem[Idx].Size =3D QemuFwCfgRead32 (); + Blob->Size +=3D Blob->FwCfgItem[Idx].Size; + } if (Blob->Size =3D=3D 0) { return EFI_SUCCESS; } @@ -872,18 +894,28 @@ FetchBlob ( =20 DEBUG ((DEBUG_INFO, "%a: loading %Ld bytes for \"%s\"\n", __FUNCTION__, (INT64)Blob->Size, Blob->Name)); - QemuFwCfgSelectItem (Blob->DataKey); - - Left =3D Blob->Size; - do { - UINT32 Chunk; - - Chunk =3D (Left < SIZE_1MB) ? Left : SIZE_1MB; - QemuFwCfgReadBytes (Chunk, Blob->Data + (Blob->Size - Left)); - Left -=3D Chunk; - DEBUG ((DEBUG_VERBOSE, "%a: %Ld bytes remaining for \"%s\"\n", - __FUNCTION__, (INT64)Left, Blob->Name)); - } while (Left > 0); + + ChunkData =3D Blob->Data; + for (Idx =3D 0; Idx < ARRAY_SIZE (Blob->FwCfgItem); Idx++) { + if (Blob->FwCfgItem[Idx].DataKey =3D=3D 0) { + break; + } + QemuFwCfgSelectItem (Blob->FwCfgItem[Idx].DataKey); + + Left =3D Blob->FwCfgItem[Idx].Size; + while (Left > 0) { + UINT32 Chunk; + + Chunk =3D (Left < SIZE_1MB) ? Left : SIZE_1MB; + QemuFwCfgReadBytes (Chunk, ChunkData + Blob->FwCfgItem[Idx].Size - L= eft); + Left -=3D Chunk; + DEBUG ((DEBUG_VERBOSE, "%a: %Ld bytes remaining for \"%s\" (%d)\n", + __FUNCTION__, (INT64)Left, Blob->Name, (INT32)Idx)); + } + + ChunkData +=3D Blob->FwCfgItem[Idx].Size; + } + return EFI_SUCCESS; } =20 --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#55389): https://edk2.groups.io/g/devel/message/55389 Mute This Topic: https://groups.io/mt/71722802/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-