- In
c36414b131dfd0a1ca51f10f87a18955bc110ff2 change, it was introduced
the ReadyToBoot event check to prevent the boot service got called
in runtime to cause the issue.
- In this patch introduced the ExitBootService event to replace it.
It would be better to base on the BootService status to decide
the source of ESRT table.
- Based on the BootService availability to decide,
- Exit : Use cache ESRT table in IF-condition
- Not Exit: Use boot service to locate protocol in ELSE-condition
Co-authored-by: Dakota Chiang <dakota.chiang@intel.com>
Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
ValidateFmpCapsule(), and DisplayCapsuleImage() receives untrusted input and\r
performs basic validation.\r
\r
- Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2016 - 2024, Intel Corporation. All rights reserved.<BR>\r
Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
\r
EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress = NULL;\r
\r
-BOOLEAN mDxeCapsuleLibReadyToBootEvent = FALSE;\r
+BOOLEAN mDxeCapsuleLibIsExitBootService = FALSE;\r
\r
/**\r
Initialize capsule related variables.\r
EFI_SYSTEM_RESOURCE_ENTRY Entry;\r
\r
EsrtGuidFound = FALSE;\r
- if (mEsrtTable != NULL) {\r
- EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);\r
- for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {\r
- if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {\r
- EsrtGuidFound = TRUE;\r
- break;\r
+ if (mDxeCapsuleLibIsExitBootService) {\r
+ if (mEsrtTable != NULL) {\r
+ EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);\r
+ for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {\r
+ if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {\r
+ EsrtGuidFound = TRUE;\r
+ break;\r
+ }\r
}\r
}\r
} else {\r
- if (mDxeCapsuleLibReadyToBootEvent) {\r
- //\r
- // The ESRT table (mEsrtTable) in the Configuration Table would be located\r
- // at the ReadyToBoot event if it exists. Hence, it should return here to\r
- // avoid a crash due to calling gBS->LocateProtocol () at runtime in case\r
- // there is no ERST table installed.\r
- //\r
- return FALSE;\r
- }\r
-\r
//\r
// Check ESRT protocol\r
//\r
#include <Library/MemoryAllocationLib.h>\r
\r
extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;\r
+extern BOOLEAN mDxeCapsuleLibIsExitBootService;\r
EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;\r
EFI_EVENT mDxeRuntimeCapsuleLibSystemResourceTableEvent = NULL;\r
-EFI_EVENT mDxeRuntimeCapsuleLibReadyToBootEvent = NULL;\r
-extern BOOLEAN mDxeCapsuleLibReadyToBootEvent;\r
+EFI_EVENT mDxeRuntimeCapsuleLibExitBootServiceEvent = NULL;\r
\r
/**\r
Convert EsrtTable physical address to virtual address.\r
}\r
\r
/**\r
- Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT.\r
+ Notify function for event of exit boot service.\r
\r
@param[in] Event The Event that is being processed.\r
@param[in] Context The Event Context.\r
STATIC\r
VOID\r
EFIAPI\r
-DxeCapsuleLibReadyToBootEventNotify (\r
+DxeCapsuleLibExitBootServiceEventNotify (\r
IN EFI_EVENT Event,\r
IN VOID *Context\r
)\r
{\r
- mDxeCapsuleLibReadyToBootEvent = TRUE;\r
+ mDxeCapsuleLibIsExitBootService = TRUE;\r
}\r
\r
/**\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
- // Register notify function to indicate the event is signaled at ReadyToBoot.\r
+ // Register notify function to indicate the event is signaled at ExitBootService.\r
//\r
Status = gBS->CreateEventEx (\r
EVT_NOTIFY_SIGNAL,\r
TPL_CALLBACK,\r
- DxeCapsuleLibReadyToBootEventNotify,\r
+ DxeCapsuleLibExitBootServiceEventNotify,\r
NULL,\r
- &gEfiEventReadyToBootGuid,\r
- &mDxeRuntimeCapsuleLibReadyToBootEvent\r
+ &gEfiEventExitBootServicesGuid,\r
+ &mDxeRuntimeCapsuleLibExitBootServiceEvent\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
- // Close the ReadyToBoot event.\r
+ // Close the ExitBootService event.\r
//\r
- Status = gBS->CloseEvent (mDxeRuntimeCapsuleLibReadyToBootEvent);\r
+ Status = gBS->CloseEvent (mDxeRuntimeCapsuleLibExitBootServiceEvent);\r
ASSERT_EFI_ERROR (Status);\r
\r
return EFI_SUCCESS;\r
#\r
# Capsule library instance for DXE_RUNTIME_DRIVER module types.\r
#\r
-# Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2016 - 2024, Intel Corporation. All rights reserved.<BR>\r
# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
##\r
gEfiCapsuleReportGuid\r
gEfiCapsuleVendorGuid ## SOMETIMES_CONSUMES ## Variable:L"CapsuleUpdateData"\r
gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event\r
- gEfiEventReadyToBootGuid ## CONSUMES ## Event\r
+ gEfiEventExitBootServicesGuid ## CONSUMES ## Event\r
gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event\r
gEdkiiCapsuleOnDiskNameGuid ## SOMETIMES_CONSUMES ## GUID\r
\r