From 597342b2120f819aa1ba063dd10143a5f420a251 Mon Sep 17 00:00:00 2001 From: Luigi Leonardi Date: Fri, 13 Dec 2024 11:35:34 +0100 Subject: OvmfPkg/PlatformBootManagerLib: Optimize PlatformRegisterFvBootOption Add a FileIsInFv check to PlatformRegisterFvBootOption, this is to to avoid adding and then removing a boot option shortly after, because the file is no longer in the firmware volume. Signed-off-by: Luigi Leonardi --- OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c index 430da6429d..17e3bda967 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -199,6 +199,15 @@ PlatformRegisterFvBootOption ( ); ASSERT (DevicePath != NULL); + // + // File is not in firmware, so it is going to be deleted anyway by + // RemoveStaleFvFileOptions, let's not add it. + // + if (!FileIsInFv (DevicePath)) { + FreePool (DevicePath); + return; + } + Status = EfiBootManagerInitializeLoadOption ( &NewOption, LoadOptionNumberUnassigned, -- cgit