]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update DxeCore and FwVolDxe drivers to inherit authentication status for the FV image...
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 29 May 2012 05:22:01 +0000 (05:22 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 29 May 2012 05:22:01 +0000 (05:22 +0000)
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13368 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVol.c
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDriver.h
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolRead.c
MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/Core/Dxe/FwVol/FwVol.c
MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h
MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.h

index c3878968d4201b6259b1d5c3aff571f104c4aa90..1365a5277db310ea3e28c7c5a69427668d932cf0 100644 (file)
@@ -174,6 +174,109 @@ FreeFvDeviceResource (
   return ;\r
 }\r
 \r
+/**\r
+\r
+  Firmware volume inherits authentication status from the FV image file and section(in another firmware volume)\r
+  where it came from.\r
+\r
+  @param  FvDevice              A pointer to the FvDevice.\r
+\r
+**/\r
+VOID\r
+FwVolInheritAuthenticationStatus (\r
+  IN FV_DEVICE  *FvDevice\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_FIRMWARE_VOLUME_HEADER        *CachedFvHeader;\r
+  EFI_FIRMWARE_VOLUME_EXT_HEADER    *CachedFvExtHeader;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL     *ParentFvProtocol;\r
+  UINTN                             Key;\r
+  EFI_GUID                          FileNameGuid;\r
+  EFI_FV_FILETYPE                   FileType;\r
+  EFI_FV_FILE_ATTRIBUTES            FileAttributes;\r
+  UINTN                             FileSize;\r
+  EFI_SECTION_TYPE                  SectionType;\r
+  UINT32                            AuthenticationStatus;\r
+  EFI_FIRMWARE_VOLUME_HEADER        *FvHeader;\r
+  EFI_FIRMWARE_VOLUME_EXT_HEADER    *FvExtHeader;\r
+  UINTN                             BufferSize;\r
+\r
+  CachedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvDevice->CachedFv;\r
+\r
+  if (FvDevice->Fv.ParentHandle != NULL) {\r
+    //\r
+    // By Parent Handle, find out the FV image file and section(in another firmware volume) where the firmware volume came from \r
+    //\r
+    Status = gBS->HandleProtocol (FvDevice->Fv.ParentHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &ParentFvProtocol);\r
+    if (!EFI_ERROR (Status) && (ParentFvProtocol != NULL)) {\r
+      Key = 0;\r
+      do {\r
+        FileType = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE;\r
+        Status = ParentFvProtocol->GetNextFile (\r
+                                     ParentFvProtocol,\r
+                                     &Key,\r
+                                     &FileType,\r
+                                     &FileNameGuid,\r
+                                     &FileAttributes,\r
+                                     &FileSize\r
+                                     );\r
+        if (EFI_ERROR (Status)) {\r
+          return;\r
+        }\r
+\r
+        SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
+        FvHeader = NULL;\r
+        BufferSize = 0;\r
+        Status = ParentFvProtocol->ReadSection (\r
+                                     ParentFvProtocol,\r
+                                     &FileNameGuid,\r
+                                     SectionType,\r
+                                     0,\r
+                                     (VOID **) &FvHeader,\r
+                                     &BufferSize,\r
+                                     &AuthenticationStatus\r
+                                     );\r
+        if (!EFI_ERROR (Status)) {\r
+          if ((FvHeader->FvLength == CachedFvHeader->FvLength) &&\r
+              (FvHeader->ExtHeaderOffset == CachedFvHeader->ExtHeaderOffset)) {\r
+            if (FvHeader->ExtHeaderOffset !=0) {\r
+              //\r
+              // Both FVs contain extension header, then compare their FV Name GUID\r
+              //\r
+              FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINTN) FvHeader + FvHeader->ExtHeaderOffset);\r
+              CachedFvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINTN) CachedFvHeader + CachedFvHeader->ExtHeaderOffset);\r
+              if (CompareGuid (&FvExtHeader->FvName, &CachedFvExtHeader->FvName)) {\r
+                //\r
+                // Found the FV image section where the firmware volume came from,\r
+                // and then inherit authentication status from it.\r
+                //\r
+                FvDevice->AuthenticationStatus = AuthenticationStatus;\r
+                FreePool ((VOID *) FvHeader);\r
+                return;\r
+              }\r
+            } else {\r
+              //\r
+              // Both FVs don't contain extension header, then compare their whole FV Image.\r
+              //\r
+              if (CompareMem ((VOID *) FvHeader, (VOID *) CachedFvHeader, FvHeader->FvLength) == 0) {\r
+                //\r
+                // Found the FV image section where the firmware volume came from\r
+                // and then inherit authentication status from it.\r
+                //\r
+                FvDevice->AuthenticationStatus = AuthenticationStatus;\r
+                FreePool ((VOID *) FvHeader);\r
+                return;\r
+              }\r
+            }\r
+          }\r
+          FreePool ((VOID *) FvHeader);\r
+        }\r
+      } while (TRUE);\r
+    }\r
+  }\r
+}\r
+\r
 /**\r
   Check if an FV is consistent and allocate cache for it.\r
 \r
@@ -612,6 +715,7 @@ FwVolDriverInit (
     FvDevice->Fv.KeySize              = KEYSIZE;\r
     FvDevice->Fv.GetInfo              = FvGetVolumeInfo;\r
     FvDevice->Fv.SetInfo              = FvSetVolumeInfo;\r
+    FvDevice->Fv.ParentHandle         = Fvb->ParentHandle;\r
 \r
     Status = FvCheck (FvDevice);\r
     if (EFI_ERROR (Status)) {\r
@@ -622,6 +726,8 @@ FwVolDriverInit (
       continue;\r
     }\r
 \r
+    FwVolInheritAuthenticationStatus (FvDevice);\r
+\r
     if (Reinstall) {\r
       //\r
       // Reinstall an New FV protocol\r
index 2de65f511d3182bb956ce41a6ce6b4d12e3a21bc..e424f9572da61069affc6dcedf1e9ce7af30e01d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common defines and definitions for a FwVolDxe driver.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -94,6 +94,7 @@ typedef struct {
 \r
   FFS_FILE_LIST_ENTRY                 *CurrentFfsFile;\r
   BOOLEAN                             IsFfs3Fv;\r
+  UINT32                              AuthenticationStatus;\r
 } FV_DEVICE;\r
 \r
 #define FV_DEVICE_FROM_THIS(a)  CR (a, FV_DEVICE, Fv, FV_DEVICE_SIGNATURE)\r
index 1e8ba91581fe2a8ab3626e68cea5217af91be9f3..8e2706bb8a72866c37df30ec15be4e467d41ce16 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements functions to read firmware file.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -510,6 +510,7 @@ FvReadFileSection (
   )\r
 {\r
   EFI_STATUS                      Status;\r
+  FV_DEVICE                       *FvDevice;\r
   EFI_FV_ATTRIBUTES               FvAttributes;\r
   EFI_FV_FILETYPE                 FileType;\r
   EFI_FV_FILE_ATTRIBUTES          FileAttributes;\r
@@ -522,6 +523,8 @@ FvReadFileSection (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  FvDevice  = FV_DEVICE_FROM_THIS (This);\r
+\r
   Status    = This->GetVolumeAttributes (This, &FvAttributes);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -607,6 +610,14 @@ FvReadFileSection (
                     AuthenticationStatus\r
                     );\r
   }\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Inherit the authentication status.\r
+    //\r
+    *AuthenticationStatus |= FvDevice->AuthenticationStatus;\r
+  }\r
+\r
   //\r
   // Handle AuthenticationStatus if necessary\r
   //\r
index 476c8b39adc9478acf651f2f771750ea4f9562eb..3a7e0db37ebbb58bdcee008c9e3d2ca6f0a50cf8 100644 (file)
@@ -26,7 +26,7 @@
   Depex - Dependency Expresion.\r
   SOR   - Schedule On Request - Don't schedule if this bit is set.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1039,6 +1039,7 @@ CoreProcessFvImageFile (
                 (EFI_PHYSICAL_ADDRESS) (UINTN) AlignedBuffer,\r
                 (UINT64)BufferSize,\r
                 FvHandle,\r
+                AuthenticationStatus,\r
                 NULL\r
                 );\r
     }\r
index 4ec895c0a228aa3d772708b999f90b00e5534336..dedb84047f8e7e65e3f7e76dc7b1dba86f06b283 100644 (file)
@@ -2429,6 +2429,19 @@ FwVolBlockDriverInit (
   IN EFI_SYSTEM_TABLE           *SystemTable\r
   );\r
 \r
+/**\r
+\r
+  Get FVB authentication status\r
+\r
+  @param FvbProtocol    FVB protocol.\r
+\r
+  @return Authentication status.\r
+\r
+**/\r
+UINT32\r
+GetFvbAuthenticationStatus (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *FvbProtocol\r
+  );\r
 \r
 /**\r
   This routine produces a firmware volume block protocol on a given\r
@@ -2437,8 +2450,10 @@ FwVolBlockDriverInit (
   @param  BaseAddress            base address of the firmware volume image\r
   @param  Length                 length of the firmware volume image\r
   @param  ParentHandle           handle of parent firmware volume, if this image\r
-                                 came from an FV image file in another firmware\r
+                                 came from an FV image file and section in another firmware\r
                                  volume (ala capsules)\r
+  @param  AuthenticationStatus   Authentication status inherited, if this image\r
+                                 came from an FV image file and section in another firmware volume.\r
   @param  FvProtocol             Firmware volume block protocol produced.\r
 \r
   @retval EFI_VOLUME_CORRUPTED   Volume corrupted.\r
@@ -2452,6 +2467,7 @@ ProduceFVBProtocolOnBuffer (
   IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
   IN UINT64                 Length,\r
   IN EFI_HANDLE             ParentHandle,\r
+  IN UINT32                 AuthenticationStatus,\r
   OUT EFI_HANDLE            *FvProtocol  OPTIONAL\r
   );\r
 \r
index 1cee6a9ba0e3dca053562a44444e56b2a4a98a3d..9355e52ab068179760e6e19bcbc2ec6b7564cb8e 100644 (file)
@@ -45,6 +45,8 @@ FV_DEVICE mFvDevice = {
   NULL,\r
   NULL,\r
   { NULL, NULL },\r
+  0,\r
+  FALSE,\r
   0\r
 };\r
 \r
@@ -638,8 +640,15 @@ NotifyFwVolBlock (
       FvDevice->Fvb             = Fvb;\r
       FvDevice->Handle          = Handle;\r
       FvDevice->FwVolHeader     = FwVolHeader;\r
-      FvDevice->Fv.ParentHandle = Fvb->ParentHandle;\r
       FvDevice->IsFfs3Fv        = CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid);\r
+      FvDevice->Fv.ParentHandle = Fvb->ParentHandle;\r
+\r
+      if (Fvb->ParentHandle != NULL) {\r
+        //\r
+        // Inherit the authentication status from FVB.\r
+        //\r
+        FvDevice->AuthenticationStatus = GetFvbAuthenticationStatus (Fvb);\r
+      }\r
       \r
       if (!EFI_ERROR (FvCheck (FvDevice))) {\r
         //\r
index 31d15120eba9adb2329a3718285c188f73ee10ae..4986792edd443db8aa26f4117518761da471b1c9 100644 (file)
@@ -44,6 +44,7 @@ typedef struct {
 \r
   UINT8                                   ErasePolarity;\r
   BOOLEAN                                 IsFfs3Fv;\r
+  UINT32                                  AuthenticationStatus;\r
 } FV_DEVICE;\r
 \r
 #define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)\r
index fc1a2e5fae4aa7c29f9f8c53a03b08ce228f41ff..b5a0d874f05fb652fc011101c4cc906c99c2b1e4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements functions to read firmware file\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -484,6 +484,13 @@ FvReadFileSection (
              FvDevice->IsFfs3Fv\r
              );\r
 \r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Inherit the authentication status.\r
+    //\r
+    *AuthenticationStatus |= FvDevice->AuthenticationStatus;\r
+  }\r
+\r
   //\r
   // Close of stream defered to close of FfsHeader list to allow SEP to cache data\r
   //\r
index f44310f8ef323707b7084c78eed1e5196b533abe..523738d52da849884d3d30fcfecde7f21ca9bd1d 100644 (file)
@@ -4,7 +4,7 @@
   It consumes FV HOBs and creates read-only Firmare Volume Block protocol\r
   instances for each of them.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -81,6 +81,7 @@ EFI_FW_VOL_BLOCK_DEVICE  mFwVolBlock = {
   0,\r
   NULL,\r
   0,\r
+  0,\r
   0\r
 };\r
 \r
@@ -402,7 +403,31 @@ FwVolBlockGetBlockSize (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  Get FVB authentication status\r
+\r
+  @param FvbProtocol    FVB protocol.\r
 \r
+  @return Authentication status.\r
+\r
+**/\r
+UINT32\r
+GetFvbAuthenticationStatus (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *FvbProtocol\r
+  )\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE   *FvbDevice;\r
+  UINT32                    AuthenticationStatus;\r
+\r
+  AuthenticationStatus = 0;\r
+  FvbDevice = BASE_CR (FvbProtocol, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance);\r
+  if (FvbDevice->Signature == FVB_DEVICE_SIGNATURE) {\r
+    AuthenticationStatus = FvbDevice->AuthenticationStatus;\r
+  }\r
+\r
+  return AuthenticationStatus;\r
+}\r
 \r
 /**\r
   This routine produces a firmware volume block protocol on a given\r
@@ -411,8 +436,10 @@ FwVolBlockGetBlockSize (
   @param  BaseAddress            base address of the firmware volume image\r
   @param  Length                 length of the firmware volume image\r
   @param  ParentHandle           handle of parent firmware volume, if this image\r
-                                 came from an FV image file in another firmware\r
+                                 came from an FV image file and section in another firmware\r
                                  volume (ala capsules)\r
+  @param  AuthenticationStatus   Authentication status inherited, if this image\r
+                                 came from an FV image file and section in another firmware volume.\r
   @param  FvProtocol             Firmware volume block protocol produced.\r
 \r
   @retval EFI_VOLUME_CORRUPTED   Volume corrupted.\r
@@ -426,6 +453,7 @@ ProduceFVBProtocolOnBuffer (
   IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
   IN UINT64                 Length,\r
   IN EFI_HANDLE             ParentHandle,\r
+  IN UINT32                 AuthenticationStatus,\r
   OUT EFI_HANDLE            *FvProtocol  OPTIONAL\r
   )\r
 {\r
@@ -473,6 +501,9 @@ ProduceFVBProtocolOnBuffer (
   FvbDev->BaseAddress   = BaseAddress;\r
   FvbDev->FvbAttributes = FwVolHeader->Attributes;\r
   FvbDev->FwVolBlockInstance.ParentHandle = ParentHandle;\r
+  if (ParentHandle != NULL) {\r
+    FvbDev->AuthenticationStatus = AuthenticationStatus;\r
+  }\r
 \r
   //\r
   // Init the block caching fields of the device\r
@@ -587,7 +618,7 @@ FwVolBlockDriverInit (
     //\r
     // Produce an FVB protocol for it\r
     //\r
-    ProduceFVBProtocolOnBuffer (FvHob.FirmwareVolume->BaseAddress, FvHob.FirmwareVolume->Length, NULL, NULL);\r
+    ProduceFVBProtocolOnBuffer (FvHob.FirmwareVolume->BaseAddress, FvHob.FirmwareVolume->Length, NULL, 0, NULL);\r
     FvHob.Raw = GET_NEXT_HOB (FvHob);\r
   }\r
 \r
@@ -629,6 +660,7 @@ CoreProcessFirmwareVolume (
             (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,\r
             (UINT64)Size,\r
             NULL,\r
+            0,\r
             FVProtocolHandle\r
             );\r
   //\r
index d269ccfbe6945c622ec01a3db5874f1a26314a95..7ad4e35ecb346687fa90ea58186e12942f12edb0 100644 (file)
@@ -2,7 +2,7 @@
   Firmware Volume Block protocol functions.\r
   Consumes FV hobs and creates appropriate block protocols.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -47,6 +47,7 @@ typedef struct {
   LBA_CACHE                             *LbaCache;\r
   UINT32                                FvbAttributes;\r
   EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
+  UINT32                                AuthenticationStatus;\r
 } EFI_FW_VOL_BLOCK_DEVICE;\r
 \r
 \r