diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c index cead685c56..a797682751 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -2964,6 +2964,7 @@ BdsDeleteAllInvalidEfiBootOption ( UINTN Index2; UINT16 BootOption[BOOT_OPTION_MAX_CHAR]; EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath; + EFI_DEVICE_PATH_PROTOCOL *WorkingDevicePath; UINT8 *TempPtr; CHAR16 *Description; BOOLEAN Corrupted; @@ -3018,6 +3019,24 @@ BdsDeleteAllInvalidEfiBootOption ( Index++; continue; } + + // + // If it's Device Path that starts with a hard drive path, append it with the front part to compose a + // full device path + // + WorkingDevicePath = NULL; + if ((DevicePathType (OptionDevicePath) == MEDIA_DEVICE_PATH) && + (DevicePathSubType (OptionDevicePath) == MEDIA_HARDDRIVE_DP)) { + WorkingDevicePath = BdsExpandPartitionPartialDevicePathToFull ( + (HARDDRIVE_DEVICE_PATH *)OptionDevicePath + ); + if (WorkingDevicePath != NULL) { + OptionDevicePath = WorkingDevicePath; + } else { + // Ensure unexpandable HD paths are removed + Corrupted = TRUE; + } + } } if (Corrupted || !BdsLibIsValidEFIBootOptDevicePathExt (OptionDevicePath, FALSE, Description)) {