public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guo Dong" <guo.dong@intel.com>
To: "Liu, Zhiguang" <zhiguang.liu@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Ma, Maurice" <maurice.ma@intel.com>,
	"You, Benjamin" <benjamin.you@intel.com>
Subject: Re: [PATCH 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload
Date: Tue, 22 Jun 2021 22:50:58 +0000	[thread overview]
Message-ID: <BYAPR11MB36226D0F295E63329DDEF5839E099@BYAPR11MB3622.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20210620154702.2681-7-zhiguang.liu@intel.com>


Reviewed-by: Guo Dong <guo.dong@intel.com>

> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice <maurice.ma@intel.com>; Dong, Guo
> <guo.dong@intel.com>; You, Benjamin <benjamin.you@intel.com>
> Subject: [PATCH 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal
> Payload
> 
> From gUniversalPayloadExtraDataGuid Guid Hob, get the Dxe FV information,
> and get the Dxe Core from the FV.
> Also, make sure if there are muliple FV hob, the FV hob pointing to this FV
> will be the first in the hob list.
> 
> Cc: Maurice Ma <maurice.ma@intel.com>
> Cc: Guo Dong <guo.dong@intel.com>
> Cc: Benjamin You <benjamin.you@intel.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
>  UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c             | 47
> +++++++++++++++++++++++++++++++++++++++++++++++
>  UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h        | 17
> +++++++++++++++++
>  UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 44
> ++++++++++++++++++++++++++++++++++++++++++--
>  UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  1 +
>  UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c         |  4 ++--
>  5 files changed, 109 insertions(+), 4 deletions(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> index de9dbb0b0e..f5d70c59f8 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> @@ -305,3 +305,50 @@ LoadDxeCore (
> 
> 
>    return EFI_SUCCESS;
> 
>  }
> 
> +
> 
> +/**
> 
> +  Find DXE core from FV and build DXE core HOBs.
> 
> +
> 
> +  @param[in]   DxeFv                 The FV where to find the DXE core.
> 
> +  @param[out]  DxeCoreEntryPoint     DXE core entry point
> 
> +
> 
> +  @retval EFI_SUCCESS        If it completed successfully.
> 
> +  @retval EFI_NOT_FOUND      If it failed to load DXE FV.
> 
> +**/
> 
> +EFI_STATUS
> 
> +UniversalLoadDxeCore (
> 
> +  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
> 
> +  OUT PHYSICAL_ADDRESS           *DxeCoreEntryPoint
> 
> +  )
> 
> +{
> 
> +  EFI_STATUS                  Status;
> 
> +  EFI_FFS_FILE_HEADER         *FileHeader;
> 
> +  VOID                        *PeCoffImage;
> 
> +  EFI_PHYSICAL_ADDRESS        ImageAddress;
> 
> +  UINT64                      ImageSize;
> 
> +
> 
> +  //
> 
> +  // Find DXE core file from DXE FV
> 
> +  //
> 
> +  Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);
> 
> +  if (EFI_ERROR (Status)) {
> 
> +    return Status;
> 
> +  }
> 
> +
> 
> +  Status = FileFindSection (FileHeader, EFI_SECTION_PE32, (VOID
> **)&PeCoffImage);
> 
> +  if (EFI_ERROR (Status)) {
> 
> +    return Status;
> 
> +  }
> 
> +
> 
> +  //
> 
> +  // Get DXE core info
> 
> +  //
> 
> +  Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize,
> DxeCoreEntryPoint);
> 
> +  if (EFI_ERROR (Status)) {
> 
> +    return Status;
> 
> +  }
> 
> +
> 
> +  BuildModuleHob (&FileHeader->Name, ImageAddress,
> EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE,
> *DxeCoreEntryPoint);
> 
> +
> 
> +  return EFI_SUCCESS;
> 
> +}
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> index e9c3ec3073..35098f5141 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> @@ -33,6 +33,8 @@
>  #include <Guid/GraphicsInfoHob.h>
> 
>  #include <UniversalPayload/SmbiosTable.h>
> 
>  #include <UniversalPayload/AcpiTable.h>
> 
> +#include <UniversalPayload/UniversalPayload.h>
> 
> +#include <UniversalPayload/ExtraData.h>
> 
> 
> 
>  #define LEGACY_8259_MASK_REGISTER_MASTER  0x21
> 
>  #define LEGACY_8259_MASK_REGISTER_SLAVE   0xA1
> 
> @@ -117,6 +119,21 @@ LoadDxeCore (
>    OUT PHYSICAL_ADDRESS        *DxeCoreEntryPoint
> 
>    );
> 
> 
> 
> +/**
> 
> +  Find DXE core from FV and build DXE core HOBs.
> 
> +
> 
> +  @param[in]   DxeFv                 The FV where to find the DXE core.
> 
> +  @param[out]  DxeCoreEntryPoint     DXE core entry point
> 
> +
> 
> +  @retval EFI_SUCCESS        If it completed successfully.
> 
> +  @retval EFI_NOT_FOUND      If it failed to load DXE FV.
> 
> +**/
> 
> +EFI_STATUS
> 
> +UniversalLoadDxeCore (
> 
> +  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
> 
> +  OUT PHYSICAL_ADDRESS           *DxeCoreEntryPoint
> 
> +  );
> 
> +
> 
>  /**
> 
>     Transfers control to DxeCore.
> 
> 
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> index 66e87bcb9b..9d59454486 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> @@ -179,7 +179,8 @@ FindAnotherHighestBelow4GResourceDescriptor (
>  **/
> 
>  EFI_STATUS
> 
>  BuildHobs (
> 
> -  IN UINTN                     BootloaderParameter
> 
> +  IN  UINTN                       BootloaderParameter,
> 
> +  OUT EFI_FIRMWARE_VOLUME_HEADER  **DxeFv
> 
>    )
> 
>  {
> 
>    EFI_PEI_HOB_POINTERS             Hob;
> 
> @@ -190,6 +191,10 @@ BuildHobs (
>    EFI_PHYSICAL_ADDRESS             MemoryTop;
> 
>    EFI_HOB_RESOURCE_DESCRIPTOR      *PhitResourceHob;
> 
>    EFI_HOB_RESOURCE_DESCRIPTOR      *ResourceHob;
> 
> +  UNIVERSAL_PAYLOAD_EXTRA_DATA     *ExtraData;
> 
> +  UINT8                            *GuidHob;
> 
> +  EFI_HOB_FIRMWARE_VOLUME          *FvHob;
> 
> +  UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
> 
> 
> 
>    Hob.Raw = (UINT8 *) BootloaderParameter;
> 
>    MinimalNeededSize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
> 
> @@ -254,6 +259,10 @@ BuildHobs (
>    // From now on, mHobList will point to the new Hob range.
> 
>    //
> 
> 
> 
> +  //
> 
> +  // Create an empty FvHob for the DXE FV that contains DXE core.
> 
> +  //
> 
> +  BuildFvHob ((EFI_PHYSICAL_ADDRESS) 0, 0);
> 
>    //
> 
>    // Since payload created new Hob, move all hobs except PHIT from boot
> loader hob list.
> 
>    //
> 
> @@ -265,6 +274,29 @@ BuildHobs (
>      Hob.Raw = GET_NEXT_HOB (Hob);
> 
>    }
> 
> 
> 
> +  //
> 
> +  // Get DXE FV location
> 
> +  //
> 
> +  GuidHob = GetFirstGuidHob(&gUniversalPayloadExtraDataGuid);
> 
> +  ASSERT (GuidHob != NULL);
> 
> +  GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)
> GET_GUID_HOB_DATA (GuidHob);
> 
> +  ASSERT (sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) <=
> GET_GUID_HOB_DATA_SIZE (GuidHob));
> 
> +  ASSERT (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE
> (GuidHob));
> 
> +  ASSERT (GenericHeader->Length >= (sizeof
> (UNIVERSAL_PAYLOAD_EXTRA_DATA) + sizeof
> (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY)));
> 
> +  ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *)
> GET_GUID_HOB_DATA (GuidHob);
> 
> +  ASSERT (ExtraData->Count == 1);
> 
> +  ASSERT (AsciiStrCmp (ExtraData->Entry[0].Identifier, "uefi_fv") == 0);
> 
> +
> 
> +  *DxeFv = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) ExtraData-
> >Entry[0].Base;
> 
> +  ASSERT ((*DxeFv)->FvLength == ExtraData->Entry[0].Size);
> 
> +
> 
> +  //
> 
> +  // Update DXE FV information to first fv hob in the hob list, which
> 
> +  // is the empty FvHob created before.
> 
> +  //
> 
> +  FvHob = GetFirstHob (EFI_HOB_TYPE_FV);
> 
> +  FvHob->BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) *DxeFv;
> 
> +  FvHob->Length = (*DxeFv)->FvLength;
> 
>    return EFI_SUCCESS;
> 
>  }
> 
> 
> 
> @@ -280,10 +312,13 @@ _ModuleEntryPoint (
>    )
> 
>  {
> 
>    EFI_STATUS                    Status;
> 
> +  PHYSICAL_ADDRESS              DxeCoreEntryPoint;
> 
>    EFI_HOB_HANDOFF_INFO_TABLE    *HandoffHobTable;
> 
>    EFI_PEI_HOB_POINTERS          Hob;
> 
> +  EFI_FIRMWARE_VOLUME_HEADER    *DxeFv;
> 
> 
> 
>    mHobList = (VOID *) BootloaderParameter;
> 
> +  DxeFv    = NULL;
> 
>    // Call constructor for all libraries
> 
>    ProcessLibraryConstructorList ();
> 
> 
> 
> @@ -294,7 +329,11 @@ _ModuleEntryPoint (
>    InitializeFloatingPointUnits ();
> 
> 
> 
>    // Build HOB based on information from Bootloader
> 
> -  Status = BuildHobs (BootloaderParameter);
> 
> +  Status = BuildHobs (BootloaderParameter, &DxeFv);
> 
> +  ASSERT_EFI_ERROR (Status);
> 
> +
> 
> +  Status = UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint);
> 
> +  ASSERT_EFI_ERROR (Status);
> 
> 
> 
>    //
> 
>    // Mask off all legacy 8259 interrupt sources
> 
> @@ -304,6 +343,7 @@ _ModuleEntryPoint (
> 
> 
>    HandoffHobTable = (EFI_HOB_HANDOFF_INFO_TABLE *)
> GetFirstHob(EFI_HOB_TYPE_HANDOFF);
> 
>    Hob.HandoffInformationTable = HandoffHobTable;
> 
> +  HandOffToDxeCore (DxeCoreEntryPoint, Hob);
> 
> 
> 
>    // Should not get here
> 
>    CpuDeadLoop ();
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> index 58ff87d969..77cd25aafd 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> @@ -62,6 +62,7 @@
>    gEfiSmbiosTableGuid
> 
>    gEfiAcpiTableGuid
> 
>    gUefiSerialPortInfoGuid
> 
> +  gUniversalPayloadExtraDataGuid
> 
> 
> 
>  [FeaturePcd.IA32]
> 
>    gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode      ##
> CONSUMES
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
> b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
> index 73ea30e7a2..dec87ee1ef 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
> @@ -66,8 +66,8 @@ HandOffToDxeCore (
>    //
> 
>    // Get the address and size of the GHCB pages
> 
>    //
> 
> -  GhcbBase = (VOID *) PcdGet64 (PcdGhcbBase);
> 
> -  GhcbSize = PcdGet64 (PcdGhcbSize);
> 
> +  GhcbBase = 0;
> 
> +  GhcbSize = 0;
> 
> 
> 
>    PageTables = 0;
> 
>    if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {
> 
> --
> 2.16.2.windows.1


  reply	other threads:[~2021-06-22 22:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-20 15:46 [PATCH 00/12] Enable Universal Payload in UefiPayloadPkg Zhiguang Liu
2021-06-20 15:46 ` [PATCH 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload Zhiguang Liu
2021-06-22 22:48   ` Guo Dong
2021-06-20 15:46 ` [PATCH 02/12] MdeModulePkg: Add new structure for the Universal Payload Serial Port Info Zhiguang Liu
2021-06-21 11:09   ` Wu, Hao A
2021-06-20 15:46 ` [PATCH 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload Zhiguang Liu
2021-06-22 22:48   ` Guo Dong
2021-06-20 15:46 ` [PATCH 04/12] UefiPayloadPkg: Update the function definition of HobConstructor Zhiguang Liu
2021-06-22 22:48   ` Guo Dong
2021-06-20 15:46 ` [PATCH 05/12] UefiPayloadPkg: Create separate Payload Entry for UniversalPayload Zhiguang Liu
2021-06-22 22:50   ` Guo Dong
2021-06-20 15:46 ` [PATCH 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload Zhiguang Liu
2021-06-22 22:50   ` Guo Dong [this message]
2021-06-20 15:46 ` [PATCH 07/12] UefiPayloadPkg: Fix up UPL Pcd database Zhiguang Liu
2021-06-22 22:49   ` Guo Dong
2021-06-20 15:46 ` [PATCH 08/12] UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc Zhiguang Liu
2021-06-22 22:51   ` Guo Dong
2021-06-20 15:46 ` [PATCH 09/12] UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for devices Zhiguang Liu
2021-06-22 22:51   ` Guo Dong
2021-06-20 15:47 ` [PATCH 10/12] UefiPayloadPkg: Add macro to disable some drivers Zhiguang Liu
2021-06-22 22:49   ` Guo Dong
2021-06-20 15:47 ` [PATCH 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in UefiPayloadPkg Zhiguang Liu
2021-06-22 22:52   ` Guo Dong
2021-06-20 15:47 ` [PATCH 12/12] UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange " Zhiguang Liu
2021-06-22 22:51   ` Guo Dong

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=BYAPR11MB36226D0F295E63329DDEF5839E099@BYAPR11MB3622.namprd11.prod.outlook.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