]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098)
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
index 56b3bd85793d168a40fbc69a4e972c7b785dffa6..6d95a5d32c784b1759263cc13bbff3d9e2366c0b 100644 (file)
@@ -394,6 +394,41 @@ PeimDispatchReadiness (
   IN VOID               *DependencyExpression\r
   );\r
 \r
+/**\r
+  Migrate a PEIM from temporary RAM to permanent memory.\r
+\r
+  @param PeimFileHandle       Pointer to the FFS file header of the image.\r
+  @param MigratedFileHandle   Pointer to the FFS file header of the migrated image.\r
+\r
+  @retval EFI_SUCCESS         Sucessfully migrated the PEIM to permanent memory.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MigratePeim (\r
+  IN  EFI_PEI_FILE_HANDLE     FileHandle,\r
+  IN  EFI_PEI_FILE_HANDLE     MigratedFileHandle\r
+  );\r
+\r
+/**\r
+  Migrate FVs out of temporary RAM before the cache is flushed.\r
+\r
+  @param Private         PeiCore's private data structure\r
+  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
+                         environment, such as the size and location of temporary RAM, the stack location and\r
+                         the BFV location.\r
+\r
+  @retval EFI_SUCCESS           Succesfully migrated installed FVs from temporary RAM to permanent memory.\r
+  @retval EFI_OUT_OF_RESOURCES  Insufficient memory exists to allocate needed pages.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EvacuateTempRam (\r
+  IN PEI_CORE_INSTANCE            *Private,\r
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
+  );\r
+\r
 /**\r
   Conduct PEIM dispatch.\r
 \r
@@ -477,6 +512,50 @@ ConvertPpiPointers (
   IN PEI_CORE_INSTANCE           *PrivateData\r
   );\r
 \r
+/**\r
+\r
+  Migrate Notify Pointers inside an FV from temporary memory to permanent memory.\r
+\r
+  @param PrivateData      Pointer to PeiCore's private data structure.\r
+  @param OrgFvHandle      Address of FV Handle in temporary memory.\r
+  @param FvHandle         Address of FV Handle in permanent memory.\r
+  @param FvSize           Size of the FV.\r
+\r
+**/\r
+VOID\r
+ConvertPpiPointersFv (\r
+  IN  PEI_CORE_INSTANCE       *PrivateData,\r
+  IN  UINTN                   OrgFvHandle,\r
+  IN  UINTN                   FvHandle,\r
+  IN  UINTN                   FvSize\r
+  );\r
+\r
+/**\r
+\r
+  Migrate PPI Pointers of PEI_CORE from temporary memory to permanent memory.\r
+\r
+  @param PrivateData      Pointer to PeiCore's private data structure.\r
+  @param CoreFvHandle     Address of PEI_CORE FV Handle in temporary memory.\r
+\r
+**/\r
+VOID\r
+ConvertPeiCorePpiPointers (\r
+  IN  PEI_CORE_INSTANCE        *PrivateData,\r
+  PEI_CORE_FV_HANDLE           CoreFvHandle\r
+  );\r
+\r
+/**\r
+\r
+  Dumps the PPI lists to debug output.\r
+\r
+  @param PrivateData     Points to PeiCore's private instance data.\r
+\r
+**/\r
+VOID\r
+DumpPpiList (\r
+  IN PEI_CORE_INSTANCE    *PrivateData\r
+  );\r
+\r
 /**\r
 \r
   Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.\r
@@ -808,6 +887,37 @@ PeiFfsFindNextFile (
   IN OUT EFI_PEI_FILE_HANDLE     *FileHandle\r
   );\r
 \r
+/**\r
+  Go through the file to search SectionType section.\r
+  Search within encapsulation sections (compression and GUIDed) recursively,\r
+  until the match section is found.\r
+\r
+  @param PeiServices          An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param SectionType          Filter to find only section of this type.\r
+  @param SectionInstance      Pointer to the filter to find the specific instance of section.\r
+  @param Section              From where to search.\r
+  @param SectionSize          The file size to search.\r
+  @param OutputBuffer         A pointer to the discovered section, if successful.\r
+                              NULL if section not found.\r
+  @param AuthenticationStatus Updated upon return to point to the authentication status for this section.\r
+  @param IsFfs3Fv             Indicates the FV format.\r
+\r
+  @return EFI_NOT_FOUND       The match section is not found.\r
+  @return EFI_SUCCESS         The match section is found.\r
+\r
+**/\r
+EFI_STATUS\r
+ProcessSection (\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN OUT UINTN                  *SectionInstance,\r
+  IN EFI_COMMON_SECTION_HEADER  *Section,\r
+  IN UINTN                      SectionSize,\r
+  OUT VOID                      **OutputBuffer,\r
+  OUT UINT32                    *AuthenticationStatus,\r
+  IN BOOLEAN                    IsFfs3Fv\r
+  );\r
+\r
 /**\r
   Searches for the next matching section within the specified file.\r
 \r
@@ -931,6 +1041,33 @@ MigrateMemoryPages (
   IN BOOLEAN                TemporaryRamMigrated\r
   );\r
 \r
+/**\r
+  Removes any FV HOBs whose base address is not in PEI installed memory.\r
+\r
+  @param[in] Private          Pointer to PeiCore's private data structure.\r
+\r
+**/\r
+VOID\r
+RemoveFvHobsInTemporaryMemory (\r
+  IN PEI_CORE_INSTANCE        *Private\r
+  );\r
+\r
+/**\r
+  Migrate the base address in firmware volume allocation HOBs\r
+  from temporary memory to PEI installed memory.\r
+\r
+  @param[in] PrivateData      Pointer to PeiCore's private data structure.\r
+  @param[in] OrgFvHandle      Address of FV Handle in temporary memory.\r
+  @param[in] FvHandle         Address of FV Handle in permanent memory.\r
+\r
+**/\r
+VOID\r
+ConvertFvHob (\r
+  IN PEI_CORE_INSTANCE          *PrivateData,\r
+  IN UINTN                      OrgFvHandle,\r
+  IN UINTN                      FvHandle\r
+  );\r
+\r
 /**\r
   Migrate MemoryBaseAddress in memory allocation HOBs\r
   from the temporary memory to PEI installed memory.\r
@@ -1249,6 +1386,38 @@ InitializeImageServices (
   IN  PEI_CORE_INSTANCE   *OldCoreData\r
   );\r
 \r
+/**\r
+  Loads and relocates a PE/COFF image in place.\r
+\r
+  @param Pe32Data         The base address of the PE/COFF file that is to be loaded and relocated\r
+  @param ImageAddress     The base address of the relocated PE/COFF image\r
+\r
+  @retval EFI_SUCCESS     The file was loaded and relocated\r
+  @retval Others          The file not be loaded and error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+LoadAndRelocatePeCoffImageInPlace (\r
+  IN  VOID    *Pe32Data,\r
+  IN  VOID    *ImageAddress\r
+  );\r
+\r
+/**\r
+  Find the PE32 Data for an FFS file.\r
+\r
+  @param FileHandle       Pointer to the FFS file header of the image.\r
+  @param Pe32Data         Pointer to a (VOID *) PE32 Data pointer.\r
+\r
+  @retval EFI_SUCCESS      Image is successfully loaded.\r
+  @retval EFI_NOT_FOUND    Fail to locate PE32 Data.\r
+\r
+**/\r
+EFI_STATUS\r
+PeiGetPe32Data (\r
+  IN     EFI_PEI_FILE_HANDLE          FileHandle,\r
+  OUT    VOID                         **Pe32Data\r
+  );\r
+\r
 /**\r
   The wrapper function of PeiLoadImageLoadImage().\r
 \r