]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/VariablePei/Variable.c
As variable area is not reliable in recovery path, then we should not produce Readonl...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / VariablePei / Variable.c
index 33363e67eaed69ae7deb920b7b8e741e1d7fac9c..2cda7ff3add962561b39d6417410e84499d24207 100644 (file)
@@ -47,11 +47,12 @@ EFI_GUID mEfiVariableIndexTableGuid = EFI_VARIABLE_INDEX_TABLE_GUID;
 /**\r
   Provide the functionality of the variable services.\r
 \r
-  @param  FileHandle  Handle of the file being invoked.\r
-  @param  PeiServices Describes the list of possible PEI Services.\r
+  @param  FileHandle      Handle of the file being invoked.\r
+  @param  PeiServices     Describes the list of possible PEI Services.\r
 \r
-  @return Status -  EFI_SUCCESS if the interface could be successfully\r
-          installed\r
+  @return EFI_SUCCESS     If the interface could be successfully installed.\r
+  @return EFI_UNSUPPORTED If current boot path is in recovery mode, then does not\r
+                          install this interface.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -61,9 +62,21 @@ PeimInitializeVariableServices (
   IN CONST EFI_PEI_SERVICES     **PeiServices\r
   )\r
 {\r
+  EFI_BOOT_MODE BootMode;\r
+  EFI_STATUS    Status;\r
+\r
   //\r
-  // Publish the variable capability to other modules\r
-  //\r
+  // Check if this is recovery boot path. If no, publish the variable access capability\r
+  // to other modules. If yes, the content of variable area is not reliable. Therefore,\r
+  // in this case we should not provide variable service to other pei modules. \r
+  // \r
+  Status = (*PeiServices)->GetBootMode (PeiServices, &BootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
   return (**PeiServices).InstallPpi (PeiServices, &mPpiListVariable[0]);\r
 \r
 }\r