mirror of
				https://git.proxmox.com/git/mirror_edk2
				synced 2025-11-04 02:40:26 +00:00 
			
		
		
		
	MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it
Current implementation deletes the "BootNext" before calling any PlatformBootManagerLib APIs, but if system resets in PlatformBootManagerLib APIs, "BootNext" is not consumed but lost. The patch defers the deletion of "BootNext" to before booting it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Eric Dong <eric.dong@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Sunny Wang <sunnywang@hpe.com>
This commit is contained in:
		
							parent
							
								
									b23592a8fe
								
							
						
					
					
						commit
						0e6584e386
					
				@ -808,7 +808,8 @@ BdsEntry (
 | 
			
		||||
  ASSERT_EFI_ERROR (Status);
 | 
			
		||||
 | 
			
		||||
  //
 | 
			
		||||
  // Cache and remove the "BootNext" NV variable.
 | 
			
		||||
  // Cache the "BootNext" NV variable before calling any PlatformBootManagerLib APIs
 | 
			
		||||
  // This could avoid the "BootNext" set by PlatformBootManagerLib be consumed in this boot.
 | 
			
		||||
  //
 | 
			
		||||
  GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **) &BootNext, &DataSize);
 | 
			
		||||
  if (DataSize != sizeof (UINT16)) {
 | 
			
		||||
@ -817,17 +818,6 @@ BdsEntry (
 | 
			
		||||
    }
 | 
			
		||||
    BootNext = NULL;
 | 
			
		||||
  }
 | 
			
		||||
  Status = gRT->SetVariable (
 | 
			
		||||
                  EFI_BOOT_NEXT_VARIABLE_NAME,
 | 
			
		||||
                  &gEfiGlobalVariableGuid,
 | 
			
		||||
                  0,
 | 
			
		||||
                  0,
 | 
			
		||||
                  NULL
 | 
			
		||||
                  );
 | 
			
		||||
  //
 | 
			
		||||
  // Deleting NV variable shouldn't fail unless it doesn't exist.
 | 
			
		||||
  //
 | 
			
		||||
  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
 | 
			
		||||
 | 
			
		||||
  //
 | 
			
		||||
  // Initialize the platform language variables
 | 
			
		||||
@ -1052,10 +1042,25 @@ BdsEntry (
 | 
			
		||||
 | 
			
		||||
    EfiBootManagerHotkeyBoot ();
 | 
			
		||||
 | 
			
		||||
    //
 | 
			
		||||
    // Boot to "BootNext"
 | 
			
		||||
    //
 | 
			
		||||
    if (BootNext != NULL) {
 | 
			
		||||
      //
 | 
			
		||||
      // Delete "BootNext" NV variable before transferring control to it to prevent loops.
 | 
			
		||||
      //
 | 
			
		||||
      Status = gRT->SetVariable (
 | 
			
		||||
                      EFI_BOOT_NEXT_VARIABLE_NAME,
 | 
			
		||||
                      &gEfiGlobalVariableGuid,
 | 
			
		||||
                      0,
 | 
			
		||||
                      0,
 | 
			
		||||
                      NULL
 | 
			
		||||
                      );
 | 
			
		||||
      //
 | 
			
		||||
      // Deleting NV variable shouldn't fail unless it doesn't exist.
 | 
			
		||||
      //
 | 
			
		||||
      ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
 | 
			
		||||
 | 
			
		||||
      //
 | 
			
		||||
      // Boot to "BootNext"
 | 
			
		||||
      //
 | 
			
		||||
      UnicodeSPrint (BootNextVariableName, sizeof (BootNextVariableName), L"Boot%04x", *BootNext);
 | 
			
		||||
      Status = EfiBootManagerVariableToLoadOption (BootNextVariableName, &LoadOption);
 | 
			
		||||
      if (!EFI_ERROR (Status)) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user