MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP
authorKinney, Michael D <michael.d.kinney@intel.com>
Wed, 7 Feb 2018 01:43:32 +0000 (17:43 -0800)
committerMichael D Kinney <michael.d.kinney@intel.com>
Mon, 12 Feb 2018 00:35:15 +0000 (16:35 -0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=873

Update IsNestedFmpCapsule() to verify the CapsuleGuid in
the CapsuleHeader against the installed Firmware Management
Protocol instances.  The current logic that uses the ESRT
Table does not work because capsules are processed before
the ESRT Table is published at the Ready To Boot event.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf

index 56c8e98..15dbc00 100644 (file)
@@ -1190,7 +1190,6 @@ IsNestedFmpCapsule (
   )\r
 {\r
   EFI_STATUS                 Status;\r
-  EFI_SYSTEM_RESOURCE_TABLE  *Esrt;\r
   EFI_SYSTEM_RESOURCE_ENTRY  *EsrtEntry;\r
   UINTN                      Index;\r
   BOOLEAN                    EsrtGuidFound;\r
@@ -1198,6 +1197,8 @@ IsNestedFmpCapsule (
   UINTN                      NestedCapsuleSize;\r
   ESRT_MANAGEMENT_PROTOCOL   *EsrtProtocol;\r
   EFI_SYSTEM_RESOURCE_ENTRY  Entry;\r
+  EFI_HANDLE                 *HandleBuffer;\r
+  UINTN                      NumberOfHandles;\r
 \r
   EsrtGuidFound = FALSE;\r
   if (mIsVirtualAddrConverted) {\r
@@ -1223,19 +1224,21 @@ IsNestedFmpCapsule (
     }\r
 \r
     //\r
-    // Check ESRT configuration table\r
+    // Check Firmware Management Protocols\r
     //\r
     if (!EsrtGuidFound) {\r
-      Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt);\r
+      HandleBuffer = NULL;\r
+      Status = GetFmpHandleBufferByType (\r
+                 &CapsuleHeader->CapsuleGuid,\r
+                 0,\r
+                 &NumberOfHandles,\r
+                 &HandleBuffer\r
+                 );\r
       if (!EFI_ERROR(Status)) {\r
-        ASSERT (Esrt != NULL);\r
-        EsrtEntry = (VOID *)(Esrt + 1);\r
-        for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) {\r
-          if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {\r
-            EsrtGuidFound = TRUE;\r
-            break;\r
-          }\r
-        }\r
+        EsrtGuidFound = TRUE;\r
+      }\r
+      if (HandleBuffer != NULL) {\r
+        FreePool (HandleBuffer);\r
       }\r
     }\r
   }\r
index 9eb5033..1d94710 100644 (file)
@@ -73,7 +73,6 @@
 [Guids]\r
   gEfiFmpCapsuleGuid                      ## SOMETIMES_CONSUMES ## GUID\r
   gWindowsUxCapsuleGuid                   ## SOMETIMES_CONSUMES ## GUID\r
-  gEfiSystemResourceTableGuid             ## SOMETIMES_CONSUMES ## GUID\r
   ## SOMETIMES_CONSUMES ## Variable:L"CapsuleMax"\r
   ## SOMETIMES_PRODUCES ## Variable:L"CapsuleMax"\r
   gEfiCapsuleReportGuid\r