Skip to content

Commit

Permalink
Infinite boot retries (#347)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
apop5 authored Apr 17, 2023
1 parent b188842 commit 74ceeb9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
9 changes: 9 additions & 0 deletions MdeModulePkg/MdeModulePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,15 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportAlternativeQueueSize|FALSE|BOOLEAN|0x40000151
# MU_CHANGE [END]

# MU_CHANGE [BEGIN] - Support indefinite boot retries
# # Some platforms require that all EfiLoadOptions are retried until one of the options
# # succeeds. When True, this Pcd will force Bds to retry all the valid EfiLoadOptions
# # indefinitely until one of the options succeeds.
# # TRUE - Efi boot options will be retried indefinitely.
# # FALSE - Efi boot options will not be retried.
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportInfiniteBootRetries|FALSE|BOOLEAN|0x40000152
# MU_CHANGE [END]

[PcdsFixedAtBuild, PcdsPatchableInModule]
## Dynamic type PCD can be registered callback function for Pcd setting action.
# PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function
Expand Down
1 change: 1 addition & 0 deletions MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportInfiniteBootRetries ## CONSUMES // MU_CHANGE

[Depex]
TRUE
Expand Down
40 changes: 31 additions & 9 deletions MdeModulePkg/Universal/BdsDxe/BdsEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,38 @@ BootBootOptions (

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

//
// If the boot via Boot#### returns with a status of EFI_SUCCESS, platform firmware
// supports boot manager menu, and if firmware is configured to boot in an
// interactive mode, the boot manager will stop processing the BootOrder variable and
// present a boot manager menu to the user.
//
if ((BootManagerMenu != NULL) && (BootOptions[Index].Status == EFI_SUCCESS)) {
EfiBootManagerBoot (BootManagerMenu);
break;
// MU_CHANGE [BEGIN] - Support infinite boot retries
// Changes for PcdSupportInfiniteBootRetries are meant to minimize upkeep in mu repos.
// If/when upstreaming this change, refactoring calling loop in BdsEntry() would be
// better location.
if (!PcdGetBool (PcdSupportInfiniteBootRetries)) {
// MU_CHANGE [END] - Support infinite boot retries

//
// If the boot via Boot#### returns with a status of EFI_SUCCESS, platform firmware
// supports boot manager menu, and if firmware is configured to boot in an
// interactive mode, the boot manager will stop processing the BootOrder variable and
// present a boot manager menu to the user.
//
if ((BootManagerMenu != NULL) && (BootOptions[Index].Status == EFI_SUCCESS)) {
EfiBootManagerBoot (BootManagerMenu);
break;
}

// MU_CHANGE [BEGIN]- Support infinite boot retries
// Changes for PcdSupportInfiniteBootRetries are meant to minimize upkeep in mu repos.
// If/when upstreaming this change, refactoring calling loop in BdsEntry() would be
// better location.
}

if (PcdGetBool (PcdSupportInfiniteBootRetries)) {
if (Index == (BootOptionCount - 1)) {
// Resetting index back to -1 so loop increment will result in Index 0 for next iteration
Index = (UINTN)-1;
}
}

// MU_CHANGE [END]- Support infinite boot retries
}

return (BOOLEAN)(Index < BootOptionCount);
Expand Down

0 comments on commit 74ceeb9

Please sign in to comment.