Procházet zdrojové kódy

Sync the fix for recovery mode from MdeModulePkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12290 6f19259b-4bc3-4df7-8a09-765794883524
gdong1 před 12 roky
rodič
revize
1f58a5dcd4
1 změnil soubory, kde provedl 45 přidání a 16 odebrání
  1. 45 16
      SecurityPkg/VariableAuthenticated/Pei/Variable.c

+ 45 - 16
SecurityPkg/VariableAuthenticated/Pei/Variable.c

@@ -32,6 +32,32 @@ EFI_PEI_PPI_DESCRIPTOR     mPpiListVariable = {
 };
 
 
+/**
+  Check if it runs in Recovery mode.
+  
+  @param  PeiServices  General purpose services available to every PEIM.
+
+  @retval TRUE         It's in Recovery mode.
+  @retval FALSE        It's not in Recovery mode.
+
+**/
+BOOLEAN
+IsInRecoveryMode (
+  IN CONST EFI_PEI_SERVICES          **PeiServices
+  )
+{
+  EFI_STATUS              Status;
+  EFI_BOOT_MODE           BootMode;
+
+  Status = (*PeiServices)->GetBootMode (PeiServices, &BootMode);
+  ASSERT_EFI_ERROR (Status);
+  
+  if (BootMode == BOOT_IN_RECOVERY_MODE) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
 /**
   Provide the functionality of the variable services.
   
@@ -50,23 +76,7 @@ PeimInitializeVariableServices (
   IN CONST EFI_PEI_SERVICES          **PeiServices
   )
 {
-  EFI_BOOT_MODE BootMode;
-  EFI_STATUS    Status;
-
-  //
-  // Check if this is recovery boot path. If no, publish the variable access capability
-  // to other modules. If yes, the content of variable area is not reliable. Therefore,
-  // in this case we should not provide variable service to other pei modules. 
-  // 
-  Status = (*PeiServices)->GetBootMode (PeiServices, &BootMode);
-  ASSERT_EFI_ERROR (Status);
-  
-  if (BootMode == BOOT_IN_RECOVERY_MODE) {
-    return EFI_UNSUPPORTED;
-  }
-
   return PeiServicesInstallPpi (&mPpiListVariable);
-
 }
 
 /**
@@ -548,6 +558,16 @@ PeiGetVariable (
   if (VariableName == NULL || VariableGuid == NULL || DataSize == NULL) {
     return EFI_INVALID_PARAMETER;
   }
+
+  //
+  // Check if this is recovery boot path.
+  // If yes, the content of variable area is not reliable. Therefore we directly
+  // return EFI_NOT_FOUND. 
+  // 
+  if (IsInRecoveryMode(PeiServices)) {
+    return EFI_NOT_FOUND;
+  }
+
   //
   // Find existing variable
   //
@@ -626,6 +646,15 @@ PeiGetNextVariableName (
     return EFI_INVALID_PARAMETER;
   }
 
+  //
+  // Check if this is recovery boot path.
+  // If yes, the content of variable area is not reliable. Therefore we directly
+  // return EFI_NOT_FOUND. 
+  //   
+  if (IsInRecoveryMode(PeiServices)) {
+    return EFI_NOT_FOUND;
+  }
+
   Status = FindVariable (PeiServices, VariableName, VariableGuid, &Variable);
   if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) {
     return Status;