summaryrefslogtreecommitdiff
path: root/OvmfPkg
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2017-11-27 18:16:27 +0100
committerLaszlo Ersek <lersek@redhat.com>2017-11-28 21:36:53 +0100
commita0e761b1532ded8a30810c7b3ce89a1082069b01 (patch)
tree21c4bb84ef65c3ca7eee5dbdcea58615bba9085f /OvmfPkg
parentf9bc2f876326af08db58db446a7b7609b4a9c83e (diff)
downloadedk2-a0e761b1532ded8a30810c7b3ce89a1082069b01.zip
edk2-a0e761b1532ded8a30810c7b3ce89a1082069b01.tar.gz
edk2-a0e761b1532ded8a30810c7b3ce89a1082069b01.tar.bz2
OvmfPkg/QemuBootOrderLib: skip already matched / appended UEFI boot opts
The SetBootOrderFromQemu() function implements a nested loop where - the outer loop iterates over all OpenFirmware (OFW) device paths in the QEMU boot order, and translates each to a UEFI device path prefix; - the inner loop matches the current (translated) prefix against all active UEFI boot options in turn; - if the UEFI boot option is matched by the translated prefix, the UEFI boot option is appended to the "new" UEFI boot order, and marked as "has been appended". This patch adds a micro-optimization where already matched / appended UEFI boot options are skipped in the inner loop. This is not a functional change. A functional change would be if, as a consequence of the patch, some UEFI boot options would no longer be *doubly* matched. For a UEFI boot option to be matched by two translated prefixes, one of those prefixes would have to be a (proper, or equal) prefix of the other prefix. The PCI and MMIO OFW translation routines output such only in the following cases: - When the original OFW device paths are prefixes of each other. This is not possible from the QEMU side. (Only leaf devices are bootable.) - When the translation rules in the routines are incomplete, and don't look at the OFW device paths for sufficient length (i.e., at nodes where they would already differ, and the difference would show up in the translation output). This would be a shortcoming of the translation routines and should be fixed in TranslatePciOfwNodes() and TranslateMmioOfwNodes(), whenever identified. Even in the second case, this patch would replace the double appending of a single UEFI boot option (matched by two different OFW device paths) with a correct, or cross-, matching of two different UEFI boot options. Again, this is not expected, but arguably it would be more correct than duplicate boot option appending, should it occur due to any (unexpected, unknown) lack of detail in the translation routines. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Diffstat (limited to 'OvmfPkg')
-rw-r--r--OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index 7c1f375..a9a62e9 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -1861,7 +1861,8 @@ SetBootOrderFromQemu (
// match translated OpenFirmware path against all active boot options
//
for (Idx = 0; Idx < ActiveCount; ++Idx) {
- if (Match (
+ if (!ActiveOption[Idx].Appended &&
+ Match (
Translated,
TranslatedSize, // contains length, not size, in CHAR16's here
ActiveOption[Idx].BootOption->FilePath