From nobody Wed May 8 20:35:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1512977987857601.1452934664187; Sun, 10 Dec 2017 23:39:47 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 66B50220FB32C; Sun, 10 Dec 2017 23:35:09 -0800 (PST) Received: from mail-ot0-x242.google.com (mail-ot0-x242.google.com [IPv6:2607:f8b0:4003:c0f::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8D6E12214E358 for ; Sun, 10 Dec 2017 23:35:07 -0800 (PST) Received: by mail-ot0-x242.google.com with SMTP id e74so13966238ote.7 for ; Sun, 10 Dec 2017 23:39:44 -0800 (PST) Received: by 10.157.1.204 with HTTP; Sun, 10 Dec 2017 23:39:43 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4003:c0f::242; helo=mail-ot0-x242.google.com; envelope-from=sigmaepsilon92@gmail.com; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=xUfe2U3QKnoISsIZ2ZfL3Rytt59661L7cp2elntDYnQ=; b=gz58x/GXf3ZSA3el6SS90rE1smemF/UGZl+JBaN3W9F6vQ5g2mNDNkyTibdEB7/ToB waTHXR5om0vX/jWOs6ir+K1S5bGFk6fvAyh/DV5z7lS1DEwLyn/plDYcOxWw9odl69q8 82GOHnxnVwtBrVltdgVjQXvotOv+LyjPr8pW1XogbKdjb18mifj/SQMTltP5jpF76cQ4 Z4qppUZB/PdP1baROK9kFsMkMyA5m32vRbX9Wt3E1CWAA8vL3c2Lr8j9c5sZuJ/aBa2x QnRkh6vfeilZXMiSmSgyC+DKBlovayDVllbxU5Gz+Y6MxELuhw3pWhPS3xIP9hA/RaPQ N4Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=xUfe2U3QKnoISsIZ2ZfL3Rytt59661L7cp2elntDYnQ=; b=fJqeDT4ME/3bk2ca1bPOrNObl/Zu3YwYlK6l6CybcxikgBWFOFSjP1cMaHyROPKqvZ tRB5RRlv1vCAr/+f0HSH+i+HRjI2FqeNI0o/V1uEKitg/hjzb4t52knFUMhERAw5Bx9l sH7c/hOD6aimfeQIpnd9zgQHIVl2cx3C/ydd7vv+WDP3gI+dsAnwcTyrI2N4ipXJrH4j O6yQzt6dOdstK4J9tGMu61bPxwejSWI7tFlIf3m8gTAs75sFR47BhvPaMhy8LWCHXkPX G0I3y5aoivtdcv8uLlPZopdXgKgv9reggCH7uJwDW5UoRu7U6BSIjMZQOftgjoaVHjZs IBlA== X-Gm-Message-State: AJaThX4mm13s00d0gQI9y/WEoy0F2Y4OYxlajcGxhCgGfxqBvfPUr+Bz qYuf0uQjPwBxbmoShw1B/0gExiXoA9/8osbsibZj0F9H X-Google-Smtp-Source: AGs4zMYddyZk8kCN+g/1/8o0o5LGNZeDBKI5EWQdh5HMNlLAHiL9CUrOZ/WaJyvJVP/sBipyk1wzfyR8i4vukrHpQ/U= X-Received: by 10.157.85.194 with SMTP id z2mr32093881oti.74.1512977983726; Sun, 10 Dec 2017 23:39:43 -0800 (PST) MIME-Version: 1.0 From: Michael Zimmermann Date: Mon, 11 Dec 2017 08:39:43 +0100 Message-ID: To: edk2-devel-01 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: [edk2] [PATCH] EmbeddedPkg/PrePiLib: add support for v2 sections X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leif Lindholm , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael Zimmermann Reviewed-by: Ard Biesheuvel --- EmbeddedPkg/Library/PrePiLib/FwVol.c | 63 ++++++++++++++++---- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/EmbeddedPkg/Library/PrePiLib/FwVol.c b/EmbeddedPkg/Library/PrePiLib/FwVol.c index 530fc15dc..d513de351 100644 --- a/EmbeddedPkg/Library/PrePiLib/FwVol.c +++ b/EmbeddedPkg/Library/PrePiLib/FwVol.c @@ -296,35 +296,61 @@ FfsProcessSection ( UINT32 SectionLength; UINT32 ParsedLength; EFI_COMPRESSION_SECTION *CompressionSection; + EFI_COMPRESSION_SECTION2 *CompressionSection2; UINT32 DstBufferSize; VOID *ScratchBuffer; UINT32 ScratchBufferSize; VOID *DstBuffer; UINT16 SectionAttribute; UINT32 AuthenticationStatus; + CHAR8 *CompressedData; + UINTN CompressedDataLength; *OutputBuffer =3D NULL; ParsedLength =3D 0; Status =3D EFI_NOT_FOUND; while (ParsedLength < SectionSize) { + if (IS_SECTION2 (Section)) { + ASSERT (SECTION2_SIZE (Section) > 0x00FFFFFF); + } + if (Section->Type =3D=3D SectionType) { - *OutputBuffer =3D (VOID *)(Section + 1); + if (IS_SECTION2 (Section)) { + *OutputBuffer =3D (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2)); + } else { + *OutputBuffer =3D (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER)); + } return EFI_SUCCESS; } else if ((Section->Type =3D=3D EFI_SECTION_COMPRESSION) || (Section->Type =3D=3D EFI_SECTION_GUID_DEFINED)) { if (Section->Type =3D=3D EFI_SECTION_COMPRESSION) { - CompressionSection =3D (EFI_COMPRESSION_SECTION *) Section; - SectionLength =3D *(UINT32 *)Section->Size & 0x00FFFFFF; - - if (CompressionSection->CompressionType !=3D EFI_STANDARD_COMPRESSION) { - return EFI_UNSUPPORTED; + if (IS_SECTION2 (Section)) { + CompressionSection2 =3D (EFI_COMPRESSION_SECTION2 *) Section; + SectionLength =3D SECTION2_SIZE (Section); + + if (CompressionSection2->CompressionType !=3D EFI_STANDARD_COMPRESSION) { + return EFI_UNSUPPORTED; + } + + CompressedData =3D (CHAR8 *) ((EFI_COMPRESSION_SECTION2 *) Secti= on + 1); + CompressedDataLength =3D (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION2); + } else { + CompressionSection =3D (EFI_COMPRESSION_SECTION *) Section; + SectionLength =3D SECTION_SIZE (Section); + + if (CompressionSection->CompressionType !=3D EFI_STANDARD_COMPRESSION) { + return EFI_UNSUPPORTED; + } + + CompressedData =3D (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1); + CompressedDataLength =3D (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION); } Status =3D UefiDecompressGetInfo ( - (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), - (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION), + CompressedData, + CompressedDataLength, &DstBufferSize, &ScratchBufferSize ); @@ -362,13 +388,23 @@ FfsProcessSection ( // DstBuffer still is one section. Adjust DstBuffer offset, skip EFI section header // to make section data at page alignment. // - DstBuffer =3D (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER); + if (IS_SECTION2 (Section)) + DstBuffer =3D (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER2); + else + DstBuffer =3D (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER); // // Call decompress function // if (Section->Type =3D=3D EFI_SECTION_COMPRESSION) { + if (IS_SECTION2 (Section)) { + CompressedData =3D (CHAR8 *) ((EFI_COMPRESSION_SECTION2 *) Secti= on + 1); + } + else { + CompressedData =3D (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1); + } + Status =3D UefiDecompress ( - (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), + CompressedData, DstBuffer, ScratchBuffer ); @@ -397,12 +433,15 @@ FfsProcessSection ( } } + if (IS_SECTION2 (Section)) { + SectionLength =3D SECTION2_SIZE (Section); + } else { + SectionLength =3D SECTION_SIZE (Section); + } // - // Size is 24 bits wide so mask upper 8 bits. // SectionLength is adjusted it is 4 byte aligned. // Go to the next section // - SectionLength =3D *(UINT32 *)Section->Size & 0x00FFFFFF; SectionLength =3D GET_OCCUPIED_SIZE (SectionLength, 4); ASSERT (SectionLength !=3D 0); ParsedLength +=3D SectionLength; --=20 2.15.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel