From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::241; helo=mail-it0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x241.google.com (mail-it0-x241.google.com [IPv6:2607:f8b0:4001:c0b::241]) (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 2B5B121A1099A for ; Tue, 12 Dec 2017 02:42:10 -0800 (PST) Received: by mail-it0-x241.google.com with SMTP id 68so23227345ite.4 for ; Tue, 12 Dec 2017 02:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=p9dR1e8gsHx26e164VNBa09pKa1xhzPT7gNwQqv7mmw=; b=izcPMQG/AZk2FpU1TMRuiiwzV7qZocdhgzXkm0oV9HTsHCPYx0JYDLP1DKDwAi/zW7 S+xvxR5GKLeZUMBYJ742UoJNQgkRe5QHj6rLGyUl4oxo1hRJ6b86JMGBzaCyWHemuNms yT+F9DzSeczlI99ZZ6RUtGh/vqJ42SL7C0eNY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=p9dR1e8gsHx26e164VNBa09pKa1xhzPT7gNwQqv7mmw=; b=dbbmFQ2+KSYyeSHEDvM2bGNB5z2mXZG3I4nWcoELVYuC3wsWiW+mhY0gzoTBzvyEaP 6pQ/6WTPTxABEMmSeH4P6F9ZXYBs8SJFj8e1AcAecPh/KsaTghmIpHug5UaDojE0dSll clUPQ3nlVPlgAPm8LOH4r0A1aJnGrrZz8+YQ2n3FlQDaXXXB5wWT5vATKFo2tHHmV2rE n55ux8Cpds59yS6EA5nxNu78hnPBTd7bbF420ZB7kwJ1Yn6ygHrhYd+zXFdyTQPM4MO9 Q/NEx7bALl0c9UbcC6WVgfJ4334Jgp4am649oX3w97KZQOLI3YVE1yGHksxyuv0+lMNr cV6w== X-Gm-Message-State: AKGB3mI3enUiywNjpj8NthfJ0wAUAwObuxKv9GAa6k90PR3ZnVyH7emc 6kEgAHFOVEs0sM25ve4b7WrPaNjrVfUlfsMGnNthig== X-Google-Smtp-Source: ACJfBouCaNQ3AjkVhqFKidv8jtJoMJNjHexvKSMAaEGlv0zbFPK+WK2/g1PQ5tAvLs4RFU2D7cY+kb8dGZcr3f3F2kE= X-Received: by 10.107.151.142 with SMTP id z136mr4625112iod.248.1513075609051; Tue, 12 Dec 2017 02:46:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.104.16 with HTTP; Tue, 12 Dec 2017 02:46:48 -0800 (PST) In-Reply-To: <20171212065219.11843-1-sigmaepsilon92@gmail.com> References: <20171212065219.11843-1-sigmaepsilon92@gmail.com> From: Ard Biesheuvel Date: Tue, 12 Dec 2017 10:46:48 +0000 Message-ID: To: M1cha Cc: "edk2-devel@lists.01.org" , Leif Lindholm Subject: Re: [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: , X-List-Received-Date: Tue, 12 Dec 2017 10:42:11 -0000 Content-Type: text/plain; charset="UTF-8" On 12 December 2017 at 06:52, M1cha wrote: > From: Michael Zimmermann > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Michael Zimmermann Reviewed-by: Ard Biesheuvel Pushed as 4efc8a402d155fa5c80dac7d1f576b6dd1d3defb Thanks. > --- > EmbeddedPkg/Library/PrePiLib/FwVol.c | 61 ++++++++++++++++---- > 1 file changed, 50 insertions(+), 11 deletions(-) > > diff --git a/EmbeddedPkg/Library/PrePiLib/FwVol.c b/EmbeddedPkg/Library/PrePiLib/FwVol.c > index 530fc15dca1c..d513de351ff5 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 = NULL; > ParsedLength = 0; > Status = EFI_NOT_FOUND; > while (ParsedLength < SectionSize) { > + if (IS_SECTION2 (Section)) { > + ASSERT (SECTION2_SIZE (Section) > 0x00FFFFFF); > + } > + > if (Section->Type == SectionType) { > - *OutputBuffer = (VOID *)(Section + 1); > + if (IS_SECTION2 (Section)) { > + *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2)); > + } else { > + *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER)); > + } > > return EFI_SUCCESS; > } else if ((Section->Type == EFI_SECTION_COMPRESSION) || (Section->Type == EFI_SECTION_GUID_DEFINED)) { > > if (Section->Type == EFI_SECTION_COMPRESSION) { > - CompressionSection = (EFI_COMPRESSION_SECTION *) Section; > - SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF; > + if (IS_SECTION2 (Section)) { > + CompressionSection2 = (EFI_COMPRESSION_SECTION2 *) Section; > + SectionLength = SECTION2_SIZE (Section); > > - if (CompressionSection->CompressionType != EFI_STANDARD_COMPRESSION) { > - return EFI_UNSUPPORTED; > + if (CompressionSection2->CompressionType != EFI_STANDARD_COMPRESSION) { > + return EFI_UNSUPPORTED; > + } > + > + CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION2 *) Section + 1); > + CompressedDataLength = (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION2); > + } else { > + CompressionSection = (EFI_COMPRESSION_SECTION *) Section; > + SectionLength = SECTION_SIZE (Section); > + > + if (CompressionSection->CompressionType != EFI_STANDARD_COMPRESSION) { > + return EFI_UNSUPPORTED; > + } > + > + CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1); > + CompressedDataLength = (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION); > } > > Status = 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 = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER); > + if (IS_SECTION2 (Section)) > + DstBuffer = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER2); > + else > + DstBuffer = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER); > // > // Call decompress function > // > if (Section->Type == EFI_SECTION_COMPRESSION) { > + if (IS_SECTION2 (Section)) { > + CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION2 *) Section + 1); > + } > + else { > + CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1); > + } > + > Status = UefiDecompress ( > - (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), > + CompressedData, > DstBuffer, > ScratchBuffer > ); > @@ -397,12 +433,15 @@ FfsProcessSection ( > } > } > > + if (IS_SECTION2 (Section)) { > + SectionLength = SECTION2_SIZE (Section); > + } else { > + SectionLength = 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 = *(UINT32 *)Section->Size & 0x00FFFFFF; > SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4); > ASSERT (SectionLength != 0); > ParsedLength += SectionLength; > -- > 2.15.1 >