From nobody Mon Feb 9 20:31:59 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+55531+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+55531+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1583415983; cv=none; d=zohomail.com; s=zohoarc; b=D3v0EgFbDpEVwpivOukdgzCe7fcaj1AT5TA1KFx/Q6BVW52pkzMqtXQC1sCrDyqY4ttcs2gQdj68TO1HkjNgkSkGFStWseLd5MOWwRZ8xUpouc1gzLK8tsJH/vnaApntYS/vzuLsYa3wLZrezG4fMhdtmgQDlqtNovNTiZOdJ+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583415983; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=qMcGWUaovfn1TRfG4Y3KimRfhw1vZ6gNLuUguHBbyoQ=; b=DBKQ1ZTp+um18T8NWnXZNu3n10bO7wBB5flfjpBhH8k7NHrdnBxHAxKZ+H15WdkbcgpdM6gRxwouVtBOxzfCVuZA2Y9EI0ViOpgZj6W/Kwr53ONM6ZTiZmVLDka+GnWs0lrbsW4GcygiSLmVfw3gMkfeOVpTZmls6Ns+LdqQKks= 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+55531+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 1583415983097148.57328113363053; Thu, 5 Mar 2020 05:46:23 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id PQOgYY1788612xLEKlnBYKIC; Thu, 05 Mar 2020 05:46:22 -0800 X-Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.groups.io with SMTP id smtpd.web11.12601.1583415982098614378 for ; Thu, 05 Mar 2020 05:46:22 -0800 X-Received: by mail-wm1-f68.google.com with SMTP id a25so7131335wmm.0 for ; Thu, 05 Mar 2020 05:46:21 -0800 (PST) X-Gm-Message-State: Mm3JaACqEksDbv6elUzPwM72x1787277AA= X-Google-Smtp-Source: ADFU+vtNa5ZBINmPeBLoze6JgzSfbrSV6VdF0qhX4SxxbqwbC78ayPVcdj6I4LxhSByPYO+GegSqsA== X-Received: by 2002:a7b:cb12:: with SMTP id u18mr9833483wmj.153.1583415980217; Thu, 05 Mar 2020 05:46:20 -0800 (PST) X-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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 05:46:19 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 08/14] OvmfPkg/QemuKernelLoaderFsDxe: add support for the kernel setup block Date: Thu, 5 Mar 2020 14:46:01 +0100 Message-Id: <20200305134607.20125-9-ard.biesheuvel@linaro.org> In-Reply-To: <20200305134607.20125-1-ard.biesheuvel@linaro.org> References: <20200305134607.20125-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=1583415982; bh=/yE7gVQ4doOhPytDGgF1iSIvncGL234x875xfy63fzY=; h=Cc:Date:From:Reply-To:Subject:To; b=nXvb4oeq6McfsgTKXAlrauV/sF8AyEiQzVPN/+0PyLvqCNUPxih227eGFMbcopvIX+f tAsR9HkDGmclfQkSYT+pf0uTuTRweaQAvuzx0iIPnZx7F0W/ej3ZcuLhJH3mve1E3JktU dcUi5E76a2ZX1CZm9QDcsslCij1MSBkfR0I= 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 (#55531): https://edk2.groups.io/g/devel/message/55531 Mute This Topic: https://groups.io/mt/71749521/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-