Re: [edk2] [edk2-test][RFC] Integrating SBBR tests into SCT - A design proposal

2019-01-14 Thread Jin, Eric
Hi Sakar,

Thank for the clarification.
Now, I understand that the SBBR wants to add/modify in existing 
edk2-test/uefi-sct. In your description, '-s' is not suitable for sbbr purpose. 

The fundamental point to be discussed is that edk2-test/uefi-sct is UEFI Self 
Compliance Test and should keep the alignment to UEFI spec.
To my understanding, the SBBR is published by arm and gives special 
requirements on UEFI/ACPI/SMBIOS areas. 
I remember some new files/new directories with the prefix "sbbr" in 
file/directory name are adding into the edk2-test/uefi-sct In previous push 
request emails, it makes me confused. And it is the reason that I ask for the 
possible standalone space.

Could you please send the patches for review? We can discuss further based on 
them and explore the correct direction. At least, the baseline is it doesn't 
impact existing test result (I want to hear the comments from Supreeth on this 
baseline). 

Best Regards
Eric

-Original Message-
From: Sakar Arora  
Sent: Friday, January 11, 2019 8:23 PM
To: Jin, Eric ; Supreeth Venkatesh 
; edk2-devel@lists.01.org
Cc: Prasanth Pulla 
Subject: RE: [edk2][edk2-test][RFC] Integrating SBBR tests into SCT - A design 
proposal

Hi Supreeth, Eric,

My replies inlined.

Thanks,
Sakar
-Original Message-
From: Jin, Eric 
Sent: Tuesday, January 8, 2019 7:30 AM
To: Supreeth Venkatesh ; Sakar Arora 
; edk2-devel@lists.01.org
Cc: Prasanth Pulla 
Subject: RE: [edk2][edk2-test][RFC] Integrating SBBR tests into SCT - A design 
proposal

Hello Sakar,

SBBR spec is not published by UEFI Forum and can be considered as a supplement 
to ARM UEFI. The evolution of edk2-test/uefi-sct should be tagged to UEFI Spec 
only.
Can we land SBBR test on standalone space under edk2-test currently or in 
short-term?  I mean SBBR test can leverage edk2-test/uefi-sct (as sub-module)or 
not to build test efi files itself and these test efi files can be integrated 
into UEFI SCT to execute with user usage.

[Sakar] If I understand correctly, you want a separate directory in edk2-test 
for SBBR code, rather than having it in edk2-test/uefi-sct.
The problem I see here is that apart from standalone SBBR test cases, there are 
some changes to the existing test cases inside edk2-test/uefi-sct, that we 
would need pushed for SBBR compliance (These changes will only take effect if 
"-sbbr" parameter is passed while running SCT). So SBBR tests are not exactly 
standalone. Keeping all SBBR specific stuff away, would mean maintaining 
patches to SCT code, which will be difficult. I hope I am making sense.

For the new attributes - SBBR and SBBR_EXCL, I agree with Supreeth that they 
are more like the additional parameters. So they are not the similar cases to 
(AUTO, MANUAL, DESTRUCTIVE, or RESET_REQUIRED).

[Sakar] The reasoning for proposing these 2 attributes is this.
There are some SBBR tests that are needed only for SBBR compliance. When SCT 
app is run *without* the "-sbbr" cmdline parameter, it should run all tests, 
excluding those specific to SBBR. So it needs to differentiate, at runtime, 
tests that are valid for both SBBR and UEFI compliance from the ones that are 
exclusively for SBBR. Tests with attribute SBBR are meant to run for both UEFI 
and SBBR compliance, while those with attribute SBBR_EXCL are only meant for 
SBBR compliance.

If the intention is to distinguish SBBR test from existing test, It can be 
implemented with "-s" parameter plus the SBBR test sequence easily.

[Sakar] Using the "-s" parameter with test sequence file is an option I 
explored a bit.
It doesn't seem to offer control over what sub-tests to run within a test 
scenario,  which is something we want while adding SBBR support in SCT. For 
example, there are some sub-tests that need to be removed from some main tests, 
for SBBR compliance. As far as I understand, sequence file does not provide 
that level of control. Please correct me if I am missing something.

Above is my quick response and I will continue to consider it these days and 
look at SBBR spec.  Any input is welcome.

Best Regards
Eric
-Original Message-
From: Supreeth Venkatesh 
Sent: Tuesday, January 8, 2019 4:14 AM
To: Sakar Arora ; edk2-devel@lists.01.org; Jin, Eric 

Cc: Prasanth Pulla 
Subject: RE: [edk2][edk2-test][RFC] Integrating SBBR tests into SCT - A design 
proposal

Sakar,

Looks good.
However, Why do we need two  additional parameters SBBR and SBBR_EXCL?

Since SBBR is a subset/superset of UEFI specifications, would "sbbr_standalone" 
or similar (just sbbr) which would run all the sbbr tests including ones that 
is already part of UEFI-SCT Suffice?

Lets wait for additional comments from Eric.

Thanks,
Supreeth

-Original Message-
From: Sakar Arora 
Sent: Monday, December 31, 2018 12:50 AM
To: edk2-devel@lists.01.org; eric@intel.com; Supreeth Venkatesh 

Cc: Prasanth Pulla 
Subject: [edk2][edk2-test][RFC] Integrating SBBR tests into SCT - A design 
proposal

Hi All,

Introduction -->


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

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

Best Regards,
Hao Wu


> -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.
> +//
> +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 05/15] MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec

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

Best Regards,
Hao Wu


> -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 05/15] MdeModulePkg: Add
> PcdEmuVariableNvModeEnable in dec
> 
> 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 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 10 --
>  MdeModulePkg/MdeModulePkg.uni | 10 --
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 217ede1f7163..8fbc0af61365 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,13 @@ [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.
> +  #   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|U
> INT64|0x4008
> diff --git a/MdeModulePkg/MdeModulePkg.uni
> b/MdeModulePkg/MdeModulePkg.uni
> index 35af744d89be..9c413a98f65d 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,15 @@
> 
>  #string
> STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBa
> se64_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."
> + 
>  "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 PCD 

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

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

Best Regards,
Hao Wu


> -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 04/15] MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm

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

Best Regards,
Hao Wu


> -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
> +  // 

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

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

Best Regards,
Hao Wu


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Star Zeng
> Sent: Monday, January 14, 2019 11:20 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A; Zeng, Star
> Subject: [edk2] [PATCH V2 01/15] MdeModulePkg Variable: Add some
> missing changes for 9b18845
> 
> 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.
> 
> 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 = 

Re: [edk2] [PATCH V2 02/15] MdeModulePkg Variable: Abstract InitRealNonVolatileVariableStore

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

Best Regards,
Hao Wu


> -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 02/15] MdeModulePkg Variable: Abstract
> InitRealNonVolatileVariableStore
> 
> 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 
> ---
>  .../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 

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

2019-01-14 Thread Wang, Jian J
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 

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

2019-01-14 Thread Marcin Wojtas
Hi Leif,


wt., 15 sty 2019 o 00:32 Leif Lindholm  napisał(a):
>
> On Thu, Jan 10, 2019 at 02:44:35AM +0100, Marcin Wojtas wrote:
> > Marvell Armada 7k/8k SoCs comprise integrated GPIO controllers,
> > one in AP806 and two in each south bridge hardware blocks.
> >
> > This patch introduces support for them. The new driver implements
> > a generic EMBEDDED_GPIO protocol.
> >
> > In order to ease description of used GPIO pins and controllers
> > of the Armada 7k8k platforms, add a common enum type.
> >
> > Based on original work of Jing Hua .
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Marcin Wojtas 
> > ---
> >  Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf |  44 +++
> >  Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h   |  49 +++
> >  Silicon/Marvell/Include/Protocol/MvGpio.h|  10 +
> >  Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c   | 372 
> > 
> >  4 files changed, 475 insertions(+)
> >  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
> >  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
> >  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c
> >
> > diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf 
> > b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
> > new file mode 100644
> > index 000..5ff9130
> > --- /dev/null
> > +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
> > @@ -0,0 +1,44 @@
> > +## @file
> > +#
> > +#  Copyright (c) 2017, Marvell International 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= 0x0001001A
> > +  BASE_NAME  = MvGpioDxe
> > +  FILE_GUID  = 706eb761-b3b5-4f41-8558-5fd9217c0079
> > +  MODULE_TYPE= DXE_DRIVER
> > +  VERSION_STRING = 1.0
> > +  ENTRY_POINT= MvGpioEntryPoint
> > +
> > +[Sources]
> > +  MvGpioDxe.c
> > +  MvGpioDxe.h
> > +
> > +[Packages]
> > +  EmbeddedPkg/EmbeddedPkg.dec
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  MdePkg/MdePkg.dec
> > +  Silicon/Marvell/Marvell.dec
> > +
> > +[LibraryClasses]
> > +  ArmadaSoCDescLib
> > +  DebugLib
> > +  MemoryAllocationLib
> > +  UefiDriverEntryPoint
> > +  UefiLib
> > +
> > +[Protocols]
> > +  gEmbeddedGpioProtocolGuid
> > +  gMarvellBoardDescProtocolGuid
> > +
> > +[Depex]
> > +  TRUE
> > diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h 
> > b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
> > new file mode 100644
> > index 000..4e5422b
> > --- /dev/null
> > +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
> > @@ -0,0 +1,49 @@
> > +/**
> > +*
> > +*  Copyright (c) 2018, Marvell International 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.
> > +*
> > +**/
> > +#ifndef __MV_GPIO_H__
> > +#define __MV_GPIO_H__
> > +
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#define MV_GPIO_SIGNATURESIGNATURE_32 ('G', 'P', 'I', 'O')
>
> Unaddressed feedback from last time. But rereading it makes it clear
> my feedback was too imprecise, apologies. The point was that "GPIO" is
> not a very good choice of key to distinguish _this_ GPIO driver from
> other GPIO drivers. (As well as the MV_ prefix.)
>

Sure, I will modify it to be more specific signature.

> One more comment below, but it does not require code changes.
> If you can just change the signature, I'm happy with this patch.
>
> > +
> > +// Marvell MV_GPIO Controller Registers
> > +#define MV_GPIO_DATA_OUT_REG (0x0)
> > +#define MV_GPIO_OUT_EN_REG   (0x4)
> > +#define MV_GPIO_BLINK_EN_REG (0x8)
> > +#define MV_GPIO_DATA_IN_POL_REG  (0xc)
> > +#define MV_GPIO_DATA_IN_REG  (0x10)
> > +
> > +typedef struct {
> > +  EMBEDDED_GPIO GpioProtocol;
> > +  GPIO_CONTROLLER  *SoCGpio;
> > +  UINTN GpioDeviceCount;
> > +  UINTN Signature;
> > + 

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

2019-01-14 Thread Zeng, Star

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

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.



It would be better to mention, although it could be dynamically
configured, it's just a one-shot action before this driver is loaded,
just in case of any misunderstanding.


Yes, I can add more description for PcdEmuVariableNvModeEnable and in 
this commit message. :)





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(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 4c8e1d8cf4f1..845276d891ae 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.
+  //
+  

Re: [edk2] [platforms: PATCH v2 07/12] Marvell/Protocol: Introduce GPIO helper header

2019-01-14 Thread Marcin Wojtas
Hi Leif,

wt., 15 sty 2019 o 00:12 Leif Lindholm  napisał(a):
>
> On Thu, Jan 10, 2019 at 02:44:34AM +0100, Marcin Wojtas wrote:
> > From: jinghua 
> >
> > This patch introduces a helper header that can be used by
> > multiple EMBEDDED_GPIO protocol producers (e.g. platform
> > driver or GPIO expanders). The drives are differentiated by
> > MV_GPIO_DRIVER_TYPE field of driver's MV_GPIO_DEVICE_PATH.
> >
> > In order to ease selection of the desired GPIO controller
> > a helper function was added - MarvellGpioGetProtocol().
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Marcin Wojtas 
> > ---
> >  Silicon/Marvell/Include/Protocol/MvGpio.h | 156 
> >  1 file changed, 156 insertions(+)
> >  create mode 100644 Silicon/Marvell/Include/Protocol/MvGpio.h
> >
> > diff --git a/Silicon/Marvell/Include/Protocol/MvGpio.h 
> > b/Silicon/Marvell/Include/Protocol/MvGpio.h
> > new file mode 100644
> > index 000..c9f1007
> > --- /dev/null
> > +++ b/Silicon/Marvell/Include/Protocol/MvGpio.h
> > @@ -0,0 +1,156 @@
> > +/**
> > +*
> > +*  Copyright (C) 2018, Marvell International Ltd. and its affiliates.
> > +*
> > +*  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 __MV_GPIO_PROTOCOL_H__
> > +#define __MV_GPIO_PROTOCOL_H__
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +typedef enum {
> > +  MV_GPIO_DRIVER_TYPE_SOC_CONTROLLER,
> > +} MV_GPIO_DRIVER_TYPE;
> > +
> > +typedef struct {
> > +  VENDOR_DEVICE_PATHHeader;
> > +  MV_GPIO_DRIVER_TYPE   GpioDriverType;
> > +  EFI_DEVICE_PATH_PROTOCOL  End;
> > +} MV_GPIO_DEVICE_PATH;
> > +
> > +typedef struct {
> > +  UINTNControllerId;
> > +  UINTNPinNumber;
> > +  BOOLEAN  ActiveHigh;
> > +} MV_GPIO_PIN;
> > +
> > +/*
> > + * Check if the driver type matches the requested value.
> > + * In case of the success open the GPIO protocol and return.
> > + */
> > +STATIC
> > +inline
> > +EFI_STATUS
> > +EFIAPI
> > +MvGpioFindMatchingDriver (
>
> Eep!
> I missed this in v1 (I assumed I'd missed the new file indicator
> whilst scrolling) - please move these functions out of this .h file.
> https://edk2-docs.gitbooks.io/edk-ii-c-coding-standards-specification/content/v/release/2.20/5_source_files/53_include_files.html#537-include-files-shall-not-generate-code-or-define-data-variables
>
> This makes me take a closer look at the rest of the patch ... and this
> just isn't a protocol - it's a library. Please restrucure it as such
> and move the header file to Include/Library rather than
> Include/Protocol.
>

Initially it was a header for MvGpioProtocol + this inline C addition
at the end... I will change it to the library.

Thanks,
Marcin

> /
> Leif
>
> > +  IN MV_GPIO_DRIVER_TYPEGpioDriverType,
> > +  IN EFI_HANDLE HandleBuffer,
> > +  IN EFI_DEVICE_PATH   *DevicePath,
> > +  IN OUT EMBEDDED_GPIO**GpioProtocol
> > +  )
> > +{
> > +  MV_GPIO_DEVICE_PATH *GpioDevicePath;
> > +  EFI_STATUS   Status;
> > +
> > +  while (!IsDevicePathEndType (DevicePath)) {
> > +/* Check if GpioDriverType matches one found in the device path */
> > +GpioDevicePath = (MV_GPIO_DEVICE_PATH *)DevicePath;
> > +if (GpioDevicePath->GpioDriverType != GpioDriverType) {
> > +  DevicePath = NextDevicePathNode (DevicePath);
> > +  continue;
> > +}
> > +
> > +/*
> > + * Open GpioProtocol. With EFI_OPEN_PROTOCOL_GET_PROTOCOL attribute
> > + * the consumer is not obliged to call CloseProtocol.
> > + */
> > +Status = gBS->OpenProtocol (HandleBuffer,
> > +,
> > +(VOID **)GpioProtocol,
> > +gImageHandle,
> > +NULL,
> > +EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> > +return Status;
> > +  }
> > +
> > +  return EFI_NOT_FOUND;
> > +}
> > +
> > +/*
> > + * Select desired protocol producer upon MV_GPIO_DRIVER_TYPE
> > + * field of driver's MV_GPIO_DEVICE_PATH.
> > + */
> > +STATIC
> > +inline
> > +EFI_STATUS
> > +EFIAPI
> > +MvGpioGetProtocol (
> > +  IN MV_GPIO_DRIVER_TYPEGpioDriverType,
> > +  IN OUT EMBEDDED_GPIO**GpioProtocol
> > +  )
> > +{
> > +  EFI_DEVICE_PATH *DevicePath;
> > +  EFI_HANDLE  *HandleBuffer;
> > +  EFI_STATUS   Status;
> > +  UINTNHandleCount;
> > +  UINTNIndex;
> > +
> > +  /* Locate Handles of all EMBEDDED_GPIO producers */
> > +  Status = gBS->LocateHandleBuffer (ByProtocol,
> > 

Re: [edk2] [PATCH v3] IntelFsp2Pkg: Add FspmArchConfigPpi to support Dispatch mode

2019-01-14 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Chiu, Chasel 
Sent: Tuesday, January 15, 2019 2:03 PM
To: edk2-devel@lists.01.org
Cc: Desimone, Nathaniel L ; Zeng, Star 
; Chiu, Chasel 
Subject: [PATCH v3] IntelFsp2Pkg: Add FspmArchConfigPpi to support Dispatch mode

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

In Dispatch mode FSP may consume PPI directly so creating FSPM_ARCH_CONFIG_PPI 
to align with FSPM_ARCH_UPD.
Also Keeps new structure size 8 bytes alignment as other structures.

Test: Verified on internal platform to boot with this PPI installed 
successfully.

Cc: Nate DeSimone 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h | 54 
++
 IntelFsp2Pkg/IntelFsp2Pkg.dec|  3 +++
 2 files changed, 57 insertions(+)

diff --git a/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h 
b/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
new file mode 100644
index 00..5bedb95aa7
--- /dev/null
+++ b/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
@@ -0,0 +1,54 @@
+/** @file
+  Header file for FSP-M Arch Config PPI for Dispatch mode
+
+ @copyright
+  Copyright (c) 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  
+ 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 _FSPM_ARCH_CONFIG_PPI_H_
+#define _FSPM_ARCH_CONFIG_PPI_H_
+
+#define FSPM_ARCH_CONFIG_PPI_REVISION 0x1
+
+///
+/// Global ID for the FSPM_ARCH_CONFIG_PPI.
+///
+#define FSPM_ARCH_CONFIG_GUID \
+  { \
+0x824d5a3a, 0xaf92, 0x4c0c, { 0x9f, 0x19, 0x19, 0x52, 0x6d, 0xca, 
+0x4a, 0xbb } \
+  }
+
+///
+/// This PPI provides FSP-M Arch Config PPI.
+///
+typedef struct {
+  ///
+  /// Revision of the structure
+  ///
+  UINT8 Revision;
+  UINT8 Reserved[3];
+  ///
+  /// Pointer to the non-volatile storage (NVS) data buffer.
+  /// If it is NULL it indicates the NVS data is not available.
+  ///
+  VOID  *NvsBufferPtr;
+  ///
+  /// Size of memory to be reserved by FSP below "top
+  /// of low usable memory" for bootloader usage.
+  ///
+  UINT32BootLoaderTolumSize;
+  UINT8 Reserved1[4];
+} FSPM_ARCH_CONFIG_PPI;
+
+extern EFI_GUID gFspmArchConfigPpiGuid;
+
+#endif // _FSPM_ARCH_CONFIG_PPI_H_
diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dec b/IntelFsp2Pkg/IntelFsp2Pkg.dec 
index 50496241da..de1bece562 100644
--- a/IntelFsp2Pkg/IntelFsp2Pkg.dec
+++ b/IntelFsp2Pkg/IntelFsp2Pkg.dec
@@ -70,6 +70,9 @@
   gFspPerformanceDataGuid   = { 0x56ed21b6, 0xba23, 0x429e, { 
0x89, 0x32, 0x37, 0x6d, 0x8e, 0x18, 0x2e, 0xe3 } }
   gFspEventEndOfFirmwareGuid= { 0xbd44f629, 0xeae7, 0x4198, { 
0x87, 0xf1, 0x39, 0xfa, 0xb0, 0xfd, 0x71, 0x7e } }
 
+[Ppis]
+  gFspmArchConfigPpiGuid= { 0x824d5a3a, 0xaf92, 0x4c0c, { 
0x9f, 0x19, 0x19, 0x52, 0x6d, 0xca, 0x4a, 0xbb } }
+
 [PcdsFixedAtBuild]
   gIntelFsp2PkgTokenSpaceGuid.PcdGlobalDataPointerAddress 
|0xFED00108|UINT32|0x0001
   gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase 
|0xFEF0|UINT32|0x10001001
--
2.13.3.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-14 Thread Marcin Wojtas
Hi Leif,

pon., 14 sty 2019 o 23:58 Leif Lindholm  napisał(a):
>
> On Thu, Jan 10, 2019 at 02:44:33AM +0100, Marcin Wojtas wrote:
> > Introduce new callback that can provide information
> > about GPIO SoC controllers, as well as on-board
> > I2C IO expanders. According ArmadaSoCDescLib
> > ArmadaBoardDescLib routines are used for
> > obtaining required data.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Marcin Wojtas 
> > ---
> >  Silicon/Marvell/Include/Protocol/BoardDesc.h   |  8 
> >  Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 43 
> > 
> >  2 files changed, 51 insertions(+)
> >
> > diff --git a/Silicon/Marvell/Include/Protocol/BoardDesc.h 
> > b/Silicon/Marvell/Include/Protocol/BoardDesc.h
> > index 1d57a16..02905ea 100644
> > --- a/Silicon/Marvell/Include/Protocol/BoardDesc.h
> > +++ b/Silicon/Marvell/Include/Protocol/BoardDesc.h
> > @@ -50,6 +50,13 @@ EFI_STATUS
> >
> >  typedef
> >  EFI_STATUS
> > +(EFIAPI *MV_BOARD_GPIO_DESCRIPTION_GET) (
> > +  IN MARVELL_BOARD_DESC_PROTOCOL*This,
> > +  IN OUT MV_BOARD_GPIO_DESCRIPTION **GpioDescription
> > +  );
> > +
> > +typedef
> > +EFI_STATUS
> >  (EFIAPI *MV_BOARD_DESC_I2C_GET) (
> >IN MARVELL_BOARD_DESC_PROTOCOL  *This,
> >IN OUT MV_BOARD_I2C_DESC   **I2cDesc
> > @@ -113,6 +120,7 @@ struct _MARVELL_BOARD_DESC_PROTOCOL {
> >MV_BOARD_DESC_UTMI_GET BoardDescUtmiGet;
> >MV_BOARD_DESC_XHCI_GET BoardDescXhciGet;
> >MV_BOARD_DESC_FREE BoardDescFree;
> > +  MV_BOARD_GPIO_DESCRIPTION_GET  GpioDescriptionGet;
> >  };
> >
> >  #endif // __MARVELL_BOARD_DESC_PROTOCOL_H__
> > diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c 
> > b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
> > 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:/

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.

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;
> >

[edk2] [PATCH v3] IntelFsp2Pkg: Add FspmArchConfigPpi to support Dispatch mode

2019-01-14 Thread Chasel, Chiu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1381

In Dispatch mode FSP may consume PPI directly so creating
FSPM_ARCH_CONFIG_PPI to align with FSPM_ARCH_UPD.
Also Keeps new structure size 8 bytes alignment as other
structures.

Test: Verified on internal platform to boot with this PPI
installed successfully.

Cc: Nate DeSimone 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h | 54 
++
 IntelFsp2Pkg/IntelFsp2Pkg.dec|  3 +++
 2 files changed, 57 insertions(+)

diff --git a/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h 
b/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
new file mode 100644
index 00..5bedb95aa7
--- /dev/null
+++ b/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
@@ -0,0 +1,54 @@
+/** @file
+  Header file for FSP-M Arch Config PPI for Dispatch mode
+
+ @copyright
+  Copyright (c) 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
+  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 _FSPM_ARCH_CONFIG_PPI_H_
+#define _FSPM_ARCH_CONFIG_PPI_H_
+
+#define FSPM_ARCH_CONFIG_PPI_REVISION 0x1
+
+///
+/// Global ID for the FSPM_ARCH_CONFIG_PPI.
+///
+#define FSPM_ARCH_CONFIG_GUID \
+  { \
+0x824d5a3a, 0xaf92, 0x4c0c, { 0x9f, 0x19, 0x19, 0x52, 0x6d, 0xca, 0x4a, 
0xbb } \
+  }
+
+///
+/// This PPI provides FSP-M Arch Config PPI.
+///
+typedef struct {
+  ///
+  /// Revision of the structure
+  ///
+  UINT8 Revision;
+  UINT8 Reserved[3];
+  ///
+  /// Pointer to the non-volatile storage (NVS) data buffer.
+  /// If it is NULL it indicates the NVS data is not available.
+  ///
+  VOID  *NvsBufferPtr;
+  ///
+  /// Size of memory to be reserved by FSP below "top
+  /// of low usable memory" for bootloader usage.
+  ///
+  UINT32BootLoaderTolumSize;
+  UINT8 Reserved1[4];
+} FSPM_ARCH_CONFIG_PPI;
+
+extern EFI_GUID gFspmArchConfigPpiGuid;
+
+#endif // _FSPM_ARCH_CONFIG_PPI_H_
diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dec b/IntelFsp2Pkg/IntelFsp2Pkg.dec
index 50496241da..de1bece562 100644
--- a/IntelFsp2Pkg/IntelFsp2Pkg.dec
+++ b/IntelFsp2Pkg/IntelFsp2Pkg.dec
@@ -70,6 +70,9 @@
   gFspPerformanceDataGuid   = { 0x56ed21b6, 0xba23, 0x429e, { 
0x89, 0x32, 0x37, 0x6d, 0x8e, 0x18, 0x2e, 0xe3 } }
   gFspEventEndOfFirmwareGuid= { 0xbd44f629, 0xeae7, 0x4198, { 
0x87, 0xf1, 0x39, 0xfa, 0xb0, 0xfd, 0x71, 0x7e } }
 
+[Ppis]
+  gFspmArchConfigPpiGuid= { 0x824d5a3a, 0xaf92, 0x4c0c, { 
0x9f, 0x19, 0x19, 0x52, 0x6d, 0xca, 0x4a, 0xbb } }
+
 [PcdsFixedAtBuild]
   gIntelFsp2PkgTokenSpaceGuid.PcdGlobalDataPointerAddress 
|0xFED00108|UINT32|0x0001
   gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase 
|0xFEF0|UINT32|0x10001001
-- 
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 08/15] MdeModulePkg Variable: Add emulated variable NV mode support

2019-01-14 Thread Wang, Jian J
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
> 
> 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.
> 

It would be better to mention, although it could be dynamically
configured, it's just a one-shot action before this driver is loaded,
just in case of any misunderstanding. 

> 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(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> index 4c8e1d8cf4f1..845276d891ae 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 v2] MdePkg/BasePeCoffLib: Add more check for relocation data

2019-01-14 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: Bi, Dandan
>Sent: Monday, January 14, 2019 11:02 PM
>To: edk2-devel@lists.01.org
>Cc: Kinney, Michael D ; Gao, Liming
>
>Subject: [patch v2] MdePkg/BasePeCoffLib: Add more check for relocation
>data
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1426
>
>V2:
>(1) Add NULL pointer check for the input parameters
>(2) Add check for the "Adjust" value before applying fix ups.
>
>In function PeCoffLoaderRelocateImageForRuntime, it doesn't
>do much check when do relocation. For API level consideration,
>it's not safe enough.
>So this patch is to replace the same code logic with function
>PeCoffLoaderImageAddress which will cover more validation.
>
>Cc: Michael D Kinney 
>Cc: Liming Gao 
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Dandan Bi 
>---
> MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 165 +-
> 1 file changed, 95 insertions(+), 70 deletions(-)
>
>diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
>b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
>index c57816a808..d9c94b89bd 100644
>--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
>+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
>@@ -13,11 +13,11 @@
>   This library will also do some additional check for PE header fields.
>
>   PeCoffLoaderGetPeHeader() routine will do basic check for PE/COFF header.
>   PeCoffLoaderGetImageInfo() routine will do basic check for whole PE/COFF
>image.
>
>-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>   Portions copyright (c) 2008 - 2009, Apple Inc. 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.
>@@ -1669,25 +1669,34 @@ PeCoffLoaderRelocateImageForRuntime (
>   UINT32  NumberOfRvaAndSizes;
>   EFI_IMAGE_DATA_DIRECTORY*DataDirectory;
>   EFI_IMAGE_DATA_DIRECTORY*RelocDir;
>   EFI_IMAGE_BASE_RELOCATION   *RelocBase;
>   EFI_IMAGE_BASE_RELOCATION   *RelocBaseEnd;
>+  EFI_IMAGE_BASE_RELOCATION   *RelocBaseOrig;
>   UINT16  *Reloc;
>   UINT16  *RelocEnd;
>   CHAR8   *Fixup;
>   CHAR8   *FixupBase;
>   UINT16  *Fixup16;
>   UINT32  *Fixup32;
>   UINT64  *Fixup64;
>   CHAR8   *FixupData;
>   UINTN   Adjust;
>   RETURN_STATUS   Status;
>+  PE_COFF_LOADER_IMAGE_CONTEXTImageContext;
>+
>+  if (RelocationData == NULL || ImageBase == 0x0 || VirtImageBase == 0x0) {
>+return;
>+  }
>
>   OldBase = (CHAR8 *)((UINTN)ImageBase);
>   NewBase = (CHAR8 *)((UINTN)VirtImageBase);
>   Adjust = (UINTN) NewBase - (UINTN) OldBase;
>
>+  ImageContext.ImageAddress = ImageBase;
>+  ImageContext.ImageSize = ImageSize;
>+
>   //
>   // Find the image's relocate dir info
>   //
>   DosHdr = (EFI_IMAGE_DOS_HEADER *)OldBase;
>   if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
>@@ -1730,12 +1739,15 @@ PeCoffLoaderRelocateImageForRuntime (
>   // is present in the image. You have to check the NumberOfRvaAndSizes in
>   // the optional header to verify a desired directory entry is there.
>   //
>   if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
> RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
>-RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase +
>RelocDir->VirtualAddress);
>-RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase +
>RelocDir->VirtualAddress + RelocDir->Size);
>+RelocBase = (EFI_IMAGE_BASE_RELOCATION *)
>PeCoffLoaderImageAddress (, RelocDir->VirtualAddress, 0);
>+RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)
>PeCoffLoaderImageAddress (,
>+
>RelocDir->VirtualAddress + RelocDir-
>>Size,
>+0
>+);
>   } else {
> //
> // Cannot find relocations, cannot continue to relocate the image, ASSERT
>for this invalid image.
> //
> ASSERT (FALSE);
>@@ -1745,100 +1757,113 @@ PeCoffLoaderRelocateImageForRuntime (
>   //
>   // ASSERT for the invalid image when RelocBase and RelocBaseEnd are both
>NULL.
>   //
>   ASSERT (RelocBase != NULL && RelocBaseEnd != NULL);
>
>-  //
>-  // Run the whole relocation block. And re-fixup data that has not been
>-  // modified. The FixupData is used to see if the image has been modified
>-  // since 

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

2019-01-14 Thread Fan, ZhijuX
https://vthsd.intel.com/hsd/tiano/tracker/default.aspx?tracker_id=223983

1. Define one fixedatbuild PCD in dec:
 [PcdsFixedAtBuild]
gUefiOvmfPkgTokenSpaceGuid.test1| {0x01, 0x02}|VOID*|0x3c

2. Define this PCD point to a depex GUID in dsc:
  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf {

  NULL|OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf
  
  gUefiOvmfPkgTokenSpaceGuid.test1| gEfiSmbiosProtocolGuid
  }

3. Define this PCD under [Depex] and [pcd] section in above lib file:
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.test1
[Depex]
gUefiOvmfPkgTokenSpaceGuid.test1

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

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index cfe2d29099..b3dda1adeb 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2779,11 +2779,21 @@ class ModuleAutoGen(AutoGen):
 if '.' not in item:
 NewList.append(item)
 else:
-if item not in self._FixedPcdVoidTypeDict:
+if item not in self.FixedVoidTypePcds.keys():
 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]
-if len(Value.split(',')) != 16:
+Value = self.FixedVoidTypePcds[item]
+if Value.startswith('"') and Value.endswith('"'):
+GuidValue = Value[1:-1]
+GuidList = self.GuidList
+GuidList.update(self.PpiList)
+GuidList.update(self.ProtocolList)
+try:
+Value = GuidList[GuidValue]
+except:
+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))
+elif 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))
 NewList.append(Value)
-- 
2.14.1.windows.1

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


Re: [edk2] [platforms: PATCH v2 04/12] Marvell/Armada70x0Db: Extend board description library with GPIO

2019-01-14 Thread Marcin Wojtas
Hi Leif,

pon., 14 sty 2019 o 23:41 Leif Lindholm  napisał(a):
>
> On Thu, Jan 10, 2019 at 02:44:31AM +0100, Marcin Wojtas wrote:
> > This patch implements ArmadaBoarDescLib library for
> > Armada70x0Db comunity board and introduces ArmadaBoardGpioGet
> > routine with per-board GPIO expander description.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Marcin Wojtas 
> > ---
> >  
> > Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
> >  |  1 +
> >  
> > Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
> >| 25 
> >  2 files changed, 26 insertions(+)
> >
> > diff --git 
> > a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
> >  
> > b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
> > index b26f55b..c995515 100644
> > --- 
> > a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
> > +++ 
> > b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
> > @@ -25,6 +25,7 @@
> >Armada70x0DbBoardDescLib.c
> >
> >  [Packages]
> > +  EmbeddedPkg/EmbeddedPkg.dec
> >MdeModulePkg/MdeModulePkg.dec
> >MdePkg/MdePkg.dec
> >Silicon/Marvell/Marvell.dec
> > diff --git 
> > a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
> >  
> > b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
> > index 48c68e4..f63d8fd 100644
> > --- 
> > a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
> > +++ 
> > b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
> > @@ -21,6 +21,31 @@
> >  #include 
> >  #include 
> >
> > +#include 
> > +
> > +//
> > +// GPIO Expander
> > +//
> > +STATIC MV_GPIO_EXPANDER mGpioExpander = {
> > +  8, /* PCA9555 */
>
> Why did you drop the use of the still existing enumeration in favour
> of live coding the integer value that it currently produces for the
> member PCA9555_ID?
>

As you noticed, I 'fixed' it in 10/12 - otherwise compilation for this
board would be temporarily broken. I will split add MvGpio header with
the enum before this one.

Best regards,
Marcin

> /
> Leif
>
> > +  0x21,
> > +  0x0,
> > +};
> > +
> > +
> > +EFI_STATUS
> > +EFIAPI
> > +ArmadaBoardGpioExpanderGet (
> > +  IN OUT MV_GPIO_EXPANDER **GpioExpanders,
> > +  IN OUT UINTN *GpioExpanderCount
> > +  )
> > +{
> > +  *GpioExpanderCount = 1;
> > +  *GpioExpanders = 
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> >  //
> >  // Order of devices in SdMmcDescTemplate has to be in par with 
> > ArmadaSoCDescLib
> >  //
> > --
> > 2.7.4
> >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 05/15] MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec

2019-01-14 Thread Zeng, Star

On 2019/1/15 13:05, Wang, Jian J wrote:

Hi Star,



-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 05/15] MdeModulePkg: Add PcdEmuVariableNvModeEnable
in dec

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 
---
  MdeModulePkg/MdeModulePkg.dec | 10 --
  MdeModulePkg/MdeModulePkg.uni | 10 --
  2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec
b/MdeModulePkg/MdeModulePkg.dec
index 217ede1f7163..8fbc0af61365 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,13 @@ [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.
+  #   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|BO
OLEAN|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.



The description is a little bit confuse to me. The value of this PCD is 
actually the
base address of reserved memory range, but not the range (size). A complete
memory range includes both base address and its size. But this PCD contains
only base address information. Maybe something like below would be better
(just for example):

--
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.
--

If you agree, please update the uni help string below as well.


In fact, it is not related to this task directly.
But I agree we can make the description to be more clear, I can handle 
it in a new separated patch.



Thanks,
Star




gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0|UINT6
4|0x4008
diff --git a/MdeModulePkg/MdeModulePkg.uni
b/MdeModulePkg/MdeModulePkg.uni
index 35af744d89be..9c413a98f65d 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,15 @@

  #string
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase6
4_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_PRO
MPT  #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."
+  
"TRUE  - An EMU variable NV
storage will be allocated or reserved for NV variables."
+   

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

2019-01-14 Thread Zeng, Star

On 2019/1/15 13:48, Wu, Hao A wrote:

Hi Star,

One minor 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] [PATCH V2 03/15] MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize

2019-01-14 Thread Wu, Hao A
Hi Star,

One minor 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 

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

2019-01-14 Thread Feng, Bob C
Reviewed-by: Feng Bob C 

-Original Message-
From: Gao, Liming 
Sent: Monday, January 14, 2019 9:52 PM
To: edk2-devel@lists.01.org
Cc: Feng, Bob C 
Subject: [Patch] BaseTools GenFw: Fix XCODE5 build issue

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/GenFw/GenFw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index 37278bbc68..af2c909866 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -1014,7 +1014,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; @@ -2180,7 
+2180,7 @@ Returns:
   // Set new base address into image
   //
   if (mOutImageType == FW_REBASE_IMAGE || mOutImageType == 
FW_SET_ADDRESS_IMAGE) {
-if ((PeHdr->Pe32.OptionalHeader.Magic == 
EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
+if (PeHdr->Pe32.OptionalHeader.Magic == 
+ EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
   if (NewBaseAddress >= 0x1ULL) {
 Error (NULL, 0, 3000, "Invalid", "New base address is larger than 4G 
for 32bit PE image");
 goto Finish;
--
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 05/15] MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec

2019-01-14 Thread Wang, Jian J
Hi Star,


> -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 05/15] MdeModulePkg: Add PcdEmuVariableNvModeEnable
> in dec
> 
> 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 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 10 --
>  MdeModulePkg/MdeModulePkg.uni | 10 --
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 217ede1f7163..8fbc0af61365 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,13 @@ [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.
> +  #   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|BO
> OLEAN|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.
> 

The description is a little bit confuse to me. The value of this PCD is 
actually the
base address of reserved memory range, but not the range (size). A complete
memory range includes both base address and its size. But this PCD contains
only base address information. Maybe something like below would be better
(just for example):

--
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.
--

If you agree, please update the uni help string below as well.

> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0|UINT6
> 4|0x4008
> diff --git a/MdeModulePkg/MdeModulePkg.uni
> b/MdeModulePkg/MdeModulePkg.uni
> index 35af744d89be..9c413a98f65d 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,15 @@
> 
>  #string
> STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase6
> 4_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_PRO
> MPT  #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."
> + 
>  "TRUE  - An EMU variable NV
> storage will be allocated or reserved for NV variables."
> +

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

2019-01-14 Thread Chiu, Chasel


+ 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/PeiDxeSmmPchCycleDecodingLib
> /PchCycleDecodingLib.c | 17 +
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git
> a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodingLi
> b/PchCycleDecodingLib.c
> b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodingL
> ib/PchCycleDecodingLib.c
> index 68b0b5dd4b..e135ef1f3e 100644
> ---
> a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodingLi
> b/PchCycleDecodingLib.c
> +++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDeco
> +++ 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


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

2019-01-14 Thread Chasel, Chiu
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/PeiDxeSmmPchCycleDecodingLib/PchCycleDecodingLib.c
 | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git 
a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodingLib/PchCycleDecodingLib.c
 
b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodingLib/PchCycleDecodingLib.c
index 68b0b5dd4b..e135ef1f3e 100644
--- 
a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodingLib/PchCycleDecodingLib.c
+++ 
b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodingLib/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


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

2019-01-14 Thread 唐佳诚
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 
-I/Users/QianYun/Downloads/edk2-vUDK2018/MdeModulePkg/Include 
-I/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg 
-I/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg/Include 
/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg/Unix/Host/Host.c
"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  -o 
/Users/QianYun/Downloads/edk2-vUDK2018/Build/Emulator/DEBUG_XCODE5/X64/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib/OUTPUT/./AutoGen.obj
 
-I/Users/QianYun/Downloads/edk2-vUDK2018/ShellPkg/Library/UefiShellNetwork1CommandsLib
 
-I/Users/QianYun/Downloads/edk2-vUDK2018/Build/Emulator/DEBUG_XCODE5/X64/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib/DEBUG
 

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

2019-01-14 Thread 唐佳诚
Hi Dear EmulatorPkg Maintainer:  I'm a newbie at this, There are some issue 
when building EmulatorPkg. Any inspiration or help will appreciated!OS macOS 
mojave with Xcode 10 command line tool and installed 
macOS_SDK_headers_for_macOS_10.14.pkgDownload edk2-UDK2018.zipInitializing 
workspace> source ./edk2setup.shWORKSPACE: 
/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.shThe BaseTools will build successfully, and EmulatorPkg will fail to 
build.'import sitecustomize' failed; use -v for traceback Build environment: Dar
 win-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:00Edit EmulatorPkg/build.sh and 
./build.sh againdiff --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 1else 
-HO
 ST_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   
 fiBUILD_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 -Wn
 o-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-vUDK2018/MdePkg/Include/X64 
-I/Users/QianYun/Downloads/edk2-vUDK2018/MdeModulePkg 
-I/Users/QianYun/Downloads/edk2-vUDK2018/MdeModulePkg/Include 
-I/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg 
-I/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg/Include 
/Users/QianYun/Downloads/edk2-vUDK2018/EmulatorPkg/Unix/Host/Host.c "c
 lang" -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  -o 
/Users/QianYun/Downloads/edk2-vUDK2018/Build/Emulator/DEBUG_XCODE5/X64/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib/OUTPUT/./AutoGen.obj
 
-I/Users/QianYun/Downloads/edk2-vUDK2018/ShellPkg/Library/UefiShellNetwork1CommandsLib
 
-I/Users/QianYun/Downloads/edk2-vUDK2018/Build/Emulator/DEBUG_XCODE5/X64/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib/DEBUG
 -I/Users/QianYun/Downloads/edk2-vUDK2018/MdePkg 

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

2019-01-14 Thread Zeng, Star

On 2019/1/15 6:11, Leif Lindholm wrote:

Hi Star,

This set looks like a good cleanup.


Thanks.



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.



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.



Thanks,
Star




Regards,

Leif

On Mon, Jan 14, 2019 at 11:19:53PM +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 
---
  BeagleBoardPkg/BeagleBoardPkg.dsc | 13 +++--
  BeagleBoardPkg/BeagleBoardPkg.fdf |  4 ++--
  2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc 
b/BeagleBoardPkg/BeagleBoardPkg.dsc
index 6dabfa905ae9..479b1504825a 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,10 @@ [LibraryClasses.common]
  
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.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 +349,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 +385,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 v1 0/2] Remove unused global variables in

2019-01-14 Thread Wu, Jiaxin
Series Reviewed-by: Jiaxin Wu 

Thanks,
jiaxin

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Songpeng Li
> Sent: Monday, January 14, 2019 5:25 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH v1 0/2] Remove unused global variables in
> 
> Uefi-aware compiler found some redundant definitions in
> the NetworkPkg. We need to clean them.
> 
> Songpeng Li (2):
>   NetworkPkg/IScsiDxe: Remove unused global variables.
>   NetworkPkg/Dhcp6Dxe: Remove an unused global variable.
> 
>  NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c   | 2 --
>  NetworkPkg/IScsiDxe/IScsiConfig.c | 2 --
>  NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h   | 1 -
>  3 files changed, 5 deletions(-)
> 
> --
> 2.18.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 v1 0/2] Fix the possible NULL pointer dereference issue.

2019-01-14 Thread Jiaxin Wu
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.

Besides, NET_LIST_FOR_EACH_SAFE is defined to iterate through the double
linked list in delete-safe way. It's unnecessary to use this macro if
list entries won't be deleted.

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 
Jiaxin Wu (2):
  MdeModulePkg/NetLib.h: Fix the possible NULL pointer dereference issue.
  MdeModulePkg/Dhcp4Dxe: Use NET_LIST_FOR_EACH instead of 
NET_LIST_FOR_EACH_SAFE.

 MdeModulePkg/Include/Library/NetLib.h | 6 +++---
 MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.17.1.windows.2

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


[edk2] [PATCH v1 2/2] MdeModulePkg/Dhcp4Dxe: Use NET_LIST_FOR_EACH instead of NET_LIST_FOR_EACH_SAFE.

2019-01-14 Thread Jiaxin Wu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1456

NET_LIST_FOR_EACH_SAFE is defined to iterate through the double linked list
in delete-safe way. It's unnecessary to use this macro if list entries won't
be deleted.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c 
b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
index 98a22a77b4..47a9db6489 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
@@ -1493,15 +1493,15 @@ DhcpOnTimerTick (
   IN EFI_EVENT  Event,
   IN VOID   *Context
   )
 {
   LIST_ENTRY*Entry;
-  LIST_ENTRY*Next;
   DHCP_SERVICE  *DhcpSb;
   DHCP_PROTOCOL *Instance;
   EFI_STATUSStatus;
 
+  Entry= NULL;
   DhcpSb   = (DHCP_SERVICE *) Context;
   Instance = DhcpSb->ActiveChild;
 
   //
   // 0x is the maximum supported value for elapsed time according to RFC.
@@ -1644,11 +1644,11 @@ DhcpOnTimerTick (
 
 ON_EXIT:
   //
   // Iterate through all the DhcpSb Children.
   //
-  NET_LIST_FOR_EACH_SAFE (Entry, Next, >Children) {
+  NET_LIST_FOR_EACH (Entry, >Children) {
 Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link);
 
 if ((Instance != NULL) && (Instance->Token != NULL)) {
   Instance->Timeout--;
   if (Instance->Timeout == 0) {
-- 
2.17.1.windows.2

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


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

2019-01-14 Thread Jiaxin Wu
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)
 
 //
 // 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] [platforms: PATCH v2 03/12] SolidRun/Armada80x0McBin: Extend board description library with GPIO

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:30AM +0100, Marcin Wojtas wrote:
> This patch implements ArmadaBoarDescLib library for
> Armada80x0McBin comunity board and introduces ArmadaBoardGpioGet
> routine with per-board GPIO expander description.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 

Reviewed-by: Leif Lindholm 

> ---
>  
> Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf
>  |  1 +
>  
> Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c
>| 17 +
>  2 files changed, 18 insertions(+)
> 
> diff --git 
> a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf
>  
> b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf
> index 63a4f66..43e4b9e 100644
> --- 
> a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf
> +++ 
> b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf
> @@ -25,6 +25,7 @@
>Armada80x0McBinBoardDescLib.c
>  
>  [Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Marvell/Marvell.dec
> diff --git 
> a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c
>  
> b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c
> index d52adfc..32596ad 100644
> --- 
> a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c
> +++ 
> b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c
> @@ -22,6 +22,23 @@
>  #include 
>  
>  //
> +// GPIO Expander
> +//
> +EFI_STATUS
> +EFIAPI
> +ArmadaBoardGpioExpanderGet (
> +  IN OUT MV_GPIO_EXPANDER **GpioExpanders,
> +  IN OUT UINTN *GpioExpanderCount
> +  )
> +{
> +  /* No GPIO expanders on board */
> +  *GpioExpanders = NULL;
> +  *GpioExpanderCount = 0;
> +
> +  return EFI_SUCCESS;
> +}
> +
> +//
>  // Order of devices in SdMmcDescTemplate has to be in par with 
> ArmadaSoCDescLib
>  //
>  STATIC
> -- 
> 2.7.4
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 02/12] Marvell/Library: ArmadaBoardDescLib: Add GPIO information

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:29AM +0100, Marcin Wojtas wrote:
> This patch extends library with GPIO devices per-board
> description. Both embedded SoC controllers and
> I2C IO expanders are supported. Add a helper routine
> for obtaining information about the latter.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 

Reviewed-by: Leif Lindholm 

> ---
>  Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h | 23 
> 
>  1 file changed, 23 insertions(+)
> 
> diff --git a/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h 
> b/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h
> index 3fe2988..6ec5ace 100644
> --- a/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h
> +++ b/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h
> @@ -25,6 +25,29 @@ typedef struct {
>  } MV_BOARD_COMPHY_DESC;
>  
>  //
> +// GPIO devices per-board description
> +//
> +typedef struct {
> +  UINTN ChipId;
> +  UINTN I2cAddress;
> +  UINTN I2cBus;
> +} MV_GPIO_EXPANDER;
> +
> +typedef struct {
> +  GPIO_CONTROLLER  *SoCGpio;
> +  UINTN GpioDeviceCount;
> +  MV_GPIO_EXPANDER *GpioExpanders;
> +  UINTN GpioExpanderCount;
> +} MV_BOARD_GPIO_DESCRIPTION;
> +
> +EFI_STATUS
> +EFIAPI
> +ArmadaBoardGpioExpanderGet (
> +  IN OUT MV_GPIO_EXPANDER **GpioExpanders,
> +  IN OUT UINTN *GpioExpanderCount
> +  );
> +
> +//
>  // I2C devices per-board description
>  //
>  typedef struct {
> -- 
> 2.7.4
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 01/12] Marvell/Library: ArmadaSoCDescLib: Add GPIO information

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:28AM +0100, Marcin Wojtas wrote:
> This patch introduces new library callback (ArmadaSoCGpioGet ()),
> which dynamically allocates and fills EmbeddedGpio's
> GPIO_CONTROLLER structure with the SoC description of GPIO controllers.
> 
> Because the library header is indirectly used in many modules,
> update all dependencies after including EmbeddedGpio.h.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 

Reviewed-by: Leif Lindholm 

> ---
>  Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf   
> |  1 +
>  
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf
>  |  1 +
>  Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf 
> |  1 +
>  Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
> |  1 +
>  Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf  
> |  1 +
>  Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf  
> |  1 +
>  Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf  
> |  1 +
>  Silicon/Marvell/Library/IcuLib/IcuLib.inf
> |  1 +
>  Silicon/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
> |  1 +
>  
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
>| 10 +
>  Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h   
> | 12 ++
>  
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
>| 39 
>  12 files changed, 70 insertions(+)
> 
> diff --git a/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf 
> b/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf
> index 5503463..e707fe9 100644
> --- a/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf
> +++ b/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf
> @@ -25,6 +25,7 @@
>PlatInitDxe.c
>  
>  [Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Marvell/Marvell.dec
> diff --git 
> a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf
>  
> b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf
> index 2b73b73..48a320c 100644
> --- 
> a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf
> +++ 
> b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf
> @@ -24,6 +24,7 @@
>Armada7k8kSoCDescLib.c
>  
>  [Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Marvell/Marvell.dec
> diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf 
> b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
> index 0b93948..0b641fe 100644
> --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
> +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
> @@ -42,6 +42,7 @@
>MvBoardDescDxe.h
>  
>  [Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Marvell/Marvell.dec
> diff --git a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf 
> b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
> index 0eef350..e5bd370 100755
> --- a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
> +++ b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
> @@ -41,6 +41,7 @@
>MvI2cDxe.c
>  
>  [Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdePkg/MdePkg.dec
>MdeModulePkg/MdeModulePkg.dec
>ArmPlatformPkg/ArmPlatformPkg.dec
> diff --git a/Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf 
> b/Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf
> index 739576f..8a877da 100644
> --- a/Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf
> +++ b/Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf
> @@ -45,6 +45,7 @@
>  [Packages]
>ArmPkg/ArmPkg.dec
>ArmPlatformPkg/ArmPlatformPkg.dec
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Marvell/Marvell.dec
> diff --git a/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf 
> b/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf
> index 00c738a..09c5842 100644
> --- a/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf
> +++ b/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf
> @@ -35,6 +35,7 @@
>XenonSdMmcOverride.h
>  
>  [Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdePkg/MdePkg.dec
>MdeModulePkg/MdeModulePkg.dec
>Silicon/Marvell/Marvell.dec
> diff --git a/Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf 
> b/Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
> index 36f498b..c360edd 100644
> --- a/Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
> +++ b/Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
> @@ -41,6 +41,7 @@
>  [Packages]
>

Re: [edk2] [platforms: PATCH v2 12/12] Marvell/Armada7k8k: Introduce NonDiscoverable device init routines

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:39AM +0100, Marcin Wojtas wrote:
> To abstract the initialization required for non-discoverable devices,
> which is often platform specific (e.g. enable GPIO-driven power supply),
> introduce a NonDiscoverableInitLib for use by the NonDiscoverable code,
> for which each platform can supply its own version.
> 
> Add XHCI power supply (so called 'VBUS') enabling routines
> for supported platforms (Armada70x0Db, Armada80x0Db, Armada80x0McBin).
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 

Reviewed-by: Leif Lindholm 

> ---
>  Silicon/Marvell/Marvell.dec  
>|   1 +
>  Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc   
>|   3 +
>  Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc   
>|   3 +
>  Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc
>|   3 +
>  
> Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
>  |  48 +
>  
> Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
>  |  49 +
>  
> Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
>  |  49 +
>  Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.inf
>|   1 +
>  
> Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h 
>   |  23 +
>  
> Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h 
>   |  28 ++
>  
> Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h
>|  20 
>  Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h 
>|  28 ++
>  
> Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c 
>   |  96 ++
>  
> Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c 
>   | 106 
>  
> Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c
>|  71 +
>  Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c  
>|  13 ++-
>  16 files changed, 539 insertions(+), 3 deletions(-)
>  create mode 100644 
> Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
>  create mode 100644 
> Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
>  create mode 100644 
> Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
>  create mode 100644 
> Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
>  create mode 100644 
> Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
>  create mode 100644 
> Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h
>  create mode 100644 Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h
>  create mode 100644 
> Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
>  create mode 100644 
> Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
>  create mode 100644 
> Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c
> 
> diff --git a/Silicon/Marvell/Marvell.dec b/Silicon/Marvell/Marvell.dec
> index 616624e..12bac55 100644
> --- a/Silicon/Marvell/Marvell.dec
> +++ b/Silicon/Marvell/Marvell.dec
> @@ -63,6 +63,7 @@
>ArmadaBoardDescLib|Include/Library/ArmadaBoardDescLib.h
>ArmadaIcuLib|Include/Library/ArmadaIcuLib.h
>ArmadaSoCDescLib|Include/Library/ArmadaSoCDescLib.h
> +  NonDiscoverableInitLib|Include/Library/NonDiscoverableInitLib.h
>SampleAtResetLib|Include/Library/SampleAtResetLib.h
>  
>  [Protocols]
> diff --git a/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc 
> b/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc
> index 31815e4..e8cd177 100644
> --- a/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc
> +++ b/Platform/Marvell/Armada70x0Db/Armada70x0Db.dsc
> @@ -48,6 +48,9 @@
>  
>  !include Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
>  
> +[LibraryClasses.common]
> +  
> NonDiscoverableInitLib|Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
> +
>  [Components.common]
>Silicon/Marvell/Armada7k8k/DeviceTree/Armada70x0Db.inf
>  
> diff --git a/Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc 
> b/Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc
> index 42f7bd3..8e8c2ba 100644
> --- a/Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc
> +++ b/Platform/Marvell/Armada80x0Db/Armada80x0Db.dsc
> @@ -48,6 +48,9 @@
>  
>  !include Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
>  
> +[LibraryClasses.common]
> +  
> NonDiscoverableInitLib|Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
> +
>  [Components.common]
>

Re: [edk2] [platforms: PATCH v2 10/12] Marvell/Drivers: MvPca95xxDxe: Introduce GPIO expander driver

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:37AM +0100, Marcin Wojtas wrote:
> Marvell Armada 7k/8k-based platforms may use Pca95xx to extend
> amount of the GPIO pins.
> 
> This patch introduces support for them. The new driver implements
> a generic EMBEDDED_GPIO protocol.
> 
> In order to ease description of used PCA9XXX controllers
> add a common enum type. It can be used e.g. in the board description
> library to specify the expander model on a board (instead of passing
> a raw number). Update relevant libraries.
> 
> Driver is based on initial work done by Allen Yan .
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 
> ---
>  Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf   
>  |  45 ++
>  Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h 
>  |  65 ++
>  Silicon/Marvell/Include/Protocol/MvGpio.h
>  |  16 +
>  
> Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
>  |   2 +-
>  
> Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
>  |   4 +-
>  Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c 
>  | 651 
>  6 files changed, 780 insertions(+), 3 deletions(-)
>  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf
>  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h
>  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c
> 
> diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf 
> b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf
> new file mode 100644
> index 000..3b1ab4e
> --- /dev/null
> +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf
> @@ -0,0 +1,45 @@
> +## @file
> +#
> +#  Copyright (c) 2017, Marvell International 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= 0x0001001A
> +  BASE_NAME  = MvPca95xxDxe
> +  FILE_GUID  = f0e405eb-8407-43b9-88e6-2f7d70715c72
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  ENTRY_POINT= MvPca95xxEntryPoint
> +
> +[Sources]
> +  MvPca95xxDxe.c
> +  MvPca95xxDxe.h
> +
> +[Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +  Silicon/Marvell/Marvell.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  MemoryAllocationLib
> +  UefiDriverEntryPoint
> +  UefiLib
> +
> +[Protocols]
> +  gEfiDriverBindingProtocolGuid
> +  gEfiI2cIoProtocolGuid
> +  gEmbeddedGpioProtocolGuid
> +  gMarvellBoardDescProtocolGuid
> +
> +[Depex]
> +  TRUE
> diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h 
> b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h
> new file mode 100644
> index 000..1fed739
> --- /dev/null
> +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h
> @@ -0,0 +1,65 @@
> +/**
> +*
> +*  Copyright (c) 2018, Marvell International 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.
> +*
> +**/
> +#ifndef __MV_PCA953X_H__
> +#define __MV_PCA953X_H__
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#define PCA95XX_GPIO_SIGNATURE   SIGNATURE_32 ('I', 'O', 'E', 'X')
> +
> +#define PCA95XX_INPUT_REG0x0
> +#define PCA95XX_OUTPUT_REG   0x2
> +#define PCA95XX_DIRECTION_REG0x6
> +
> +#define PCA95XX_BANK_SIZE8
> +#define PCA95XX_OPERATION_COUNT  2
> +#define PCA95XX_OPERATION_LENGTH 1
> +
> +typedef enum {
> +  PCA9505_PIN_COUNT = 40,
> +  PCA9534_PIN_COUNT = 8,
> +  PCA9535_PIN_COUNT = 16,
> +  PCA9536_PIN_COUNT = 4,
> +  PCA9537_PIN_COUNT = 4,
> +  PCA9538_PIN_COUNT = 8,
> +  PCA9539_PIN_COUNT = 16,
> +  PCA9554_PIN_COUNT = 8,
> +  PCA9555_PIN_COUNT = 16,
> +  PCA9556_PIN_COUNT = 16,
> +  PCA9557_PIN_COUNT = 16,
> +} PCA95XX_PIN_COUNT;
> +
> +typedef struct {
> +  

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

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:35AM +0100, Marcin Wojtas wrote:
> Marvell Armada 7k/8k SoCs comprise integrated GPIO controllers,
> one in AP806 and two in each south bridge hardware blocks.
> 
> This patch introduces support for them. The new driver implements
> a generic EMBEDDED_GPIO protocol.
> 
> In order to ease description of used GPIO pins and controllers
> of the Armada 7k8k platforms, add a common enum type.
> 
> Based on original work of Jing Hua .
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 
> ---
>  Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf |  44 +++
>  Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h   |  49 +++
>  Silicon/Marvell/Include/Protocol/MvGpio.h|  10 +
>  Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c   | 372 
> 
>  4 files changed, 475 insertions(+)
>  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
>  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
>  create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c
> 
> diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf 
> b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
> new file mode 100644
> index 000..5ff9130
> --- /dev/null
> +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
> @@ -0,0 +1,44 @@
> +## @file
> +#
> +#  Copyright (c) 2017, Marvell International 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= 0x0001001A
> +  BASE_NAME  = MvGpioDxe
> +  FILE_GUID  = 706eb761-b3b5-4f41-8558-5fd9217c0079
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  ENTRY_POINT= MvGpioEntryPoint
> +
> +[Sources]
> +  MvGpioDxe.c
> +  MvGpioDxe.h
> +
> +[Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +  Silicon/Marvell/Marvell.dec
> +
> +[LibraryClasses]
> +  ArmadaSoCDescLib
> +  DebugLib
> +  MemoryAllocationLib
> +  UefiDriverEntryPoint
> +  UefiLib
> +
> +[Protocols]
> +  gEmbeddedGpioProtocolGuid
> +  gMarvellBoardDescProtocolGuid
> +
> +[Depex]
> +  TRUE
> diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h 
> b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
> new file mode 100644
> index 000..4e5422b
> --- /dev/null
> +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
> @@ -0,0 +1,49 @@
> +/**
> +*
> +*  Copyright (c) 2018, Marvell International 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.
> +*
> +**/
> +#ifndef __MV_GPIO_H__
> +#define __MV_GPIO_H__
> +
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#include 
> +
> +#define MV_GPIO_SIGNATURESIGNATURE_32 ('G', 'P', 'I', 'O')

Unaddressed feedback from last time. But rereading it makes it clear
my feedback was too imprecise, apologies. The point was that "GPIO" is
not a very good choice of key to distinguish _this_ GPIO driver from
other GPIO drivers. (As well as the MV_ prefix.)

One more comment below, but it does not require code changes.
If you can just change the signature, I'm happy with this patch.

> +
> +// Marvell MV_GPIO Controller Registers
> +#define MV_GPIO_DATA_OUT_REG (0x0)
> +#define MV_GPIO_OUT_EN_REG   (0x4)
> +#define MV_GPIO_BLINK_EN_REG (0x8)
> +#define MV_GPIO_DATA_IN_POL_REG  (0xc)
> +#define MV_GPIO_DATA_IN_REG  (0x10)
> +
> +typedef struct {
> +  EMBEDDED_GPIO GpioProtocol;
> +  GPIO_CONTROLLER  *SoCGpio;
> +  UINTN GpioDeviceCount;
> +  UINTN Signature;
> +  EFI_HANDLEHandle;
> +} MV_GPIO;
> +
> +#endif // __MV_GPIO_H__
> diff --git a/Silicon/Marvell/Include/Protocol/MvGpio.h 
> b/Silicon/Marvell/Include/Protocol/MvGpio.h
> index c9f1007..3319b79 100644
> --- a/Silicon/Marvell/Include/Protocol/MvGpio.h
> +++ b/Silicon/Marvell/Include/Protocol/MvGpio.h
> @@ -27,6 +27,16 @@ typedef enum {
>MV_GPIO_DRIVER_TYPE_SOC_CONTROLLER,
>  } 

Re: [edk2] [PATCH edk2-platforms 3/3] Silicon/SynQuacer: add support for DEBUG output on second UART

2019-01-14 Thread Ard Biesheuvel
On Sat, 12 Jan 2019 at 19:25, Mark Kettenis  wrote:
>
> > Date: Fri, 11 Jan 2019 17:58:44 +
> > From: Leif Lindholm 
> >
> > On Wed, Dec 26, 2018 at 02:25:30PM +0100, Ard Biesheuvel wrote:
> > > On headless server systems where the PL011 serial port is the primary
> > > console, having DEBUG output on the same port can be annoying, since
> > > DEBUG output gets lost when the console driver clears the screen or
> > > positions the cursor using control characters.
> > >
> > > So add the ability to emit the DEBUG output on the DesignWare FUART
> > > (which is exposed via the LS connector on DeveloperBox)
> >
> > >From what I can tell, the DesignWare component is 8250-compatible, yet
> > here we're using the 16550 driver. I presume this makes no difference
> > for how we're using it, but could you add a comment to this effect to
> > the commit message? (If the FUART is indeed a 16550 clone, please add
> > a statement to that effect instead.)
>
> The DesignWare component is (largely) 16550-compatible.  But the
> FIFO's are optional and if they're not included you'll end up with
> something that's probably closer to an 16450.  I suspect in most cases
> SoC designers will include the FIFO's though since without them you
> really can't use the port at anything but the slowest speeds.
>

Thanks Mark

Series pushed as e6fd447b23b6..307f7f5bfc4f (with Mark's clarification
added to the commit log of 3/3)
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 07/12] Marvell/Protocol: Introduce GPIO helper header

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:34AM +0100, Marcin Wojtas wrote:
> From: jinghua 
> 
> This patch introduces a helper header that can be used by
> multiple EMBEDDED_GPIO protocol producers (e.g. platform
> driver or GPIO expanders). The drives are differentiated by
> MV_GPIO_DRIVER_TYPE field of driver's MV_GPIO_DEVICE_PATH.
> 
> In order to ease selection of the desired GPIO controller
> a helper function was added - MarvellGpioGetProtocol().
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 
> ---
>  Silicon/Marvell/Include/Protocol/MvGpio.h | 156 
>  1 file changed, 156 insertions(+)
>  create mode 100644 Silicon/Marvell/Include/Protocol/MvGpio.h
> 
> diff --git a/Silicon/Marvell/Include/Protocol/MvGpio.h 
> b/Silicon/Marvell/Include/Protocol/MvGpio.h
> new file mode 100644
> index 000..c9f1007
> --- /dev/null
> +++ b/Silicon/Marvell/Include/Protocol/MvGpio.h
> @@ -0,0 +1,156 @@
> +/**
> +*
> +*  Copyright (C) 2018, Marvell International Ltd. and its affiliates.
> +*
> +*  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 __MV_GPIO_PROTOCOL_H__
> +#define __MV_GPIO_PROTOCOL_H__
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +typedef enum {
> +  MV_GPIO_DRIVER_TYPE_SOC_CONTROLLER,
> +} MV_GPIO_DRIVER_TYPE;
> +
> +typedef struct {
> +  VENDOR_DEVICE_PATHHeader;
> +  MV_GPIO_DRIVER_TYPE   GpioDriverType;
> +  EFI_DEVICE_PATH_PROTOCOL  End;
> +} MV_GPIO_DEVICE_PATH;
> +
> +typedef struct {
> +  UINTNControllerId;
> +  UINTNPinNumber;
> +  BOOLEAN  ActiveHigh;
> +} MV_GPIO_PIN;
> +
> +/*
> + * Check if the driver type matches the requested value.
> + * In case of the success open the GPIO protocol and return.
> + */
> +STATIC
> +inline
> +EFI_STATUS
> +EFIAPI
> +MvGpioFindMatchingDriver (

Eep!
I missed this in v1 (I assumed I'd missed the new file indicator
whilst scrolling) - please move these functions out of this .h file.
https://edk2-docs.gitbooks.io/edk-ii-c-coding-standards-specification/content/v/release/2.20/5_source_files/53_include_files.html#537-include-files-shall-not-generate-code-or-define-data-variables

This makes me take a closer look at the rest of the patch ... and this
just isn't a protocol - it's a library. Please restrucure it as such
and move the header file to Include/Library rather than
Include/Protocol.

/
Leif

> +  IN MV_GPIO_DRIVER_TYPEGpioDriverType,
> +  IN EFI_HANDLE HandleBuffer,
> +  IN EFI_DEVICE_PATH   *DevicePath,
> +  IN OUT EMBEDDED_GPIO**GpioProtocol
> +  )
> +{
> +  MV_GPIO_DEVICE_PATH *GpioDevicePath;
> +  EFI_STATUS   Status;
> +
> +  while (!IsDevicePathEndType (DevicePath)) {
> +/* Check if GpioDriverType matches one found in the device path */
> +GpioDevicePath = (MV_GPIO_DEVICE_PATH *)DevicePath;
> +if (GpioDevicePath->GpioDriverType != GpioDriverType) {
> +  DevicePath = NextDevicePathNode (DevicePath);
> +  continue;
> +}
> +
> +/*
> + * Open GpioProtocol. With EFI_OPEN_PROTOCOL_GET_PROTOCOL attribute
> + * the consumer is not obliged to call CloseProtocol.
> + */
> +Status = gBS->OpenProtocol (HandleBuffer,
> +,
> +(VOID **)GpioProtocol,
> +gImageHandle,
> +NULL,
> +EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> +return Status;
> +  }
> +
> +  return EFI_NOT_FOUND;
> +}
> +
> +/*
> + * Select desired protocol producer upon MV_GPIO_DRIVER_TYPE
> + * field of driver's MV_GPIO_DEVICE_PATH.
> + */
> +STATIC
> +inline
> +EFI_STATUS
> +EFIAPI
> +MvGpioGetProtocol (
> +  IN MV_GPIO_DRIVER_TYPEGpioDriverType,
> +  IN OUT EMBEDDED_GPIO**GpioProtocol
> +  )
> +{
> +  EFI_DEVICE_PATH *DevicePath;
> +  EFI_HANDLE  *HandleBuffer;
> +  EFI_STATUS   Status;
> +  UINTNHandleCount;
> +  UINTNIndex;
> +
> +  /* Locate Handles of all EMBEDDED_GPIO producers */
> +  Status = gBS->LocateHandleBuffer (ByProtocol,
> +  ,
> +  NULL,
> +  ,
> +  );
> +  if (EFI_ERROR (Status)) {
> +DEBUG ((DEBUG_ERROR, "%a: Unable to locate handles\n", __FUNCTION__));
> +return Status;
> +  }
> +
> +  /* Iterate over all protocol producers */
> +  for (Index = 0; Index < HandleCount; Index++) {
> +/* Open device path protocol installed on each handle */
> +Status = gBS->OpenProtocol (HandleBuffer[Index],
> +,

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

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:33AM +0100, Marcin Wojtas wrote:
> Introduce new callback that can provide information
> about GPIO SoC controllers, as well as on-board
> I2C IO expanders. According ArmadaSoCDescLib
> ArmadaBoardDescLib routines are used for
> obtaining required data.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 
> ---
>  Silicon/Marvell/Include/Protocol/BoardDesc.h   |  8 
>  Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c | 43 
>  2 files changed, 51 insertions(+)
> 
> diff --git a/Silicon/Marvell/Include/Protocol/BoardDesc.h 
> b/Silicon/Marvell/Include/Protocol/BoardDesc.h
> index 1d57a16..02905ea 100644
> --- a/Silicon/Marvell/Include/Protocol/BoardDesc.h
> +++ b/Silicon/Marvell/Include/Protocol/BoardDesc.h
> @@ -50,6 +50,13 @@ EFI_STATUS
>  
>  typedef
>  EFI_STATUS
> +(EFIAPI *MV_BOARD_GPIO_DESCRIPTION_GET) (
> +  IN MARVELL_BOARD_DESC_PROTOCOL*This,
> +  IN OUT MV_BOARD_GPIO_DESCRIPTION **GpioDescription
> +  );
> +
> +typedef
> +EFI_STATUS
>  (EFIAPI *MV_BOARD_DESC_I2C_GET) (
>IN MARVELL_BOARD_DESC_PROTOCOL  *This,
>IN OUT MV_BOARD_I2C_DESC   **I2cDesc
> @@ -113,6 +120,7 @@ struct _MARVELL_BOARD_DESC_PROTOCOL {
>MV_BOARD_DESC_UTMI_GET BoardDescUtmiGet;
>MV_BOARD_DESC_XHCI_GET BoardDescXhciGet;
>MV_BOARD_DESC_FREE BoardDescFree;
> +  MV_BOARD_GPIO_DESCRIPTION_GET  GpioDescriptionGet;
>  };
>  
>  #endif // __MARVELL_BOARD_DESC_PROTOCOL_H__
> diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c 
> b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
> 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

> +  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.

/
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] [platforms: PATCH v2 05/12] Marvell/Armada80x0Db: Extend board description library with GPIO

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:32AM +0100, Marcin Wojtas wrote:
> This patch implements ArmadaBoarDescLib library for
> Armada80x0Db comunity board and introduces ArmadaBoardGpioGet
> routine with per-board GPIO expander description.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 
> ---
>  
> Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf
>  |  1 +
>  
> Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
>| 31 
>  2 files changed, 32 insertions(+)
> 
> diff --git 
> a/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf
>  
> b/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf
> index 2d39d96..786b7f0 100644
> --- 
> a/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf
> +++ 
> b/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf
> @@ -25,6 +25,7 @@
>Armada80x0DbBoardDescLib.c
>  
>  [Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Marvell/Marvell.dec
> diff --git 
> a/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
>  
> b/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
> index feb69ad..f6e3675 100644
> --- 
> a/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
> +++ 
> b/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
> @@ -21,6 +21,37 @@
>  #include 
>  #include 
>  
> +#include 
> +
> +//
> +// GPIO Expanders
> +//
> +STATIC MV_GPIO_EXPANDER mGpioExpanders[] = {
> +  {
> +8, /* PCA9555 */

Same as for 4/12.

> +0x21,
> +0x0,
> +  },
> +  {
> +8, /* PCA9555 */

And again.

Please re-jig such that the enum appears in time to be used by this
and preceding patches, then resubmit affected patches.

/
Leif

> +0x25,
> +0x0,
> +  },
> +};
> +
> +EFI_STATUS
> +EFIAPI
> +ArmadaBoardGpioExpanderGet (
> +  IN OUT MV_GPIO_EXPANDER **GpioExpanders,
> +  IN OUT UINTN *GpioExpanderCount
> +  )
> +{
> +  *GpioExpanderCount = ARRAY_SIZE (mGpioExpanders);
> +  *GpioExpanders = mGpioExpanders;
> +
> +  return EFI_SUCCESS;
> +}
> +
>  //
>  // Order of devices in SdMmcDescTemplate has to be in par with 
> ArmadaSoCDescLib
>  //
> -- 
> 2.7.4
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v2 04/12] Marvell/Armada70x0Db: Extend board description library with GPIO

2019-01-14 Thread Leif Lindholm
On Thu, Jan 10, 2019 at 02:44:31AM +0100, Marcin Wojtas wrote:
> This patch implements ArmadaBoarDescLib library for
> Armada70x0Db comunity board and introduces ArmadaBoardGpioGet
> routine with per-board GPIO expander description.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 
> ---
>  
> Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
>  |  1 +
>  
> Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
>| 25 
>  2 files changed, 26 insertions(+)
> 
> diff --git 
> a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
>  
> b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
> index b26f55b..c995515 100644
> --- 
> a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
> +++ 
> b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
> @@ -25,6 +25,7 @@
>Armada70x0DbBoardDescLib.c
>  
>  [Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Marvell/Marvell.dec
> diff --git 
> a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
>  
> b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
> index 48c68e4..f63d8fd 100644
> --- 
> a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
> +++ 
> b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
> @@ -21,6 +21,31 @@
>  #include 
>  #include 
>  
> +#include 
> +
> +//
> +// GPIO Expander
> +//
> +STATIC MV_GPIO_EXPANDER mGpioExpander = {
> +  8, /* PCA9555 */

Why did you drop the use of the still existing enumeration in favour
of live coding the integer value that it currently produces for the
member PCA9555_ID?

/
Leif

> +  0x21,
> +  0x0,
> +};
> +
> +
> +EFI_STATUS
> +EFIAPI
> +ArmadaBoardGpioExpanderGet (
> +  IN OUT MV_GPIO_EXPANDER **GpioExpanders,
> +  IN OUT UINTN *GpioExpanderCount
> +  )
> +{
> +  *GpioExpanderCount = 1;
> +  *GpioExpanders = 
> +
> +  return EFI_SUCCESS;
> +}
> +
>  //
>  // Order of devices in SdMmcDescTemplate has to be in par with 
> ArmadaSoCDescLib
>  //
> -- 
> 2.7.4
> 
___
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-14 Thread Leif Lindholm
Hi Star,

This set looks like a good cleanup.

This patch also need an added resolution for SynchronizationLib.
(MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
should be fine.)

The same modification will also be needed in edk2-platforms for
Platform/Hisilicon/HiKey and HiKey960.

Regards,

Leif

On Mon, Jan 14, 2019 at 11:19:53PM +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 
> ---
>  BeagleBoardPkg/BeagleBoardPkg.dsc | 13 +++--
>  BeagleBoardPkg/BeagleBoardPkg.fdf |  4 ++--
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc 
> b/BeagleBoardPkg/BeagleBoardPkg.dsc
> index 6dabfa905ae9..479b1504825a 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,10 @@ [LibraryClasses.common]
>  
>CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.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 +349,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 +385,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] IntelFsp2Pkg: Add FspmArchConfigPpi to support Dispatch mode

2019-01-14 Thread Desimone, Nathaniel L
Hi Star,

There are three fields in FSPM_ARCH_UPD that are not in FSPM_ARCH_CONFIG_PPI:

1. StackBase
2. StackSize
3. BootMode

For #1 and #2, there is no need for a second stack and second HOB list when FSP 
is running in dispatch mode, so these entries are not needed.

For #3, there is already a PI specification defined method of setting BootMode, 
specifically (*PeiServices)->SetBootMode().

The purpose of dispatch mode is to align FSP with the existing PI specification 
as much as possible, which is why we explicitly removed these entries from 
FSPM_ARCH_CONFIG_PPI.

Reviewed-by: Nate DeSimone 

Thanks,
Nate

-Original Message-
From: edk2-devel  On Behalf Of Zeng, Star
Sent: Monday, December 10, 2018 12:01 AM
To: Chiu, Chasel ; edk2-devel@lists.01.org
Cc: Zeng, Star 
Subject: Re: [edk2] [PATCH] IntelFsp2Pkg: Add FspmArchConfigPpi to support 
Dispatch mode

Hi Chasel,

Two minor comments are added inline.

On 2018/12/7 21:30, Chasel, Chiu wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1381
> 
> In Dispatch mode FSP may consume PPI directly so creating 
> FSPM_ARCH_CONFIG_PPI to align with FSPM_ARCH_UPD.
> 
> Test: Verified on internal platform to boot with this PPI installed 
> successfully.
> 
> Cc: Nate DeSimone 
> Cc: Star Zeng 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chasel Chiu 
> ---
>   IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h | 41 
> +
>   IntelFsp2Pkg/IntelFsp2Pkg.dec|  3 +++
>   2 files changed, 44 insertions(+)
> 
> diff --git a/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h 
> b/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
> new file mode 100644
> index 00..5b3dac5b04
> --- /dev/null
> +++ b/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
> @@ -0,0 +1,41 @@
> +/** @file
> +  Header file for FSP-M Arch Config PPI
> +
> + @copyright
> +  Copyright (c) 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.
> +
> +**/
> +
> +#ifndef _FSPM_ARCH_CONFIG_PPI_H_
> +#define _FSPM_ARCH_CONFIG_PPI_H_
> +
> +///
> +/// Global ID for the FSPM_ARCH_CONFIG_PPI.
> +///
> +#define FSPM_ARCH_CONFIG_GUID \
> +  { \
> +0x824d5a3a, 0xaf92, 0x4c0c, { 0x9f, 0x19, 0x19, 0x52, 0x6d, 0xca, 
> +0x4a, 0xbb } \
> +  }
> +
> +///
> +/// This PPI provides FSP-M Arch Config PPI.

How about adding more description about this PPI is used for dispatch mode?

> +///
> +typedef struct {
> +  UINT8 Revision;
> +  UINT8 Reserved[3];
> +  VOID  *NvsBufferPtr;
> +  UINT32BootLoaderTolumSize;
> +  UINT8 Reserved1[8];
> +} FSPM_ARCH_CONFIG_PPI;

Could the definition be aligned with FSPM_ARCH_UPD in 
IntelFsp2Pkg\Include\FspEas\FspApi.h? Then we can use typedef to define it like 
below.

typedef FSPM_ARCH_UPD FSPM_ARCH_CONFIG_PPI;

Otherwise, please add description for the fields like FSPM_ARCH_UPD did.


Thanks,
Star

> +
> +extern EFI_GUID gFspmArchConfigPpiGuid;
> +
> +#endif // _FSPM_ARCH_CONFIG_PPI_H_
> diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dec 
> b/IntelFsp2Pkg/IntelFsp2Pkg.dec index 50496241da..de1bece562 100644
> --- a/IntelFsp2Pkg/IntelFsp2Pkg.dec
> +++ b/IntelFsp2Pkg/IntelFsp2Pkg.dec
> @@ -70,6 +70,9 @@
> gFspPerformanceDataGuid   = { 0x56ed21b6, 0xba23, 0x429e, { 
> 0x89, 0x32, 0x37, 0x6d, 0x8e, 0x18, 0x2e, 0xe3 } }
> gFspEventEndOfFirmwareGuid= { 0xbd44f629, 0xeae7, 0x4198, { 
> 0x87, 0xf1, 0x39, 0xfa, 0xb0, 0xfd, 0x71, 0x7e } }
>   
> +[Ppis]
> +  gFspmArchConfigPpiGuid= { 0x824d5a3a, 0xaf92, 0x4c0c, { 
> 0x9f, 0x19, 0x19, 0x52, 0x6d, 0xca, 0x4a, 0xbb } }
> +
>   [PcdsFixedAtBuild]
> gIntelFsp2PkgTokenSpaceGuid.PcdGlobalDataPointerAddress 
> |0xFED00108|UINT32|0x0001
> gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase 
> |0xFEF0|UINT32|0x10001001
> 

___
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


Re: [edk2] [PATCH v2 04/11] MdePkg/Include: Add StandaloneMmServicesTableLib library

2019-01-14 Thread Ard Biesheuvel
On Sun, 13 Jan 2019 at 13:42, Cohen, Eugene  wrote:
>
> I saw this thread earlier this week and wanted to chime in.
>
> > > Also, there are some other pieces missing (which I mentioned in one of
> > > the other threads but I suppose you may not have caught up yet):
> > > EndOfDxe (as well as some other PI defined events) needs to be
> > > signalled to the standalone MM context by some non-MM agent, and I
> > > think there are other parts of the traditional SMM IPL that have not
> > > been ported to standalone MM yet.
>
> I haven't been following closely the state of StandaloneMmPkg on edk2  - as 
> we were ready to sync up some of our earlier MM stuff to edk2 I learned that 
> the support in place is only partial as patches have been coming in slowly so 
> we chose to implement a version based on the early joint prototype work we 
> did ("uefiproto" repo).  In this there is a DXE component that produces the 
> SMM Communication protocol and also ensures that when key GUIDed events occur 
> in DXE that they are forwarded to MM including EndOfDxe.
>
> I don't see a strong argument for not forwarding the event signaling 
> information to MM - MM can either use the information or ignore it as it sees 
> fit.  I can see scenarios around variable services where knowing what phase 
> of boot the normal world is in is necessary.
>

I agree. If the normal world firmware is guaranteed to signal EndOfDxe
before loading any third party modules, it is not unreasonable to use
this on the secure side as a trust indicator as well.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/5] ArmPkg/ArmMmuLib AARCH64: fix out of bounds access

2019-01-14 Thread Ard Biesheuvel
On Mon, 14 Jan 2019 at 13:00, Leif Lindholm  wrote:
>
> On Mon, Jan 07, 2019 at 08:15:00AM +0100, Ard Biesheuvel wrote:
> > Take care not to dereference BlockEntry if it may be pointing past
> > the end of the page table we are manipulating. It is only a read,
> > and thus harmless, but HeapGuard triggers on it so let's fix it.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
>
> Reviewed-by: Leif Lindholm 
>

Thanks

Pushed as d08575759e5a..76c23f9e0d0d

> > ---
> >  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c 
> > b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > index e41044142ef4..d66df3e17a02 100644
> > --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > @@ -382,7 +382,7 @@ UpdateRegionMapping (
> >
> >// Break the inner loop when next block is a table
> >// Rerun GetBlockEntryListFromAddress to avoid page table memory leak
> > -  if (TableLevel != 3 &&
> > +  if (TableLevel != 3 && BlockEntry <= LastBlockEntry &&
> >(*BlockEntry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY) {
> >  break;
> >}
> > --
> > 2.20.1
> >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] ArmPkg/ArmMmuLib ARM: disregard high memory when setting permissions

2019-01-14 Thread Ard Biesheuvel
On Mon, 14 Jan 2019 at 12:43, Leif Lindholm  wrote:
>
> On Mon, Jan 07, 2019 at 07:56:49AM +0100, Ard Biesheuvel wrote:
> > Ignore calls to ArmSetMemoryAttributes () when the region described
> > is outside of the 32-bit addressable range. This memory is not
> > mapped in the first place, and the current code does not deal with
> > the high bits correctly, resulting in hangs.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
>
> Reviewed-by: Leif Lindholm 
>

Thanks

Pushed as e695e44545b4..d08575759e5a

> > ---
> >  ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 4 
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c 
> > b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> > index 3b3b20aa9b78..bffab83d4fd0 100644
> > --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> > +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> > @@ -744,6 +744,10 @@ ArmSetMemoryAttributes (
> >UINT64ChunkLength;
> >BOOLEAN   FlushTlbs;
> >
> > +  if (BaseAddress > (UINT64)MAX_ADDRESS - Length + 1) {
> > +return EFI_UNSUPPORTED;
> > +  }
> > +
> >if (Length == 0) {
> >  return EFI_SUCCESS;
> >}
> > --
> > 2.20.1
> >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms 6/8] Silicon/SynQuacer/Stage2Tables: fix 32-bit build

2019-01-14 Thread Ard Biesheuvel
On Mon, 14 Jan 2019 at 18:02, Ard Biesheuvel  wrote:
>
> The static stage2 page tables don't contain any code, but we are
> relying on the linker to resolve the references to the next level
> tables, so we can only use native word size quantities. So add a
> CPP macro to emit the same quantity in different ways.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S | 12 +---

The 'elf64-little' in the .inf is now wrong as well, but it seems I
can just remove that and objcopy will detect the input format.

>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S 
> b/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
> index af55f27bca47..28c7a6ac970f 100644
> --- a/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
> +++ b/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
> @@ -32,6 +32,12 @@
>  #define TT_S2_L3_PAGE   (0x1 << 1)
>  #define TT_S2_VALID (0x1 << 0)
>
> +#ifdef __aarch64__
> +#define QWORD(x).quad (x)
> +#else
> +#define QWORD(x).long (x), 0
> +#endif
> +
>.altmacro
>.macrofor, start, count, do, arg2, arg3, arg4
>.if   \count == 1
> @@ -69,7 +75,7 @@
>.section  ".rodata", "a", %progbits
>/* level 1 */
>s2_mem_entry  0  /* 0x_ - 0x3fff_ */
> -  .quad   1f + TT_S2_TABLE /* 0x4000_ - 0x7fff_ */
> +  QWORD   (1f + TT_S2_TABLE) /* 0x4000_ - 0x7fff_ */
>for   2, 246, s2_mem_entry  /* 0x8000_ - 0x3d__ */
>for 248,   8, s2_dev_entry  /* PCIe MMIO64 */
>for 256, 768, s2_mem_entry  /* 0x40__ - 0xff__ */
> @@ -77,12 +83,12 @@
>/* level 2 */
>  1:for 0, 256, s2_mem_entry, 21, 0x4000, 1
>
> -  .quad   2f + TT_S2_TABLE /* 0x6000_ -> RC #0 bus 0 */
> +  QWORD   (2f + TT_S2_TABLE) /* 0x6000_ -> RC #0 bus 0 */
>for 1, 15, s2_mem_entry, 21, 0x6000
>for 0, 48, s2_mem_entry, 21, 0x6200, 1
>for 0, 64, s2_dev_entry, 21, 0x6800, 1 /* PCIe MMIO32 */
>
> -  .quad   3f + TT_S2_TABLE /* 0x7000_ -> RC #1 bus 0 */
> +  QWORD   (3f + TT_S2_TABLE) /* 0x7000_ -> RC #1 bus 0 */
>for 1, 15, s2_mem_entry, 21, 0x7000
>for 0, 48, s2_mem_entry, 21, 0x7200, 1
>for 0, 64, s2_dev_entry, 21, 0x7800, 1 /* PCIe MMIO32 */
> --
> 2.17.1
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms] Platform/Intel/MinPlatformPkg: add MmServicesTableLib resolution

2019-01-14 Thread Ard Biesheuvel
Ensure that the platform will still build when we move the upstream
FTW and variable SMM runtime drivers to use the new MmServiceTableLib
library class.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc 
b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
index 1103572408d0..1ed3591f360a 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
+++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
@@ -77,6 +77,7 @@ [LibraryClasses.common.UEFI_DRIVER]
 [LibraryClasses.common.DXE_SMM_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   
ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
   
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
-- 
2.17.1

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


Re: [edk2] [edk2-announce] Community Meeting Minutes

2019-01-14 Thread stephano

On 1/12/2019 7:59 PM, Rebecca Cran wrote:


I wonder if we might want to have a separate mailing list for reviews?

I find it a bit overwhelming having both patches and more general discussions
on the same list, since I only check it every few days.



My original thought was to add "edk2-announce" as a separate mailing 
list and keep the number of lists at 2 until we determine that more 
granularity is needed. While we decide on a new platform it was agreed 
(at the steward's meeting) that simply appending "edk2-announce" would 
suffice for now.


I have been trying out Groups.io and so far things look very promising:

https://edk2.groups.io/g/main

I added 2 subgroups: announce and devel. This allows us to keep 
community wide announcements (like this thread) separate from patch 
discussions. If we think that more granularity is needed (e.g. 
"architecture" for design discussions) we can discuss those possibilities.


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


Re: [edk2] [PATCH v2] BaseTools/tools_def GCC5: disable LTO for ASLC invocations

2019-01-14 Thread Ard Biesheuvel
On Mon, 14 Jan 2019 at 15:10, Gao, Liming  wrote:
>
> Reviewed-by: Liming Gao 
>

Pushed as 17f5fd9291e0..e695e44545b4

Thanks all

> > -Original Message-
> > From: Philippe Mathieu-Daudé [mailto:phi...@redhat.com]
> > Sent: Monday, January 14, 2019 10:09 PM
> > To: Ard Biesheuvel ; Gao, Liming 
> > ; edk2-devel@lists.01.org
> > Cc: leif.lindh...@linaro.org
> > Subject: Re: [PATCH v2] BaseTools/tools_def GCC5: disable LTO for ASLC 
> > invocations
> >
> > On 1/14/19 3:04 PM, Ard Biesheuvel wrote:
> > > GCC for 32-bit ARM chokes on .aslc files when running with LTO
> > > enabled. Since LTO has no benefit whatsoever here, just disable
> > > it globally for GCC5 and up when building .aslc files.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Ard Biesheuvel 
> > > Reviewed-by: Leif Lindholm 
> >
> > Reviewed-by: Philippe Mathieu-Daudé 
> >
> > > ---
> > >  BaseTools/Conf/tools_def.template | 27 +++-
> > >  1 file changed, 15 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/BaseTools/Conf/tools_def.template 
> > > b/BaseTools/Conf/tools_def.template
> > > index 4d74816837ab..2bd098287219 100755
> > > --- a/BaseTools/Conf/tools_def.template
> > > +++ b/BaseTools/Conf/tools_def.template
> > > @@ -4155,6 +4155,7 @@ DEFINE GCC48_AARCH64_DLINK_FLAGS = 
> > > DEF(GCC_AARCH64_DLINK_FLAGS)
> > >  DEFINE GCC48_AARCH64_DLINK2_FLAGS= DEF(GCC_DLINK2_FLAGS_COMMON) 
> > > -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
> > >  DEFINE GCC48_ARM_ASLDLINK_FLAGS  = DEF(GCC_ARM_ASLDLINK_FLAGS) 
> > > -Wl,--oformat=elf32-littlearm
> > >  DEFINE GCC48_AARCH64_ASLDLINK_FLAGS  = DEF(GCC_AARCH64_ASLDLINK_FLAGS)
> > > +DEFINE GCC48_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
> > >
> > >  DEFINE GCC49_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS)
> > >  DEFINE GCC49_X64_CC_FLAGS= DEF(GCC48_X64_CC_FLAGS)
> > > @@ -4177,6 +4178,7 @@ DEFINE GCC49_AARCH64_DLINK_FLAGS = 
> > > DEF(GCC48_AARCH64_DLINK_FLAGS) -z common-
> > >  DEFINE GCC49_AARCH64_DLINK2_FLAGS= DEF(GCC48_AARCH64_DLINK2_FLAGS)
> > >  DEFINE GCC49_ARM_ASLDLINK_FLAGS  = DEF(GCC48_ARM_ASLDLINK_FLAGS)
> > >  DEFINE GCC49_AARCH64_ASLDLINK_FLAGS  = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
> > > +DEFINE GCC49_ASLCC_FLAGS = DEF(GCC48_ASLCC_FLAGS)
> > >
> > >  DEFINE GCC5_IA32_CC_FLAGS= DEF(GCC49_IA32_CC_FLAGS) -fno-pic 
> > > -fno-pie
> > >  DEFINE GCC5_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS)
> > > @@ -4199,6 +4201,7 @@ DEFINE GCC5_AARCH64_DLINK_FLAGS  = 
> > > DEF(GCC49_AARCH64_DLINK_FLAGS)
> > >  DEFINE GCC5_AARCH64_DLINK2_FLAGS = DEF(GCC49_AARCH64_DLINK2_FLAGS) 
> > > -Wno-error
> > >  DEFINE GCC5_ARM_ASLDLINK_FLAGS   = DEF(GCC49_ARM_ASLDLINK_FLAGS)
> > >  DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
> > > +DEFINE GCC5_ASLCC_FLAGS  = DEF(GCC49_ASLCC_FLAGS) -fno-lto
> > >
> > >  
> > > 
> > >  #
> > > @@ -4301,7 +4304,7 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = 
> > > DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
> > >  *_GCC48_IA32_ASLPP_PATH   = DEF(GCC48_IA32_PREFIX)gcc
> > >  *_GCC48_IA32_RC_PATH  = DEF(GCC48_IA32_PREFIX)objcopy
> > >
> > > -*_GCC48_IA32_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m32
> > > +*_GCC48_IA32_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS) -m32
> > >  *_GCC48_IA32_ASLDLINK_FLAGS   = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) 
> > > -Wl,-m,elf_i386
> > >  *_GCC48_IA32_ASM_FLAGS= DEF(GCC48_ASM_FLAGS) -m32 -march=i386
> > >  *_GCC48_IA32_DLINK_FLAGS  = DEF(GCC48_IA32_X64_DLINK_FLAGS) 
> > > -Wl,-m,elf_i386,--oformat=elf32-i386
> > > @@ -4329,7 +4332,7 @@ RELEASE_GCC48_IA32_CC_FLAGS   = 
> > > DEF(GCC48_IA32_CC_FLAGS) -Os -Wno-unused-but
> > >  *_GCC48_X64_ASLPP_PATH   = DEF(GCC48_X64_PREFIX)gcc
> > >  *_GCC48_X64_RC_PATH  = DEF(GCC48_X64_PREFIX)objcopy
> > >
> > > -*_GCC48_X64_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m64
> > > +*_GCC48_X64_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS) -m64
> > >  *_GCC48_X64_ASLDLINK_FLAGS   = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) 
> > > -Wl,-m,elf_x86_64
> > >  *_GCC48_X64_ASM_FLAGS= DEF(GCC48_ASM_FLAGS) -m64
> > >  *_GCC48_X64_DLINK_FLAGS  = DEF(GCC48_X64_DLINK_FLAGS)
> > > @@ -4359,7 +4362,7 @@ RELEASE_GCC48_X64_CC_FLAGS   = 
> > > DEF(GCC48_X64_CC_FLAGS) -Os -Wno-unused-but-s
> > >  *_GCC48_ARM_ARCHCC_FLAGS = -mthumb
> > >  *_GCC48_ARM_PLATFORM_FLAGS   = -march=armv7-a
> > >
> > > -*_GCC48_ARM_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
> > > +*_GCC48_ARM_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS)
> > >  *_GCC48_ARM_ASLDLINK_FLAGS   = DEF(GCC48_ARM_ASLDLINK_FLAGS)
> > >  *_GCC48_ARM_ASM_FLAGS= DEF(GCC48_ARM_ASM_FLAGS)
> > >  *_GCC48_ARM_DLINK_FLAGS  = DEF(GCC48_ARM_DLINK_FLAGS)
> > > @@ -4389,7 +4392,7 @@ RELEASE_GCC48_ARM_CC_FLAGS   

Re: [edk2] [PATCH v2 02/17] OvmfPkg: add MmServicesTableLib resolution

2019-01-14 Thread Ard Biesheuvel
On Mon, 14 Jan 2019 at 17:40, Laszlo Ersek  wrote:
>
> On 01/14/19 14: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 various OvmfPkg .dsc files.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >  OvmfPkg/OvmfPkgIa32.dsc| 1 +
> >  OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
> >  OvmfPkg/OvmfPkgX64.dsc | 1 +
> >  3 files changed, 3 insertions(+)
> >
> > diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> > index 3f3533e5c163..aee19b75d7ae 100644
> > --- a/OvmfPkg/OvmfPkgIa32.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32.dsc
> > @@ -385,6 +385,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
> >
> > ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
> >HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> >SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> > +  
> > MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >
> > SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >  !ifdef $(DEBUG_ON_SERIAL_PORT)
> >DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> > index 6c08b2728d63..90cbd8e34158 100644
> > --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> > @@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
> >
> > ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
> >HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> >SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> > +  
> > MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >
> > SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >  !ifdef $(DEBUG_ON_SERIAL_PORT)
> >DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> > diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> > index 4072c839d73f..83d16eb00b82 100644
> > --- a/OvmfPkg/OvmfPkgX64.dsc
> > +++ b/OvmfPkg/OvmfPkgX64.dsc
> > @@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
> >
> > ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
> >HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> >SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> > +  
> > MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >
> > SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >  !ifdef $(DEBUG_ON_SERIAL_PORT)
> >DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> >
>
> Reviewed-by: Laszlo Ersek 
>

Thanks.

> Also, because this patch is clearly equivalent (although not textually
> identical) to the one I used in
> <0d229de3-623a-1062-1daf-cce5dec14824@redhat.com">http://mid.mail-archive.com/0d229de3-623a-1062-1daf-cce5dec14824@redhat.com>,
> I believe we should add:
>
> Regression-tested-by: Laszlo Ersek 
>

OK.

> (From the blurb, I sought to familiarize myself with the anatomy of this
> v2 series, and after checking my R-t-b on patches v2 05/17 and v2 07/17,
> I think v2 02/17 -- i.e., this patch -- is the only one where my review
> is required. Please correct me if I'm wrong.)
>

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


[edk2] [PATCH edk2-platforms 6/8] Silicon/SynQuacer/Stage2Tables: fix 32-bit build

2019-01-14 Thread Ard Biesheuvel
The static stage2 page tables don't contain any code, but we are
relying on the linker to resolve the references to the next level
tables, so we can only use native word size quantities. So add a
CPP macro to emit the same quantity in different ways.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S 
b/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
index af55f27bca47..28c7a6ac970f 100644
--- a/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
+++ b/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
@@ -32,6 +32,12 @@
 #define TT_S2_L3_PAGE   (0x1 << 1)
 #define TT_S2_VALID (0x1 << 0)
 
+#ifdef __aarch64__
+#define QWORD(x).quad (x)
+#else
+#define QWORD(x).long (x), 0
+#endif
+
   .altmacro
   .macrofor, start, count, do, arg2, arg3, arg4
   .if   \count == 1
@@ -69,7 +75,7 @@
   .section  ".rodata", "a", %progbits
   /* level 1 */
   s2_mem_entry  0  /* 0x_ - 0x3fff_ */
-  .quad   1f + TT_S2_TABLE /* 0x4000_ - 0x7fff_ */
+  QWORD   (1f + TT_S2_TABLE) /* 0x4000_ - 0x7fff_ */
   for   2, 246, s2_mem_entry  /* 0x8000_ - 0x3d__ */
   for 248,   8, s2_dev_entry  /* PCIe MMIO64 */
   for 256, 768, s2_mem_entry  /* 0x40__ - 0xff__ */
@@ -77,12 +83,12 @@
   /* level 2 */
 1:for 0, 256, s2_mem_entry, 21, 0x4000, 1
 
-  .quad   2f + TT_S2_TABLE /* 0x6000_ -> RC #0 bus 0 */
+  QWORD   (2f + TT_S2_TABLE) /* 0x6000_ -> RC #0 bus 0 */
   for 1, 15, s2_mem_entry, 21, 0x6000
   for 0, 48, s2_mem_entry, 21, 0x6200, 1
   for 0, 64, s2_dev_entry, 21, 0x6800, 1 /* PCIe MMIO32 */
 
-  .quad   3f + TT_S2_TABLE /* 0x7000_ -> RC #1 bus 0 */
+  QWORD   (3f + TT_S2_TABLE) /* 0x7000_ -> RC #1 bus 0 */
   for 1, 15, s2_mem_entry, 21, 0x7000
   for 0, 48, s2_mem_entry, 21, 0x7200, 1
   for 0, 64, s2_dev_entry, 21, 0x7800, 1 /* PCIe MMIO32 */
-- 
2.17.1

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


[edk2] [PATCH edk2-platforms 2/8] Silicon/SynQuacer/OpteeRngDxe: fix 32-bit build

2019-01-14 Thread Ard Biesheuvel
Replace a UINT64 cast of a virtual address with a UINTN cast so
that this driver can be built for 32-bit ARM as well.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c 
b/Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c
index 089fad8b5ce5..e55d87ea4299 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c
@@ -159,7 +159,7 @@ GetRNG (
 InvokeFunctionArg.Params[0].Attribute =
   OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT;
 InvokeFunctionArg.Params[0].Union.Memory.BufferAddress =
-  (UINT64) OutPointer;
+  (UINTN) OutPointer;
 InvokeFunctionArg.Params[0].Union.Memory.Size = ValueLength;
 
 Status = OpteeInvokeFunction ();
-- 
2.17.1

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


[edk2] [PATCH edk2-platforms 7/8] Platform/Socionext/DeveloperBox: disable EbcDxe for ARM builds

2019-01-14 Thread Ard Biesheuvel
EBC and 32-bit ARM are fundamentally incompatible, so only enable
it on AArch64 builds.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 4 +++-
 Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc 
b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
index e6922fa3880b..beacd02adcc6 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -333,7 +333,6 @@ [Components.common]
   }
   MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
   MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
-  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
   
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
   Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.inf
   MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf
@@ -462,3 +461,6 @@ [Components.common]
   }
 
   Platform/Socionext/DeveloperBox/OsInstallerMenuDxe/OsInstallerMenuDxe.inf
+
+[Components.AARCH64]
+  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf 
b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
index f52bec60b928..bc9ed30fb0d2 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
@@ -157,7 +157,9 @@ [FV.FvMain]
   INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
   INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
   INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+!if $(ARCH) == AARCH64
   INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
+!endif
   INF 
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
   INF MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf
 
-- 
2.17.1

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


[edk2] [PATCH edk2-platforms 8/8] Platform/Socionext/DeveloperBox: add resolution for ArmSoftFloatLib

2019-01-14 Thread Ard Biesheuvel
OpensslLib depends on ArmSoftFloatLib when built for 32-bit ARM, so
add the required resolution for it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc 
b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
index beacd02adcc6..e09c58d2dffa 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -40,6 +40,9 @@ [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_ARM_DLINK_FLAGS = -z common-page-size=0x1000
   GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x1
 
+[LibraryClasses.ARM]
+ ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
+
 [LibraryClasses.common.SEC]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
-- 
2.17.1

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


[edk2] [PATCH edk2-platforms 3/8] Silicon/SynQuacerPciHostBridgeLib: fix MMIO32-only configuration

2019-01-14 Thread Ard Biesheuvel
When running on 32-bit ARM, we cannot decode the MMIO64 region, and
so we don't set the EFI_PCI_HOST_BRIDGE_MEM64_DECODE flag in this
case. However, with that flag cleared, it is no longer permitted to
include a definition for the placement of the MMIO64 region either,
so remove those as well if MDE_CPU_ARM is set (which is the same
condition under which EFI_PCI_HOST_BRIDGE_MEM64_DECODE is cleared)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 
Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c
 | 8 
 1 file changed, 8 insertions(+)

diff --git 
a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c
 
b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c
index 7c096f0801dd..117cf6cfd81b 100644
--- 
a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c
+++ 
b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.c
@@ -109,8 +109,12 @@ PCI_ROOT_BRIDGE mPciRootBridges[] = {
 { SYNQUACER_PCI_SEG0_MMIO32_MIN,
   SYNQUACER_PCI_SEG0_MMIO32_MAX,
   MAX_UINT64 - SYNQUACER_PCI_SEG0_MMIO32_XLATE + 1 },// Mem
+#ifndef MDE_CPU_ARM
 { SYNQUACER_PCI_SEG0_MMIO64_MIN,
   SYNQUACER_PCI_SEG0_MMIO64_MAX },  // MemAbove4G
+#else
+{ MAX_UINT64, 0x0 },// MemAbove4G
+#endif
 { MAX_UINT64, 0x0 },// PMem
 { MAX_UINT64, 0x0 },// PMemAbove4G
 (EFI_DEVICE_PATH_PROTOCOL *)[0]
@@ -130,8 +134,12 @@ PCI_ROOT_BRIDGE mPciRootBridges[] = {
 { SYNQUACER_PCI_SEG1_MMIO32_MIN,
   SYNQUACER_PCI_SEG1_MMIO32_MAX,
   MAX_UINT64 - SYNQUACER_PCI_SEG1_MMIO32_XLATE + 1 },// Mem
+#ifndef MDE_CPU_ARM
 { SYNQUACER_PCI_SEG1_MMIO64_MIN,
   SYNQUACER_PCI_SEG1_MMIO64_MAX },  // MemAbove4G
+#else
+{ MAX_UINT64, 0x0 },// MemAbove4G
+#endif
 { MAX_UINT64, 0x0 },// PMem
 { MAX_UINT64, 0x0 },// PMemAbove4G
 (EFI_DEVICE_PATH_PROTOCOL *)[1]
-- 
2.17.1

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


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

2019-01-14 Thread Ard Biesheuvel
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

 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


[edk2] [PATCH edk2-platforms 4/8] Silicon/SynQuacerMemoryInitPeiLib: don't map memory above MAX_ALLOC_ADDRESS

2019-01-14 Thread Ard Biesheuvel
When encountering memory that is above the threshold of what we can
map, don't add it to the virtual memory table. This table is only
used by the early MMU code that creates the 1:1 mapping, and since
it cannot be mapped in the first place, there is no point.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 
Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
 | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
 
b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
index 1402ecafce4a..3955b6df84a0 100644
--- 
a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
+++ 
b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
@@ -156,17 +156,22 @@ DeclareDram (
 
   DramDescriptor = *VirtualMemoryTable + ARRAY_SIZE (mVirtualMemoryTable);
 
-  for (Idx = 0; Idx < RegionCount; Idx++, DramDescriptor++) {
+  for (Idx = 0; Idx < RegionCount; Idx++) {
 Status = DramInfo->GetRegion (Idx, , );
 ASSERT_EFI_ERROR (Status);
 
 BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY,
   mDramResourceAttributes, Base, Size);
 
+if (Base > MAX_ALLOC_ADDRESS - Size + 1) {
+  continue;
+}
+
 DramDescriptor->PhysicalBase = Base;
 DramDescriptor->VirtualBase  = Base;
-DramDescriptor->Length   = Size;
+DramDescriptor->Length   = MIN (Size, MAX_ALLOC_ADDRESS - Base + 1);
 DramDescriptor->Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
+DramDescriptor++;
   }
 
   DramDescriptor->PhysicalBase = 0;
-- 
2.17.1

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


[edk2] [PATCH edk2-platforms 5/8] Silicon/SynQuacerMemoryInitPeiLib: fix 32-bit build

2019-01-14 Thread Ard Biesheuvel
Add a missing intermediate UINTN case to fix the 32-bit build.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 
Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
 
b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
index 3955b6df84a0..19151b93d571 100644
--- 
a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
+++ 
b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
@@ -201,7 +201,7 @@ CheckCapsule (
 // Coalesce the capsule into unused memory. CreateState() below will copy
 // it to a properly allocated buffer.
 //
-*CapsuleBuffer = (VOID *)PcdGet64 (PcdSystemMemoryBase);
+*CapsuleBuffer = (VOID *)(UINTN)PcdGet64 (PcdSystemMemoryBase);
 *CapsuleBufferLength = UefiMemoryBase - PcdGet64 (PcdSystemMemoryBase);
 
 PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE);
-- 
2.17.1

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


[edk2] [PATCH edk2-platforms 1/8] Silicon/SynQuacer/NetsecDxe: fix 32-bit build

2019-01-14 Thread Ard Biesheuvel
Tweak the definition of pfdep_cpu_addr_t and add some intermediate
UINTN casts so that the NETSEC driver builds cleanly in 32-bit mode.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c | 6 
+++---
 Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h | 2 
+-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
index fa8ae79da28e..1bf1b3cb8f05 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
@@ -103,9 +103,9 @@ Probe (
   ogma_err = ogma_init (
(VOID *)(UINTN)LanDriver->Dev->Resources[0].AddrRangeMin,
Handle, ,
-   (VOID *)dmac_hm_cmd_base, dmac_hm_cmd_size,
-   (VOID *)dmac_mh_cmd_base, dmac_mh_cmd_size,
-   (VOID *)core_cmd_base, core_cmd_size,
+   (VOID *)(UINTN)dmac_hm_cmd_base, dmac_hm_cmd_size,
+   (VOID *)(UINTN)dmac_mh_cmd_base, dmac_mh_cmd_size,
+   (VOID *)(UINTN)core_cmd_base, core_cmd_size,
>Handle);
   if (ogma_err != OGMA_ERR_OK) {
 DEBUG ((DEBUG_ERROR, "NETSEC: ogma_init() failed with error code %d\n",
diff --git 
a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h
index d31a9c48bafc..95796b4cfe6a 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h
+++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/pfdep.h
@@ -71,7 +71,7 @@ typedef struct {
 typedef VOID *pfdep_dev_handle_t;
 typedef PACKET_HANDLE *pfdep_pkt_handle_t;
 typedef EFI_PHYSICAL_ADDRESS pfdep_phys_addr_t;
-typedef UINT64 pfdep_cpu_addr_t;
+typedef UINTN pfdep_cpu_addr_t;
 
 typedef int pfdep_hard_lock_t;
 typedef int pfdep_soft_lock_t;
-- 
2.17.1

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


Re: [edk2] [PATCH v2 02/17] OvmfPkg: add MmServicesTableLib resolution

2019-01-14 Thread Laszlo Ersek
On 01/14/19 14: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 various OvmfPkg .dsc files.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
>  OvmfPkg/OvmfPkgX64.dsc | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 3f3533e5c163..aee19b75d7ae 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -385,6 +385,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
>
> ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
>HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>  !ifdef $(DEBUG_ON_SERIAL_PORT)
>DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 6c08b2728d63..90cbd8e34158 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
>
> ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
>HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>  !ifdef $(DEBUG_ON_SERIAL_PORT)
>DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 4072c839d73f..83d16eb00b82 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
>
> ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
>HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>  !ifdef $(DEBUG_ON_SERIAL_PORT)
>DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> 

Reviewed-by: Laszlo Ersek 

Also, because this patch is clearly equivalent (although not textually
identical) to the one I used in
<0d229de3-623a-1062-1daf-cce5dec14824@redhat.com">http://mid.mail-archive.com/0d229de3-623a-1062-1daf-cce5dec14824@redhat.com>,
I believe we should add:

Regression-tested-by: Laszlo Ersek 

(From the blurb, I sought to familiarize myself with the anatomy of this
v2 series, and after checking my R-t-b on patches v2 05/17 and v2 07/17,
I think v2 02/17 -- i.e., this patch -- is the only one where my review
is required. Please correct me if I'm wrong.)

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


Re: [edk2] [PATCH] IntelSiliconPkg\Include\IndustryStandard: Update IGD_OPREGION_MBOX3 Structure

2019-01-14 Thread Chaganty, Rangasai V
Please add the spec revision in the comment that introduced this change. Also 
if the spec has provided any additional details or rationale, please add the 
summary to justify this change.

Thanks,
Sai

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Digant H 
Solanki
Sent: Monday, January 14, 2019 1:59 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming 
Subject: [edk2] [PATCH] IntelSiliconPkg\Include\IndustryStandard: Update 
IGD_OPREGION_MBOX3 Structure

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1454
Based on latest IGD OpRegion Spec, IGD_OPREGION_MBOX3 needs to be updated with 
two new members : Physical Address of Raw VBT Data (RVDA) and Size of Raw VBT 
Data (RVDS)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Digant H Solanki 
Cc: Liming Gao 
---
 IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h 
b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
index 5ce80a5be8..e1d92717a4 100644
--- a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
+++ b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
@@ -4,9 +4,7 @@
 
   https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf
 
-  @note Fixed bug in the spec Mailbox3 - RM31 size from 0x45(69) to 0x46(70)
-
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 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 @@ -118,7 +116,9 @@ typedef struct {
   UINT64 FDSS;  ///< Offset 0x3AA DSS Buffer address allocated for 
IFFS feature
   UINT32 FDSP;  ///< Offset 0x3B2 Size of DSS buffer
   UINT32 STAT;  ///< Offset 0x3B6 State Indicator
-  UINT8  RM31[0x46];///< Offset 0x3BA - 0x3FF  Reserved Must be zero. Bug 
in spec 0x45(69)
+  UINT64 RVDA;  ///< Offset 0x3BA Physical address of Raw VBT data
+  UINT32 RVDS;  ///< Offset 0x3C2 Size of Raw VBT data
+  UINT8  RM31[0x3A];///< Offset 0x3C6 - 0x3FF  Reserved Must be zero.
 } IGD_OPREGION_MBOX3;
 
 ///
--
2.18.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


Re: [edk2] [edk2-platforms] [PATCH v7 2/2] Platform/ARM: Add Readme.md

2019-01-14 Thread Nariman Poushin
On Fri, Jan 11, 2019 at 05:42:43PM +, Leif Lindholm wrote:
> On Wed, Dec 19, 2018 at 06:01:46PM +, Nariman Poushin wrote:
> > This covers the bulk of the information originally present in
> > https://github.com/tianocore/tianocore.github.io/wiki/ArmPlatformPkg-AArch64
> > regarding building and running the Foundation/Base FVP Platforms.
> > 
> > The sections on fetching source have been delegated to the root Readme.md
> > 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Nariman Poushin 
> 
> I'm going to push this patch because I really don't want to get to v8.
> A few comments below.

You and me both, thanks though, hopefully it moves us forward a bit
by updating the docs.

> 
> > ---
> > 
> > Changes from v6:
> > 
> > - Removed inline html and generally tidied up markdown
> > 
> >  Platform/ARM/Readme.md | 63 
> > ++
> >  Readme.md  |  4 +---
> >  2 files changed, 64 insertions(+), 3 deletions(-)
> >  create mode 100644 Platform/ARM/Readme.md
> > 
> > diff --git a/Platform/ARM/Readme.md b/Platform/ARM/Readme.md
> > new file mode 100644
> > index 000..ac86e95
> > --- /dev/null
> > +++ b/Platform/ARM/Readme.md
> > @@ -0,0 +1,63 @@
> > +# Introduction
> > +
> > +These instructions explain how to get an edk2/edk2-platforms build running
> > +on the ARM Base FVP, which is a software model provided by ARM (for free)
> > +, which models a Cortex A core with various peripherals. More information
> > +can be found here:
> > +[https://developer.arm.com/products/system-design/fixed-virtual-platforms]
> > +
> > +##Requirements
> > +- A 32-bit or 64-bit Linux host machine.
> > +- Visual Studio is not officially supported, experimental support can be 
> > found here:
> > +[https://git.linaro.org/people/leif.lindholm/edk2.git/log/?h=aarch64-vs]
> > +
> > +# Build EDK2 Tianocore
> > +
> > +`cd $(WORKSPACE)/edk2`
> > +
> 
> Dropping above two lines which make assumptions that may not apply for 
> everyone.
> 

Sure thing.

> > +`build -a AARCH64 -p Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc 
> > -t GCC5`
> > +
> > +Once built, the edk2 image is the following file 
> > Build/ArmVExpress-FVP-AArch64/DEBUG_GCC5/FV/FVP_AARCH64_EFI.fd
> > +
> > +# Run edk2/edk2-platforms on the ARM Base Platform FVP
> > +
> > +In order to run the binary we have just built there are a few steps we 
> > need to
> > +go through, we need to get a model, a set of prebuilts (where we will swap 
> > out
> > +the edk2 image with our own) and the tool with which we will swap out the
> > +prebuilt edk2 image.
> > +
> > +We will also rely on the "run_model" script that comes with the prebuilts, 
> > it
> > +is entirely possible to run the model without this but would require quite 
> > a bit
> > +of knowledge regarding the areguments ARM fastmodel (documentation can be 
> > found here:
> > +[https://developer.arm.com/docs/100966/1101/programming-reference-for-base-fvps/base-platform-revc-features])
> > +however the manual set of the FVP is outside the scope of this document. 
> > If you are interested
> > +please consult the documentation.
> > +
> > +It's recommended you create a folder where you download the prebuilts and
> > +required tool and copy your edk2 image in to it, as the run script expects
> > +the binaries in the same directory.
> > +
> > +1. Download the Base FVP from here 
> > https://developer.arm.com/products/system-design/fixed-virtual-platforms
> > +
> > +   - Select Armv8-A Base Platform FVP based on Fast Models 11.4
> > +   - It has a click through license but is free.
> > +
> > +2. Download the 18.10 Linaro ARM Landing Team release for FVP booting UEFI
> > +https://releases.linaro.org/members/arm/platforms/18.10/fvp-uefi.zip
> > +
> > +3. Download the prebuilt fiptool from 
> > https://git.linaro.org/landing-teams/working/arm/prebuilt_tools.git
> > +
> > +4. Update the fip.bin image from fvp-uefi.zip by running the following 
> > command:
> > +
> > +   `fiptool update --nt-fw=[path to binary built above] fip.bin`
> > +
> > +5. Execute the FVP run_model.sh script from fvp-uefi.zip and provide a 
> > path to the FVP binaries
> > +downloaded in step 1):
> > +
> > +   `MODEL=[path to FVP binary] ./run_model.sh`
> > +
> > +This expects the contents of fvp-uefi.zip, the bl1.bin and fip.bin (which 
> > is
> > +the file we modify), to be in the same directory as the run_model.sh 
> > script.
> > +
> > +This should be sufficient to provide a build/run/debug environment for 
> > aarch64.
> > +
> 
> Above line makes the 'file' command call this an "exported SGML
> document". So I'm dropping this too.
> 

Sure.

> > diff --git a/Readme.md b/Readme.md
> > index bb53c6f..86c989f 100644
> > --- a/Readme.md
> > +++ b/Readme.md
> > @@ -206,9 +206,7 @@ they will be documented with the platform.
> >  * [Overdrive](Platform/AMD/OverdriveBoard)
> >  * [Overdrive 1000](Platform/SoftIron/Overdrive1000Board)
> >  
> > -## ARM
> > -* 

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

2019-01-14 Thread Gao, Liming
Got it. I will update the commit message with the warning message "equality 
comparison with extraneous parentheses".

Thanks
Liming
> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Monday, January 14, 2019 10:36 PM
> To: Gao, Liming ; edk2-devel@lists.01.org
> Subject: Re: [edk2] [Patch] BaseTools GenFw: Fix XCODE5 build issue
> 
> On 01/14/19 14:52, Liming Gao wrote:
> > Remove extraneous parentheses around the comparison to silence this warning.
> 
> Can you please quote the warning message in the commit message? It's
> unclear what warning the commit message refers to. (No need to repost
> just for this.)
> 
> Thanks
> Laszlo
> 
> > 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/GenFw/GenFw.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/BaseTools/Source/C/GenFw/GenFw.c 
> > b/BaseTools/Source/C/GenFw/GenFw.c
> > index 37278bbc68..af2c909866 100644
> > --- a/BaseTools/Source/C/GenFw/GenFw.c
> > +++ b/BaseTools/Source/C/GenFw/GenFw.c
> > @@ -1014,7 +1014,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;
> > @@ -2180,7 +2180,7 @@ Returns:
> >// Set new base address into image
> >//
> >if (mOutImageType == FW_REBASE_IMAGE || mOutImageType == 
> > FW_SET_ADDRESS_IMAGE) {
> > -if ((PeHdr->Pe32.OptionalHeader.Magic == 
> > EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
> > +if (PeHdr->Pe32.OptionalHeader.Magic == 
> > EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
> >if (NewBaseAddress >= 0x1ULL) {
> >  Error (NULL, 0, 3000, "Invalid", "New base address is larger than 
> > 4G for 32bit PE image");
> >  goto Finish;
> >

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


Re: [edk2] [PATCH 0/6] implement standalone MM versions of the variable runtime drivers

2019-01-14 Thread Gao, Liming
Ard:
  Got it. I will update our internal platform dsc to include new 
MmServicesTableLib library.

  Besides, will you send the patch to update platform DSC files in 
edk2-platforms? If yes, please update DSCs in 
https://github.com/tianocore/edk2-platforms/tree/devel-MinPlatform. They both 
depend on edk2 master. 

Thanks
Liming
> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Monday, January 14, 2019 4:27 PM
> To: Gao, Liming 
> Cc: edk2-devel@lists.01.org; Laszlo Ersek ; Leif Lindholm 
> ; Kinney, Michael D
> ; Wang, Jian J ; Wu, Hao A 
> ; Jagadeesh Ujja
> ; Achin Gupta ; Thomas 
> Panakamattam Abraham ;
> Sami Mujawar 
> Subject: Re: [PATCH 0/6] implement standalone MM versions of the variable 
> runtime drivers
> 
> On Mon, 14 Jan 2019 at 03:55, Gao, Liming  wrote:
> >
> > Ard:
> >   I don't find the function issue in this patch. I have no other comments 
> > for the change in MdePkg. Reviewed-by: Liming Gao
> . For this patch set, if you push the change, please 
> push the patches in MdePkg first, and tell me the revision. I
> will update our internal platform DSC to include new MmServicesTableLib 
> library instance. After I am done, I will let you know. Then,
> you can continue to push the change in MdeModulePkg. Is it OK?
> >
> 
> Yes, that is fine. I will need to respin the remaining patches anyway.
> 
> I have pushed the following patches
> 
> b94aecb4ec94 MdePkg/Include: add MmServicesTableLib header file
> 17f5fd9291e0 MdePkg: implement MmServicesTableLib based on traditional SMM
> 
> with Star's and Jian's feedback addressed, and your R-b's added.
> 
> 
> >   I see you will continue to look add MmStandaloneEntryPointLib and 
> > MmServiceLib for MmStandalone driver. You can create
> another BZ for it. I will review them once you are done.
> >
> 
> OK.
> 
> > >-Original Message-
> > >From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> > >Sent: Wednesday, January 09, 2019 11:30 PM
> > >To: Gao, Liming 
> > >Cc: edk2-devel@lists.01.org; Laszlo Ersek ; Leif 
> > >Lindholm
> > >; Kinney, Michael D ;
> > >Wang, Jian J ; Wu, Hao A ;
> > >Jagadeesh Ujja ; Achin Gupta
> > >; Thomas Panakamattam Abraham
> > >; Sami Mujawar 
> > >Subject: Re: [PATCH 0/6] implement standalone MM versions of the variable
> > >runtime drivers
> > >
> > >On Wed, 9 Jan 2019 at 14:56, Gao, Liming  wrote:
> > >>
> > >> Ard:
> > >>   Now, the impact is to update platform DSC to include MmServicesTableLib
> > >library instance. This change is acceptable for me. I suggest your create 
> > >one BZ
> > >for this patch set.
> > >
> > >https://bugzilla.tianocore.org/show_bug.cgi?id=1442
> > >
> > >>   Besides, I can't apply for these patches in my machine. Could you 
> > >> share git
> > >branch to me? Then, I can further verify its functionality on SMM mode.
> > >>
> > >
> > >https://github.com/ardbiesheuvel/edk2/tree/variable-ftw-standalone-mm-
> > >conversion
> > >
> > >Note that I included the changes to add the MmServicesTableLib
> > >resolution to consumers of the FTW and variable drivers.
> > >
> > >Thanks,
> > >Ard.
> > >
> > >
> > >
> > >> Thanks
> > >> Liming
> > >> > -Original Message-
> > >> > From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> > >> > Sent: Monday, January 7, 2019 9:06 PM
> > >> > To: Gao, Liming 
> > >> > Cc: edk2-devel@lists.01.org; Laszlo Ersek ; Leif
> > >Lindholm ; Kinney, Michael D
> > >> > ; Wang, Jian J ; Wu,
> > >Hao A ; Jagadeesh Ujja
> > >> > ; Achin Gupta ;
> > >Thomas Panakamattam Abraham ;
> > >> > Sami Mujawar 
> > >> > Subject: Re: [PATCH 0/6] implement standalone MM versions of the
> > >variable runtime drivers
> > >> >
> > >> > On Mon, 7 Jan 2019 at 13:44, Gao, Liming  wrote:
> > >> > >
> > >> > > Ard:
> > >> > >   I agree this design is good. But, I need some time to evaluate its 
> > >> > > impact
> > >on our X86 platform. Could you wait for several days?
> > >> > >
> > >> >
> > >> > Of course.
> > >> >
> > >> > Thanks,
> > >> >
> > >> > > > -Original Message-
> > >> > > > From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> > >> > > > Sent: Friday, January 4, 2019 2:28 AM
> > >> > > > 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
> > >
> > >> > > > Subject: [PATCH 0/6] implement standalone MM versions of the
> > >variable runtime drivers
> > >> > > >
> > >> > > > This series proposed an alternative approach to the series sent 
> > >> > > > out by
> > >> > > > Jagadeesh [0]. In particular, it gets rid of the InMm() calls and 
> > >> > > > the
> > >> > > > special PCD, as well as some other if() conditionals.
> > >> > > >
> > >> > > > The primary difference is that this series defines and implements
> > >> > > > MmServicesTableLib in such a way that the 

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

2019-01-14 Thread Zeng, Star

Hi Laszlo,

On 2019/1/14 19:40, Laszlo Ersek wrote:

On 01/13/19 16:37, 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 


(1) Please CC Julien Grall (I'm adding him now); he's listed as a
Reviewer for ArmVirtPkg in "Maintainers.txt", and we depend on him for
Xen testing.


Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
  ArmVirtPkg/ArmVirtXen.dsc | 11 +--
  ArmVirtPkg/ArmVirtXen.fdf |  4 ++--
  2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index a29d8a4ae717..126782372a58 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
@@ -172,7 +172,14 @@ [Components.common]
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
  
-  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf

+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
+
+  
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+  
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+  }


OK, I've stared at this long and hard, to see if we should try to unify
it with the ArmVirtQemu* platforms. Ultimately, I don't think so (see
commits 44d71c217ccbd and bf453d581ecff, which don't apply to Xen).
Thus, I agree that adding the "VariableRuntimeDxe.inf" reference
*itself* to "ArmVirtXen.dsc" is fine.

That said, I'd suggest some tweaks:

(1) I think we should add the "PcdEmuVariableNvModeEnable" override
simply to the [PcdsFixedAtBuild.common] section of "ArmVirtXen.dsc". I
think there's no reason to scope the PCD more narrowly than that; so for
clarity, we shouldn't.


Agree.



(2) The resolutions for the AuthVariableLib, TpmMeasurementLib,
VarCheckLib classes seem superfluous; they are already in effect, from
"ArmVirt.dsc.inc".


Good information.



(3) The following tweak should be covered in an additional patch:

- In commit 7a9f5b202c7a ("ArmVirtPkg: Link separated VarCheckUefiLib
NULL class library instance", 2015-08-25), you linked VarCheckUefiLib
into VariableRuntimeDxe in ArmVirtQemu.

- In commit 8de84d424221 ("ArmVirtPkg: implement ArmVirtQemuKernel",
2016-02-05), Ard created the ArmVirtQemuKernel platform with
VarCheckUefiLib used at once.

- So I think at this point we should link VarCheckUefiLib into
ArmVirtXen's VariableRuntimeDxe binary as well -- however, because it is
a functional change, and not strictly related to this driver
unification, it should be a separate patch.

If you decide that (3) is out of scope for this work, we can file a BZ
for it and address it separately -- after BZ#1323 is fixed. Otherwise,
if it's not a big burden, you could include the patch in this series
too. Can you please state which approach you prefer, for (3)?


A new patch has been added for it in V2 patch series at 
https://lists.01.org/pipermail/edk2-devel/2019-January/035015.html.


Thanks,
Star



Thank you!
Laszlo

  
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 

Re: [edk2] [PATCH 06/12] MdeModulePkg Variable: Add emulated variable NV mode support

2019-01-14 Thread Zeng, Star

Hi Laszlo,

Yes, agree with the suggestions.
Two patches have been separated from this patch in V2 patch series at 
https://lists.01.org/pipermail/edk2-devel/2019-January/035015.html.



Thanks,
Star

On 2019/1/14 18:57, Laszlo Ersek wrote:

Hi Star,

On 01/13/19 16:37, 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   | 319 +++--
  .../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(+), 113 deletions(-)


What I did for (briefly) reviewing this patch was the following. I
fetched the branch you noted in the blurb, and the ran

   git show --color -W -b 9b509dea1227

Because, a large part of this patch just re-indents existent code, due
to new conditionals.

My main goal with this review was to see whether "EmuNvMode==FALSE"
would imply that the changes are a "no-op". Because OVMF, and the
non-Xen ArmVirt DSC, will inherit the default FALSE setting for the PCD.
So far, things look fine.

However, I noticed two small things that I believe would improve the
readability of the patch. I suggest that you please split them out to
separate patches, in the "preparation" section of the series. Namely:




diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 424f92a53757..845276d891ae 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) ((UINT8 *) VolatileBase + VolatileBase->Size))) {

-  return EFI_OUT_OF_RESOURCES;
+  if ((DataPtr + DataSize) > ((UINTN) VolatileBase + VolatileBase->Size)) {


(1) Here the "if" statement is not just re-indented, but the controlling
expression is also modified. The change looks OK to me (and I understand
why you were motivated to simplify it); however, it would be better to
split this change to a separate refactoring patch. That patch will be
simple to review in isolation, and in turn it will make this patch
easier to read, especially with "git show -b".


+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) {
  //
  // 

Re: [edk2] [PATCH] ArmPkg/ArmGicV3Dxe: use correct value for ARM_GICD_IROUTER

2019-01-14 Thread Ard Biesheuvel
On Mon, 14 Jan 2019 at 12:24, Leif Lindholm  wrote:
>
> On Fri, Dec 21, 2018 at 04:08:48PM +0100, Ard Biesheuvel wrote:
> > Use the correct value for ARM_GICD_IROUTER as per the GIC spec,
> > and fix the code that relies on the value being skewed by 32 x 8
> > bytes.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >  ArmPkg/Include/Library/ArmGicLib.h| 2 +-
> >  ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/ArmPkg/Include/Library/ArmGicLib.h 
> > b/ArmPkg/Include/Library/ArmGicLib.h
> > index 5775905ca91b..b52b77628ae1 100644
> > --- a/ArmPkg/Include/Library/ArmGicLib.h
> > +++ b/ArmPkg/Include/Library/ArmGicLib.h
> > @@ -43,7 +43,7 @@
> >  #define ARM_GIC_ICDSGIR 0xF00 // Software Generated Interrupt 
> > Register
> >
> >  // GICv3 specific registers
> > -#define ARM_GICD_IROUTER0x6100 // Interrupt Routing Registers
> > +#define ARM_GICD_IROUTER0x6000 // Interrupt Routing Registers
>
> Actually, whilst I agree the above would be more consistent, both
> revisions C and D of ARM IHI 0069 list the address offset of
> ARM_GICD_IROUTER as 0x6100 (and the preceding register space as
> "Reserved").
>

OK, in that case, please disregard this patch.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


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

2019-01-14 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 | 13 +++--
 BeagleBoardPkg/BeagleBoardPkg.fdf |  4 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc 
b/BeagleBoardPkg/BeagleBoardPkg.dsc
index 6dabfa905ae9..479b1504825a 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,10 @@ [LibraryClasses.common]
 
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.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 +349,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 +385,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 V2 15/15] MdeModulePkg: Remove EmuVariableRuntimeDxe

2019-01-14 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 V2 13/15] QuarkMin: Use merged variable driver for emulated NV mode

2019-01-14 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 V2 14/15] CorebootPayloadPkg: Use merged variable driver for emulated NV mode

2019-01-14 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 V2 10/15] ArmVirtXen: Use merged variable driver for emulated NV mode

2019-01-14 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 
---
 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 V2 09/15] MdeModulePkg VariablePei: Don't check BOOT_IN_RECOVERY_MODE

2019-01-14 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 V2 11/15] ArmVirtXen: Link VarCheckUefiLib NULL class library instance

2019-01-14 Thread Star Zeng
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
-- 
2.7.0.windows.1

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


[edk2] [PATCH V2 05/15] MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec

2019-01-14 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 
---
 MdeModulePkg/MdeModulePkg.dec | 10 --
 MdeModulePkg/MdeModulePkg.uni | 10 --
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 217ede1f7163..8fbc0af61365 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,13 @@ [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.
+  #   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..9c413a98f65d 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,15 @@
 
 #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."
+   
   "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 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_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 V2 08/15] MdeModulePkg Variable: Add emulated variable NV mode support

2019-01-14 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.

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(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 4c8e1d8cf4f1..845276d891ae 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 IsCommonUserVariable;
   AUTHENTICATED_VARIABLE_HEADER   *AuthVariable;
 
-  if (mVariableModuleGlobal->FvbInstance == NULL) {
+  if (mVariableModuleGlobal->FvbInstance == 

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

2019-01-14 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 
---
 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


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

2019-01-14 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);

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.
-- 
2.7.0.windows.1

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


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

2019-01-14 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 
---
 .../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
+  // 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 V2 03/15] MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize

2019-01-14 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  | 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 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index f7185df3a7eb..baba6729c1c2 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -386,13 +386,17 @@ FtwNotificationEvent (
 ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
   }
 
+  NvStorageVariableBase = 

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

2019-01-14 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
at 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 
---
 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 V2 02/15] MdeModulePkg Variable: Abstract InitRealNonVolatileVariableStore

2019-01-14 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 
---
 .../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 V2 00/15] Merge EmuVariable and Real variable driver

2019-01-14 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.

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 (15):
  MdeModulePkg Variable: Add some missing changes for 9b18845
  MdeModulePkg Variable: Abstract InitRealNonVolatileVariableStore
  MdeModulePkg Variable: Not get NV PCD in
VariableWriteServiceInitialize
  MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm
  MdeModulePkg: Add PcdEmuVariableNvModeEnable in dec
  MdeModulePkg Variable: Remove CacheOffset in UpdateVariable()
  MdeModulePkg Variable: type case VolatileBase to UINTN directly
  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  |   13 +-
 BeagleBoardPkg/BeagleBoardPkg.fdf  |4 +-
 CorebootPayloadPkg/CorebootPayloadPkg.fdf  |4 +-
 CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc  |   11 +-
 CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc   |   11 +-
 MdeModulePkg/MdeModulePkg.dec  |   10 +-
 MdeModulePkg/MdeModulePkg.dsc  |5 +-
 MdeModulePkg/MdeModulePkg.uni  |   10 +-
 .../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   |   10 +-
 .../Universal/Variable/RuntimeDxe/VariableDxe.c|  100 +-
 .../Variable/RuntimeDxe/VariableRuntimeDxe.inf |4 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.c|   88 +-
 .../Universal/Variable/RuntimeDxe/VariableSmm.inf  |4 +-
 QuarkPlatformPkg/QuarkMin.dsc  |8 +-
 QuarkPlatformPkg/QuarkMin.fdf  |4 +-
 26 files changed, 505 insertions(+), 2724 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

-- 
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 3/5] ArmPkg/ArmMmuLib AARCH64: implement support for EFI_MEMORY_RP permissions

2019-01-14 Thread Leif Lindholm
On Mon, Jan 14, 2019 at 03:59:08PM +0100, Ard Biesheuvel wrote:
> On Mon, 14 Jan 2019 at 15:29, Leif Lindholm  wrote:
> >
> > On Mon, Jan 07, 2019 at 08:15:02AM +0100, Ard Biesheuvel wrote:
> > > Wire up the access flag (AF) page table attribute to the EFI_MEMORY_RP
> > > permission attribute, so that attempts to read from such a region will
> > > trigger an access flag fault.
> > >
> > > Note that this is a stronger notion than just read protection, since
> > > it now implies that any write or execute attempt is trapped as well.
> > > However, this does not really matter in practice since we never assume
> > > that a read protected page is writable or executable, and StackGuard
> > > and HeapGuard (which are the primary users of this facility) certainly
> > > don't care.
> >
> > So ... I'm cautiously positive to this patch.
> > But this use does contradict the UEFI spec (2.7a, 2.3.6.1 Memory
> > types), which says EFI_MEMORY_RP is "not used or defined" for AArch64.
> >
> > Charles?
> 
> Not defined by the spec means we can use it do whatever we bloody want
> with it, at least that is what a typical compiler engineer will tell
> you :-)

Not defined, yes. Not used, less so. For a reciprocal compiler
engineer analogy, think pointer tagging :)

> I think there was a pending ECR to update the AArch64 binding code to
> reflect reality, but I don't think we included EFI_MEMORY_RP.

Right.

Anyway, I'm reasonably happy with stretching the rules slightly here,
and I believe it to be safe, but I do want Charles' take on it.

/
Leif

> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Ard Biesheuvel 
> > > ---
> > >  ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c  |  5 +++--
> > >  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 14 +++---
> > >  2 files changed, 14 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c 
> > > b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > > index 3e216c7cb235..e62e3fa87112 100644
> > > --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > > +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > > @@ -223,8 +223,9 @@ EfiAttributeToArmAttribute (
> > >  ArmAttributes = TT_ATTR_INDX_MASK;
> > >}
> > >
> > > -  // Set the access flag to match the block attributes
> > > -  ArmAttributes |= TT_AF;
> > > +  if ((EfiAttributes & EFI_MEMORY_RP) == 0) {
> > > +ArmAttributes |= TT_AF;
> > > +  }
> > >
> > >// Determine protection attributes
> > >if (EfiAttributes & EFI_MEMORY_RO) {
> > > diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c 
> > > b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > > index e1fabfcbea14..b59c081a7e49 100644
> > > --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > > +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > > @@ -102,6 +102,10 @@ PageAttributeToGcdAttribute (
> > >  GcdAttributes |= EFI_MEMORY_XP;
> > >}
> > >
> > > +  if ((PageAttributes & TT_AF) == 0) {
> > > +GcdAttributes |= EFI_MEMORY_RP;
> > > +  }
> > > +
> > >return GcdAttributes;
> > >  }
> > >
> > > @@ -451,7 +455,11 @@ GcdAttributeToPageAttribute (
> > >  PageAttributes |= TT_AP_RO_RO;
> > >}
> > >
> > > -  return PageAttributes | TT_AF;
> > > +  if ((GcdAttributes & EFI_MEMORY_RP) == 0) {
> > > +PageAttributes |= TT_AF;
> > > +  }
> > > +
> > > +  return PageAttributes;
> > >  }
> > >
> > >  EFI_STATUS
> > > @@ -474,9 +482,9 @@ ArmSetMemoryAttributes (
> > >  // No memory type was set in Attributes, so we are going to update 
> > > the
> > >  // permissions only.
> > >  //
> > > -PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK;
> > > +PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK | TT_AF;
> > >  PageAttributeMask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK |
> > > -  TT_PXN_MASK | TT_XN_MASK);
> > > +  TT_PXN_MASK | TT_XN_MASK | TT_AF);
> > >}
> > >
> > >TranslationTable = ArmGetTTBR0BaseAddress ();
> > > --
> > > 2.20.1
> > >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch v2] MdePkg/BasePeCoffLib: Add more check for relocation data

2019-01-14 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1426

V2:
(1) Add NULL pointer check for the input parameters
(2) Add check for the "Adjust" value before applying fix ups.

In function PeCoffLoaderRelocateImageForRuntime, it doesn't
do much check when do relocation. For API level consideration,
it's not safe enough.
So this patch is to replace the same code logic with function
PeCoffLoaderImageAddress which will cover more validation.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 165 +-
 1 file changed, 95 insertions(+), 70 deletions(-)

diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c 
b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index c57816a808..d9c94b89bd 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -13,11 +13,11 @@
   This library will also do some additional check for PE header fields.
 
   PeCoffLoaderGetPeHeader() routine will do basic check for PE/COFF header.
   PeCoffLoaderGetImageInfo() routine will do basic check for whole PE/COFF 
image.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
   Portions copyright (c) 2008 - 2009, Apple Inc. 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.
@@ -1669,25 +1669,34 @@ PeCoffLoaderRelocateImageForRuntime (
   UINT32  NumberOfRvaAndSizes;
   EFI_IMAGE_DATA_DIRECTORY*DataDirectory;
   EFI_IMAGE_DATA_DIRECTORY*RelocDir;
   EFI_IMAGE_BASE_RELOCATION   *RelocBase;
   EFI_IMAGE_BASE_RELOCATION   *RelocBaseEnd;
+  EFI_IMAGE_BASE_RELOCATION   *RelocBaseOrig;
   UINT16  *Reloc;
   UINT16  *RelocEnd;
   CHAR8   *Fixup;
   CHAR8   *FixupBase;
   UINT16  *Fixup16;
   UINT32  *Fixup32;
   UINT64  *Fixup64;
   CHAR8   *FixupData;
   UINTN   Adjust;
   RETURN_STATUS   Status;
+  PE_COFF_LOADER_IMAGE_CONTEXTImageContext;
+
+  if (RelocationData == NULL || ImageBase == 0x0 || VirtImageBase == 0x0) {
+return;
+  }
 
   OldBase = (CHAR8 *)((UINTN)ImageBase);
   NewBase = (CHAR8 *)((UINTN)VirtImageBase);
   Adjust = (UINTN) NewBase - (UINTN) OldBase;
 
+  ImageContext.ImageAddress = ImageBase;
+  ImageContext.ImageSize = ImageSize;
+
   //
   // Find the image's relocate dir info
   //
   DosHdr = (EFI_IMAGE_DOS_HEADER *)OldBase;
   if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
@@ -1730,12 +1739,15 @@ PeCoffLoaderRelocateImageForRuntime (
   // is present in the image. You have to check the NumberOfRvaAndSizes in
   // the optional header to verify a desired directory entry is there.
   //
   if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
 RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
-RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + 
RelocDir->VirtualAddress);
-RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + 
RelocDir->VirtualAddress + RelocDir->Size);
+RelocBase = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
(, RelocDir->VirtualAddress, 0);
+RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
(,
+
RelocDir->VirtualAddress + RelocDir->Size,
+0
+);
   } else {
 //
 // Cannot find relocations, cannot continue to relocate the image, ASSERT 
for this invalid image.
 //
 ASSERT (FALSE);
@@ -1745,100 +1757,113 @@ PeCoffLoaderRelocateImageForRuntime (
   //
   // ASSERT for the invalid image when RelocBase and RelocBaseEnd are both 
NULL.
   //
   ASSERT (RelocBase != NULL && RelocBaseEnd != NULL);
 
-  //
-  // Run the whole relocation block. And re-fixup data that has not been
-  // modified. The FixupData is used to see if the image has been modified
-  // since it was relocated. This is so data sections that have been updated
-  // by code will not be fixed up, since that would set them back to
-  // defaults.
-  //
-  FixupData = RelocationData;
-  while (RelocBase < RelocBaseEnd) {
+  if (Adjust != 0) {
 //
-// Add check for RelocBase->SizeOfBlock field.
+// Run the whole relocation block. And 

Re: [edk2] [PATCH 3/5] ArmPkg/ArmMmuLib AARCH64: implement support for EFI_MEMORY_RP permissions

2019-01-14 Thread Ard Biesheuvel
On Mon, 14 Jan 2019 at 15:29, Leif Lindholm  wrote:
>
> On Mon, Jan 07, 2019 at 08:15:02AM +0100, Ard Biesheuvel wrote:
> > Wire up the access flag (AF) page table attribute to the EFI_MEMORY_RP
> > permission attribute, so that attempts to read from such a region will
> > trigger an access flag fault.
> >
> > Note that this is a stronger notion than just read protection, since
> > it now implies that any write or execute attempt is trapped as well.
> > However, this does not really matter in practice since we never assume
> > that a read protected page is writable or executable, and StackGuard
> > and HeapGuard (which are the primary users of this facility) certainly
> > don't care.
>
> So ... I'm cautiously positive to this patch.
> But this use does contradict the UEFI spec (2.7a, 2.3.6.1 Memory
> types), which says EFI_MEMORY_RP is "not used or defined" for AArch64.
>
> Charles?
>

Not defined by the spec means we can use it do whatever we bloody want
with it, at least that is what a typical compiler engineer will tell
you :-)

I think there was a pending ECR to update the AArch64 binding code to
reflect reality, but I don't think we included EFI_MEMORY_RP.


> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >  ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c  |  5 +++--
> >  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 14 +++---
> >  2 files changed, 14 insertions(+), 5 deletions(-)
> >
> > diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c 
> > b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > index 3e216c7cb235..e62e3fa87112 100644
> > --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > @@ -223,8 +223,9 @@ EfiAttributeToArmAttribute (
> >  ArmAttributes = TT_ATTR_INDX_MASK;
> >}
> >
> > -  // Set the access flag to match the block attributes
> > -  ArmAttributes |= TT_AF;
> > +  if ((EfiAttributes & EFI_MEMORY_RP) == 0) {
> > +ArmAttributes |= TT_AF;
> > +  }
> >
> >// Determine protection attributes
> >if (EfiAttributes & EFI_MEMORY_RO) {
> > diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c 
> > b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > index e1fabfcbea14..b59c081a7e49 100644
> > --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> > @@ -102,6 +102,10 @@ PageAttributeToGcdAttribute (
> >  GcdAttributes |= EFI_MEMORY_XP;
> >}
> >
> > +  if ((PageAttributes & TT_AF) == 0) {
> > +GcdAttributes |= EFI_MEMORY_RP;
> > +  }
> > +
> >return GcdAttributes;
> >  }
> >
> > @@ -451,7 +455,11 @@ GcdAttributeToPageAttribute (
> >  PageAttributes |= TT_AP_RO_RO;
> >}
> >
> > -  return PageAttributes | TT_AF;
> > +  if ((GcdAttributes & EFI_MEMORY_RP) == 0) {
> > +PageAttributes |= TT_AF;
> > +  }
> > +
> > +  return PageAttributes;
> >  }
> >
> >  EFI_STATUS
> > @@ -474,9 +482,9 @@ ArmSetMemoryAttributes (
> >  // No memory type was set in Attributes, so we are going to update the
> >  // permissions only.
> >  //
> > -PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK;
> > +PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK | TT_AF;
> >  PageAttributeMask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK |
> > -  TT_PXN_MASK | TT_XN_MASK);
> > +  TT_PXN_MASK | TT_XN_MASK | TT_AF);
> >}
> >
> >TranslationTable = ArmGetTTBR0BaseAddress ();
> > --
> > 2.20.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

2019-01-14 Thread Laszlo Ersek
On 01/14/19 15:03, Feng, Bob C wrote:
> Sure. Since ECC and UPT are two standalone tools, I'll send another patch for 
> them.

That sounds like a good idea to me, but shouldn't we then split this
patch as well?

Namely, the first two hunks apply to GenFds. So, for those, I would
suggest a common patch, and a subject like

  BaseTools/GenFds: remove EDK_SOURCE keyword

However, the last hunk applies to "Workspace/InfBuildData.py". What
utility does that file belong to? "build" perhaps? What would be the
correct subject for the patch?

I mean, if these three hunks belong together, that's OK (and then they
should be in a single patch), but the subject line, as-is, is too
generic. We should say something more specifc than just "BaseTools" --
we're not covering UPT or ECC, and those are also under BaseTools.

Other than that, the patch works for me:

Tested-by: Laszlo Ersek 

But please don't push it without updating the subject line at least.

Thanks
Laszlo

> -Original Message-
> From: Gao, Liming 
> Sent: Monday, January 14, 2019 9:57 PM
> To: Feng, Bob C ; edk2-devel@lists.01.org
> Cc: Laszlo Ersek 
> Subject: RE: [Patch] BaseTools: Remove EDK_SOURCE keyword
> 
> Bob:
>   This change cleans up EDK environments in GenFds. Could you continue to 
> clean up EDK env in ECC and UPT tool?
> 
> Thanks
> Liming
>> -Original Message-
>> From: Feng, Bob C
>> Sent: Monday, January 14, 2019 7:14 PM
>> To: edk2-devel@lists.01.org
>> Cc: Feng, Bob C ; Gao, Liming 
>> ; Laszlo Ersek 
>> Subject: [Patch] BaseTools: Remove EDK_SOURCE keyword
>>
>> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
>> Remove unused EDK_SOURCE keyword in python tool.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Bob Feng 
>> Cc: Liming Gao 
>> Cc: Laszlo Ersek 
>> ---
>>  BaseTools/Source/Python/GenFds/GenFds.py  |  3 --
>>  .../Python/GenFds/GenFdsGlobalVariable.py |  3 --
>>  .../Source/Python/Workspace/InfBuildData.py   | 34 ---
>>  3 files changed, 7 insertions(+), 33 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"]
>>  

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

2019-01-14 Thread Laszlo Ersek
On 01/14/19 14:52, Liming Gao wrote:
> Remove extraneous parentheses around the comparison to silence this warning.

Can you please quote the warning message in the commit message? It's
unclear what warning the commit message refers to. (No need to repost
just for this.)

Thanks
Laszlo

> 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/GenFw/GenFw.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Source/C/GenFw/GenFw.c 
> b/BaseTools/Source/C/GenFw/GenFw.c
> index 37278bbc68..af2c909866 100644
> --- a/BaseTools/Source/C/GenFw/GenFw.c
> +++ b/BaseTools/Source/C/GenFw/GenFw.c
> @@ -1014,7 +1014,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;
> @@ -2180,7 +2180,7 @@ Returns:
>// Set new base address into image
>//
>if (mOutImageType == FW_REBASE_IMAGE || mOutImageType == 
> FW_SET_ADDRESS_IMAGE) {
> -if ((PeHdr->Pe32.OptionalHeader.Magic == 
> EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
> +if (PeHdr->Pe32.OptionalHeader.Magic == 
> EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
>if (NewBaseAddress >= 0x1ULL) {
>  Error (NULL, 0, 3000, "Invalid", "New base address is larger than 4G 
> for 32bit PE image");
>  goto Finish;
> 

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


Re: [edk2] [PATCH] IntelSiliconPkg\Include\IndustryStandard: Update IGD_OPREGION_MBOX3 Structure

2019-01-14 Thread Yao, Jiewen
Hi
According to 
https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf, there 
is no the new field.

Would you please give a new link for the latest spec to make sure code/doc 
match ?


Thank you
Yao Jiewen


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Digant H Solanki
> Sent: Monday, January 14, 2019 1:59 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [edk2] [PATCH] IntelSiliconPkg\Include\IndustryStandard: Update
> IGD_OPREGION_MBOX3 Structure
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1454
> Based on latest IGD OpRegion Spec, IGD_OPREGION_MBOX3 needs to be
> updated with two new members : Physical Address of Raw VBT Data (RVDA)
> and Size of Raw VBT Data (RVDS)
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Digant H Solanki 
> Cc: Liming Gao 
> ---
>  IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
> b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
> index 5ce80a5be8..e1d92717a4 100644
> --- a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
> +++ b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
> @@ -4,9 +4,7 @@
> 
> 
> https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf
> 
> -  @note Fixed bug in the spec Mailbox3 - RM31 size from 0x45(69) to
> 0x46(70)
> -
> -  Copyright (c) 2016, Intel Corporation. All rights reserved.
> +  Copyright (c) 2016 - 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
> @@ -118,7 +116,9 @@ typedef struct {
>UINT64 FDSS;  ///< Offset 0x3AA DSS Buffer address allocated
> for IFFS feature
>UINT32 FDSP;  ///< Offset 0x3B2 Size of DSS buffer
>UINT32 STAT;  ///< Offset 0x3B6 State Indicator
> -  UINT8  RM31[0x46];///< Offset 0x3BA - 0x3FF  Reserved Must be
> zero. Bug in spec 0x45(69)
> +  UINT64 RVDA;  ///< Offset 0x3BA Physical address of Raw
> VBT data
> +  UINT32 RVDS;  ///< Offset 0x3C2 Size of Raw VBT data
> +  UINT8  RM31[0x3A];///< Offset 0x3C6 - 0x3FF  Reserved Must be
> zero.
>  } IGD_OPREGION_MBOX3;
> 
>  ///
> --
> 2.18.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


Re: [edk2] [PATCH 3/5] ArmPkg/ArmMmuLib AARCH64: implement support for EFI_MEMORY_RP permissions

2019-01-14 Thread Leif Lindholm
On Mon, Jan 07, 2019 at 08:15:02AM +0100, Ard Biesheuvel wrote:
> Wire up the access flag (AF) page table attribute to the EFI_MEMORY_RP
> permission attribute, so that attempts to read from such a region will
> trigger an access flag fault.
> 
> Note that this is a stronger notion than just read protection, since
> it now implies that any write or execute attempt is trapped as well.
> However, this does not really matter in practice since we never assume
> that a read protected page is writable or executable, and StackGuard
> and HeapGuard (which are the primary users of this facility) certainly
> don't care.

So ... I'm cautiously positive to this patch.
But this use does contradict the UEFI spec (2.7a, 2.3.6.1 Memory
types), which says EFI_MEMORY_RP is "not used or defined" for AArch64.

Charles?

/
Leif

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c  |  5 +++--
>  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 14 +++---
>  2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c 
> b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> index 3e216c7cb235..e62e3fa87112 100644
> --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> @@ -223,8 +223,9 @@ EfiAttributeToArmAttribute (
>  ArmAttributes = TT_ATTR_INDX_MASK;
>}
>  
> -  // Set the access flag to match the block attributes
> -  ArmAttributes |= TT_AF;
> +  if ((EfiAttributes & EFI_MEMORY_RP) == 0) {
> +ArmAttributes |= TT_AF;
> +  }
>  
>// Determine protection attributes
>if (EfiAttributes & EFI_MEMORY_RO) {
> diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c 
> b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> index e1fabfcbea14..b59c081a7e49 100644
> --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> @@ -102,6 +102,10 @@ PageAttributeToGcdAttribute (
>  GcdAttributes |= EFI_MEMORY_XP;
>}
>  
> +  if ((PageAttributes & TT_AF) == 0) {
> +GcdAttributes |= EFI_MEMORY_RP;
> +  }
> +
>return GcdAttributes;
>  }
>  
> @@ -451,7 +455,11 @@ GcdAttributeToPageAttribute (
>  PageAttributes |= TT_AP_RO_RO;
>}
>  
> -  return PageAttributes | TT_AF;
> +  if ((GcdAttributes & EFI_MEMORY_RP) == 0) {
> +PageAttributes |= TT_AF;
> +  }
> +
> +  return PageAttributes;
>  }
>  
>  EFI_STATUS
> @@ -474,9 +482,9 @@ ArmSetMemoryAttributes (
>  // No memory type was set in Attributes, so we are going to update the
>  // permissions only.
>  //
> -PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK;
> +PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK | TT_AF;
>  PageAttributeMask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK |
> -  TT_PXN_MASK | TT_XN_MASK);
> +  TT_PXN_MASK | TT_XN_MASK | TT_AF);
>}
>  
>TranslationTable = ArmGetTTBR0BaseAddress ();
> -- 
> 2.20.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] BaseTools/tools_def GCC5: disable LTO for ASLC invocations

2019-01-14 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Philippe Mathieu-Daudé [mailto:phi...@redhat.com]
> Sent: Monday, January 14, 2019 10:09 PM
> To: Ard Biesheuvel ; Gao, Liming 
> ; edk2-devel@lists.01.org
> Cc: leif.lindh...@linaro.org
> Subject: Re: [PATCH v2] BaseTools/tools_def GCC5: disable LTO for ASLC 
> invocations
> 
> On 1/14/19 3:04 PM, Ard Biesheuvel wrote:
> > GCC for 32-bit ARM chokes on .aslc files when running with LTO
> > enabled. Since LTO has no benefit whatsoever here, just disable
> > it globally for GCC5 and up when building .aslc files.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > Reviewed-by: Leif Lindholm 
> 
> Reviewed-by: Philippe Mathieu-Daudé 
> 
> > ---
> >  BaseTools/Conf/tools_def.template | 27 +++-
> >  1 file changed, 15 insertions(+), 12 deletions(-)
> >
> > diff --git a/BaseTools/Conf/tools_def.template 
> > b/BaseTools/Conf/tools_def.template
> > index 4d74816837ab..2bd098287219 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -4155,6 +4155,7 @@ DEFINE GCC48_AARCH64_DLINK_FLAGS = 
> > DEF(GCC_AARCH64_DLINK_FLAGS)
> >  DEFINE GCC48_AARCH64_DLINK2_FLAGS= DEF(GCC_DLINK2_FLAGS_COMMON) 
> > -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
> >  DEFINE GCC48_ARM_ASLDLINK_FLAGS  = DEF(GCC_ARM_ASLDLINK_FLAGS) 
> > -Wl,--oformat=elf32-littlearm
> >  DEFINE GCC48_AARCH64_ASLDLINK_FLAGS  = DEF(GCC_AARCH64_ASLDLINK_FLAGS)
> > +DEFINE GCC48_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
> >
> >  DEFINE GCC49_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS)
> >  DEFINE GCC49_X64_CC_FLAGS= DEF(GCC48_X64_CC_FLAGS)
> > @@ -4177,6 +4178,7 @@ DEFINE GCC49_AARCH64_DLINK_FLAGS = 
> > DEF(GCC48_AARCH64_DLINK_FLAGS) -z common-
> >  DEFINE GCC49_AARCH64_DLINK2_FLAGS= DEF(GCC48_AARCH64_DLINK2_FLAGS)
> >  DEFINE GCC49_ARM_ASLDLINK_FLAGS  = DEF(GCC48_ARM_ASLDLINK_FLAGS)
> >  DEFINE GCC49_AARCH64_ASLDLINK_FLAGS  = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
> > +DEFINE GCC49_ASLCC_FLAGS = DEF(GCC48_ASLCC_FLAGS)
> >
> >  DEFINE GCC5_IA32_CC_FLAGS= DEF(GCC49_IA32_CC_FLAGS) -fno-pic 
> > -fno-pie
> >  DEFINE GCC5_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS)
> > @@ -4199,6 +4201,7 @@ DEFINE GCC5_AARCH64_DLINK_FLAGS  = 
> > DEF(GCC49_AARCH64_DLINK_FLAGS)
> >  DEFINE GCC5_AARCH64_DLINK2_FLAGS = DEF(GCC49_AARCH64_DLINK2_FLAGS) 
> > -Wno-error
> >  DEFINE GCC5_ARM_ASLDLINK_FLAGS   = DEF(GCC49_ARM_ASLDLINK_FLAGS)
> >  DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
> > +DEFINE GCC5_ASLCC_FLAGS  = DEF(GCC49_ASLCC_FLAGS) -fno-lto
> >
> >  
> > 
> >  #
> > @@ -4301,7 +4304,7 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = 
> > DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
> >  *_GCC48_IA32_ASLPP_PATH   = DEF(GCC48_IA32_PREFIX)gcc
> >  *_GCC48_IA32_RC_PATH  = DEF(GCC48_IA32_PREFIX)objcopy
> >
> > -*_GCC48_IA32_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m32
> > +*_GCC48_IA32_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS) -m32
> >  *_GCC48_IA32_ASLDLINK_FLAGS   = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) 
> > -Wl,-m,elf_i386
> >  *_GCC48_IA32_ASM_FLAGS= DEF(GCC48_ASM_FLAGS) -m32 -march=i386
> >  *_GCC48_IA32_DLINK_FLAGS  = DEF(GCC48_IA32_X64_DLINK_FLAGS) 
> > -Wl,-m,elf_i386,--oformat=elf32-i386
> > @@ -4329,7 +4332,7 @@ RELEASE_GCC48_IA32_CC_FLAGS   = 
> > DEF(GCC48_IA32_CC_FLAGS) -Os -Wno-unused-but
> >  *_GCC48_X64_ASLPP_PATH   = DEF(GCC48_X64_PREFIX)gcc
> >  *_GCC48_X64_RC_PATH  = DEF(GCC48_X64_PREFIX)objcopy
> >
> > -*_GCC48_X64_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m64
> > +*_GCC48_X64_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS) -m64
> >  *_GCC48_X64_ASLDLINK_FLAGS   = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) 
> > -Wl,-m,elf_x86_64
> >  *_GCC48_X64_ASM_FLAGS= DEF(GCC48_ASM_FLAGS) -m64
> >  *_GCC48_X64_DLINK_FLAGS  = DEF(GCC48_X64_DLINK_FLAGS)
> > @@ -4359,7 +4362,7 @@ RELEASE_GCC48_X64_CC_FLAGS   = 
> > DEF(GCC48_X64_CC_FLAGS) -Os -Wno-unused-but-s
> >  *_GCC48_ARM_ARCHCC_FLAGS = -mthumb
> >  *_GCC48_ARM_PLATFORM_FLAGS   = -march=armv7-a
> >
> > -*_GCC48_ARM_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
> > +*_GCC48_ARM_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS)
> >  *_GCC48_ARM_ASLDLINK_FLAGS   = DEF(GCC48_ARM_ASLDLINK_FLAGS)
> >  *_GCC48_ARM_ASM_FLAGS= DEF(GCC48_ARM_ASM_FLAGS)
> >  *_GCC48_ARM_DLINK_FLAGS  = DEF(GCC48_ARM_DLINK_FLAGS)
> > @@ -4389,7 +4392,7 @@ RELEASE_GCC48_ARM_CC_FLAGS   = 
> > DEF(GCC48_ARM_CC_FLAGS) -Wno-unused-but-set-v
> >  *_GCC48_AARCH64_ASLPP_PATH   = ENV(GCC48_AARCH64_PREFIX)gcc
> >  *_GCC48_AARCH64_RC_PATH  = ENV(GCC48_AARCH64_PREFIX)objcopy
> >
> > -*_GCC48_AARCH64_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
> > +*_GCC48_AARCH64_ASLCC_FLAGS  

Re: [edk2] [PATCH v2] BaseTools/tools_def GCC5: disable LTO for ASLC invocations

2019-01-14 Thread Philippe Mathieu-Daudé
On 1/14/19 3:04 PM, Ard Biesheuvel wrote:
> GCC for 32-bit ARM chokes on .aslc files when running with LTO
> enabled. Since LTO has no benefit whatsoever here, just disable
> it globally for GCC5 and up when building .aslc files.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> Reviewed-by: Leif Lindholm 

Reviewed-by: Philippe Mathieu-Daudé 

> ---
>  BaseTools/Conf/tools_def.template | 27 +++-
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index 4d74816837ab..2bd098287219 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -4155,6 +4155,7 @@ DEFINE GCC48_AARCH64_DLINK_FLAGS = 
> DEF(GCC_AARCH64_DLINK_FLAGS)
>  DEFINE GCC48_AARCH64_DLINK2_FLAGS= DEF(GCC_DLINK2_FLAGS_COMMON) 
> -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
>  DEFINE GCC48_ARM_ASLDLINK_FLAGS  = DEF(GCC_ARM_ASLDLINK_FLAGS) 
> -Wl,--oformat=elf32-littlearm
>  DEFINE GCC48_AARCH64_ASLDLINK_FLAGS  = DEF(GCC_AARCH64_ASLDLINK_FLAGS)
> +DEFINE GCC48_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
>  
>  DEFINE GCC49_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS)
>  DEFINE GCC49_X64_CC_FLAGS= DEF(GCC48_X64_CC_FLAGS)
> @@ -4177,6 +4178,7 @@ DEFINE GCC49_AARCH64_DLINK_FLAGS = 
> DEF(GCC48_AARCH64_DLINK_FLAGS) -z common-
>  DEFINE GCC49_AARCH64_DLINK2_FLAGS= DEF(GCC48_AARCH64_DLINK2_FLAGS)
>  DEFINE GCC49_ARM_ASLDLINK_FLAGS  = DEF(GCC48_ARM_ASLDLINK_FLAGS)
>  DEFINE GCC49_AARCH64_ASLDLINK_FLAGS  = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
> +DEFINE GCC49_ASLCC_FLAGS = DEF(GCC48_ASLCC_FLAGS)
>  
>  DEFINE GCC5_IA32_CC_FLAGS= DEF(GCC49_IA32_CC_FLAGS) -fno-pic 
> -fno-pie
>  DEFINE GCC5_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS)
> @@ -4199,6 +4201,7 @@ DEFINE GCC5_AARCH64_DLINK_FLAGS  = 
> DEF(GCC49_AARCH64_DLINK_FLAGS)
>  DEFINE GCC5_AARCH64_DLINK2_FLAGS = DEF(GCC49_AARCH64_DLINK2_FLAGS) 
> -Wno-error
>  DEFINE GCC5_ARM_ASLDLINK_FLAGS   = DEF(GCC49_ARM_ASLDLINK_FLAGS)
>  DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
> +DEFINE GCC5_ASLCC_FLAGS  = DEF(GCC49_ASLCC_FLAGS) -fno-lto
>  
>  
> 
>  #
> @@ -4301,7 +4304,7 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = 
> DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
>  *_GCC48_IA32_ASLPP_PATH   = DEF(GCC48_IA32_PREFIX)gcc
>  *_GCC48_IA32_RC_PATH  = DEF(GCC48_IA32_PREFIX)objcopy
>  
> -*_GCC48_IA32_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m32
> +*_GCC48_IA32_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS) -m32
>  *_GCC48_IA32_ASLDLINK_FLAGS   = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) 
> -Wl,-m,elf_i386
>  *_GCC48_IA32_ASM_FLAGS= DEF(GCC48_ASM_FLAGS) -m32 -march=i386
>  *_GCC48_IA32_DLINK_FLAGS  = DEF(GCC48_IA32_X64_DLINK_FLAGS) 
> -Wl,-m,elf_i386,--oformat=elf32-i386
> @@ -4329,7 +4332,7 @@ RELEASE_GCC48_IA32_CC_FLAGS   = 
> DEF(GCC48_IA32_CC_FLAGS) -Os -Wno-unused-but
>  *_GCC48_X64_ASLPP_PATH   = DEF(GCC48_X64_PREFIX)gcc
>  *_GCC48_X64_RC_PATH  = DEF(GCC48_X64_PREFIX)objcopy
>  
> -*_GCC48_X64_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m64
> +*_GCC48_X64_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS) -m64
>  *_GCC48_X64_ASLDLINK_FLAGS   = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) 
> -Wl,-m,elf_x86_64
>  *_GCC48_X64_ASM_FLAGS= DEF(GCC48_ASM_FLAGS) -m64
>  *_GCC48_X64_DLINK_FLAGS  = DEF(GCC48_X64_DLINK_FLAGS)
> @@ -4359,7 +4362,7 @@ RELEASE_GCC48_X64_CC_FLAGS   = 
> DEF(GCC48_X64_CC_FLAGS) -Os -Wno-unused-but-s
>  *_GCC48_ARM_ARCHCC_FLAGS = -mthumb
>  *_GCC48_ARM_PLATFORM_FLAGS   = -march=armv7-a
>  
> -*_GCC48_ARM_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
> +*_GCC48_ARM_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS)
>  *_GCC48_ARM_ASLDLINK_FLAGS   = DEF(GCC48_ARM_ASLDLINK_FLAGS)
>  *_GCC48_ARM_ASM_FLAGS= DEF(GCC48_ARM_ASM_FLAGS)
>  *_GCC48_ARM_DLINK_FLAGS  = DEF(GCC48_ARM_DLINK_FLAGS)
> @@ -4389,7 +4392,7 @@ RELEASE_GCC48_ARM_CC_FLAGS   = 
> DEF(GCC48_ARM_CC_FLAGS) -Wno-unused-but-set-v
>  *_GCC48_AARCH64_ASLPP_PATH   = ENV(GCC48_AARCH64_PREFIX)gcc
>  *_GCC48_AARCH64_RC_PATH  = ENV(GCC48_AARCH64_PREFIX)objcopy
>  
> -*_GCC48_AARCH64_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
> +*_GCC48_AARCH64_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS)
>  *_GCC48_AARCH64_ASLDLINK_FLAGS   = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
>  *_GCC48_AARCH64_ASM_FLAGS= DEF(GCC48_AARCH64_ASM_FLAGS)
>  *_GCC48_AARCH64_DLINK_FLAGS  = DEF(GCC48_AARCH64_DLINK_FLAGS)
> @@ -4440,7 +4443,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS   = 
> DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
>  *_GCC49_IA32_ASLPP_PATH   = DEF(GCC49_IA32_PREFIX)gcc
>  *_GCC49_IA32_RC_PATH  = DEF(GCC49_IA32_PREFIX)objcopy
>  
> 

[edk2] [PATCH v2] BaseTools/tools_def GCC5: disable LTO for ASLC invocations

2019-01-14 Thread Ard Biesheuvel
GCC for 32-bit ARM chokes on .aslc files when running with LTO
enabled. Since LTO has no benefit whatsoever here, just disable
it globally for GCC5 and up when building .aslc files.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
---
 BaseTools/Conf/tools_def.template | 27 +++-
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 4d74816837ab..2bd098287219 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -4155,6 +4155,7 @@ DEFINE GCC48_AARCH64_DLINK_FLAGS = 
DEF(GCC_AARCH64_DLINK_FLAGS)
 DEFINE GCC48_AARCH64_DLINK2_FLAGS= DEF(GCC_DLINK2_FLAGS_COMMON) 
-Wl,--defsym=PECOFF_HEADER_SIZE=0x228
 DEFINE GCC48_ARM_ASLDLINK_FLAGS  = DEF(GCC_ARM_ASLDLINK_FLAGS) 
-Wl,--oformat=elf32-littlearm
 DEFINE GCC48_AARCH64_ASLDLINK_FLAGS  = DEF(GCC_AARCH64_ASLDLINK_FLAGS)
+DEFINE GCC48_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
 
 DEFINE GCC49_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS)
 DEFINE GCC49_X64_CC_FLAGS= DEF(GCC48_X64_CC_FLAGS)
@@ -4177,6 +4178,7 @@ DEFINE GCC49_AARCH64_DLINK_FLAGS = 
DEF(GCC48_AARCH64_DLINK_FLAGS) -z common-
 DEFINE GCC49_AARCH64_DLINK2_FLAGS= DEF(GCC48_AARCH64_DLINK2_FLAGS)
 DEFINE GCC49_ARM_ASLDLINK_FLAGS  = DEF(GCC48_ARM_ASLDLINK_FLAGS)
 DEFINE GCC49_AARCH64_ASLDLINK_FLAGS  = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
+DEFINE GCC49_ASLCC_FLAGS = DEF(GCC48_ASLCC_FLAGS)
 
 DEFINE GCC5_IA32_CC_FLAGS= DEF(GCC49_IA32_CC_FLAGS) -fno-pic 
-fno-pie
 DEFINE GCC5_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS)
@@ -4199,6 +4201,7 @@ DEFINE GCC5_AARCH64_DLINK_FLAGS  = 
DEF(GCC49_AARCH64_DLINK_FLAGS)
 DEFINE GCC5_AARCH64_DLINK2_FLAGS = DEF(GCC49_AARCH64_DLINK2_FLAGS) 
-Wno-error
 DEFINE GCC5_ARM_ASLDLINK_FLAGS   = DEF(GCC49_ARM_ASLDLINK_FLAGS)
 DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
+DEFINE GCC5_ASLCC_FLAGS  = DEF(GCC49_ASLCC_FLAGS) -fno-lto
 
 

 #
@@ -4301,7 +4304,7 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = 
DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
 *_GCC48_IA32_ASLPP_PATH   = DEF(GCC48_IA32_PREFIX)gcc
 *_GCC48_IA32_RC_PATH  = DEF(GCC48_IA32_PREFIX)objcopy
 
-*_GCC48_IA32_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m32
+*_GCC48_IA32_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS) -m32
 *_GCC48_IA32_ASLDLINK_FLAGS   = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) 
-Wl,-m,elf_i386
 *_GCC48_IA32_ASM_FLAGS= DEF(GCC48_ASM_FLAGS) -m32 -march=i386
 *_GCC48_IA32_DLINK_FLAGS  = DEF(GCC48_IA32_X64_DLINK_FLAGS) 
-Wl,-m,elf_i386,--oformat=elf32-i386
@@ -4329,7 +4332,7 @@ RELEASE_GCC48_IA32_CC_FLAGS   = 
DEF(GCC48_IA32_CC_FLAGS) -Os -Wno-unused-but
 *_GCC48_X64_ASLPP_PATH   = DEF(GCC48_X64_PREFIX)gcc
 *_GCC48_X64_RC_PATH  = DEF(GCC48_X64_PREFIX)objcopy
 
-*_GCC48_X64_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m64
+*_GCC48_X64_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS) -m64
 *_GCC48_X64_ASLDLINK_FLAGS   = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) 
-Wl,-m,elf_x86_64
 *_GCC48_X64_ASM_FLAGS= DEF(GCC48_ASM_FLAGS) -m64
 *_GCC48_X64_DLINK_FLAGS  = DEF(GCC48_X64_DLINK_FLAGS)
@@ -4359,7 +4362,7 @@ RELEASE_GCC48_X64_CC_FLAGS   = 
DEF(GCC48_X64_CC_FLAGS) -Os -Wno-unused-but-s
 *_GCC48_ARM_ARCHCC_FLAGS = -mthumb
 *_GCC48_ARM_PLATFORM_FLAGS   = -march=armv7-a
 
-*_GCC48_ARM_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
+*_GCC48_ARM_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS)
 *_GCC48_ARM_ASLDLINK_FLAGS   = DEF(GCC48_ARM_ASLDLINK_FLAGS)
 *_GCC48_ARM_ASM_FLAGS= DEF(GCC48_ARM_ASM_FLAGS)
 *_GCC48_ARM_DLINK_FLAGS  = DEF(GCC48_ARM_DLINK_FLAGS)
@@ -4389,7 +4392,7 @@ RELEASE_GCC48_ARM_CC_FLAGS   = 
DEF(GCC48_ARM_CC_FLAGS) -Wno-unused-but-set-v
 *_GCC48_AARCH64_ASLPP_PATH   = ENV(GCC48_AARCH64_PREFIX)gcc
 *_GCC48_AARCH64_RC_PATH  = ENV(GCC48_AARCH64_PREFIX)objcopy
 
-*_GCC48_AARCH64_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
+*_GCC48_AARCH64_ASLCC_FLAGS  = DEF(GCC48_ASLCC_FLAGS)
 *_GCC48_AARCH64_ASLDLINK_FLAGS   = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
 *_GCC48_AARCH64_ASM_FLAGS= DEF(GCC48_AARCH64_ASM_FLAGS)
 *_GCC48_AARCH64_DLINK_FLAGS  = DEF(GCC48_AARCH64_DLINK_FLAGS)
@@ -4440,7 +4443,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS   = 
DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
 *_GCC49_IA32_ASLPP_PATH   = DEF(GCC49_IA32_PREFIX)gcc
 *_GCC49_IA32_RC_PATH  = DEF(GCC49_IA32_PREFIX)objcopy
 
-*_GCC49_IA32_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m32
+*_GCC49_IA32_ASLCC_FLAGS  = DEF(GCC49_ASLCC_FLAGS) -m32
 *_GCC49_IA32_ASLDLINK_FLAGS   = DEF(GCC49_IA32_X64_ASLDLINK_FLAGS) 
-Wl,-m,elf_i386
 *_GCC49_IA32_ASM_FLAGS= DEF(GCC49_ASM_FLAGS) -m32 -march=i386
 

Re: [edk2] [Patch] BaseTools: Remove EDK_SOURCE keyword

2019-01-14 Thread Feng, Bob C
Sure. Since ECC and UPT are two standalone tools, I'll send another patch for 
them.

-Original Message-
From: Gao, Liming 
Sent: Monday, January 14, 2019 9:57 PM
To: Feng, Bob C ; edk2-devel@lists.01.org
Cc: Laszlo Ersek 
Subject: RE: [Patch] BaseTools: Remove EDK_SOURCE keyword

Bob:
  This change cleans up EDK environments in GenFds. Could you continue to clean 
up EDK env in ECC and UPT tool?

Thanks
Liming
> -Original Message-
> From: Feng, Bob C
> Sent: Monday, January 14, 2019 7:14 PM
> To: edk2-devel@lists.01.org
> Cc: Feng, Bob C ; Gao, Liming 
> ; Laszlo Ersek 
> Subject: [Patch] BaseTools: Remove EDK_SOURCE keyword
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
> Remove unused EDK_SOURCE keyword in python tool.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng 
> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> ---
>  BaseTools/Source/Python/GenFds/GenFds.py  |  3 --
>  .../Python/GenFds/GenFdsGlobalVariable.py |  3 --
>  .../Source/Python/Workspace/InfBuildData.py   | 34 ---
>  3 files changed, 7 insertions(+), 33 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)': ' '
> }
> diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py 
> 

Re: [edk2] [PATCH] BaseTools/tools_def ARM GCC5: disable LTO for ASLC invocations

2019-01-14 Thread Gao, Liming
That's great. 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ard 
> Biesheuvel
> Sent: Monday, January 14, 2019 9:47 PM
> To: Gao, Liming 
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] [PATCH] BaseTools/tools_def ARM GCC5: disable LTO for 
> ASLC invocations
> 
> On Mon, 14 Jan 2019 at 14:38, Gao, Liming  wrote:
> >
> > I see IA32 and X64 arch both have this option. I have no idea on AArch64.
> >
> 
> I think we should just add it for all LTO toolchains in the GCC
> family. These are fixed size data structures so LTO is entirely
> pointless here.
> 
> 
> > > -Original Message-
> > > From: Philippe Mathieu-Daudé [mailto:phi...@redhat.com]
> > > Sent: Monday, January 14, 2019 9:36 PM
> > > To: Gao, Liming ; Leif Lindholm 
> > > ; Ard Biesheuvel 
> > > Cc: edk2-devel@lists.01.org
> > > Subject: Re: [edk2] [PATCH] BaseTools/tools_def ARM GCC5: disable LTO for 
> > > ASLC invocations
> > >
> > > On 1/14/19 2:18 PM, Gao, Liming wrote:
> > > > Ard:
> > > >   Could you consider the suggestion from 
> > > > https://lists.01.org/pipermail/edk2-devel/2019-January/034698.html?
> > >
> > > There might be a special case for Aarch64, but I'm not seeing it.
> > >
> > > >
> > > > Thanks
> > > > Liming
> > > >> -Original Message-
> > > >> From: Leif Lindholm [mailto:leif.lindh...@linaro.org]
> > > >> Sent: Monday, January 14, 2019 7:42 PM
> > > >> To: Ard Biesheuvel 
> > > >> Cc: edk2-devel@lists.01.org; Gao, Liming ; Feng, 
> > > >> Bob C 
> > > >> Subject: Re: [PATCH] BaseTools/tools_def ARM GCC5: disable LTO for 
> > > >> ASLC invocations
> > > >>
> > > >> On Mon, Jan 07, 2019 at 07:55:41AM +0100, Ard Biesheuvel wrote:
> > > >>> GCC for 32-bit ARM chokes on .aslc files when running with LTO
> > > >>> enabled. Since LTO has no benefit whatsoever here, just disable
> > > >>> it.
> > > >>>
> > > >>> Contributed-under: TianoCore Contribution Agreement 1.1
> > > >>> Signed-off-by: Ard Biesheuvel 
> > > >>
> > > >> Looks sensible.
> > > >> Reviewed-by: Leif Lindholm 
> > > >>
> > > >>> ---
> > > >>>  BaseTools/Conf/tools_def.template | 2 +-
> > > >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >>>
> > > >>> diff --git a/BaseTools/Conf/tools_def.template 
> > > >>> b/BaseTools/Conf/tools_def.template
> > > >>> index f7eb87af14c2..e68cfd9a4997 100755
> > > >>> --- a/BaseTools/Conf/tools_def.template
> > > >>> +++ b/BaseTools/Conf/tools_def.template
> > > >>> @@ -5145,7 +5145,7 @@ RELEASE_GCC5_X64_DLINK_FLAGS = 
> > > >>> DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
> > > >>>  *_GCC5_ARM_RC_PATH   = ENV(GCC5_ARM_PREFIX)objcopy
> > > >>>
> > > >>>  *_GCC5_ARM_ARCHCC_FLAGS  = -mthumb
> > > >>> -*_GCC5_ARM_ASLCC_FLAGS   = DEF(GCC_ASLCC_FLAGS)
> > > >>> +*_GCC5_ARM_ASLCC_FLAGS   = DEF(GCC_ASLCC_FLAGS) -fno-lto
> > > >>>  *_GCC5_ARM_ASLDLINK_FLAGS= DEF(GCC5_ARM_ASLDLINK_FLAGS)
> > > >>>  *_GCC5_ARM_ASM_FLAGS = DEF(GCC5_ARM_ASM_FLAGS)
> > > >>>  *_GCC5_ARM_DLINK2_FLAGS  = DEF(GCC5_ARM_DLINK2_FLAGS)
> > > >>> --
> > > >>> 2.20.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-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] BaseTools: Remove EDK_SOURCE keyword

2019-01-14 Thread Gao, Liming
Bob:
  This change cleans up EDK environments in GenFds. Could you continue to clean 
up EDK env in ECC and UPT tool?

Thanks
Liming
> -Original Message-
> From: Feng, Bob C
> Sent: Monday, January 14, 2019 7:14 PM
> To: edk2-devel@lists.01.org
> Cc: Feng, Bob C ; Gao, Liming ; 
> Laszlo Ersek 
> Subject: [Patch] BaseTools: Remove EDK_SOURCE keyword
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350
> Remove unused EDK_SOURCE keyword in python tool.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng 
> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> ---
>  BaseTools/Source/Python/GenFds/GenFds.py  |  3 --
>  .../Python/GenFds/GenFdsGlobalVariable.py |  3 --
>  .../Source/Python/Workspace/InfBuildData.py   | 34 ---
>  3 files changed, 7 insertions(+), 33 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)': ' '
> }
> 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
>   

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

2019-01-14 Thread Liming Gao
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/GenFw/GenFw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index 37278bbc68..af2c909866 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -1014,7 +1014,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;
@@ -2180,7 +2180,7 @@ Returns:
   // Set new base address into image
   //
   if (mOutImageType == FW_REBASE_IMAGE || mOutImageType == 
FW_SET_ADDRESS_IMAGE) {
-if ((PeHdr->Pe32.OptionalHeader.Magic == 
EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC)) {
+if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) 
{
   if (NewBaseAddress >= 0x1ULL) {
 Error (NULL, 0, 3000, "Invalid", "New base address is larger than 4G 
for 32bit PE image");
 goto Finish;
-- 
2.13.0.windows.1

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


  1   2   >