MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted

If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted
is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when
executing gBS->LocateProtocol () in the else case.

To serve the omitted SetVirtualAddressMap() call, we could just check
mEsrtTable presence instead of relying on mIsVirtualAddrConverted.

Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Nhi Pham 2023-11-23 11:48:54 +07:00 committed by mergify[bot]
parent 38ba4a64c5
commit 466f2f0c5f
2 changed files with 7 additions and 12 deletions

View File

@ -42,7 +42,6 @@
#include <Protocol/DevicePath.h> #include <Protocol/DevicePath.h>
EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable = NULL; EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable = NULL;
BOOLEAN mIsVirtualAddrConverted = FALSE;
BOOLEAN mDxeCapsuleLibEndOfDxe = FALSE; BOOLEAN mDxeCapsuleLibEndOfDxe = FALSE;
EFI_EVENT mDxeCapsuleLibEndOfDxeEvent = NULL; EFI_EVENT mDxeCapsuleLibEndOfDxeEvent = NULL;
@ -1394,7 +1393,6 @@ IsNestedFmpCapsule (
EFI_SYSTEM_RESOURCE_ENTRY Entry; EFI_SYSTEM_RESOURCE_ENTRY Entry;
EsrtGuidFound = FALSE; EsrtGuidFound = FALSE;
if (mIsVirtualAddrConverted) {
if (mEsrtTable != NULL) { if (mEsrtTable != NULL) {
EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1); EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) { for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {
@ -1403,7 +1401,6 @@ IsNestedFmpCapsule (
break; break;
} }
} }
}
} else { } else {
// //
// Check ESRT protocol // Check ESRT protocol

View File

@ -21,7 +21,6 @@
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable; extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
extern BOOLEAN mIsVirtualAddrConverted;
EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL; EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
EFI_EVENT mDxeRuntimeCapsuleLibReadyToBootEvent = NULL; EFI_EVENT mDxeRuntimeCapsuleLibReadyToBootEvent = NULL;
@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent (
) )
{ {
gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable); gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable);
mIsVirtualAddrConverted = TRUE;
} }
/** /**