From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B2E991A1DED for ; Sun, 23 Oct 2016 21:56:14 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP; 23 Oct 2016 21:56:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,392,1473145200"; d="scan'208";a="22913462" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.9]) by orsmga005.jf.intel.com with ESMTP; 23 Oct 2016 21:56:13 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Liming Gao , Sean Brogan Date: Mon, 24 Oct 2016 12:56:09 +0800 Message-Id: <1477284969-38320-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [PATCH] MdePkg PeiServicesLib: Make sure FvInfo has FFS2 format if FvFormat == NULL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2016 04:56:14 -0000 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=160 Cc: Liming Gao Cc: Sean Brogan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng --- MdePkg/Library/PeiServicesLib/PeiServicesLib.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c index 3428addcc63b..2373251bc3e5 100644 --- a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c +++ b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c @@ -1,7 +1,7 @@ /** @file Implementation for PEI Services Library. - Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -574,6 +574,7 @@ PeiServicesFfsGetVolumeInfo ( the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance. If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI, then ASSERT(). If the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI can not be installed, then ASSERT(). + If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT. @param InstallFvInfoPpi Install FvInfo Ppi if it is TRUE. Otherwise, install FvInfo2 Ppi. @param FvFormat Unique identifier of the format of the memory-mapped @@ -640,6 +641,16 @@ InternalPeiServicesInstallFvInfoPpi ( CopyGuid (&FvInfoPpi->FvFormat, FvFormat); } else { CopyGuid (&FvInfoPpi->FvFormat, &gEfiFirmwareFileSystem2Guid); + // + // Since the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed if NULL is specified for FvFormat, + // check the FileSystemGuid pointed by FvInfo against EFI_FIRMWARE_FILE_SYSTEM2_GUID to make sure + // FvInfo has the firmware file system 2 format. + // If the ASSERT really appears, FvFormat needs to be specified correctly, for example, + // EFI_FIRMWARE_FILE_SYSTEM3_GUID can be used for firmware file system 3 format, or + // &(((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid can be just used for both + // firmware file system 2 and 3 format. + // + ASSERT (CompareGuid (&(((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid), &gEfiFirmwareFileSystem2Guid)); } FvInfoPpi->FvInfo = (VOID *) FvInfo; FvInfoPpi->FvInfoSize = FvInfoSize; @@ -672,6 +683,7 @@ InternalPeiServicesInstallFvInfoPpi ( the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance. If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT(). If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT(). + If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT. @param FvFormat Unique identifier of the format of the memory-mapped firmware volume. This parameter is optional and @@ -714,6 +726,7 @@ PeiServicesInstallFvInfoPpi ( the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance. If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT(). If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT(). + If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT. @param FvFormat Unique identifier of the format of the memory-mapped firmware volume. This parameter is optional and -- 2.7.0.windows.1