public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: "Wang, Jian J" <jian.j.wang@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wu, Hao A" <hao.a.wu@intel.com>, star.zeng@intel.com
Subject: Re: [PATCH V2 03/15] MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize
Date: Tue, 15 Jan 2019 18:13:09 +0800	[thread overview]
Message-ID: <a1bb7130-bfd7-eed0-a7db-8230fecbaa4e@intel.com> (raw)
In-Reply-To: <D827630B58408649ACB04F44C5100036258960F9@SHSMSX107.ccr.corp.intel.com>

On 2019/1/15 14:37, Wang, Jian J wrote:
> Hi Star,
> 
> One comment below.
> 
>> -----Original Message-----
>> From: Zeng, Star
>> Sent: Monday, January 14, 2019 11:20 PM
>> To: edk2-devel@lists.01.org
>> Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
>> Wu, Hao A <hao.a.wu@intel.com>
>> Subject: [PATCH V2 03/15] MdeModulePkg Variable: Not get NV PCD in
>> VariableWriteServiceInitialize
>>
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
>> Merge EmuVariable and Real variable driver.
>>
>> Add macro NV_STORAGE_VARIABLE_BASE.
>> Not get NV PCD in VariableWriteServiceInitialize, but in
>> FtwNotificationEvent/SmmFtwNotificationEvent, then
>> VariableWriteServiceInitialize could be not aware the NV
>> storage is real or emulated.
>>
>> This patch prepares for adding emulated variable NV mode
>> support in VariableRuntimeDxe.
>>
>> Cc: Jian J Wang <jian.j.wang@intel.com>
>> Cc: Hao Wu <hao.a.wu@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Star Zeng <star.zeng@intel.com>
>> ---
>>   .../Universal/Variable/RuntimeDxe/Variable.c         | 20 ++------------------
>>   .../Universal/Variable/RuntimeDxe/Variable.h         |  9 +++++++--
>>   .../Universal/Variable/RuntimeDxe/VariableDxe.c      | 12 ++++++++----
>>   .../Universal/Variable/RuntimeDxe/VariableSmm.c      | 16 +++++++++++-----
>>   4 files changed, 28 insertions(+), 29 deletions(-)
>>
>> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> index 0b675c8f36df..424f92a53757 100644
>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> @@ -3770,10 +3770,7 @@ InitRealNonVolatileVariableStore (
>>       return EFI_OUT_OF_RESOURCES;
>>     }
>>
>> -  NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64
>> (PcdFlashNvStorageVariableBase64);
>> -  if (NvStorageBase == 0) {
>> -    NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32
>> (PcdFlashNvStorageVariableBase);
>> -  }
>> +  NvStorageBase = NV_STORAGE_VARIABLE_BASE;
>>     ASSERT (NvStorageBase != 0);
>>
>>     //
>> @@ -4027,7 +4024,7 @@ FlushHobVariableToFlash (
>>   }
>>
>>   /**
>> -  Initializes variable write service after FTW was ready.
>> +  Initializes variable write service.
>>
>>     @retval EFI_SUCCESS          Function successfully executed.
>>     @retval Others               Fail to initialize the variable service.
>> @@ -4041,23 +4038,10 @@ VariableWriteServiceInitialize (
>>     EFI_STATUS                      Status;
>>     UINTN                           Index;
>>     UINT8                           Data;
>> -  EFI_PHYSICAL_ADDRESS            VariableStoreBase;
>> -  EFI_PHYSICAL_ADDRESS            NvStorageBase;
>>     VARIABLE_ENTRY_PROPERTY         *VariableEntry;
>>
>>     AcquireLockOnlyAtBootTime(&mVariableModuleGlobal-
>>> VariableGlobal.VariableServicesLock);
>>
>> -  NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64
>> (PcdFlashNvStorageVariableBase64);
>> -  if (NvStorageBase == 0) {
>> -    NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32
>> (PcdFlashNvStorageVariableBase);
>> -  }
>> -  VariableStoreBase = NvStorageBase + (mNvFvHeaderCache->HeaderLength);
>> -
>> -  //
>> -  // Let NonVolatileVariableBase point to flash variable store base directly after
>> FTW ready.
>> -  //
>> -  mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase =
>> VariableStoreBase;
>> -
>>     //
>>     // Check if the free area is really free.
>>     //
>> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
>> index 938eb5de61fa..566e7268d187 100644
>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
>> @@ -2,7 +2,7 @@
>>     The internal header file includes the common header files, defines
>>     internal structure and functions used by Variable modules.
>>
>> -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
>> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>>   This program and the accompanying materials
>>   are licensed and made available under the terms and conditions of the BSD
>> License
>>   which accompanies this distribution.  The full text of the license may be found
>> at
>> @@ -46,6 +46,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
>> KIND, EITHER EXPRESS OR IMPLIED.
>>
>>   #include "PrivilegePolymorphic.h"
>>
>> +#define NV_STORAGE_VARIABLE_BASE (EFI_PHYSICAL_ADDRESS) \
>> +                                   (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ? \
>> +                                    PcdGet64 (PcdFlashNvStorageVariableBase64) : \
>> +                                    PcdGet32 (PcdFlashNvStorageVariableBase))
>> +
>>   #define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \
>>                                         EFI_VARIABLE_BOOTSERVICE_ACCESS | \
>>                                         EFI_VARIABLE_RUNTIME_ACCESS | \
>> @@ -473,7 +478,7 @@ GetMaxVariableSize (
>>     );
>>
>>   /**
>> -  Initializes variable write service after FVB was ready.
>> +  Initializes variable write service.
>>
>>     @retval EFI_SUCCESS          Function successfully executed.
>>     @retval Others               Fail to initialize the variable service.
>> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
>> index f7185df3a7eb..baba6729c1c2 100644
>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
>> @@ -386,13 +386,17 @@ FtwNotificationEvent (
>>       ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
>>     }
>>
>> +  NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
>> +  VariableStoreBase = NvStorageVariableBase + (mNvFvHeaderCache-
>>> HeaderLength);
>> +
>> +  //
>> +  // Let NonVolatileVariableBase point to flash variable store base directly after
>> FTW ready.
>> +  //
>> +  mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase =
>> VariableStoreBase;
>> +
>>     //
>>     // Find the proper FVB protocol for variable.
>>     //
>> -  NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet64
>> (PcdFlashNvStorageVariableBase64);
>> -  if (NvStorageVariableBase == 0) {
>> -    NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32
>> (PcdFlashNvStorageVariableBase);
>> -  }
>>     Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);
>>     if (EFI_ERROR (Status)) {
>>       return ;
>> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
>> index 8c53f84ff6e8..018587ed7373 100644
>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
>> @@ -14,7 +14,7 @@
>>     VariableServiceSetVariable(), VariableServiceQueryVariableInfo(),
>> ReclaimForOS(),
>>     SmmVariableGetStatistics() should also do validation based on its own
>> knowledge.
>>
>> -Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
>> +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
>>   This program and the accompanying materials
>>   are licensed and made available under the terms and conditions of the BSD
>> License
>>   which accompanies this distribution.  The full text of the license may be found
>> at
>> @@ -37,6 +37,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
>> KIND, EITHER EXPRESS OR IMPLIED.
>>   #include <Guid/SmmVariableCommon.h>
>>   #include "Variable.h"
>>
>> +extern EFI_FIRMWARE_VOLUME_HEADER                    *mNvFvHeaderCache;
>>   extern VARIABLE_INFO_ENTRY                           *gVariableInfo;
> 
> Suggest moving the extern declarations to Variable.h. Both of them are shared
> in three files.

It is fine. I can update the patch series to include a separated patch 
for moving "extern XXX" to Variable.h

Thanks,
Star

> 
> Regards,
> Jian
> 
>>   EFI_HANDLE                                           mSmmVariableHandle      = NULL;
>>   EFI_HANDLE                                           mVariableHandle         = NULL;
>> @@ -867,6 +868,7 @@ SmmFtwNotificationEvent (
>>     )
>>   {
>>     EFI_STATUS                              Status;
>> +  EFI_PHYSICAL_ADDRESS                    VariableStoreBase;
>>     EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *FvbProtocol;
>>     EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL   *FtwProtocol;
>>     EFI_PHYSICAL_ADDRESS                    NvStorageVariableBase;
>> @@ -889,13 +891,17 @@ SmmFtwNotificationEvent (
>>       ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
>>     }
>>
>> +  NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
>> +  VariableStoreBase = NvStorageVariableBase + (mNvFvHeaderCache-
>>> HeaderLength);
>> +
>> +  //
>> +  // Let NonVolatileVariableBase point to flash variable store base directly after
>> FTW ready.
>> +  //
>> +  mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase =
>> VariableStoreBase;
>> +
>>     //
>>     // Find the proper FVB protocol for variable.
>>     //
>> -  NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet64
>> (PcdFlashNvStorageVariableBase64);
>> -  if (NvStorageVariableBase == 0) {
>> -    NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32
>> (PcdFlashNvStorageVariableBase);
>> -  }
>>     Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);
>>     if (EFI_ERROR (Status)) {
>>       return EFI_NOT_FOUND;
>> --
>> 2.7.0.windows.1



  reply	other threads:[~2019-01-15 10:13 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14 15:19 [PATCH V2 00/15] Merge EmuVariable and Real variable driver Star Zeng
2019-01-14 15:19 ` [PATCH V2 01/15] MdeModulePkg Variable: Add some missing changes for 9b18845 Star Zeng
2019-01-15  6:36   ` Wu, Hao A
2019-01-15  8:06   ` Laszlo Ersek
2019-01-14 15:19 ` [PATCH V2 02/15] MdeModulePkg Variable: Abstract InitRealNonVolatileVariableStore Star Zeng
2019-01-15  6:37   ` Wu, Hao A
2019-01-14 15:19 ` [PATCH V2 03/15] MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize Star Zeng
2019-01-15  5:48   ` Wu, Hao A
2019-01-15  5:53     ` Zeng, Star
2019-01-15  6:37   ` Wang, Jian J
2019-01-15 10:13     ` Zeng, Star [this message]
2019-01-14 15:19 ` [PATCH V2 04/15] MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm Star Zeng
2019-01-15  6:37   ` Wu, Hao A
2019-01-15  8:05   ` Wang, Jian J
2019-01-14 15:19 ` [PATCH V2 05/15] MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec Star Zeng
2019-01-15  5:05   ` Wang, Jian J
2019-01-15  5:55     ` Zeng, Star
2019-01-15  6:37   ` Wu, Hao A
2019-01-14 15:19 ` [PATCH V2 06/15] MdeModulePkg Variable: Remove CacheOffset in UpdateVariable() Star Zeng
2019-01-15  6:37   ` Wu, Hao A
2019-01-15  8:04   ` Wang, Jian J
2019-01-15  9:58     ` Laszlo Ersek
2019-01-15 10:10       ` Zeng, Star
2019-01-15  8:15   ` Laszlo Ersek
2019-01-14 15:19 ` [PATCH V2 07/15] MdeModulePkg Variable: type case VolatileBase to UINTN directly Star Zeng
2019-01-15  6:37   ` Wu, Hao A
2019-01-15  8:06   ` Wang, Jian J
2019-01-15  8:18   ` Laszlo Ersek
2019-01-14 15:19 ` [PATCH V2 08/15] MdeModulePkg Variable: Add emulated variable NV mode support Star Zeng
2019-01-15  6:01   ` Wang, Jian J
2019-01-15  6:16     ` Zeng, Star
2019-01-15  9:53       ` Laszlo Ersek
2019-01-15  9:33   ` Laszlo Ersek
2019-01-15  9:52     ` Zeng, Star
2019-01-14 15:19 ` [PATCH V2 09/15] MdeModulePkg VariablePei: Don't check BOOT_IN_RECOVERY_MODE Star Zeng
2019-01-14 15:19 ` [PATCH V2 10/15] ArmVirtXen: Use merged variable driver for emulated NV mode Star Zeng
2019-01-15  9:37   ` Laszlo Ersek
2019-01-16 14:26     ` Julien Grall
2019-01-17  1:26       ` Zeng, Star
2019-01-17 18:59         ` Julien Grall
2019-01-21 10:46           ` Zeng, Star
2019-01-21 13:36             ` Julien Grall
2019-01-21 19:40               ` Ard Biesheuvel
2019-01-22  4:30                 ` Zeng, Star
2019-01-23  1:41                   ` Zeng, Star
2019-01-23 12:15                     ` Julien Grall
2019-01-23 14:20                       ` Zeng, Star
2019-01-21 21:15               ` Laszlo Ersek
2019-01-21 21:22                 ` Ard Biesheuvel
2019-01-21 21:25                   ` Ard Biesheuvel
2019-01-14 15:19 ` [PATCH V2 11/15] ArmVirtXen: Link VarCheckUefiLib NULL class library instance Star Zeng
2019-01-15  9:39   ` Laszlo Ersek
2019-01-14 15:19 ` [PATCH V2 12/15] BeagleBoardPkg: Use merged variable driver for emulated NV mode Star Zeng
2019-01-14 22:11   ` Leif Lindholm
2019-01-15  1:32     ` Zeng, Star
2019-01-15  9:48       ` Leif Lindholm
2019-01-14 15:19 ` [PATCH V2 13/15] QuarkMin: " Star Zeng
2019-01-14 15:19 ` [PATCH V2 14/15] CorebootPayloadPkg: " Star Zeng
2019-01-14 15:19 ` [PATCH V2 15/15] MdeModulePkg: Remove EmuVariableRuntimeDxe Star Zeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1bb7130-bfd7-eed0-a7db-8230fecbaa4e@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox