Skip to content

Commit 74ceeb9

Browse files
authored
Infinite boot retries (#347)
## Description This is a draft of infinite boot retries based on a newly created PCD. When true, the system will never stop retrying the boot options. PCD default is FALSE to match existing functionality. For each item, place an "x" in between `[` and `]` if true. Example: `[x]`. _(you can also check items in the GitHub UI)_ - [X] Impacts functionality? - **Functionality** - Does the change ultimately impact how firmware functions? - Examples: Add a new library, publish a new PPI, update an algorithm, ... - [ ] Impacts security? - **Security** - Does the change have a direct security impact on an application, flow, or firmware? - Examples: Crypto algorithm change, buffer overflow fix, parameter validation improvement, ... - [ ] Breaking change? - **Breaking change** - Will anyone consuming this change experience a break in build or boot behavior? - Examples: Add a new library class, move a module to a different repo, call a function in a new library class in a pre-existing module, ... - [ ] Includes tests? - **Tests** - Does the change include any explicit test code? - Examples: Unit tests, integration tests, robot tests, ... - [ ] Includes documentation? - **Documentation** - Does the change contain explicit documentation additions outside direct code modifications (and comments)? - Examples: Update readme file, add feature readme file, link to documentation on an a separate Web page, ... ## How This Was Tested ## Integration Instructions n/a
1 parent b188842 commit 74ceeb9

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

MdeModulePkg/MdeModulePkg.dec

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,15 @@
12721272
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportAlternativeQueueSize|FALSE|BOOLEAN|0x40000151
12731273
# MU_CHANGE [END]
12741274

1275+
# MU_CHANGE [BEGIN] - Support indefinite boot retries
1276+
# # Some platforms require that all EfiLoadOptions are retried until one of the options
1277+
# # succeeds. When True, this Pcd will force Bds to retry all the valid EfiLoadOptions
1278+
# # indefinitely until one of the options succeeds.
1279+
# # TRUE - Efi boot options will be retried indefinitely.
1280+
# # FALSE - Efi boot options will not be retried.
1281+
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportInfiniteBootRetries|FALSE|BOOLEAN|0x40000152
1282+
# MU_CHANGE [END]
1283+
12751284
[PcdsFixedAtBuild, PcdsPatchableInModule]
12761285
## Dynamic type PCD can be registered callback function for Pcd setting action.
12771286
# PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function

MdeModulePkg/Universal/BdsDxe/BdsDxe.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## CONSUMES
9898
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport ## CONSUMES
9999
gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport ## CONSUMES
100+
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportInfiniteBootRetries ## CONSUMES // MU_CHANGE
100101

101102
[Depex]
102103
TRUE

MdeModulePkg/Universal/BdsDxe/BdsEntry.c

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,38 @@ BootBootOptions (
417417

418418
PlatformBootManagerProcessBootCompletion (&BootOptions[Index]); // MSCHANGE 00076 - record boot status
419419

420-
//
421-
// If the boot via Boot#### returns with a status of EFI_SUCCESS, platform firmware
422-
// supports boot manager menu, and if firmware is configured to boot in an
423-
// interactive mode, the boot manager will stop processing the BootOrder variable and
424-
// present a boot manager menu to the user.
425-
//
426-
if ((BootManagerMenu != NULL) && (BootOptions[Index].Status == EFI_SUCCESS)) {
427-
EfiBootManagerBoot (BootManagerMenu);
428-
break;
420+
// MU_CHANGE [BEGIN] - Support infinite boot retries
421+
// Changes for PcdSupportInfiniteBootRetries are meant to minimize upkeep in mu repos.
422+
// If/when upstreaming this change, refactoring calling loop in BdsEntry() would be
423+
// better location.
424+
if (!PcdGetBool (PcdSupportInfiniteBootRetries)) {
425+
// MU_CHANGE [END] - Support infinite boot retries
426+
427+
//
428+
// If the boot via Boot#### returns with a status of EFI_SUCCESS, platform firmware
429+
// supports boot manager menu, and if firmware is configured to boot in an
430+
// interactive mode, the boot manager will stop processing the BootOrder variable and
431+
// present a boot manager menu to the user.
432+
//
433+
if ((BootManagerMenu != NULL) && (BootOptions[Index].Status == EFI_SUCCESS)) {
434+
EfiBootManagerBoot (BootManagerMenu);
435+
break;
436+
}
437+
438+
// MU_CHANGE [BEGIN]- Support infinite boot retries
439+
// Changes for PcdSupportInfiniteBootRetries are meant to minimize upkeep in mu repos.
440+
// If/when upstreaming this change, refactoring calling loop in BdsEntry() would be
441+
// better location.
442+
}
443+
444+
if (PcdGetBool (PcdSupportInfiniteBootRetries)) {
445+
if (Index == (BootOptionCount - 1)) {
446+
// Resetting index back to -1 so loop increment will result in Index 0 for next iteration
447+
Index = (UINTN)-1;
448+
}
429449
}
450+
451+
// MU_CHANGE [END]- Support infinite boot retries
430452
}
431453

432454
return (BOOLEAN)(Index < BootOptionCount);

0 commit comments

Comments
 (0)