summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/DxeCapsuleLibFmp
diff options
context:
space:
mode:
authorNhi Pham <nhi@os.amperecomputing.com>2024-05-29 09:46:25 +0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-06-07 15:20:42 +0000
commitc36414b131dfd0a1ca51f10f87a18955bc110ff2 (patch)
treebcadafc509e0ce254b98d024637eb4bfe23fe90c /MdeModulePkg/Library/DxeCapsuleLibFmp
parent948f23417010309a5557d46195eae258f6105025 (diff)
downloadedk2-c36414b131dfd0a1ca51f10f87a18955bc110ff2.zip
edk2-c36414b131dfd0a1ca51f10f87a18955bc110ff2.tar.gz
edk2-c36414b131dfd0a1ca51f10f87a18955bc110ff2.tar.bz2
MdeModulePkg/DxeCapsuleLibFmp: Fix crash if no ESRT is found
The ESRT table is not required in UEFI firmware. In such cases, the table may not be present in the UEFI Configuration Table. The mEsrtTable is to check if the IsNestedFmpCapsule() function is invoked at runtime to determine whether to use gEsrtManagementProtocolGuid or the ESRT table from the Configuration Table. Unfortunately, the check does not cover situations where the ESRT is not present, potentially resulting in a kernel crash. This patch is intended to fix this issue. Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
Diffstat (limited to 'MdeModulePkg/Library/DxeCapsuleLibFmp')
-rw-r--r--MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c13
-rw-r--r--MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c4
2 files changed, 17 insertions, 0 deletions
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 2433c76..36efd64 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -11,6 +11,7 @@
performs basic validation.
Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -48,6 +49,8 @@ EFI_EVENT mDxeCapsuleLibEndOfDxeEvent = NULL;
EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress = NULL;
+extern BOOLEAN mDxeCapsuleLibReadyToBootEvent;
+
/**
Initialize capsule related variables.
**/
@@ -1402,6 +1405,16 @@ IsNestedFmpCapsule (
}
}
} else {
+ if (mDxeCapsuleLibReadyToBootEvent) {
+ //
+ // The ESRT table (mEsrtTable) in the Configuration Table would be located
+ // at the ReadyToBoot event if it exists. Hence, it should return here to
+ // avoid a crash due to calling gBS->LocateProtocol () at runtime in case
+ // there is no ERST table installed.
+ //
+ return FALSE;
+ }
+
//
// Check ESRT protocol
//
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
index 44f30c1..efff714 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
@@ -2,6 +2,7 @@
Capsule library runtime support.
Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -23,6 +24,7 @@
extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
EFI_EVENT mDxeRuntimeCapsuleLibReadyToBootEvent = NULL;
+BOOLEAN mDxeCapsuleLibReadyToBootEvent = FALSE;
/**
Convert EsrtTable physical address to virtual address.
@@ -93,6 +95,8 @@ DxeCapsuleLibReadyToBootEventNotify (
//
mEsrtTable->FwResourceCountMax = mEsrtTable->FwResourceCount;
}
+
+ mDxeCapsuleLibReadyToBootEvent = TRUE;
}
/**