Re: [edk2] Recall: [PATCH V3 00/17] Merge EmuVariable and Real variable driver

2019-01-15 Thread Wu, Hao A
Wrong operation made. Please ignore the message.
Sorry for the noise.

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Wu, Hao A
> Sent: Wednesday, January 16, 2019 3:42 PM
> To: Zeng, Star; edk2-devel@lists.01.org
> Cc: Zeng, Star
> Subject: [edk2] Recall: [PATCH V3 00/17] Merge EmuVariable and Real
> variable driver
> 
> Wu, Hao A would like to recall the message, "[edk2] [PATCH V3 00/17] Merge
> EmuVariable and Real variable driver".
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] Recall: [PATCH V3 00/17] Merge EmuVariable and Real variable driver

2019-01-15 Thread Wu, Hao A
Wu, Hao A would like to recall the message, "[edk2] [PATCH V3 00/17] Merge 
EmuVariable and Real variable driver".
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V3 00/17] Merge EmuVariable and Real variable driver

2019-01-15 Thread Wu, Hao A
Star,

The KW scan for the patch series is good.

Best Regards,
Hao Wu


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Star Zeng
> Sent: Tuesday, January 15, 2019 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star
> Subject: [edk2] [PATCH V3 00/17] Merge EmuVariable and Real variable
> driver
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> 
> Purpose:
> 1. Add emulated variable NV mode support in
>MdeModulePkg\Universal\Variable\RuntimeDxe.
>Platform can configure PCD statically (build time) or
>dynamically (boot time) to support emulated variable NV mode.
> 2. Remove MdeModulePkg\Universal\Variable\EmuRuntimeDxe whose
>most codes are duplicated.
> 
> 
> V3:
> Addressed all the great feedbacks from Jian, Hao, Laszlo and Leif, thanks.
> Pick up RB and AB tags.
> 
> Repo: g...@github.com:lzeng14/edk2.git
> Branch: MergedVariableDriver_EmuNvMode_V3
> 
> Patches 1~9: Preparation
>   Patch 3 and 9 are new added based on feedbacks.
> Patch 10~11: Real work
> Patch 12~17: Migration for platforms and cleanup
> 
> 
> V2: Addressed all the feedbacks from Laszlo, thanks.
> 
> Repo: g...@github.com:lzeng14/edk2.git
> Branch: MergedVariableDriver_EmuNvMode_V2
> 
> Patches 1~7: Preparation
>   Patch 6 and 7 are new separated.
> Patch 8~9: Real work
> Patch 10~15: Migration for platforms and cleanup
>   Patch 11 is new added to let ArmVirtXen be aligned with ArmVirtQemuXXX.
> 
> 
> V1:
> 
> Repo: g...@github.com:lzeng14/edk2.git
> Branch: MergedVariableDriver_EmuNvMode
> 
> Patches 1~5: Preparation
> Patch 6~7: Real work
> Patch 8~12: Migration for platforms and cleanup
> 
> Test done:
> Build code with VS2012, VS2015 and GCC49.
> Regression: Boot Nt32, Ovmf (including 32, 3264 and 64 with no SMM) to UEFI
> SHELL.
> Boot some internal platform to UEFI SHELL and Windows.
> Functionality: Boot Nt32, Ovmf (including 32, 3264 and 64 with no SMM) to
> UEFI SHELL
>with PcdEmuVariableNvModeEnable == TRUE.
> 
> More test will be welcome and appreciated. :)
> 
> Patches to update edk2-platforms Repo will be sent out separately.
> 
> Star Zeng (17):
>   MdeModulePkg Variable: Add some missing changes for 9b18845
>   MdeModulePkg Variable: Abstract InitRealNonVolatileVariableStore
>   MdeModulePkg Variable: Move "extern XXX" to Variable.h
>   MdeModulePkg Variable: Not get NV PCD in
> VariableWriteServiceInitialize
>   MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm
>   MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()
>   MdeModulePkg Variable: type case VolatileBase to UINTN directly
>   MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec
>   MdeModulePkg: Refine description a little for
> PcdEmuVariableNvStoreReserved
>   MdeModulePkg Variable: Add emulated variable NV mode support
>   MdeModulePkg VariablePei: Don't check BOOT_IN_RECOVERY_MODE
>   ArmVirtXen: Use merged variable driver for emulated NV mode
>   ArmVirtXen: Link VarCheckUefiLib NULL class library instance
>   BeagleBoardPkg: Use merged variable driver for emulated NV mode
>   QuarkMin: Use merged variable driver for emulated NV mode
>   CorebootPayloadPkg: Use merged variable driver for emulated NV mode
>   MdeModulePkg: Remove EmuVariableRuntimeDxe
> 
>  ArmVirtPkg/ArmVirtXen.dsc  |   12 +-
>  ArmVirtPkg/ArmVirtXen.fdf  |4 +-
>  BeagleBoardPkg/BeagleBoardPkg.dsc  |   14 +-
>  BeagleBoardPkg/BeagleBoardPkg.fdf  |4 +-
>  CorebootPayloadPkg/CorebootPayloadPkg.fdf  |4 +-
>  CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc  |   11 +-
>  CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc   |   11 +-
>  MdeModulePkg/MdeModulePkg.dec  |   16 +-
>  MdeModulePkg/MdeModulePkg.dsc  |5 +-
>  MdeModulePkg/MdeModulePkg.uni  |   14 +-
>  .../Universal/Variable/EmuRuntimeDxe/EmuVariable.c | 1820 --
> --
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxe.inf|   88 -
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxe.uni|   22 -
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxeExtra.uni   |   19 -
>  .../Variable/EmuRuntimeDxe/InitVariable.c  |  259 ---
>  .../Universal/Variable/EmuRuntimeDxe/Variable.h|  277 ---
>  MdeModulePkg/Universal/Variable/Pei/Variable.c |8 +-
>  .../Universal/Variable/Pei/VariablePei.inf |3 +-
>  .../Universal/Variable/RuntimeDxe/Variable.c   |  431 +++--
>  .../Universal/Variable/RuntimeDxe/Variable.h   |   19 +-
>  .../Universal/Variable/RuntimeDxe/VariableDxe.c|  103 +-
>  .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |4 +-
>  .../Universal/Variable/RuntimeDxe/VariableSmm.c|   90 +-
>  .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |4 +-
>  QuarkPlatformPkg/QuarkMin.dsc  |8 +-
>  QuarkPlatformPkg/QuarkMin.fdf  |

[edk2] [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.

2019-01-15 Thread Meenakshi Aggarwal
Issue : SD read failure for high capacity cards e.g. 64 GB
i
Reason : Command argument value exceeds 32 bit for block number 0x3787FFF
and cant be fit into 32 bit wide SD host controller register.

Fix :
AccessMode bits [29:30] of OCR is a valid definition to calculate
data address for eMMC cards.

For SD cards, data address is calculated on the basis of
card capacity status bit[30] of OCR.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Meenakshi Aggarwal 
---
 EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c 
b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index a2b9232..625a59e 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -148,12 +148,21 @@ MmcTransferBlock (
   MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
   MmcHost = MmcHostInstance->MmcHost;
 
-  //Set command argument based on the card access mode (Byte mode or Block 
mode)
-  if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
-  MMC_OCR_ACCESS_SECTOR) {
-CmdArg = Lba;
+  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
+//Set command argument based on the card capacity (SDSC or SDXC/SDHC)
+if (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1) {
+  CmdArg = Lba;
+} else {
+  CmdArg = Lba * This->Media->BlockSize;
+}
   } else {
-CmdArg = Lba * This->Media->BlockSize;
+//Set command argument based on the card access mode (Byte mode or Block 
mode)
+if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
+MMC_OCR_ACCESS_SECTOR) {
+  CmdArg = Lba;
+} else {
+  CmdArg = Lba * This->Media->BlockSize;
+}
   }
 
   Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
-- 
1.9.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V3 10/17] MdeModulePkg Variable: Add emulated variable NV mode support

2019-01-15 Thread Wu, Hao A
Reviewed-by: Hao Wu 

Best Regards,
Hao Wu


> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, January 15, 2019 6:30 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Wang, Jian J; Wu, Hao A; Kinney, Michael D; Gao, Liming; Ni,
> Ray; Laszlo Ersek; Ard Biesheuvel
> Subject: [PATCH V3 10/17] MdeModulePkg Variable: Add emulated variable
> NV mode support
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> Add emulated variable NV mode support in real variable driver.
> Platform can configure PcdEmuVariableNvModeEnable statically
> (build time) or dynamically (boot time) to support emulated
> variable NV mode.
> 
> If PcdEmuVariableNvModeEnable is configured to dynamic, its
> value should be set before Variable driver starts to work,
> otherwise default value will take effect.
> 
> Then EmuVariableRuntimeDxe could be removed, the removal of
> EmuVariableRuntimeDxe will be done after platforms are migrated
> to use the merged variable driver.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> Acked-by: Laszlo Ersek 
> ---
>  .../Universal/Variable/RuntimeDxe/Variable.c   | 318 +++
> --
>  .../Universal/Variable/RuntimeDxe/Variable.h   |   1 +
>  .../Universal/Variable/RuntimeDxe/VariableDxe.c|  27 +-
>  .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |   4 +-
>  .../Universal/Variable/RuntimeDxe/VariableSmm.c|  29 +-
>  .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |   4 +-
>  6 files changed, 271 insertions(+), 112 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> index d3df21819abe..e8e19508cd9a 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> @@ -34,6 +34,7 @@ VARIABLE_MODULE_GLOBAL  *mVariableModuleGlobal;
> 
>  ///
>  /// Define a memory cache that improves the search performance for a
> variable.
> +/// For EmuNvMode == TRUE, it will be equal to NonVolatileVariableBase.
>  ///
>  VARIABLE_STORE_HEADER  *mNvVariableCache  = NULL;
> 
> @@ -273,7 +274,7 @@ UpdateVariableStore (
>//
>// Check if the Data is Volatile.
>//
> -  if (!Volatile) {
> +  if (!Volatile && !mVariableModuleGlobal->VariableGlobal.EmuNvMode) {
>  if (Fvb == NULL) {
>return EFI_UNSUPPORTED;
>  }
> @@ -296,17 +297,30 @@ UpdateVariableStore (
>  // Data Pointer should point to the actual Address where data is to be
>  // written.
>  //
> -VolatileBase = (VARIABLE_STORE_HEADER *) ((UINTN)
> mVariableModuleGlobal->VariableGlobal.VolatileVariableBase);
> -if (SetByIndex) {
> -  DataPtr += mVariableModuleGlobal-
> >VariableGlobal.VolatileVariableBase;
> -}
> +if (Volatile) {
> +  VolatileBase = (VARIABLE_STORE_HEADER *) ((UINTN)
> mVariableModuleGlobal->VariableGlobal.VolatileVariableBase);
> +  if (SetByIndex) {
> +DataPtr += mVariableModuleGlobal-
> >VariableGlobal.VolatileVariableBase;
> +  }
> 
> -if ((DataPtr + DataSize) > ((UINTN) VolatileBase + VolatileBase->Size)) {
> -  return EFI_OUT_OF_RESOURCES;
> +  if ((DataPtr + DataSize) > ((UINTN) VolatileBase + 
> VolatileBase->Size)) {
> +return EFI_OUT_OF_RESOURCES;
> +  }
> +} else {
> +  //
> +  // Emulated non-volatile variable mode.
> +  //
> +  if (SetByIndex) {
> +DataPtr += (UINTN) mNvVariableCache;
> +  }
> +
> +  if ((DataPtr + DataSize) > ((UINTN) mNvVariableCache +
> mNvVariableCache->Size)) {
> +return EFI_OUT_OF_RESOURCES;
> +  }
>  }
> 
>  //
> -// If Volatile Variable just do a simple mem copy.
> +// If Volatile/Emulated Non-volatile Variable just do a simple mem copy.
>  //
>  CopyMem ((UINT8 *)(UINTN)DataPtr, Buffer, DataSize);
>  return EFI_SUCCESS;
> @@ -987,7 +1001,7 @@ Reclaim (
>CommonUserVariableTotalSize = 0;
>HwErrVariableTotalSize  = 0;
> 
> -  if (IsVolatile) {
> +  if (IsVolatile || mVariableModuleGlobal->VariableGlobal.EmuNvMode) {
>  //
>  // Start Pointers for the variable.
>  //
> @@ -1155,13 +1169,21 @@ Reclaim (
>  CurrPtr += NewVariableSize;
>}
> 
> -  if (IsVolatile) {
> +  if (IsVolatile || mVariableModuleGlobal->VariableGlobal.EmuNvMode) {
>  //
> -// If volatile variable store, just copy valid buffer.
> +// If volatile/emulated non-volatile variable store, just copy valid 
> buffer.
>  //
>  SetMem ((UINT8 *) (UINTN) VariableBase, VariableStoreHeader->Size,
> 0xff);
>  CopyMem ((UINT8 *) (UINTN) VariableBase, ValidBuffer, (UINTN) CurrPtr -
> (UINTN) ValidBuffer);
>  *LastVariableOffset = (UINTN) CurrPtr - (UINTN) ValidBuffer;
> +if (!IsVolatile) {
> +

Re: [edk2] [PATCH V3 17/17] MdeModulePkg: Remove EmuVariableRuntimeDxe

2019-01-15 Thread Wu, Hao A
Reviewed-by: Hao Wu 

Best Regards,
Hao Wu


> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, January 15, 2019 6:30 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Wang, Jian J; Wu, Hao A
> Subject: [PATCH V3 17/17] MdeModulePkg: Remove
> EmuVariableRuntimeDxe
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> The real variable driver has been updated to support emulated
> variable NV mode.
> This patch removes EmuVariableRuntimeDxe after platforms are
> migrated to use the merged variable driver.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/MdeModulePkg.dsc  |5 +-
>  .../Universal/Variable/EmuRuntimeDxe/EmuVariable.c | 1820 
> 
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxe.inf|   88 -
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxe.uni|   22 -
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxeExtra.uni   |   19 -
>  .../Variable/EmuRuntimeDxe/InitVariable.c  |  259 ---
>  .../Universal/Variable/EmuRuntimeDxe/Variable.h|  277 ---
>  7 files changed, 1 insertion(+), 2489 deletions(-)
>  delete mode 100644
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
>  delete mode 100644
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntime
> Dxe.inf
>  delete mode 100644
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntime
> Dxe.uni
>  delete mode 100644
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntime
> DxeExtra.uni
>  delete mode 100644
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/InitVariable.c
>  delete mode 100644
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc
> b/MdeModulePkg/MdeModulePkg.dsc
> index 5d042be3a862..3186f35a1a48 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -2,7 +2,7 @@
>  # EFI/PI Reference Module Package for All Architectures
>  #
>  # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
> -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> +# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
>  #
>  #This program and the accompanying materials
>  #are licensed and made available under the terms and conditions of the
> BSD License
> @@ -433,9 +433,6 @@ [Components.IA32, Components.X64,
> Components.ARM, Components.AARCH64]
> 
> NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32G
> uidedSectionExtractLib.inf
>}
> 
> -[Components.IA32, Components.X64, Components.Ebc]
> -
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntime
> Dxe.inf
> -
>  [Components.IA32, Components.X64]
> 
> MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.
> inf
>MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
> diff --git
> a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
> b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
> deleted file mode 100644
> index 1bcf931b96a6..
> --- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
> +++ /dev/null
> @@ -1,1820 +0,0 @@
> -/** @file
> -
> -  Emulation Variable services operate on the runtime volatile memory.
> -  The nonvolatile variable space doesn't exist.
> -
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -
> -**/
> -
> -#include "Variable.h"
> -
> -///
> -/// Don't use module globals after the SetVirtualAddress map is signaled
> -///
> -ESAL_VARIABLE_GLOBAL  *mVariableModuleGlobal;
> -
> -VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
> -
> -///
> -/// The size of a 3 character ISO639 language code.
> -///
> -#define ISO_639_2_ENTRY_SIZE3
> -
> -/**
> -  Update the variable region with Variable information. These are the same
> -  arguments as the EFI Variable services.
> -
> -  @param[in] VariableName   Name of variable
> -
> -  @param[in] VendorGuid Guid of variable
> -
> -  @param[in] Data   Variable data
> -
> -  @param[in] DataSize   Size of data. 0 means delete
> -
> -  @param[in] Attributes Attribues of the variable
> -
> -  @param[in] Variable   The variable information which is used to 
> keep
> track of variable usage.
> -
> -  @retval EFI_SUCCESS   The update operation is success.
> -
> -  @retval EFI_OUT_OF_RESOURCES  Variable region is full, can not write
> other data into this region.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> 

Re: [edk2] [PATCH V3 04/17] MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize

2019-01-15 Thread Wu, Hao A
Reviewed-by: Hao Wu 

Best Regards,
Hao Wu


> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, January 15, 2019 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Wang, Jian J; Wu, Hao A
> Subject: [PATCH V3 04/17] 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 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  .../Universal/Variable/RuntimeDxe/Variable.c | 20 
> ++--
>  .../Universal/Variable/RuntimeDxe/Variable.h |  9 +++--
>  .../Universal/Variable/RuntimeDxe/VariableDxe.c  | 13 -
>  .../Universal/Variable/RuntimeDxe/VariableSmm.c  | 15 ++-
>  4 files changed, 27 insertions(+), 30 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_ADDRESSVariableStoreBase;
> -  EFI_PHYSICAL_ADDRESSNvStorageBase;
>VARIABLE_ENTRY_PROPERTY *VariableEntry;
> 
>AcquireLockOnlyAtBootTime(
> >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 90507a8e64f6..d128d1a9c680 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.
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>  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 

Re: [edk2] [PATCH V3 11/17] MdeModulePkg VariablePei: Don't check BOOT_IN_RECOVERY_MODE

2019-01-15 Thread Wu, Hao A
Reviewed-by: Hao Wu 

Best Regards,
Hao Wu


> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, January 15, 2019 6:30 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Wang, Jian J; Wu, Hao A
> Subject: [PATCH V3 11/17] MdeModulePkg VariablePei: Don't check
> BOOT_IN_RECOVERY_MODE
> 
> Don't check BOOT_IN_RECOVERY_MODE, but check
> PcdEmuVariableNvModeEnable
> which platform can configure flexibly.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/Pei/Variable.c  | 8 +---
>  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf | 3 ++-
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c
> b/MdeModulePkg/Universal/Variable/Pei/Variable.c
> index 77b3eaeb210d..148c1cfefd90 100644
> --- a/MdeModulePkg/Universal/Variable/Pei/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c
> @@ -2,7 +2,7 @@
>Implement ReadOnly Variable Services required by PEIM and install
>PEI ReadOnly Varaiable2 PPI. These services operates the non volatile
> storage space.
> 
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>  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
> @@ -584,9 +584,9 @@ GetVariableStore (
>break;
> 
>  case VariableStoreTypeNv:
> -  if (GetBootModeHob () != BOOT_IN_RECOVERY_MODE) {
> +  if (!PcdGetBool (PcdEmuVariableNvModeEnable)) {
>  //
> -// The content of NV storage for variable is not reliable in recovery
> boot mode.
> +// Emulated non-volatile variable mode is not enabled.
>  //
> 
>  NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
> @@ -594,6 +594,8 @@ GetVariableStore (
>  PcdGet64 
> (PcdFlashNvStorageVariableBase64) :
>  PcdGet32 
> (PcdFlashNvStorageVariableBase)
> );
> +ASSERT (NvStorageBase != 0);
> +
>  //
>  // First let FvHeader point to NV storage base.
>  //
> diff --git a/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
> b/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
> index 565efdc02116..3161617a56c2 100644
> --- a/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
> +++ b/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
> @@ -3,7 +3,7 @@
>  #
>  #  This module implements ReadOnly Variable Services required by PEIM
> and installs PEI ReadOnly Varaiable2 PPI.
>  #
> -#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>  #  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
> @@ -68,6 +68,7 @@ [Pcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase  ##
> SOMETIMES_CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize  ##
> CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
> ## SOMETIMES_CONSUMES
> 
>  [Depex]
>gEdkiiFaultTolerantWriteGuid
> --
> 2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V3 09/17] MdeModulePkg: Refine description a little for PcdEmuVariableNvStoreReserved

2019-01-15 Thread Wu, Hao A
Reviewed-by: Hao Wu 

Best Regards,
Hao Wu


> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, January 15, 2019 6:30 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Wang, Jian J; Wu, Hao A
> Subject: [PATCH V3 09/17] MdeModulePkg: Refine description a little for
> PcdEmuVariableNvStoreReserved
> 
> This patch is not related directly to
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> PcdEmuVariableNvStoreReserved actually defines the base address of
> reserved memory range.
> 
> This patch refines description a little for PcdEmuVariableNvStoreReserved.
> 
> Suggested-by: Jian J Wang 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 6 +++---
>  MdeModulePkg/MdeModulePkg.uni | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 2be77022c948..e5c32d15edcd 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1594,9 +1594,9 @@ [PcdsFixedAtBuild, PcdsPatchableInModule,
> PcdsDynamic, PcdsDynamicEx]
># @Prompt EMU variable NV mode enable.
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|FALSE
> |BOOLEAN|0x0111
> 
> -  ## This PCD defines a reserved memory range for EMU variable NV storage.
> -  #  The range is valid if non-zero. The memory range size must be
> PcdVariableStoreSize.
> -  # @Prompt Reserved memory range for EMU variable NV storage.
> +  ## This PCD defines the base address of reserved memory range for EMU
> variable NV storage.
> +  #  A non-ZERO value indicates a valid range reserved with size given by
> PcdVariableStoreSize.
> +  # @Prompt Base of reserved memory range for EMU variable NV storage.
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0|UI
> NT64|0x4008
> 
>## This PCD defines the times to print hello world string.
> diff --git a/MdeModulePkg/MdeModulePkg.uni
> b/MdeModulePkg/MdeModulePkg.uni
> index 2f437d78eba2..787fdf2282c3 100644
> --- a/MdeModulePkg/MdeModulePkg.uni
> +++ b/MdeModulePkg/MdeModulePkg.uni
> @@ -397,9 +397,9 @@
>   
>  "TRUE  - An EMU variable NV
> storage will be allocated or reserved for NV variables."
>   
>  "FALSE - No EMU variable NV
> storage will be allocated or reserved for NV variables."
> 
> -#string
> STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved
> _PROMPT  #language en-US "Reserved memory range for EMU variable NV
> storage"
> +#string
> STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved
> _PROMPT  #language en-US "Base of reserved memory range for EMU
> variable NV storage"
> 
> -#string
> STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved
> _HELP  #language en-US "This PCD defines a reserved memory range for
> EMU variable NV storage. The range is valid if non-zero. The memory range
> size must be PcdVariableStoreSize."
> +#string
> STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved
> _HELP  #language en-US "This PCD defines the base address of reserved
> memory range for EMU variable NV storage. A non-ZERO value indicates a
> valid range reserved with size given by PcdVariableStoreSize."
> 
>  #string
> STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHelloWorldPrintTimes_PROM
> PT  #language en-US "HelloWorld print times"
> 
> --
> 2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V3 03/17] MdeModulePkg Variable: Move "extern XXX" to Variable.h

2019-01-15 Thread Wu, Hao A
Reviewed-by: Hao Wu 

Best Regards,
Hao Wu


> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, January 15, 2019 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Wang, Jian J; Wu, Hao A
> Subject: [PATCH V3 03/17] MdeModulePkg Variable: Move "extern XXX" to
> Variable.h
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> Move "extern XXX" to Variable.h from VariableDxe.c/VariableSmm.c.
> 
> This patch prepares for adding emulated variable NV mode
> support in VariableRuntimeDxe.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h| 11
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c |  4 
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c |  3 ---
>  3 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
> index 938eb5de61fa..90507a8e64f6 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
> @@ -792,9 +792,14 @@ InitializeVariableQuota (
>VOID
>);
> 
> -extern VARIABLE_MODULE_GLOBAL  *mVariableModuleGlobal;
> -
> -extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut;
> +extern VARIABLE_MODULE_GLOBAL   *mVariableModuleGlobal;
> +extern EFI_FIRMWARE_VOLUME_HEADER   *mNvFvHeaderCache;
> +extern VARIABLE_STORE_HEADER*mNvVariableCache;
> +extern VARIABLE_INFO_ENTRY  *gVariableInfo;
> +extern BOOLEAN  mEndOfDxe;
> +extern VAR_CHECK_REQUEST_SOURCE mRequestSource;
> +
> +extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut;
> 
>  /**
>Finds variable in storage blocks of volatile and non-volatile storage 
> areas.
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> index f7185df3a7eb..f1304c9dbccc 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> @@ -17,13 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> 
>  #include "Variable.h"
> 
> -extern VARIABLE_STORE_HEADER*mNvVariableCache;
> -extern EFI_FIRMWARE_VOLUME_HEADER   *mNvFvHeaderCache;
> -extern VARIABLE_INFO_ENTRY  *gVariableInfo;
>  EFI_HANDLE  mHandle= NULL;
>  EFI_EVENT   mVirtualAddressChangeEvent = NULL;
>  EFI_EVENT   mFtwRegistration   = NULL;
> -extern BOOLEAN  mEndOfDxe;
>  VOID***mVarCheckAddressPointer = NULL;
>  UINTN   mVarCheckAddressPointerCount = 0;
>  EDKII_VARIABLE_LOCK_PROTOCOLmVariableLock  =
> { VariableLockRequestToLock };
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> index 8c53f84ff6e8..623badb0c755 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> @@ -37,14 +37,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF
> ANY KIND, EITHER EXPRESS OR IMPLIED.
>  #include 
>  #include "Variable.h"
> 
> -extern VARIABLE_INFO_ENTRY   *gVariableInfo;
>  EFI_HANDLE   mSmmVariableHandle  
> = NULL;
>  EFI_HANDLE   mVariableHandle 
> = NULL;
>  BOOLEAN  mAtRuntime  
> = FALSE;
>  UINT8*mVariableBufferPayload 
> = NULL;
>  UINTN
> mVariableBufferPayloadSize;
> -extern BOOLEAN   mEndOfDxe;
> -extern VAR_CHECK_REQUEST_SOURCE  mRequestSource;
> 
>  /**
>SecureBoot Hook for SetVariable.
> --
> 2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] BaseTools:Evaluation of undefined macros in dsc files

2019-01-15 Thread Fan, ZhijuX
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=989

doc:If macro that is not defined is used in locations
that are not expressions (where the tools would just
do macro expansion as in C flags in a [BuildOptions]
section), nothing will be emitted.

This is in fact not what happens.Instead, the text
$(MACRO1) is emitted verbatim into the Makefile
and left the for make to process.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/GenMake.py | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py 
b/BaseTools/Source/Python/AutoGen/GenMake.py
index 4da10e3950..fe07564bb3 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -34,7 +34,7 @@ gIncludePattern = re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ 
\t]*(?:\\(?:\r\n|\r
 
 ## Regular expression for matching macro used in header file inclusion
 gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
-
+gMacroRePattern = re.compile('.*?(\$\(\w*?\)).*?')
 gIsFileMap = {}
 
 ## pattern for include style in Edk.x code
@@ -517,7 +517,21 @@ cleanlib:
 continue
 # Remove duplicated include path, if any
 if Attr == "FLAGS":
-Value = RemoveDupOption(Value, IncPrefix, 
MyAgo.IncludePathList)
+Value = ValueCopy = RemoveDupOption(Value, IncPrefix, 
MyAgo.IncludePathList)
+while (ValueCopy.find('$(') != -1):
+for macro in self._AutoGenObject.Macros:
+MacroName = '$(' + macro + ')'
+if (ValueCopy.find(MacroName) != -1):
+ValueCopy = ValueCopy.replace(MacroName, 
self._AutoGenObject.Macros[macro])
+break
+else:
+if gMacroRePattern.search(ValueCopy, 
re.UNICODE):
+FlageReList = 
gMacroRePattern.findall(ValueCopy, re.UNICODE)
+for FlageRe in FlageReList:
+Value = Value.replace(FlageRe, 
'').strip()
+break
+else:
+break
 if Tool == "OPTROM" and PCI_COMPRESS_Flag:
 ValueList = Value.split()
 if ValueList:
-- 
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] BaseTools VolInfo: Fix XCODE5 build issue

2019-01-15 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Liming 
Gao
Sent: Wednesday, January 16, 2019 2:45 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch] BaseTools VolInfo: Fix XCODE5 build issue

XCODE5 reports warning "equality comparison with extraneous parentheses".
Remove extraneous parentheses around the comparison to silence this warning.
This issue is caused by commit 8daa4278e80c70e6caabc525cd122744488253f5.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Feng Bob C 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 89fe3a044d..c8a99face2 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -1573,7 +1573,7 @@ Returns:
   //
   // Update Image Base Address
   //
-  if ((ImgHdr->Pe32.OptionalHeader.Magic == 
EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
+  if (ImgHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
 ImgHdr->Pe32.OptionalHeader.ImageBase = (UINT32) NewPe32BaseAddress;
   } else if (ImgHdr->Pe32Plus.OptionalHeader.Magic == 
EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
 ImgHdr->Pe32Plus.OptionalHeader.ImageBase = NewPe32BaseAddress;
-- 
2.13.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools VolInfo: Fix XCODE5 build issue

2019-01-15 Thread Liming Gao
XCODE5 reports warning "equality comparison with extraneous parentheses".
Remove extraneous parentheses around the comparison to silence this warning.
This issue is caused by commit 8daa4278e80c70e6caabc525cd122744488253f5.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Feng Bob C 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 89fe3a044d..c8a99face2 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -1573,7 +1573,7 @@ Returns:
   //
   // Update Image Base Address
   //
-  if ((ImgHdr->Pe32.OptionalHeader.Magic == 
EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
+  if (ImgHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
 ImgHdr->Pe32.OptionalHeader.ImageBase = (UINT32) NewPe32BaseAddress;
   } else if (ImgHdr->Pe32Plus.OptionalHeader.Magic == 
EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
 ImgHdr->Pe32Plus.OptionalHeader.ImageBase = NewPe32BaseAddress;
-- 
2.13.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class

2019-01-15 Thread Zeng, Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

Add the library interface for the standalone MM driver entry point.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  MdePkg/MdePkg.dec |   3 +
  MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h | 134 

  2 files changed, 137 insertions(+)

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index a7383b6daafb..a4854083105d 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -247,6 +247,9 @@ [LibraryClasses]
#Only available to MM_STANDALONE, SMM/DXE Combined and SMM 
module types.
MmServicesTableLib|Include/Library/MmServicesTableLib.h
  
+  ##  @libraryclass  Module entry point library for standalone MM drivers.

+  StandaloneMmDriverEntryPoint|Include/Library/StandaloneMmDriverEntryPoint.h
+
  [LibraryClasses.IA32, LibraryClasses.X64]
##  @libraryclass  Abstracts both S/W SMI generation and detection.
##
diff --git a/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h 
b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
new file mode 100644
index ..d08a73303dbb
--- /dev/null
+++ b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
@@ -0,0 +1,134 @@
+/** @file
+  Module entry point library for Standalone MM Drivers.
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+Copyright (c) 2018, Linaro, Limited. All rights reserved.
+
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __MODULE_ENTRY_POINT_H__
+#define __MODULE_ENTRY_POINT_H__
+
+///
+/// Declare the PI Specification Revision that this driver requires to execute
+/// correctly.
+///
+extern CONST UINT32   _gMmRevision;
+
+/**
+  The entry point of PE/COFF Image for a Standalone MM Driver.
+
+  This function is the entry point for a Standalone MM Driver.
+  This function must call ProcessLibraryConstructorList() and
+  ProcessModuleEntryPointList().
+  If the return status from ProcessModuleEntryPointList()
+  is an error status, then ProcessLibraryDestructorList() must be called.
+  The return value from ProcessModuleEntryPointList() is returned.


noop


+  If _gDriverUnloadImageCount is greater
+  than zero, then an unload handler must be registered for this image and
+  the unload handler must invoke ProcessModuleUnloadList().


This block could be removed.


+  If _gMmRevision is not zero and SystemTable->Hdr.Revision is


SystemTable should be MmSystemTable.


+  less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.


_gUefiDriverRevison should be _gMmRevision.


+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the EFI System Table.
+
+  @retval  EFI_SUCCESS   The Standalone MM Driver exited normally.
+  @retval  EFI_INCOMPATIBLE_VERSION  _gMmRevision is greater than
+ SystemTable->Hdr.Revision.


SystemTable should be MmSystemTable.

These feedback may be also applied to the implementation in next patch.

With them handled, Acked-by: Star Zeng  to this and 
next patches.


Thanks,
Star



+  @retval  Other Return value from
+ ProcessModuleEntryPointList().
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*MmSystemTable
+  );
+
+
+/**
+  Auto generated function that calls the library constructors for all of the
+  module's dependent libraries.
+
+  This function must be called by _ModuleEntryPoint().
+  This function calls the set of library constructors for the set of library
+  instances that a module depends on.  This includes library instances that a
+  module depends on directly and library instances that a module depends on
+  indirectly through other libraries. This function is auto generated by build
+  tools and those build tools are responsible for collecting the set of library
+  instances, determine which ones have constructors, and calling the library
+  constructors in the proper order based upon each of the library instances own
+  dependencies.
+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the MM System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*MmSystemTable
+  );
+
+
+/**
+  Auto generated function that calls the library descructors for all of the
+  module's 

Re: [edk2] [PATCH v2 14/17] MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only section

2019-01-15 Thread Zeng, Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf does not
build for AARCH64 since it does not provide the needed PlDebugSupport.h
header. So move the module to a x86 only section.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 


Reviewed-by: Star Zeng 


---
  MdeModulePkg/MdeModulePkg.dsc | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 967fe082aaae..3e9a9daf1649 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -421,7 +421,6 @@ [Components]
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
  
  [Components.IA32, Components.X64, Components.AARCH64]

-  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
@@ -438,6 +437,7 @@ [Components.IA32, Components.X64, Components.Ebc]
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
  
  [Components.IA32, Components.X64]

+  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.inf
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V3 16/17] CorebootPayloadPkg: Use merged variable driver for emulated NV mode

2019-01-15 Thread You, Benjamin
Reviewed-by: Benjamin You 

> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, January 15, 2019 6:30 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Ma, Maurice ;
> Agyeman, Prince ; You, Benjamin
> 
> Subject: [PATCH V3 16/17] CorebootPayloadPkg: Use merged variable driver for
> emulated NV mode
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> The real variable driver has been updated to support emulated
> variable NV mode and the EmuVariableRuntimeDxe will be removed
> later, so use merged variable driver for emulated NV mode.
> 
> Cc: Maurice Ma 
> Cc: Prince Agyeman 
> Cc: Benjamin You 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  CorebootPayloadPkg/CorebootPayloadPkg.fdf|  4 ++--
>  CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc| 11 +--
>  CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc | 11 +--
>  3 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/CorebootPayloadPkg/CorebootPayloadPkg.fdf
> b/CorebootPayloadPkg/CorebootPayloadPkg.fdf
> index 741a5c232ed8..0c24f96a1561 100644
> --- a/CorebootPayloadPkg/CorebootPayloadPkg.fdf
> +++ b/CorebootPayloadPkg/CorebootPayloadPkg.fdf
> @@ -3,7 +3,7 @@
>  #
>  # Provides drivers and definitions to create uefi payload for coreboot.
>  #
> -# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
> +# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
>  # This program and the accompanying materials are licensed and made
> available under
>  # the terms and conditions of the BSD License that accompanies this 
> distribution.
>  # The full text of the license may be found at
> @@ -109,7 +109,7 @@ [FV.DXEFV]
>  INF
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterR
> untimeDxe.inf
>  INF
> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.in
> f
>  INF
> PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe
> .inf
> -INF
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.i
> nf
> +INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> 
>  INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
>  INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
> diff --git a/CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc
> b/CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc
> index 467d4fcdb422..98d6073866f0 100644
> --- a/CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc
> +++ b/CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc
> @@ -3,7 +3,7 @@
>  #
>  # Provides drivers and definitions to create uefi payload for coreboot.
>  #
> -# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
> +# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
>  # This program and the accompanying materials are licensed and made
> available under
>  # the terms and conditions of the BSD License that accompanies this 
> distribution.
>  # The full text of the license may be found at
> @@ -203,6 +203,9 @@ [LibraryClasses]
> 
> DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDe
> bugLibReportStatusCode.inf
>LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
>FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
> +
> AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibN
> ull.inf
> +
> TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmM
> easurementLibNull.inf
> +  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
> 
>  [LibraryClasses.IA32.SEC]
>DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
> @@ -277,6 +280,10 @@ [PcdsFixedAtBuild]
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x1
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000
>gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x1
> +  #
> +  # Make VariableRuntimeDxe work at emulated non-volatile variable mode.
> +  #
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
> 
>gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0
>gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa,
> 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23,
> 0x31 }
> @@ -417,7 +424,7 @@ [Components.IA32]
> 
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterR
> untimeDxe.inf
> 
> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.in
> f
> 
> PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe
> .inf
> -
> MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.i
> nf
> +  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> 
>#
># Following are the DXE drivers
> diff --git a/CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc
> b/CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc
> index 673bd26c7973..608a288c425f 100644
> --- 

Re: [edk2] [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class

2019-01-15 Thread Zeng, Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

In order to permit MM_STANDALONE modules to be built without relying
on StandaloneMmPkg, provide a BASE type NULL implementation of HobLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 


Reviewed-by: Star Zeng 


---
  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf |  38 ++
  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c   | 542 

  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni |  20 +
  3 files changed, 600 insertions(+)

diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf 
b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
new file mode 100644
index ..c0e927ff14be
--- /dev/null
+++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
@@ -0,0 +1,38 @@
+## @file
+# Null instance of HOB Library.
+#
+# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+#
+#  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
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001B
+  BASE_NAME  = BaseHobLibNull
+  MODULE_UNI_FILE= BaseHobLibNull.uni
+  FILE_GUID  = a89dea6f-c9a0-40be-903c-7cac2ef8a0e7
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = HobLib
+
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  BaseHobLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c 
b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
new file mode 100644
index ..0ea7d9304e9d
--- /dev/null
+++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
@@ -0,0 +1,542 @@
+/** @file
+  Provide Hob Library functions for build testing only.
+
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+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
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include 
+#include 
+
+#include 
+#include 
+
+/**
+  Returns the pointer to the HOB list.
+
+  This function returns the pointer to first HOB in the list.
+  For PEI phase, the PEI service GetHobList() can be used to retrieve the 
pointer
+  to the HOB list.  For the DXE phase, the HOB list pointer can be retrieved 
through
+  the EFI System Table by looking up theHOB list GUID in the System 
Configuration Table.
+  Since the System Configuration Table does not exist that the time the DXE 
Core is
+  launched, the DXE Core uses a global variable from the DXE Core Entry Point 
Library
+  to manage the pointer to the HOB list.
+
+  If the pointer to the HOB list is NULL, then ASSERT().
+
+  @return The pointer to the HOB list.
+
+**/
+VOID *
+EFIAPI
+GetHobList (
+  VOID
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Returns the next instance of a HOB type from the starting HOB.
+
+  This function searches the first instance of a HOB type from the starting 
HOB pointer.
+  If there does not exist such HOB type from the starting HOB pointer, it will 
return NULL.
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the 
starting HOB pointer
+  unconditionally: it returns HobStart back if HobStart itself meets the 
requirement;
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current 
HobStart.
+
+  If HobStart is NULL, then ASSERT().
+
+  @param  Type  The HOB type to return.
+  @param  HobStart  The starting HOB pointer to search from.
+
+  @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetNextHob (
+  IN UINT16 Type,
+  IN CONST VOID *HobStart
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Returns the first instance of a HOB type among the whole HOB list.
+
+  This function searches the first instance of a HOB type among the whole HOB 
list.
+  If there does not exist such HOB type in the HOB list, it will return NULL.
+
+  If the pointer to the HOB list is NULL, then ASSERT().
+
+  @param  Type  The HOB type to return.
+
+  @return The next instance of a HOB 

Re: [edk2] [PATCH v2 13/17] MdeModulePkg: implement NULL instance of MemoryAllocationLib library class

2019-01-15 Thread Zeng, Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

In order to permit MM_STANDALONE modules to be built without relying
on StandaloneMmPkg, provide a BASE type NULL implementation of
MemoryAllocationLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  
MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
 |  38 ++
  
MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c  
 | 575 
  
MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni
 |  20 +
  3 files changed, 633 insertions(+)

diff --git 
a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
 
b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
new file mode 100644
index ..c231cd0e271b
--- /dev/null
+++ 
b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
@@ -0,0 +1,38 @@
+## @file
+# Null instance of Memory Allocation Library.
+#
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+#
+#  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
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001B
+  BASE_NAME  = BaseMemoryAllocationLibNull
+  MODULE_UNI_FILE= BaseMemoryAllocationLibNull.uni
+  FILE_GUID  = fd56f5d6-f194-448f-be69-c0cbb0c281af
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = MemoryAllocationLib
+
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  BaseMemoryAllocationLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
diff --git 
a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
 
b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
new file mode 100644
index ..16812d3f9bb3
--- /dev/null
+++ 
b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
@@ -0,0 +1,575 @@
+/** @file
+  DUmmy support routines for memory allocation


Should be "Dummy" here?

With it handled, Reviewed-by: Star Zeng .

Thanks,
Star


+
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+  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
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#include 
+
+#include 
+#include 
+
+
+/**
+  Allocates one or more 4KB pages of type EfiBootServicesData.
+
+  Allocates the number of 4KB pages of type EfiBootServicesData and returns a 
pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If 
Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the 
request, then NULL is
+  returned.
+
+  @param  Pages The number of 4 KB pages to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocatePages (
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData.
+
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns 
a pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If 
Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the 
request, then NULL is
+  returned.
+
+  @param  Pages The number of 4 KB pages to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePages (
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiReservedMemoryType.
+
+  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns 
a pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If 
Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the 
request, then NULL is
+  returned.
+
+  @param  Pages The number of 4 KB pages 

Re: [edk2] [PATCH v2 17/17] MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules

2019-01-15 Thread Zeng, Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

For build testing coverage, add the newly introduced MM_STANDALONE
versions of the fault tolerant write (FTW) and variable runtime
driver to MdeModulePkg.dsc. Note that the resulting binaries will
not be able to run, since they rely on dummy implementations of
MemoryAllocationLib and HobLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 


Reviewed-by: Star Zeng 


---
  MdeModulePkg/MdeModulePkg.dsc | 9 +
  1 file changed, 9 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 3e9a9daf1649..93eaf4b404a1 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -168,6 +168,12 @@ [LibraryClasses.common.UEFI_APPLICATION]

MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
  
+[LibraryClasses.common.MM_STANDALONE]

+  HobLib|MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
+  
MemoryAllocationLib|MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
+  
StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
+  
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
+
  [LibraryClasses.ARM, LibraryClasses.AARCH64]
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -420,6 +426,9 @@ [Components]
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
  
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf

+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
+
  [Components.IA32, Components.X64, Components.AARCH64]
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 16/17] MdeModulePkg/VarCheckLib: add MM_STANDALONE support

2019-01-15 Thread Zeng, Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

Add MM_STANDALONE to the list of permitted module types of the
VarCheckLib library implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 


Reviewed-by: Star Zeng 


---
  MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf 
b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
index 099f83dd6aee..b1041c290df9 100644
--- a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+++ b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
@@ -21,7 +21,7 @@ [Defines]
FILE_GUID  = 63E12D08-0C5D-47F8-95E4-09F89D7506C5
MODULE_TYPE= DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
-  LIBRARY_CLASS  = VarCheckLib|DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER
+  LIBRARY_CLASS  = VarCheckLib|DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER MM_STANDALONE
  
  #

  # The following information is for reference only and not required by the 
build tools.



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 15/17] MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support

2019-01-15 Thread Zeng, Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

Add MM_STANDALONE to the list of permitted module types of the
AuthVariableLibNull library implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 


Reviewed-by: Star Zeng 


---
  MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf 
b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
index 900fef5d4989..93f3e675a2ff 100644
--- a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+++ b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
@@ -21,7 +21,7 @@ [Defines]
FILE_GUID  = 435CB0E4-7C9A-4BB7-9907-8FD4643E978A
MODULE_TYPE= DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
-  LIBRARY_CLASS  = AuthVariableLib|DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER
+  LIBRARY_CLASS  = AuthVariableLib|DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER MM_STANDALONE
  
  #

  # The following information is for reference only and not required by the 
build tools.



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 01/17] MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution

2019-01-15 Thread Zeng, Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

The SMM based FTW and variable drivers are going to depend on
MmServicesTableLib after a subsequent patch, so add a resolution
for it to MdeModulePkg.dsc.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 


Reviewed-by: Star Zeng 


---
  MdeModulePkg/MdeModulePkg.dsc | 1 +
  1 file changed, 1 insertion(+)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 5d042be3a862..967fe082aaae 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -152,6 +152,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf

MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf

SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 08/17] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version

2019-01-15 Thread Zeng, Star

One minor comment.

With it handled, Reviewed-by: Star Zeng 

On 2019/1/14 21:27, Ard Biesheuvel wrote:

Reuse most of the existing code to implement a variable runtime
driver that will be able to execute in the context of standalone
MM.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Jian J Wang 
Reviewed-by: Star Zeng 
---
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 136 

  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c   |  89 
+
  2 files changed, 225 insertions(+)



[Trimmed]


+
+/**
+  Variable service MM driver entry point


The comments block should have description for the two parameters and 
return status (forgot to mention this for other places).



Thanks,
Star


+**/
+EFI_STATUS
+EFIAPI
+VariableServiceInitialize (
+  IN EFI_HANDLE   ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE  *MmSystemTable
+  )
+{
+  return MmVariableServiceInitialize ();
+}
+
+/**
+  Whether the TCG or TCG2 protocols are installed in the UEFI protocol 
database.
+  This information is used by the MorLock code to infer whether an existing
+  MOR variable is legitimate or not.
+
+  @retval TRUE  Either the TCG or TCG2 protocol is installed in the UEFI
+protocol database
+  @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
+protocol database
+**/
+BOOLEAN
+VariableHaveTcgProtocols (
+  VOID
+  )
+{
+  return FALSE;
+}



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 07/17] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses

2019-01-15 Thread Zeng, Star

Some minor comments.

With them handled, Reviewed-by: Star Zeng 

On 2019/1/14 21:27, Ard Biesheuvel wrote:

In preparation of providing a standalone MM based variable runtime
driver, move the existing SMM driver to the new MM services table,
and factor out some pieces that are specific to the traditional
driver, mainly related to the use of UEFI boot services, which are
not accessible to standalone MM drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Regression-tested-by: Laszlo Ersek 
---
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf |   5 +-
  MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h  |  58 
+
  MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c |  18 +--
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c   |  59 
+++--
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c | 130 

  5 files changed, 211 insertions(+), 59 deletions(-)



[Trimmed]


diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
index 7af22a4ad671..eb84589fc404 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
@@ -97,4 +97,62 @@ VariableSpeculationBarrier (
VOID
);
  
+/**

+  Notify the system that the SMM variable driver is ready
+**/
+VOID
+VariableNotifySmmReady (
+  VOID
+  );
+
+/**
+  Notify the system that the SMM variable write driver is ready
+**/
+VOID
+VariableNotifySmmWriteReady (
+  VOID
+  );
+
+/**
+  Variable service MM driver entry point


The block should be matched with the MmVariableServiceInitialize 
implementation in VariableSmm.c. But not SmmVariableServiceInitialize 
implementation in VariableTraditionalMm.c



+**/
+EFI_STATUS
+EFIAPI
+MmVariableServiceInitialize (
+  VOID
+  );
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+with SMRAM.
+**/
+BOOLEAN
+VariableSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64Length
+  );
+
+/**
+  Whether the TCG or TCG2 protocols are installed in the UEFI protocol 
database.
+  This information is used by the MorLock code to infer whether an existing
+  MOR variable is legitimate or not.
+
+  @retval TRUE  Either the TCG or TCG2 protocol is installed in the UEFI
+protocol database
+  @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
+protocol database
+**/
+BOOLEAN
+VariableHaveTcgProtocols (
+  VOID
+  );
+
  #endif


[Trimmed]


@@ -928,18 +920,11 @@ SmmFtwNotificationEvent (
runtime services in the EFI System Table and installs arch protocols
for variable read and write services being available. It also registers
a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
-
-  @param[in] ImageHandleThe firmware allocated handle for the EFI image.
-  @param[in] SystemTableA pointer to the EFI System Table.
-
-  @retval EFI_SUCCESS   Variable service successfully initialized.


This line needs to be kept.


-
  **/
  EFI_STATUS
  EFIAPI
-VariableServiceInitialize (
-  IN EFI_HANDLE   ImageHandle,
-  IN EFI_SYSTEM_TABLE *SystemTable
+MmVariableServiceInitialize (
+  VOID
)
  {
EFI_STATUS  Status;
@@ -957,7 +942,7 @@ VariableServiceInitialize (
// Install the Smm Variable Protocol on a new handle.
//
VariableHandle = NULL;
-  Status = gSmst->SmmInstallProtocolInterface (
+  Status = gMmst->MmInstallProtocolInterface (
  ,
  ,
  EFI_NATIVE_INTERFACE,
@@ -965,7 +950,7 @@ VariableServiceInitialize (
  );
ASSERT_EFI_ERROR (Status);
  
-  Status = gSmst->SmmInstallProtocolInterface (

+  Status = gMmst->MmInstallProtocolInterface (
  ,
  ,
  EFI_NATIVE_INTERFACE,
@@ -976,7 +961,7 @@ VariableServiceInitialize (
mVariableBufferPayloadSize = GetMaxVariableSize () +
 OFFSET_OF 
(SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY, Name) - 
GetVariableHeaderSize ();
  
-  Status = gSmst->SmmAllocatePool (

+  Status = gMmst->MmAllocatePool (
  EfiRuntimeServicesData,
  mVariableBufferPayloadSize,
  (VOID **)
@@ -987,25 +972,19 @@ VariableServiceInitialize (

Re: [edk2] [PATCH v2 06/17] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version

2019-01-15 Thread Zeng, Star

One minor comment.

With it handled, Reviewed-by: Star Zeng 

On 2019/1/14 21:27, Ard Biesheuvel wrote:

Implement a new version of the fault tolerant write driver that can
be used in the context of a standalone MM implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Jian J Wang 
---
  
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 
| 90 
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c 
  | 88 +++
  2 files changed, 178 insertions(+)



[Trimmed]


diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
new file mode 100644
index ..95effd6d75fa
--- /dev/null
+++ 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
@@ -0,0 +1,88 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include 
+#include 
+#include "FaultTolerantWrite.h"
+#include "FaultTolerantWriteSmmCommon.h"
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+with SMRAM.
+**/
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64Length
+  )
+{
+  return TRUE;
+}
+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (standalone SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer   A pointer to the buffer on which the 32-bit CRC is 
to be computed.
+  @param[in]  Length   The number of bytes in the buffer Data.
+
+  @retval Crc32The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID *Buffer,
+  IN  UINTNLength
+  )
+{
+  return CalculateCrc32 (Buffer, Length);
+}
+
+/**
+  Notify the system that the SMM FTW driver is ready
+**/
+VOID
+FtwNotifySmmReady (
+  VOID
+  )
+{
+}
+
+/**
+  Entry point of the module


The comments block should have description for the two parameters.


Thanks,
Star


+**/
+EFI_STATUS
+EFIAPI
+StandaloneMmFaultTolerantWriteInitialize (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 05/17] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses

2019-01-15 Thread Zeng, Star

Some minor comments.

With them handled, Reviewed-by: Star Zeng 

Thanks,
Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:

In preparation of providing a standalone MM based FTW driver, move
the existing SMM driver to the new MM services table, and factor out
some pieces that are specific to the traditional driver, mainly
related to the use of UEFI boot services, which are not accessible
to standalone MM drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Jian J Wang 
Regression-tested-by: Laszlo Ersek 
---
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
 |   5 +-
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h 
 |  23 -
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
 |  34 +++
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c  
 |  31 ++
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c  
 |  53 --
  
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c 
| 106 
  MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c 
 |  10 +-
  7 files changed, 219 insertions(+), 43 deletions(-)



[Trimmed]

  
+/**

+  Entry point of the module
+**/


The block should be matched with the MmFaultTolerantWriteInitialize 
implementation in FaultTolerantWriteSmm.c. But not 
SmmFaultTolerantWriteInitialize implementation in 
FaultTolerantWriteTraditionalMm.c



+EFI_STATUS
+MmFaultTolerantWriteInitialize (
+  VOID
+  );
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+with SMRAM.
+**/
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64Length
+  );
+
+/**
+  Notify the system that the SMM FTW driver is ready
+**/
+VOID
+FtwNotifySmmReady (
+  VOID
+  );
+
  #endif
diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
index 094e40f9d86c..24e507104bbe 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
@@ -51,6 +51,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.


[Trimmed]

  
  **/

  EFI_STATUS
-EFIAPI
-SmmFaultTolerantWriteInitialize (
-  IN EFI_HANDLE   ImageHandle,
-  IN EFI_SYSTEM_TABLE *SystemTable


The comments block should be also removed for these two parameters.


+MmFaultTolerantWriteInitialize (
+  VOID
)
  {
EFI_STATUS  Status;
-  VOID*SmmEndOfDxeRegistration;
+  VOID*MmEndOfDxeRegistration;
  
//

// Allocate private data structure for SMM FTW protocol and do some 
initialization
@@ -634,17 +623,17 @@ SmmFaultTolerantWriteInitialize (
//
// Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
//
-  Status = gSmst->SmmRegisterProtocolNotify (
-,
-SmmEndOfDxeCallback,
-
+  Status = gMmst->MmRegisterProtocolNotify (
+,
+MmEndOfDxeCallback,
+
  );
ASSERT_EFI_ERROR (Status);
  
//

// Register FvbNotificationEvent () notify function.
//
-  Status = gSmst->SmmRegisterProtocolNotify (
+  Status = gMmst->MmRegisterProtocolNotify (
  ,
  FvbNotificationEvent,
  
diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
new file mode 100644
index ..78351199d3f1
--- /dev/null
+++ 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
@@ -0,0 +1,106 @@


[Trimmed]


+
+/**
+  Entry point of the module


The comments block should have description for the two parameters.


Thanks,
Star


+**/
+EFI_STATUS
+EFIAPI
+SmmFaultTolerantWriteInitialize (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
index 50d3421b88bb..d09e9719cf05 100644
--- 

Re: [edk2] [PATCH V3 00/17] Merge EmuVariable and Real variable driver

2019-01-15 Thread Wang, Jian J
For patch 1-12,17
Reviewed-by: Jian J Wang 


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Star
> Zeng
> Sent: Tuesday, January 15, 2019 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star 
> Subject: [edk2] [PATCH V3 00/17] Merge EmuVariable and Real variable driver
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> 
> Purpose:
> 1. Add emulated variable NV mode support in
>MdeModulePkg\Universal\Variable\RuntimeDxe.
>Platform can configure PCD statically (build time) or
>dynamically (boot time) to support emulated variable NV mode.
> 2. Remove MdeModulePkg\Universal\Variable\EmuRuntimeDxe whose
>most codes are duplicated.
> 
> 
> V3:
> Addressed all the great feedbacks from Jian, Hao, Laszlo and Leif, thanks.
> Pick up RB and AB tags.
> 
> Repo: g...@github.com:lzeng14/edk2.git
> Branch: MergedVariableDriver_EmuNvMode_V3
> 
> Patches 1~9: Preparation
>   Patch 3 and 9 are new added based on feedbacks.
> Patch 10~11: Real work
> Patch 12~17: Migration for platforms and cleanup
> 
> 
> V2: Addressed all the feedbacks from Laszlo, thanks.
> 
> Repo: g...@github.com:lzeng14/edk2.git
> Branch: MergedVariableDriver_EmuNvMode_V2
> 
> Patches 1~7: Preparation
>   Patch 6 and 7 are new separated.
> Patch 8~9: Real work
> Patch 10~15: Migration for platforms and cleanup
>   Patch 11 is new added to let ArmVirtXen be aligned with ArmVirtQemuXXX.
> 
> 
> V1:
> 
> Repo: g...@github.com:lzeng14/edk2.git
> Branch: MergedVariableDriver_EmuNvMode
> 
> Patches 1~5: Preparation
> Patch 6~7: Real work
> Patch 8~12: Migration for platforms and cleanup
> 
> Test done:
> Build code with VS2012, VS2015 and GCC49.
> Regression: Boot Nt32, Ovmf (including 32, 3264 and 64 with no SMM) to UEFI
> SHELL.
> Boot some internal platform to UEFI SHELL and Windows.
> Functionality: Boot Nt32, Ovmf (including 32, 3264 and 64 with no SMM) to UEFI
> SHELL
>with PcdEmuVariableNvModeEnable == TRUE.
> 
> More test will be welcome and appreciated. :)
> 
> Patches to update edk2-platforms Repo will be sent out separately.
> 
> Star Zeng (17):
>   MdeModulePkg Variable: Add some missing changes for 9b18845
>   MdeModulePkg Variable: Abstract InitRealNonVolatileVariableStore
>   MdeModulePkg Variable: Move "extern XXX" to Variable.h
>   MdeModulePkg Variable: Not get NV PCD in
> VariableWriteServiceInitialize
>   MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm
>   MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()
>   MdeModulePkg Variable: type case VolatileBase to UINTN directly
>   MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec
>   MdeModulePkg: Refine description a little for
> PcdEmuVariableNvStoreReserved
>   MdeModulePkg Variable: Add emulated variable NV mode support
>   MdeModulePkg VariablePei: Don't check BOOT_IN_RECOVERY_MODE
>   ArmVirtXen: Use merged variable driver for emulated NV mode
>   ArmVirtXen: Link VarCheckUefiLib NULL class library instance
>   BeagleBoardPkg: Use merged variable driver for emulated NV mode
>   QuarkMin: Use merged variable driver for emulated NV mode
>   CorebootPayloadPkg: Use merged variable driver for emulated NV mode
>   MdeModulePkg: Remove EmuVariableRuntimeDxe
> 
>  ArmVirtPkg/ArmVirtXen.dsc  |   12 +-
>  ArmVirtPkg/ArmVirtXen.fdf  |4 +-
>  BeagleBoardPkg/BeagleBoardPkg.dsc  |   14 +-
>  BeagleBoardPkg/BeagleBoardPkg.fdf  |4 +-
>  CorebootPayloadPkg/CorebootPayloadPkg.fdf  |4 +-
>  CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc  |   11 +-
>  CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc   |   11 +-
>  MdeModulePkg/MdeModulePkg.dec  |   16 +-
>  MdeModulePkg/MdeModulePkg.dsc  |5 +-
>  MdeModulePkg/MdeModulePkg.uni  |   14 +-
>  .../Universal/Variable/EmuRuntimeDxe/EmuVariable.c | 1820 
> 
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxe.inf|   88 -
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxe.uni|   22 -
>  .../EmuRuntimeDxe/EmuVariableRuntimeDxeExtra.uni   |   19 -
>  .../Variable/EmuRuntimeDxe/InitVariable.c  |  259 ---
>  .../Universal/Variable/EmuRuntimeDxe/Variable.h|  277 ---
>  MdeModulePkg/Universal/Variable/Pei/Variable.c |8 +-
>  .../Universal/Variable/Pei/VariablePei.inf |3 +-
>  .../Universal/Variable/RuntimeDxe/Variable.c   |  431 +++--
>  .../Universal/Variable/RuntimeDxe/Variable.h   |   19 +-
>  .../Universal/Variable/RuntimeDxe/VariableDxe.c|  103 +-
>  .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |4 +-
>  .../Universal/Variable/RuntimeDxe/VariableSmm.c|   90 +-
>  .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |4 +-
>  QuarkPlatformPkg/QuarkMin.dsc  |8 +-
>  QuarkPlatformPkg/QuarkMin.fdf  |4 +-
>  26 files changed, 

Re: [edk2] [Patch] BaseTools: Fix incorrect formatting of GenFds command dictionary

2019-01-15 Thread Gao, Liming
Please update the patch to remove EFI_SOURCE. This has been removed from edk2 
master. 

Thanks
Liming
>-Original Message-
>From: Felix Polyudov [mailto:fel...@ami.com]
>Sent: Wednesday, January 16, 2019 7:33 AM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C ; Gao, Liming
>; Zhu, Yonghong 
>Subject: [Patch] BaseTools: Fix incorrect formatting of GenFds command
>dictionary
>
>The issue is introduced by commit
>b3497bad1221704a5dbc5da0b10f42625f1ad2ed.
>GenFdsCommand returned dictionary with elements that
>are not compatible with GenFdsApi.
>As a result the following options were not processed by GenFdsApi:
>-v, -q, -d, --genfds-multi-thread, --ignore-sources
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Felix Polyudov 
>---
> BaseTools/Source/Python/AutoGen/AutoGen.py | 54
>+-
> 1 file changed, 53 insertions(+), 1 deletion(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index cfe2d29..db3717d 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -3,6 +3,7 @@
> #
> # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
> # Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
>+# Copyright (c) 2019, American Megatrends, Inc. All rights reserved.
> #
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD
>License
>@@ -935,7 +936,58 @@ class WorkspaceAutoGen(AutoGen):
>
> @property
> def GenFdsCommandDict(self):
>-return GenMake.TopLevelMakefile(self)._TemplateDict
>+FdsCommandDict = {}
>+LogLevel = EdkLogger.GetLevel()
>+if LogLevel == EdkLogger.VERBOSE:
>+FdsCommandDict["verbose"] = True
>+elif LogLevel <= EdkLogger.DEBUG_9:
>+FdsCommandDict["debug"] = LogLevel - 1
>+elif LogLevel == EdkLogger.QUIET:
>+FdsCommandDict["quiet"] = True
>+
>+if GlobalData.gEnableGenfdsMultiThread:
>+FdsCommandDict["GenfdsMultiThread"] = True
>+if GlobalData.gIgnoreSource:
>+FdsCommandDict["IgnoreSources"] = True
>+
>+FdsCommandDict["OptionPcd"] = []
>+for pcd in GlobalData.BuildOptionPcd:
>+if pcd[2]:
>+pcdname = '.'.join(pcd[0:3])
>+else:
>+pcdname = '.'.join(pcd[0:2])
>+if pcd[3].startswith('{'):
>+FdsCommandDict["OptionPcd"].append(pcdname + '=' + 'H' + '"' +
>pcd[3] + '"')
>+else:
>+FdsCommandDict["OptionPcd"].append(pcdname + '=' + pcd[3])
>+
>+MacroList = []
>+# macros passed to GenFds
>+MacroList.append('"%s=%s"' % ("EFI_SOURCE",
>GlobalData.gEfiSource.replace('\\', '')))
>+MacroDict = {}
>+MacroDict.update(GlobalData.gGlobalDefines)
>+MacroDict.update(GlobalData.gCommandLineDefines)
>+MacroDict.pop("EFI_SOURCE", "dummy")
>+for MacroName in MacroDict:
>+if MacroDict[MacroName] != "":
>+MacroList.append('"%s=%s"' % (MacroName,
>MacroDict[MacroName].replace('\\', '')))
>+else:
>+MacroList.append('"%s"' % MacroName)
>+FdsCommandDict["macro"] = MacroList
>+
>+FdsCommandDict["fdf_file"] = [self.FdfFile]
>+FdsCommandDict["build_target"] = self.BuildTarget
>+FdsCommandDict["toolchain_tag"] = self.ToolChain
>+FdsCommandDict["active_platform"] = str(self)
>+
>+FdsCommandDict["conf_directory"] = GlobalData.gConfDirectory
>+FdsCommandDict["build_architecture_list"] = ','.join(self.ArchList)
>+FdsCommandDict["platform_build_directory"] = self.BuildDir
>+
>+FdsCommandDict["fd"] = self.FdTargetList
>+FdsCommandDict["fv"] = self.FvTargetList
>+FdsCommandDict["cap"] = self.CapTargetList
>+return FdsCommandDict
>
> ## Create makefile for the platform and modules in it
> #
>--
>2.10.0.windows.1
>
>
>
>Please consider the environment before printing this email.
>
>The information contained in this message may be confidential and
>proprietary to American Megatrends, Inc.  This communication is intended to
>be read only by the individual or entity to whom it is addressed or by their
>designee. If the reader of this message is not the intended recipient, you are
>on notice that any distribution of this message, in any form, is strictly
>prohibited.  Please promptly notify the sender by reply e-mail or by telephone
>at 770-246-8600, and then delete or destroy all copies of the transmission.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Match the nested partitions

2019-01-15 Thread Gary Lin
On Tue, Jan 15, 2019 at 12:58:10PM +0100, Laszlo Ersek wrote:
> On 01/15/19 10:45, Gary Lin wrote:
> > In some cases, such as MD RAID1 in Linux, the bootloader may be in a
> > nested EFI system partition partition. For example, sda1 and sdb1 are
> > combined as md0 and the first partition of md0, md0p1, is an EFI system
> > partition. Then, the bootloader can be located by the following device
> > paths:
> > 
> > PCI()/SATA(sda)/Partition(sda1)/Partition(md0p1)/File(bootloader.efi)
> > PCI()/SATA(sdb)/Partition(sdb1)/Partition(md0p1)/File(bootloader.efi)
> 
> How does edk2 recognize the nested partition md0p1 in the first place?
> 
> I would assume that the "outer" partitions (sda1, sdb1) start with some
> kind of MD RAID1 header that allows Linux to combine sda1 and sdb1 into
> md0p1. How does edk2 get past that header?
> 
> Hmmm... based on
> , does
> Linux use "footers" instead of "headers"?
> 
See the "Sub-versions of the version-1 superblock" section:


For MD 0.9 and 1.0, the metadata is stored in the end of the disk, and
those partitions, nested or not, are just like the normal partitions, so
the firmare can see them without the knowledge of MD metadata. MD 1.1
and 1.2 would be a different story because those two use "headers".

Anyway, I have tested RAID1 with MD 1.0 and OVMF actually appended md0p1
in the device path. I only need to iterate the nested partitions in the
match function to make my boot option work.

Thanks,

Gary Lin

> Thanks,
> Laszlo
> 
> > 
> > To make the boot option more resilient, we may create a boot option with
> > the short-form device path like "Partition(md0p1)/File(bootloader.efi)".
> > 
> > However, BmMatchPartitionDevicePathNode() only matched the first
> > partition node and ignored the nested partitions, so the firmware would
> > refuse to load bootloader.efi since "Partition(md0p1)" doesn't match
> > either "Partition(sda1)" or "Partition(sda2)".
> > 
> > This commit modifies BmMatchPartitionDevicePathNode() to iterate all
> > nested partitions so that the above boot option could work.
> > 
> > Cc: Ruiyu Ni 
> > Cc: Star Zeng 
> > Cc: Jian J Wang 
> > Cc: Hao Wu 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Gary Lin 
> > ---
> >  .../Library/UefiBootManagerLib/BmBoot.c   | 37 ---
> >  1 file changed, 23 insertions(+), 14 deletions(-)
> > 
> > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
> > b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > index 6a23477eb873..8354c2af674b 100644
> > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > @@ -1995,21 +1995,30 @@ BmMatchPartitionDevicePathNode (
> >  return FALSE;
> >}
> >  
> > -  //
> > -  // See if the harddrive device path in blockio matches the orig Hard 
> > Drive Node
> > -  //
> > -  Node = (HARDDRIVE_DEVICE_PATH *) BlockIoDevicePath;
> > +  do {
> > +//
> > +// See if the harddrive device path in blockio matches the orig Hard 
> > Drive Node
> > +//
> > +Node = (HARDDRIVE_DEVICE_PATH *) BlockIoDevicePath;
> >  
> > -  //
> > -  // Match Signature and PartitionNumber.
> > -  // Unused bytes in Signature are initiaized with zeros.
> > -  //
> > -  return (BOOLEAN) (
> > -(Node->PartitionNumber == HardDriveDevicePath->PartitionNumber) &&
> > -(Node->MBRType == HardDriveDevicePath->MBRType) &&
> > -(Node->SignatureType == HardDriveDevicePath->SignatureType) &&
> > -(CompareMem (Node->Signature, HardDriveDevicePath->Signature, sizeof 
> > (Node->Signature)) == 0)
> > -);
> > +//
> > +// Match Signature and PartitionNumber.
> > +// Unused bytes in Signature are initiaized with zeros.
> > +//
> > +if ((Node->PartitionNumber == HardDriveDevicePath->PartitionNumber) &&
> > +(Node->MBRType == HardDriveDevicePath->MBRType) &&
> > +(Node->SignatureType == HardDriveDevicePath->SignatureType) &&
> > +(CompareMem (Node->Signature, HardDriveDevicePath->Signature, 
> > sizeof (Node->Signature)) == 0)) {
> > +  return TRUE;
> > +}
> > +
> > +// See if a nested partition exists
> > +BlockIoDevicePath = NextDevicePathNode (BlockIoDevicePath);
> > +  } while (!IsDevicePathEnd (BlockIoDevicePath) &&
> > +   (DevicePathType (BlockIoDevicePath) == MEDIA_DEVICE_PATH) &&
> > +   (DevicePathSubType (BlockIoDevicePath) == MEDIA_HARDDRIVE_DP));
> > +
> > +  return FALSE;
> >  }
> >  
> >  /**
> > 
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools: Fix incorrect formatting of GenFds command dictionary

2019-01-15 Thread Felix Polyudov
The issue is introduced by commit b3497bad1221704a5dbc5da0b10f42625f1ad2ed.
GenFdsCommand returned dictionary with elements that
are not compatible with GenFdsApi.
As a result the following options were not processed by GenFdsApi:
-v, -q, -d, --genfds-multi-thread, --ignore-sources

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Felix Polyudov 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 54 +-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index cfe2d29..db3717d 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -3,6 +3,7 @@
 #
 # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
 # Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
+# Copyright (c) 2019, American Megatrends, Inc. All rights reserved.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -935,7 +936,58 @@ class WorkspaceAutoGen(AutoGen):
 
 @property
 def GenFdsCommandDict(self):
-return GenMake.TopLevelMakefile(self)._TemplateDict
+FdsCommandDict = {}
+LogLevel = EdkLogger.GetLevel()
+if LogLevel == EdkLogger.VERBOSE:
+FdsCommandDict["verbose"] = True
+elif LogLevel <= EdkLogger.DEBUG_9:
+FdsCommandDict["debug"] = LogLevel - 1
+elif LogLevel == EdkLogger.QUIET:
+FdsCommandDict["quiet"] = True
+
+if GlobalData.gEnableGenfdsMultiThread:
+FdsCommandDict["GenfdsMultiThread"] = True
+if GlobalData.gIgnoreSource:
+FdsCommandDict["IgnoreSources"] = True
+
+FdsCommandDict["OptionPcd"] = []
+for pcd in GlobalData.BuildOptionPcd:
+if pcd[2]:
+pcdname = '.'.join(pcd[0:3])
+else:
+pcdname = '.'.join(pcd[0:2])
+if pcd[3].startswith('{'):
+FdsCommandDict["OptionPcd"].append(pcdname + '=' + 'H' + '"' + 
pcd[3] + '"')
+else:
+FdsCommandDict["OptionPcd"].append(pcdname + '=' + pcd[3])
+
+MacroList = []
+# macros passed to GenFds
+MacroList.append('"%s=%s"' % ("EFI_SOURCE", 
GlobalData.gEfiSource.replace('\\', '')))
+MacroDict = {}
+MacroDict.update(GlobalData.gGlobalDefines)
+MacroDict.update(GlobalData.gCommandLineDefines)
+MacroDict.pop("EFI_SOURCE", "dummy")
+for MacroName in MacroDict:
+if MacroDict[MacroName] != "":
+MacroList.append('"%s=%s"' % (MacroName, 
MacroDict[MacroName].replace('\\', '')))
+else:
+MacroList.append('"%s"' % MacroName)
+FdsCommandDict["macro"] = MacroList
+
+FdsCommandDict["fdf_file"] = [self.FdfFile]
+FdsCommandDict["build_target"] = self.BuildTarget
+FdsCommandDict["toolchain_tag"] = self.ToolChain
+FdsCommandDict["active_platform"] = str(self)
+
+FdsCommandDict["conf_directory"] = GlobalData.gConfDirectory
+FdsCommandDict["build_architecture_list"] = ','.join(self.ArchList)
+FdsCommandDict["platform_build_directory"] = self.BuildDir
+
+FdsCommandDict["fd"] = self.FdTargetList
+FdsCommandDict["fv"] = self.FvTargetList
+FdsCommandDict["cap"] = self.CapTargetList
+return FdsCommandDict
 
 ## Create makefile for the platform and modules in it
 #
-- 
2.10.0.windows.1



Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary 
to American Megatrends, Inc.  This communication is intended to be read only by 
the individual or entity to whom it is addressed or by their designee. If the 
reader of this message is not the intended recipient, you are on notice that 
any distribution of this message, in any form, is strictly prohibited.  Please 
promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and 
then delete or destroy all copies of the transmission.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] EmulatorPkg build issue with macOS mojave and Xcode 10

2019-01-15 Thread Gao, Liming
I check the history. EmulatorPkg doesn't support macOS. EmulatorePkg depends on 
XCODE32 tool chain to generate the host application. But, XCODE32 tool chain 
has been removed at edk2 f7bd152c2a05bd75471305184c25f14f01ccf0b7. 

I just try to add back this change, and call build.sh without the change. I 
meet with new issue. Seemly, I need to install XQuartz. I will continue to try 
it. Besides, I suggest you directly use edk2 master instead of UDK2018 branch. 
If I do some fix, you can directly get it. 

/Users/tiano/lgao4/AllPkg/Edk2/EmulatorPkg/Unix/Host/X11GraphicsWindow.c:21:10: 
fatal error: 'X11/Xlib.h' file not found

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 唐佳诚
> Sent: Tuesday, January 15, 2019 10:57 AM
> To: edk2-devel 
> Subject: [edk2] EmulatorPkg build issue with macOS mojave and Xcode 10
> 
> Hi Dear EmulatorPkg Maintainer:
>   I'm a newbie at this, I am sorry for the wrong format of the previous mail. 
> There are some issue when building EmulatorPkg. Any
> inspiration or help will appreciated!
> 
> OS Environment: macOS mojave with Xcode 10 command line tool and installed 
> macOS_SDK_headers_for_macOS_10.14.pkg
> Download edk2-UDK2018.zip
> Initializing workspace
> > source ./edk2setup.sh
> 
> WORKSPACE: /Users/QianYun/Downloads/edk2-vUDK2018
> EDK_TOOLS_PATH: /Users/QianYun/Downloads/edk2-vUDK2018/BaseTools
> CONF_PATH: /Users/QianYun/Downloads/edk2-vUDK2018/Conf
> Copying $EDK_TOOLS_PATH/Conf/build_rule.template
>  to /Users/QianYun/Downloads/edk2-vUDK2018/Conf/build_rule.txt
> Copying $EDK_TOOLS_PATH/Conf/tools_def.template
>  to /Users/QianYun/Downloads/edk2-vUDK2018/Conf/tools_def.txt
> Copying $EDK_TOOLS_PATH/Conf/target.template
>  to /Users/QianYun/Downloads/edk2-vUDK2018/Conf/target.txt
> 
> > cd EmulatorPkg && ./build.sh
> 
> The BaseTools will build successfully, and EmulatorPkg will fail to build.
> 
> 'import sitecustomize' failed; use -v for traceback
> Build environment: Darwin-18.2.0-x86_64-i386-64bit
> Build start time: 15:10:45, Jan.14 2019
> 
> WORKSPACE= /Users/QianYun/Downloads/edk2-vUDK2018
> ECP_SOURCE   = /Users/QianYun/Downloads/edk2-vUDK2018/EdkCompatibilityPkg
> EDK_SOURCE   = /Users/QianYun/Downloads/edk2-vUDK2018/EdkCompatibilityPkg
> EFI_SOURCE   = /Users/QianYun/Downloads/edk2-vUDK2018/EdkCompatibilityPkg
> EDK_TOOLS_PATH   = /Users/QianYun/Downloads/edk2-vUDK2018/BaseTools
> CONF_PATH= /Users/QianYun/Downloads/edk2-vUDK2018/Conf
> build: : warning: Tool chain [XCODE32] is not defined
> 
> 
> build.py...
>  : error 4000: Not available
>   [XCODE32] not defined. No toolchain available for build!
> 
> 
> - Failed -
> Build end time: 15:10:46, Jan.14 2019
> Build total time: 00:00:00
> 
> Edit EmulatorPkg/build.sh and ./build.sh again
> 
> diff --git a/build.sh.new b/build.sh
> index 4f653d2..339c6b3 100755
> --- a/build.sh.new
> +++ b/build.sh
> @@ -63,8 +63,17 @@ case `uname` in
>  echo UnixPkg requires Snow Leopard or later OS
>  exit 1
>else
> -HOST_TOOLS=XCODE5
> -TARGET_TOOLS=XCODE5
> +CLANG_VER=$(clang -ccc-host-triple x86_64-pc-win32-macho 2>&1 
> >/dev/null) || true
> +if [[ "$CLANG_VER" == *-ccc-host-triple* ]]
> +then
> +# only older versions of Xcode support -ccc-host-tripe, for newer 
> versions
> +# it is -target
> +  HOST_TOOLS=XCODE32
> +  TARGET_TOOLS=XCODE5
> +else
> +  HOST_TOOLS=XCODE32
> +  TARGET_TOOLS=XCLANG
> +fi
>fi
>BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
>BUILD_FAT="-D BUILD_FAT"
> 
> However, this attempt still failed.
> 
> Building ... 
> /Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg/Unix/Host/Host.inf [X64]
> "clang" -target x86_64-pc-win32-macho -c -g -Os -Wall -Werror -Wextra 
> -include AutoGen.h -funsigned-char -fno-ms-extensions
> -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float 
> -mms-bitfields -Wno-unused-parameter -Wno-missing-braces
> -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
> -Wno-varargs
> -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D 
> NO_MSABI_VA_FUNCS
> -I/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg/Unix/Host/X11IncludeHack 
> -o
> /Users/QianYun/Downloads/edk2-vUDK2018/Build/Emulator/DEBUG_XCODE5/X64/EmulatorPkg/Unix/Host/Host/OUTPUT/./Host.obj
> -I/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg/Unix/Host/X64
> -I/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg/Unix/Host
> -I/Users/QianYun/Downloads/edk2-vUDK2018/Build/Emulator/DEBUG_XCODE5/X64/EmulatorPkg/Unix/Host/Host/DEBUG
> -I/Users/QianYun/Downloads/edk2-vUDK2018/MdePkg 
> -I/Users/QianYun/Downloads/edk2-vUDK2018/MdePkg/Include
> -I/Users/QianYun/Downloads/edk2-v
>  UDK2018/MdePkg/Include/X64 
> -I/Users/QianYun/Downloads/edk2-vUDK2018/MdeModulePkg
> 

Re: [edk2] Conditional Compilation support in INF file

2019-01-15 Thread Gao, Liming
Karunakar and Mike:
   Basetools doesn't support Feature Flag Expressions in INF file. It just 
ignores them. Because there are other solutions, I would like to propose to 
update INF spec to remove Feature Flag Expressions and avoid the confuse. 

Thanks
Liming
> -Original Message-
> From: Kinney, Michael D
> Sent: Saturday, January 12, 2019 2:54 AM
> To: karunakarpoosapa...@dell.com; Gao, Liming ; 
> ler...@redhat.com; edk2-devel@lists.01.org; Kinney,
> Michael D 
> Cc: sumanth.vidyadh...@dell.com; shekar.bab...@dell.com; Gao, Liming 
> ; sriramkumar.r...@dell.com
> Subject: RE: [edk2] Conditional Compilation support in INF file
> 
> Karunakar,
> 
> Feature Flag Expressions is a concept that is defined in the
> specs, but is a feature that is not fully implemented.  Liming
> should be able to provide details on what has been implemented
> and validated in BaseTools.  I think the reason that this feature
> has not been implemented fully is that we have been able to find
> alternate ways to get the equivalent results.  Here are a few
> example techniques:
> 
> 3a: One approach is to use multiple INF files and select the
> Right INF for different types of platform builds in DSC file.
> If multiple modules share source files but have different
> elements produced/consumed/depex, then multiple INF
> file is an approach that makes the produced/consumed/depex
> clear and is compatible with UDP Spec.
> 
> 3c: One approach is to use DEBUG_CODE(), DEBUG_CODE_BEGIN(),
> and DEBUG_CODE_END() macros in a single version of the
> source files and enable/disable the debug code using BIT2
> in the following PCD:
> 
>   ## The mask is used to control DebugLib behavior.
>   #  BIT0 - Enable Debug Assert.
>   #  BIT1 - Enable Debug Print.
>   #  BIT2 - Enable Debug Code.
>   #  BIT3 - Enable Clear Memory.
>   #  BIT4 - Enable BreakPoint as ASSERT.
>   #  BIT5 - Enable DeadLoop as ASSERT.
>   # @Prompt Debug Property.
>   # @Expression  0x8002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask 
> & 0xC0) == 0
>   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x0005
> 
> 3c: Another approach is to use multiple INF files and select
> the one needed for debug/release in DSC file.
> 
> If these techniques, or other techniques that other community
> Member may be using do not work for your use cases, and
> Feature Flag Expressions are the best approach, then Bugzillas
> Can be entered with supporting use cases to justify adding the
> feature to BaseTools.
> 
> Thanks,
> 
> Mike
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-
> > boun...@lists.01.org] On Behalf Of
> > karunakarpoosapa...@dell.com
> > Sent: Thursday, January 10, 2019 10:34 PM
> > To: Kinney, Michael D ; Gao,
> > Liming ; ler...@redhat.com; edk2-
> > de...@lists.01.org
> > Cc: sumanth.vidyadh...@dell.com; shekar.bab...@dell.com;
> > Gao, Liming ;
> > sriramkumar.r...@dell.com
> > Subject: Re: [edk2] Conditional Compilation support in
> > INF file
> >
> > Hi All,
> >
> > Thank you very much for your valuable thoughts.
> > Below are my concerns/thoughts, Could you please help on
> >
> > 1. Is there any module or INF already using
> > FeatureFlagExpression feature support in current edk2
> > source?
> > 2. If not, could you please help in providing more
> > detailed spec/Doc to verify this support.
> > 3. Below are the few of use cases we're looking for, Did
> > really FeatureFlagExpression support all of this?
> > a.  If we've this support we can add different
> > protocols in DEPEX section, like we can put condition
> > check and add rotococol1 for Notebook and Protocol2 for
> > Desktop.
> > b.   Help in simplifying build files. We
> > could dispense with the prefix to inf files and more
> > developer convenient.
> > c.  Sometimes we would like to add Conditional  .C
> > and .H for file inclusion. Helps in our Debug / release
> > builds as well..
> > Example; we do have release and debug
> > build, although Source Section has - IA32,X64, Common,
> > IPF, EBC exclusively.
> >   But for the same Source section, we
> > can't have choices based on our build inputs...
> >
> > #if Condition1
> >   [Sources]
> > Main.c
> > #elif Condition2
> >  [Sources]
> > DebugMain.c
> >
> > 4. I don't think INF file support MACRO support, How
> > complex in modifying the BaseTools to support Condition
> > checks and MACRO support?
> >
> > Thanks & Regards,
> > Karunakar
> >
> > -Original Message-
> > From: Kinney, Michael D
> > 

Re: [edk2] [PATCH edk2-platforms 0/8] Silicon/SynQuacer: add support for 32-bit mode

2019-01-15 Thread Leif Lindholm
On Mon, Jan 14, 2019 at 06:01:57PM +0100, Ard Biesheuvel wrote:
> This series fixes various issues that prevent the SynQuacer/DeveloperBox
> platform from being built or executed in 32-bit mode.
> 
> Ard Biesheuvel (8):
>   Silicon/SynQuacer/NetsecDxe: fix 32-bit build
>   Silicon/SynQuacer/OpteeRngDxe: fix 32-bit build
>   Silicon/SynQuacerPciHostBridgeLib: fix MMIO32-only configuration
>   Silicon/SynQuacerMemoryInitPeiLib: don't map memory above
> MAX_ALLOC_ADDRESS
>   Silicon/SynQuacerMemoryInitPeiLib: fix 32-bit build
>   Silicon/SynQuacer/Stage2Tables: fix 32-bit build
>   Platform/Socionext/DeveloperBox: disable EbcDxe for ARM builds
>   Platform/Socionext/DeveloperBox: add resolution for ArmSoftFloatLib

For the series:
Reviewed-by: Leif Lindholm 

>  Platform/Socionext/DeveloperBox/DeveloperBox.dsc |  7 ++-
>  Platform/Socionext/DeveloperBox/DeveloperBox.fdf |  2 ++
>  .../SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c  |  6 +++---
>  .../Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h|  2 +-
>  .../SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c |  2 +-
>  .../SynQuacerMemoryInitPeiLib.c  | 11 ---
>  .../SynQuacerPciHostBridgeLib.c  |  8 
>  .../Socionext/SynQuacer/Stage2Tables/Stage2Tables.S  | 12 +---
>  8 files changed, 38 insertions(+), 12 deletions(-)
> 
> -- 
> 2.17.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Match the nested partitions

2019-01-15 Thread Laszlo Ersek
On 01/15/19 10:45, Gary Lin wrote:
> In some cases, such as MD RAID1 in Linux, the bootloader may be in a
> nested EFI system partition partition. For example, sda1 and sdb1 are
> combined as md0 and the first partition of md0, md0p1, is an EFI system
> partition. Then, the bootloader can be located by the following device
> paths:
> 
> PCI()/SATA(sda)/Partition(sda1)/Partition(md0p1)/File(bootloader.efi)
> PCI()/SATA(sdb)/Partition(sdb1)/Partition(md0p1)/File(bootloader.efi)

How does edk2 recognize the nested partition md0p1 in the first place?

I would assume that the "outer" partitions (sda1, sdb1) start with some
kind of MD RAID1 header that allows Linux to combine sda1 and sdb1 into
md0p1. How does edk2 get past that header?

Hmmm... based on
, does
Linux use "footers" instead of "headers"?

Thanks,
Laszlo

> 
> To make the boot option more resilient, we may create a boot option with
> the short-form device path like "Partition(md0p1)/File(bootloader.efi)".
> 
> However, BmMatchPartitionDevicePathNode() only matched the first
> partition node and ignored the nested partitions, so the firmware would
> refuse to load bootloader.efi since "Partition(md0p1)" doesn't match
> either "Partition(sda1)" or "Partition(sda2)".
> 
> This commit modifies BmMatchPartitionDevicePathNode() to iterate all
> nested partitions so that the above boot option could work.
> 
> Cc: Ruiyu Ni 
> Cc: Star Zeng 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Gary Lin 
> ---
>  .../Library/UefiBootManagerLib/BmBoot.c   | 37 ---
>  1 file changed, 23 insertions(+), 14 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
> b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> index 6a23477eb873..8354c2af674b 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> @@ -1995,21 +1995,30 @@ BmMatchPartitionDevicePathNode (
>  return FALSE;
>}
>  
> -  //
> -  // See if the harddrive device path in blockio matches the orig Hard Drive 
> Node
> -  //
> -  Node = (HARDDRIVE_DEVICE_PATH *) BlockIoDevicePath;
> +  do {
> +//
> +// See if the harddrive device path in blockio matches the orig Hard 
> Drive Node
> +//
> +Node = (HARDDRIVE_DEVICE_PATH *) BlockIoDevicePath;
>  
> -  //
> -  // Match Signature and PartitionNumber.
> -  // Unused bytes in Signature are initiaized with zeros.
> -  //
> -  return (BOOLEAN) (
> -(Node->PartitionNumber == HardDriveDevicePath->PartitionNumber) &&
> -(Node->MBRType == HardDriveDevicePath->MBRType) &&
> -(Node->SignatureType == HardDriveDevicePath->SignatureType) &&
> -(CompareMem (Node->Signature, HardDriveDevicePath->Signature, sizeof 
> (Node->Signature)) == 0)
> -);
> +//
> +// Match Signature and PartitionNumber.
> +// Unused bytes in Signature are initiaized with zeros.
> +//
> +if ((Node->PartitionNumber == HardDriveDevicePath->PartitionNumber) &&
> +(Node->MBRType == HardDriveDevicePath->MBRType) &&
> +(Node->SignatureType == HardDriveDevicePath->SignatureType) &&
> +(CompareMem (Node->Signature, HardDriveDevicePath->Signature, sizeof 
> (Node->Signature)) == 0)) {
> +  return TRUE;
> +}
> +
> +// See if a nested partition exists
> +BlockIoDevicePath = NextDevicePathNode (BlockIoDevicePath);
> +  } while (!IsDevicePathEnd (BlockIoDevicePath) &&
> +   (DevicePathType (BlockIoDevicePath) == MEDIA_DEVICE_PATH) &&
> +   (DevicePathSubType (BlockIoDevicePath) == MEDIA_HARDDRIVE_DP));
> +
> +  return FALSE;
>  }
>  
>  /**
> 

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch V2] BaseTools: Remove EDK_SOURCE keyword from GenFds tool.

2019-01-15 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
Remove unused EDK_SOURCE keyword from GenFds tool.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
Tested-by: Laszlo Ersek 
---
 BaseTools/Source/Python/GenFds/GenFds.py   | 3 ---
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/GenFds.py 
b/BaseTools/Source/Python/GenFds/GenFds.py
index 77383d3378..5a166bf455 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -73,11 +73,10 @@ def resetFdsGlobalVariable():
 GenFdsGlobalVariable.FdfParser = None
 GenFdsGlobalVariable.LibDir = ''
 GenFdsGlobalVariable.WorkSpace = None
 GenFdsGlobalVariable.WorkSpaceDir = ''
 GenFdsGlobalVariable.ConfDir = ''
-GenFdsGlobalVariable.EdkSourceDir = ''
 GenFdsGlobalVariable.OutputDirFromDscDict = {}
 GenFdsGlobalVariable.TargetName = ''
 GenFdsGlobalVariable.ToolChainTag = ''
 GenFdsGlobalVariable.RuleDict = {}
 GenFdsGlobalVariable.ArchList = None
@@ -141,12 +140,10 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None):
 EdkLogger.error("GenFds", PARAMETER_INVALID, "WORKSPACE is 
invalid",
 ExtraData="Please use '-w' switch to pass it or 
set the WORKSPACE environment variable.")
 else:
 Workspace = 
os.path.normcase(FdsCommandDict.get("Workspace",os.environ.get('WORKSPACE')))
 GenFdsGlobalVariable.WorkSpaceDir = Workspace
-if 'EDK_SOURCE' in os.environ:
-GenFdsGlobalVariable.EdkSourceDir = 
os.path.normcase(os.environ['EDK_SOURCE'])
 if FdsCommandDict.get("debug"):
 GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + 
Workspace)
 if FdsCommandDict.get("GenfdsMultiThread"):
 GenFdsGlobalVariable.EnableGenfdsMultiThread = True
 os.chdir(GenFdsGlobalVariable.WorkSpaceDir)
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py 
b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 51c9ab046c..febe0737a2 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -48,11 +48,10 @@ class GenFdsGlobalVariable:
 FdfParser = None
 LibDir = ''
 WorkSpace = None
 WorkSpaceDir = ''
 ConfDir = ''
-EdkSourceDir = ''
 OutputDirFromDscDict = {}
 TargetName = ''
 ToolChainTag = ''
 RuleDict = {}
 ArchList = None
@@ -338,11 +337,10 @@ class GenFdsGlobalVariable:
 GenFdsGlobalVariable.WorkSpace = WorkSpace.Db
 GenFdsGlobalVariable.ArchList = ArchList
 GenFdsGlobalVariable.ToolChainTag = 
GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]
 GenFdsGlobalVariable.TargetName = GlobalData.gGlobalDefines["TARGET"]
 GenFdsGlobalVariable.ActivePlatform = GlobalData.gActivePlatform
-GenFdsGlobalVariable.EdkSourceDir = 
GlobalData.gGlobalDefines["EDK_SOURCE"]
 GenFdsGlobalVariable.ConfDir  = GlobalData.gConfDirectory
 GenFdsGlobalVariable.EnableGenfdsMultiThread = 
GlobalData.gEnableGenfdsMultiThread
 for Arch in ArchList:
 GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.normpath(
 os.path.join(GlobalData.gWorkspace,
@@ -755,11 +753,10 @@ class GenFdsGlobalVariable:
 def MacroExtend (Str, MacroDict={}, Arch=DataType.TAB_COMMON):
 if Str is None:
 return None
 
 Dict = {'$(WORKSPACE)': GenFdsGlobalVariable.WorkSpaceDir,
-'$(EDK_SOURCE)': GenFdsGlobalVariable.EdkSourceDir,
 #'$(OUTPUT_DIRECTORY)': GenFdsGlobalVariable.OutputDirFromDsc,
 '$(TARGET)': GenFdsGlobalVariable.TargetName,
 '$(TOOL_CHAIN_TAG)': GenFdsGlobalVariable.ToolChainTag,
 '$(SPACE)': ' '
}
-- 
2.19.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch V2] BaseTools: Remove EDK_SOURCE keyword from Inf Parser.

2019-01-15 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
Remove unused EDK_SOURCE keyword from Inf Parser.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
Tested-by: Laszlo Ersek 
---
 .../Source/Python/Workspace/InfBuildData.py   | 34 ---
 1 file changed, 7 insertions(+), 27 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py 
b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 02d6c1c756..709854de1e 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -634,38 +634,18 @@ class InfBuildData(ModuleBuildClassObject):
 
 Macros = self._Macros
 Macros['PROCESSOR'] = GlobalData.gEdkGlobal.get('PROCESSOR', 
self._Arch)
 RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, 
self._Platform]
 for Record in RecordList:
-if Record[0].find('EDK_SOURCE') > -1:
-File = NormPath(Record[0], self._Macros)
-if File[0] == '.':
-File = os.path.join(self._ModuleDir, File)
-else:
-File = os.path.join(GlobalData.gWorkspace, File)
-File = RealPath(os.path.normpath(File))
-if File:
-RetVal.append(File)
-
-# TRICK: let compiler to choose correct header file
-File = NormPath(Record[0], self._Macros)
-if File[0] == '.':
-File = os.path.join(self._ModuleDir, File)
-else:
-File = os.path.join(GlobalData.gWorkspace, File)
-File = RealPath(os.path.normpath(File))
-if File:
-RetVal.append(File)
+File = NormPath(Record[0], Macros)
+if File[0] == '.':
+File = os.path.join(self._ModuleDir, File)
 else:
-File = NormPath(Record[0], Macros)
-if File[0] == '.':
-File = os.path.join(self._ModuleDir, File)
-else:
-File = mws.join(GlobalData.gWorkspace, File)
-File = RealPath(os.path.normpath(File))
-if File:
-RetVal.append(File)
+File = mws.join(GlobalData.gWorkspace, File)
+File = RealPath(os.path.normpath(File))
+if File:
+RetVal.append(File)
 return RetVal
 
 ## Retrieve packages this module depends on
 @cached_property
 def Packages(self):
-- 
2.19.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] BaseTools: Remove EDK_SOURCE keyword from GenFds tool.

2019-01-15 Thread Laszlo Ersek
Hi Bob,

On 01/15/19 12:03, Feng, Bob C wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
> Remove unused EDK_SOURCE keyword from GenFds tool.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng 
> Cc: Liming Gao 
> ---
>  BaseTools/Source/Python/GenFds/GenFds.py   | 3 ---
>  BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 3 ---
>  2 files changed, 6 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/GenFds/GenFds.py 
> b/BaseTools/Source/Python/GenFds/GenFds.py
> index 77383d3378..5a166bf455 100644
> --- a/BaseTools/Source/Python/GenFds/GenFds.py
> +++ b/BaseTools/Source/Python/GenFds/GenFds.py
> @@ -73,11 +73,10 @@ def resetFdsGlobalVariable():
>  GenFdsGlobalVariable.FdfParser = None
>  GenFdsGlobalVariable.LibDir = ''
>  GenFdsGlobalVariable.WorkSpace = None
>  GenFdsGlobalVariable.WorkSpaceDir = ''
>  GenFdsGlobalVariable.ConfDir = ''
> -GenFdsGlobalVariable.EdkSourceDir = ''
>  GenFdsGlobalVariable.OutputDirFromDscDict = {}
>  GenFdsGlobalVariable.TargetName = ''
>  GenFdsGlobalVariable.ToolChainTag = ''
>  GenFdsGlobalVariable.RuleDict = {}
>  GenFdsGlobalVariable.ArchList = None
> @@ -141,12 +140,10 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None):
>  EdkLogger.error("GenFds", PARAMETER_INVALID, "WORKSPACE is 
> invalid",
>  ExtraData="Please use '-w' switch to pass it or 
> set the WORKSPACE environment variable.")
>  else:
>  Workspace = 
> os.path.normcase(FdsCommandDict.get("Workspace",os.environ.get('WORKSPACE')))
>  GenFdsGlobalVariable.WorkSpaceDir = Workspace
> -if 'EDK_SOURCE' in os.environ:
> -GenFdsGlobalVariable.EdkSourceDir = 
> os.path.normcase(os.environ['EDK_SOURCE'])
>  if FdsCommandDict.get("debug"):
>  GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + 
> Workspace)
>  if FdsCommandDict.get("GenfdsMultiThread"):
>  GenFdsGlobalVariable.EnableGenfdsMultiThread = True
>  os.chdir(GenFdsGlobalVariable.WorkSpaceDir)
> diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py 
> b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
> index 51c9ab046c..febe0737a2 100644
> --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
> +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
> @@ -48,11 +48,10 @@ class GenFdsGlobalVariable:
>  FdfParser = None
>  LibDir = ''
>  WorkSpace = None
>  WorkSpaceDir = ''
>  ConfDir = ''
> -EdkSourceDir = ''
>  OutputDirFromDscDict = {}
>  TargetName = ''
>  ToolChainTag = ''
>  RuleDict = {}
>  ArchList = None
> @@ -338,11 +337,10 @@ class GenFdsGlobalVariable:
>  GenFdsGlobalVariable.WorkSpace = WorkSpace.Db
>  GenFdsGlobalVariable.ArchList = ArchList
>  GenFdsGlobalVariable.ToolChainTag = 
> GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]
>  GenFdsGlobalVariable.TargetName = GlobalData.gGlobalDefines["TARGET"]
>  GenFdsGlobalVariable.ActivePlatform = GlobalData.gActivePlatform
> -GenFdsGlobalVariable.EdkSourceDir = 
> GlobalData.gGlobalDefines["EDK_SOURCE"]
>  GenFdsGlobalVariable.ConfDir  = GlobalData.gConfDirectory
>  GenFdsGlobalVariable.EnableGenfdsMultiThread = 
> GlobalData.gEnableGenfdsMultiThread
>  for Arch in ArchList:
>  GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.normpath(
>  os.path.join(GlobalData.gWorkspace,
> @@ -755,11 +753,10 @@ class GenFdsGlobalVariable:
>  def MacroExtend (Str, MacroDict={}, Arch=DataType.TAB_COMMON):
>  if Str is None:
>  return None
>  
>  Dict = {'$(WORKSPACE)': GenFdsGlobalVariable.WorkSpaceDir,
> -'$(EDK_SOURCE)': GenFdsGlobalVariable.EdkSourceDir,
>  #'$(OUTPUT_DIRECTORY)': 
> GenFdsGlobalVariable.OutputDirFromDsc,
>  '$(TARGET)': GenFdsGlobalVariable.TargetName,
>  '$(TOOL_CHAIN_TAG)': GenFdsGlobalVariable.ToolChainTag,
>  '$(SPACE)': ' '
> }
> 

if this patch has been identically extracted from

20190114111341.20784-1-bob.c.feng@intel.com">http://mid.mail-archive.com/20190114111341.20784-1-bob.c.feng@intel.com

then you can add

Tested-by: Laszlo Ersek 

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] BaseTools: Remove EDK_SOURCE keyword from Inf Parser.

2019-01-15 Thread Laszlo Ersek
Hi Bob,

On 01/15/19 12:03, Feng, Bob C wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
> Remove unused EDK_SOURCE keyword from Inf Parser.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng 
> Cc: Liming Gao 
> ---
>  .../Source/Python/Workspace/InfBuildData.py   | 34 ---
>  1 file changed, 7 insertions(+), 27 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py 
> b/BaseTools/Source/Python/Workspace/InfBuildData.py
> index 02d6c1c756..709854de1e 100644
> --- a/BaseTools/Source/Python/Workspace/InfBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
> @@ -634,38 +634,18 @@ class InfBuildData(ModuleBuildClassObject):
>  
>  Macros = self._Macros
>  Macros['PROCESSOR'] = GlobalData.gEdkGlobal.get('PROCESSOR', 
> self._Arch)
>  RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, 
> self._Platform]
>  for Record in RecordList:
> -if Record[0].find('EDK_SOURCE') > -1:
> -File = NormPath(Record[0], self._Macros)
> -if File[0] == '.':
> -File = os.path.join(self._ModuleDir, File)
> -else:
> -File = os.path.join(GlobalData.gWorkspace, File)
> -File = RealPath(os.path.normpath(File))
> -if File:
> -RetVal.append(File)
> -
> -# TRICK: let compiler to choose correct header file
> -File = NormPath(Record[0], self._Macros)
> -if File[0] == '.':
> -File = os.path.join(self._ModuleDir, File)
> -else:
> -File = os.path.join(GlobalData.gWorkspace, File)
> -File = RealPath(os.path.normpath(File))
> -if File:
> -RetVal.append(File)
> +File = NormPath(Record[0], Macros)
> +if File[0] == '.':
> +File = os.path.join(self._ModuleDir, File)
>  else:
> -File = NormPath(Record[0], Macros)
> -if File[0] == '.':
> -File = os.path.join(self._ModuleDir, File)
> -else:
> -File = mws.join(GlobalData.gWorkspace, File)
> -File = RealPath(os.path.normpath(File))
> -if File:
> -RetVal.append(File)
> +File = mws.join(GlobalData.gWorkspace, File)
> +File = RealPath(os.path.normpath(File))
> +if File:
> +RetVal.append(File)
>  return RetVal
>  
>  ## Retrieve packages this module depends on
>  @cached_property
>  def Packages(self):
> 

again, if this patch has been identically extracted from

20190114111341.20784-1-bob.c.feng@intel.com">http://mid.mail-archive.com/20190114111341.20784-1-bob.c.feng@intel.com

then you can add

Tested-by: Laszlo Ersek 

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V3 14/17] BeagleBoardPkg: Use merged variable driver for emulated NV mode

2019-01-15 Thread Leif Lindholm
On Tue, Jan 15, 2019 at 06:29:36PM +0800, Star Zeng wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> The real variable driver has been updated to support emulated
> variable NV mode and the EmuVariableRuntimeDxe will be removed
> later, so use merged variable driver for emulated NV mode.
> 
> Cc: Leif Lindholm 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 

Reviewed-by: Leif Lindholm 

> ---
>  BeagleBoardPkg/BeagleBoardPkg.dsc | 14 --
>  BeagleBoardPkg/BeagleBoardPkg.fdf |  4 ++--
>  2 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc 
> b/BeagleBoardPkg/BeagleBoardPkg.dsc
> index 6dabfa905ae9..e0fee3692fd1 100644
> --- a/BeagleBoardPkg/BeagleBoardPkg.dsc
> +++ b/BeagleBoardPkg/BeagleBoardPkg.dsc
> @@ -2,7 +2,7 @@
>  # Beagle board package.
>  #
>  # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.
> -# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> +# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
>  # Copyright (c) 2016, Linaro Ltd. All rights reserved.
>  #
>  #This program and the accompanying materials
> @@ -137,6 +137,11 @@ [LibraryClasses.common]
>  
>CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
>  
> +  
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> +  
> AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> +  
> TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
> +  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
> +
>  [LibraryClasses.common.SEC]
>PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
>
> ReportStatusCodeLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
> @@ -345,6 +350,11 @@ [PcdsFixedAtBuild.common]
>  
>gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
>  
> +  #
> +  # Make VariableRuntimeDxe work at emulated non-volatile variable mode.
> +  #
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
> +
>  
> 
>  #
>  # Components Section - list of all EDK II Modules needed by this Platform
> @@ -376,7 +386,7 @@ [Components.common]
>MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
> -  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
> +  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
>  
>MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
> diff --git a/BeagleBoardPkg/BeagleBoardPkg.fdf 
> b/BeagleBoardPkg/BeagleBoardPkg.fdf
> index 83d85fce4070..42d6bad0c73b 100644
> --- a/BeagleBoardPkg/BeagleBoardPkg.fdf
> +++ b/BeagleBoardPkg/BeagleBoardPkg.fdf
> @@ -1,7 +1,7 @@
>  # FLASH layout file for Beagle board.
>  #
>  # Copyright (c) 2009, Apple Inc. All rights reserved.
> -# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> +# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
>  # Copyright (c) 2016, Linaro, Ltd. All rights reserved.
>  #
>  #This program and the accompanying materials
> @@ -106,7 +106,7 @@ [FV.FvMain]
>INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
> -  INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
> +  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>INF EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
>  
>INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
> -- 
> 2.7.0.windows.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 5/5] ArmPkg/DefaultExceptionHandlerLib: use console if available

2019-01-15 Thread Ard Biesheuvel
On Tue, 15 Jan 2019 at 11:09, Laszlo Ersek  wrote:
>
> On 01/15/19 09:23, Ard Biesheuvel wrote:
> > Print the minimal 'exception occurred' message to the console instead
> > of straight to the serial port if the console is available. This makes
> > such messages visible on systems where the console is graphical and
> > the serial is not connected.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > Reviewed-by: Leif Lindholm 
> > ---
> >  
> > ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c 
> > | 12 ++--
> >  ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
> >  |  7 ++-
> >  ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf   
> >  |  1 +
> >  3 files changed, 17 insertions(+), 3 deletions(-)
>
> Please consider updating the following, before pushing the patch:
>
> > diff --git 
> > a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> >  
> > b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> > index 1024bf48c63d..362acd5ba6d2 100644
> > --- 
> > a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> > +++ 
> > b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> > @@ -22,6 +22,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include 
> >  #include 
> > @@ -159,14 +160,21 @@ DefaultExceptionHandler (
> >INT32  Offset;
> >
> >if (mRecursiveException) {
> > -CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive 
> > exception occurred while dumping the CPU state\n");
> > -SerialPortWrite ((UINT8 *) Buffer, CharCount);
> > +STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while 
> > dumping the CPU state\n";
> > +
> > +SerialPortWrite ((UINT8 *)Message, AsciiStrLen (Message));
>
> (1) A micro-optimization could be (sizeof Message - 1) rather than
> AsciiStrLen (Message), but it's mostly irrelevant.
>

OK

> > +if (gST->ConOut != NULL) {
> > +  AsciiPrint (Message);
> > +}
> >  CpuDeadLoop ();
> >}
> >mRecursiveException = TRUE;
> >
> >CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 
> > 0x%016lx\n", gExceptionTypeString[ExceptionType], 
> > SystemContext.SystemContextAArch64->ELR);
> >SerialPortWrite ((UINT8 *) Buffer, CharCount);
> > +  if (gST->ConOut != NULL) {
> > +AsciiPrint (Buffer);
> > +  }
> >
> >DEBUG_CODE_BEGIN ();
> >  CHAR8  *Pdb, *PrevPdb;
> > diff --git 
> > a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c 
> > b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
> > index cc79cb2fa301..a79f73725aed 100644
> > --- 
> > a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
> > +++ 
> > b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
> > @@ -21,6 +21,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include 
> >
> > @@ -194,7 +195,11 @@ DefaultExceptionHandler (
> >
> >CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 
> > 0x%08x  CPSR 0x%08x ",
> >   gExceptionTypeString[ExceptionType], 
> > SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);
> > -  SerialPortWrite ((UINT8 *) Buffer, CharCount);
> > +  if (gST->ConOut != NULL) {
> > +AsciiPrint (Buffer);
> > +  } else {
> > +SerialPortWrite ((UINT8 *)Buffer, CharCount);
> > +  }
>
> (2) I think the "serial PLUS console" reporting applies to the 32-bit
> lib instance as well, so I assume not updating this from v1 was an
> oversight.
>

Yes it was. Thanks for spotting that.

> >
> >DEBUG_CODE_BEGIN ();
> >  CHAR8   *Pdb;
> > diff --git 
> > a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf 
> > b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
> > index 7609f82d89a1..6bc48714c9dc 100644
> > --- 
> > a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
> > +++ 
> > b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
> > @@ -42,6 +42,7 @@ [LibraryClasses]
> >PeCoffGetEntryPointLib
> >ArmDisassemblerLib
> >SerialPortLib
> > +  UefiBootServicesTableLib
> >
> >  [Guids]
> >gEfiDebugImageInfoTableGuid
> >
>
> With (2) updated, and regardless of (1):
>
> Acked-by: Laszlo Ersek 
>
> Thanks!
> Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools: Remove EDK_SOURCE keyword from Inf Parser.

2019-01-15 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
Remove unused EDK_SOURCE keyword from Inf Parser.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 .../Source/Python/Workspace/InfBuildData.py   | 34 ---
 1 file changed, 7 insertions(+), 27 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py 
b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 02d6c1c756..709854de1e 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -634,38 +634,18 @@ class InfBuildData(ModuleBuildClassObject):
 
 Macros = self._Macros
 Macros['PROCESSOR'] = GlobalData.gEdkGlobal.get('PROCESSOR', 
self._Arch)
 RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, 
self._Platform]
 for Record in RecordList:
-if Record[0].find('EDK_SOURCE') > -1:
-File = NormPath(Record[0], self._Macros)
-if File[0] == '.':
-File = os.path.join(self._ModuleDir, File)
-else:
-File = os.path.join(GlobalData.gWorkspace, File)
-File = RealPath(os.path.normpath(File))
-if File:
-RetVal.append(File)
-
-# TRICK: let compiler to choose correct header file
-File = NormPath(Record[0], self._Macros)
-if File[0] == '.':
-File = os.path.join(self._ModuleDir, File)
-else:
-File = os.path.join(GlobalData.gWorkspace, File)
-File = RealPath(os.path.normpath(File))
-if File:
-RetVal.append(File)
+File = NormPath(Record[0], Macros)
+if File[0] == '.':
+File = os.path.join(self._ModuleDir, File)
 else:
-File = NormPath(Record[0], Macros)
-if File[0] == '.':
-File = os.path.join(self._ModuleDir, File)
-else:
-File = mws.join(GlobalData.gWorkspace, File)
-File = RealPath(os.path.normpath(File))
-if File:
-RetVal.append(File)
+File = mws.join(GlobalData.gWorkspace, File)
+File = RealPath(os.path.normpath(File))
+if File:
+RetVal.append(File)
 return RetVal
 
 ## Retrieve packages this module depends on
 @cached_property
 def Packages(self):
-- 
2.19.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools: Remove EDK_SOURCE keyword from ECC Tool

2019-01-15 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
Remove EDK_SOURCE keyword from ECC Tool.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/Ecc/EccMain.py| 27 ---
 .../Ecc/MetaFileWorkspace/MetaFileParser.py   | 20 --
 2 files changed, 47 deletions(-)

diff --git a/BaseTools/Source/Python/Ecc/EccMain.py 
b/BaseTools/Source/Python/Ecc/EccMain.py
index 5f9e497e37..0f97447751 100644
--- a/BaseTools/Source/Python/Ecc/EccMain.py
+++ b/BaseTools/Source/Python/Ecc/EccMain.py
@@ -66,47 +66,20 @@ class Ecc(object):
 
 # Parse the options and args
 self.ParseOption()
 EdkLogger.info(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime()) 
+ "[00:00]" + "\n")
 
-#
-# Check EFI_SOURCE (Edk build convention). EDK_SOURCE will always 
point to ECP
-#
 WorkspaceDir = 
os.path.normcase(os.path.normpath(os.environ["WORKSPACE"]))
 os.environ["WORKSPACE"] = WorkspaceDir
 
 # set multiple workspace
 PackagesPath = os.getenv("PACKAGES_PATH")
 mws.setWs(WorkspaceDir, PackagesPath)
 
-if "ECP_SOURCE" not in os.environ:
-os.environ["ECP_SOURCE"] = mws.join(WorkspaceDir, 
GlobalData.gEdkCompatibilityPkg)
-if "EFI_SOURCE" not in os.environ:
-os.environ["EFI_SOURCE"] = os.environ["ECP_SOURCE"]
-if "EDK_SOURCE" not in os.environ:
-os.environ["EDK_SOURCE"] = os.environ["ECP_SOURCE"]
-
-#
-# Unify case of characters on case-insensitive systems
-#
-EfiSourceDir = 
os.path.normcase(os.path.normpath(os.environ["EFI_SOURCE"]))
-EdkSourceDir = 
os.path.normcase(os.path.normpath(os.environ["EDK_SOURCE"]))
-EcpSourceDir = 
os.path.normcase(os.path.normpath(os.environ["ECP_SOURCE"]))
-
-os.environ["EFI_SOURCE"] = EfiSourceDir
-os.environ["EDK_SOURCE"] = EdkSourceDir
-os.environ["ECP_SOURCE"] = EcpSourceDir
-
 GlobalData.gWorkspace = WorkspaceDir
-GlobalData.gEfiSource = EfiSourceDir
-GlobalData.gEdkSource = EdkSourceDir
-GlobalData.gEcpSource = EcpSourceDir
 
 GlobalData.gGlobalDefines["WORKSPACE"]  = WorkspaceDir
-GlobalData.gGlobalDefines["EFI_SOURCE"] = EfiSourceDir
-GlobalData.gGlobalDefines["EDK_SOURCE"] = EdkSourceDir
-GlobalData.gGlobalDefines["ECP_SOURCE"] = EcpSourceDir
 
 EdkLogger.info("Loading ECC configuration ... done")
 # Generate checkpoints list
 EccGlobalData.gConfig = Configuration(self.ConfigFile)
 
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py 
b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
index 283789fd1d..862974894a 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
@@ -608,21 +608,10 @@ class InfParser(MetaFileParser):
 for Index in range(0, len(self._ValueList)):
 Value = self._ValueList[Index]
 if not Value:
 continue
 
-if Value.upper().find('$(EFI_SOURCE)\Edk'.upper()) > -1 or 
Value.upper().find('$(EFI_SOURCE)/Edk'.upper()) > -1:
-Value = '$(EDK_SOURCE)' + Value[17:]
-if Value.find('$(EFI_SOURCE)') > -1 or 
Value.find('$(EDK_SOURCE)') > -1:
-pass
-elif Value.startswith('.'):
-pass
-elif Value.startswith('$('):
-pass
-else:
-Value = '$(EFI_SOURCE)/' + Value
-
 self._ValueList[Index] = ReplaceMacro(Value, Macros)
 
 ## Parse [Sources] section
 #
 #   Only path can have macro used. So we need to replace them before use.
@@ -1357,20 +1346,11 @@ class DscParser(MetaFileParser):
 __IncludeMacros = {}
 #
 # Allow using system environment variables  in path after !include
 #
 __IncludeMacros['WORKSPACE'] = 
GlobalData.gGlobalDefines['WORKSPACE']
-if "ECP_SOURCE" in GlobalData.gGlobalDefines.keys():
-__IncludeMacros['ECP_SOURCE'] = 
GlobalData.gGlobalDefines['ECP_SOURCE']
-#
-# During GenFds phase call DSC parser, will go into this branch.
-#
-elif "ECP_SOURCE" in GlobalData.gCommandLineDefines.keys():
-__IncludeMacros['ECP_SOURCE'] = 
GlobalData.gCommandLineDefines['ECP_SOURCE']
 
-__IncludeMacros['EFI_SOURCE'] = 
GlobalData.gGlobalDefines['EFI_SOURCE']
-__IncludeMacros['EDK_SOURCE'] = 
GlobalData.gGlobalDefines['EDK_SOURCE']
 #
 # Allow using MACROs comes from [Defines] section to keep 
compatible.
 #
 __IncludeMacros.update(self._Macros)
 
-- 
2.19.1.windows.1


[edk2] [Patch] BaseTools: Remove EDK_SOURCE keyword from GenFds tool.

2019-01-15 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
Remove unused EDK_SOURCE keyword from GenFds tool.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/GenFds/GenFds.py   | 3 ---
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/GenFds.py 
b/BaseTools/Source/Python/GenFds/GenFds.py
index 77383d3378..5a166bf455 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -73,11 +73,10 @@ def resetFdsGlobalVariable():
 GenFdsGlobalVariable.FdfParser = None
 GenFdsGlobalVariable.LibDir = ''
 GenFdsGlobalVariable.WorkSpace = None
 GenFdsGlobalVariable.WorkSpaceDir = ''
 GenFdsGlobalVariable.ConfDir = ''
-GenFdsGlobalVariable.EdkSourceDir = ''
 GenFdsGlobalVariable.OutputDirFromDscDict = {}
 GenFdsGlobalVariable.TargetName = ''
 GenFdsGlobalVariable.ToolChainTag = ''
 GenFdsGlobalVariable.RuleDict = {}
 GenFdsGlobalVariable.ArchList = None
@@ -141,12 +140,10 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None):
 EdkLogger.error("GenFds", PARAMETER_INVALID, "WORKSPACE is 
invalid",
 ExtraData="Please use '-w' switch to pass it or 
set the WORKSPACE environment variable.")
 else:
 Workspace = 
os.path.normcase(FdsCommandDict.get("Workspace",os.environ.get('WORKSPACE')))
 GenFdsGlobalVariable.WorkSpaceDir = Workspace
-if 'EDK_SOURCE' in os.environ:
-GenFdsGlobalVariable.EdkSourceDir = 
os.path.normcase(os.environ['EDK_SOURCE'])
 if FdsCommandDict.get("debug"):
 GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + 
Workspace)
 if FdsCommandDict.get("GenfdsMultiThread"):
 GenFdsGlobalVariable.EnableGenfdsMultiThread = True
 os.chdir(GenFdsGlobalVariable.WorkSpaceDir)
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py 
b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 51c9ab046c..febe0737a2 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -48,11 +48,10 @@ class GenFdsGlobalVariable:
 FdfParser = None
 LibDir = ''
 WorkSpace = None
 WorkSpaceDir = ''
 ConfDir = ''
-EdkSourceDir = ''
 OutputDirFromDscDict = {}
 TargetName = ''
 ToolChainTag = ''
 RuleDict = {}
 ArchList = None
@@ -338,11 +337,10 @@ class GenFdsGlobalVariable:
 GenFdsGlobalVariable.WorkSpace = WorkSpace.Db
 GenFdsGlobalVariable.ArchList = ArchList
 GenFdsGlobalVariable.ToolChainTag = 
GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]
 GenFdsGlobalVariable.TargetName = GlobalData.gGlobalDefines["TARGET"]
 GenFdsGlobalVariable.ActivePlatform = GlobalData.gActivePlatform
-GenFdsGlobalVariable.EdkSourceDir = 
GlobalData.gGlobalDefines["EDK_SOURCE"]
 GenFdsGlobalVariable.ConfDir  = GlobalData.gConfDirectory
 GenFdsGlobalVariable.EnableGenfdsMultiThread = 
GlobalData.gEnableGenfdsMultiThread
 for Arch in ArchList:
 GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.normpath(
 os.path.join(GlobalData.gWorkspace,
@@ -755,11 +753,10 @@ class GenFdsGlobalVariable:
 def MacroExtend (Str, MacroDict={}, Arch=DataType.TAB_COMMON):
 if Str is None:
 return None
 
 Dict = {'$(WORKSPACE)': GenFdsGlobalVariable.WorkSpaceDir,
-'$(EDK_SOURCE)': GenFdsGlobalVariable.EdkSourceDir,
 #'$(OUTPUT_DIRECTORY)': GenFdsGlobalVariable.OutputDirFromDsc,
 '$(TARGET)': GenFdsGlobalVariable.TargetName,
 '$(TOOL_CHAIN_TAG)': GenFdsGlobalVariable.ToolChainTag,
 '$(SPACE)': ' '
}
-- 
2.19.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 17/17] MdeModulePkg: Remove EmuVariableRuntimeDxe

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

The real variable driver has been updated to support emulated
variable NV mode.
This patch removes EmuVariableRuntimeDxe after platforms are
migrated to use the merged variable driver.

Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/MdeModulePkg.dsc  |5 +-
 .../Universal/Variable/EmuRuntimeDxe/EmuVariable.c | 1820 
 .../EmuRuntimeDxe/EmuVariableRuntimeDxe.inf|   88 -
 .../EmuRuntimeDxe/EmuVariableRuntimeDxe.uni|   22 -
 .../EmuRuntimeDxe/EmuVariableRuntimeDxeExtra.uni   |   19 -
 .../Variable/EmuRuntimeDxe/InitVariable.c  |  259 ---
 .../Universal/Variable/EmuRuntimeDxe/Variable.h|  277 ---
 7 files changed, 1 insertion(+), 2489 deletions(-)
 delete mode 100644 MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
 delete mode 100644 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
 delete mode 100644 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.uni
 delete mode 100644 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxeExtra.uni
 delete mode 100644 MdeModulePkg/Universal/Variable/EmuRuntimeDxe/InitVariable.c
 delete mode 100644 MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 5d042be3a862..3186f35a1a48 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -2,7 +2,7 @@
 # EFI/PI Reference Module Package for All Architectures
 #
 # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
 #
 #This program and the accompanying materials
 #are licensed and made available under the terms and conditions of the BSD 
License
@@ -433,9 +433,6 @@ [Components.IA32, Components.X64, Components.ARM, 
Components.AARCH64]
   
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
   }
 
-[Components.IA32, Components.X64, Components.Ebc]
-  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
-
 [Components.IA32, Components.X64]
   MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.inf
   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
diff --git a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c 
b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
deleted file mode 100644
index 1bcf931b96a6..
--- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
+++ /dev/null
@@ -1,1820 +0,0 @@
-/** @file
-
-  Emulation Variable services operate on the runtime volatile memory.
-  The nonvolatile variable space doesn't exist.
-
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "Variable.h"
-
-///
-/// Don't use module globals after the SetVirtualAddress map is signaled
-///
-ESAL_VARIABLE_GLOBAL  *mVariableModuleGlobal;
-
-VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
-
-///
-/// The size of a 3 character ISO639 language code.
-///
-#define ISO_639_2_ENTRY_SIZE3
-
-/**
-  Update the variable region with Variable information. These are the same
-  arguments as the EFI Variable services.
-
-  @param[in] VariableName   Name of variable
-
-  @param[in] VendorGuid Guid of variable
-
-  @param[in] Data   Variable data
-
-  @param[in] DataSize   Size of data. 0 means delete
-
-  @param[in] Attributes Attribues of the variable
-
-  @param[in] Variable   The variable information which is used to keep 
track of variable usage.
-
-  @retval EFI_SUCCESS   The update operation is success.
-
-  @retval EFI_OUT_OF_RESOURCES  Variable region is full, can not write other 
data into this region.
-
-**/
-EFI_STATUS
-EFIAPI
-UpdateVariable (
-  IN  CHAR16 *VariableName,
-  IN  EFI_GUID   *VendorGuid,
-  IN  VOID   *Data,
-  IN  UINTN  DataSize,
-  IN  UINT32 Attributes OPTIONAL,
-  IN  VARIABLE_POINTER_TRACK *Variable
-  );
-
-/**
-  Finds variable in storage blocks of volatile and non-volatile storage areas.
-
-  This code finds variable in storage blocks of volatile and non-volatile 
storage areas.
-  If VariableName is an empty string, then we just return 

[edk2] [PATCH V3 10/17] MdeModulePkg Variable: Add emulated variable NV mode support

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

Add emulated variable NV mode support in real variable driver.
Platform can configure PcdEmuVariableNvModeEnable statically
(build time) or dynamically (boot time) to support emulated
variable NV mode.

If PcdEmuVariableNvModeEnable is configured to dynamic, its
value should be set before Variable driver starts to work,
otherwise default value will take effect.

Then EmuVariableRuntimeDxe could be removed, the removal of
EmuVariableRuntimeDxe will be done after platforms are migrated
to use the merged variable driver.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Acked-by: Laszlo Ersek 
---
 .../Universal/Variable/RuntimeDxe/Variable.c   | 318 +++--
 .../Universal/Variable/RuntimeDxe/Variable.h   |   1 +
 .../Universal/Variable/RuntimeDxe/VariableDxe.c|  27 +-
 .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |   4 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.c|  29 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |   4 +-
 6 files changed, 271 insertions(+), 112 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index d3df21819abe..e8e19508cd9a 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -34,6 +34,7 @@ VARIABLE_MODULE_GLOBAL  *mVariableModuleGlobal;
 
 ///
 /// Define a memory cache that improves the search performance for a variable.
+/// For EmuNvMode == TRUE, it will be equal to NonVolatileVariableBase.
 ///
 VARIABLE_STORE_HEADER  *mNvVariableCache  = NULL;
 
@@ -273,7 +274,7 @@ UpdateVariableStore (
   //
   // Check if the Data is Volatile.
   //
-  if (!Volatile) {
+  if (!Volatile && !mVariableModuleGlobal->VariableGlobal.EmuNvMode) {
 if (Fvb == NULL) {
   return EFI_UNSUPPORTED;
 }
@@ -296,17 +297,30 @@ UpdateVariableStore (
 // Data Pointer should point to the actual Address where data is to be
 // written.
 //
-VolatileBase = (VARIABLE_STORE_HEADER *) ((UINTN) 
mVariableModuleGlobal->VariableGlobal.VolatileVariableBase);
-if (SetByIndex) {
-  DataPtr += mVariableModuleGlobal->VariableGlobal.VolatileVariableBase;
-}
+if (Volatile) {
+  VolatileBase = (VARIABLE_STORE_HEADER *) ((UINTN) 
mVariableModuleGlobal->VariableGlobal.VolatileVariableBase);
+  if (SetByIndex) {
+DataPtr += mVariableModuleGlobal->VariableGlobal.VolatileVariableBase;
+  }
 
-if ((DataPtr + DataSize) > ((UINTN) VolatileBase + VolatileBase->Size)) {
-  return EFI_OUT_OF_RESOURCES;
+  if ((DataPtr + DataSize) > ((UINTN) VolatileBase + VolatileBase->Size)) {
+return EFI_OUT_OF_RESOURCES;
+  }
+} else {
+  //
+  // Emulated non-volatile variable mode.
+  //
+  if (SetByIndex) {
+DataPtr += (UINTN) mNvVariableCache;
+  }
+
+  if ((DataPtr + DataSize) > ((UINTN) mNvVariableCache + 
mNvVariableCache->Size)) {
+return EFI_OUT_OF_RESOURCES;
+  }
 }
 
 //
-// If Volatile Variable just do a simple mem copy.
+// If Volatile/Emulated Non-volatile Variable just do a simple mem copy.
 //
 CopyMem ((UINT8 *)(UINTN)DataPtr, Buffer, DataSize);
 return EFI_SUCCESS;
@@ -987,7 +1001,7 @@ Reclaim (
   CommonUserVariableTotalSize = 0;
   HwErrVariableTotalSize  = 0;
 
-  if (IsVolatile) {
+  if (IsVolatile || mVariableModuleGlobal->VariableGlobal.EmuNvMode) {
 //
 // Start Pointers for the variable.
 //
@@ -1155,13 +1169,21 @@ Reclaim (
 CurrPtr += NewVariableSize;
   }
 
-  if (IsVolatile) {
+  if (IsVolatile || mVariableModuleGlobal->VariableGlobal.EmuNvMode) {
 //
-// If volatile variable store, just copy valid buffer.
+// If volatile/emulated non-volatile variable store, just copy valid 
buffer.
 //
 SetMem ((UINT8 *) (UINTN) VariableBase, VariableStoreHeader->Size, 0xff);
 CopyMem ((UINT8 *) (UINTN) VariableBase, ValidBuffer, (UINTN) CurrPtr - 
(UINTN) ValidBuffer);
 *LastVariableOffset = (UINTN) CurrPtr - (UINTN) ValidBuffer;
+if (!IsVolatile) {
+  //
+  // Emulated non-volatile variable mode.
+  //
+  mVariableModuleGlobal->HwErrVariableTotalSize = HwErrVariableTotalSize;
+  mVariableModuleGlobal->CommonVariableTotalSize = CommonVariableTotalSize;
+  mVariableModuleGlobal->CommonUserVariableTotalSize = 
CommonUserVariableTotalSize;
+}
 Status  = EFI_SUCCESS;
   } else {
 //
@@ -1200,7 +1222,7 @@ Reclaim (
   }
 
 Done:
-  if (IsVolatile) {
+  if (IsVolatile || mVariableModuleGlobal->VariableGlobal.EmuNvMode) {
 FreePool (ValidBuffer);
   } else {
 //
@@ -2147,7 +2169,7 @@ UpdateVariable (
   BOOLEAN   

[edk2] [PATCH V3 12/17] ArmVirtXen: Use merged variable driver for emulated NV mode

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

The real variable driver has been updated to support emulated
variable NV mode and the EmuVariableRuntimeDxe will be removed
later, so use merged variable driver for emulated NV mode.

Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Julien Grall 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Laszlo Ersek 
---
 ArmVirtPkg/ArmVirtXen.dsc | 9 +++--
 ArmVirtPkg/ArmVirtXen.fdf | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index a29d8a4ae717..db85fb3402d0 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -1,7 +1,7 @@
 #
 #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -101,6 +101,11 @@ [PcdsFixedAtBuild.common]
   # Set terminal type to TtyTerm, the value encoded is EFI_TTY_TERM_GUID
   gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91, 0x7d, 
0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94}
 
+  #
+  # Make VariableRuntimeDxe work at emulated non-volatile variable mode.
+  #
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
+
 [PcdsPatchableInModule.common]
   #
   # This will be overridden in the code
@@ -172,7 +177,7 @@ [Components.common]
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 
-  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
 
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf
index 50e670254d52..5655c0df2926 100644
--- a/ArmVirtPkg/ArmVirtXen.fdf
+++ b/ArmVirtPkg/ArmVirtXen.fdf
@@ -1,7 +1,7 @@
 #
 #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -137,7 +137,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 
-  INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
 
   INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 15/17] QuarkMin: Use merged variable driver for emulated NV mode

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

The real variable driver has been updated to support emulated
variable NV mode and the EmuVariableRuntimeDxe will be removed
later, so use merged variable driver for emulated NV mode.

Cc: Michael D Kinney 
Cc: Kelly Steele 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 QuarkPlatformPkg/QuarkMin.dsc | 8 ++--
 QuarkPlatformPkg/QuarkMin.fdf | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/QuarkPlatformPkg/QuarkMin.dsc b/QuarkPlatformPkg/QuarkMin.dsc
index d7a25686a30b..bf3a9a8bfd0e 100644
--- a/QuarkPlatformPkg/QuarkMin.dsc
+++ b/QuarkPlatformPkg/QuarkMin.dsc
@@ -2,7 +2,7 @@
 # Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices.
 #
 # This package provides Clanton Peak CRB platform specific modules.
-# Copyright (c) 2013 - 2018 Intel Corporation.
+# Copyright (c) 2013 - 2019 Intel Corporation.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -342,6 +342,10 @@ [PcdsFixedAtBuild]
 !endif
   gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize|0x2000
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x1000
+  #
+  # Make VariableRuntimeDxe work at emulated non-volatile variable mode.
+  #
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
   ## RTC Update Timeout Value, need to increase timeout since also
   # waiting for RTC to be busy.
   gEfiMdeModulePkgTokenSpaceGuid.PcdRealTimeClockUpdateTimeout|50
@@ -553,7 +557,7 @@ [Components.IA32]
   MdeModulePkg/Universal/Metronome/Metronome.inf
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
-  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
diff --git a/QuarkPlatformPkg/QuarkMin.fdf b/QuarkPlatformPkg/QuarkMin.fdf
index b793fbd9a340..6e5545c16d3b 100644
--- a/QuarkPlatformPkg/QuarkMin.fdf
+++ b/QuarkPlatformPkg/QuarkMin.fdf
@@ -2,7 +2,7 @@
 # FDF file of Clanton Peak CRB platform with 32-bit DXE
 #
 # This package provides QuarkNcSocId platform specific modules.
-# Copyright (c) 2013 - 2017 Intel Corporation.
+# Copyright (c) 2013 - 2019 Intel Corporation.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -388,7 +388,7 @@ [FV.FVMAIN]
 INF  MdeModulePkg/Universal/Metronome/Metronome.inf
 INF  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
-INF  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
 INF  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 INF  
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
 INF  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 09/17] MdeModulePkg: Refine description a little for PcdEmuVariableNvStoreReserved

2019-01-15 Thread Star Zeng
This patch is not related directly to
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

PcdEmuVariableNvStoreReserved actually defines the base address of
reserved memory range.

This patch refines description a little for PcdEmuVariableNvStoreReserved.

Suggested-by: Jian J Wang 
Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/MdeModulePkg.dec | 6 +++---
 MdeModulePkg/MdeModulePkg.uni | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 2be77022c948..e5c32d15edcd 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1594,9 +1594,9 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, 
PcdsDynamicEx]
   # @Prompt EMU variable NV mode enable.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|FALSE|BOOLEAN|0x0111
 
-  ## This PCD defines a reserved memory range for EMU variable NV storage.
-  #  The range is valid if non-zero. The memory range size must be 
PcdVariableStoreSize.
-  # @Prompt Reserved memory range for EMU variable NV storage.
+  ## This PCD defines the base address of reserved memory range for EMU 
variable NV storage.
+  #  A non-ZERO value indicates a valid range reserved with size given by 
PcdVariableStoreSize.
+  # @Prompt Base of reserved memory range for EMU variable NV storage.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0|UINT64|0x4008
 
   ## This PCD defines the times to print hello world string.
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 2f437d78eba2..787fdf2282c3 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -397,9 +397,9 @@

   "TRUE  - An EMU variable NV storage will be allocated or reserved for NV 
variables."

   "FALSE - No EMU variable NV storage will be allocated or reserved for NV 
variables."
 
-#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved_PROMPT  
#language en-US "Reserved memory range for EMU variable NV storage"
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved_PROMPT  
#language en-US "Base of reserved memory range for EMU variable NV storage"
 
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved_HELP  
#language en-US "This PCD defines a reserved memory range for EMU variable NV 
storage. The range is valid if non-zero. The memory range size must be 
PcdVariableStoreSize."
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved_HELP  
#language en-US "This PCD defines the base address of reserved memory range for 
EMU variable NV storage. A non-ZERO value indicates a valid range reserved with 
size given by PcdVariableStoreSize."
 
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHelloWorldPrintTimes_PROMPT  
#language en-US "HelloWorld print times"
 
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 16/17] CorebootPayloadPkg: Use merged variable driver for emulated NV mode

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

The real variable driver has been updated to support emulated
variable NV mode and the EmuVariableRuntimeDxe will be removed
later, so use merged variable driver for emulated NV mode.

Cc: Maurice Ma 
Cc: Prince Agyeman 
Cc: Benjamin You 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 CorebootPayloadPkg/CorebootPayloadPkg.fdf|  4 ++--
 CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc| 11 +--
 CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc | 11 +--
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/CorebootPayloadPkg/CorebootPayloadPkg.fdf 
b/CorebootPayloadPkg/CorebootPayloadPkg.fdf
index 741a5c232ed8..0c24f96a1561 100644
--- a/CorebootPayloadPkg/CorebootPayloadPkg.fdf
+++ b/CorebootPayloadPkg/CorebootPayloadPkg.fdf
@@ -3,7 +3,7 @@
 #
 # Provides drivers and definitions to create uefi payload for coreboot.
 #
-# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
 # This program and the accompanying materials are licensed and made available 
under
 # the terms and conditions of the BSD License that accompanies this 
distribution.
 # The full text of the license may be found at
@@ -109,7 +109,7 @@ [FV.DXEFV]
 INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
 INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
 INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
-INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
 
 INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
 INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc 
b/CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc
index 467d4fcdb422..98d6073866f0 100644
--- a/CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc
+++ b/CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc
@@ -3,7 +3,7 @@
 #
 # Provides drivers and definitions to create uefi payload for coreboot.
 #
-# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
 # This program and the accompanying materials are licensed and made available 
under
 # the terms and conditions of the BSD License that accompanies this 
distribution.
 # The full text of the license may be found at
@@ -203,6 +203,9 @@ [LibraryClasses]
   
DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
   LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
   FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+  
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
 
 [LibraryClasses.IA32.SEC]
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
@@ -277,6 +280,10 @@ [PcdsFixedAtBuild]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x1
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x1
+  #
+  # Make VariableRuntimeDxe work at emulated non-volatile variable mode.
+  #
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 
0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
@@ -417,7 +424,7 @@ [Components.IA32]
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
   PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
-  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
 
   #
   # Following are the DXE drivers
diff --git a/CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc 
b/CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc
index 673bd26c7973..608a288c425f 100644
--- a/CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc
+++ b/CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc
@@ -3,7 +3,7 @@
 #
 # Provides drivers and definitions to create uefi payload for coreboot.
 #
-# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
 # This program and the accompanying materials are licensed and made available 
under
 # the terms and conditions of the BSD License that accompanies this 
distribution.
 # The full text of the license may be found at
@@ -203,6 

[edk2] [PATCH V3 04/17] MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize

2019-01-15 Thread Star Zeng
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 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 .../Universal/Variable/RuntimeDxe/Variable.c | 20 ++--
 .../Universal/Variable/RuntimeDxe/Variable.h |  9 +++--
 .../Universal/Variable/RuntimeDxe/VariableDxe.c  | 13 -
 .../Universal/Variable/RuntimeDxe/VariableSmm.c  | 15 ++-
 4 files changed, 27 insertions(+), 30 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_ADDRESSVariableStoreBase;
-  EFI_PHYSICAL_ADDRESSNvStorageBase;
   VARIABLE_ENTRY_PROPERTY *VariableEntry;
 
   
AcquireLockOnlyAtBootTime(>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 90507a8e64f6..d128d1a9c680 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.
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
 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 f1304c9dbccc..30165ce4dc95 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -382,13 +382,17 @@ FtwNotificationEvent (
 ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
   }
 
+  NvStorageVariableBase = 

Re: [edk2] [PATCH v1 1/2] MdeModulePkg/NetLib.h: Fix the possible NULL pointer dereference issue.

2019-01-15 Thread Laszlo Ersek
Hi Jiaxin,

On 01/15/19 02:26, Jiaxin Wu wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1456
> 
> For the NET_LIST_FOR_EACH & NET_LIST_FOR_EACH_SAFE, "Entry" should be
> checked whether it's NULL or not instead of using the pointer directly.
> 
> Cc: Wu Hao A 
> Cc: Gao Liming 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wu Jiaxin 
> ---
>  MdeModulePkg/Include/Library/NetLib.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Include/Library/NetLib.h 
> b/MdeModulePkg/Include/Library/NetLib.h
> index 0977973921..5b1307553a 100644
> --- a/MdeModulePkg/Include/Library/NetLib.h
> +++ b/MdeModulePkg/Include/Library/NetLib.h
> @@ -616,21 +616,21 @@ NetRandomInitSeed (
>  
>  //
>  // Iterate through the double linked list. It is NOT delete safe
>  //
>  #define NET_LIST_FOR_EACH(Entry, ListHead) \
> -  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = 
> Entry->ForwardLink)
> +  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead), Entry != NULL; 
> Entry = Entry->ForwardLink)

(1) The linked list from BaseLib (LIST_ENTRY) always has at least one
element (the head element), and the list is empty if the head element
points back to itself. In other words, ForwardLink may never be NULL.

So why is it necessary to check against that case here?

(2) If the NULL check is indeed necessary for some reason, then we
should write

  Entry != (ListHead) && Entry != NULL

in the controlling expression. Because, with the comma operator, the
(Entry != (ListHead)) expression would be evaluated, but its result
would be ignored.

Thanks,
Laszlo

>  
>  //
>  // Iterate through the double linked list. This is delete-safe.
>  // Don't touch NextEntry. Also, don't use this macro if list
>  // entries other than the Entry may be deleted when processing
>  // the current Entry.
>  //
>  #define NET_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
> -  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink; \
> -  Entry != (ListHead); \
> +  for(Entry = (ListHead)->ForwardLink, (Entry != NULL) ? (NextEntry = 
> Entry->ForwardLink) : (Entry = NULL); \
> +  Entry != (ListHead), Entry != NULL; \
>Entry = NextEntry, NextEntry = Entry->ForwardLink \
>   )
>  
>  //
>  // Make sure the list isn't empty before getting the first/last record.
> 

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 13/17] ArmVirtXen: Link VarCheckUefiLib NULL class library instance

2019-01-15 Thread Star Zeng
This patch is not related directly to
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

It just makes ArmVirtXen be aligned with ArmVirtQemuXXX to
link VarCheckUefiLib NULL class library instance.

Suggested-by: Laszlo Ersek 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Julien Grall 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Laszlo Ersek 
---
 ArmVirtPkg/ArmVirtXen.dsc | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index db85fb3402d0..e58444e6ae27 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -177,7 +177,10 @@ [Components.common]
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
 
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 11/17] MdeModulePkg VariablePei: Don't check BOOT_IN_RECOVERY_MODE

2019-01-15 Thread Star Zeng
Don't check BOOT_IN_RECOVERY_MODE, but check PcdEmuVariableNvModeEnable
which platform can configure flexibly.

Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Universal/Variable/Pei/Variable.c  | 8 +---
 MdeModulePkg/Universal/Variable/Pei/VariablePei.inf | 3 ++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c 
b/MdeModulePkg/Universal/Variable/Pei/Variable.c
index 77b3eaeb210d..148c1cfefd90 100644
--- a/MdeModulePkg/Universal/Variable/Pei/Variable.c
+++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c
@@ -2,7 +2,7 @@
   Implement ReadOnly Variable Services required by PEIM and install
   PEI ReadOnly Varaiable2 PPI. These services operates the non volatile 
storage space.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
 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
@@ -584,9 +584,9 @@ GetVariableStore (
   break;
 
 case VariableStoreTypeNv:
-  if (GetBootModeHob () != BOOT_IN_RECOVERY_MODE) {
+  if (!PcdGetBool (PcdEmuVariableNvModeEnable)) {
 //
-// The content of NV storage for variable is not reliable in recovery 
boot mode.
+// Emulated non-volatile variable mode is not enabled.
 //
 
 NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
@@ -594,6 +594,8 @@ GetVariableStore (
 PcdGet64 
(PcdFlashNvStorageVariableBase64) :
 PcdGet32 
(PcdFlashNvStorageVariableBase)
);
+ASSERT (NvStorageBase != 0);
+
 //
 // First let FvHeader point to NV storage base.
 //
diff --git a/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf 
b/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
index 565efdc02116..3161617a56c2 100644
--- a/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
+++ b/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
@@ -3,7 +3,7 @@
 #
 #  This module implements ReadOnly Variable Services required by PEIM and 
installs PEI ReadOnly Varaiable2 PPI.
 #
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
 #  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
@@ -68,6 +68,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase  ## 
SOMETIMES_CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize  ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable ## 
SOMETIMES_CONSUMES
 
 [Depex]
   gEdkiiFaultTolerantWriteGuid
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 14/17] BeagleBoardPkg: Use merged variable driver for emulated NV mode

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

The real variable driver has been updated to support emulated
variable NV mode and the EmuVariableRuntimeDxe will be removed
later, so use merged variable driver for emulated NV mode.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 BeagleBoardPkg/BeagleBoardPkg.dsc | 14 --
 BeagleBoardPkg/BeagleBoardPkg.fdf |  4 ++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc 
b/BeagleBoardPkg/BeagleBoardPkg.dsc
index 6dabfa905ae9..e0fee3692fd1 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.dsc
+++ b/BeagleBoardPkg/BeagleBoardPkg.dsc
@@ -2,7 +2,7 @@
 # Beagle board package.
 #
 # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.
-# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
 # Copyright (c) 2016, Linaro Ltd. All rights reserved.
 #
 #This program and the accompanying materials
@@ -137,6 +137,11 @@ [LibraryClasses.common]
 
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
 
+  
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+  
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+
 [LibraryClasses.common.SEC]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   
ReportStatusCodeLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
@@ -345,6 +350,11 @@ [PcdsFixedAtBuild.common]
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
 
+  #
+  # Make VariableRuntimeDxe work at emulated non-volatile variable mode.
+  #
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
@@ -376,7 +386,7 @@ [Components.common]
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
   EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
 
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
diff --git a/BeagleBoardPkg/BeagleBoardPkg.fdf 
b/BeagleBoardPkg/BeagleBoardPkg.fdf
index 83d85fce4070..42d6bad0c73b 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.fdf
+++ b/BeagleBoardPkg/BeagleBoardPkg.fdf
@@ -1,7 +1,7 @@
 # FLASH layout file for Beagle board.
 #
 # Copyright (c) 2009, Apple Inc. All rights reserved.
-# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
 # Copyright (c) 2016, Linaro, Ltd. All rights reserved.
 #
 #This program and the accompanying materials
@@ -106,7 +106,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
   INF EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
 
   INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 08/17] MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

Add PcdEmuVariableNvModeEnable (support both static and
dynamic) to indicate if Variable driver will enable
emulated variable NV mode.

This patch prepares for adding emulated variable NV mode
support in VariableRuntimeDxe.

Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Hao Wu 
---
 MdeModulePkg/MdeModulePkg.dec | 12 ++--
 MdeModulePkg/MdeModulePkg.uni | 12 ++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 217ede1f7163..2be77022c948 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -3,7 +3,7 @@
 # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs and library 
classes)
 # and libraries instances, which are used for those modules.
 #
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
 # Copyright (c) 2016, Linaro Ltd. All rights reserved.
 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.
@@ -1586,7 +1586,15 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, 
PcdsDynamicEx]
   # @Prompt 64-bit Base address of flash FTW working block range.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0x0|UINT64|0x8010
 
-  ## This PCD defines a reserved memory range for the EMU Variable driver's NV 
Variable Store.
+  ## Indicates if Variable driver will enable emulated variable NV 
mode.
+  #  If this PCD is configured to dynamic, its value should be set before 
Variable driver starts to work,
+  #  otherwise default value will take effect.
+  #   TRUE  - An EMU variable NV storage will be allocated or reserved for NV 
variables.
+  #   FALSE - No EMU variable NV storage will be allocated or reserved for NV 
variables.
+  # @Prompt EMU variable NV mode enable.
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|FALSE|BOOLEAN|0x0111
+
+  ## This PCD defines a reserved memory range for EMU variable NV storage.
   #  The range is valid if non-zero. The memory range size must be 
PcdVariableStoreSize.
   # @Prompt Reserved memory range for EMU variable NV storage.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0|UINT64|0x4008
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 35af744d89be..2f437d78eba2 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -4,7 +4,7 @@
 // It also provides the definitions(including PPIs/PROTOCOLs/GUIDs and library 
classes)
 // and libraries instances, which are used for those modules.
 //
-// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+// Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
 //
 // This program and the accompanying materials are licensed and made available 
under
 // the terms and conditions of the BSD License that accompanies this 
distribution.
@@ -389,9 +389,17 @@
 
 #string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase64_HELP  
#language en-US "64-bit Base address of the FTW working block range in flash 
device. If PcdFlashNvStorageFtwWorkingSize is larger than one block size, this 
value should be block size aligned."
 
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvModeEnable_PROMPT  
#language en-US "EMU variable NV mode enable"
+
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvModeEnable_HELP  
#language en-US "Indicates if Variable driver will enable emulated variable NV 
mode."
+   
   "If this PCD is configured to dynamic, its value should be set before 
Variable driver starts to work,"
+   
   "otherwise default value will take effect."
+   
   "TRUE  - An EMU variable NV storage will be allocated or reserved for NV 
variables."
+   
   "FALSE - No EMU variable NV storage will be allocated or reserved for NV 
variables."
+
 #string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved_PROMPT  
#language en-US "Reserved memory range for EMU variable NV storage"
 
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved_HELP  
#language en-US "This PCD defines a reserved memory range for the EMU Variable 
driver's NV Variable Store. The range is valid if non-zero. The memory range 
size must be PcdVariableStoreSize."
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvStoreReserved_HELP  
#language en-US "This 

[edk2] [PATCH V3 05/17] MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

Abstract VariableWriteServiceInitializeDxe/Smm from
FtwNotificationEvent/SmmFtwNotificationEvent, then
VariableWriteServiceInitializeDxe/Smm 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 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Hao Wu 
Reviewed-by: Jian J Wang 
---
 .../Universal/Variable/RuntimeDxe/VariableDxe.c| 55 ++
 .../Universal/Variable/RuntimeDxe/VariableSmm.c| 43 -
 2 files changed, 66 insertions(+), 32 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index 30165ce4dc95..521cb4ed2490 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -342,6 +342,40 @@ OnEndOfDxe (
 }
 
 /**
+  Initializes variable write service for DXE.
+
+**/
+VOID
+VariableWriteServiceInitializeDxe (
+  VOID
+  )
+{
+  EFI_STATUSStatus;
+
+  Status = VariableWriteServiceInitialize ();
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status 
= %r\n", Status));
+  }
+
+  //
+  // Some Secure Boot Policy Var (SecureBoot, etc) updates following other
+  // Secure Boot Policy Variable change. Record their initial value.
+  //
+  RecordSecureBootPolicyVarData();
+
+  //
+  // Install the Variable Write Architectural protocol.
+  //
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  NULL
+  );
+  ASSERT_EFI_ERROR (Status);
+}
+
+/**
   Fault Tolerant Write protocol notification event handler.
 
   Non-Volatile variable write may needs FTW protocol to reclaim when
@@ -423,27 +457,10 @@ FtwNotificationEvent (
 }
   }
 
-  Status = VariableWriteServiceInitialize ();
-  if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status 
= %r\n", Status));
-  }
-
   //
-  // Some Secure Boot Policy Var (SecureBoot, etc) updates following other
-  // Secure Boot Policy Variable change. Record their initial value.
+  // Initializes variable write service after FTW was ready.
   //
-  RecordSecureBootPolicyVarData();
-
-  //
-  // Install the Variable Write Architectural protocol.
-  //
-  Status = gBS->InstallProtocolInterface (
-  ,
-  ,
-  EFI_NATIVE_INTERFACE,
-  NULL
-  );
-  ASSERT_EFI_ERROR (Status);
+  VariableWriteServiceInitializeDxe ();
 
   //
   // Close the notify event to avoid install gEfiVariableWriteArchProtocolGuid 
again.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
index 2401ad912ef1..17b7090f0dcd 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
@@ -842,6 +842,34 @@ SmmEndOfDxeCallback (
 }
 
 /**
+  Initializes variable write service for SMM.
+
+**/
+VOID
+VariableWriteServiceInitializeSmm (
+  VOID
+  )
+{
+  EFI_STATUSStatus;
+
+  Status = VariableWriteServiceInitialize ();
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status 
= %r\n", Status));
+  }
+
+  //
+  // Notify the variable wrapper driver the variable write service is ready
+  //
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  NULL
+  );
+  ASSERT_EFI_ERROR (Status);
+}
+
+/**
   SMM Fault Tolerant Write protocol notification event handler.
 
   Non-Volatile variable write may needs FTW protocol to reclaim when
@@ -905,21 +933,10 @@ SmmFtwNotificationEvent (
 
   mVariableModuleGlobal->FvbInstance = FvbProtocol;
 
-  Status = VariableWriteServiceInitialize ();
-  if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status 
= %r\n", Status));
-  }
-
   //
-  // Notify the variable wrapper driver the variable write service is ready
+  // Initializes variable write service after FTW was ready.
   //
-  Status = gBS->InstallProtocolInterface (
-  ,
-  ,
-  EFI_NATIVE_INTERFACE,
-  NULL
-  );
-  ASSERT_EFI_ERROR (Status);
+  VariableWriteServiceInitializeSmm ();
 
   return EFI_SUCCESS;
 }
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 01/17] MdeModulePkg Variable: Add some missing changes for 9b18845

2019-01-15 Thread Star Zeng
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 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Reviewed-by: Hao Wu 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c| 12 +---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c |  6 +++---
 2 files changed, 8 insertions(+), 10 deletions(-)

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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 03/17] MdeModulePkg Variable: Move "extern XXX" to Variable.h

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

Move "extern XXX" to Variable.h from VariableDxe.c/VariableSmm.c.

This patch prepares for adding emulated variable NV mode
support in VariableRuntimeDxe.

Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h| 11 ---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c |  4 
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c |  3 ---
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
index 938eb5de61fa..90507a8e64f6 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
@@ -792,9 +792,14 @@ InitializeVariableQuota (
   VOID
   );
 
-extern VARIABLE_MODULE_GLOBAL  *mVariableModuleGlobal;
-
-extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut;
+extern VARIABLE_MODULE_GLOBAL   *mVariableModuleGlobal;
+extern EFI_FIRMWARE_VOLUME_HEADER   *mNvFvHeaderCache;
+extern VARIABLE_STORE_HEADER*mNvVariableCache;
+extern VARIABLE_INFO_ENTRY  *gVariableInfo;
+extern BOOLEAN  mEndOfDxe;
+extern VAR_CHECK_REQUEST_SOURCE mRequestSource;
+
+extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut;
 
 /**
   Finds variable in storage blocks of volatile and non-volatile storage areas.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index f7185df3a7eb..f1304c9dbccc 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -17,13 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #include "Variable.h"
 
-extern VARIABLE_STORE_HEADER*mNvVariableCache;
-extern EFI_FIRMWARE_VOLUME_HEADER   *mNvFvHeaderCache;
-extern VARIABLE_INFO_ENTRY  *gVariableInfo;
 EFI_HANDLE  mHandle= NULL;
 EFI_EVENT   mVirtualAddressChangeEvent = NULL;
 EFI_EVENT   mFtwRegistration   = NULL;
-extern BOOLEAN  mEndOfDxe;
 VOID***mVarCheckAddressPointer = NULL;
 UINTN   mVarCheckAddressPointerCount = 0;
 EDKII_VARIABLE_LOCK_PROTOCOLmVariableLock  = { 
VariableLockRequestToLock };
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
index 8c53f84ff6e8..623badb0c755 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
@@ -37,14 +37,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include "Variable.h"
 
-extern VARIABLE_INFO_ENTRY   *gVariableInfo;
 EFI_HANDLE   mSmmVariableHandle  = 
NULL;
 EFI_HANDLE   mVariableHandle = 
NULL;
 BOOLEAN  mAtRuntime  = 
FALSE;
 UINT8*mVariableBufferPayload = 
NULL;
 UINTN
mVariableBufferPayloadSize;
-extern BOOLEAN   mEndOfDxe;
-extern VAR_CHECK_REQUEST_SOURCE  mRequestSource;
 
 /**
   SecureBoot Hook for SetVariable.
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support

2019-01-15 Thread Marcin Wojtas
wt., 15 sty 2019 o 11:12 Leif Lindholm  napisał(a):
>
> On Tue, Jan 15, 2019 at 11:05:12AM +0100, Marcin Wojtas wrote:
> > > > Anyway, I tried to play with the MV_BOARD_GPIO_DESCRIPTION to be the
> > > > global variable, but was not convinced by the outcome. My biggest
> > > > objection to the global variable and checking whether it's NULL in the
> > > > consumer driver is following - until now all users of the
> > > > BoardDescProtocol 'know' and call only the relevant protocol routine,
> > > > everything what happens underneath (PCDs, variable names, etc) is
> > > > transparent.
> > > >
> > > > The consumers should be responsible for avoiding the memory leaks and
> > > > this was an improvement of v2. Both MvGpioDxe and MvPca9xxxDxe have
> > > > now fixed error path an properly take care of freeing the memory after
> > > > using protocol.
> > >
> > > But the call sites don't keep track of freeing it when error handling.
> > >
> > > Which I think serves as a clear demonstrator of how magically
> > > allocating buffers makes for difficult code to keep correct. (Which is
> > > why the UEFI intefaces all require you to allocate a buffer and then
> > > pass that and a size as parameters.)
> > >
> > > So, since we are dealing with data that isn't changing, I prefer the
> > > original design - just not the original implemenation.
> > >
> > > So how about sticking with that, but moving the STATIC struct global
> > > in that source file (but keeping it STATIC)?
> > >
> >
> > Good, keeping the global variable inside MvBoardDescDxe and checking
> > it there is a clean and easy solution (consumers won't have to bother
> > about the stuff additional to calling the protocol and error handling
> > will be simpler).
> >
> > How about on top of the file I add a section for global varibles (IMO
> > it's worth to modify other interfaces to that scheme later) and call
> > it:
> >
> > STATIC MV_BOARD_GPIO_DESCRIPTION gGpioDescription;
> > ?
>
> Static, so 'm', not 'g', but yeah.
>

Effectively it will be global to other files :) But I will change to
'm' prefix of course.

Thanks,
Marcin
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support

2019-01-15 Thread Leif Lindholm
On Tue, Jan 15, 2019 at 11:14:16AM +0100, Marcin Wojtas wrote:
> wt., 15 sty 2019 o 11:12 Leif Lindholm  napisał(a):
> >
> > On Tue, Jan 15, 2019 at 11:05:12AM +0100, Marcin Wojtas wrote:
> > > > > Anyway, I tried to play with the MV_BOARD_GPIO_DESCRIPTION to be the
> > > > > global variable, but was not convinced by the outcome. My biggest
> > > > > objection to the global variable and checking whether it's NULL in the
> > > > > consumer driver is following - until now all users of the
> > > > > BoardDescProtocol 'know' and call only the relevant protocol routine,
> > > > > everything what happens underneath (PCDs, variable names, etc) is
> > > > > transparent.
> > > > >
> > > > > The consumers should be responsible for avoiding the memory leaks and
> > > > > this was an improvement of v2. Both MvGpioDxe and MvPca9xxxDxe have
> > > > > now fixed error path an properly take care of freeing the memory after
> > > > > using protocol.
> > > >
> > > > But the call sites don't keep track of freeing it when error handling.
> > > >
> > > > Which I think serves as a clear demonstrator of how magically
> > > > allocating buffers makes for difficult code to keep correct. (Which is
> > > > why the UEFI intefaces all require you to allocate a buffer and then
> > > > pass that and a size as parameters.)
> > > >
> > > > So, since we are dealing with data that isn't changing, I prefer the
> > > > original design - just not the original implemenation.
> > > >
> > > > So how about sticking with that, but moving the STATIC struct global
> > > > in that source file (but keeping it STATIC)?
> > > >
> > >
> > > Good, keeping the global variable inside MvBoardDescDxe and checking
> > > it there is a clean and easy solution (consumers won't have to bother
> > > about the stuff additional to calling the protocol and error handling
> > > will be simpler).
> > >
> > > How about on top of the file I add a section for global varibles (IMO
> > > it's worth to modify other interfaces to that scheme later) and call
> > > it:
> > >
> > > STATIC MV_BOARD_GPIO_DESCRIPTION gGpioDescription;
> > > ?
> >
> > Static, so 'm', not 'g', but yeah.
> 
> Effectively it will be global to other files :) But I will change to
> 'm' prefix of course.

Global is about visibility, not accessibility. This will not be
globally visible.

/
Leif
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 07/17] MdeModulePkg Variable: type case VolatileBase to UINTN directly

2019-01-15 Thread Star Zeng
Simplify
((UINTN) ((UINT8 *) VolatileBase + VolatileBase->Size))
to
((UINTN) VolatileBase + VolatileBase->Size)

This patch prepares for adding emulated variable NV mode
support in VariableRuntimeDxe.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Hao Wu 
Reviewed-by: Jian J Wang 
Reviewed-by: Laszlo Ersek 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 14684b3fedb4..d3df21819abe 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -301,7 +301,7 @@ UpdateVariableStore (
   DataPtr += mVariableModuleGlobal->VariableGlobal.VolatileVariableBase;
 }
 
-if ((DataPtr + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + 
VolatileBase->Size))) {
+if ((DataPtr + DataSize) > ((UINTN) VolatileBase + VolatileBase->Size)) {
   return EFI_OUT_OF_RESOURCES;
 }
 
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 06/17] MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

CacheOffset could be removed in UpdateVariable() after
//
// update the memory copy of Flash region.
//
CopyMem (
  (UINT8 *)mNvVariableCache + CacheOffset,
  (UINT8 *)NextVariable, VarSize
   );

is moved to be before mVariableModuleGlobal->NonVolatileLastVariableOffset
value is updated, like right before
mVariableModuleGlobal->NonVolatileLastVariableOffset +=
  HEADER_ALIGN (VarSize);

Except for the movement above, the patch also capitalizes the first
character of "update the memory copy of Flash region".

This patch prepares for adding emulated variable NV mode
support in VariableRuntimeDxe.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Hao Wu 
Reviewed-by: Jian J Wang 
Reviewed-by: Laszlo Ersek 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 424f92a53757..14684b3fedb4 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -2139,7 +2139,6 @@ UpdateVariable (
   VARIABLE_POINTER_TRACK  *Variable;
   VARIABLE_POINTER_TRACK  NvVariable;
   VARIABLE_STORE_HEADER   *VariableStoreHeader;
-  UINTN   CacheOffset;
   UINT8   *BufferForMerge;
   UINTN   MergedBufSize;
   BOOLEAN DataReady;
@@ -2577,7 +2576,6 @@ UpdateVariable (
 //
 // Step 1:
 //
-CacheOffset = mVariableModuleGlobal->NonVolatileLastVariableOffset;
 Status = UpdateVariableStore (
>VariableGlobal,
FALSE,
@@ -2643,6 +2641,11 @@ UpdateVariable (
   goto Done;
 }
 
+//
+// Update the memory copy of Flash region.
+//
+CopyMem ((UINT8 *)mNvVariableCache + 
mVariableModuleGlobal->NonVolatileLastVariableOffset, (UINT8 *)NextVariable, 
VarSize);
+
 mVariableModuleGlobal->NonVolatileLastVariableOffset += HEADER_ALIGN 
(VarSize);
 
 if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
@@ -2653,10 +2656,6 @@ UpdateVariable (
 mVariableModuleGlobal->CommonUserVariableTotalSize += HEADER_ALIGN 
(VarSize);
   }
 }
-//
-// update the memory copy of Flash region.
-//
-CopyMem ((UINT8 *)mNvVariableCache + CacheOffset, (UINT8 *)NextVariable, 
VarSize);
   } else {
 //
 // Create a volatile variable.
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V3 02/17] MdeModulePkg Variable: Abstract InitRealNonVolatileVariableStore

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

Abstract InitRealNonVolatileVariableStore from
InitNonVolatileVariableStore.

This patch prepares for adding emulated variable NV mode
support in VariableRuntimeDxe.

Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Hao Wu 
---
 .../Universal/Variable/RuntimeDxe/Variable.c   | 86 +++---
 1 file changed, 58 insertions(+), 28 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 99d487adac9e..0b675c8f36df 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -3728,9 +3728,9 @@ GetMaxVariableSize (
 }
 
 /**
-  Init non-volatile variable store.
+  Init real non-volatile variable store.
 
-  @param[out] NvFvHeaderOutput pointer to non-volatile FV header 
address.
+  @param[out] VariableStoreBase Output pointer to real non-volatile variable 
store base.
 
   @retval EFI_SUCCESS   Function successfully executed.
   @retval EFI_OUT_OF_RESOURCES  Fail to allocate enough memory resource.
@@ -3738,16 +3738,13 @@ GetMaxVariableSize (
 
 **/
 EFI_STATUS
-InitNonVolatileVariableStore (
-  OUT EFI_FIRMWARE_VOLUME_HEADER**NvFvHeader
+InitRealNonVolatileVariableStore (
+  OUT EFI_PHYSICAL_ADDRESS  *VariableStoreBase
   )
 {
   EFI_FIRMWARE_VOLUME_HEADER*FvHeader;
-  VARIABLE_HEADER   *Variable;
-  VARIABLE_HEADER   *NextVariable;
-  EFI_PHYSICAL_ADDRESS  VariableStoreBase;
-  UINT64VariableStoreLength;
-  UINTN VariableSize;
+  VARIABLE_STORE_HEADER *VariableStore;
+  UINT32VariableStoreLength;
   EFI_HOB_GUID_TYPE *GuidHob;
   EFI_PHYSICAL_ADDRESS  NvStorageBase;
   UINT8 *NvStorageData;
@@ -3777,6 +3774,8 @@ InitNonVolatileVariableStore (
   if (NvStorageBase == 0) {
 NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 
(PcdFlashNvStorageVariableBase);
   }
+  ASSERT (NvStorageBase != 0);
+
   //
   // Copy NV storage data to the memory buffer.
   //
@@ -3826,24 +3825,23 @@ InitNonVolatileVariableStore (
 return EFI_VOLUME_CORRUPTED;
   }
 
-  VariableStoreBase = (UINTN) FvHeader + FvHeader->HeaderLength;
+  VariableStore = (VARIABLE_STORE_HEADER *) ((UINTN) FvHeader + 
FvHeader->HeaderLength);
   VariableStoreLength = NvStorageSize - FvHeader->HeaderLength;
+  ASSERT (sizeof (VARIABLE_STORE_HEADER) <= VariableStoreLength);
+  ASSERT (VariableStore->Size == VariableStoreLength);
 
-  mNvFvHeaderCache = FvHeader;
-  mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = 
VariableStoreBase;
-  mNvVariableCache = (VARIABLE_STORE_HEADER *) (UINTN) VariableStoreBase;
-  if (GetVariableStoreStatus (mNvVariableCache) != EfiValid) {
+  //
+  // Check if the Variable Store header is not corrupted
+  //
+  if (GetVariableStoreStatus (VariableStore) != EfiValid) {
 FreePool (NvStorageData);
-mNvFvHeaderCache = NULL;
-mNvVariableCache = NULL;
 DEBUG((EFI_D_ERROR, "Variable Store header is corrupted\n"));
 return EFI_VOLUME_CORRUPTED;
   }
-  ASSERT(mNvVariableCache->Size == VariableStoreLength);
 
-  ASSERT (sizeof (VARIABLE_STORE_HEADER) <= VariableStoreLength);
+  mNvFvHeaderCache = FvHeader;
 
-  mVariableModuleGlobal->VariableGlobal.AuthFormat = (BOOLEAN)(CompareGuid 
(>Signature, ));
+  *VariableStoreBase = (EFI_PHYSICAL_ADDRESS) (UINTN) VariableStore;
 
   HwErrStorageSize = PcdGet32 (PcdHwErrStorageSize);
   MaxUserNvVariableSpaceSize = PcdGet32 (PcdMaxUserNvVariableSpaceSize);
@@ -3878,14 +3876,45 @@ InitNonVolatileVariableStore (
   //
   ASSERT (GetNonVolatileMaxVariableSize () < (VariableStoreLength - sizeof 
(VARIABLE_STORE_HEADER)));
 
+  return EFI_SUCCESS;
+}
+
+/**
+  Init non-volatile variable store.
+
+  @retval EFI_SUCCESS   Function successfully executed.
+  @retval EFI_OUT_OF_RESOURCES  Fail to allocate enough memory resource.
+  @retval EFI_VOLUME_CORRUPTED  Variable Store or Firmware Volume for Variable 
Store is corrupted.
+
+**/
+EFI_STATUS
+InitNonVolatileVariableStore (
+  VOID
+  )
+{
+  VARIABLE_HEADER   *Variable;
+  VARIABLE_HEADER   *NextVariable;
+  EFI_PHYSICAL_ADDRESS  VariableStoreBase;
+  UINTN VariableSize;
+  EFI_STATUSStatus;
+
+  Status = InitRealNonVolatileVariableStore ();
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = 
VariableStoreBase;
+  mNvVariableCache = (VARIABLE_STORE_HEADER *) (UINTN) VariableStoreBase;
+  

[edk2] [PATCH V3 00/17] Merge EmuVariable and Real variable driver

2019-01-15 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323

Purpose:
1. Add emulated variable NV mode support in
   MdeModulePkg\Universal\Variable\RuntimeDxe.
   Platform can configure PCD statically (build time) or
   dynamically (boot time) to support emulated variable NV mode.
2. Remove MdeModulePkg\Universal\Variable\EmuRuntimeDxe whose
   most codes are duplicated.


V3:
Addressed all the great feedbacks from Jian, Hao, Laszlo and Leif, thanks.
Pick up RB and AB tags.

Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode_V3

Patches 1~9: Preparation
  Patch 3 and 9 are new added based on feedbacks.
Patch 10~11: Real work
Patch 12~17: Migration for platforms and cleanup


V2: Addressed all the feedbacks from Laszlo, thanks.

Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode_V2

Patches 1~7: Preparation
  Patch 6 and 7 are new separated.
Patch 8~9: Real work
Patch 10~15: Migration for platforms and cleanup
  Patch 11 is new added to let ArmVirtXen be aligned with ArmVirtQemuXXX.


V1:

Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode

Patches 1~5: Preparation
Patch 6~7: Real work
Patch 8~12: Migration for platforms and cleanup

Test done:
Build code with VS2012, VS2015 and GCC49.
Regression: Boot Nt32, Ovmf (including 32, 3264 and 64 with no SMM) to UEFI 
SHELL.
Boot some internal platform to UEFI SHELL and Windows.
Functionality: Boot Nt32, Ovmf (including 32, 3264 and 64 with no SMM) to UEFI 
SHELL
   with PcdEmuVariableNvModeEnable == TRUE.

More test will be welcome and appreciated. :)

Patches to update edk2-platforms Repo will be sent out separately.

Star Zeng (17):
  MdeModulePkg Variable: Add some missing changes for 9b18845
  MdeModulePkg Variable: Abstract InitRealNonVolatileVariableStore
  MdeModulePkg Variable: Move "extern XXX" to Variable.h
  MdeModulePkg Variable: Not get NV PCD in
VariableWriteServiceInitialize
  MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm
  MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()
  MdeModulePkg Variable: type case VolatileBase to UINTN directly
  MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec
  MdeModulePkg: Refine description a little for
PcdEmuVariableNvStoreReserved
  MdeModulePkg Variable: Add emulated variable NV mode support
  MdeModulePkg VariablePei: Don't check BOOT_IN_RECOVERY_MODE
  ArmVirtXen: Use merged variable driver for emulated NV mode
  ArmVirtXen: Link VarCheckUefiLib NULL class library instance
  BeagleBoardPkg: Use merged variable driver for emulated NV mode
  QuarkMin: Use merged variable driver for emulated NV mode
  CorebootPayloadPkg: Use merged variable driver for emulated NV mode
  MdeModulePkg: Remove EmuVariableRuntimeDxe

 ArmVirtPkg/ArmVirtXen.dsc  |   12 +-
 ArmVirtPkg/ArmVirtXen.fdf  |4 +-
 BeagleBoardPkg/BeagleBoardPkg.dsc  |   14 +-
 BeagleBoardPkg/BeagleBoardPkg.fdf  |4 +-
 CorebootPayloadPkg/CorebootPayloadPkg.fdf  |4 +-
 CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc  |   11 +-
 CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc   |   11 +-
 MdeModulePkg/MdeModulePkg.dec  |   16 +-
 MdeModulePkg/MdeModulePkg.dsc  |5 +-
 MdeModulePkg/MdeModulePkg.uni  |   14 +-
 .../Universal/Variable/EmuRuntimeDxe/EmuVariable.c | 1820 
 .../EmuRuntimeDxe/EmuVariableRuntimeDxe.inf|   88 -
 .../EmuRuntimeDxe/EmuVariableRuntimeDxe.uni|   22 -
 .../EmuRuntimeDxe/EmuVariableRuntimeDxeExtra.uni   |   19 -
 .../Variable/EmuRuntimeDxe/InitVariable.c  |  259 ---
 .../Universal/Variable/EmuRuntimeDxe/Variable.h|  277 ---
 MdeModulePkg/Universal/Variable/Pei/Variable.c |8 +-
 .../Universal/Variable/Pei/VariablePei.inf |3 +-
 .../Universal/Variable/RuntimeDxe/Variable.c   |  431 +++--
 .../Universal/Variable/RuntimeDxe/Variable.h   |   19 +-
 .../Universal/Variable/RuntimeDxe/VariableDxe.c|  103 +-
 .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |4 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.c|   90 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |4 +-
 QuarkPlatformPkg/QuarkMin.dsc  |8 +-
 QuarkPlatformPkg/QuarkMin.fdf  |4 +-
 26 files changed, 518 insertions(+), 2736 deletions(-)
 delete mode 100644 MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
 delete mode 100644 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
 delete mode 100644 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.uni
 delete mode 100644 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxeExtra.uni
 delete mode 100644 MdeModulePkg/Universal/Variable/EmuRuntimeDxe/InitVariable.c
 delete mode 100644 

Re: [edk2] [PATCH v2 3/5] ArmVirtPkg: drop reference to ArmPkg/DefaultExceptionHandlerLibBase

2019-01-15 Thread Laszlo Ersek
On 01/15/19 09:23, Ard Biesheuvel wrote:
> Drop the reference to ArmPkg/DefaultExceptionHandlerLibBase, which
> is no longer used anywhere now that DebugAgentSymbolsBaseLib no
> longer incorporates a vector table and exception handling.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> Reviewed-by: Leif Lindholm 
> ---
>  ArmVirtPkg/ArmVirt.dsc.inc | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> index 89c2db074711..c47955be940c 100644
> --- a/ArmVirtPkg/ArmVirt.dsc.inc
> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> @@ -174,7 +174,6 @@ [LibraryClasses.common.SEC]
>BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
>  
>
> DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
> -  
> DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
>
> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
> 

Reviewed-by: Laszlo Ersek 

Thanks!
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 03/15] MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize

2019-01-15 Thread Zeng, Star

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 ; Wang, Jian J ;
Wu, Hao A 
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 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
  .../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_ADDRESSVariableStoreBase;
-  EFI_PHYSICAL_ADDRESSNvStorageBase;
VARIABLE_ENTRY_PROPERTY *VariableEntry;

AcquireLockOnlyAtBootTime(

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.
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
  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

Re: [edk2] [platforms: PATCH v2 08/12] Marvell/Drivers: MvGpioDxe: Introduce platform GPIO driver

2019-01-15 Thread Marcin Wojtas
wt., 15 sty 2019 o 11:04 Leif Lindholm  napisał(a):
>
> On Tue, Jan 15, 2019 at 07:19:04AM +0100, Marcin Wojtas wrote:
> > > > +  if (MmioRead32 (BaseAddress + MV_GPIO_OUT_EN_REG) & (1 << GpioPin)) {
> > > > +*Mode = GPIO_MODE_INPUT;
> > > > +  } else {
> > > > +if (MmioRead32 (BaseAddress + MV_GPIO_DATA_IN_REG) & (1 << 
> > > > GpioPin)) {
> > > > +  *Mode = GPIO_MODE_OUTPUT_1;
> > > > +} else {
> > > > +  *Mode = GPIO_MODE_OUTPUT_0;
> > >
> > > Ah, right, it's the change to EMBEDDED_GPIO that means we have two
> > > output modes to return instead of just input or output.
> > > Could I just ask that you're a bit more explicit about such things in
> > > the cover letter? Would have saved me a couple of minutes of head
> > > scratching.
> >
> > Well, in the cover letter I wrote:
> > "The biggest change is dropping custom GPIO protocol and start using
> > the generic EMBEDDED_GPIO with all its types."
> >
> > And in the commit log of both drivers:
> > "The new driver implements a generic EMBEDDED_GPIO protocol."
> >
> > Wasn't it explicit enough? :)
>
> I mean, it's fine - you've technically given all the information
> needed to deduce that. But it does sort of imply that the reader knows
> all EDK2 interfaces by heart. And I'm not quite there.
>

Ok, sorry for not being specific enough.

Best regards,
Marcin
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support

2019-01-15 Thread Leif Lindholm
On Tue, Jan 15, 2019 at 11:05:12AM +0100, Marcin Wojtas wrote:
> > > Anyway, I tried to play with the MV_BOARD_GPIO_DESCRIPTION to be the
> > > global variable, but was not convinced by the outcome. My biggest
> > > objection to the global variable and checking whether it's NULL in the
> > > consumer driver is following - until now all users of the
> > > BoardDescProtocol 'know' and call only the relevant protocol routine,
> > > everything what happens underneath (PCDs, variable names, etc) is
> > > transparent.
> > >
> > > The consumers should be responsible for avoiding the memory leaks and
> > > this was an improvement of v2. Both MvGpioDxe and MvPca9xxxDxe have
> > > now fixed error path an properly take care of freeing the memory after
> > > using protocol.
> >
> > But the call sites don't keep track of freeing it when error handling.
> >
> > Which I think serves as a clear demonstrator of how magically
> > allocating buffers makes for difficult code to keep correct. (Which is
> > why the UEFI intefaces all require you to allocate a buffer and then
> > pass that and a size as parameters.)
> >
> > So, since we are dealing with data that isn't changing, I prefer the
> > original design - just not the original implemenation.
> >
> > So how about sticking with that, but moving the STATIC struct global
> > in that source file (but keeping it STATIC)?
> >
> 
> Good, keeping the global variable inside MvBoardDescDxe and checking
> it there is a clean and easy solution (consumers won't have to bother
> about the stuff additional to calling the protocol and error handling
> will be simpler).
> 
> How about on top of the file I add a section for global varibles (IMO
> it's worth to modify other interfaces to that scheme later) and call
> it:
> 
> STATIC MV_BOARD_GPIO_DESCRIPTION gGpioDescription;
> ?

Static, so 'm', not 'g', but yeah.

Regards,

Leif
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 06/15] MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()

2019-01-15 Thread Zeng, Star

On 2019/1/15 17:58, Laszlo Ersek wrote:

On 01/15/19 09:04, Wang, Jian J wrote:

Star,

Just a tiny comment below. With it's addressed,

Reviewed-by: Jian J Wang 


-Original Message-
From: Zeng, Star
Sent: Monday, January 14, 2019 11:20 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Wang, Jian J ;
Wu, Hao A ; Laszlo Ersek 
Subject: [PATCH V2 06/15] MdeModulePkg Variable: Remove CacheOffset in
UpdateVariable()

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

CacheOffset could be removed in UpdateVariable() after
//
// update the memory copy of Flash region.
//
CopyMem (
   (UINT8 *)mNvVariableCache + CacheOffset,
   (UINT8 *)NextVariable, VarSize
);

is moved to be before mVariableModuleGlobal->NonVolatileLastVariableOffset
value is updated, like right before

mVariableModuleGlobal->NonVolatileLastVariableOffset +=
   HEADER_ALIGN (VarSize);

This patch prepares for adding emulated variable NV mode
support in VariableRuntimeDxe.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 11 +--
  1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 424f92a53757..4d524db30fec 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -2139,7 +2139,6 @@ UpdateVariable (
VARIABLE_POINTER_TRACK  *Variable;
VARIABLE_POINTER_TRACK  NvVariable;
VARIABLE_STORE_HEADER   *VariableStoreHeader;
-  UINTN   CacheOffset;
UINT8   *BufferForMerge;
UINTN   MergedBufSize;
BOOLEAN DataReady;
@@ -2577,7 +2576,6 @@ UpdateVariable (
  //
  // Step 1:
  //
-CacheOffset = mVariableModuleGlobal->NonVolatileLastVariableOffset;
  Status = UpdateVariableStore (
 >VariableGlobal,
 FALSE,
@@ -2643,6 +2641,11 @@ UpdateVariable (
goto Done;
  }

+//
+// update the memory copy of Flash region.
+//


The first character of comment is not capitalized.


In this particular case, I agree that such a change can be added to the
patch. While it does not pertain to the actual work done here, the patch
itself is so small (which is a good thing!) that the comment
capitalization would not cause confusion.

Still I suggest mentioning it briefly in the commit message too.


Make sense, I can do that.

Thanks,
Star



Thanks
Laszlo





+CopyMem ((UINT8 *)mNvVariableCache + mVariableModuleGlobal-

NonVolatileLastVariableOffset, (UINT8 *)NextVariable, VarSize);

+
  mVariableModuleGlobal->NonVolatileLastVariableOffset += HEADER_ALIGN
(VarSize);

  if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
@@ -2653,10 +2656,6 @@ UpdateVariable (
  mVariableModuleGlobal->CommonUserVariableTotalSize +=
HEADER_ALIGN (VarSize);
}
  }
-//
-// update the memory copy of Flash region.
-//
-CopyMem ((UINT8 *)mNvVariableCache + CacheOffset, (UINT8
*)NextVariable, VarSize);
} else {
  //
  // Create a volatile variable.
--
2.7.0.windows.1




___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 5/5] ArmPkg/DefaultExceptionHandlerLib: use console if available

2019-01-15 Thread Laszlo Ersek
On 01/15/19 09:23, Ard Biesheuvel wrote:
> Print the minimal 'exception occurred' message to the console instead
> of straight to the serial port if the console is available. This makes
> such messages visible on systems where the console is graphical and
> the serial is not connected.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> Reviewed-by: Leif Lindholm 
> ---
>  ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c 
> | 12 ++--
>  ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c 
> |  7 ++-
>  ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
> |  1 +
>  3 files changed, 17 insertions(+), 3 deletions(-)

Please consider updating the following, before pushing the patch:

> diff --git 
> a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c 
> b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> index 1024bf48c63d..362acd5ba6d2 100644
> --- 
> a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> +++ 
> b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> @@ -22,6 +22,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -159,14 +160,21 @@ DefaultExceptionHandler (
>INT32  Offset;
>  
>if (mRecursiveException) {
> -CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive exception 
> occurred while dumping the CPU state\n");
> -SerialPortWrite ((UINT8 *) Buffer, CharCount);
> +STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while 
> dumping the CPU state\n";
> +
> +SerialPortWrite ((UINT8 *)Message, AsciiStrLen (Message));

(1) A micro-optimization could be (sizeof Message - 1) rather than
AsciiStrLen (Message), but it's mostly irrelevant.

> +if (gST->ConOut != NULL) {
> +  AsciiPrint (Message);
> +}
>  CpuDeadLoop ();
>}
>mRecursiveException = TRUE;
>  
>CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 
> 0x%016lx\n", gExceptionTypeString[ExceptionType], 
> SystemContext.SystemContextAArch64->ELR);
>SerialPortWrite ((UINT8 *) Buffer, CharCount);
> +  if (gST->ConOut != NULL) {
> +AsciiPrint (Buffer);
> +  }
>  
>DEBUG_CODE_BEGIN ();
>  CHAR8  *Pdb, *PrevPdb;
> diff --git 
> a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c 
> b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
> index cc79cb2fa301..a79f73725aed 100644
> --- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
> +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
> @@ -21,6 +21,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
> @@ -194,7 +195,11 @@ DefaultExceptionHandler (
>  
>CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 
> 0x%08x  CPSR 0x%08x ",
>   gExceptionTypeString[ExceptionType], 
> SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);
> -  SerialPortWrite ((UINT8 *) Buffer, CharCount);
> +  if (gST->ConOut != NULL) {
> +AsciiPrint (Buffer);
> +  } else {
> +SerialPortWrite ((UINT8 *)Buffer, CharCount);
> +  }

(2) I think the "serial PLUS console" reporting applies to the 32-bit
lib instance as well, so I assume not updating this from v1 was an
oversight.

>  
>DEBUG_CODE_BEGIN ();
>  CHAR8   *Pdb;
> diff --git 
> a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf 
> b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
> index 7609f82d89a1..6bc48714c9dc 100644
> --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
> +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
> @@ -42,6 +42,7 @@ [LibraryClasses]
>PeCoffGetEntryPointLib
>ArmDisassemblerLib
>SerialPortLib
> +  UefiBootServicesTableLib
>  
>  [Guids]
>gEfiDebugImageInfoTableGuid
> 

With (2) updated, and regardless of (1):

Acked-by: Laszlo Ersek 

Thanks!
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support

2019-01-15 Thread Marcin Wojtas
wt., 15 sty 2019 o 10:56 Leif Lindholm  napisał(a):
>
> On Tue, Jan 15, 2019 at 07:05:42AM +0100, Marcin Wojtas wrote:
> > > > index f71bfc4..e348b85 100644
> > > > --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
> > > > +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
> > > > @@ -100,6 +100,48 @@ MvBoardDescComPhyGet (
> > > >
> > > >  STATIC
> > > >  EFI_STATUS
> > > > +MvBoardGpioDescriptionGet (
> > > > +  IN MARVELL_BOARD_DESC_PROTOCOL*This,
> > > > +  IN OUT MV_BOARD_GPIO_DESCRIPTION **GpioDescription
> > > > +  )
> > > > +{
> > > > +  MV_BOARD_GPIO_DESCRIPTION *Description;
> > >
> > > My request on v1 was that this be refactored from a STATIC local
> > > variable to a global variable.
> > >
> > > > +  UINTN SoCGpioCount, GpioExpanderCount;
> > > > +  MV_GPIO_EXPANDER *GpioExpanders;
> > > > +  GPIO_CONTROLLER *SoCGpio;
> > > > +  EFI_STATUS Status;
> > > > +
> > > > +  /* Get SoC data about all available GPIO controllers */
> > > > +  Status = ArmadaSoCGpioGet (, );
> > > > +  if (EFI_ERROR (Status)) {
> > > > +return Status;
> > > > +  }
> > > > +
> > > > +  /* Get per-board information about all available I2C IO expanders */
> > >
> > > GPIO
> >
> > OK.
> >
> > >
> > > > +  Status = ArmadaBoardGpioExpanderGet (, 
> > > > );
> > > > +  if (EFI_ERROR (Status)) {
> > > > +return Status;
> > > > +  }
> > > > +
> > > > +  /* Allocate and fill board description */
> > > > +  Description = AllocateZeroPool (sizeof (MV_BOARD_GPIO_DESCRIPTION));
> > >
> > > Instead, this space is now dynamically allocated. But none of the call
> > > sites actually change, leading to potential memory leaks.
> > >
> > > I don't have a problem if you prefer an alternative solution to the
> > > one I propose, but please discuss the change first rather than
> > > submitting a new revision containing something I didn't ask for.
> >
> > Indeed, I could have asked, but didn't want to spoil your Christmas
> > time with questions, especially gitven it was 3+ weeks from review:/
>
> It's not like I was checking email :)
>
> > Anyway, I tried to play with the MV_BOARD_GPIO_DESCRIPTION to be the
> > global variable, but was not convinced by the outcome. My biggest
> > objection to the global variable and checking whether it's NULL in the
> > consumer driver is following - until now all users of the
> > BoardDescProtocol 'know' and call only the relevant protocol routine,
> > everything what happens underneath (PCDs, variable names, etc) is
> > transparent.
> >
> > The consumers should be responsible for avoiding the memory leaks and
> > this was an improvement of v2. Both MvGpioDxe and MvPca9xxxDxe have
> > now fixed error path an properly take care of freeing the memory after
> > using protocol.
>
> But the call sites don't keep track of freeing it when error handling.
>
> Which I think serves as a clear demonstrator of how magically
> allocating buffers makes for difficult code to keep correct. (Which is
> why the UEFI intefaces all require you to allocate a buffer and then
> pass that and a size as parameters.)
>
> So, since we are dealing with data that isn't changing, I prefer the
> original design - just not the original implemenation.
>
> So how about sticking with that, but moving the STATIC struct global
> in that source file (but keeping it STATIC)?
>

Good, keeping the global variable inside MvBoardDescDxe and checking
it there is a clean and easy solution (consumers won't have to bother
about the stuff additional to calling the protocol and error handling
will be simpler).

How about on top of the file I add a section for global varibles (IMO
it's worth to modify other interfaces to that scheme later) and call
it:

STATIC MV_BOARD_GPIO_DESCRIPTION gGpioDescription;
?

Thanks,
Marcin

> /
> Leif
>
> > Please let know if above approach is acceptable.
> >
> > Best regards,
> > Marcin
> >
> > > /
> > > Leif
> > >
> > > > +  if (Description == NULL) {
> > > > +DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", 
> > > > __FUNCTION__));
> > > > +return EFI_OUT_OF_RESOURCES;
> > > > +  }
> > > > +
> > > > +  Description->SoCGpio = SoCGpio;
> > > > +  Description->GpioDeviceCount = SoCGpioCount;
> > > > +  Description->GpioExpanders = GpioExpanders;
> > > > +  Description->GpioExpanderCount = GpioExpanderCount;
> > > > +
> > > > +  *GpioDescription = Description;
> > > > +
> > > > +  return EFI_SUCCESS;
> > > > +}
> > > > +
> > > > +STATIC
> > > > +EFI_STATUS
> > > >  MvBoardDescI2cGet (
> > > >IN MARVELL_BOARD_DESC_PROTOCOL  *This,
> > > >IN OUT MV_BOARD_I2C_DESC   **I2cDesc
> > > > @@ -571,6 +613,7 @@ MvBoardDescInitProtocol (
> > > >BoardDescProtocol->BoardDescUtmiGet = MvBoardDescUtmiGet;
> > > >BoardDescProtocol->BoardDescXhciGet = MvBoardDescXhciGet;
> > > >BoardDescProtocol->BoardDescFree = MvBoardDescFree;
> > > > +  BoardDescProtocol->GpioDescriptionGet = MvBoardGpioDescriptionGet;
> > > >
> > > >return EFI_SUCCESS;
> > > >  }
> > > > --
> > > > 

Re: [edk2] [platforms: PATCH v2 08/12] Marvell/Drivers: MvGpioDxe: Introduce platform GPIO driver

2019-01-15 Thread Leif Lindholm
On Tue, Jan 15, 2019 at 07:19:04AM +0100, Marcin Wojtas wrote:
> > > +  if (MmioRead32 (BaseAddress + MV_GPIO_OUT_EN_REG) & (1 << GpioPin)) {
> > > +*Mode = GPIO_MODE_INPUT;
> > > +  } else {
> > > +if (MmioRead32 (BaseAddress + MV_GPIO_DATA_IN_REG) & (1 << GpioPin)) 
> > > {
> > > +  *Mode = GPIO_MODE_OUTPUT_1;
> > > +} else {
> > > +  *Mode = GPIO_MODE_OUTPUT_0;
> >
> > Ah, right, it's the change to EMBEDDED_GPIO that means we have two
> > output modes to return instead of just input or output.
> > Could I just ask that you're a bit more explicit about such things in
> > the cover letter? Would have saved me a couple of minutes of head
> > scratching.
> 
> Well, in the cover letter I wrote:
> "The biggest change is dropping custom GPIO protocol and start using
> the generic EMBEDDED_GPIO with all its types."
> 
> And in the commit log of both drivers:
> "The new driver implements a generic EMBEDDED_GPIO protocol."
> 
> Wasn't it explicit enough? :)

I mean, it's fine - you've technically given all the information
needed to deduce that. But it does sort of imply that the reader knows
all EDK2 interfaces by heart. And I'm not quite there.

/
Leif
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 06/15] MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()

2019-01-15 Thread Laszlo Ersek
On 01/15/19 09:04, Wang, Jian J wrote:
> Star,
> 
> Just a tiny comment below. With it's addressed, 
> 
> Reviewed-by: Jian J Wang 
> 
>> -Original Message-
>> From: Zeng, Star
>> Sent: Monday, January 14, 2019 11:20 PM
>> To: edk2-devel@lists.01.org
>> Cc: Zeng, Star ; Wang, Jian J ;
>> Wu, Hao A ; Laszlo Ersek 
>> Subject: [PATCH V2 06/15] MdeModulePkg Variable: Remove CacheOffset in
>> UpdateVariable()
>>
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
>> Merge EmuVariable and Real variable driver.
>>
>> CacheOffset could be removed in UpdateVariable() after
>> //
>> // update the memory copy of Flash region.
>> //
>> CopyMem (
>>   (UINT8 *)mNvVariableCache + CacheOffset,
>>   (UINT8 *)NextVariable, VarSize
>>);
>>
>> is moved to be before mVariableModuleGlobal->NonVolatileLastVariableOffset
>> value is updated, like right before
>>
>> mVariableModuleGlobal->NonVolatileLastVariableOffset +=
>>   HEADER_ALIGN (VarSize);
>>
>> This patch prepares for adding emulated variable NV mode
>> support in VariableRuntimeDxe.
>>
>> Cc: Jian J Wang 
>> Cc: Hao Wu 
>> Cc: Laszlo Ersek 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Star Zeng 
>> ---
>>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 11 +--
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> index 424f92a53757..4d524db30fec 100644
>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> @@ -2139,7 +2139,6 @@ UpdateVariable (
>>VARIABLE_POINTER_TRACK  *Variable;
>>VARIABLE_POINTER_TRACK  NvVariable;
>>VARIABLE_STORE_HEADER   *VariableStoreHeader;
>> -  UINTN   CacheOffset;
>>UINT8   *BufferForMerge;
>>UINTN   MergedBufSize;
>>BOOLEAN DataReady;
>> @@ -2577,7 +2576,6 @@ UpdateVariable (
>>  //
>>  // Step 1:
>>  //
>> -CacheOffset = mVariableModuleGlobal->NonVolatileLastVariableOffset;
>>  Status = UpdateVariableStore (
>> >VariableGlobal,
>> FALSE,
>> @@ -2643,6 +2641,11 @@ UpdateVariable (
>>goto Done;
>>  }
>>
>> +//
>> +// update the memory copy of Flash region.
>> +//
> 
> The first character of comment is not capitalized.

In this particular case, I agree that such a change can be added to the
patch. While it does not pertain to the actual work done here, the patch
itself is so small (which is a good thing!) that the comment
capitalization would not cause confusion.

Still I suggest mentioning it briefly in the commit message too.

Thanks
Laszlo


> 
>> +CopyMem ((UINT8 *)mNvVariableCache + mVariableModuleGlobal-
>>> NonVolatileLastVariableOffset, (UINT8 *)NextVariable, VarSize);
>> +
>>  mVariableModuleGlobal->NonVolatileLastVariableOffset += HEADER_ALIGN
>> (VarSize);
>>
>>  if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
>> @@ -2653,10 +2656,6 @@ UpdateVariable (
>>  mVariableModuleGlobal->CommonUserVariableTotalSize +=
>> HEADER_ALIGN (VarSize);
>>}
>>  }
>> -//
>> -// update the memory copy of Flash region.
>> -//
>> -CopyMem ((UINT8 *)mNvVariableCache + CacheOffset, (UINT8
>> *)NextVariable, VarSize);
>>} else {
>>  //
>>  // Create a volatile variable.
>> --
>> 2.7.0.windows.1
> 

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 06/12] Marvell/Drivers: MvBoardDesc: Extend protocol with GPIO support

2019-01-15 Thread Leif Lindholm
On Tue, Jan 15, 2019 at 07:05:42AM +0100, Marcin Wojtas wrote:
> > > index f71bfc4..e348b85 100644
> > > --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
> > > +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
> > > @@ -100,6 +100,48 @@ MvBoardDescComPhyGet (
> > >
> > >  STATIC
> > >  EFI_STATUS
> > > +MvBoardGpioDescriptionGet (
> > > +  IN MARVELL_BOARD_DESC_PROTOCOL*This,
> > > +  IN OUT MV_BOARD_GPIO_DESCRIPTION **GpioDescription
> > > +  )
> > > +{
> > > +  MV_BOARD_GPIO_DESCRIPTION *Description;
> >
> > My request on v1 was that this be refactored from a STATIC local
> > variable to a global variable.
> >
> > > +  UINTN SoCGpioCount, GpioExpanderCount;
> > > +  MV_GPIO_EXPANDER *GpioExpanders;
> > > +  GPIO_CONTROLLER *SoCGpio;
> > > +  EFI_STATUS Status;
> > > +
> > > +  /* Get SoC data about all available GPIO controllers */
> > > +  Status = ArmadaSoCGpioGet (, );
> > > +  if (EFI_ERROR (Status)) {
> > > +return Status;
> > > +  }
> > > +
> > > +  /* Get per-board information about all available I2C IO expanders */
> >
> > GPIO
> 
> OK.
> 
> >
> > > +  Status = ArmadaBoardGpioExpanderGet (, 
> > > );
> > > +  if (EFI_ERROR (Status)) {
> > > +return Status;
> > > +  }
> > > +
> > > +  /* Allocate and fill board description */
> > > +  Description = AllocateZeroPool (sizeof (MV_BOARD_GPIO_DESCRIPTION));
> >
> > Instead, this space is now dynamically allocated. But none of the call
> > sites actually change, leading to potential memory leaks.
> >
> > I don't have a problem if you prefer an alternative solution to the
> > one I propose, but please discuss the change first rather than
> > submitting a new revision containing something I didn't ask for.
> 
> Indeed, I could have asked, but didn't want to spoil your Christmas
> time with questions, especially gitven it was 3+ weeks from review:/

It's not like I was checking email :)

> Anyway, I tried to play with the MV_BOARD_GPIO_DESCRIPTION to be the
> global variable, but was not convinced by the outcome. My biggest
> objection to the global variable and checking whether it's NULL in the
> consumer driver is following - until now all users of the
> BoardDescProtocol 'know' and call only the relevant protocol routine,
> everything what happens underneath (PCDs, variable names, etc) is
> transparent.
> 
> The consumers should be responsible for avoiding the memory leaks and
> this was an improvement of v2. Both MvGpioDxe and MvPca9xxxDxe have
> now fixed error path an properly take care of freeing the memory after
> using protocol.

But the call sites don't keep track of freeing it when error handling.

Which I think serves as a clear demonstrator of how magically
allocating buffers makes for difficult code to keep correct. (Which is
why the UEFI intefaces all require you to allocate a buffer and then
pass that and a size as parameters.)

So, since we are dealing with data that isn't changing, I prefer the
original design - just not the original implemenation.

So how about sticking with that, but moving the STATIC struct global
in that source file (but keeping it STATIC)?

/
Leif

> Please let know if above approach is acceptable.
> 
> Best regards,
> Marcin
> 
> > /
> > Leif
> >
> > > +  if (Description == NULL) {
> > > +DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__));
> > > +return EFI_OUT_OF_RESOURCES;
> > > +  }
> > > +
> > > +  Description->SoCGpio = SoCGpio;
> > > +  Description->GpioDeviceCount = SoCGpioCount;
> > > +  Description->GpioExpanders = GpioExpanders;
> > > +  Description->GpioExpanderCount = GpioExpanderCount;
> > > +
> > > +  *GpioDescription = Description;
> > > +
> > > +  return EFI_SUCCESS;
> > > +}
> > > +
> > > +STATIC
> > > +EFI_STATUS
> > >  MvBoardDescI2cGet (
> > >IN MARVELL_BOARD_DESC_PROTOCOL  *This,
> > >IN OUT MV_BOARD_I2C_DESC   **I2cDesc
> > > @@ -571,6 +613,7 @@ MvBoardDescInitProtocol (
> > >BoardDescProtocol->BoardDescUtmiGet = MvBoardDescUtmiGet;
> > >BoardDescProtocol->BoardDescXhciGet = MvBoardDescXhciGet;
> > >BoardDescProtocol->BoardDescFree = MvBoardDescFree;
> > > +  BoardDescProtocol->GpioDescriptionGet = MvBoardGpioDescriptionGet;
> > >
> > >return EFI_SUCCESS;
> > >  }
> > > --
> > > 2.7.4
> > >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 08/15] MdeModulePkg Variable: Add emulated variable NV mode support

2019-01-15 Thread Laszlo Ersek
On 01/15/19 07:16, Zeng, Star wrote:
> On 2019/1/15 14:01, Wang, Jian J wrote:
>> Hi Star,
>>
>> Just two minor comments below.
>>
>>> -Original Message-
>>> From: Zeng, Star
>>> Sent: Monday, January 14, 2019 11:20 PM
>>> To: edk2-devel@lists.01.org
>>> Cc: Zeng, Star ; Wang, Jian J
>>> ;
>>> Wu, Hao A ; Kinney, Michael D
>>> ; Gao, Liming ; Ni,
>>> Ray
>>> ; Laszlo Ersek ; Ard Biesheuvel
>>> 
>>> Subject: [PATCH V2 08/15] MdeModulePkg Variable: Add emulated
>>> variable NV
>>> mode support

>>> @@ -3894,9 +4024,19 @@ InitNonVolatileVariableStore (
>>>     UINTN VariableSize;
>>>     EFI_STATUS    Status;
>>>
>>> -  Status = InitRealNonVolatileVariableStore ();
>>> -  if (EFI_ERROR (Status)) {
>>> -    return Status;
>>> +  if (!PcdGetBool (PcdEmuVariableNvModeEnable)) {
>>> +    Status = InitRealNonVolatileVariableStore ();
>>> +    if (EFI_ERROR (Status)) {
>>> +  return Status;
>>> +    }
>>> +    mVariableModuleGlobal->VariableGlobal.EmuNvMode = FALSE;
>>> +  } else {
>>> +    Status = InitEmuNonVolatileVariableStore ();
>>> +    if (EFI_ERROR (Status)) {
>>> +  return Status;
>>> +    }
>>> +    mVariableModuleGlobal->VariableGlobal.EmuNvMode = TRUE;
>>> +    DEBUG ((DEBUG_INFO, "Variable driver will work at emulated
>>> non-volatile
>>> variable mode!\n"));
>>>     }
>>>
>>
>> The logic is not wrong, just the if/else style might cause confusion at
>> the first glance. Swapping the if/else might let the code more clear.
>>
>> if (PcdGetBool (PcdEmuVariableNvModeEnable)) {
>>     ...initialize emulated variable store...
>> } else {
>>     ...initialize the real nv variable store...
>> }
> 
> I am neutral about it. I can update it if no other comment.

I agree with Jian: the change that he suggests does not complicate the
patch, and the end result is slightly more readable.

Thanks
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 12/15] BeagleBoardPkg: Use merged variable driver for emulated NV mode

2019-01-15 Thread Leif Lindholm
On Tue, Jan 15, 2019 at 09:32:59AM +0800, Zeng, Star wrote:
> > This patch also need an added resolution for SynchronizationLib.
> > (MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> > should be fine.)
> 
> Oh, yes. I assumed it has been there, but it is not.

Yes, BeagleBoard really is quite a minimalistic port.

> > The same modification will also be needed in edk2-platforms for
> > Platform/Hisilicon/HiKey and HiKey960.
> 
> Yes, I mentioned it in cover letter, that will be in a separated patch
> series later.

Excellent, thanks.
But I was not Cc:d on the cover letter.

Regards,

Leif
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 08/15] MdeModulePkg Variable: Add emulated variable NV mode support

2019-01-15 Thread Zeng, Star

On 2019/1/15 17:33, Laszlo Ersek wrote:

On 01/14/19 16:19, Star Zeng wrote:

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
Merge EmuVariable and Real variable driver.

Add emulated variable NV mode support in real variable driver.
Platform can configure PcdEmuVariableNvModeEnable statically
(build time) or dynamically (boot time) to support emulated
variable NV mode.

Then EmuVariableRuntimeDxe could be removed, the removal of
EmuVariableRuntimeDxe will be done after platforms are migrated
to use the merged variable driver.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
  .../Universal/Variable/RuntimeDxe/Variable.c   | 318 +++--
  .../Universal/Variable/RuntimeDxe/Variable.h   |   1 +
  .../Universal/Variable/RuntimeDxe/VariableDxe.c|  27 +-
  .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |   4 +-
  .../Universal/Variable/RuntimeDxe/VariableSmm.c|  29 +-
  .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |   4 +-
  6 files changed, 271 insertions(+), 112 deletions(-)


Acked-by: Laszlo Ersek 

(I think that this work and Ard's standalone MM refactoring will
conflict. If that's the case then I guess one of the patch sets should
be rebased. I seem to recall that this was already discussed on the list.)


Yes, right.
I have been aware of the conflict, and I have notified it at 
https://lists.01.org/pipermail/edk2-devel/2019-January/034934.html when 
I sent V1 patches.


Thanks,
Star



Thanks,
Laszlo



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Match the nested partitions

2019-01-15 Thread Gary Lin
In some cases, such as MD RAID1 in Linux, the bootloader may be in a
nested EFI system partition partition. For example, sda1 and sdb1 are
combined as md0 and the first partition of md0, md0p1, is an EFI system
partition. Then, the bootloader can be located by the following device
paths:

PCI()/SATA(sda)/Partition(sda1)/Partition(md0p1)/File(bootloader.efi)
PCI()/SATA(sdb)/Partition(sdb1)/Partition(md0p1)/File(bootloader.efi)

To make the boot option more resilient, we may create a boot option with
the short-form device path like "Partition(md0p1)/File(bootloader.efi)".

However, BmMatchPartitionDevicePathNode() only matched the first
partition node and ignored the nested partitions, so the firmware would
refuse to load bootloader.efi since "Partition(md0p1)" doesn't match
either "Partition(sda1)" or "Partition(sda2)".

This commit modifies BmMatchPartitionDevicePathNode() to iterate all
nested partitions so that the above boot option could work.

Cc: Ruiyu Ni 
Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Gary Lin 
---
 .../Library/UefiBootManagerLib/BmBoot.c   | 37 ---
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 6a23477eb873..8354c2af674b 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1995,21 +1995,30 @@ BmMatchPartitionDevicePathNode (
 return FALSE;
   }
 
-  //
-  // See if the harddrive device path in blockio matches the orig Hard Drive 
Node
-  //
-  Node = (HARDDRIVE_DEVICE_PATH *) BlockIoDevicePath;
+  do {
+//
+// See if the harddrive device path in blockio matches the orig Hard Drive 
Node
+//
+Node = (HARDDRIVE_DEVICE_PATH *) BlockIoDevicePath;
 
-  //
-  // Match Signature and PartitionNumber.
-  // Unused bytes in Signature are initiaized with zeros.
-  //
-  return (BOOLEAN) (
-(Node->PartitionNumber == HardDriveDevicePath->PartitionNumber) &&
-(Node->MBRType == HardDriveDevicePath->MBRType) &&
-(Node->SignatureType == HardDriveDevicePath->SignatureType) &&
-(CompareMem (Node->Signature, HardDriveDevicePath->Signature, sizeof 
(Node->Signature)) == 0)
-);
+//
+// Match Signature and PartitionNumber.
+// Unused bytes in Signature are initiaized with zeros.
+//
+if ((Node->PartitionNumber == HardDriveDevicePath->PartitionNumber) &&
+(Node->MBRType == HardDriveDevicePath->MBRType) &&
+(Node->SignatureType == HardDriveDevicePath->SignatureType) &&
+(CompareMem (Node->Signature, HardDriveDevicePath->Signature, sizeof 
(Node->Signature)) == 0)) {
+  return TRUE;
+}
+
+// See if a nested partition exists
+BlockIoDevicePath = NextDevicePathNode (BlockIoDevicePath);
+  } while (!IsDevicePathEnd (BlockIoDevicePath) &&
+   (DevicePathType (BlockIoDevicePath) == MEDIA_DEVICE_PATH) &&
+   (DevicePathSubType (BlockIoDevicePath) == MEDIA_HARDDRIVE_DP));
+
+  return FALSE;
 }
 
 /**
-- 
2.20.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 11/15] ArmVirtXen: Link VarCheckUefiLib NULL class library instance

2019-01-15 Thread Laszlo Ersek
On 01/14/19 16:19, Star Zeng wrote:
> This patch is not related to
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> It just makes ArmVirtXen be aligned with ArmVirtQemuXXX to
> link VarCheckUefiLib NULL class library instance.
> 
> Suggested-by: Laszlo Ersek 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Cc: Julien Grall 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  ArmVirtPkg/ArmVirtXen.dsc | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
> index db85fb3402d0..e58444e6ae27 100644
> --- a/ArmVirtPkg/ArmVirtXen.dsc
> +++ b/ArmVirtPkg/ArmVirtXen.dsc
> @@ -177,7 +177,10 @@ [Components.common]
>MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>  
> -  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> +  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
> +
> +  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
> +  }
>  
>
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
>MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
> 

Reviewed-by: Laszlo Ersek 

Thanks!
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 10/15] ArmVirtXen: Use merged variable driver for emulated NV mode

2019-01-15 Thread Laszlo Ersek
On 01/14/19 16:19, Star Zeng wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> The real variable driver has been updated to support emulated
> variable NV mode and the EmuVariableRuntimeDxe will be removed
> later, so use merged variable driver for emulated NV mode.
> 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Cc: Julien Grall 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  ArmVirtPkg/ArmVirtXen.dsc | 9 +++--
>  ArmVirtPkg/ArmVirtXen.fdf | 4 ++--
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
> index a29d8a4ae717..db85fb3402d0 100644
> --- a/ArmVirtPkg/ArmVirtXen.dsc
> +++ b/ArmVirtPkg/ArmVirtXen.dsc
> @@ -1,7 +1,7 @@
>  #
>  #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
>  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
> -#  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -101,6 +101,11 @@ [PcdsFixedAtBuild.common]
># Set terminal type to TtyTerm, the value encoded is EFI_TTY_TERM_GUID
>gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91, 0x7d, 
> 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94}
>  
> +  #
> +  # Make VariableRuntimeDxe work at emulated non-volatile variable mode.
> +  #
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
> +
>  [PcdsPatchableInModule.common]
>#
># This will be overridden in the code
> @@ -172,7 +177,7 @@ [Components.common]
>MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>  
> -  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
> +  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>  
>
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
>MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
> diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf
> index 50e670254d52..5655c0df2926 100644
> --- a/ArmVirtPkg/ArmVirtXen.fdf
> +++ b/ArmVirtPkg/ArmVirtXen.fdf
> @@ -1,7 +1,7 @@
>  #
>  #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
>  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
> -#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -137,7 +137,7 @@ [FV.FvMain]
>INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>  
> -  INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
> +  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>  
>INF 
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
>INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
> 

Reviewed-by: Laszlo Ersek 

Julien, can you please regression test this series on Xen? The repo URL
and the branch name are in the blurb.

Thanks!
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 08/15] MdeModulePkg Variable: Add emulated variable NV mode support

2019-01-15 Thread Laszlo Ersek
On 01/14/19 16:19, Star Zeng wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> Add emulated variable NV mode support in real variable driver.
> Platform can configure PcdEmuVariableNvModeEnable statically
> (build time) or dynamically (boot time) to support emulated
> variable NV mode.
> 
> Then EmuVariableRuntimeDxe could be removed, the removal of
> EmuVariableRuntimeDxe will be done after platforms are migrated
> to use the merged variable driver.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  .../Universal/Variable/RuntimeDxe/Variable.c   | 318 
> +++--
>  .../Universal/Variable/RuntimeDxe/Variable.h   |   1 +
>  .../Universal/Variable/RuntimeDxe/VariableDxe.c|  27 +-
>  .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |   4 +-
>  .../Universal/Variable/RuntimeDxe/VariableSmm.c|  29 +-
>  .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |   4 +-
>  6 files changed, 271 insertions(+), 112 deletions(-)

Acked-by: Laszlo Ersek 

(I think that this work and Ard's standalone MM refactoring will
conflict. If that's the case then I guess one of the patch sets should
be rebased. I seem to recall that this was already discussed on the list.)

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] BaseTools:The BuildOptionPcd value is wrong

2019-01-15 Thread Fan, ZhijuX
In GenFds.py, Due to the second assignment, the value is wrong
Its value should a list, not a string.and this line is not required

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/GenFds/GenFds.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/BaseTools/Source/Python/GenFds/GenFds.py 
b/BaseTools/Source/Python/GenFds/GenFds.py
index 77383d3378..2baee570ed 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -192,7 +192,6 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None):
 else:
 EdkLogger.error("GenFds", OPTION_MISSING, "Missing active 
platform")
 
-GlobalData.BuildOptionPcd = FdsCommandDict.get("OptionPcd") if 
FdsCommandDict.get("OptionPcd") else {}
 GenFdsGlobalVariable.ActivePlatform = 
PathClass(NormPath(ActivePlatform))
 
 if FdsCommandDict.get("conf_directory"):
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] BaseTools:build break if the Path contains SingleFile.Ext

2019-01-15 Thread Fan, ZhijuX
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1325

if SingleFile.Path = "/foo/bar.Sap/yada/source.S" and 
SingleFile.Ext = ".S". Then key would end up "/foo/bar"
instead of "/foo/bar.Sap/yada/source" as intended.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 1aa4a5ca5f..4bffb95ce6 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -3012,7 +3012,7 @@ class ModuleAutoGen(AutoGen):
 self.BuildOption
 for SingleFile in FileList:
 if self.BuildRuleOrder and SingleFile.Ext in self.BuildRuleOrder 
and SingleFile.Ext in self.BuildRules:
-key = SingleFile.Path.split(SingleFile.Ext)[0]
+key = SingleFile.Path.rsplit(SingleFile.Ext,1)[0]
 if key in Order_Dict:
 Order_Dict[key].append(SingleFile.Ext)
 else:
-- 
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V2] BaseTools:Build fail when PCD use in the [DEPEX] section of INF files

2019-01-15 Thread Fan, ZhijuX
Update _FixedPcdVoidTypeDict to FixedVoidTypePcds
'_FixedPcdVoidTypeDict' no longer exists because edk2 version (b23414f6).
'ModuleAutoGen' object has no attribute '_FixedPcdVoidTypeDict'.
Build fail when PCD use in the [DEPEX] section of INF files

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index cfe2d29099..5149bdd6ec 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2779,10 +2779,10 @@ class ModuleAutoGen(AutoGen):
 if '.' not in item:
 NewList.append(item)
 else:
-if item not in self._FixedPcdVoidTypeDict:
+if item not in self.FixedVoidTypePcds:
 EdkLogger.error("build", FORMAT_INVALID, "{} used 
in [Depex] section should be used as FixedAtBuild type and VOID* datum type in 
the module.".format(item))
 else:
-Value = self._FixedPcdVoidTypeDict[item]
+Value = self.FixedVoidTypePcds[item]
 if len(Value.split(',')) != 16:
 EdkLogger.error("build", FORMAT_INVALID,
 "{} used in [Depex] section 
should be used as FixedAtBuild type and VOID* datum type and 16 bytes in the 
module.".format(item))
-- 
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers

2019-01-15 Thread Wang, Jian J
Ard,

For patch 1,5,6,7,8,12,13,14,15,16,17

Reviewed-by: Jian J Wang 


> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Monday, January 14, 2019 9:28 PM
> To: edk2-devel@lists.01.org
> Cc: Ard Biesheuvel ; Laszlo Ersek
> ; Leif Lindholm ; Kinney,
> Michael D ; Gao, Liming ;
> Wang, Jian J ; Wu, Hao A ;
> Jagadeesh Ujja ; Achin Gupta
> ; Thomas Panakamattam Abraham
> ; Sami Mujawar ;
> Zeng, Star 
> Subject: [PATCH v2 00/17] implement standalone MM versions of the variable
> runtime drivers
> 
> This v2 series is a followup to [0], and updates the SMM implementations of
> the fault tolerant write and variable runtime drivers to provide standalone
> MM versions that share as much of the existing code as possible with the
> traditional SMM implementations.
> 
> The meat is in patches #5 - #8, which were part of v1. I updated them 
> according
> to the received feedback, and added tags that were given on list.
> 
> Patches #1 - #4 add library class resolutions for MmServiceTableLib, which was
> introduced in v1 of the series, and has already been merged (at the request of
> Liming) so that downstream platforms can add the resolution as well.
> 
> The remaining patches #9 - #17 are new, and have been added so that the new
> standalone MM drivers can be added to and built from MdeModulePkg.dsc, but
> for coverage only (the resulting binaries won't actually work)
> - patches #9 and #10 add a definition and implementation of
>   StandaloneMmDriverEntryPoint, which is rather straight-forward and has no
>   dependencies on the standalone MM core, so it is reasonable to add it to
>   MdePkg directly. Note that this version contains the _gMmVersion check that
>   is missing from the one in StandaloneMmPkg
> - patch #11 adds a standalone MM implementation of MmServicesTableLib to
> MdePkg,
>   which -again- does not depend on the standalone MM core at all, so added
> here
>   for simplicity
> - patches #12 and #13 add NULL implementations of MemoryAllocationLib and
> HobLib
>   so that the FTW and variable MM_STANDALONE modules can be built without
>   depending on StandaloneMmPkg
> - patch #14 is an unrelated fix so that MdeModulePkg.dsc can be built for
>   AARCH64
> - patches #15 and #16 add MM_STANDALONE support to a couple of libraries
> that
>   the new modules depend on
> - patch #17 adds the FTW and variable standalone MM drivers to
> MdeModulePkg.dsc
> 
> NOTE: the drivers added in patches #10 and #11 supersede the ones that reside
> in
> or have been proposed for StandaloneMmPkg
> 
> Patches can be found here:
> https://github.com/ardbiesheuvel/edk2/tree/variable-ftw-standalone-mm-
> conversion
> 
> Cc: Laszlo Ersek 
> Cc: Leif Lindholm 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Jagadeesh Ujja 
> Cc: Achin Gupta 
> Cc: Thomas Panakamattam Abraham 
> Cc: Sami Mujawar 
> Cc: Star Zeng 
> 
> [0] https://lists.01.org/pipermail/edk2-devel/2019-January/034608.html
> 
> Ard Biesheuvel (17):
>   MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution
>   OvmfPkg: add MmServicesTableLib resolution
>   QuarkPlatformPkg: add MmServicesTableLib resolution
>   Vlv2TbltDevicePkg: add MmServicesTableLib resolution
>   MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
>   MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
>   MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
>   MdeModulePkg/VariableRuntimeDxe: implement standalone MM version
>   MdePkg: introduce standalone MM entry point library class
>   MdePkg: introduce standalone MM entry point library implementation
>   MdePkg: add MM_STANDALONE implementation of MmServicesTableLib
>   MdeModulePkg: implement NULL instance of HobLib library class
>   MdeModulePkg: implement NULL instance of MemoryAllocationLib library
> class
>   MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only
> section
>   MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support
>   MdeModulePkg/VarCheckLib: add MM_STANDALONE support
>   MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable
> modules
> 
>  MdePkg/MdePkg.dec
>   |   3 +
>  MdeModulePkg/MdeModulePkg.dsc
> |  12 +-
>  MdePkg/MdePkg.dsc
>   |   3 +
>  OvmfPkg/OvmfPkgIa32.dsc  
>   |   1
> +
>  OvmfPkg/OvmfPkgIa32X64.dsc   
>   |
> 1 +
>  OvmfPkg/OvmfPkgX64.dsc   
>   |   1
> +
>  QuarkPlatformPkg/Quark.dsc   
>   |   1
> +
>  QuarkPlatformPkg/QuarkMin.dsc  

[edk2] [PATCH v2 3/5] ArmVirtPkg: drop reference to ArmPkg/DefaultExceptionHandlerLibBase

2019-01-15 Thread Ard Biesheuvel
Drop the reference to ArmPkg/DefaultExceptionHandlerLibBase, which
is no longer used anywhere now that DebugAgentSymbolsBaseLib no
longer incorporates a vector table and exception handling.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
---
 ArmVirtPkg/ArmVirt.dsc.inc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 89c2db074711..c47955be940c 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -174,7 +174,6 @@ [LibraryClasses.common.SEC]
   BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
 
   
DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
-  
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
   
SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
-- 
2.17.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 5/5] ArmPkg/DefaultExceptionHandlerLib: use console if available

2019-01-15 Thread Ard Biesheuvel
Print the minimal 'exception occurred' message to the console instead
of straight to the serial port if the console is available. This makes
such messages visible on systems where the console is graphical and
the serial is not connected.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
---
 ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 
12 ++--
 ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c |  
7 ++-
 ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf|  
1 +
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git 
a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c 
b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
index 1024bf48c63d..362acd5ba6d2 100644
--- 
a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
+++ 
b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -159,14 +160,21 @@ DefaultExceptionHandler (
   INT32  Offset;
 
   if (mRecursiveException) {
-CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive exception 
occurred while dumping the CPU state\n");
-SerialPortWrite ((UINT8 *) Buffer, CharCount);
+STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while 
dumping the CPU state\n";
+
+SerialPortWrite ((UINT8 *)Message, AsciiStrLen (Message));
+if (gST->ConOut != NULL) {
+  AsciiPrint (Message);
+}
 CpuDeadLoop ();
   }
   mRecursiveException = TRUE;
 
   CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 
0x%016lx\n", gExceptionTypeString[ExceptionType], 
SystemContext.SystemContextAArch64->ELR);
   SerialPortWrite ((UINT8 *) Buffer, CharCount);
+  if (gST->ConOut != NULL) {
+AsciiPrint (Buffer);
+  }
 
   DEBUG_CODE_BEGIN ();
 CHAR8  *Pdb, *PrevPdb;
diff --git 
a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c 
b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
index cc79cb2fa301..a79f73725aed 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -194,7 +195,11 @@ DefaultExceptionHandler (
 
   CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x 
 CPSR 0x%08x ",
  gExceptionTypeString[ExceptionType], 
SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);
-  SerialPortWrite ((UINT8 *) Buffer, CharCount);
+  if (gST->ConOut != NULL) {
+AsciiPrint (Buffer);
+  } else {
+SerialPortWrite ((UINT8 *)Buffer, CharCount);
+  }
 
   DEBUG_CODE_BEGIN ();
 CHAR8   *Pdb;
diff --git 
a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf 
b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
index 7609f82d89a1..6bc48714c9dc 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
@@ -42,6 +42,7 @@ [LibraryClasses]
   PeCoffGetEntryPointLib
   ArmDisassemblerLib
   SerialPortLib
+  UefiBootServicesTableLib
 
 [Guids]
   gEfiDebugImageInfoTableGuid
-- 
2.17.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 4/5] ArmPkg/DefaultExceptionHandlerLib: drop BASE variant

2019-01-15 Thread Ard Biesheuvel
Drop the redundant BASE variant, which is no longer used anywhere
now that DebugAgentSymbolsBaseLib no longer incorporates a vector
table and exception handling.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
---
 ArmPkg/ArmPkg.dsc| 
 1 -
 ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerBase.c  | 
35 ---
 ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf | 
45 
 3 files changed, 81 deletions(-)

diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index 5d83c18b143e..d9f9935d70b6 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -141,7 +141,6 @@ [Components.common]
   ArmPkg/Library/ArmGicArchSecLib/ArmGicArchSecLib.inf
   ArmPkg/Library/ArmLib/ArmBaseLib.inf
   ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
-  ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
   ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
   ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
 
diff --git 
a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerBase.c 
b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerBase.c
deleted file mode 100644
index 4a54298b1189..
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerBase.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/** @file
-
-  Copyright (c) 2012, ARM Ltd. All rights reserved.
-
-  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
-  http://opensource.org/licenses/bsd-license.php
-
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include 
-
-/**
-
-  @param  FaultAddress Address to find PE/COFF image for.
-  @param  ImageBaseReturn load address of found image
-  @param  PeCoffSizeOfHeaders  Return the size of the PE/COFF header for the 
image that was found
-
-  @retval NULL FaultAddress not in a loaded PE/COFF image.
-  @retval  Path and file name of PE/COFF image.
-
-**/
-CHAR8 *
-GetImageName (
-  IN  UINTN  FaultAddress,
-  OUT UINTN  *ImageBase,
-  OUT UINTN  *PeCoffSizeOfHeaders
-  )
-{
-  return NULL;
-}
diff --git 
a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf 
b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
deleted file mode 100644
index b53a5e89f507..
--- 
a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
+++ /dev/null
@@ -1,45 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2012, ARM Ltd. All rights reserved.
-#
-#  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
-#  http://opensource.org/licenses/bsd-license.php
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
-#
-#
-#**/
-
-[Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = DefaultExceptionHandlerBaseLib
-  FILE_GUID  = 3d5261d5-5eb7-4559-98e7-475aa9d0dc42
-  MODULE_TYPE= BASE
-  VERSION_STRING = 1.0
-  LIBRARY_CLASS  = DefaultExceptionHandlerLib
-
-[Sources.common]
-  DefaultExceptionHandlerBase.c
-
-[Sources.ARM]
-  Arm/DefaultExceptionHandler.c
-
-[Sources.AARCH64]
-  AArch64/DefaultExceptionHandler.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  ArmPkg/ArmPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  PrintLib
-  DebugLib
-  PeCoffGetEntryPointLib
-  ArmDisassemblerLib
-  SerialPortLib
-
-[Guids]
-  gEfiDebugImageInfoTableGuid
-- 
2.17.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 2/5] ArmPkg/DefaultExceptionHandlerLib: declare the permitted usage context

2019-01-15 Thread Ard Biesheuvel
Declare that this library is only usable in the context of DXE core
or a DXE driver. Set the MODULE_TYPE to BASE: this only affects the
prototype of the constructor (if present) but doesn't actually
restrict the usage context otherwise.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
---
 ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf | 4 
++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf 
b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
index f5421b1240a1..7609f82d89a1 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
@@ -17,9 +17,9 @@ [Defines]
   INF_VERSION= 0x00010005
   BASE_NAME  = DefaultExceptionHandlerLib
   FILE_GUID  = EACDB354-DF1A-4AF9-A171-499737ED818F
-  MODULE_TYPE= UEFI_DRIVER
+  MODULE_TYPE= BASE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = DefaultExceptionHandlerLib
+  LIBRARY_CLASS  = DefaultExceptionHandlerLib|DXE_CORE 
DXE_DRIVER
 
 [Sources.common]
   DefaultExceptionHandlerUefi.c
-- 
2.17.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 1/5] ArmPkg/DebugAgentSymbolsBaseLib: remove exception handling

2019-01-15 Thread Ard Biesheuvel
DebugAgentSymbolsBaseLib is an optional library that is in charge
of extracting debug headers from SEC and PEI_CORE images in memory
so the filename and the offset in memory can be reported via the
UART, allowing a developer to load debugging symbols into his
debugger.

Interestingly enough, DebugAgentSymbolsBaseLib is also in charge of
exception handling before this duty is taken over by either the PEI
core, or the CPU DXE driver when running under PrePi.

Since exceptions are not actually handled at all on AArch64, and simply
routed to the DefaultExceptionHandlerLib (for which a special version
has been created to be usable this early), let's get rid of this
dubious functionality altogether.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
---
 ArmPkg/Library/DebugAgentSymbolsBaseLib/AArch64/DebugAgentException.S |  96 
---
 ArmPkg/Library/DebugAgentSymbolsBaseLib/Arm/DebugAgentException.S | 277 

 ArmPkg/Library/DebugAgentSymbolsBaseLib/Arm/DebugAgentException.asm   | 273 
---
 ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.c|   7 -
 ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf  |   9 -
 5 files changed, 662 deletions(-)

diff --git 
a/ArmPkg/Library/DebugAgentSymbolsBaseLib/AArch64/DebugAgentException.S 
b/ArmPkg/Library/DebugAgentSymbolsBaseLib/AArch64/DebugAgentException.S
deleted file mode 100644
index f33a07a19bad..
--- a/ArmPkg/Library/DebugAgentSymbolsBaseLib/AArch64/DebugAgentException.S
+++ /dev/null
@@ -1,96 +0,0 @@
-#--
-#
-# Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
-#
-# 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
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#--
-
-#include 
-
-GCC_ASM_IMPORT(DefaultExceptionHandler)
-
-.text
-VECTOR_BASE(DebugAgentVectorTable)
-
-//
-// Current EL with SP0 : 0x0 - 0x180
-//
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_CUR_SP0_SYNC)
-ASM_PFX(SynchronousExceptionSP0):
-  b   ASM_PFX(SynchronousExceptionSP0)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_CUR_SP0_IRQ)
-ASM_PFX(IrqSP0):
-  b   ASM_PFX(IrqSP0)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_CUR_SP0_FIQ)
-ASM_PFX(FiqSP0):
-  b   ASM_PFX(FiqSP0)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_CUR_SP0_SERR)
-ASM_PFX(SErrorSP0):
-  b   ASM_PFX(SErrorSP0)
-
-//
-// Current EL with SPx: 0x200 - 0x380
-//
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_CUR_SPx_SYNC)
-ASM_PFX(SynchronousExceptionSPx):
-  b   ASM_PFX(SynchronousExceptionSPx)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_CUR_SPx_IRQ)
-ASM_PFX(IrqSPx):
-  b   ASM_PFX(IrqSPx)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_CUR_SPx_FIQ)
-ASM_PFX(FiqSPx):
-  b   ASM_PFX(FiqSPx)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_CUR_SPx_SERR)
-ASM_PFX(SErrorSPx):
-  b   ASM_PFX(SErrorSPx)
-
-/* Lower EL using AArch64 : 0x400 - 0x580 */
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_LOW_A64_SYNC)
-ASM_PFX(SynchronousExceptionA64):
-  b   ASM_PFX(SynchronousExceptionA64)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_LOW_A64_IRQ)
-ASM_PFX(IrqA64):
-  b   ASM_PFX(IrqA64)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_LOW_A64_FIQ)
-ASM_PFX(FiqA64):
-  b   ASM_PFX(FiqA64)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_LOW_A64_SERR)
-ASM_PFX(SErrorA64):
-  b   ASM_PFX(SErrorA64)
-
-//
-// Lower EL using AArch32 : 0x600 - 0x780
-//
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_LOW_A32_SYNC)
-ASM_PFX(SynchronousExceptionA32):
-  b   ASM_PFX(SynchronousExceptionA32)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_LOW_A32_IRQ)
-ASM_PFX(IrqA32):
-  b   ASM_PFX(IrqA32)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_LOW_A32_FIQ)
-ASM_PFX(FiqA32):
-  b   ASM_PFX(FiqA32)
-
-VECTOR_ENTRY(DebugAgentVectorTable, ARM_VECTOR_LOW_A32_SERR)
-ASM_PFX(SErrorA32):
-  b   ASM_PFX(SErrorA32)
-
-VECTOR_END(DebugAgentVectorTable)
diff --git a/ArmPkg/Library/DebugAgentSymbolsBaseLib/Arm/DebugAgentException.S 
b/ArmPkg/Library/DebugAgentSymbolsBaseLib/Arm/DebugAgentException.S
deleted file mode 100644
index 215181460803..
--- a/ArmPkg/Library/DebugAgentSymbolsBaseLib/Arm/DebugAgentException.S
+++ /dev/null
@@ -1,277 +0,0 @@
-#--
-#
-# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
-# Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.
-#
-# This program and the accompanying 

[edk2] [PATCH v2 0/5] ArmPkg: use console for minimal 'exception occurred' message

2019-01-15 Thread Ard Biesheuvel
When running with a graphical console, no message whatsoever is printed
when the systems hits an unexpected exception and hangs, because even
the minimal 'exception occurred' message is only sent to the serial port.

So let's fix that, by updating DefaultExceptionHandlerLib to take the
availability of a console into account. (#5)

This requires some preparatory decruftication so that we can safely refer
to the system table and console (#1 .. #4).

Changes since v1:
- split off ArmVirtPkg patch (#3)
- always send minimal error message to the serial port before attempting to
  send it to console->stdout as well (which is more likely to fail) (#5)
- add Leif's R-b to the series

Ard Biesheuvel (5):
  ArmPkg/DebugAgentSymbolsBaseLib: remove exception handling
  ArmPkg/DefaultExceptionHandlerLib: declare the permitted usage context
  ArmVirtPkg: drop reference to ArmPkg/DefaultExceptionHandlerLibBase
  ArmPkg/DefaultExceptionHandlerLib: drop BASE variant
  ArmPkg/DefaultExceptionHandlerLib: use console if available

 ArmPkg/ArmPkg.dsc |   1 -
 .../AArch64/DebugAgentException.S |  96 --
 .../Arm/DebugAgentException.S | 277 --
 .../Arm/DebugAgentException.asm   | 273 -
 .../DebugAgentSymbolsBaseLib.c|   7 -
 .../DebugAgentSymbolsBaseLib.inf  |   9 -
 .../AArch64/DefaultExceptionHandler.c |  12 +-
 .../Arm/DefaultExceptionHandler.c |   7 +-
 .../DefaultExceptionHandlerBase.c |  35 ---
 .../DefaultExceptionHandlerLib.inf|   5 +-
 .../DefaultExceptionHandlerLibBase.inf|  45 ---
 ArmVirtPkg/ArmVirt.dsc.inc|   1 -
 12 files changed, 19 insertions(+), 749 deletions(-)
 delete mode 100644 
ArmPkg/Library/DebugAgentSymbolsBaseLib/AArch64/DebugAgentException.S
 delete mode 100644 
ArmPkg/Library/DebugAgentSymbolsBaseLib/Arm/DebugAgentException.S
 delete mode 100644 
ArmPkg/Library/DebugAgentSymbolsBaseLib/Arm/DebugAgentException.asm
 delete mode 100644 
ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerBase.c
 delete mode 100644 
ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf

-- 
2.17.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 1/2] MdeModulePkg/NetLib.h: Fix the possible NULL pointer dereference issue.

2019-01-15 Thread Jiaxin Wu
v2: Fix the wrong condition in for cycle.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1456

For the NET_LIST_FOR_EACH & NET_LIST_FOR_EACH_SAFE, "Entry" should be
checked whether it's NULL or not instead of using the pointer directly.

Cc: Wu Hao A 
Cc: Gao Liming 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Include/Library/NetLib.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Include/Library/NetLib.h 
b/MdeModulePkg/Include/Library/NetLib.h
index 0977973921..c9a86733ec 100644
--- a/MdeModulePkg/Include/Library/NetLib.h
+++ b/MdeModulePkg/Include/Library/NetLib.h
@@ -616,21 +616,21 @@ NetRandomInitSeed (
 
 //
 // Iterate through the double linked list. It is NOT delete safe
 //
 #define NET_LIST_FOR_EACH(Entry, ListHead) \
-  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = 
Entry->ForwardLink)
+  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead) && Entry != NULL; 
Entry = Entry->ForwardLink)
 
 //
 // Iterate through the double linked list. This is delete-safe.
 // Don't touch NextEntry. Also, don't use this macro if list
 // entries other than the Entry may be deleted when processing
 // the current Entry.
 //
 #define NET_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
-  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink; \
-  Entry != (ListHead); \
+  for(Entry = (ListHead)->ForwardLink, (Entry != NULL) ? (NextEntry = 
Entry->ForwardLink) : (Entry = NULL); \
+  Entry != (ListHead) && Entry != NULL; \
   Entry = NextEntry, NextEntry = Entry->ForwardLink \
  )
 
 //
 // Make sure the list isn't empty before getting the first/last record.
-- 
2.17.1.windows.2

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MinPlatformPkg: Support TCO base locked by FSP

2019-01-15 Thread Chiu, Chasel


Good point! I will send another patch for this.

Thanks!
Chasel


> -Original Message-
> From: Kubacki, Michael A
> Sent: Tuesday, January 15, 2019 4:12 PM
> To: Chiu, Chasel ; edk2-devel@lists.01.org
> Cc: Desimone, Nathaniel L ; Zeng, Star
> 
> Subject: RE: [PATCH] MinPlatformPkg: Support TCO base locked by FSP
> 
> According to the function description, PchTcoBaseSet ( ) should ensure the
> following steps are done before returning success:
>   1. set Smbus PCI offset 54h [8] to enable TCO base address.
>   2. program Smbus PCI offset 50h [15:5] to TCO base address.
>   3. set Smbus PCI offset 54h [8] to enable TCO base address.
>   4. program "TCO Base Address" PCR[DMI] + 2778h[15:5, 1] to [Smbus PCI offset
> 50h[15:5], 1].
> 
> Currently the patch updates PchTcoBaseSet ( ) to return EFI_SUCCESS if it 
> finds
> the TCOCTL lock is already set, however, it doesn't test the other conditions 
> are
> met. This is different from returning EFI_SUCCESS if the lock is not already 
> set.
> The lock could have erroneously been set by HW/SW and this would return that
> the PCH TCO base address was successfully set when it may not be.
> 
> What about adding a PchTcoIsLocked () that checks if the lock is set and the 
> caller
> not call PchTcoBaseSet () if PchTcoIsLocked () returns true? Then 
> PchTcoBaseSet
> () can continue to return an error if it cannot update the base address.
> 
> Regards,
> Michael
> 
> > -Original Message-
> > From: Chiu, Chasel
> > Sent: Monday, January 14, 2019 8:15 PM
> > To: edk2-devel@lists.01.org
> > Cc: Desimone, Nathaniel L ; Zeng, Star
> > ; Kubacki, Michael A
> > 
> > Subject: RE: [PATCH] MinPlatformPkg: Support TCO base locked by FSP
> >
> >
> > + Michael to review this too.
> >
> > Thanks!
> > Chasel
> >
> >
> > > -Original Message-
> > > From: Chiu, Chasel
> > > Sent: Tuesday, January 15, 2019 12:07 PM
> > > To: edk2-devel@lists.01.org
> > > Cc: Desimone, Nathaniel L ; Zeng,
> > > Star ; Chiu, Chasel 
> > > Subject: [PATCH] MinPlatformPkg: Support TCO base locked by FSP
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1457
> > >
> > > Per security recommendation TCO Base should be initialized and
> > > locked by FSP and MinPlatform should support both TCO Base locked
> > > and not locked
> > scenarios.
> > >
> > > Cc: Nate DeSimone 
> > > Cc: Star Zeng 
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Chasel Chiu 
> > > ---
> > >
> > > Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodi
> > > ng Lib /PchCycleDecodingLib.c | 17 +
> > >  1 file changed, 9 insertions(+), 8 deletions(-)
> > >
> > > diff --git
> > > a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDeco
> > > di
> > > ngLi
> > > b/PchCycleDecodingLib.c
> > > b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDeco
> > > di
> > > ngL
> > > ib/PchCycleDecodingLib.c
> > > index 68b0b5dd4b..e135ef1f3e 100644
> > > ---
> > > a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDeco
> > > di
> > > ngLi
> > > b/PchCycleDecodingLib.c
> > > +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycle
> > > +++ De
> > > +++ co
> > > +++ dingLib/PchCycleDecodingLib.c
> > > @@ -1,7 +1,7 @@
> > >  /** @file
> > >PCH cycle deocding configuration and query library.
> > >
> > > -Copyright (c) 2017, Intel Corporation. All rights reserved.
> > > +Copyright (c) 2017 - 2019, Intel Corporation. All rights
> > > +reserved.
> > >  This program and the accompanying materials are licensed and made
> > > available under  the terms and conditions of the BSD License that
> > > accompanies this distribution.
> > >  The full text of the license may be found at @@ -352,17 +352,18 @@
> > > PchTcoBaseSet (
> > >}
> > >//
> > >// Verify TCO base is not locked.
> > > +  // If it is locked already, skip following steps.
> > >//
> > >if ((MmioRead8 (SmbusBase + R_PCH_SMBUS_TCOCTL) &
> > > B_PCH_SMBUS_TCOCTL_TCO_BASE_LOCK) != 0) {
> > > -ASSERT (FALSE);
> > > -return EFI_DEVICE_ERROR;
> > > +return EFI_SUCCESS;
> > >}
> > >//
> > >// Disable TCO in SMBUS Device first before changing base address.
> > > +  // Byte access to not touch the TCO_BASE_LOCK bit
> > >//
> > > -  MmioAnd16 (
> > > -SmbusBase + R_PCH_SMBUS_TCOCTL,
> > > -(UINT16) ~B_PCH_SMBUS_TCOCTL_TCO_BASE_EN
> > > +  MmioAnd8 (
> > > +SmbusBase + R_PCH_SMBUS_TCOCTL + 1,
> > > +(UINT8) ~(B_PCH_SMBUS_TCOCTL_TCO_BASE_EN >> 8)
> > >  );
> > >//
> > >// Program TCO in SMBUS Device
> > > @@ -373,11 +374,11 @@ PchTcoBaseSet (
> > >  Address
> > >  );
> > >//
> > > -  // Enable TCO in SMBUS Device
> > > +  // Enable TCO in SMBUS Device and lock TCO BASE
> > >//
> > >MmioOr16 (
> > >  SmbusBase + R_PCH_SMBUS_TCOCTL,
> > > -B_PCH_SMBUS_TCOCTL_TCO_BASE_EN
> > > +B_PCH_SMBUS_TCOCTL_TCO_BASE_EN |
> > > B_PCH_SMBUS_TCOCTL_TCO_BASE_LOCK
> > >   

Re: [edk2] [PATCH V2 07/15] MdeModulePkg Variable: type case VolatileBase to UINTN directly

2019-01-15 Thread Laszlo Ersek
On 01/14/19 16:19, Star Zeng wrote:
> Simplify
> ((UINTN) ((UINT8 *) VolatileBase + VolatileBase->Size))
> to
> ((UINTN) VolatileBase + VolatileBase->Size)
> 
> This patch prepares for adding emulated variable NV mode
> support in VariableRuntimeDxe.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> index 4d524db30fec..4c8e1d8cf4f1 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> @@ -301,7 +301,7 @@ UpdateVariableStore (
>DataPtr += mVariableModuleGlobal->VariableGlobal.VolatileVariableBase;
>  }
>  
> -if ((DataPtr + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + 
> VolatileBase->Size))) {
> +if ((DataPtr + DataSize) > ((UINTN) VolatileBase + VolatileBase->Size)) {
>return EFI_OUT_OF_RESOURCES;
>  }
>  
> 

Reviewed-by: Laszlo Ersek 

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 06/15] MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()

2019-01-15 Thread Laszlo Ersek
On 01/14/19 16:19, Star Zeng wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> CacheOffset could be removed in UpdateVariable() after
> //
> // update the memory copy of Flash region.
> //
> CopyMem (
>   (UINT8 *)mNvVariableCache + CacheOffset,
>   (UINT8 *)NextVariable, VarSize
>);
> 
> is moved to be before mVariableModuleGlobal->NonVolatileLastVariableOffset
> value is updated, like right before
> 
> mVariableModuleGlobal->NonVolatileLastVariableOffset +=
>   HEADER_ALIGN (VarSize);
> 
> This patch prepares for adding emulated variable NV mode
> support in VariableRuntimeDxe.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> index 424f92a53757..4d524db30fec 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> @@ -2139,7 +2139,6 @@ UpdateVariable (
>VARIABLE_POINTER_TRACK  *Variable;
>VARIABLE_POINTER_TRACK  NvVariable;
>VARIABLE_STORE_HEADER   *VariableStoreHeader;
> -  UINTN   CacheOffset;
>UINT8   *BufferForMerge;
>UINTN   MergedBufSize;
>BOOLEAN DataReady;
> @@ -2577,7 +2576,6 @@ UpdateVariable (
>  //
>  // Step 1:
>  //
> -CacheOffset = mVariableModuleGlobal->NonVolatileLastVariableOffset;
>  Status = UpdateVariableStore (
> >VariableGlobal,
> FALSE,
> @@ -2643,6 +2641,11 @@ UpdateVariable (
>goto Done;
>  }
>  
> +//
> +// update the memory copy of Flash region.
> +//
> +CopyMem ((UINT8 *)mNvVariableCache + 
> mVariableModuleGlobal->NonVolatileLastVariableOffset, (UINT8 *)NextVariable, 
> VarSize);
> +
>  mVariableModuleGlobal->NonVolatileLastVariableOffset += HEADER_ALIGN 
> (VarSize);
>  
>  if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
> @@ -2653,10 +2656,6 @@ UpdateVariable (
>  mVariableModuleGlobal->CommonUserVariableTotalSize += HEADER_ALIGN 
> (VarSize);
>}
>  }
> -//
> -// update the memory copy of Flash region.
> -//
> -CopyMem ((UINT8 *)mNvVariableCache + CacheOffset, (UINT8 *)NextVariable, 
> VarSize);
>} else {
>  //
>  // Create a volatile variable.
> 

Reviewed-by: Laszlo Ersek 

Thanks!
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MinPlatformPkg: Support TCO base locked by FSP

2019-01-15 Thread Kubacki, Michael A
According to the function description, PchTcoBaseSet ( ) should ensure the 
following steps are done before returning success:
  1. set Smbus PCI offset 54h [8] to enable TCO base address.
  2. program Smbus PCI offset 50h [15:5] to TCO base address.
  3. set Smbus PCI offset 54h [8] to enable TCO base address.
  4. program "TCO Base Address" PCR[DMI] + 2778h[15:5, 1] to [Smbus PCI offset 
50h[15:5], 1].

Currently the patch updates PchTcoBaseSet ( ) to return EFI_SUCCESS if it finds 
the TCOCTL lock is already set, however, it doesn't test the other conditions 
are met. This is different from returning EFI_SUCCESS if the lock is not 
already set. The lock could have erroneously been set by HW/SW and this would 
return that the PCH TCO base address was successfully set when it may not be.

What about adding a PchTcoIsLocked () that checks if the lock is set and the 
caller not call PchTcoBaseSet () if PchTcoIsLocked () returns true? Then 
PchTcoBaseSet () can continue to return an error if it cannot update the base 
address. 

Regards,
Michael

> -Original Message-
> From: Chiu, Chasel
> Sent: Monday, January 14, 2019 8:15 PM
> To: edk2-devel@lists.01.org
> Cc: Desimone, Nathaniel L ; Zeng, Star
> ; Kubacki, Michael A 
> Subject: RE: [PATCH] MinPlatformPkg: Support TCO base locked by FSP
> 
> 
> + Michael to review this too.
> 
> Thanks!
> Chasel
> 
> 
> > -Original Message-
> > From: Chiu, Chasel
> > Sent: Tuesday, January 15, 2019 12:07 PM
> > To: edk2-devel@lists.01.org
> > Cc: Desimone, Nathaniel L ; Zeng, Star
> > ; Chiu, Chasel 
> > Subject: [PATCH] MinPlatformPkg: Support TCO base locked by FSP
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1457
> >
> > Per security recommendation TCO Base should be initialized and locked
> > by FSP and MinPlatform should support both TCO Base locked and not locked
> scenarios.
> >
> > Cc: Nate DeSimone 
> > Cc: Star Zeng 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Chasel Chiu 
> > ---
> >
> > Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecoding
> > Lib /PchCycleDecodingLib.c | 17 +
> >  1 file changed, 9 insertions(+), 8 deletions(-)
> >
> > diff --git
> > a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodi
> > ngLi
> > b/PchCycleDecodingLib.c
> > b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodi
> > ngL
> > ib/PchCycleDecodingLib.c
> > index 68b0b5dd4b..e135ef1f3e 100644
> > ---
> > a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodi
> > ngLi
> > b/PchCycleDecodingLib.c
> > +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDe
> > +++ co
> > +++ dingLib/PchCycleDecodingLib.c
> > @@ -1,7 +1,7 @@
> >  /** @file
> >PCH cycle deocding configuration and query library.
> >
> > -Copyright (c) 2017, Intel Corporation. All rights reserved.
> > +Copyright (c) 2017 - 2019, Intel Corporation. All rights
> > +reserved.
> >  This program and the accompanying materials are licensed and made
> > available under  the terms and conditions of the BSD License that
> > accompanies this distribution.
> >  The full text of the license may be found at @@ -352,17 +352,18 @@
> > PchTcoBaseSet (
> >}
> >//
> >// Verify TCO base is not locked.
> > +  // If it is locked already, skip following steps.
> >//
> >if ((MmioRead8 (SmbusBase + R_PCH_SMBUS_TCOCTL) &
> > B_PCH_SMBUS_TCOCTL_TCO_BASE_LOCK) != 0) {
> > -ASSERT (FALSE);
> > -return EFI_DEVICE_ERROR;
> > +return EFI_SUCCESS;
> >}
> >//
> >// Disable TCO in SMBUS Device first before changing base address.
> > +  // Byte access to not touch the TCO_BASE_LOCK bit
> >//
> > -  MmioAnd16 (
> > -SmbusBase + R_PCH_SMBUS_TCOCTL,
> > -(UINT16) ~B_PCH_SMBUS_TCOCTL_TCO_BASE_EN
> > +  MmioAnd8 (
> > +SmbusBase + R_PCH_SMBUS_TCOCTL + 1,
> > +(UINT8) ~(B_PCH_SMBUS_TCOCTL_TCO_BASE_EN >> 8)
> >  );
> >//
> >// Program TCO in SMBUS Device
> > @@ -373,11 +374,11 @@ PchTcoBaseSet (
> >  Address
> >  );
> >//
> > -  // Enable TCO in SMBUS Device
> > +  // Enable TCO in SMBUS Device and lock TCO BASE
> >//
> >MmioOr16 (
> >  SmbusBase + R_PCH_SMBUS_TCOCTL,
> > -B_PCH_SMBUS_TCOCTL_TCO_BASE_EN
> > +B_PCH_SMBUS_TCOCTL_TCO_BASE_EN |
> > B_PCH_SMBUS_TCOCTL_TCO_BASE_LOCK
> >  );
> >//
> >// Program "TCO Base Address" PCR[DMI] + 2778h[15:5, 1] to [SMBUS
> > PCI offset 50h[15:5], 1].
> > --
> > 2.13.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 07/15] MdeModulePkg Variable: type case VolatileBase to UINTN directly

2019-01-15 Thread Wang, Jian J



Reviewed-by: Jian J Wang 


> -Original Message-
> From: Zeng, Star
> Sent: Monday, January 14, 2019 11:20 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J ;
> Wu, Hao A ; Laszlo Ersek 
> Subject: [PATCH V2 07/15] MdeModulePkg Variable: type case VolatileBase to
> UINTN directly
> 
> Simplify
> ((UINTN) ((UINT8 *) VolatileBase + VolatileBase->Size))
> to
> ((UINTN) VolatileBase + VolatileBase->Size)
> 
> This patch prepares for adding emulated variable NV mode
> support in VariableRuntimeDxe.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> index 4d524db30fec..4c8e1d8cf4f1 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> @@ -301,7 +301,7 @@ UpdateVariableStore (
>DataPtr += mVariableModuleGlobal->VariableGlobal.VolatileVariableBase;
>  }
> 
> -if ((DataPtr + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + 
> VolatileBase-
> >Size))) {
> +if ((DataPtr + DataSize) > ((UINTN) VolatileBase + VolatileBase->Size)) {
>return EFI_OUT_OF_RESOURCES;
>  }
> 
> --
> 2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 01/15] MdeModulePkg Variable: Add some missing changes for 9b18845

2019-01-15 Thread Laszlo Ersek
On 01/14/19 16:19, Star Zeng wrote:
> 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
> at the same away for performance optimization.

This commit message looks good to me; I have one suggestion only: please
consider replacing "at the same away" with just "the same way", when you
push the patch.

(I haven't checked anything else in this patch, so I think I shouldn't
respond with an A-b.)

Thank you!
Laszlo

> 
> 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 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c| 12 +---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c |  6 +++---
>  2 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> index 443cf07144a1..99d487adac9e 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> @@ -16,7 +16,7 @@
>VariableServiceSetVariable() should also check authenticate data to avoid 
> buffer overflow,
>integer overflow. It should also check attribute to avoid authentication 
> bypass.
>  
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>  (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -262,13 +262,12 @@ UpdateVariableStore (
>UINT8   *CurrBuffer;
>EFI_LBA LbaNumber;
>UINTN   Size;
> -  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
>VARIABLE_STORE_HEADER   *VolatileBase;
>EFI_PHYSICAL_ADDRESSFvVolHdr;
>EFI_PHYSICAL_ADDRESSDataPtr;
>EFI_STATUS  Status;
>  
> -  FwVolHeader = NULL;
> +  FvVolHdr= 0;
>DataPtr = DataPtrIndex;
>  
>//
> @@ -281,7 +280,6 @@ UpdateVariableStore (
>  Status = Fvb->GetPhysicalAddress(Fvb, );
>  ASSERT_EFI_ERROR (Status);
>  
> -FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvVolHdr);
>  //
>  // Data Pointer should point to the actual Address where data is to be
>  // written.
> @@ -290,7 +288,7 @@ UpdateVariableStore (
>DataPtr += 
> mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase;
>  }
>  
> -if ((DataPtr + DataSize) > ((EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) 
> FwVolHeader + FwVolHeader->FvLength))) {
> +if ((DataPtr + DataSize) > (FvVolHdr + mNvFvHeaderCache->FvLength)) {
>return EFI_OUT_OF_RESOURCES;
>  }
>} else {
> @@ -317,7 +315,7 @@ UpdateVariableStore (
>//
>// If we are here we are dealing with Non-Volatile Variables.
>//
> -  LinearOffset  = (UINTN) FwVolHeader;
> +  LinearOffset  = (UINTN) FvVolHdr;
>CurrWritePtr  = (UINTN) DataPtr;
>CurrWriteSize = DataSize;
>CurrBuffer= Buffer;
> @@ -2739,7 +2737,7 @@ UpdateVariable (
>}
>  }
>  
> -State = Variable->CurrPtr->State;
> +State = CacheVariable->CurrPtr->State;
>  State &= VAR_DELETED;
>  
>  Status = UpdateVariableStore (
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c 
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> index 23186176be75..f7185df3a7eb 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> @@ -3,7 +3,7 @@
>and volatile storage space and install variable architecture protocol.
>  
>  Copyright (C) 2013, Red Hat, Inc.
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>  (C) Copyright 2015 Hewlett Packard Enterprise Development LP
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -402,8 +402,8 @@ FtwNotificationEvent (
>//
>// Mark the variable storage region of the FLASH as RUNTIME.
>//
> -  VariableStoreBase   = NvStorageVariableBase + 
> (((EFI_FIRMWARE_VOLUME_HEADER 
> *)(UINTN)(NvStorageVariableBase))->HeaderLength);
> -  VariableStoreLength = ((VARIABLE_STORE_HEADER 
> *)(UINTN)VariableStoreBase)->Size;
> +  VariableStoreBase   = NvStorageVariableBase + 
> mNvFvHeaderCache->HeaderLength;
> +  VariableStoreLength = mNvVariableCache->Size;
>BaseAddress = VariableStoreBase & 

Re: [edk2] [PATCH V2 06/15] MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()

2019-01-15 Thread Wang, Jian J
Star,

Just a tiny comment below. With it's addressed, 

Reviewed-by: Jian J Wang 

> -Original Message-
> From: Zeng, Star
> Sent: Monday, January 14, 2019 11:20 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J ;
> Wu, Hao A ; Laszlo Ersek 
> Subject: [PATCH V2 06/15] MdeModulePkg Variable: Remove CacheOffset in
> UpdateVariable()
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> CacheOffset could be removed in UpdateVariable() after
> //
> // update the memory copy of Flash region.
> //
> CopyMem (
>   (UINT8 *)mNvVariableCache + CacheOffset,
>   (UINT8 *)NextVariable, VarSize
>);
> 
> is moved to be before mVariableModuleGlobal->NonVolatileLastVariableOffset
> value is updated, like right before
> 
> mVariableModuleGlobal->NonVolatileLastVariableOffset +=
>   HEADER_ALIGN (VarSize);
> 
> This patch prepares for adding emulated variable NV mode
> support in VariableRuntimeDxe.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> index 424f92a53757..4d524db30fec 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> @@ -2139,7 +2139,6 @@ UpdateVariable (
>VARIABLE_POINTER_TRACK  *Variable;
>VARIABLE_POINTER_TRACK  NvVariable;
>VARIABLE_STORE_HEADER   *VariableStoreHeader;
> -  UINTN   CacheOffset;
>UINT8   *BufferForMerge;
>UINTN   MergedBufSize;
>BOOLEAN DataReady;
> @@ -2577,7 +2576,6 @@ UpdateVariable (
>  //
>  // Step 1:
>  //
> -CacheOffset = mVariableModuleGlobal->NonVolatileLastVariableOffset;
>  Status = UpdateVariableStore (
> >VariableGlobal,
> FALSE,
> @@ -2643,6 +2641,11 @@ UpdateVariable (
>goto Done;
>  }
> 
> +//
> +// update the memory copy of Flash region.
> +//

The first character of comment is not capitalized.

> +CopyMem ((UINT8 *)mNvVariableCache + mVariableModuleGlobal-
> >NonVolatileLastVariableOffset, (UINT8 *)NextVariable, VarSize);
> +
>  mVariableModuleGlobal->NonVolatileLastVariableOffset += HEADER_ALIGN
> (VarSize);
> 
>  if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
> @@ -2653,10 +2656,6 @@ UpdateVariable (
>  mVariableModuleGlobal->CommonUserVariableTotalSize +=
> HEADER_ALIGN (VarSize);
>}
>  }
> -//
> -// update the memory copy of Flash region.
> -//
> -CopyMem ((UINT8 *)mNvVariableCache + CacheOffset, (UINT8
> *)NextVariable, VarSize);
>} else {
>  //
>  // Create a volatile variable.
> --
> 2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 04/15] MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm

2019-01-15 Thread Wang, Jian J



Reviewed-by: Jian J Wang 


> -Original Message-
> From: Zeng, Star
> Sent: Monday, January 14, 2019 11:20 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J ;
> Wu, Hao A 
> Subject: [PATCH V2 04/15] MdeModulePkg Variable: Abstract
> VariableWriteServiceInitializeDxe/Smm
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323
> Merge EmuVariable and Real variable driver.
> 
> Abstract VariableWriteServiceInitializeDxe/Smm from
> FtwNotificationEvent/SmmFtwNotificationEvent, then
> VariableWriteServiceInitializeDxe/Smm 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 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  .../Universal/Variable/RuntimeDxe/VariableDxe.c| 55 ++---
> -
>  .../Universal/Variable/RuntimeDxe/VariableSmm.c| 43 -
>  2 files changed, 66 insertions(+), 32 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> index baba6729c1c2..5131e6f351e4 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
> @@ -346,6 +346,40 @@ OnEndOfDxe (
>  }
> 
>  /**
> +  Initializes variable write service for DXE.
> +
> +**/
> +VOID
> +VariableWriteServiceInitializeDxe (
> +  VOID
> +  )
> +{
> +  EFI_STATUSStatus;
> +
> +  Status = VariableWriteServiceInitialize ();
> +  if (EFI_ERROR (Status)) {
> +DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. 
> Status
> = %r\n", Status));
> +  }
> +
> +  //
> +  // Some Secure Boot Policy Var (SecureBoot, etc) updates following other
> +  // Secure Boot Policy Variable change. Record their initial value.
> +  //
> +  RecordSecureBootPolicyVarData();
> +
> +  //
> +  // Install the Variable Write Architectural protocol.
> +  //
> +  Status = gBS->InstallProtocolInterface (
> +  ,
> +  ,
> +  EFI_NATIVE_INTERFACE,
> +  NULL
> +  );
> +  ASSERT_EFI_ERROR (Status);
> +}
> +
> +/**
>Fault Tolerant Write protocol notification event handler.
> 
>Non-Volatile variable write may needs FTW protocol to reclaim when
> @@ -428,27 +462,10 @@ FtwNotificationEvent (
>  }
>}
> 
> -  Status = VariableWriteServiceInitialize ();
> -  if (EFI_ERROR (Status)) {
> -DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. 
> Status
> = %r\n", Status));
> -  }
> -
>//
> -  // Some Secure Boot Policy Var (SecureBoot, etc) updates following other
> -  // Secure Boot Policy Variable change. Record their initial value.
> +  // Initializes variable write service after FTW was ready.
>//
> -  RecordSecureBootPolicyVarData();
> -
> -  //
> -  // Install the Variable Write Architectural protocol.
> -  //
> -  Status = gBS->InstallProtocolInterface (
> -  ,
> -  ,
> -  EFI_NATIVE_INTERFACE,
> -  NULL
> -  );
> -  ASSERT_EFI_ERROR (Status);
> +  VariableWriteServiceInitializeDxe ();
> 
>//
>// Close the notify event to avoid install 
> gEfiVariableWriteArchProtocolGuid
> again.
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> index 018587ed7373..e63af812534e 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> @@ -846,6 +846,34 @@ SmmEndOfDxeCallback (
>  }
> 
>  /**
> +  Initializes variable write service for SMM.
> +
> +**/
> +VOID
> +VariableWriteServiceInitializeSmm (
> +  VOID
> +  )
> +{
> +  EFI_STATUSStatus;
> +
> +  Status = VariableWriteServiceInitialize ();
> +  if (EFI_ERROR (Status)) {
> +DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. 
> Status
> = %r\n", Status));
> +  }
> +
> +  //
> +  // Notify the variable wrapper driver the variable write service is ready
> +  //
> +  Status = gBS->InstallProtocolInterface (
> +  ,
> +  ,
> +  EFI_NATIVE_INTERFACE,
> +  NULL
> +  );
> +  ASSERT_EFI_ERROR (Status);
> +}
> +
> +/**
>SMM Fault Tolerant Write protocol notification event handler.
> 
>Non-Volatile variable write may needs FTW protocol to reclaim when
> @@ -909,21 +937,10 @@ SmmFtwNotificationEvent (
> 
>mVariableModuleGlobal->FvbInstance = FvbProtocol;
> 
> -  Status = VariableWriteServiceInitialize ();
> -  if (EFI_ERROR (Status)) {
> -DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. 
> Status
> = %r\n", Status));
> -  }
> -
>//
> -  // Notify the variable wrapper driver the variable write service is ready
> +  // 

  1   2   >