From b3441e01003ab91df816263df98f9675b2cd2aa1 Mon Sep 17 00:00:00 2001 From: Jason1 Lin Date: Mon, 15 Jul 2024 22:29:40 +0800 Subject: [PATCH] MdeModulePkg/Core/DxeIplPeim: Enhance Code in DxeIplFindDxeCore Function REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4653 In DxeIplFindDxeCore function, there exists different behavior between Debug and Release built BIOS. This change is used to unify both of the code flow and fix the potential overflow of "Instance" variable. In this change, [1] Move the ASSERT_EFI_ERROR (Status) in failure to find DxeCore in any firmware volume condition. [2] Break the while-loop when not found required DxeCore. This would make the Instance variable not overflow in while-loop. [3] Add the CpuDeadLoop () in the end of the function and do not return since DxeCore is mandatory for the following booting to hand-off the PEI phase to DXE phase. [4] In case of the CpuDeadLoop () is de-assert by debugger, return the NULL pointer. Signed-off-by: Jason1 Lin --- MdeModulePkg/Core/DxeIplPeim/DxeLoad.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c index 2c19f1a507..933b245036 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c +++ b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c @@ -3,7 +3,7 @@ Responsibility of this module is to load the DXE Core from a Firmware Volume. Copyright (c) 2016 HP Development Company, L.P. -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -487,10 +487,10 @@ DxeIplFindDxeCore ( // if (EFI_ERROR (Status)) { REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_CORE_EC_DXE_CORRUPT)); + ASSERT_EFI_ERROR (Status); + break; } - ASSERT_EFI_ERROR (Status); - // // Find the DxeCore file type from the beginning in this firmware volume. // @@ -509,6 +509,13 @@ DxeIplFindDxeCore ( // Instance++; } + + // + // DxeCore cannot find in any firmware volume. + // + CpuDeadLoop (); + + return NULL; } /**