diff --git a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c b/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c index c9b8556fab..e9580b98d0 100644 --- a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c +++ b/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c @@ -881,6 +881,34 @@ Match ( return FALSE; } + // + // Attempt to expand any relative UEFI device path starting with HD() to an + // absolute device path first. The logic imitates BdsLibBootViaBootOption(). + // We don't have to free the absolute device path, + // BdsExpandPartitionPartialDevicePathToFull() has internal caching. + // + Result = FALSE; + if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH && + DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP) { + EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath; + CHAR16 *AbsConverted; + + AbsDevicePath = BdsExpandPartitionPartialDevicePathToFull ( + (HARDDRIVE_DEVICE_PATH *) DevicePath); + if (AbsDevicePath == NULL) { + goto Exit; + } + AbsConverted = ConvertDevicePathToText (AbsDevicePath, FALSE, FALSE); + if (AbsConverted == NULL) { + goto Exit; + } + DEBUG ((DEBUG_VERBOSE, + "%a: expanded relative device path \"%s\" for prefix matching\n", + __FUNCTION__, Converted)); + FreePool (Converted); + Converted = AbsConverted; + } + // // Is Translated a prefix of Converted? // @@ -892,6 +920,7 @@ Match ( Converted, Result ? "match" : "no match" )); +Exit: FreePool (Converted); return Result; }