]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
SecurityPkg Variable: Reuse scratch data area(at the end of volatile variable store)
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / RuntimeDxe / AuthService.c
index 9b8f63f089322fbc80c28d75826e2a2eb037dde0..1e9e1907c00426fe02ed358571e49ac2bcc36f18 100644 (file)
@@ -55,14 +55,6 @@ CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };
 //\r
 VOID  *mHashCtx = NULL;\r
 \r
-//\r
-// The serialization of the values of the VariableName, VendorGuid and Attributes\r
-// parameters of the SetVariable() call and the TimeStamp component of the\r
-// EFI_VARIABLE_AUTHENTICATION_2 descriptor followed by the variable's new value\r
-// i.e. (VariableName, VendorGuid, Attributes, TimeStamp, Data)\r
-//\r
-UINT8 *mSerializationRuntimeBuffer = NULL;\r
-\r
 //\r
 // Requirement for different signature type which have been defined in UEFI spec.\r
 // These data are used to peform SignatureList format check while setting PK/KEK variable.\r
@@ -182,15 +174,6 @@ AutenticatedVariableServiceInitialize (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  //\r
-  // Prepare runtime buffer for serialized data of time-based authenticated\r
-  // Variable, i.e. (VariableName, VendorGuid, Attributes, TimeStamp, Data).\r
-  //\r
-  mSerializationRuntimeBuffer = AllocateRuntimePool (PcdGet32 (PcdMaxVariableSize) + sizeof (EFI_GUID) + sizeof (UINT32) + sizeof (EFI_TIME));\r
-  if (mSerializationRuntimeBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
   //\r
   // Check "AuthVarKeyDatabase" variable's existence.\r
   // If it doesn't exist, create a new one with initial value of 0 and EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.\r
@@ -2267,11 +2250,21 @@ VerifyTimeBasedPayload (
   PayloadSize = DataSize - OFFSET_OF_AUTHINFO2_CERT_DATA - (UINTN) SigDataSize;\r
 \r
   //\r
-  // Construct a buffer to fill with (VariableName, VendorGuid, Attributes, TimeStamp, Data).\r
+  // Construct a serialization buffer of the values of the VariableName, VendorGuid and Attributes\r
+  // parameters of the SetVariable() call and the TimeStamp component of the\r
+  // EFI_VARIABLE_AUTHENTICATION_2 descriptor followed by the variable's new value\r
+  // i.e. (VariableName, VendorGuid, Attributes, TimeStamp, Data)\r
   //\r
   NewDataSize = PayloadSize + sizeof (EFI_TIME) + sizeof (UINT32) +\r
                 sizeof (EFI_GUID) + StrSize (VariableName) - sizeof (CHAR16);\r
-  NewData = mSerializationRuntimeBuffer;\r
+  //\r
+  // Here is to reuse scratch data area(at the end of volatile variable store)\r
+  // to reduce SMRAM consumption for SMM variable driver.\r
+  // The scratch buffer is enough to hold the serialized data and safe to use,\r
+  // because it will be used at here to do verification only first\r
+  // and then used in UpdateVariable() for a time based auth variable set.\r
+  //\r
+  NewData = (UINT8 *) GetEndPointer ((VARIABLE_STORE_HEADER *) ((UINTN) mVariableModuleGlobal->VariableGlobal.VolatileVariableBase));\r
 \r
   Buffer = NewData;\r
   Length = StrLen (VariableName) * sizeof (CHAR16);\r