]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg Variable: Add some missing changes for 9b18845
authorStar Zeng <star.zeng@intel.com>
Mon, 7 Aug 2017 07:31:01 +0000 (15:31 +0800)
committerStar Zeng <star.zeng@intel.com>
Thu, 24 Jan 2019 02:52:29 +0000 (10:52 +0800)
To improve performance 9b18845a4b4cd1d2cf004cbc1cadf8a93ccb37ea
changed the code which read from physical MMIO address to read
from memory cache, but it missed some places that could be updated
the same away for performance optimization.

The patch updates these places as supplementary.

I found them when updating code for
https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Tested-by: Julien Grall <julien.grall@arm.com>
Acked-by: Julien Grall <julien.grall@arm.com>
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c

index 443cf07144a1215bc8c37ce03ca77e9e2d11f41d..99d487adac9ecdb38fd17c2aa7ef2a904899b934 100644 (file)
@@ -16,7 +16,7 @@
   VariableServiceSetVariable() should also check authenticate data to avoid buffer overflow,\r
   integer overflow. It should also check attribute to avoid authentication bypass.\r
 \r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -262,13 +262,12 @@ UpdateVariableStore (
   UINT8                       *CurrBuffer;\r
   EFI_LBA                     LbaNumber;\r
   UINTN                       Size;\r
-  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;\r
   VARIABLE_STORE_HEADER       *VolatileBase;\r
   EFI_PHYSICAL_ADDRESS        FvVolHdr;\r
   EFI_PHYSICAL_ADDRESS        DataPtr;\r
   EFI_STATUS                  Status;\r
 \r
-  FwVolHeader = NULL;\r
+  FvVolHdr    = 0;\r
   DataPtr     = DataPtrIndex;\r
 \r
   //\r
@@ -281,7 +280,6 @@ UpdateVariableStore (
     Status = Fvb->GetPhysicalAddress(Fvb, &FvVolHdr);\r
     ASSERT_EFI_ERROR (Status);\r
 \r
-    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvVolHdr);\r
     //\r
     // Data Pointer should point to the actual Address where data is to be\r
     // written.\r
@@ -290,7 +288,7 @@ UpdateVariableStore (
       DataPtr += mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase;\r
     }\r
 \r
-    if ((DataPtr + DataSize) > ((EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) FwVolHeader + FwVolHeader->FvLength))) {\r
+    if ((DataPtr + DataSize) > (FvVolHdr + mNvFvHeaderCache->FvLength)) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
   } else {\r
@@ -317,7 +315,7 @@ UpdateVariableStore (
   //\r
   // If we are here we are dealing with Non-Volatile Variables.\r
   //\r
-  LinearOffset  = (UINTN) FwVolHeader;\r
+  LinearOffset  = (UINTN) FvVolHdr;\r
   CurrWritePtr  = (UINTN) DataPtr;\r
   CurrWriteSize = DataSize;\r
   CurrBuffer    = Buffer;\r
@@ -2739,7 +2737,7 @@ UpdateVariable (
       }\r
     }\r
 \r
-    State = Variable->CurrPtr->State;\r
+    State = CacheVariable->CurrPtr->State;\r
     State &= VAR_DELETED;\r
 \r
     Status = UpdateVariableStore (\r
index 23186176be756fce424cd7165f06e5672444e6dd..f7185df3a7eb5bf06e0ffd9a5010bb8a6fd7efe8 100644 (file)
@@ -3,7 +3,7 @@
   and volatile storage space and install variable architecture protocol.\r
 \r
 Copyright (C) 2013, Red Hat, Inc.\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -402,8 +402,8 @@ FtwNotificationEvent (
   //\r
   // Mark the variable storage region of the FLASH as RUNTIME.\r
   //\r
-  VariableStoreBase   = NvStorageVariableBase + (((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)(NvStorageVariableBase))->HeaderLength);\r
-  VariableStoreLength = ((VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase)->Size;\r
+  VariableStoreBase   = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;\r
+  VariableStoreLength = mNvVariableCache->Size;\r
   BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);\r
   Length      = VariableStoreLength + (VariableStoreBase - BaseAddress);\r
   Length      = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);\r