MdeModulePkg/UefiBootManagerLib: Report boot option variable failures

When EfiBootManagerRefreshAllBootOption() discovers a bootable device
that is not present in BootOrder, it attempts to persist the device as a
Boot#### option. The operation is intentionally best-effort, so failures
are ignored and the refresh continues.

If the variable store is full, the device can still be connected and
visible from the UEFI Shell through SimpleFileSystem, but setup or boot
manager pages that rely on BootOrder/Boot#### do not show the device.
Without a boot manager level message, the failure is difficult to
distinguish from device enumeration problems.

Report SetVariable() failures through the existing status-code helper
when updating Boot#### and *Order variables, and log failures when
auto-created boot options cannot be added during refresh.

Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
This commit is contained in:
Dongyan Qian 2026-06-22 10:40:39 +08:00 committed by MarsDoge
parent 01b02a8c22
commit 1d508dafa6
2 changed files with 24 additions and 15 deletions

View file

@ -2523,7 +2523,16 @@ EfiBootManagerRefreshAllBootOption (
// //
for (Index = 0; Index < BootOptionCount; Index++) { for (Index = 0; Index < BootOptionCount; Index++) {
if (EfiBootManagerFindLoadOption (&BootOptions[Index], NvBootOptions, NvBootOptionCount) == -1) { if (EfiBootManagerFindLoadOption (&BootOptions[Index], NvBootOptions, NvBootOptionCount) == -1) {
EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN)-1); Status = EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN)-1);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"[Bds] Failed to add boot option for '%s': %r\n",
BootOptions[Index].Description,
Status
));
}
// //
// Try best to add the boot options so continue upon failure. // Try best to add the boot options so continue upon failure.
// //

View file

@ -260,13 +260,13 @@ structure.
VariableAttributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; VariableAttributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
} }
Status = gRT->SetVariable ( Status = BmSetVariableAndReportStatusCodeOnError (
OptionName, OptionName,
&gEfiGlobalVariableGuid, &gEfiGlobalVariableGuid,
VariableAttributes, VariableAttributes,
VariableSize, VariableSize,
Variable Variable
); );
FreePool (Variable); FreePool (Variable);
return Status; return Status;
@ -323,13 +323,13 @@ BmAddOptionNumberToOrderVariable (
NewOptionOrder[Position] = OptionNumber; NewOptionOrder[Position] = OptionNumber;
Status = gRT->SetVariable ( Status = BmSetVariableAndReportStatusCodeOnError (
OptionOrderName, OptionOrderName,
&gEfiGlobalVariableGuid, &gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
OptionOrderSize + sizeof (UINT16), OptionOrderSize + sizeof (UINT16),
NewOptionOrder NewOptionOrder
); );
FreePool (NewOptionOrder); FreePool (NewOptionOrder);
} }