]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c
Fix the return value bug when updating public key database variable failure.
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / RuntimeDxe / VariableDxe.c
index a2e764cf610c5d4046e6c947fc2e2d46006fdd69..949fb64248bf99acdab98e8924e43ec0402122dc 100644 (file)
@@ -2,7 +2,8 @@
   Implement all four UEFI Runtime Variable services for the nonvolatile\r
   and volatile storage space and install variable architecture protocol.\r
 \r
-Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (C) 2013, Red Hat, Inc.\r
+Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -21,6 +22,7 @@ extern VARIABLE_INFO_ENTRY     *gVariableInfo;
 EFI_HANDLE                     mHandle                    = NULL;\r
 EFI_EVENT                      mVirtualAddressChangeEvent = NULL;\r
 EFI_EVENT                      mFtwRegistration           = NULL;\r
+extern LIST_ENTRY              mLockedVariableList;\r
 extern BOOLEAN                 mEndOfDxe;\r
 EDKII_VARIABLE_LOCK_PROTOCOL   mVariableLock              = { VariableLockRequestToLock };\r
 \r
@@ -220,6 +222,10 @@ VariableClassAddressChangeEvent (
   IN VOID                                 *Context\r
   )\r
 {\r
+  LIST_ENTRY     *Link;\r
+  VARIABLE_ENTRY *Entry;\r
+  EFI_STATUS     Status;\r
+\r
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetBlockSize);\r
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);\r
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetAttributes);\r
@@ -235,9 +241,25 @@ VariableClassAddressChangeEvent (
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->VariableGlobal.VolatileVariableBase);\r
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);\r
   EfiConvertPointer (0x0, (VOID **) &mHashCtx);\r
-  EfiConvertPointer (0x0, (VOID **) &mStorageArea);\r
   EfiConvertPointer (0x0, (VOID **) &mSerializationRuntimeBuffer);\r
   EfiConvertPointer (0x0, (VOID **) &mNvVariableCache);\r
+\r
+  //\r
+  // in the list of locked variables, convert the name pointers first\r
+  //\r
+  for ( Link = GetFirstNode (&mLockedVariableList)\r
+      ; !IsNull (&mLockedVariableList, Link)\r
+      ; Link = GetNextNode (&mLockedVariableList, Link)\r
+      ) {\r
+    Entry = BASE_CR (Link, VARIABLE_ENTRY, Link);\r
+    Status = EfiConvertPointer (0x0, (VOID **) &Entry->Name);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  //\r
+  // second, convert the list itself using UefiRuntimeLib\r
+  //\r
+  Status = EfiConvertList (0x0, &mLockedVariableList);\r
+  ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
 \r
@@ -314,6 +336,7 @@ FtwNotificationEvent (
   UINT64                                  Length;\r
   EFI_PHYSICAL_ADDRESS                    VariableStoreBase;\r
   UINT64                                  VariableStoreLength;\r
+  UINTN                                   FtwMaxBlockSize;\r
 \r
   //\r
   // Ensure FTW protocol is installed.\r
@@ -323,6 +346,11 @@ FtwNotificationEvent (
     return ;\r
   }\r
 \r
+  Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);\r
+  if (!EFI_ERROR (Status)) {\r
+    ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);\r
+  }\r
+\r
   //\r
   // Find the proper FVB protocol for variable.\r
   //\r
@@ -360,7 +388,9 @@ FtwNotificationEvent (
   }\r
 \r
   Status = VariableWriteServiceInitialize ();\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));\r
+  }\r
 \r
   //\r
   // Install the Variable Write Architectural protocol.\r