]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFrameworkModulePkg FwVolDxe: Get FV auth status propagated from PEI
authorStar Zeng <star.zeng@intel.com>
Tue, 3 Oct 2017 13:33:04 +0000 (21:33 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 10 Oct 2017 12:54:46 +0000 (20:54 +0800)
FV3 HOB was introduced by new (>= 1.5) PI spec, it is intended to
be used to propagate PEI-phase FV authentication status to DXE.
This patch is to update FwVolDxe to get the authentication status
propagated from PEI-phase to DXE by FV3 HOB when producing FV
protocol.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVol.c
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDriver.h
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDxe.inf

index 65a292db6b91ae672addd6e3c8268d27df86131a..91fcd472124444d121561a5bea742ad88c80b7fc 100644 (file)
@@ -4,7 +4,7 @@
   Layers on top of Firmware Block protocol to produce a file abstraction\r
   of FV based files.\r
 \r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2017, 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
@@ -195,7 +195,7 @@ FreeFvDeviceResource (
 /**\r
 \r
   Firmware volume inherits authentication status from the FV image file and section(in another firmware volume)\r
-  where it came from.\r
+  where it came from or propagated from PEI-phase.\r
 \r
   @param  FvDevice              A pointer to the FvDevice.\r
 \r
@@ -205,26 +205,30 @@ FwVolInheritAuthenticationStatus (
   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
+  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
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *Fvb;\r
+  EFI_FVB_ATTRIBUTES_2                  FvbAttributes;\r
+  EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
+  EFI_PEI_HOB_POINTERS                  Fv3Hob;\r
 \r
   if (FvDevice->Fv.ParentHandle != NULL) {\r
+    CachedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvDevice->CachedFv;\r
+\r
     //\r
-    // By Parent Handle, find out the FV image file and section(in another firmware volume) where the firmware volume came from \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
@@ -258,7 +262,7 @@ FwVolInheritAuthenticationStatus (
         if (!EFI_ERROR (Status)) {\r
           if ((FvHeader->FvLength == CachedFvHeader->FvLength) &&\r
               (FvHeader->ExtHeaderOffset == CachedFvHeader->ExtHeaderOffset)) {\r
-            if (FvHeader->ExtHeaderOffset !=0) {\r
+            if (FvHeader->ExtHeaderOffset != 0) {\r
               //\r
               // Both FVs contain extension header, then compare their FV Name GUID\r
               //\r
@@ -292,6 +296,35 @@ FwVolInheritAuthenticationStatus (
         }\r
       } while (TRUE);\r
     }\r
+  } else {\r
+    Fvb = FvDevice->Fvb;\r
+\r
+    Status  = Fvb->GetAttributes (Fvb, &FvbAttributes);\r
+    if (EFI_ERROR (Status)) {\r
+      return;\r
+    }\r
+\r
+    if ((FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {\r
+      //\r
+      // Get volume base address\r
+      //\r
+      Status = Fvb->GetPhysicalAddress (Fvb, &BaseAddress);\r
+      if (EFI_ERROR (Status)) {\r
+        return;\r
+      }\r
+\r
+      //\r
+      // Get the authentication status propagated from PEI-phase to DXE.\r
+      //\r
+      Fv3Hob.Raw = GetHobList ();\r
+      while ((Fv3Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV3, Fv3Hob.Raw)) != NULL) {\r
+        if (Fv3Hob.FirmwareVolume3->BaseAddress == BaseAddress) {\r
+          FvDevice->AuthenticationStatus = Fv3Hob.FirmwareVolume3->AuthenticationStatus;\r
+          return;\r
+        }\r
+        Fv3Hob.Raw = GET_NEXT_HOB (Fv3Hob);\r
+      }\r
+    }\r
   }\r
 }\r
 \r
index b1646dd39edfe0ed751a56b74b0905c2e8e73823..b14a488ead880612d420b9016ec284e91177d7b3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common defines and definitions for a FwVolDxe driver.\r
 \r
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2017, 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
@@ -33,6 +33,7 @@
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/HobLib.h>\r
 \r
 #define FV_DEVICE_SIGNATURE           SIGNATURE_32 ('_', 'F', 'V', '_')\r
 \r
index 057266bb2b680ae34989eaf9ce5da346bd1ed088..6844afb063e77f4f4840519be5767ad5e8575bee 100644 (file)
@@ -4,7 +4,7 @@
 #  This driver produces Firmware Volume2 protocol with full services\r
 #  (read/write, get/set) based on Firmware Volume Block protocol.\r
 #\r
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials are\r
 # licensed and made available under the terms and conditions of the BSD License\r
@@ -55,7 +55,7 @@
   UefiLib\r
   UefiDriverEntryPoint\r
   DebugLib\r
-\r
+  HobLib\r
 \r
 [Guids]\r
   gEfiFirmwareVolumeTopFileGuid                ## CONSUMES ## File # VTF file\r