public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "Chiu, Chasel" <chasel.chiu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>,
	"Wu, Hao A" <hao.a.wu@intel.com>,
	 "Zeng, Star" <star.zeng@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH 2/3] MdeModulePkg/PeiMain: Support EFI_PEI_CORE_FV_LOCATION_PPI
Date: Thu, 14 Feb 2019 08:20:26 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C0197FD@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20190212131957.2576-3-chasel.chiu@intel.com>

Sorry, please ignore my other review mail and just check this mail.
3 minor comments below.

> -----Original Message-----
> From: Chiu, Chasel <chasel.chiu@intel.com>
> Sent: Tuesday, February 12, 2019 9:20 PM
> To: edk2-devel@lists.01.org
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Ni, Ray <ray.ni@intel.com>; Zeng, Star <star.zeng@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
> Subject: [PATCH 2/3] MdeModulePkg/PeiMain: Support
> EFI_PEI_CORE_FV_LOCATION_PPI
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1524
> 
> When shadowing PeiCore the EFI_PEI_CORE_FV_LOCATION_PPI should be
> checked to see if PeiCore not in BFV, otherwise just shadowing PeiCore from
> BFV.
> 
> Test: Verified on internal platform and booting successfully.
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
>  MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 58
> +++++++++++++++++++++++++++++++++++++++++++++-------------
>  MdeModulePkg/Core/Pei/PeiMain.h         |  3 ++-
>  MdeModulePkg/Core/Pei/PeiMain.inf       |  3 ++-
>  3 files changed, 49 insertions(+), 15 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> index 4da80a8222..408f24c216 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Pei Core Main Entry Point
> 
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>  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
> @@ -80,23 +80,55 @@ ShadowPeiCore (
>    IN PEI_CORE_INSTANCE  *PrivateData
>    )
>  {
> -  EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;
> -  EFI_PHYSICAL_ADDRESS EntryPoint;
> -  EFI_STATUS           Status;
> -  UINT32               AuthenticationState;
> +  EFI_PEI_FILE_HANDLE          PeiCoreFileHandle;
> +  EFI_PHYSICAL_ADDRESS         EntryPoint;
> +  EFI_STATUS                   Status;
> +  UINT32                       AuthenticationState;
> +  UINTN                        Index;
> +  EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
> 
>    PeiCoreFileHandle = NULL;
> 
>    //
> -  // Find the PEI Core in the BFV
> +  // Find the PEI Core either from EFI_PEI_CORE_FV_LOCATION_PPI
> + indicated FV or BFV
>    //
> -  Status = PrivateData->Fv[0].FvPpi->FindFileByType (
> -                                       PrivateData->Fv[0].FvPpi,
> -                                       EFI_FV_FILETYPE_PEI_CORE,
> -                                       PrivateData->Fv[0].FvHandle,
> -                                       &PeiCoreFileHandle
> -                                       );
> -  ASSERT_EFI_ERROR (Status);
> +  Status = PeiServicesLocatePpi (
> +             &gEfiPeiCoreFvLocationPpiGuid,
> +             0,
> +             NULL,
> +             (VOID **) &PeiCoreFvLocationPpi
> +             );
> +  if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation !=
> NULL)) {
> +    //
> +    // If PeiCoreFvLocation present, the PEI Core should be found from
> indicated FV.
> +    //
> +    for (Index = 0; Index < PrivateData->FvCount; Index ++) {
> +      if ((UINT32) PrivateData->Fv[Index].FvHandle != (UINT32)
> PeiCoreFvLocationPpi->PeiCoreFvLocation) {
> +        continue;
> +      }
> +      Status = PrivateData->Fv[Index].FvPpi->FindFileByType (
> +                                               PrivateData->Fv[Index].FvPpi,
> +                                               EFI_FV_FILETYPE_PEI_CORE,
> +                                               PrivateData->Fv[Index].FvHandle,
> +                                               &PeiCoreFileHandle
> +                                               );
> +      if (!EFI_ERROR (Status)) {
> +        break;
1. Is it valid that PEI_CORE cannot be found in the PeiCoreFvLocation?
If no, why not assert here?

> +      }
> +    }
> +    ASSERT (Index < PrivateData->FvCount);  } else {
> +    //
> +    // Find PEI Core from BFV
> +    //
> +    Status = PrivateData->Fv[0].FvPpi->FindFileByType (
> +                                         PrivateData->Fv[0].FvPpi,
> +                                         EFI_FV_FILETYPE_PEI_CORE,
> +                                         PrivateData->Fv[0].FvHandle,
> +                                         &PeiCoreFileHandle
> +                                         );
> +    ASSERT_EFI_ERROR (Status);

2. Seems to have code duplication here. Can we have a local PeiCoreFvIndex to be 0 as default?
And when the gEfiPeiCoreFvLocationPpiGuid PPI exists, PeiCoreFvIndex is updated to the correct value.
So that FindFileByType() is only used once in source code with first parameter
PrivateData->Fv[PeiCoreFvIndex].FvPpi.

> +  }
> 
>    //
>    // Shadow PEI Core into memory so it will run faster diff --git
> a/MdeModulePkg/Core/Pei/PeiMain.h
> b/MdeModulePkg/Core/Pei/PeiMain.h index 322e7cd845..38542ab072
> 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.h
> +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> @@ -1,7 +1,7 @@
>  /** @file
>    Definition of Pei Core Structures and Services
> 
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>  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
> @@ -49,6 +49,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
>  #include <Guid/FirmwareFileSystem2.h>
>  #include <Guid/FirmwareFileSystem3.h>
>  #include <Guid/AprioriFileName.h>
> +#include <Ppi/PeiCoreFvLocation.h>

3. please move the #include adjacent to other #include<Ppi/*>

> 
>  ///
>  /// It is an FFS type extension used for PeiFindFileEx. It indicates current diff
> --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index 140c4444b1..5bab2aab8c 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -6,7 +6,7 @@
>  # 2) Dispatch PEIM from discovered FV.
>  # 3) Handoff control to DxeIpl to load DXE core and enter DXE phase.
>  #
> -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2006 - 2019, Intel Corporation. All rights
> +reserved.<BR>
>  #
>  #  This program and the accompanying materials  #  are licensed and made
> available under the terms and conditions of the BSD License @@ -102,6
> +102,7 @@
>    gEfiTemporaryRamDonePpiGuid                   ## SOMETIMES_CONSUMES
>    gEfiPeiReset2PpiGuid                          ## SOMETIMES_CONSUMES
>    gEfiSecHobDataPpiGuid                         ## SOMETIMES_CONSUMES
> +  gEfiPeiCoreFvLocationPpiGuid                  ## SOMETIMES_CONSUMES
> 
>  [Pcd]
>    gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize
> ## CONSUMES
> --
> 2.13.3.windows.1



  parent reply	other threads:[~2019-02-14  8:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 13:19 [PATCH 0/3] Support EFI_PEI_CORE_FV_LOCATION_PPI Chasel, Chiu
2019-02-12 13:19 ` [PATCH 1/3] MdePkg: " Chasel, Chiu
2019-02-13  9:20   ` Zeng, Star
2019-02-14  8:06   ` Ni, Ray
2019-02-12 13:19 ` [PATCH 2/3] MdeModulePkg/PeiMain: " Chasel, Chiu
2019-02-13  1:14   ` Wang, Jian J
2019-02-13  3:58     ` Chiu, Chasel
2019-02-13  9:33       ` Zeng, Star
2019-02-14  8:13   ` Ni, Ray
2019-02-14  8:20   ` Ni, Ray [this message]
2019-02-14 10:32     ` Chiu, Chasel
2019-02-12 13:19 ` [PATCH 3/3] UefiCpuPkg/SecCore: " Chasel, Chiu
2019-02-12 13:57   ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=734D49CCEBEEF84792F5B80ED585239D5C0197FD@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox