public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sunil V L" <sunilvl@ventanamicro.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Erdem Aktas <erdemaktas@google.com>,
	James Bottomley <jejb@linux.ibm.com>, Min Xu <min.m.xu@intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: [edk2-staging/RiscV64QemuVirt PATCH V4 09/34] OvmfPkg/Sec: Refactor to allow other architectures
Date: Fri, 14 Oct 2022 22:18:11 +0530	[thread overview]
Message-ID: <20221014164836.1513036-10-sunilvl@ventanamicro.com> (raw)
In-Reply-To: <20221014164836.1513036-1-sunilvl@ventanamicro.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

Currently, the Sec module supports only X86 architecture.
Refactor the module to allow other CPU architectures.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
 OvmfPkg/Sec/SecMain.inf             |  18 +-
 OvmfPkg/Sec/{ => Ia32X64}/AmdSev.h  |   0
 OvmfPkg/Sec/SecMainCommon.h         |  73 ++++++
 OvmfPkg/Sec/{ => Ia32X64}/AmdSev.c  |   0
 OvmfPkg/Sec/{ => Ia32X64}/SecMain.c | 227 +------------------
 OvmfPkg/Sec/SecMainCommon.c         | 238 ++++++++++++++++++++
 6 files changed, 323 insertions(+), 233 deletions(-)

diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf
index 561a840f29c5..a014bcb4cf1a 100644
--- a/OvmfPkg/Sec/SecMain.inf
+++ b/OvmfPkg/Sec/SecMain.inf
@@ -21,10 +21,12 @@ [Defines]
 #  VALID_ARCHITECTURES           = IA32 X64 EBC
 #
 
-[Sources]
-  SecMain.c
-  AmdSev.c
-  AmdSev.h
+[Sources.IA32, Sources.X64]
+  SecMainCommon.c
+  SecMainCommon.h
+  Ia32X64/SecMain.c
+  Ia32X64/AmdSev.c
+  Ia32X64/AmdSev.h
 
 [Sources.IA32]
   Ia32/SecEntry.nasm
@@ -42,19 +44,21 @@ [LibraryClasses]
   BaseLib
   DebugLib
   BaseMemoryLib
-  PeiServicesLib
   PcdLib
   CpuLib
-  UefiCpuLib
   DebugAgentLib
   IoLib
   PeCoffLib
   PeCoffGetEntryPointLib
   PeCoffExtraActionLib
   ExtractGuidedSectionLib
+  CpuExceptionHandlerLib
+
+[LibraryClasses.IA32, LibraryClasses.X64]
+  UefiCpuLib
   LocalApicLib
   MemEncryptSevLib
-  CpuExceptionHandlerLib
+  PeiServicesLib
   CcProbeLib
 
 [Ppis]
diff --git a/OvmfPkg/Sec/AmdSev.h b/OvmfPkg/Sec/Ia32X64/AmdSev.h
similarity index 100%
rename from OvmfPkg/Sec/AmdSev.h
rename to OvmfPkg/Sec/Ia32X64/AmdSev.h
diff --git a/OvmfPkg/Sec/SecMainCommon.h b/OvmfPkg/Sec/SecMainCommon.h
new file mode 100644
index 000000000000..c3cc16e2c8cf
--- /dev/null
+++ b/OvmfPkg/Sec/SecMainCommon.h
@@ -0,0 +1,73 @@
+/** @file
+  Header file for common functions of Sec.
+
+  Copyright (c) 2022, Ventana Micro Systems Inc. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+  Locates a section within a series of sections
+  with the specified section type.
+
+  The Instance parameter indicates which instance of the section
+  type to return. (0 is first instance, 1 is second...)
+
+  @param[in]   Sections        The sections to search
+  @param[in]   SizeOfSections  Total size of all sections
+  @param[in]   SectionType     The section type to locate
+  @param[in]   Instance        The section instance number
+  @param[out]  FoundSection    The FFS section if found
+
+  @retval EFI_SUCCESS           The file and section was found
+  @retval EFI_NOT_FOUND         The file and section was not found
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
+
+**/
+EFI_STATUS
+FindFfsSectionInstance (
+  IN  VOID                       *Sections,
+  IN  UINTN                      SizeOfSections,
+  IN  EFI_SECTION_TYPE           SectionType,
+  IN  UINTN                      Instance,
+  OUT EFI_COMMON_SECTION_HEADER  **FoundSection
+  );
+
+/**
+  Locates a FFS file with the specified file type and a section
+  within that file with the specified section type.
+
+  @param[in]   Fv            The firmware volume to search
+  @param[in]   FileType      The file type to locate
+  @param[in]   SectionType   The section type to locate
+  @param[out]  FoundSection  The FFS section if found
+
+  @retval EFI_SUCCESS           The file and section was found
+  @retval EFI_NOT_FOUND         The file and section was not found
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
+
+**/
+EFI_STATUS
+FindFfsFileAndSection (
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *Fv,
+  IN  EFI_FV_FILETYPE             FileType,
+  IN  EFI_SECTION_TYPE            SectionType,
+  OUT EFI_COMMON_SECTION_HEADER   **FoundSection
+  );
+
+/**
+  Locates the PEI Core entry point address
+
+  @param[in]  Fv                 The firmware volume to search
+  @param[out] PeiCoreEntryPoint  The entry point of the PEI Core image
+
+  @retval EFI_SUCCESS           The file and section was found
+  @retval EFI_NOT_FOUND         The file and section was not found
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
+
+**/
+EFI_STATUS
+FindPeiCoreImageBaseInFv (
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *Fv,
+  OUT  EFI_PHYSICAL_ADDRESS       *PeiCoreImageBase
+  );
diff --git a/OvmfPkg/Sec/AmdSev.c b/OvmfPkg/Sec/Ia32X64/AmdSev.c
similarity index 100%
rename from OvmfPkg/Sec/AmdSev.c
rename to OvmfPkg/Sec/Ia32X64/AmdSev.c
diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/Ia32X64/SecMain.c
similarity index 75%
rename from OvmfPkg/Sec/SecMain.c
rename to OvmfPkg/Sec/Ia32X64/SecMain.c
index 1167d22a68cc..096bab074f35 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/Ia32X64/SecMain.c
@@ -32,6 +32,7 @@
 #include <Library/PlatformInitLib.h>
 #include <Library/CcProbeLib.h>
 #include "AmdSev.h"
+#include "SecMainCommon.h"
 
 #define SEC_IDT_ENTRY_COUNT  34
 
@@ -143,189 +144,6 @@ FindMainFv (
   } while (TRUE);
 }
 
-/**
-  Locates a section within a series of sections
-  with the specified section type.
-
-  The Instance parameter indicates which instance of the section
-  type to return. (0 is first instance, 1 is second...)
-
-  @param[in]   Sections        The sections to search
-  @param[in]   SizeOfSections  Total size of all sections
-  @param[in]   SectionType     The section type to locate
-  @param[in]   Instance        The section instance number
-  @param[out]  FoundSection    The FFS section if found
-
-  @retval EFI_SUCCESS           The file and section was found
-  @retval EFI_NOT_FOUND         The file and section was not found
-  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
-
-**/
-EFI_STATUS
-FindFfsSectionInstance (
-  IN  VOID                       *Sections,
-  IN  UINTN                      SizeOfSections,
-  IN  EFI_SECTION_TYPE           SectionType,
-  IN  UINTN                      Instance,
-  OUT EFI_COMMON_SECTION_HEADER  **FoundSection
-  )
-{
-  EFI_PHYSICAL_ADDRESS       CurrentAddress;
-  UINT32                     Size;
-  EFI_PHYSICAL_ADDRESS       EndOfSections;
-  EFI_COMMON_SECTION_HEADER  *Section;
-  EFI_PHYSICAL_ADDRESS       EndOfSection;
-
-  //
-  // Loop through the FFS file sections within the PEI Core FFS file
-  //
-  EndOfSection  = (EFI_PHYSICAL_ADDRESS)(UINTN)Sections;
-  EndOfSections = EndOfSection + SizeOfSections;
-  for ( ; ;) {
-    if (EndOfSection == EndOfSections) {
-      break;
-    }
-
-    CurrentAddress = (EndOfSection + 3) & ~(3ULL);
-    if (CurrentAddress >= EndOfSections) {
-      return EFI_VOLUME_CORRUPTED;
-    }
-
-    Section = (EFI_COMMON_SECTION_HEADER *)(UINTN)CurrentAddress;
-
-    Size = SECTION_SIZE (Section);
-    if (Size < sizeof (*Section)) {
-      return EFI_VOLUME_CORRUPTED;
-    }
-
-    EndOfSection = CurrentAddress + Size;
-    if (EndOfSection > EndOfSections) {
-      return EFI_VOLUME_CORRUPTED;
-    }
-
-    //
-    // Look for the requested section type
-    //
-    if (Section->Type == SectionType) {
-      if (Instance == 0) {
-        *FoundSection = Section;
-        return EFI_SUCCESS;
-      } else {
-        Instance--;
-      }
-    }
-  }
-
-  return EFI_NOT_FOUND;
-}
-
-/**
-  Locates a section within a series of sections
-  with the specified section type.
-
-  @param[in]   Sections        The sections to search
-  @param[in]   SizeOfSections  Total size of all sections
-  @param[in]   SectionType     The section type to locate
-  @param[out]  FoundSection    The FFS section if found
-
-  @retval EFI_SUCCESS           The file and section was found
-  @retval EFI_NOT_FOUND         The file and section was not found
-  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
-
-**/
-EFI_STATUS
-FindFfsSectionInSections (
-  IN  VOID                       *Sections,
-  IN  UINTN                      SizeOfSections,
-  IN  EFI_SECTION_TYPE           SectionType,
-  OUT EFI_COMMON_SECTION_HEADER  **FoundSection
-  )
-{
-  return FindFfsSectionInstance (
-           Sections,
-           SizeOfSections,
-           SectionType,
-           0,
-           FoundSection
-           );
-}
-
-/**
-  Locates a FFS file with the specified file type and a section
-  within that file with the specified section type.
-
-  @param[in]   Fv            The firmware volume to search
-  @param[in]   FileType      The file type to locate
-  @param[in]   SectionType   The section type to locate
-  @param[out]  FoundSection  The FFS section if found
-
-  @retval EFI_SUCCESS           The file and section was found
-  @retval EFI_NOT_FOUND         The file and section was not found
-  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
-
-**/
-EFI_STATUS
-FindFfsFileAndSection (
-  IN  EFI_FIRMWARE_VOLUME_HEADER  *Fv,
-  IN  EFI_FV_FILETYPE             FileType,
-  IN  EFI_SECTION_TYPE            SectionType,
-  OUT EFI_COMMON_SECTION_HEADER   **FoundSection
-  )
-{
-  EFI_STATUS            Status;
-  EFI_PHYSICAL_ADDRESS  CurrentAddress;
-  EFI_PHYSICAL_ADDRESS  EndOfFirmwareVolume;
-  EFI_FFS_FILE_HEADER   *File;
-  UINT32                Size;
-  EFI_PHYSICAL_ADDRESS  EndOfFile;
-
-  if (Fv->Signature != EFI_FVH_SIGNATURE) {
-    DEBUG ((DEBUG_ERROR, "FV at %p does not have FV header signature\n", Fv));
-    return EFI_VOLUME_CORRUPTED;
-  }
-
-  CurrentAddress      = (EFI_PHYSICAL_ADDRESS)(UINTN)Fv;
-  EndOfFirmwareVolume = CurrentAddress + Fv->FvLength;
-
-  //
-  // Loop through the FFS files in the Boot Firmware Volume
-  //
-  for (EndOfFile = CurrentAddress + Fv->HeaderLength; ; ) {
-    CurrentAddress = (EndOfFile + 7) & ~(7ULL);
-    if (CurrentAddress > EndOfFirmwareVolume) {
-      return EFI_VOLUME_CORRUPTED;
-    }
-
-    File = (EFI_FFS_FILE_HEADER *)(UINTN)CurrentAddress;
-    Size = FFS_FILE_SIZE (File);
-    if (Size < (sizeof (*File) + sizeof (EFI_COMMON_SECTION_HEADER))) {
-      return EFI_VOLUME_CORRUPTED;
-    }
-
-    EndOfFile = CurrentAddress + Size;
-    if (EndOfFile > EndOfFirmwareVolume) {
-      return EFI_VOLUME_CORRUPTED;
-    }
-
-    //
-    // Look for the request file type
-    //
-    if (File->Type != FileType) {
-      continue;
-    }
-
-    Status = FindFfsSectionInSections (
-               (VOID *)(File + 1),
-               (UINTN)EndOfFile - (UINTN)(File + 1),
-               SectionType,
-               FoundSection
-               );
-    if (!EFI_ERROR (Status) || (Status == EFI_VOLUME_CORRUPTED)) {
-      return Status;
-    }
-  }
-}
-
 /**
   Locates the compressed main firmware volume and decompresses it.
 
@@ -474,49 +292,6 @@ DecompressMemFvs (
   return EFI_SUCCESS;
 }
 
-/**
-  Locates the PEI Core entry point address
-
-  @param[in]  Fv                 The firmware volume to search
-  @param[out] PeiCoreEntryPoint  The entry point of the PEI Core image
-
-  @retval EFI_SUCCESS           The file and section was found
-  @retval EFI_NOT_FOUND         The file and section was not found
-  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
-
-**/
-EFI_STATUS
-FindPeiCoreImageBaseInFv (
-  IN  EFI_FIRMWARE_VOLUME_HEADER  *Fv,
-  OUT  EFI_PHYSICAL_ADDRESS       *PeiCoreImageBase
-  )
-{
-  EFI_STATUS                 Status;
-  EFI_COMMON_SECTION_HEADER  *Section;
-
-  Status = FindFfsFileAndSection (
-             Fv,
-             EFI_FV_FILETYPE_PEI_CORE,
-             EFI_SECTION_PE32,
-             &Section
-             );
-  if (EFI_ERROR (Status)) {
-    Status = FindFfsFileAndSection (
-               Fv,
-               EFI_FV_FILETYPE_PEI_CORE,
-               EFI_SECTION_TE,
-               &Section
-               );
-    if (EFI_ERROR (Status)) {
-      DEBUG ((DEBUG_ERROR, "Unable to find PEI Core image\n"));
-      return Status;
-    }
-  }
-
-  *PeiCoreImageBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(Section + 1);
-  return EFI_SUCCESS;
-}
-
 /**
   Reads 8-bits of CMOS data.
 
diff --git a/OvmfPkg/Sec/SecMainCommon.c b/OvmfPkg/Sec/SecMainCommon.c
new file mode 100644
index 000000000000..f360e63a7c26
--- /dev/null
+++ b/OvmfPkg/Sec/SecMainCommon.c
@@ -0,0 +1,238 @@
+/** @file
+  Locate the entry point for the PEI Core
+
+  Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2020, Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiPei.h>
+#include <Library/DebugLib.h>
+
+/**
+  Locates a section within a series of sections
+  with the specified section type.
+
+  The Instance parameter indicates which instance of the section
+  type to return. (0 is first instance, 1 is second...)
+
+  @param[in]   Sections        The sections to search
+  @param[in]   SizeOfSections  Total size of all sections
+  @param[in]   SectionType     The section type to locate
+  @param[in]   Instance        The section instance number
+  @param[out]  FoundSection    The FFS section if found
+
+  @retval EFI_SUCCESS           The file and section was found
+  @retval EFI_NOT_FOUND         The file and section was not found
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
+
+**/
+EFI_STATUS
+FindFfsSectionInstance (
+  IN  VOID                       *Sections,
+  IN  UINTN                      SizeOfSections,
+  IN  EFI_SECTION_TYPE           SectionType,
+  IN  UINTN                      Instance,
+  OUT EFI_COMMON_SECTION_HEADER  **FoundSection
+  )
+{
+  EFI_PHYSICAL_ADDRESS       CurrentAddress;
+  UINT32                     Size;
+  EFI_PHYSICAL_ADDRESS       EndOfSections;
+  EFI_COMMON_SECTION_HEADER  *Section;
+  EFI_PHYSICAL_ADDRESS       EndOfSection;
+
+  //
+  // Loop through the FFS file sections within the PEI Core FFS file
+  //
+  EndOfSection  = (EFI_PHYSICAL_ADDRESS)(UINTN)Sections;
+  EndOfSections = EndOfSection + SizeOfSections;
+  for ( ; ;) {
+    if (EndOfSection == EndOfSections) {
+      break;
+    }
+
+    CurrentAddress = (EndOfSection + 3) & ~(3ULL);
+    if (CurrentAddress >= EndOfSections) {
+      return EFI_VOLUME_CORRUPTED;
+    }
+
+    Section = (EFI_COMMON_SECTION_HEADER *)(UINTN)CurrentAddress;
+
+    Size = SECTION_SIZE (Section);
+    if (Size < sizeof (*Section)) {
+      return EFI_VOLUME_CORRUPTED;
+    }
+
+    EndOfSection = CurrentAddress + Size;
+    if (EndOfSection > EndOfSections) {
+      return EFI_VOLUME_CORRUPTED;
+    }
+
+    //
+    // Look for the requested section type
+    //
+    if (Section->Type == SectionType) {
+      if (Instance == 0) {
+        *FoundSection = Section;
+        return EFI_SUCCESS;
+      } else {
+        Instance--;
+      }
+    }
+  }
+
+  return EFI_NOT_FOUND;
+}
+
+/**
+  Locates a section within a series of sections
+  with the specified section type.
+
+  @param[in]   Sections        The sections to search
+  @param[in]   SizeOfSections  Total size of all sections
+  @param[in]   SectionType     The section type to locate
+  @param[out]  FoundSection    The FFS section if found
+
+  @retval EFI_SUCCESS           The file and section was found
+  @retval EFI_NOT_FOUND         The file and section was not found
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
+
+**/
+EFI_STATUS
+FindFfsSectionInSections (
+  IN  VOID                       *Sections,
+  IN  UINTN                      SizeOfSections,
+  IN  EFI_SECTION_TYPE           SectionType,
+  OUT EFI_COMMON_SECTION_HEADER  **FoundSection
+  )
+{
+  return FindFfsSectionInstance (
+           Sections,
+           SizeOfSections,
+           SectionType,
+           0,
+           FoundSection
+           );
+}
+
+/**
+  Locates a FFS file with the specified file type and a section
+  within that file with the specified section type.
+
+  @param[in]   Fv            The firmware volume to search
+  @param[in]   FileType      The file type to locate
+  @param[in]   SectionType   The section type to locate
+  @param[out]  FoundSection  The FFS section if found
+
+  @retval EFI_SUCCESS           The file and section was found
+  @retval EFI_NOT_FOUND         The file and section was not found
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
+
+**/
+EFI_STATUS
+FindFfsFileAndSection (
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *Fv,
+  IN  EFI_FV_FILETYPE             FileType,
+  IN  EFI_SECTION_TYPE            SectionType,
+  OUT EFI_COMMON_SECTION_HEADER   **FoundSection
+  )
+{
+  EFI_STATUS            Status;
+  EFI_PHYSICAL_ADDRESS  CurrentAddress;
+  EFI_PHYSICAL_ADDRESS  EndOfFirmwareVolume;
+  EFI_FFS_FILE_HEADER   *File;
+  UINT32                Size;
+  EFI_PHYSICAL_ADDRESS  EndOfFile;
+
+  if (Fv->Signature != EFI_FVH_SIGNATURE) {
+    DEBUG ((DEBUG_ERROR, "FV at %p does not have FV header signature\n", Fv));
+    return EFI_VOLUME_CORRUPTED;
+  }
+
+  CurrentAddress      = (EFI_PHYSICAL_ADDRESS)(UINTN)Fv;
+  EndOfFirmwareVolume = CurrentAddress + Fv->FvLength;
+
+  //
+  // Loop through the FFS files in the Boot Firmware Volume
+  //
+  for (EndOfFile = CurrentAddress + Fv->HeaderLength; ; ) {
+    CurrentAddress = (EndOfFile + 7) & ~(7ULL);
+    if (CurrentAddress > EndOfFirmwareVolume) {
+      return EFI_VOLUME_CORRUPTED;
+    }
+
+    File = (EFI_FFS_FILE_HEADER *)(UINTN)CurrentAddress;
+    Size = FFS_FILE_SIZE (File);
+    if (Size < (sizeof (*File) + sizeof (EFI_COMMON_SECTION_HEADER))) {
+      return EFI_VOLUME_CORRUPTED;
+    }
+
+    EndOfFile = CurrentAddress + Size;
+    if (EndOfFile > EndOfFirmwareVolume) {
+      return EFI_VOLUME_CORRUPTED;
+    }
+
+    //
+    // Look for the request file type
+    //
+    if (File->Type != FileType) {
+      continue;
+    }
+
+    Status = FindFfsSectionInSections (
+               (VOID *)(File + 1),
+               (UINTN)EndOfFile - (UINTN)(File + 1),
+               SectionType,
+               FoundSection
+               );
+    if (!EFI_ERROR (Status) || (Status == EFI_VOLUME_CORRUPTED)) {
+      return Status;
+    }
+  }
+}
+
+/**
+  Locates the PEI Core entry point address
+
+  @param[in]  Fv                 The firmware volume to search
+  @param[out] PeiCoreEntryPoint  The entry point of the PEI Core image
+
+  @retval EFI_SUCCESS           The file and section was found
+  @retval EFI_NOT_FOUND         The file and section was not found
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
+
+**/
+EFI_STATUS
+FindPeiCoreImageBaseInFv (
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *Fv,
+  OUT  EFI_PHYSICAL_ADDRESS       *PeiCoreImageBase
+  )
+{
+  EFI_STATUS                 Status;
+  EFI_COMMON_SECTION_HEADER  *Section;
+
+  Status = FindFfsFileAndSection (
+             Fv,
+             EFI_FV_FILETYPE_PEI_CORE,
+             EFI_SECTION_PE32,
+             &Section
+             );
+  if (EFI_ERROR (Status)) {
+    Status = FindFfsFileAndSection (
+               Fv,
+               EFI_FV_FILETYPE_PEI_CORE,
+               EFI_SECTION_TE,
+               &Section
+               );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Unable to find PEI Core image\n"));
+      return Status;
+    }
+  }
+
+  *PeiCoreImageBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(Section + 1);
+  return EFI_SUCCESS;
+}
-- 
2.38.0


  parent reply	other threads:[~2022-10-14 16:49 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 16:48 [edk2-staging/RiscV64QemuVirt PATCH V4 00/34] Add support for RISC-V virt machine Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 01/34] MdePkg/Register: Add register definition header files for RISC-V Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 02/34] MdePkg: Add RISCV_EFI_BOOT_PROTOCOL related definitions Sunil V L
2022-10-15 13:28   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 03/34] MdePkg/BaseLib: RISC-V: Add few more helper functions Sunil V L
2022-10-15 13:30   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 04/34] MdePkg: Add BaseRiscVSbiLib Library for RISC-V Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 05/34] OvmfPkg/PlatformInitLib: Refactor to allow other architectures Sunil V L
2022-10-15 13:39   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 06/34] OvmfPkg/PlatformInitLib: Add support for RISC-V Sunil V L
2022-10-15 13:35   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 07/34] OvmfPkg/ResetSystemLib: Refactor to allow other architectures Sunil V L
2022-10-15 13:37   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 08/34] OvmfPkg/ResetSystemLib: Add support for RISC-V Sunil V L
2022-10-14 16:48 ` Sunil V L [this message]
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 10/34] OvmfPkg/Sec: Add RISC-V support Sunil V L
2022-10-15 15:50   ` [edk2-devel] " Chang, Abner
2022-10-17  4:53     ` Sunil V L
2022-10-17 11:26       ` Chang, Abner
2022-10-17 11:32   ` Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 11/34] OvmfPkg/PlatformPei: Refactor to allow other architectures Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 12/34] OvmfPkg/PlatformPei: Add support for RISC-V Sunil V L
2022-10-15 16:13   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 13/34] UefiCpuPkg/CpuTimerLib: Refactor to allow other architectures Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 14/34] UefiCpuPkg/CpuTimerLib: Add support for RISC-V Sunil V L
2022-10-16 13:56   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 15/34] UefiCpuPkg/CpuExceptionHandlerLib: Refactor to allow other architectures Sunil V L
2022-10-16 14:00   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 16/34] UefiCpuPkg/CpuExceptionHandlerLib: Add support for RISC-V Sunil V L
2022-10-16 14:06   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 17/34] UefiCpuPkg/CpuDxe: Refactor to allow other architectures Sunil V L
2022-10-16 14:41   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 18/34] UefiCpuPkg/CpuDxe: Add support for RISC-V Sunil V L
2022-10-16 14:26   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 19/34] UefiCpuPkg/CpuDxe: Add RISCV_EFI_BOOT_PROTOCOL support Sunil V L
2022-10-16 14:48   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 20/34] UefiCpuPkg: Add CpuTimerDxe module Sunil V L
2022-10-16 14:53   ` [edk2-devel] " Chang, Abner
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 21/34] ArmVirtPkg/PlatformHasAcpiDtDxe: Move to OvmfPkg Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 22/34] ArmVirtPkg: Fix up the location of PlatformHasAcpiDtDxe Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 23/34] ArmVirtPkg/PlatformBootManagerLib: Move to OvmfPkg Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 24/34] ArmVirtPkg: Fix up the paths to PlatformBootManagerLib Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 25/34] ArmPlatformPkg/NorFlashPlatformLib.h:Move to MdePkg Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 26/34] EmbeddedPkg/NvVarStoreFormattedLib: Migrate to MdeModulePkg Sunil V L
2022-10-19  8:54   ` Ard Biesheuvel
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 27/34] ArmVirtPkg: Update the references to NvVarStoreFormattedLib Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 28/34] OvmfPkg: Add NorFlashQemuLib library Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 29/34] OvmfPkg: Add Qemu NOR flash DXE driver Sunil V L
2022-10-19  9:00   ` Ard Biesheuvel
2022-10-19 12:41     ` Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 30/34] OvmfPkg/NorFlashDxe: Avoid switching to array mode during writes Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 31/34] OvmfPkg/NorFlashDxe: Avoid switching between modes in a tight loop Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 32/34] OvmfPkg: RiscVVirt: Add Qemu Virt platform support Sunil V L
2022-10-22  7:16   ` [edk2-devel] " Chang, Abner
2022-10-24  7:47     ` Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 33/34] Maintainers.txt: Add entry for OvmfPkg/RiscVVirt Sunil V L
2022-10-14 16:48 ` [edk2-staging/RiscV64QemuVirt PATCH V4 34/34] UefiCpuPkg/UefiCpuPkg.ci.yaml: Ignore RISC-V file Sunil V L
2022-10-22  7:01   ` [edk2-devel] " Chang, Abner
2022-10-14 16:50 ` [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V4 00/34] Add support for RISC-V virt machine Ard Biesheuvel
2022-10-14 17:14   ` Sunil V L
2022-10-15  2:33     ` Chang, Abner
     [not found]     ` <171E1D672CB73789.10474@groups.io>
2022-10-22  7:21       ` Chang, Abner

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=20221014164836.1513036-10-sunilvl@ventanamicro.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