Re: [edk2] [PATCH v9] UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand paging in SMM

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

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of nkvangup
Sent: Monday, April 1, 2019 4:16 PM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen ; Dong, Eric ; 
Laszlo Ersek 
Subject: [edk2] [PATCH v9] UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand 
paging in SMM

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1593

For every SMI occurrence, save and restore CR2 register only when SMM on-demand 
paging support is enabled in 64 bit operation mode.
This is not a bug but to have better improvement of code.

Patch5 is updated with separate functions for Save and Restore of CR2 based on 
review feedback.

Patch6 - Removed Global Cr2 instead used function parameter.

Patch7 - Removed checking Cr2 with 0 as per feedback.

Patch8 and 9 - Aligned with EDK2 Coding style.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vanguput Narendra K 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Yao Jiewen 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c   | 26 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  |  9 ++---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 22 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c| 30 ++
 4 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
index b734a1ea8c..d1e146a70c 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
@@ -316,3 +316,29 @@ SetPageTableAttributes (
 
   return ;
 }
+
+/**
+  This function returns with no action for 32 bit.
+
+  @param[out]  *Cr2  Pointer to variable to hold CR2 register value.
+**/
+VOID
+SaveCr2 (
+  OUT UINTN  *Cr2
+  )
+{
+  return ;
+}
+
+/**
+  This function returns with no action for 32 bit.
+
+  @param[in]  Cr2  Value to write into CR2 register.
+**/
+VOID
+RestoreCr2 (
+  IN UINTN  Cr2
+  )
+{
+  return ;
+}
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 3b0b3b52ac..ce70f77709 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -1112,9 +1112,11 @@ SmiRendezvous (
   ASSERT(CpuIndex < mMaxNumberOfCpus);
 
   //
-  // Save Cr2 because Page Fault exception in SMM may override its value
+  // Save Cr2 because Page Fault exception in SMM may override its 
+ value,  // when using on-demand paging for above 4G memory.
   //
-  Cr2 = AsmReadCr2 ();
+  Cr2 = 0;
+  SaveCr2 (&Cr2);
 
   //
   // Perform CPU specific entry hooks
@@ -1253,10 +1255,11 @@ SmiRendezvous (
 
 Exit:
   SmmCpuFeaturesRendezvousExit (CpuIndex);
+
   //
   // Restore Cr2
   //
-  AsmWriteCr2 (Cr2);
+  RestoreCr2 (Cr2);
 }
 
 /**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index 84efb22981..38f9104117 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -1243,4 +1243,26 @@ EFIAPI
 PiSmmCpuSmiEntryFixupAddress (
  );
 
+/**
+  This function reads CR2 register when on-demand paging is enabled
+  for 64 bit and no action for 32 bit.
+
+  @param[out]  *Cr2  Pointer to variable to hold CR2 register value.
+**/
+VOID
+SaveCr2 (
+  OUT UINTN  *Cr2
+  );
+
+/**
+  This function writes into CR2 register when on-demand paging is 
+enabled
+  for 64 bit and no action for 32 bit.
+
+  @param[in]  Cr2  Value to write into CR2 register.
+**/
+VOID
+RestoreCr2 (
+  IN UINTN  Cr2
+  );
+
 #endif
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
index 2c77cb47a4..95eaf0b016 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
@@ -1053,3 +1053,33 @@ SetPageTableAttributes (
 
   return ;
 }
+
+/**
+  This function reads CR2 register when on-demand paging is enabled.
+
+  @param[out]  *Cr2  Pointer to variable to hold CR2 register value.
+**/
+VOID
+SaveCr2 (
+  OUT UINTN  *Cr2
+  )
+{
+  if (!mCpuSmmStaticPageTable) {
+*Cr2 = AsmReadCr2 ();
+  }
+}
+
+/**
+  This function restores CR2 register when on-demand paging is enabled.
+
+  @param[in]  Cr2  Value to write into CR2 register.
+**/
+VOID
+RestoreCr2 (
+  IN UINTN  Cr2
+  )
+{
+  if (!mCpuSmmStaticPageTable) {
+AsmWriteCr2 (Cr2);
+  }
+}
--
2.16.2.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 v6] UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand paging in SMM

2019-03-30 Thread Zeng, Star
Not comment to functionality. But just some observations about code style.
Please check them inline.

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> nkvangup
> Sent: Friday, March 29, 2019 12:58 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Dong, Eric ;
> Laszlo Ersek 
> Subject: [edk2] [PATCH v6] UefiCpuPkg\CpuSmm: Save & restore CR2 on-
> demand paging in SMM
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1593
> 
> For every SMI occurrence, save and restore CR2 register only when SMM
> on-demand paging support is enabled in 64 bit operation mode.
> This is not a bug but to have better improvement of code.
> 
> Patch5 is updated with separate functions for Save and Restore of CR2
> based on review feedback.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vanguput Narendra K 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Yao Jiewen 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c   | 26
> ++
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  |  9 ++---
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 22
> ++
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c| 30
> ++
>  4 files changed, 84 insertions(+), 3 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
> index b734a1ea8c..af96e42982 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
> @@ -316,3 +316,29 @@ SetPageTableAttributes (
> 
>return ;
>  }
> +
> +/**
> +  This function returns with no action for 32 bit.
> +
> +  @param[in]  *Cr2  Pointer to variable to hold CR2 register value

It will be more accurate with "@param[out]" according to 
https://edk2-docs.gitbooks.io/edk-ii-c-coding-standards-specification/content/5_source_files/57_c_programming.html#table-9-parameter-modifiers.

Same comment is also applied to other implementation or prototype in header 
file.

> +**/
> +VOID
> +SaveCr2 (
> +  UINTN  *Cr2

Align with the comments above, it will be better with "OUT UINTN  *Cr2"

Same comment is also applied to other implementation or prototype in header 
file.

> +  )
> +{
> +  return ;
> +}
> +
> +/**
> +  This function returns with no action for 32 bit.
> +
> +  @param[in]  Cr2  Value to write into CR2 register
> +**/
> +VOID
> +RestoreCr2 (
> +  UINTN  Cr2

It will be better with "IN UINTN  Cr2".

Same comment is also applied to other implementation or prototype in header 
file.

Thanks,
Star

> +  )
> +{
> +  return ;
> +}
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index 3b0b3b52ac..ce70f77709 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1112,9 +1112,11 @@ SmiRendezvous (
>ASSERT(CpuIndex < mMaxNumberOfCpus);
> 
>//
> -  // Save Cr2 because Page Fault exception in SMM may override its value
> +  // Save Cr2 because Page Fault exception in SMM may override its value,
> +  // when using on-demand paging for above 4G memory.
>//
> -  Cr2 = AsmReadCr2 ();
> +  Cr2 = 0;
> +  SaveCr2 (&Cr2);
> 
>//
>// Perform CPU specific entry hooks
> @@ -1253,10 +1255,11 @@ SmiRendezvous (
> 
>  Exit:
>SmmCpuFeaturesRendezvousExit (CpuIndex);
> +
>//
>// Restore Cr2
>//
> -  AsmWriteCr2 (Cr2);
> +  RestoreCr2 (Cr2);
>  }
> 
>  /**
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> index 84efb22981..c9d147c8a1 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> @@ -1243,4 +1243,26 @@ EFIAPI
>  PiSmmCpuSmiEntryFixupAddress (
>   );
> 
> +/**
> +  This function reads CR2 register when on-demand paging is enabled
> +  for 64 bit and no action for 32 bit.
> +
> +  @param[in]  *Cr2  Pointer to variable to hold CR2 register value
> +**/
> +VOID
> +SaveCr2 (
> +  UINTN  *Cr2
> +  );
> +
> +/**
> +  This function writes into CR2 register when on-demand paging is enabled
> +  for 64 bit and no action for 32 bit.
> +
> +  @param[in]  Cr2  Value to write into CR2 register
> +**/
> +VOID
> +RestoreCr2 (
> +  UINTN  Cr2
> +  );
> +
>  #endif
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> index 2c77cb47a4..6cb44fbbe5 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> @@ -1053,3 +1053,33 @@ SetPageTableAttributes (
> 
>return ;
>  }
> +
> +/**
> +  This function reads CR2 register when on-demand paging is enabled
> +
> +  @param[in]  *Cr2  Pointer to variable to hold CR2 register value
> +**/
> +VOID
> +SaveCr2 (
> +  UINTN  *Cr2
> +  )
> +{
> +  if (!mCpuSmmStaticPageTable) {
> +*Cr2 = AsmReadCr2 ();
> +  }
> +}
> +
> +/**
> +  This function restores CR2 register when on-demand paging is enabled
> +
> +  

Re: [edk2] [RFC PATCH] MdeModulePkg: add LockBoxNullLib for !IA32/X64 in .dsc

2019-03-20 Thread Zeng, Star
Another way to update the file is

[LibraryClasses.EBC]
  LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf

->

[LibraryClasses.EBC, LibraryClasses.ARM, LibraryClasses.AARCH64]
  LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf


Thanks,
Star
-Original Message-
From: Leif Lindholm [mailto:leif.lindh...@linaro.org] 
Sent: Thursday, March 21, 2019 1:43 AM
To: Laszlo Ersek 
Cc: edk2-devel@lists.01.org; ard.biesheu...@linaro.org; Wang, Jian J 
; Wu, Hao A ; Ni, Ray 
; Zeng, Star ; Andrew Fish 
; Kinney, Michael D 
Subject: Re: [RFC PATCH] MdeModulePkg: add LockBoxNullLib for !IA32/X64 in .dsc

On Wed, Mar 20, 2019 at 03:51:39PM +0100, Laszlo Ersek wrote:
> Hi Leif,
> 
> On 03/18/19 15:56, Leif Lindholm wrote:
> > Commit 05fd2a926833
> > ("MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList 
> > LockBox") added a dependency on LockBoxLib to NvmExpressPei, causing 
> > builds using MdeModulePkg.dsc to fail on architectures other than 
> > IA32/X64 with missing reference to 
> > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode.
> > 
> > Add a resolution for LockBoxNullLib for ARM/AARCH64 to restore builds.
> > 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Leif Lindholm 
> > ---
> > 
> > Note: this patch hides the symptom, but this isn't really the fix I 
> > would like to see.
> > 
> > The build error is caused by the chain of:
> > 1) NvmExpressPei depending on LockBoxLib
> > 2) LockBoxLib being mapped to SmmLockBoxPeiLib in 
> > [LibraryClasses.common.PEIM]
> > 3) SmmLockBoxPeiLib depending on PcdDxeIplSwitchToLongMode
> > 4) PcdDxeIplSwitchToLongMode being declared in
> >[PcdsFeatureFlag.IA32, PcdsFeatureFlag.X64] in MdeModulePkg.dsc
> > 
> > Now, an alternative quick-fix would be to move the PEIM LockBoxLib 
> > mapping into a [LibraryClasses.IA32.PEIM, LibraryClasses.X64.PEIM] 
> > section. But that would leave NvmExpressPei unbuildable on anything 
> > not IA32/X64.
> > 
> > Another option would be to add default declaration (for all other
> > architectures) of FALSE for PcdDxeIplSwitchToLongMode in 
> > MdeModulePkg.dec, but the current way this is expressed seems to 
> > treat this as an architecture-specific feature (which it is).
> > 
> > What I believe would be the cleanest solution would be to abstract 
> > NvmExpressPei to the point where it can function without the LockBoxLib.
> > But regardless, it does not look valid to me for something as 
> > architecture-specific as MdeModulePkg/Library/SmmLockBoxLib/ to live 
> > under .common sections in the .dsc. (And if this changes at some 
> > point, because we implement an ARM/AARCH64 equivalent based on 
> > StandaloneMmPkg, we will need a major refactoring of that library 
> > anyway.)
> > 
> > /
> > Leif
> > 
> > MdeModulePkg/MdeModulePkg.dsc | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/MdeModulePkg/MdeModulePkg.dsc 
> > b/MdeModulePkg/MdeModulePkg.dsc index 6cd1727a0d..6e27e9cb68 100644
> > --- a/MdeModulePkg/MdeModulePkg.dsc
> > +++ b/MdeModulePkg/MdeModulePkg.dsc
> > @@ -178,6 +178,7 @@ [LibraryClasses.common.MM_STANDALONE]
> >  [LibraryClasses.ARM, LibraryClasses.AARCH64]
> >ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
> >ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
> > +  LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
> >  
> >#
> ># It is not possible to prevent ARM compiler calls to generic intrinsic 
> > functions.
> > 
> 
> I think this patch is exactly the right solution.
> 
> The code added in commit 05fd2a926833 is gated by (BootMode == 
> BOOT_ON_S3_RESUME). That condition can never evaluate to TRUE on 
> ARM/AARCH64, presently. Accordingly, the stated goal of the commit 
> doesn't apply to ARM/AARCH64:
> 
> The purpose is to perform an on-demand (partial) NVM Express device
> enumeration/initialization to benefit the S3 resume performance.
> 
> Given that the RestoreLockBox() calls are never reached (which is 
> correct, by design, at the present level of ACPI S3 enablement in edk2 
> for ARM/AARCH64), causing the lockbox APIs to "do nothing beyond 
> compile" is exactly right. IMO anyway.
> 
> Once ARM/AARCH64 grow S3 support, a functional and secure LockBox will 
> have to be part of that. Perhaps it will use "standalone MM"; I'm not 
> sure. The point is, once the goal of the commit starts applying to 
> ARM/AARCH64, a functional LockBox will have been implemented for 
> ARM/AARCH64; and that lib instance will certainly not depend on 
> PcdDxeIplSwitchToLongMode.
> 
> Until such time, this patch is fine.

OK, I buy that argument.

*But* I still think the IA32/X64 specific library mappings should be moved out 
of .common LibraryClass sections.

Regards,

Leif

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


Re: [edk2] [RFC PATCH] MdeModulePkg: add LockBoxNullLib for !IA32/X64 in .dsc

2019-03-20 Thread Zeng, Star
Same case for AhciPei.

I am ok with the patch. Reviewed-by: Star Zeng 

Thanks,
Star
-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Wednesday, March 20, 2019 10:52 PM
To: Leif Lindholm ; edk2-devel@lists.01.org
Cc: ard.biesheu...@linaro.org; Wang, Jian J ; Wu, Hao A 
; Ni, Ray ; Zeng, Star 
; Andrew Fish ; Kinney, Michael D 

Subject: Re: [RFC PATCH] MdeModulePkg: add LockBoxNullLib for !IA32/X64 in .dsc

Hi Leif,

On 03/18/19 15:56, Leif Lindholm wrote:
> Commit 05fd2a926833
> ("MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList 
> LockBox") added a dependency on LockBoxLib to NvmExpressPei, causing 
> builds using MdeModulePkg.dsc to fail on architectures other than 
> IA32/X64 with missing reference to 
> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode.
> 
> Add a resolution for LockBoxNullLib for ARM/AARCH64 to restore builds.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Leif Lindholm 
> ---
> 
> Note: this patch hides the symptom, but this isn't really the fix I 
> would like to see.
> 
> The build error is caused by the chain of:
> 1) NvmExpressPei depending on LockBoxLib
> 2) LockBoxLib being mapped to SmmLockBoxPeiLib in 
> [LibraryClasses.common.PEIM]
> 3) SmmLockBoxPeiLib depending on PcdDxeIplSwitchToLongMode
> 4) PcdDxeIplSwitchToLongMode being declared in
>[PcdsFeatureFlag.IA32, PcdsFeatureFlag.X64] in MdeModulePkg.dsc
> 
> Now, an alternative quick-fix would be to move the PEIM LockBoxLib 
> mapping into a [LibraryClasses.IA32.PEIM, LibraryClasses.X64.PEIM] 
> section. But that would leave NvmExpressPei unbuildable on anything 
> not IA32/X64.
> 
> Another option would be to add default declaration (for all other
> architectures) of FALSE for PcdDxeIplSwitchToLongMode in 
> MdeModulePkg.dec, but the current way this is expressed seems to treat 
> this as an architecture-specific feature (which it is).
> 
> What I believe would be the cleanest solution would be to abstract 
> NvmExpressPei to the point where it can function without the LockBoxLib.
> But regardless, it does not look valid to me for something as 
> architecture-specific as MdeModulePkg/Library/SmmLockBoxLib/ to live 
> under .common sections in the .dsc. (And if this changes at some 
> point, because we implement an ARM/AARCH64 equivalent based on 
> StandaloneMmPkg, we will need a major refactoring of that library 
> anyway.)
> 
> /
> Leif
> 
> MdeModulePkg/MdeModulePkg.dsc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc 
> b/MdeModulePkg/MdeModulePkg.dsc index 6cd1727a0d..6e27e9cb68 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -178,6 +178,7 @@ [LibraryClasses.common.MM_STANDALONE]
>  [LibraryClasses.ARM, LibraryClasses.AARCH64]
>ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
>ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
> +  LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
>  
>#
># It is not possible to prevent ARM compiler calls to generic intrinsic 
> functions.
> 

I think this patch is exactly the right solution.

The code added in commit 05fd2a926833 is gated by (BootMode == 
BOOT_ON_S3_RESUME). That condition can never evaluate to TRUE on ARM/AARCH64, 
presently. Accordingly, the stated goal of the commit doesn't apply to 
ARM/AARCH64:

The purpose is to perform an on-demand (partial) NVM Express device
enumeration/initialization to benefit the S3 resume performance.

Given that the RestoreLockBox() calls are never reached (which is correct, by 
design, at the present level of ACPI S3 enablement in edk2 for ARM/AARCH64), 
causing the lockbox APIs to "do nothing beyond compile" is exactly right. IMO 
anyway.

Once ARM/AARCH64 grow S3 support, a functional and secure LockBox will have to 
be part of that. Perhaps it will use "standalone MM"; I'm not sure. The point 
is, once the goal of the commit starts applying to ARM/AARCH64, a functional 
LockBox will have been implemented for ARM/AARCH64; and that lib instance will 
certainly not depend on PcdDxeIplSwitchToLongMode.

Until such time, this patch is fine.

Reviewed-by: Laszlo Ersek 

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


Re: [edk2] [PATCH v2 3/3] UefiCpuPkg/UefiCpuPkg.uni: Add the prompt and help information

2019-03-12 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Shenglei 
Zhang
Sent: Tuesday, March 12, 2019 10:05 AM
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek ; Dong, Eric 
Subject: [edk2] [PATCH v2 3/3] UefiCpuPkg/UefiCpuPkg.uni: Add the prompt and 
help information

The prompt and help information are missing in UefiPkg.uni.
https://bugzilla.tianocore.org/show_bug.cgi?id=1600

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang 
Reviewed-by: Eric Dong 
---
 UefiCpuPkg/UefiCpuPkg.uni | 4 
 1 file changed, 4 insertions(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.uni b/UefiCpuPkg/UefiCpuPkg.uni index 
b132ce62cf..0e57b6ac98 100644
--- a/UefiCpuPkg/UefiCpuPkg.uni
+++ b/UefiCpuPkg/UefiCpuPkg.uni
@@ -114,6 +114,10 @@
 
 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackSize_HELP  #language en-US 
"Specifies stack size in bytes for each processor in SMM."
 
+#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackSize_PROMPT  #language 
en-US "Processor stack size in SMM."
+
+#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackSize_Help  #language en-US 
"Specifies stack size in bytes for each processor in SMM."
+
 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmApSyncTimeout_PROMPT  #language 
en-US "AP synchronization timeout value in SMM"
 
 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmApSyncTimeout_HELP  #language 
en-US "Specifies timeout value in microseconds for the BSP in SMM to wait for 
all APs to come into SMM."
--
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 v2 2/4] UefiCpuPkg/RegisterCpuFeaturesLib: Optimize PCD PcdCpuFeaturesUserConfiguration.

2019-03-05 Thread Zeng, Star
And suggest update the title to be like "UefiCpuPkg: Retire 
PcdCpuFeaturesUserConfiguration".

Thanks,
Star
-Original Message-----
From: Zeng, Star 
Sent: Tuesday, March 5, 2019 5:55 PM
To: Dong, Eric ; edk2-devel@lists.01.org
Cc: Ni, Ray ; Laszlo Ersek (ler...@redhat.com) 
; Gao, Liming ; Zeng, Star 

Subject: RE: [edk2] [Patch v2 2/4] UefiCpuPkg/RegisterCpuFeaturesLib: Optimize 
PCD PcdCpuFeaturesUserConfiguration.

It should be an incompatible change to remove PcdCpuFeaturesUserConfiguration.
Please add upgrade notes for it. I know upgrade notes for 2019 Q1 stable tag is 
at https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Notes. 
I do not know where is the link for 2019 Q1 stable tag. Liming may know it.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Dong
Sent: Friday, March 1, 2019 1:40 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch v2 2/4] UefiCpuPkg/RegisterCpuFeaturesLib: Optimize PCD 
PcdCpuFeaturesUserConfiguration.

Merge PcdCpuFeaturesUserConfiguration into PcdCpuFeaturesSetting.
Use PcdCpuFeaturesSetting as input for the user input feature setting Use 
PcdCpuFeaturesSetting as output for the final CPU feature setting

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1375

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 71 +-
 .../DxeRegisterCpuFeaturesLib.inf  |  3 +-
 .../PeiRegisterCpuFeaturesLib.inf  |  3 +-
 .../RegisterCpuFeaturesLib/RegisterCpuFeatures.h   |  1 -
 UefiCpuPkg/UefiCpuPkg.dec  |  9 +--
 5 files changed, 21 insertions(+), 66 deletions(-)

diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c 
b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
index bae92b89a6..d877caff74 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
@@ -21,16 +21,21 @@ CHAR16 *mRegisterTypeStr[] = {L"MSR", L"CR", L"MMIO", 
L"CACHE", L"SEMAP", L"INVA
   Worker function to save PcdCpuFeaturesCapability.
 
   @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer
+  @param[in]  FeatureMaskSize   CPU feature bits mask buffer size.
+
 **/
 VOID
 SetCapabilityPcd (
-  IN UINT8   *SupportedFeatureMask
+  IN UINT8   *SupportedFeatureMask,
+  IN UINT32  FeatureMaskSize
   )
 {
   EFI_STATUS Status;
   UINTN  BitMaskSize;
 
   BitMaskSize = PcdGetSize (PcdCpuFeaturesCapability);
+  ASSERT (FeatureMaskSize == BitMaskSize);
+
   Status = PcdSetPtrS (PcdCpuFeaturesCapability, &BitMaskSize, 
SupportedFeatureMask);
   ASSERT_EFI_ERROR (Status);
 }
@@ -53,48 +58,6 @@ SetSettingPcd (
   ASSERT_EFI_ERROR (Status);
 }
 
-/**
-  Worker function to get PcdCpuFeaturesSupport.
-
-  @return  The pointer to CPU feature bits mask buffer.
-**/
-UINT8 *
-GetSupportPcd (
-  VOID
-  )
-{
-  UINT8  *SupportBitMask;
-
-  SupportBitMask = AllocateCopyPool (
-  PcdGetSize (PcdCpuFeaturesSupport),
-  PcdGetPtr (PcdCpuFeaturesSupport)
-  );
-  ASSERT (SupportBitMask != NULL);
-
-  return SupportBitMask;
-}
-
-/**
-  Worker function to get PcdCpuFeaturesUserConfiguration.
-
-  @return  The pointer to CPU feature bits mask buffer.
-**/
-UINT8 *
-GetConfigurationPcd (
-  VOID
-  )
-{
-  UINT8  *SupportBitMask;
-
-  SupportBitMask = AllocateCopyPool (
-  PcdGetSize (PcdCpuFeaturesUserConfiguration),
-  PcdGetPtr (PcdCpuFeaturesUserConfiguration)
-  );
-  ASSERT (SupportBitMask != NULL);
-
-  return SupportBitMask;
-}
-
 /**
   Collects CPU type and feature information.
 
@@ -287,7 +250,6 @@ CpuInitDataInitialize (
   // Get support and configuration PCDs
   //
   CpuFeaturesData->SupportPcd   = GetSupportPcd ();
-  CpuFeaturesData->ConfigurationPcd = GetConfigurationPcd ();  }
 
 /**
@@ -610,16 +572,9 @@ AnalysisProcessorFeatures (
   //
   // Calculate the last setting
   //
-
   CpuFeaturesData->SettingPcd = AllocateCopyPool 
(CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcd);
   ASSERT (CpuFeaturesData->SettingPcd != NULL);
-  SupportedMaskAnd (CpuFeaturesData->SettingPcd, 
CpuFeaturesData->ConfigurationPcd);
-
-  //
-  // Save PCDs and display CPU PCDs
-  //
-  SetCapabilityPcd (CpuFeaturesData->CapabilityPcd);
-  SetSettingPcd (CpuFeaturesData->SettingPcd);
+  SupportedMaskAnd (CpuFeaturesData->SettingPcd, PcdGetPtr 
+ (PcdCpuFeaturesSetting));
 
   //
   // Dump the last CPU feature list
@@ -643,14 +598,20 @@ AnalysisProcessorFeatures (
 }
 DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSupport:\n"));
 DumpCpuFeatureMask (CpuFea

Re: [edk2] [Patch v2 2/4] UefiCpuPkg/RegisterCpuFeaturesLib: Optimize PCD PcdCpuFeaturesUserConfiguration.

2019-03-05 Thread Zeng, Star
It should be an incompatible change to remove PcdCpuFeaturesUserConfiguration.
Please add upgrade notes for it. I know upgrade notes for 2019 Q1 stable tag is 
at https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Notes. 
I do not know where is the link for 2019 Q1 stable tag. Liming may know it.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Dong
Sent: Friday, March 1, 2019 1:40 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch v2 2/4] UefiCpuPkg/RegisterCpuFeaturesLib: Optimize PCD 
PcdCpuFeaturesUserConfiguration.

Merge PcdCpuFeaturesUserConfiguration into PcdCpuFeaturesSetting.
Use PcdCpuFeaturesSetting as input for the user input feature setting Use 
PcdCpuFeaturesSetting as output for the final CPU feature setting

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1375

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 71 +-
 .../DxeRegisterCpuFeaturesLib.inf  |  3 +-
 .../PeiRegisterCpuFeaturesLib.inf  |  3 +-
 .../RegisterCpuFeaturesLib/RegisterCpuFeatures.h   |  1 -
 UefiCpuPkg/UefiCpuPkg.dec  |  9 +--
 5 files changed, 21 insertions(+), 66 deletions(-)

diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c 
b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
index bae92b89a6..d877caff74 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
@@ -21,16 +21,21 @@ CHAR16 *mRegisterTypeStr[] = {L"MSR", L"CR", L"MMIO", 
L"CACHE", L"SEMAP", L"INVA
   Worker function to save PcdCpuFeaturesCapability.
 
   @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer
+  @param[in]  FeatureMaskSize   CPU feature bits mask buffer size.
+
 **/
 VOID
 SetCapabilityPcd (
-  IN UINT8   *SupportedFeatureMask
+  IN UINT8   *SupportedFeatureMask,
+  IN UINT32  FeatureMaskSize
   )
 {
   EFI_STATUS Status;
   UINTN  BitMaskSize;
 
   BitMaskSize = PcdGetSize (PcdCpuFeaturesCapability);
+  ASSERT (FeatureMaskSize == BitMaskSize);
+
   Status = PcdSetPtrS (PcdCpuFeaturesCapability, &BitMaskSize, 
SupportedFeatureMask);
   ASSERT_EFI_ERROR (Status);
 }
@@ -53,48 +58,6 @@ SetSettingPcd (
   ASSERT_EFI_ERROR (Status);
 }
 
-/**
-  Worker function to get PcdCpuFeaturesSupport.
-
-  @return  The pointer to CPU feature bits mask buffer.
-**/
-UINT8 *
-GetSupportPcd (
-  VOID
-  )
-{
-  UINT8  *SupportBitMask;
-
-  SupportBitMask = AllocateCopyPool (
-  PcdGetSize (PcdCpuFeaturesSupport),
-  PcdGetPtr (PcdCpuFeaturesSupport)
-  );
-  ASSERT (SupportBitMask != NULL);
-
-  return SupportBitMask;
-}
-
-/**
-  Worker function to get PcdCpuFeaturesUserConfiguration.
-
-  @return  The pointer to CPU feature bits mask buffer.
-**/
-UINT8 *
-GetConfigurationPcd (
-  VOID
-  )
-{
-  UINT8  *SupportBitMask;
-
-  SupportBitMask = AllocateCopyPool (
-  PcdGetSize (PcdCpuFeaturesUserConfiguration),
-  PcdGetPtr (PcdCpuFeaturesUserConfiguration)
-  );
-  ASSERT (SupportBitMask != NULL);
-
-  return SupportBitMask;
-}
-
 /**
   Collects CPU type and feature information.
 
@@ -287,7 +250,6 @@ CpuInitDataInitialize (
   // Get support and configuration PCDs
   //
   CpuFeaturesData->SupportPcd   = GetSupportPcd ();
-  CpuFeaturesData->ConfigurationPcd = GetConfigurationPcd ();  }
 
 /**
@@ -610,16 +572,9 @@ AnalysisProcessorFeatures (
   //
   // Calculate the last setting
   //
-
   CpuFeaturesData->SettingPcd = AllocateCopyPool 
(CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcd);
   ASSERT (CpuFeaturesData->SettingPcd != NULL);
-  SupportedMaskAnd (CpuFeaturesData->SettingPcd, 
CpuFeaturesData->ConfigurationPcd);
-
-  //
-  // Save PCDs and display CPU PCDs
-  //
-  SetCapabilityPcd (CpuFeaturesData->CapabilityPcd);
-  SetSettingPcd (CpuFeaturesData->SettingPcd);
+  SupportedMaskAnd (CpuFeaturesData->SettingPcd, PcdGetPtr 
+ (PcdCpuFeaturesSetting));
 
   //
   // Dump the last CPU feature list
@@ -643,14 +598,20 @@ AnalysisProcessorFeatures (
 }
 DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSupport:\n"));
 DumpCpuFeatureMask (CpuFeaturesData->SupportPcd);
-DEBUG ((DEBUG_INFO, "PcdCpuFeaturesUserConfiguration:\n"));
-DumpCpuFeatureMask (CpuFeaturesData->ConfigurationPcd);
 DEBUG ((DEBUG_INFO, "PcdCpuFeaturesCapability:\n"));
 DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcd);
-DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSetting:\n"));
+DEBUG ((DEBUG_INFO, "Origin PcdCpuFeaturesSetting:\n"));
+DumpCpuFeatureMask (PcdGetPtr (PcdCpuFeaturesSetting));
+DEBUG ((DEBUG_INFO, "Final PcdCpuFeaturesSetting:\n"));
 DumpCpuFeatureMask (CpuFeaturesData->S

Re: [edk2] [Patch] UefiCpuPkg/MpInitLib: Direct allocate buffer for Wake up Buffer.

2019-03-04 Thread Zeng, Star
Just an idea to avoid hard code value 0x88000.

Before EndOfDxe: Allocate buffer in AllocateResetVector(), and free buffer in 
FreeResetVector().
At EndOfDxe (it is after LegacyBiosDxe driver entry point) callback: Allocate 
buffer and record it to CpuMpData->WakeupBuffer, and always occupy the buffer, 
that means no free.
After EndOfDxe: Use CpuMpData->WakeupBuffer.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Dong
Sent: Tuesday, March 5, 2019 10:07 AM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch] UefiCpuPkg/MpInitLib: Direct allocate buffer for Wake 
up Buffer.

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

Current CpuDxe driver "borrows" Wakeup Buffer (through Allocate & free to get 
the buffer pointer, backup the buffer data before using it and restore it after 
using).  Now this logic met a problem described in the above BZ because the 
test tool and the CpuDxe both use the same memory at the same time.

In order to fix the above issue, CpuDxe changed to allocate the buffer below 1M 
instead of borrow it. After investigation, we found below
0x88000 is the possible space which can be used. For now, range
0x6 ~ 0x88000 used for Legacy OPROMs by LegacyBios driver. And it tries to 
allocate these range page(4K size) by page. It just reports warning message if 
specific page been used by others already.

Also CpuDxe driver will produce CPU arch protocol and LegacyBios driver has 
dependency for this protocol. So CpuDxe driver will start before LegacyBios 
driver and CpuDxe driver can allocate that space successful.

With this change, CpuDxe driver will use 0x87000 ~ 0x88000 as wakeup buffer.

Cc: Ray Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index b2307cbb61..5bc9a47efb 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -76,7 +76,7 @@ SaveCpuMpData (
 }
 
 /**
-  Get available system memory below 1MB by specified size.
+  Get available system memory below 0x88000 by specified size.
 
   @param[in] WakeupBufferSize   Wakeup buffer size required
 
@@ -91,7 +91,19 @@ GetWakeupBuffer (
   EFI_STATUS  Status;
   EFI_PHYSICAL_ADDRESSStartAddress;
 
-  StartAddress = BASE_1MB;
+  //
+  // Current "Borrow" space mechanism caused potential race condition 
+ if both  // AP and the original owner use the share space.
+  //
+  // LegacyBios driver tries to allocate 4K pages between 0x6 ~ 
+ 0x88000  // space. It will just report an waring message if the page 
+ has been allocate  // by other drivers.
+  // LagacyBios driver depends on CPU Arch protocol, so it will start 
+ after  // CpuDxe driver which produce Cpu Arch Protocol and use this library.
+  // So below allocate logic will be trigged before LegacyBios driver 
+ and it  // will always return success.
+  //
+  StartAddress = BASE_512KB + BASE_32KB;
   Status = gBS->AllocatePages (
   AllocateMaxAddress,
   EfiBootServicesData,
@@ -99,17 +111,13 @@ GetWakeupBuffer (
   &StartAddress
   );
   ASSERT_EFI_ERROR (Status);
-  if (!EFI_ERROR (Status)) {
-Status = gBS->FreePages(
-   StartAddress,
-   EFI_SIZE_TO_PAGES (WakeupBufferSize)
-   );
-ASSERT_EFI_ERROR (Status);
-DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",
-(UINTN) StartAddress, WakeupBufferSize));
-  } else {
+  if (EFI_ERROR (Status)) {
 StartAddress = (EFI_PHYSICAL_ADDRESS) -1;
   }
+
+  DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",
+  (UINTN) StartAddress, WakeupBufferSize));
+
   return (UINTN) StartAddress;
 }
 
--
2.15.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 v2] MdePkg/Library: Install dummy variable arch protocol

2019-03-01 Thread Zeng, Star
Agree with Ard's feedbacks.

And it seems only needed for VariableSmmRuntimeDxe to co-work with 
VariableStandaloneMm.
So is it more suitable to be in StandaloneMmPkg?


Thanks,
Star
-Original Message-
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org] 
Sent: Friday, March 1, 2019 7:31 PM
To: Jagadeesh Ujja 
Cc: edk2-devel@lists.01.org; Gao, Liming ; Zhang, Chao B 
; Leif Lindholm ; Zeng, Star 
; Yao, Jiewen ; Kinney, Michael D 

Subject: Re: [PATCH v2] MdePkg/Library: Install dummy variable arch protocol

On Fri, 1 Mar 2019 at 12:14, Jagadeesh Ujja  wrote:
>
> In a system implementing the variable store in MM, there are no 
> variable arch protocol and variable write arch protocol installed into 
> the DXE_SMM protocol database. On such systems, it is not required to 
> locate these protocols by the DXE runtime variable drivers because it 
> can be assumed that these protocols are already installed in the MM 
> context. But then such an implementation will deviate from the 
> existing traditional MM based variable driver implementation.
>
> So in order to maintain consistency with the traditional MM variable 
> driver implementation, allow platforms to install dummy versions of 
> these protocols into the DXE protocol database but these protocol will 
> not be consumed by non-secure variable service runtime driver.
>
> The Platform which uses StandaloneMM based secure variable storage 
> have to include this library as below.
>
>   ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf {
> 
>   NULL|MdePkg/Library/VariableMmDependency/VariableMmDependency.inf
>   }
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jagadeesh Ujja 
> ---
> Changes since v1:
> - This is a next version of patch
>“MdeModulePkg/VariableSmmRuntimeDxe: Refactor locating Variable Arch 
> Protocol”.
>
> [https://lists.01.org/pipermail/edk2-devel/2019-February/036885.html]
> - Addressed the comments from Ard Biesheuvel and Zeng Star
> - Can this library be placed in MdePkg rather then the StandaloneMmPkg?
>

This does not belong in MdePkg. What is wrong with keeping it in 
StandaloneMmPkg?

>  MdePkg/Library/VariableMmDependency/VariableMmDependency.c   | 85 
> 
>  MdePkg/Library/VariableMmDependency/VariableMmDependency.inf | 48 
> +++
>  2 files changed, 133 insertions(+)
>
> diff --git 
> a/MdePkg/Library/VariableMmDependency/VariableMmDependency.c 
> b/MdePkg/Library/VariableMmDependency/VariableMmDependency.c
> new file mode 100644
> index 000..6e5117e
> --- /dev/null
> +++ b/MdePkg/Library/VariableMmDependency/VariableMmDependency.c
> @@ -0,0 +1,85 @@
> +/** @file
> +  Runtime DXE part corresponding to StanaloneMM variable module.
> +
> +This module installs dummy variable arch protocol and dummy variable 
> +write arch protocol to StandaloneMM runtime variable service.
> +

I think 'dummy' is a misnomer here. They are NULL protocols in the sense that 
only their presence is signifcant, and the protocol does not have an 
implementation. But this is true for traditional MM as well.

> +Copyright (c) 2019, ARM Ltd. All rights reserved.
> +
> +This program and the accompanying materials are licensed and made 
> +available under the terms and conditions of the BSD License which 
> +accompanies this distribution.  The full text of the license may be 
> +found at http://opensource.org/licenses/bsd-license.php.
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include 
> +#include 
> +
> +/**
> +  Notify the system that the SMM variable driver is ready.
> +**/
> +VOID
> +VariableNotifySmmReady (
> +  VOID
> +  )
> +{
> +  EFI_STATUSStatus;
> +  EFI_HANDLEHandle;
> +
> +  Handle = NULL;
> +  Status = gBS->InstallProtocolInterface (
> +  &Handle,
> +  &gEfiSmmVariableProtocolGuid,
> +  EFI_NATIVE_INTERFACE,
> +  NULL
> +  );
> +  ASSERT_EFI_ERROR (Status);
> +}
> +
> +/**
> +  Notify the system that the SMM variable write driver is ready.
> +**/
> +VOID
> +VariableNotifySmmWriteReady (
> +  VOID
> +  )
> +{
> +  EFI_STATUSStatus;
> +  EFI_HANDLEHandle;
> +
> +  Handle = NULL;
> +  Status = gBS->InstallProtocolInterface (
> +  &Handle,
> +  &gSmmVariableWriteGuid,
> +  EFI_NATIVE_INTERFACE,
> +  NULL
> +  );
> +  ASSERT_EFI_ERROR (Status);
> +}
> 

Re: [edk2] [PATCH] MdeModulePkg/VariableSmmRuntimeDxe: Refactor locating Variable Arch Protocol

2019-02-21 Thread Zeng, Star

On 2019/2/21 17:11, Ard Biesheuvel wrote:

On Thu, 21 Feb 2019 at 10:04, Laszlo Ersek  wrote:


On 02/20/19 13:23, Ard Biesheuvel wrote:

On Wed, 20 Feb 2019 at 06:53, Jagadeesh Ujja  wrote:


hi Ard,
On Tue, Feb 19, 2019 at 6:55 PM Ard Biesheuvel
 wrote:


Hello Jagadeesh,

On Tue, 19 Feb 2019 at 11:47, Jagadeesh Ujja  wrote:


In preparation for providing a standalone MM based non-secure variable
runtime driver, factor out some portions that are specific to the
traditional driver, mainly related to locating variable arch protocol
and variable write arch protocol, which are not required to be located
when using standalone MM based secure variable implementation.



While i think this change is correct from a technical perspective, I
don't think this is the right approach.


these changes are mandatory, this is one of the possible solution.


It was a deliberate decision to expose the MM services in a way that
only the producer of the communication protocol is aware of the
implementation details, i.e., whether it is backed by tradtional MM or
standalone MM.


can you please provide more details on how "exposing the MM services"
will help to resolve the issue here. if this helps, definitely i will use that.



Let me rephrase this for the benefit of the MdeModulePkg maintainers,
and ask them their opinion.

Currently, the DXE runtime driver that produces the architectural
varstore protocols that are based on communication with MM components
living elsewhere, rely on the EFI protocol database for sequencing.
I.e., after dispatch, they wait for certain protocols to be installed
into the DXE protocol database by the SMM drivers before proceeding to
install the variable arch protocols.

This does not work for standalone MM, since it has no access to the
DXE protocol database, nor is it needed, since it may be assumed that
the MM execution context is fully configured by the time the DXE phase
starts.

Jagadeesh's proposal is to factor this out, and create two different
.INFs to build the same DXE runtime driver in two different ways. This
defeats the purpose of having an abstract MM communication protocol,
so it is something I would like to avoid. On the other hand, is it not
obvious how to parameterize this requirement in another way.

For the moment, I could live with putting this into a library, and
leave it up to the platform to ensure the combination of the library
resolution with the driver that produces the MM communicate protocol
is a sane one.

Any thoughts?


I think I'm missing the gist of the library approach; still, would it be
possible for affected platforms (i.e. those that depend on standalone
MM) to procude the necessary DXE protocols (for unblocking the variable
runtime driver) in a platform DXE driver?



Yes, that is the other option: we could create a library that
unconditionally produces those protocols and hook it into the MM
communication driver via NULL library class resolution.



I am not familiar with standalone MM, either ARM. So may have no much 
valuable opinion.


For this case, standalone MM could not install DXE protocols into DXE 
protocol database to notify the wrapper (VariableSmmRuntimeDxe), so need 
another way to install the DXE protocols, right?
Could standalone MM assume the MM handler for variable is ready when MM 
communication driver runs?
If yes, a NULL library instance should work (as a stub to install the 
DXE protocols in its constructor). :)



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


Re: [edk2] [PATCH] MdeModulePkg/PropertiesTableAttributesDxe: Remove this driver

2019-02-18 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Wang, Jian J 
Sent: Monday, February 18, 2019 10:16 PM
To: Zhang, Shenglei ; edk2-devel@lists.01.org
Cc: Wu, Hao A ; Ni, Ray ; Zeng, Star 

Subject: RE: [PATCH] MdeModulePkg/PropertiesTableAttributesDxe: Remove this 
driver


Reviewed-by: Jian J Wang 

> -Original Message-
> From: Zhang, Shenglei
> Sent: Monday, February 18, 2019 4:53 PM
> To: edk2-devel@lists.01.org
> Cc: Wang, Jian J ; Wu, Hao A 
> ; Ni, Ray ; Zeng, Star 
> 
> Subject: [PATCH] MdeModulePkg/PropertiesTableAttributesDxe: Remove 
> this driver
> 
> This functionality of this driver has been deprecated and no platform 
> employs this driver. It can be removed completely.
> https://bugzilla.tianocore.org/show_bug.cgi?id=1475
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Ray Ni 
> Cc: Star Zeng 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Shenglei Zhang 
> ---
>  MdeModulePkg/MdeModulePkg.dsc |   1 -
>  .../PropertiesTableAttributesDxe.c| 208 --
>  .../PropertiesTableAttributesDxe.inf  |  56 -
>  .../PropertiesTableAttributesDxe.uni  |  23 --
>  .../PropertiesTableAttributesDxeExtra.uni |  23 --
>  5 files changed, 311 deletions(-)
>  delete mode 100644
> MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableAtt
> ribu
> tesDxe.c
>  delete mode 100644
> MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableAtt
> ribu
> tesDxe.inf
>  delete mode 100644
> MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableAtt
> ribu
> tesDxe.uni
>  delete mode 100644
> MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableAtt
> ribu
> tesDxeExtra.uni
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc 
> b/MdeModulePkg/MdeModulePkg.dsc index 4f2ac8ae89..388bca25bd 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -413,7 +413,6 @@
>MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
>MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
> 
> -
> MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableAtt
> ribu
> tesDxe.inf
>MdeModulePkg/Universal/FileExplorerDxe/FileExplorerDxe.inf  {
>  
>
> FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.i
> nf
> diff --git
> a/MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableA
> ttri
> butesDxe.c
> b/MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableA
> ttri
> butesDxe.c
> deleted file mode 100644
> index 4d1a46f64c..00
> ---
> a/MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableA
> ttri
> butesDxe.c
> +++ /dev/null
> @@ -1,208 +0,0 @@
> -/** @file
> -  This module sets default policy for attributes of EfiACPIMemoryNVS 
> and EfiReservedMemoryType.
> -
> -  This module sets EFI_MEMORY_XP for attributes of EfiACPIMemoryNVS 
> and EfiReservedMemoryType
> -  in UEFI memory map, if and only of PropertiesTable is published and 
> has BIT0 set.
> -
> -Copyright (c) 2015 - 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 
> -#include 
> -#include 
> -#include  -#include 
>  -#include  
> -#include  -#include 
> -
> -/**
> -  Converts a number of EFI_PAGEs to a size in bytes.
> -
> -  NOTE: Do not use EFI_PAGES_TO_SIZE because it handles UINTN only.
> -
> -  @param  Pages The number of EFI_PAGES.
> -
> -  @return  The number of bytes associated with the number of 
> EFI_PAGEs specified
> -   by Pages.
> -**/
> -UINT64
> -EfiPagesToSize (
> -  IN UINT64 Pages
> -  )
> -{
> -  return LShiftU64 (Pages, EFI_PAGE_SHIFT); -}
> -
> -/**
> -  Set memory attributes according to default policy.
> -
> -  @param  MemoryMapA pointer to the buffer in which firmware places
> the current memory map.
> -  @param  MemoryMapSizeSize, in bytes, of the MemoryMap buffer.
> -  @param  DescriptorSize   size, in bytes, of an individual
> EFI_MEMORY_DESCRIPTOR.
> -**/
> -VOID
> -SetMemorySpaceAttributesDefault (
> -  IN EFI_MEMORY_DESCRIPTOR  *MemoryMap,
> -  IN UINTN  MemoryMapSize,
> -  IN UINTN

Re: [edk2] [patch V4] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible

2019-02-18 Thread Zeng, Star
Reviewed-by: Star Zeng .

-Original Message-
From: Bi, Dandan 
Sent: Monday, February 18, 2019 9:37 PM
To: edk2-devel@lists.01.org
Cc: Max Knutsen ; Zeng, Star ; 
Wang, Jian J ; Wu, Hao A ; Michael 
Turner ; Gao, Liming 
Subject: [patch V4] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool 
if possible

From: Max Knutsen 

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

V2: simplify the code logic.
update
if (!mHaveExitedBootServices &&
  (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) {
  gBS->FreePool (StatusCodeData);
}
to
if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
  gBS->FreePool (StatusCodeData);
}

V3:
And the code below into the else condition (stack buffer is not enough) in 
/DxeReportStatusCodeLib/ReportStatusCodeLib.c

  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
return EFI_UNSUPPORTED;
  }

V4:
Refine code logic.

When report status code with ExtendedData data, and the extended data can fit 
in the local static buffer, there is no need to use AllocatePool to hold the 
ExtendedData data.

This patch is just to do the enhancement to avoid using AllocatePool.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael Turner 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../ReportStatusCodeLib.c | 45 +--
 .../ReportStatusCodeLib.c | 14 +++---
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index b28dc5c3bb..d3cf8b1de3 100644
--- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -494,41 +494,38 @@ ReportStatusCodeEx (
   UINT64Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];
 
   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
 
-  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
-return EFI_UNSUPPORTED;
-  }
-
-  //
-  // Retrieve the current TPL
-  //
-  Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
-  gBS->RestoreTPL (Tpl);
+  if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
+//
+// Use Buffer instead of allocating if possible.
+//
+StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;  } else {
+if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
+  return EFI_UNSUPPORTED;
+}
 
-  StatusCodeData = NULL;
-  if (Tpl <= TPL_NOTIFY) {
 //
-// Allocate space for the Status Code Header and its buffer
+// Retrieve the current TPL
 //
-gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **)&StatusCodeData);
-  }
+Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
+gBS->RestoreTPL (Tpl);
+
+if (Tpl > TPL_NOTIFY) {
+  return EFI_OUT_OF_RESOURCES;
+}
 
-  if (StatusCodeData == NULL) {
 //
-// If a buffer could not be allocated, then see if the local variable 
Buffer can be used
+// Allocate space for the Status Code Header and its buffer
 //
-if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
-  //
-  // The local variable Buffer not large enough to hold the extended data 
associated
-  // with the status code being reported.
-  //
-  DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be 
reported!\n"));
+StatusCodeData = NULL;
+gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **)&StatusCodeData);
+if (StatusCodeData == NULL) {
   return EFI_OUT_OF_RESOURCES;
 }
-StatusCodeData = (EFI_STATUS_CODE_DATA  *)Buffer;
   }
 
   //
   // Fill in the extended data header
   //
@@ -626,6 +623,6 @@ EFIAPI
 ReportDebugCodeEnabled (
   VOID
   )
 {
   return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & 
REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0); -}
+}
\ No newline at end of file
diff --git 
a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
index b73103517a..9b79854538 100644
--- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCod
+++ eLib.c
@@ -630,16 +630,20 @@ ReportStatusCodeEx (
   UINT64StatusCodeBuffer[(MAX_EXTENDED_DATA_SIZE / sizeof 
(UINT64)) + 1];
 
   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
 
-

Re: [edk2] [patch V3] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible

2019-02-18 Thread Zeng, Star
Hi Dandan,

/DxeReportStatusCodeLib/ReportStatusCodeLib.c:

The " Retrieve the current TPL " code block is not needed also when using stack 
buffer, so it can be also moved to else condition.

And the code block below is redundant, so it can be removed.
  if (StatusCodeData == NULL) {
//
// If a buffer could not be allocated, then see if the local variable 
Buffer can be used
//
if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
  //
  // The local variable Buffer not large enough to hold the extended data 
associated
  // with the status code being reported.
  //
  DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be 
reported!\n"));
  return EFI_OUT_OF_RESOURCES;
}
StatusCodeData = (EFI_STATUS_CODE_DATA  *)Buffer;
  }

The code for /RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c can be also 
refined.

To be easily understand, check 
https://github.com/lzeng14/edk2/tree/ReportStatusCode for reference.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Dandan Bi
Sent: Monday, February 18, 2019 10:43 AM
To: edk2-devel@lists.01.org
Cc: Max Knutsen ; Wu, Hao A ; 
Michael Turner ; Gao, Liming 
; Zeng, Star 
Subject: [edk2] [patch V3] MdeModulePkg/ReportStatusCodeLib: Avoid using 
AllocatePool if possible

From: Max Knutsen 

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

V2: simplify the code logic.
update
if (!mHaveExitedBootServices &&
  (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) {
  gBS->FreePool (StatusCodeData);
}
to
if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
  gBS->FreePool (StatusCodeData);
}

V3:
And the code below into the else condition (stack buffer is not enough) in 
/DxeReportStatusCodeLib/ReportStatusCodeLib.c

  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
return EFI_UNSUPPORTED;
  }

When report status code with ExtendedData data, and the extended data can fit 
in the local static buffer, there is no need to use AllocatePool to hold the 
ExtendedData data.

This patch is just to do the enhancement to avoid using AllocatePool.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael Turner 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../DxeReportStatusCodeLib/ReportStatusCodeLib.c  | 15 +--
 .../ReportStatusCodeLib.c |  9 +++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index b28dc5c3bb..3bca0a94ee 100644
--- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -494,24 +494,27 @@ ReportStatusCodeEx (
   UINT64Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];
 
   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
 
-  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
-return EFI_UNSUPPORTED;
-  }
-
   //
   // Retrieve the current TPL
   //
   Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
   gBS->RestoreTPL (Tpl);
 
   StatusCodeData = NULL;
-  if (Tpl <= TPL_NOTIFY) {
+  if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof 
(EFI_STATUS_CODE_DATA))) {
+//
+// Use Buffer instead of allocating if possible.
+//
+StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;  } else if (gBS == 
+ NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
+return EFI_UNSUPPORTED;
+  } else if (Tpl <= TPL_NOTIFY){
 //
-// Allocate space for the Status Code Header and its buffer
+// If Buffer is not big enough, allocate space for the Status Code 
+ Header and its buffer
 //
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **)&StatusCodeData);
   }
 
   if (StatusCodeData == NULL) {
diff --git 
a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
index b73103517a..75e2f88ad2 100644
--- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCod
+++ eLib.c
@@ -635,11 +635,14 @@ ReportStatusCodeEx (
   if (mHaveExitedBootServices) {
 if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
   return EFI_OUT_OF_RESOURCES;
 }
 StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
-  } else  {
+  } else if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
+//
+

Re: [edk2] [patch V2] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible

2019-02-15 Thread Zeng, Star
After applying the patch, the author is Max and the Signed-off-by is Dandan, is 
it expected?

And the code below is better to be into the else condition (stack buffer is not 
enough), right?

  if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
return EFI_UNSUPPORTED;
  }

  //
  // Retrieve the current TPL
  //
  Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
  gBS->RestoreTPL (Tpl);


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Dandan Bi
Sent: Thursday, February 14, 2019 10:39 AM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Michael Turner 
; Max Knutsen ; Gao, 
Liming 
Subject: [edk2] [patch V2] MdeModulePkg/ReportStatusCodeLib: Avoid using 
AllocatePool if possible

From: Max Knutsen 

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

V2:  simplify the code logic.
update
if (!mHaveExitedBootServices &&
  (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) {
  gBS->FreePool (StatusCodeData);
}
to
if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
  gBS->FreePool (StatusCodeData);
}

When report status code with ExtendedData data, and the extended data can fit 
in the local static buffer, there is no need to use AllocatePool to hold the 
ExtendedData data.

This patch is just to do the enhancement to avoid using AllocatePool.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Michael Turner 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c | 9 +++--  
.../RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c  | 9 +++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index b28dc5c3bb..c88be5a1a3 100644
--- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -505,13 +505,18 @@ ReportStatusCodeEx (
   //
   Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
   gBS->RestoreTPL (Tpl);
 
   StatusCodeData = NULL;
-  if (Tpl <= TPL_NOTIFY) {
+  if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof 
+ (EFI_STATUS_CODE_DATA))) {
 //
-// Allocate space for the Status Code Header and its buffer
+// Use Buffer instead of allocating if possible.
+//
+StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;  } else if (Tpl <= 
+ TPL_NOTIFY){
+//
+// If Buffer is not big enough, allocate space for the Status Code 
+ Header and its buffer
 //
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **)&StatusCodeData);
   }
 
   if (StatusCodeData == NULL) {
diff --git 
a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c 
b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
index b73103517a..75e2f88ad2 100644
--- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCod
+++ eLib.c
@@ -635,11 +635,14 @@ ReportStatusCodeEx (
   if (mHaveExitedBootServices) {
 if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
   return EFI_OUT_OF_RESOURCES;
 }
 StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
-  } else  {
+  } else if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > 
MAX_EXTENDED_DATA_SIZE) {
+//
+// Only use AllocatePool for larger ExtendedData.
+//
 if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
   return EFI_UNSUPPORTED;
 }
 
 //
@@ -648,10 +651,12 @@ ReportStatusCodeEx (
 StatusCodeData = NULL;
 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + 
ExtendedDataSize, (VOID **)&StatusCodeData);
 if (StatusCodeData == NULL) {
   return EFI_OUT_OF_RESOURCES;
 }
+  } else {
+StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
   }
 
   //
   // Fill in the extended data header
   //
@@ -678,11 +683,11 @@ ReportStatusCodeEx (
   Status = InternalReportStatusCode (Type, Value, Instance, CallerId, 
StatusCodeData);
 
   //
   // Free the allocated buffer
   //
-  if (!mHaveExitedBootServices) {
+  if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
 gBS->FreePool (StatusCodeData);
   }
 
   return Status;
 }
--
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 v4 11/13] MdeModulePkg/SmmLockBoxLib: Support LockBox enlarge in UpdateLockBox()

2019-02-14 Thread Zeng, Star

Some minor comments.
With them addressed, Reviewed-by: Star Zeng .

On 2019/2/11 15:57, Hao Wu wrote:

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

This commit will add the support to enlarge a LockBox when using the
LockBoxLib API UpdateLockBox().

Please note that the new support will ONLY work for LockBox with attribute
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY set.

The functional uni-test for the commit is available at:
https://github.com/hwu25/edk2/tree/lockbox_unitest

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
Reviewed-by: Ray Ni 
Acked-by: Laszlo Ersek 
---
  MdeModulePkg/Include/Library/LockBoxLib.h |  7 +-
  MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c  |  7 +-
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c |  5 +-
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c |  5 +-
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c | 72 
++--
  5 files changed, 86 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Include/Library/LockBoxLib.h 
b/MdeModulePkg/Include/Library/LockBoxLib.h
index 5921731419..addce3bd4a 100644
--- a/MdeModulePkg/Include/Library/LockBoxLib.h
+++ b/MdeModulePkg/Include/Library/LockBoxLib.h
@@ -2,7 +2,7 @@
This library is only intended to be used by DXE modules that need save
confidential information to LockBox and get it by PEI modules in S3 phase.
  
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.

+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
  
  This program and the accompanying materials

  are licensed and made available under the terms and conditions
@@ -85,7 +85,10 @@ SetLockBoxAttributes (
@retval RETURN_SUCCESSthe information is saved successfully.
@retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
@retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too small to hold 
new information.
+  @retval RETURN_BUFFER_TOO_SMALL   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE,


Here, the description should be "without attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY".



+the original buffer to too small to hold 
new information.
+  @retval RETURN_OUT_OF_RESOURCES   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
+no enough resource to save the information.
@retval RETURN_ACCESS_DENIED  it is too late to invoke this interface
@retval RETURN_NOT_STARTEDit is too early to invoke this interface
@retval RETURN_UNSUPPORTEDthe service is not supported by 
implementaion.
diff --git a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c 
b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
index c40dfea398..0adda1e2a9 100644
--- a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
+++ b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
@@ -1,6 +1,6 @@
  /** @file
  
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.

+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
  
  This program and the accompanying materials

  are licensed and made available under the terms and conditions
@@ -76,7 +76,10 @@ SetLockBoxAttributes (
@retval RETURN_SUCCESSthe information is saved successfully.
@retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
@retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too small to hold 
new information.
+  @retval RETURN_BUFFER_TOO_SMALL   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE,
+the original buffer to too small to hold 
new information.
+  @retval RETURN_OUT_OF_RESOURCES   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
+no enough resource to save the information.
@retval RETURN_ACCESS_DENIED  it is too late to invoke this interface
@retval RETURN_NOT_STARTEDit is too early to invoke this interface
@retval RETURN_UNSUPPORTEDthe service is not supported by 
implementaion.
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
index 0428decbac..5ee563b71f 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
@@ -300,7 +300,10 @@ SetLockBoxAttributes (
@retval RETURN_SUCCESSthe information is saved successfully.
@retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
@retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too smal

Re: [edk2] [PATCH v4 09/13] MdeModulePkg/SmmLockBoxLib: Use 'DEBUG_' prefix instead of 'EFI_D_'

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

-Original Message-
From: Wu, Hao A 
Sent: Monday, February 11, 2019 3:58 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Wang, Jian J ; Zeng, 
Star 
Subject: [PATCH v4 09/13] MdeModulePkg/SmmLockBoxLib: Use 'DEBUG_' prefix 
instead of 'EFI_D_'

This commit is out of the scope for BZ-1409. It is a coding style refinement 
for the SmmLockBoxLib.

More specifically, the commit will remove all the debug message display level 
macros starting with 'EFI_D_' and replace them with macros starting with 
'DEBUG_'.

Cc: Jian J Wang 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
Reviewed-by: Ray Ni 
Reviewed-by: Laszlo Ersek 
---
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c | 22 +++---  
MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c | 26 +++  
MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c | 78 ++--
 3 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
index ac8bcd2ff7..0428decbac 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
 
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions @@ -153,7 +153,7 @@ SaveLockBox (
   UINT8   *CommBuffer;
   UINTN   CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SaveLockBox - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Enter\n"));
 
   //
   // Basic check
@@ -199,7 +199,7 @@ SaveLockBox (
 
   Status = (EFI_STATUS)LockBoxParameterSave->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SaveLockBox - Exit (%r)\n", Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Exit (%r)\n", 
+ Status));
 
   //
   // Done
@@ -235,7 +235,7 @@ SetLockBoxAttributes (
   UINT8 *CommBuffer;
   UINTN CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - 
+ Enter\n"));
 
   //
   // Basic check
@@ -281,7 +281,7 @@ SetLockBoxAttributes (
 
   Status = (EFI_STATUS)LockBoxParameterSetAttributes->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Exit (%r)\n", 
Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Exit 
+ (%r)\n", Status));
 
   //
   // Done
@@ -322,7 +322,7 @@ UpdateLockBox (
   UINT8 *CommBuffer;
   UINTN CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib UpdateLockBox - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Enter\n"));
 
   //
   // Basic check
@@ -369,7 +369,7 @@ UpdateLockBox (
 
   Status = (EFI_STATUS)LockBoxParameterUpdate->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib UpdateLockBox - Exit (%r)\n", Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Exit (%r)\n", 
+ Status));
 
   //
   // Done
@@ -411,7 +411,7 @@ RestoreLockBox (
   UINT8  *CommBuffer;
   UINTN  CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreLockBox - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Enter\n"));
 
   //
   // Basic check
@@ -467,7 +467,7 @@ RestoreLockBox (
 
   Status = (EFI_STATUS)LockBoxParameterRestore->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreLockBox - Exit (%r)\n", 
Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Exit (%r)\n", 
+ Status));
 
   //
   // Done
@@ -496,7 +496,7 @@ RestoreAllLockBoxInPlace (
   UINT8   *CommBuffer;
   UINTN   CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - 
+ Enter\n"));
 
   SmmCommunication = LockBoxGetSmmCommProtocol ();
   if (SmmCommunication == NULL) {
@@ -532,7 +532,7 @@ RestoreAllLockBoxInPlace (
 
   Status = (EFI_STATUS)LockBoxParameterRestoreAllInPlace->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Exit 
(%r)\n", Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Exit 
+ (%r)\n", Status));
 
   //
   // Done
diff 

Re: [edk2] [PATCH v4 10/13] MdeModulePkg/SmmLockBox(PEI): Remove an ASSERT in RestoreLockBox()

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

-Original Message-
From: Wu, Hao A 
Sent: Monday, February 11, 2019 3:58 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Wang, Jian J ; Zeng, 
Star 
Subject: [PATCH v4 10/13] MdeModulePkg/SmmLockBox(PEI): Remove an ASSERT in 
RestoreLockBox()

This commit is out of the scope for BZ-1409. It is a refinement for the PEI 
library instance within SmmLockBoxLib.

For the below ASSERT statement within function RestoreLockBox():
  Status = SmmCommunicationPpi->Communicate (
  SmmCommunicationPpi,
  &CommBuffer[0],
  &CommSize
  );
  if (Status == EFI_NOT_STARTED) {
//
// Pei SMM communication not ready yet, so we access SMRAM directly
//
DEBUG ((DEBUG_INFO, "SmmLockBoxPeiLib Communicate - (%r)\n", Status));
Status = InternalRestoreLockBoxFromSmram (Guid, Buffer, Length);
LockBoxParameterRestore->Header.ReturnStatus = (UINT64)Status;
if (Length != NULL) {
  LockBoxParameterRestore->Length = (UINT64)*Length;
}
  }
  ASSERT_EFI_ERROR (Status);

It is possible for previous codes to return an error status that is possible 
for happen. One example is that, when the 'if' statement 'if (Status == 
EFI_NOT_STARTED) {' is entered, function
InternalRestoreLockBoxFromSmram() is possible to return 'BUFFER_TOO_SMALL'
if the caller of RestoreLockBox() provides a buffer that is too small to hold 
the content of LockBox.

Thus, this commit will remove the ASSERT here.

Please note that the current implementation of RestoreLockBox() is handling the 
above-mentioned error case properly, so no additional error handling codes are 
needed here.

Cc: Jian J Wang 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
Reviewed-by: Ray Ni 
Reviewed-by: Laszlo Ersek 
---
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
index 9f73480070..8c3e65bc96 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
@@ -623,7 +623,6 @@ RestoreLockBox (
   LockBoxParameterRestore->Length = (UINT64)*Length;
 }
   }
-  ASSERT_EFI_ERROR (Status);
 
   if (Length != NULL) {
 *Length = (UINTN)LockBoxParameterRestore->Length;
--
2.12.0.windows.1

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


Re: [edk2] [PATCH v3 3/3] UefiCpuPkg/SecCore: Support EFI_PEI_CORE_FV_LOCATION_PPI

2019-02-14 Thread Zeng, Star
   //
   // Perform platform specific initialization before entering PeiCore.
   //

This comment block should be also moved together with SecPlatformMain() 
calling, right?


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chasel, 
Chiu
Sent: Thursday, February 14, 2019 6:59 PM
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek ; Dong, Eric 
Subject: [edk2] [PATCH v3 3/3] UefiCpuPkg/SecCore: Support 
EFI_PEI_CORE_FV_LOCATION_PPI

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

EFI_PEI_CORE_FV_LOCATION_PPI may be passed by platform when PeiCore not in BFV 
so SecCore has to search PeiCore either from the FV location provided by 
EFI_PEI_CORE_FV_LOCATION_PPI or from BFV.

Test: Verified on internal platform and booting successfully.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 UefiCpuPkg/SecCore/SecMain.c   | 35 +--
 UefiCpuPkg/SecCore/SecCore.inf |  3 ++-
 UefiCpuPkg/SecCore/SecMain.h   |  3 ++-
 3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c index 
b24e190617..d84eb675f5 100644
--- a/UefiCpuPkg/SecCore/SecMain.c
+++ b/UefiCpuPkg/SecCore/SecMain.c
@@ -1,7 +1,7 @@
 /** @file
   C functions in SEC
 
-  Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2008 - 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 @@ -232,22 +232,45 @@ SecStartupPhase2(
   EFI_PEI_PPI_DESCRIPTOR  *AllSecPpiList;
   EFI_PEI_CORE_ENTRY_POINTPeiCoreEntryPoint;
 
+  PeiCoreEntryPoint = NULL;
   SecCoreData   = (EFI_SEC_PEI_HAND_OFF *) Context;
   AllSecPpiList = (EFI_PEI_PPI_DESCRIPTOR *) SecCoreData->PeiTemporaryRamBase;
+
   //
   // Find Pei Core entry point. It will report SEC and Pei Core debug 
information if remote debug
   // is enabled.
   //
-  FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) 
SecCoreData->BootFirmwareVolumeBase, &PeiCoreEntryPoint);
-  if (PeiCoreEntryPoint == NULL)
-  {
-CpuDeadLoop ();
+  PpiList = SecPlatformMain (SecCoreData);  if (PpiList != NULL) {
+for (Index = 0;
+  (PpiList[Index].Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) != 
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+  Index++) {
+  if (CompareGuid (PpiList[Index].Guid, &gEfiPeiCoreFvLocationPpiGuid) && 
(((EFI_PEI_CORE_FV_LOCATION_PPI *) PpiList[Index].Ppi)->PeiCoreFvLocation != 
0)) {
+FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) 
((EFI_PEI_CORE_FV_LOCATION_PPI *) PpiList[Index].Ppi)->PeiCoreFvLocation, 
&PeiCoreEntryPoint);
+if (PeiCoreEntryPoint != NULL) {
+  break;
+} else {
+  //
+  // PeiCore not found
+  //
+  CpuDeadLoop ();
+}
+  }
+}
+  }
+  //
+  // If EFI_PEI_CORE_FV_LOCATION_PPI not found, try to locate PeiCore from BFV.
+  //
+  if (PeiCoreEntryPoint == NULL) {
+FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) 
SecCoreData->BootFirmwareVolumeBase, &PeiCoreEntryPoint);
+if (PeiCoreEntryPoint == NULL) {
+  CpuDeadLoop ();
+}
   }
 
   //
   // Perform platform specific initialization before entering PeiCore.
   //
-  PpiList = SecPlatformMain (SecCoreData);
   if (PpiList != NULL) {
 //
 // Remove the terminal flag from the terminal PPI
diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
index 442f663911..fc1485b5cb 100644
--- a/UefiCpuPkg/SecCore/SecCore.inf
+++ b/UefiCpuPkg/SecCore/SecCore.inf
@@ -7,7 +7,7 @@
 #  protected mode, setup flat memory model, enable temporary memory and
 #  call into SecStartup().
 #
-#  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
@@ -73,6 +73,7 @@
   ## NOTIFY
   ## SOMETIMES_CONSUMES
   gPeiSecPerformancePpiGuid
+  gEfiPeiCoreFvLocationPpiGuid
 
 [Guids]
   ## SOMETIMES_PRODUCES   ## HOB
diff --git a/UefiCpuPkg/SecCore/SecMain.h b/UefiCpuPkg/SecCore/SecMain.h
index 83244af119..80045d34f4 100644
--- a/UefiCpuPkg/SecCore/SecMain.h
+++ b/UefiCpuPkg/SecCore/SecMain.h
@@ -1,7 +1,7 @@
 /** @file
   Master header file for SecCore.
 
-  Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2008 - 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
   whic

Re: [edk2] [PATCH v3 1/3] MdePkg: Support EFI_PEI_CORE_FV_LOCATION_PPI

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

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chasel, 
Chiu
Sent: Thursday, February 14, 2019 6:59 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Gao, Liming 

Subject: [edk2] [PATCH v3 1/3] MdePkg: Support EFI_PEI_CORE_FV_LOCATION_PPI

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

Add EFI_PEI_CORE_FV_LOCATION_PPI definition basing on PI spec 1.7, Section 
6.3.9.
This PPI can support the secnario that PEI Foundation not in BFV.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 MdePkg/Include/Ppi/PeiCoreFvLocation.h | 48 

 MdePkg/MdePkg.dec  | 11 +--
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Ppi/PeiCoreFvLocation.h 
b/MdePkg/Include/Ppi/PeiCoreFvLocation.h
new file mode 100644
index 00..3bea6819ec
--- /dev/null
+++ b/MdePkg/Include/Ppi/PeiCoreFvLocation.h
@@ -0,0 +1,48 @@
+/** @file
+  Header file for Pei Core FV Location PPI.
+
+  This PPI contains a pointer to the firmware volume which contains the PEI 
Foundation.
+  If the PEI Foundation does not reside in the BFV, then SEC must pass 
+ this PPI as a part  of the PPI list provided to the PEI Foundation 
+ Entry Point, otherwise the PEI Foundation  shall assume that it resides 
within the BFV.
+
+  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.
+
+  @par Revision Reference:
+  This PPI is defined in UEFI Platform Initialization Specification 1.7 Volume 
1:
+  Standards
+
+**/
+
+
+#ifndef _EFI_PEI_CORE_FV_LOCATION_H_
+#define _EFI_PEI_CORE_FV_LOCATION_H_
+
+///
+/// Global ID for EFI_PEI_CORE_FV_LOCATION_PPI /// #define 
+EFI_PEI_CORE_FV_LOCATION_GUID \
+  { \
+0x52888eae, 0x5b10, 0x47d0, {0xa8, 0x7f, 0xb8, 0x22, 0xab, 0xa0, 
+0xca, 0xf4 } \
+  }
+
+///
+/// This PPI provides location of EFI PeiCoreFv.
+///
+typedef struct {
+  ///
+  /// Pointer to the first byte of the firmware volume which contains the PEI 
Foundation.
+  ///
+  VOID*PeiCoreFvLocation;
+} EFI_PEI_CORE_FV_LOCATION_PPI;
+
+extern EFI_GUID gEfiPeiCoreFvLocationPpiGuid;
+
+#endif // _EFI_PEI_CORE_FV_LOCATION_H_
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index a485408310..c859b4a511 
100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -2,9 +2,9 @@
 # This Package provides all definitions, library classes and libraries 
instances.
 #
 # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of -# 
EFI1.10/UEFI2.7/PI1.6 and some Industry Standards.
+# EFI1.10/UEFI2.7/PI1.7 and some Industry Standards.
 #
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights 
+reserved.
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.  # 
(C) Copyright 2016 Hewlett Packard Enterprise Development LP  # @@ -929,6 
+929,13 @@
   ## Include/Ppi/SecHobData.h
   gEfiSecHobDataPpiGuid = { 0x3ebdaf20, 0x6667, 0x40d8, {0xb4, 0xee, 0xf5, 
0x99, 0x9a, 0xc1, 0xb7, 0x1f } }
 
+  #
+  # PPIs defined in PI 1.7.
+  #
+
+  ## Include/Ppi/PeiCoreFvLocation.h
+  gEfiPeiCoreFvLocationPpiGuid   = { 0x52888eae, 0x5b10, 0x47d0, { 0xa8, 0x7f, 
0xb8, 0x22, 0xab, 0xa0, 0xca, 0xf4 }}
+
 [Protocols]
   ## Include/Protocol/Pcd.h
   gPcdProtocolGuid   = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 0x90, 
0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}
--
2.13.3.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 v3 2/3] MdeModulePkg/PeiMain: Support EFI_PEI_CORE_FV_LOCATION_PPI

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

-Original Message-
From: Chiu, Chasel 
Sent: Thursday, February 14, 2019 6:59 PM
To: edk2-devel@lists.01.org
Cc: Wang, Jian J ; Wu, Hao A ; Ni, 
Ray ; Zeng, Star ; Gao, Liming 
; Chiu, Chasel 
Subject: [PATCH v3 2/3] MdeModulePkg/PeiMain: Support 
EFI_PEI_CORE_FV_LOCATION_PPI

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

When shadowing PeiCore the EFI_PEI_CORE_FV_LOCATION_PPI should be checked to 
see if PeiCore not in BFV, otherwise just shadowing PeiCore from BFV.

Test: Verified on internal platform and booting successfully.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Ray Ni 
Cc: Star Zeng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 53 
-
 MdeModulePkg/Core/Pei/PeiMain.h |  3 ++-
 MdeModulePkg/Core/Pei/PeiMain.inf   |  3 ++-
 3 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c 
b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 4da80a8222..a7da90e149 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -1,7 +1,7 @@
 /** @file
   Pei Core Main Entry Point
 
-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 @@ -80,22 +80,49 @@ 
ShadowPeiCore (
   IN PEI_CORE_INSTANCE  *PrivateData
   )
 {
-  EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;
-  EFI_PHYSICAL_ADDRESS EntryPoint;
-  EFI_STATUS   Status;
-  UINT32   AuthenticationState;
+  EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;
+  EFI_PHYSICAL_ADDRESS EntryPoint;
+  EFI_STATUS   Status;
+  UINT32   AuthenticationState;
+  UINTNIndex;
+  EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
+  UINTNPeiCoreFvIndex;
 
   PeiCoreFileHandle = NULL;
-
   //
-  // Find the PEI Core in the BFV
+  // Default PeiCore is in BFV
+  //
+  PeiCoreFvIndex = 0;
+  //
+  // Find the PEI Core either from EFI_PEI_CORE_FV_LOCATION_PPI 
+ indicated FV or BFV  //  Status = PeiServicesLocatePpi (
+ &gEfiPeiCoreFvLocationPpiGuid,
+ 0,
+ NULL,
+ (VOID **) &PeiCoreFvLocationPpi
+ );
+  if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation != 
NULL)) {
+//
+// If PeiCoreFvLocation present, the PEI Core should be found from 
indicated FV
+//
+for (Index = 0; Index < PrivateData->FvCount; Index ++) {
+  if (PrivateData->Fv[Index].FvHandle == 
PeiCoreFvLocationPpi->PeiCoreFvLocation) {
+PeiCoreFvIndex = Index;
+break;
+  }
+}
+ASSERT (Index < PrivateData->FvCount);  }  //  // Find PEI Core 
+ from the given FV index
   //
-  Status = PrivateData->Fv[0].FvPpi->FindFileByType (
-   PrivateData->Fv[0].FvPpi,
-   EFI_FV_FILETYPE_PEI_CORE,
-   PrivateData->Fv[0].FvHandle,
-   &PeiCoreFileHandle
-   );
+  Status = PrivateData->Fv[PeiCoreFvIndex].FvPpi->FindFileByType (
+
PrivateData->Fv[PeiCoreFvIndex].FvPpi,
+EFI_FV_FILETYPE_PEI_CORE,
+
PrivateData->Fv[PeiCoreFvIndex].FvHandle,
+&PeiCoreFileHandle
+);
   ASSERT_EFI_ERROR (Status);
 
   //
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h 
index 322e7cd845..a61da73fd8 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -1,7 +1,7 @@
 /** @file
   Definition of Pei Core Structures and Services
 
-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 @@ -31,6 +31,7 @@ 
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 140cb1..5bab2aab8c 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+

Re: [edk2] [PATCH v2 1/3] MdePkg: Support EFI_PEI_CORE_FV_LOCATION_PPI

2019-02-13 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chasel, 
Chiu
Sent: Wednesday, February 13, 2019 5:47 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Gao, Liming 

Subject: [edk2] [PATCH v2 1/3] MdePkg: Support EFI_PEI_CORE_FV_LOCATION_PPI

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

Add EFI_PEI_CORE_FV_LOCATION_PPI definition basing on PI spec 1.7, Section 
6.3.9.
This PPI can support the secnario that PEI Foundation not in BFV.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 MdePkg/Include/Ppi/PeiCoreFvLocation.h | 53 
+
 MdePkg/MdePkg.dec  | 11 +--
 2 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Ppi/PeiCoreFvLocation.h 
b/MdePkg/Include/Ppi/PeiCoreFvLocation.h
new file mode 100644
index 00..c7bbbfb265
--- /dev/null
+++ b/MdePkg/Include/Ppi/PeiCoreFvLocation.h
@@ -0,0 +1,53 @@
+/** @file
+  Header file for Pei Core FV Location PPI.
+
+  This PPI contains a pointer to the firmware volume which contains the PEI 
Foundation.
+  If the PEI Foundation does not reside in the BFV, then SEC must pass 
+ this PPI as a part  of the PPI list provided to the PEI Foundation 
+ Entry Point, otherwise the PEI Foundation  shall assume that it resides 
within the BFV.
+
+  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.
+
+  @par Revision Reference:
+  This PPI is defined in UEFI Platform Initialization Specification 1.7 Volume 
1:
+  Standards
+
+**/
+
+
+#ifndef _EFI_PEI_CORE_FV_LOCATION_H_
+#define _EFI_PEI_CORE_FV_LOCATION_H_
+
+///
+/// Global ID for EFI_PEI_CORE_FV_LOCATION_PPI /// #define 
+EFI_PEI_CORE_FV_LOCATION_GUID \
+  { \
+0x52888eae, 0x5b10, 0x47d0, {0xa8, 0x7f, 0xb8, 0x22, 0xab, 0xa0, 
+0xca, 0xf4 } \
+  }
+
+///
+/// Forward declaration for EFI_PEI_CORE_FV_LOCATION_PPI /// typedef 
+struct _EFI_PEI_CORE_FV_LOCATION_PPI EFI_PEI_CORE_FV_LOCATION_PPI;
+
+///
+/// This PPI provides location of EFI PeiCoreFv.
+///
+struct _EFI_PEI_CORE_FV_LOCATION_PPI {
+  ///
+  /// Pointer to the first byte of the firmware volume which contains the PEI 
Foundation.
+  ///
+  VOID*PeiCoreFvLocation;
+};
+
+extern EFI_GUID gEfiPeiCoreFvLocationPpiGuid;
+
+#endif // _EFI_PEI_CORE_FV_LOCATION_H_
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index a485408310..c859b4a511 
100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -2,9 +2,9 @@
 # This Package provides all definitions, library classes and libraries 
instances.
 #
 # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of -# 
EFI1.10/UEFI2.7/PI1.6 and some Industry Standards.
+# EFI1.10/UEFI2.7/PI1.7 and some Industry Standards.
 #
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights 
+reserved.
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.  # 
(C) Copyright 2016 Hewlett Packard Enterprise Development LP  # @@ -929,6 
+929,13 @@
   ## Include/Ppi/SecHobData.h
   gEfiSecHobDataPpiGuid = { 0x3ebdaf20, 0x6667, 0x40d8, {0xb4, 0xee, 0xf5, 
0x99, 0x9a, 0xc1, 0xb7, 0x1f } }
 
+  #
+  # PPIs defined in PI 1.7.
+  #
+
+  ## Include/Ppi/PeiCoreFvLocation.h
+  gEfiPeiCoreFvLocationPpiGuid   = { 0x52888eae, 0x5b10, 0x47d0, { 0xa8, 0x7f, 
0xb8, 0x22, 0xab, 0xa0, 0xca, 0xf4 }}
+
 [Protocols]
   ## Include/Protocol/Pcd.h
   gPcdProtocolGuid   = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 0x90, 
0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}
--
2.13.3.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 v2 2/3] MdeModulePkg/PeiMain: Support EFI_PEI_CORE_FV_LOCATION_PPI

2019-02-13 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Chiu, Chasel 
Sent: Wednesday, February 13, 2019 5:47 PM
To: edk2-devel@lists.01.org
Cc: Wang, Jian J ; Wu, Hao A ; Ni, 
Ray ; Zeng, Star ; Gao, Liming 
; Chiu, Chasel 
Subject: [PATCH v2 2/3] MdeModulePkg/PeiMain: Support 
EFI_PEI_CORE_FV_LOCATION_PPI

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

When shadowing PeiCore the EFI_PEI_CORE_FV_LOCATION_PPI should be checked to 
see if PeiCore not in BFV, otherwise just shadowing PeiCore from BFV.

Test: Verified on internal platform and booting successfully.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Ray Ni 
Cc: Star Zeng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 58 
+-
 MdeModulePkg/Core/Pei/PeiMain.h |  3 ++-
 MdeModulePkg/Core/Pei/PeiMain.inf   |  3 ++-
 3 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c 
b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 4da80a8222..ba0f2b7b69 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -1,7 +1,7 @@
 /** @file
   Pei Core Main Entry Point
 
-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 @@ -80,23 +80,55 @@ 
ShadowPeiCore (
   IN PEI_CORE_INSTANCE  *PrivateData
   )
 {
-  EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;
-  EFI_PHYSICAL_ADDRESS EntryPoint;
-  EFI_STATUS   Status;
-  UINT32   AuthenticationState;
+  EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;
+  EFI_PHYSICAL_ADDRESS EntryPoint;
+  EFI_STATUS   Status;
+  UINT32   AuthenticationState;
+  UINTNIndex;
+  EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
 
   PeiCoreFileHandle = NULL;
 
   //
-  // Find the PEI Core in the BFV
+  // Find the PEI Core either from EFI_PEI_CORE_FV_LOCATION_PPI 
+ indicated FV or BFV
   //
-  Status = PrivateData->Fv[0].FvPpi->FindFileByType (
-   PrivateData->Fv[0].FvPpi,
-   EFI_FV_FILETYPE_PEI_CORE,
-   PrivateData->Fv[0].FvHandle,
-   &PeiCoreFileHandle
-   );
-  ASSERT_EFI_ERROR (Status);
+  Status = PeiServicesLocatePpi (
+ &gEfiPeiCoreFvLocationPpiGuid,
+ 0,
+ NULL,
+ (VOID **) &PeiCoreFvLocationPpi
+ );
+  if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation != 
NULL)) {
+//
+// If PeiCoreFvLocation present, the PEI Core should be found from 
indicated FV.
+//
+for (Index = 0; Index < PrivateData->FvCount; Index ++) {
+  if (PrivateData->Fv[Index].FvHandle != 
PeiCoreFvLocationPpi->PeiCoreFvLocation) {
+continue;
+  }
+  Status = PrivateData->Fv[Index].FvPpi->FindFileByType (
+   PrivateData->Fv[Index].FvPpi,
+   EFI_FV_FILETYPE_PEI_CORE,
+   PrivateData->Fv[Index].FvHandle,
+   &PeiCoreFileHandle
+   );
+  if (!EFI_ERROR (Status)) {
+break;
+  }
+}
+ASSERT (Index < PrivateData->FvCount);  } else {
+//
+// Find PEI Core from BFV
+//
+Status = PrivateData->Fv[0].FvPpi->FindFileByType (
+ PrivateData->Fv[0].FvPpi,
+ EFI_FV_FILETYPE_PEI_CORE,
+ PrivateData->Fv[0].FvHandle,
+ &PeiCoreFileHandle
+ );
+ASSERT_EFI_ERROR (Status);
+  }
 
   //
   // Shadow PEI Core into memory so it will run faster diff --git 
a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h index 
322e7cd845..38542ab072 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -1,7 +1,7 @@
 /** @file
   Definition of Pei Core Structures and Services
 
-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 li

Re: [edk2] [PATCH 2/3] MdeModulePkg/PeiMain: Support EFI_PEI_CORE_FV_LOCATION_PPI

2019-02-13 Thread Zeng, Star
With this addressed, Reviewed-by: Star Zeng .

-Original Message-
From: Chiu, Chasel 
Sent: Wednesday, February 13, 2019 11:59 AM
To: Wang, Jian J ; edk2-devel@lists.01.org
Cc: Wu, Hao A ; Ni, Ray ; Zeng, Star 
; Gao, Liming 
Subject: RE: [PATCH 2/3] MdeModulePkg/PeiMain: Support 
EFI_PEI_CORE_FV_LOCATION_PPI


No issue, I will remove UINT32 casting. Thanks!

> -Original Message-
> From: Wang, Jian J
> Sent: Wednesday, February 13, 2019 9:14 AM
> To: Chiu, Chasel ; edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Ni, Ray ; Zeng, 
> Star ; Gao, Liming 
> Subject: RE: [PATCH 2/3] MdeModulePkg/PeiMain: Support 
> EFI_PEI_CORE_FV_LOCATION_PPI
> 
> Chasel,
> 
> 
> > -Original Message-
> > From: Chiu, Chasel
> > Sent: Tuesday, February 12, 2019 9:20 PM
> > To: edk2-devel@lists.01.org
> > Cc: Wang, Jian J ; Wu, Hao A 
> > ; Ni, Ray ; Zeng, Star 
> > ; Gao, Liming ; Chiu, 
> > Chasel 
> > Subject: [PATCH 2/3] MdeModulePkg/PeiMain: Support 
> > EFI_PEI_CORE_FV_LOCATION_PPI
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1524
> >
> > When shadowing PeiCore the EFI_PEI_CORE_FV_LOCATION_PPI should be 
> > checked to see if PeiCore not in BFV, otherwise just shadowing 
> > PeiCore from BFV.
> >
> > Test: Verified on internal platform and booting successfully.
> >
> > Cc: Jian J Wang 
> > Cc: Hao Wu 
> > Cc: Ray Ni 
> > Cc: Star Zeng 
> > Cc: Liming Gao 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Chasel Chiu 
> > ---
> >  MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 58
> > +-
> >  MdeModulePkg/Core/Pei/PeiMain.h |  3 ++-
> >  MdeModulePkg/Core/Pei/PeiMain.inf   |  3 ++-
> >  3 files changed, 49 insertions(+), 15 deletions(-)
> >
> > diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> > b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> > index 4da80a8222..408f24c216 100644
> > --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> > +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> > @@ -1,7 +1,7 @@
> >  /** @file
> >Pei Core Main Entry Point
> >
> > -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 @@ -80,23 +80,55 @@ ShadowPeiCore (
> >IN PEI_CORE_INSTANCE  *PrivateData
> >)
> >  {
> > -  EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;
> > -  EFI_PHYSICAL_ADDRESS EntryPoint;
> > -  EFI_STATUS   Status;
> > -  UINT32   AuthenticationState;
> > +  EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;
> > +  EFI_PHYSICAL_ADDRESS EntryPoint;
> > +  EFI_STATUS   Status;
> > +  UINT32   AuthenticationState;
> > +  UINTNIndex;
> > +  EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
> >
> >PeiCoreFileHandle = NULL;
> >
> >//
> > -  // Find the PEI Core in the BFV
> > +  // Find the PEI Core either from EFI_PEI_CORE_FV_LOCATION_PPI 
> > + indicated
> > FV or BFV
> >//
> > -  Status = PrivateData->Fv[0].FvPpi->FindFileByType (
> > -   PrivateData->Fv[0].FvPpi,
> > -   EFI_FV_FILETYPE_PEI_CORE,
> > -   PrivateData->Fv[0].FvHandle,
> > -   &PeiCoreFileHandle
> > -   );
> > -  ASSERT_EFI_ERROR (Status);
> > +  Status = PeiServicesLocatePpi (
> > + &gEfiPeiCoreFvLocationPpiGuid,
> > + 0,
> > + NULL,
> > + (VOID **) &PeiCoreFvLocationPpi
> > + );
> > +  if (!EFI_ERROR (Status) && 
> > + (PeiCoreFvLocationPpi->PeiCoreFvLocation
> > + !=
> > NULL)) {
> > +//
> > +// If PeiCoreFvLocation present, the PEI Core should be found 
> > + from indicated
> > FV.
> > +//
> > +for (Index = 0; Index < PrivateData->FvCount; Index ++) {
> > +  if ((UINT32) PrivateData->Fv[Index].FvHandle != (UINT32)
> > PeiCoreFvLocationPpi->PeiCoreFvLocation) {
> 
> I think the UINT32 type 

Re: [edk2] [PATCH 1/3] MdePkg: Support EFI_PEI_CORE_FV_LOCATION_PPI

2019-02-13 Thread Zeng, Star

On 2019/2/12 21:19, Chasel, Chiu wrote:

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

Add EFI_PEI_CORE_FV_LOCATION_PPI definition basing on
PI spec 1.7, Section 6.3.9.
This PPI can support the secnario that PEI Foundation
not in BFV.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 


Reviewed-by: Star Zeng 


---
  MdePkg/Include/Ppi/PeiCoreFvLocation.h | 53 
+
  MdePkg/MdePkg.dec  | 11 +--
  2 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Ppi/PeiCoreFvLocation.h 
b/MdePkg/Include/Ppi/PeiCoreFvLocation.h
new file mode 100644
index 00..c7bbbfb265
--- /dev/null
+++ b/MdePkg/Include/Ppi/PeiCoreFvLocation.h
@@ -0,0 +1,53 @@
+/** @file
+  Header file for Pei Core FV Location PPI.
+
+  This PPI contains a pointer to the firmware volume which contains the PEI 
Foundation.
+  If the PEI Foundation does not reside in the BFV, then SEC must pass this 
PPI as a part
+  of the PPI list provided to the PEI Foundation Entry Point, otherwise the 
PEI Foundation
+  shall assume that it resides within the BFV.
+
+  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.
+
+  @par Revision Reference:
+  This PPI is defined in UEFI Platform Initialization Specification 1.7 Volume 
1:
+  Standards
+
+**/
+
+
+#ifndef _EFI_PEI_CORE_FV_LOCATION_H_
+#define _EFI_PEI_CORE_FV_LOCATION_H_
+
+///
+/// Global ID for EFI_PEI_CORE_FV_LOCATION_PPI
+///
+#define EFI_PEI_CORE_FV_LOCATION_GUID \
+  { \
+0x52888eae, 0x5b10, 0x47d0, {0xa8, 0x7f, 0xb8, 0x22, 0xab, 0xa0, 0xca, 
0xf4 } \
+  }
+
+///
+/// Forward declaration for EFI_PEI_CORE_FV_LOCATION_PPI
+///
+typedef struct _EFI_PEI_CORE_FV_LOCATION_PPI EFI_PEI_CORE_FV_LOCATION_PPI;
+
+///
+/// This PPI provides location of EFI PeiCoreFv.
+///
+struct _EFI_PEI_CORE_FV_LOCATION_PPI {
+  ///
+  /// Pointer to the first byte of the firmware volume which contains the PEI 
Foundation.
+  ///
+  VOID*PeiCoreFvLocation;
+};
+
+extern EFI_GUID gEfiPeiCoreFvLocationPpiGuid;
+
+#endif // _EFI_PEI_CORE_FV_LOCATION_H_
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index a485408310..c859b4a511 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -2,9 +2,9 @@
  # This Package provides all definitions, library classes and libraries 
instances.
  #
  # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of
-# EFI1.10/UEFI2.7/PI1.6 and some Industry Standards.
+# EFI1.10/UEFI2.7/PI1.7 and some Industry Standards.
  #
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
  # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
  # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
  #
@@ -929,6 +929,13 @@
## Include/Ppi/SecHobData.h
gEfiSecHobDataPpiGuid = { 0x3ebdaf20, 0x6667, 0x40d8, {0xb4, 0xee, 0xf5, 
0x99, 0x9a, 0xc1, 0xb7, 0x1f } }
  
+  #

+  # PPIs defined in PI 1.7.
+  #
+
+  ## Include/Ppi/PeiCoreFvLocation.h
+  gEfiPeiCoreFvLocationPpiGuid   = { 0x52888eae, 0x5b10, 0x47d0, { 0xa8, 0x7f, 
0xb8, 0x22, 0xab, 0xa0, 0xca, 0xf4 }}
+
  [Protocols]
## Include/Protocol/Pcd.h
gPcdProtocolGuid   = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 
0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}



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


Re: [edk2] [PATCH] MdeModulePkg VariableStandaloneMm: Add PcdEmuVariableNvModeEnable in inf

2019-01-24 Thread Zeng, Star
Thanks.

I just pushed it at 9084239f3440369fcb5ff0476d9bdd9442a03258 since it is a 
build failure.


Star
-Original Message-
From: Wang, Jian J 
Sent: Friday, January 25, 2019 9:42 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Wu, Hao A ; Ard Biesheuvel ; 
Bi, Dandan 
Subject: RE: [PATCH] MdeModulePkg VariableStandaloneMm: Add 
PcdEmuVariableNvModeEnable in inf


Reviewed-by: Jian J Wang 


> -Original Message-
> From: Zeng, Star
> Sent: Friday, January 25, 2019 9:23 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J 
> ; Wu, Hao A ; Ard 
> Biesheuvel ; Bi, Dandan 
> 
> Subject: [PATCH] MdeModulePkg VariableStandaloneMm: Add 
> PcdEmuVariableNvModeEnable in inf
> 
> It was missed in 7cd69959463ac9c761163ed8e8a93907b68e70da when 
> rebasing the patches after 688b2cad7b712493f2cf8b6948ab795545e13961 
> added VariableStandaloneMm.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Ard Biesheuvel 
> Cc: Dandan Bi 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 
> 4
> +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> index efb84ed87832..07436d3cb6ae 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> @@ -18,7 +18,7 @@
>  #  may not be modified without authorization. If platform fails to 
> protect these resources,  #  the authentication service provided in 
> this driver will be broken, and the behavior is undefined.
>  #
> -# Copyright (c) 2010 - 2016, Intel Corporation. All rights 
> reserved.
> +# Copyright (c) 2010 - 2019, Intel Corporation. All rights 
> +reserved.
>  # Copyright (c) 2018, Linaro, Ltd. All rights reserved.  # This 
> program and the accompanying materials  # are licensed and made 
> available under the terms and conditions of the BSD License @@ -127,6 
> +127,8 @@ [FixedPcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize   ##
> CONSUMES
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpaceSize
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe   ##
> CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable  ##
> SOMETIMES_CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved   ##
> SOMETIMES_CONSUMES
> 
>  [FeaturePcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics##
> CONSUMES  # statistic the information of variable.
> --
> 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] IntelFsp2Pkg: FSP can utilize bootloader stack

2019-01-24 Thread Zeng, Star

On 2019/1/23 17:33, Chasel, Chiu wrote:

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

Current FSP utilizes pre-allocated temporary memory from
boot loader for both heap and stack. To reduce overall
temporary memory usage FSP may share the same stack with
boot loader and only needs a smaller memory for heap,
no separate memory required for stack.
Setting PcdFspHeapSizePercentage to 0 to enable FSP sharing
stack with boot loader, in this case boot loader stack
has to be large enough for FSP to use. Default is 50
(half memory heap and half memory stack) for backward
compatible with original model.

Test: Verified on internal platform and booting successfully
   with both modes.

Cc: Nate DeSimone 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 


Minor comments below. With them addressed, Reviewed-by: Star Zeng 
.



---
  IntelFsp2Pkg/FspSecCore/SecMain.c  | 86 
++
  IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf|  3 ++-
  IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm | 52 
++--
  IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm  | 28 

  IntelFsp2Pkg/IntelFsp2Pkg.dec  |  4 
  5 files changed, 154 insertions(+), 19 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c 
b/IntelFsp2Pkg/FspSecCore/SecMain.c
index 70460a3c8b..b0b5dda711 100644
--- a/IntelFsp2Pkg/FspSecCore/SecMain.c
+++ b/IntelFsp2Pkg/FspSecCore/SecMain.c
@@ -1,6 +1,6 @@
  /** @file
  
-  Copyright (c) 2014 - 2018, 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
which accompanies this distribution.  The full text of the license may be 
found at
@@ -38,6 +38,19 @@ UINT64  mIdtEntryTemplate = 0x8e08ffe4ULL;
  
  /**
  
+  Return value of esp

+
+  @return  value of esp
+
+**/
+UINT32
+EFIAPI
+AsmReadEsp (
+  VOID
+  );
+
+/**
+
Entry point to the C language phase of SEC. After the SEC assembly
code has initialized some temporary memory and set up the stack,
the control is transferred to this function.
@@ -83,7 +96,26 @@ SecStartup (
//
InitializeFloatingPointUnits ();
  
+  //

+  // Scenario 1 memory map when running on bootloader stack
+  //
+  // |---|>
+  // |Idt Table  |
+  // |---|
+  // |PeiService Pointer |
+  // |---|
+  // |   |
+  // |   |
+  // |  Heap |
+  // |   |
+  // |   |
+  // |---|>  TempRamBase
+  // |Bootloader stack   |
+  // |---|


The Bootloader stack range and TempRam range should be separated and 
should be not adjacent. How about drawing them separated here to remove 
the confusion?


Another, maybe we can propose AsmReadEsp to BaseLib for long term. :)


Thanks,
Star

  
+  //

+  // Scenario 2 memory map when running FSP on a separate stack
+  //
// |---|>
// |Idt Table  |
// |---|
@@ -135,11 +167,19 @@ SecStartup (
SecCoreData.BootFirmwareVolumeSize = (UINT32)((EFI_FIRMWARE_VOLUME_HEADER 
*)BootFirmwareVolume)->FvLength;
  
SecCoreData.TemporaryRamBase   = (VOID*)(UINTN) TempRamBase;

-  SecCoreData.TemporaryRamSize   = SizeOfRam;
-  SecCoreData.PeiTemporaryRamBase= SecCoreData.TemporaryRamBase;
-  SecCoreData.PeiTemporaryRamSize= SecCoreData.TemporaryRamSize * PcdGet8 
(PcdFspHeapSizePercentage) / 100;
-  SecCoreData.StackBase  = 
(VOID*)(UINTN)((UINTN)SecCoreData.TemporaryRamBase + 
SecCoreData.PeiTemporaryRamSize);
-  SecCoreData.StackSize  = SecCoreData.TemporaryRamSize - 
SecCoreData.PeiTemporaryRamSize;
+  if (PcdGet8 (PcdFspHeapSizePercentage) == 0) {
+SecCoreData.TemporaryRamSize   = SizeOfRam; // stack size that is 
going to be copied to the permanent memory
+SecCoreData.PeiTemporaryRamBase= SecCoreData.TemporaryRamBase;
+SecCoreData.PeiTemporaryRamSize= SecCoreData.TemporaryRamSize;
+SecCoreData.StackBase  = (VOID *)GetFspEntryStack(); // Share 
the same boot loader stack
+SecCoreData.StackSize  = 0;
+  } else {
+SecCoreData.TemporaryRamSize   = SizeOfRam;
+SecCoreData.PeiTemporaryRamBase= SecCoreData.TemporaryRamBase;
+SecCoreData.PeiTemporaryRamSize= SecCoreData.TemporaryRamSize * 
PcdGet8 (PcdFspHeapSizePercentage) / 100;
+SecCoreData.StackBase  = 
(VOID*)(UINTN)((UINTN)SecCoreData.TemporaryRamBase + 
SecCoreData.PeiTemporaryRamSize);
+SecCoreData.StackSize  = SecCoreData.TemporaryRamSize - 
SecCoreData.PeiTemporaryRamSize;
+  }
  
   

Re: [edk2] [PATCH] IntelFsp2Pkg: Add function to get bootloader stack pointer

2019-01-24 Thread Zeng, Star

On 2019/1/23 13:36, Chasel, Chiu wrote:

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

FSP on-going enhancement for stack utilization required
to know bootloader stack pointer and this pointer can be
retrieved by first input parameter address when FSP-M
entry API invoked by bootloader.

Test: Verified on internal platform and booting successfully

Cc: Nate DeSimone 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 


Minor comments below, with them addressed, Reviewed-by: Star Zeng 
.



---
  IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c | 27 
++-
  IntelFsp2Pkg/Include/Library/FspCommonLib.h  | 21 
-
  2 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c 
b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
index 64ffba1d16..2f2861281c 100644
--- a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
@@ -1,6 +1,6 @@
  /** @file
  
-  Copyright (c) 2014 - 2018, 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
which accompanies this distribution.  The full text of the license may be 
found at
@@ -87,9 +87,9 @@ GetFspGlobalDataPointer (
  }
  
  /**

-  This function gets back the FSP API first parameter passed by the bootlaoder.
+  This function gets back the FSP API first parameter passed by the bootloader.
  
-  @retval ApiParameter FSP API first parameter passed by the bootlaoder.

+  @retval ApiParameter FSP API first parameter passed by the bootloader.
  **/
  UINT32
  EFIAPI
@@ -104,9 +104,26 @@ GetFspApiParameter (
  }
  
  /**

-  This function gets back the FSP API second parameter passed by the 
bootlaoder.
+  This function returns the FSP entry stack pointer from address of the first 
API parameter
  
-  @retval ApiParameter FSP API second parameter passed by the bootlaoder.

+  @retval FSP entry stack pointer.
+**/
+VOID*
+EFIAPI
+GetFspEntryStack (
+  VOID
+  )
+{
+  FSP_GLOBAL_DATA  *FspData;
+
+  FspData  = GetFspGlobalDataPointer ();
+  return (VOID*)(FspData->CoreStack + CONTEXT_STACK_OFFSET(ApiParam[0]));
+}
+
+/**
+  This function gets back the FSP API second parameter passed by the 
bootloader.
+
+  @retval ApiParameter FSP API second parameter passed by the bootloader.
  **/
  UINT32
  EFIAPI
diff --git a/IntelFsp2Pkg/Include/Library/FspCommonLib.h 
b/IntelFsp2Pkg/Include/Library/FspCommonLib.h
index 1c99be3b1f..e98b180fca 100644
--- a/IntelFsp2Pkg/Include/Library/FspCommonLib.h
+++ b/IntelFsp2Pkg/Include/Library/FspCommonLib.h
@@ -1,6 +1,6 @@
  /** @file
  
-  Copyright (c) 2014 - 2018, 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
which accompanies this distribution.  The full text of the license may be 
found at
@@ -40,9 +40,9 @@ GetFspGlobalDataPointer (
);
  
  /**

-  This function gets back the FSP API first parameter passed by the bootlaoder.
+  This function gets back the FSP API first parameter passed by the bootloader.
  
-  @retval ApiParameter FSP API first parameter passed by the bootlaoder.

+  @retval ApiParameter FSP API first parameter passed by the bootloader.
  **/
  UINT32
  EFIAPI
@@ -51,9 +51,9 @@ GetFspApiParameter (
);
  
  /**

-  This function gets back the FSP API second parameter passed by the 
bootlaoder.
+  This function gets back the FSP API second parameter passed by the 
bootloader.
  
-  @retval ApiParameter FSP API second parameter passed by the bootlaoder.

+  @retval ApiParameter FSP API second parameter passed by the bootloader.
  **/
  UINT32
  EFIAPI
@@ -61,6 +61,17 @@ GetFspApiParameter2 (
VOID
);
  
+


Remove this new line?


+/**
+  This function returns the FSP entry stack pointer from address of the first 
API parameter
+
+  @retval FSP entry stack pointer.
+**/
+VOID*
+EFIAPI
+GetFspEntryStack (
+  VOID
+  );


Add a new line?


Thanks,
Star


  /**
This function sets the FSP API parameter in the stack.
  



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


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

2019-01-23 Thread Zeng, Star

On 2019/1/23 20:15, Julien Grall wrote:

On 23/01/2019 01:41, Zeng, Star wrote:

Hi Julien,


Hi Star,


On 2019/1/22 12:30, Zeng, Star wrote:

On 2019/1/22 3:40, Ard Biesheuvel wrote:
On Mon, 21 Jan 2019 at 14:36, Julien Grall  
wrote:

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index a8bb9cf25ebd..adaf6ccb48b0 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -236,14 +236,16 @@ VariableClassAddressChangeEvent (
  {
    UINTN  Index;

-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetBlockSize);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetAttributes);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->SetAttributes);
-  EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->FvbInstance->Read);

-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Write);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->EraseBlocks);
-  EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->FvbInstance);

+  if (mVariableModuleGlobal->FvbInstance != NULL) {
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetBlockSize);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetAttributes);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->SetAttributes);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Read);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Write);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->EraseBlocks);
+    EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->FvbInstance);

+  }
    EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->PlatformLangCodes);
    EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->LangCodes);
    EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->PlatformLang);


Thanks Ard. I integrated it into the patch 10 of V4.
Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode_V4

Julien, could you help take a try?


Sorry for a little push. Are you able to have a quick try? :)


Sorry for the late, I didn't have time yesterday to test at it.

I tried the new branch and was able to boot a Linux guest using UEFI.

Feel free to add my tags to the series:

Tested-by: Julien Grall 
Acked-by: Julien Grall 


It is really very helpful to make the patch higher quality.



Many thanks to you, Ard and Laszlo for the feedback.


Thanks all of you.

Star



Best regards,



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


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

2019-01-22 Thread Zeng, Star

Hi Julien,

On 2019/1/22 12:30, Zeng, Star wrote:

Hi,

On 2019/1/22 3:40, Ard Biesheuvel wrote:
On Mon, 21 Jan 2019 at 14:36, Julien Grall  
wrote:


Hi,

On 21/01/2019 10:46, Zeng, Star wrote:

On 2019/1/18 2:59, Julien Grall wrote:
I saw the discussion at
https://lists.01.org/pipermail/edk2-devel/2019-January/035405.html. 
Fortunately,

it has been fixed.
So I did rebase for the code.
Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode_V3_rebased


I was about to ask a branch as there were conflicts in the rebase.
Thank you for providing the branch!



If you can help have a quick test, that will be very helpful. :)


With your series applied, EDK2 is crashing while the Linux EFI stub
is running. See the log below.

My knowledge of EDK2 is quite limited, so I am not entirely where to
look at. I am happy to help debugging if you provide guidance.


Thanks for the test. Fortunately, we could catch this before the patch 
is pushed. :)






Hi Julien,

Could you try the patch below please?

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index a8bb9cf25ebd..adaf6ccb48b0 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -236,14 +236,16 @@ VariableClassAddressChangeEvent (
  {
    UINTN  Index;

-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetBlockSize);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetAttributes);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->SetAttributes);
-  EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->FvbInstance->Read);

-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Write);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->EraseBlocks);
-  EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->FvbInstance);

+  if (mVariableModuleGlobal->FvbInstance != NULL) {
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetBlockSize);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetAttributes);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->SetAttributes);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Read);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Write);
+    EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->EraseBlocks);
+    EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->FvbInstance);

+  }
    EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->PlatformLangCodes);

    EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->LangCodes);
    EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->PlatformLang);


Thanks Ard. I integrated it into the patch 10 of V4.
Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode_V4

Julien, could you help take a try?


Sorry for a little push. Are you able to have a quick try? :)


Thanks,
Star




Thanks,
Star








Press any key to continue...

[Security] 3rd party image[0] can be loaded after EndOfDxe: 
MemoryMapped(0x2,0x67789000,0x68DF1200).


InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 7AB2B040

Loading driver at 0x00065783000 EntryPoint=0x00066878664

Loading driver at 0x00065783000 EntryPoint=0x00066878664

InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 7AA54B18

ProtectUefiImageCommon - 0x7AB2B040

   - 0x65783000 - 0x02006000

SetUefiImageMemoryAttributes - 0x65783000 - 
0x1000 (0x4008)


SetUefiImageMemoryAttributes - 0x65784000 - 
0x011CD000 (0x00020008)


SetUefiImageMemoryAttributes - 0x66951000 - 
0x00E38000 (0x4008)


EFI stub: Booting Linux Kernel...

EFI stub: Using DTB from configuration table

EFI stub: Exiting boot services and installing virtual address map...

XenBus: Set state to 5

XenBus: Set state to 5, done

XenPvBlk: waiting backend state 5, current: 4

XenStore: Watch event 7B036698

XenBus: Set state to 6

XenBus: Set state to 6, done

XenPvBlk: waiting backend state 6, current: 5

XenStore: Watch event 7B036698

XenBus: Set state to 1

XenBus: Set state to 1, done

Xen GrantTable, removing 38003

Xen GrantTable, removing 38002

Xen GrantTable, removing 38001

Xen GrantTable, removing 38000

SetUefiImageMemoryAttributes - 0x7BE6 - 
0x00

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

2019-01-21 Thread Zeng, Star

Hi,

On 2019/1/22 3:40, Ard Biesheuvel wrote:

On Mon, 21 Jan 2019 at 14:36, Julien Grall  wrote:


Hi,

On 21/01/2019 10:46, Zeng, Star wrote:

On 2019/1/18 2:59, Julien Grall wrote:
I saw the discussion at
https://lists.01.org/pipermail/edk2-devel/2019-January/035405.html. Fortunately,
it has been fixed.
So I did rebase for the code.
Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode_V3_rebased


I was about to ask a branch as there were conflicts in the rebase.
Thank you for providing the branch!



If you can help have a quick test, that will be very helpful. :)


With your series applied, EDK2 is crashing while the Linux EFI stub
is running. See the log below.

My knowledge of EDK2 is quite limited, so I am not entirely where to
look at. I am happy to help debugging if you provide guidance.


Thanks for the test. Fortunately, we could catch this before the patch 
is pushed. :)






Hi Julien,

Could you try the patch below please?

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index a8bb9cf25ebd..adaf6ccb48b0 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -236,14 +236,16 @@ VariableClassAddressChangeEvent (
  {
UINTN  Index;

-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetBlockSize);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetAttributes);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->SetAttributes);
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->Read);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Write);
-  EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->EraseBlocks);
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance);
+  if (mVariableModuleGlobal->FvbInstance != NULL) {
+EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetBlockSize);
+EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);
+EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->GetAttributes);
+EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->SetAttributes);
+EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Read);
+EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->Write);
+EfiConvertPointer (0x0, (VOID **)
&mVariableModuleGlobal->FvbInstance->EraseBlocks);
+EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance);
+  }
EfiConvertPointer (0x0, (VOID **) 
&mVariableModuleGlobal->PlatformLangCodes);
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->LangCodes);
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->PlatformLang);


Thanks Ard. I integrated it into the patch 10 of V4.
Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode_V4

Julien, could you help take a try?


Thanks,
Star








Press any key to continue...

[Security] 3rd party image[0] can be loaded after EndOfDxe: 
MemoryMapped(0x2,0x67789000,0x68DF1200).

InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 7AB2B040

Loading driver at 0x00065783000 EntryPoint=0x00066878664

Loading driver at 0x00065783000 EntryPoint=0x00066878664

InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 7AA54B18

ProtectUefiImageCommon - 0x7AB2B040

   - 0x65783000 - 0x02006000

SetUefiImageMemoryAttributes - 0x65783000 - 0x1000 
(0x4008)

SetUefiImageMemoryAttributes - 0x65784000 - 0x011CD000 
(0x00020008)

SetUefiImageMemoryAttributes - 0x66951000 - 0x00E38000 
(0x4008)

EFI stub: Booting Linux Kernel...

EFI stub: Using DTB from configuration table

EFI stub: Exiting boot services and installing virtual address map...

XenBus: Set state to 5

XenBus: Set state to 5, done

XenPvBlk: waiting backend state 5, current: 4

XenStore: Watch event 7B036698

XenBus: Set state to 6

XenBus: Set state to 6, done

XenPvBlk: waiting backend state 6, current: 5

XenStore: Watch event 7B036698

XenBus: Set state to 1

XenBus: Set state to 1, done

Xen GrantTable, removing 38003

Xen GrantTable, removing 38002

Xen GrantTable, removing 38001

Xen GrantTable, removing 38000

SetUefiImageMemoryAttributes - 0x7BE6 - 0x0004 
(0x0008)

SetUefiImageMemoryAttributes - 0x78AE - 0x0005 
(0x0008)

SetUefi

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

2019-01-21 Thread Zeng, Star

Hi Julien,

On 2019/1/18 2:59, Julien Grall wrote:

Hi Star,

On 17/01/2019 01:26, Zeng, Star wrote:

On 2019/1/16 22:26, Julien Grall wrote:

Hi Laszlo,

On 15/01/2019 09:37, Laszlo Ersek wrote:

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

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

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

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

diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index a29d8a4ae717..db85fb3402d0 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -1,7 +1,7 @@
  #
  #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2016, Intel Corporation. All rights 
reserved.
+#  Copyright (c) 2015 - 2019, Intel Corporation. All rights 
reserved.

  #
  #  This program and the accompanying materials
  #  are licensed and made available under the terms and conditions 
of the BSD License

@@ -101,6 +101,11 @@ [PcdsFixedAtBuild.common]
    # Set terminal type to TtyTerm, the value encoded is 
EFI_TTY_TERM_GUID
    gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 
0x91, 0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 
0x51, 0xef, 0x94}

+  #
+  # Make VariableRuntimeDxe work at emulated non-volatile variable 
mode.

+  #
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
+
  [PcdsPatchableInModule.common]
    #
    # This will be overridden in the code
@@ -172,7 +177,7 @@ [Components.common]
    MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
    MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
- 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf 


+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf 


MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf
index 50e670254d52..5655c0df2926 100644
--- a/ArmVirtPkg/ArmVirtXen.fdf
+++ b/ArmVirtPkg/ArmVirtXen.fdf
@@ -1,7 +1,7 @@
  #
  #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2017, Intel Corporation. All rights 
reserved.
+#  Copyright (c) 2015 - 2019, Intel Corporation. All rights 
reserved.

  #
  #  This program and the accompanying materials
  #  are licensed and made available under the terms and conditions 
of the BSD License

@@ -137,7 +137,7 @@ [FV.FvMain]
    INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
    INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  INF 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf 

+  INF 
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
    INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf 

    INF 
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf




Reviewed-by: Laszlo Ersek 

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


I will have a try and let you know the result.


Thank you, Julien.
I think you can try based on V3 series although there is no essential 
difference between V2 and V3. :)


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


Thank you for the link. I am having trouble to get newer UEFI (without 
your patch) running in a Xen guest. I have an old binary working.


I am not entirely sure why, I will let you know when I can test your 
series.


I saw the discussion at 
https://lists.01.org/pipermail/edk2-devel/2019-January/035405.html. 
Fortunately, it has been fixed.

So I did rebase for the code.
Repo: g...@github.com:lzeng14/edk2.git
Branch: MergedVariableDriver_EmuNvMode_V3_rebased

If you can help have a quick test, that will be very helpful. :)

Thanks,
Star



Cheers,



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


Re: [edk2] [PATCH] IntelFsp2Pkg: Remove unused keyword in new PPI header

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

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chasel, 
Chiu
Sent: Monday, January 21, 2019 1:56 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star 
Subject: [edk2] [PATCH] IntelFsp2Pkg: Remove unused keyword in new PPI header

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

There was unused keyword added in FspmArchConfigPpi.h header block and should 
be removed.

Cc: Nate DeSimone 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h 
b/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
index 5bedb95aa7..0268f43b1e 100644
--- a/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
+++ b/IntelFsp2Pkg/Include/Ppi/FspmArchConfigPpi.h
@@ -1,7 +1,6 @@
 /** @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
--
2.13.3.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/4] MdeModulePkg/VarCheckLib: permit use by MM_STANDALONE modules

2019-01-18 Thread Zeng, Star
Anther, the parameters of constructor are removed, so their descriptions in 
function header also need to be cleaned up. Same comment to patch 2. With them 
fixed, Reviewed-by: Star Zeng  to the series.

Thanks,
Star
-Original Message-
From: Zeng, Star 
Sent: Friday, January 18, 2019 4:15 PM
To: Ard Biesheuvel ; edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Gao, Liming 
; Ye, Ting ; Wei, Gang 
; Wang, Jian J ; Zhang, Chao B 
; Yao, Jiewen ; Wu, Hao A 
; Achin Gupta ; Jagadeesh Ujja 
; Zeng, Star 
Subject: RE: [PATCH 3/4] MdeModulePkg/VarCheckLib: permit use by MM_STANDALONE 
modules

This patch does not touch VarCheckLib at all, but only touch VarCheckUefiLib, 
so the title and commit message need be updated.
With them updated correctly, Reviewed-by: Star Zeng .


Thanks,
Star
-Original Message-
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org] 
Sent: Thursday, January 17, 2019 5:22 AM
To: edk2-devel@lists.01.org
Cc: Ard Biesheuvel ; Kinney, Michael D 
; Gao, Liming ; Ye, Ting 
; Wei, Gang ; Wang, Jian J 
; Zhang, Chao B ; Yao, Jiewen 
; Wu, Hao A ; Zeng, Star 
; Achin Gupta ; Jagadeesh Ujja 

Subject: [PATCH 3/4] MdeModulePkg/VarCheckLib: permit use by MM_STANDALONE 
modules

Permit VarCheckLib and VarCheckUefiLib to be used by MM_STANDALONE modules.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf| 4 ++--
 MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c | 9 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf 
b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
index 128c44d695e1..8873fd51a02a 100644
--- a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
@@ -19,9 +19,9 @@ [Defines]
   BASE_NAME  = VarCheckUefiLib
   MODULE_UNI_FILE= VarCheckUefiLib.uni
   FILE_GUID  = AC24A4C7-F845-4665-90E5-6431D6E28DC0
-  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  MODULE_TYPE= BASE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = NULL|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER 
MM_STANDALONE
   CONSTRUCTOR= VarCheckUefiLibNullClassConstructor
 
 #
diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c 
b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
index 80dc6341adcf..5e419831e8cc 100644
--- a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
+++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
@@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 **/
 
+#include 
+
 #include 
 #include 
 #include 
@@ -927,15 +929,14 @@ VariablePropertySetUefiDefined (
   @retval EFI_SUCCESS   The constructor executed correctly.
 
 **/
-EFI_STATUS
+RETURN_STATUS
 EFIAPI
 VarCheckUefiLibNullClassConstructor (
-  IN EFI_HANDLE ImageHandle,
-  IN EFI_SYSTEM_TABLE   *SystemTable
+  VOID
   )
 {
   VariablePropertySetUefiDefined ();
   VarCheckLibRegisterSetVariableCheckHandler 
(SetVariableCheckHandlerUefiDefined);
 
-  return EFI_SUCCESS;
+  return RETURN_SUCCESS;
 }
--
2.17.1

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


Re: [edk2] [PATCH 3/4] MdeModulePkg/VarCheckLib: permit use by MM_STANDALONE modules

2019-01-18 Thread Zeng, Star
This patch does not touch VarCheckLib at all, but only touch VarCheckUefiLib, 
so the title and commit message need be updated.
With them updated correctly, Reviewed-by: Star Zeng .


Thanks,
Star
-Original Message-
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org] 
Sent: Thursday, January 17, 2019 5:22 AM
To: edk2-devel@lists.01.org
Cc: Ard Biesheuvel ; Kinney, Michael D 
; Gao, Liming ; Ye, Ting 
; Wei, Gang ; Wang, Jian J 
; Zhang, Chao B ; Yao, Jiewen 
; Wu, Hao A ; Zeng, Star 
; Achin Gupta ; Jagadeesh Ujja 

Subject: [PATCH 3/4] MdeModulePkg/VarCheckLib: permit use by MM_STANDALONE 
modules

Permit VarCheckLib and VarCheckUefiLib to be used by MM_STANDALONE modules.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf| 4 ++--
 MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c | 9 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf 
b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
index 128c44d695e1..8873fd51a02a 100644
--- a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
@@ -19,9 +19,9 @@ [Defines]
   BASE_NAME  = VarCheckUefiLib
   MODULE_UNI_FILE= VarCheckUefiLib.uni
   FILE_GUID  = AC24A4C7-F845-4665-90E5-6431D6E28DC0
-  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  MODULE_TYPE= BASE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = NULL|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER 
MM_STANDALONE
   CONSTRUCTOR= VarCheckUefiLibNullClassConstructor
 
 #
diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c 
b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
index 80dc6341adcf..5e419831e8cc 100644
--- a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
+++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
@@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 **/
 
+#include 
+
 #include 
 #include 
 #include 
@@ -927,15 +929,14 @@ VariablePropertySetUefiDefined (
   @retval EFI_SUCCESS   The constructor executed correctly.
 
 **/
-EFI_STATUS
+RETURN_STATUS
 EFIAPI
 VarCheckUefiLibNullClassConstructor (
-  IN EFI_HANDLE ImageHandle,
-  IN EFI_SYSTEM_TABLE   *SystemTable
+  VOID
   )
 {
   VariablePropertySetUefiDefined ();
   VarCheckLibRegisterSetVariableCheckHandler 
(SetVariableCheckHandlerUefiDefined);
 
-  return EFI_SUCCESS;
+  return RETURN_SUCCESS;
 }
--
2.17.1

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


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

2019-01-16 Thread Zeng, Star

On 2019/1/16 22:26, Julien Grall wrote:

Hi Laszlo,

On 15/01/2019 09:37, Laszlo Ersek wrote:

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

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

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

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

diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index a29d8a4ae717..db85fb3402d0 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -1,7 +1,7 @@
  #
  #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2016, Intel Corporation. All rights 
reserved.
+#  Copyright (c) 2015 - 2019, Intel Corporation. All rights 
reserved.

  #
  #  This program and the accompanying materials
  #  are licensed and made available under the terms and conditions 
of the BSD License

@@ -101,6 +101,11 @@ [PcdsFixedAtBuild.common]
    # Set terminal type to TtyTerm, the value encoded is 
EFI_TTY_TERM_GUID
    gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 
0x91, 0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 
0x51, 0xef, 0x94}

+  #
+  # Make VariableRuntimeDxe work at emulated non-volatile variable 
mode.

+  #
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
+
  [PcdsPatchableInModule.common]
    #
    # This will be overridden in the code
@@ -172,7 +177,7 @@ [Components.common]
    MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
    MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf

+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf

MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf 


MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf

diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf
index 50e670254d52..5655c0df2926 100644
--- a/ArmVirtPkg/ArmVirtXen.fdf
+++ b/ArmVirtPkg/ArmVirtXen.fdf
@@ -1,7 +1,7 @@
  #
  #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2017, Intel Corporation. All rights 
reserved.
+#  Copyright (c) 2015 - 2019, Intel Corporation. All rights 
reserved.

  #
  #  This program and the accompanying materials
  #  are licensed and made available under the terms and conditions 
of the BSD License

@@ -137,7 +137,7 @@ [FV.FvMain]
    INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
    INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  INF 
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf

+  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
    INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf 

    INF 
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf




Reviewed-by: Laszlo Ersek 

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


I will have a try and let you know the result.


Thank you, Julien.
I think you can try based on V3 series although there is no essential 
difference between V2 and V3. :)


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

Thanks,
Star



Cheers,



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


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

2019-01-15 Thread Zeng, Star

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

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

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

  2 files changed, 137 insertions(+)

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

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


noop


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


This block could be removed.


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


SystemTable should be MmSystemTable.


+  less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.


_gUefiDriverRevison should be _gMmRevision.


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


SystemTable should be MmSystemTable.

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

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


Thanks,
Star



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

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

2019-01-15 Thread Zeng, Star

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

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

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


Reviewed-by: Star Zeng 


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

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

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

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



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


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

2019-01-15 Thread Zeng, Star

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

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

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


Reviewed-by: Star Zeng 


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

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

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

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

2019-01-15 Thread Zeng, Star

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

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

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

diff --git 
a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
 
b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
new file mode 100644
index ..c231cd0e271b
--- /dev/null
+++ 
b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
@@ -0,0 +1,38 @@
+## @file
+# Null instance of Memory Allocation Library.
+#
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution. The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001B
+  BASE_NAME  = BaseMemoryAllocationLibNull
+  MODULE_UNI_FILE= BaseMemoryAllocationLibNull.uni
+  FILE_GUID  = fd56f5d6-f194-448f-be69-c0cbb0c281af
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = MemoryAllocationLib
+
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  BaseMemoryAllocationLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
diff --git 
a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
 
b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
new file mode 100644
index ..16812d3f9bb3
--- /dev/null
+++ 
b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
@@ -0,0 +1,575 @@
+/** @file
+  DUmmy support routines for memory allocation


Should be "Dummy" here?

With it handled, Reviewed-by: Star Zeng .

Thanks,
Star


+
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#include 
+
+#include 
+#include 
+
+
+/**
+  Allocates one or more 4KB pages of type EfiBootServicesData.
+
+  Allocates the number of 4KB pages of type EfiBootServicesData and returns a 
pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If 
Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the 
request, then NULL is
+  returned.
+
+  @param  Pages The number of 4 KB pages to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocatePages (
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData.
+
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns 
a pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If 
Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the 
request, then NULL is
+  returned.
+
+  @param  Pages The number of 4 KB pages to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePages (
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiReservedMemoryType.
+
+  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns 
a pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If 
Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the 
request, then NULL is
+  returned.
+
+  @param  Pages The number of 4 KB pages t

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

2019-01-15 Thread Zeng, Star

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

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

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


Reviewed-by: Star Zeng 


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

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

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

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

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



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


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

2019-01-15 Thread Zeng, Star

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

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

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


Reviewed-by: Star Zeng 


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

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

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



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


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

2019-01-15 Thread Zeng, Star

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

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

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


Reviewed-by: Star Zeng 


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

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

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



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


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

2019-01-15 Thread Zeng, Star

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

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

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


Reviewed-by: Star Zeng 


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

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

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

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



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


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

2019-01-15 Thread Zeng, Star

One minor comment.

With it handled, Reviewed-by: Star Zeng 

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

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

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

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



[Trimmed]


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


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



Thanks,
Star


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



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


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

2019-01-15 Thread Zeng, Star

Some minor comments.

With them handled, Reviewed-by: Star Zeng 

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

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

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

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



[Trimmed]


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

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


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



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


[Trimmed]


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


This line needs to be kept.


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

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

+  Status = gMmst->MmAllocatePool (
  EfiRuntimeServicesData,
  mVariableBufferPayloadSize,

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

2019-01-15 Thread Zeng, Star

One minor comment.

With it handled, Reviewed-by: Star Zeng 

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

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

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



[Trimmed]


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


The comments block should have description for the two parameters.


Thanks,
Star


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



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


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

2019-01-15 Thread Zeng, Star

Some minor comments.

With them handled, Reviewed-by: Star Zeng 

Thanks,
Star

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

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

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



[Trimmed]

  
+/**

+  Entry point of the module
+**/


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



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


[Trimmed]

  
  **/

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


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


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

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

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


[Trimmed]


+
+/**
+  Entry point of the module


The comments block should have description for the two parameters.


Thanks,
Star


+**/
+EFI_STATUS
+EFIAPI
+SmmFaultTolerantWriteInitialize (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBl

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

2019-01-15 Thread Zeng, Star

On 2019/1/15 14:37, Wang, Jian J wrote:

Hi Star,

One comment below.


-Original Message-
From: Zeng, Star
Sent: Monday, January 14, 2019 11:20 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Wang, Jian J ;
Wu, Hao A 
Subject: [PATCH V2 03/15] MdeModulePkg Variable: Not get NV PCD in
VariableWriteServiceInitialize

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

Add macro NV_STORAGE_VARIABLE_BASE.
Not get NV PCD in VariableWriteServiceInitialize, but in
FtwNotificationEvent/SmmFtwNotificationEvent, then
VariableWriteServiceInitialize could be not aware the NV
storage is real or emulated.

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

Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
  .../Universal/Variable/RuntimeDxe/Variable.c | 20 ++--
  .../Universal/Variable/RuntimeDxe/Variable.h |  9 +++--
  .../Universal/Variable/RuntimeDxe/VariableDxe.c  | 12 
  .../Universal/Variable/RuntimeDxe/VariableSmm.c  | 16 +++-
  4 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 0b675c8f36df..424f92a53757 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -3770,10 +3770,7 @@ InitRealNonVolatileVariableStore (
  return EFI_OUT_OF_RESOURCES;
}

-  NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64
(PcdFlashNvStorageVariableBase64);
-  if (NvStorageBase == 0) {
-NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32
(PcdFlashNvStorageVariableBase);
-  }
+  NvStorageBase = NV_STORAGE_VARIABLE_BASE;
ASSERT (NvStorageBase != 0);

//
@@ -4027,7 +4024,7 @@ FlushHobVariableToFlash (
  }

  /**
-  Initializes variable write service after FTW was ready.
+  Initializes variable write service.

@retval EFI_SUCCESS  Function successfully executed.
@retval Others   Fail to initialize the variable service.
@@ -4041,23 +4038,10 @@ VariableWriteServiceInitialize (
EFI_STATUS  Status;
UINTN   Index;
UINT8   Data;
-  EFI_PHYSICAL_ADDRESSVariableStoreBase;
-  EFI_PHYSICAL_ADDRESSNvStorageBase;
VARIABLE_ENTRY_PROPERTY *VariableEntry;

AcquireLockOnlyAtBootTime(&mVariableModuleGlobal-

VariableGlobal.VariableServicesLock);


-  NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64
(PcdFlashNvStorageVariableBase64);
-  if (NvStorageBase == 0) {
-NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32
(PcdFlashNvStorageVariableBase);
-  }
-  VariableStoreBase = NvStorageBase + (mNvFvHeaderCache->HeaderLength);
-
-  //
-  // Let NonVolatileVariableBase point to flash variable store base directly 
after
FTW ready.
-  //
-  mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase =
VariableStoreBase;
-
//
// Check if the free area is really free.
//
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
index 938eb5de61fa..566e7268d187 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
@@ -2,7 +2,7 @@
The internal header file includes the common header files, defines
internal structure and functions used by Variable modules.

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

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

2019-01-15 Thread Zeng, Star

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

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

Star,

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

Reviewed-by: Jian J Wang 


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

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

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

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

mVariableModuleGlobal->NonVolatileLastVariableOffset +=
   HEADER_ALIGN (VarSize);

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

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

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

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


The first character of comment is not capitalized.


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

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


Make sense, I can do that.

Thanks,
Star



Thanks
Laszlo





+CopyMem ((UINT8 *)mNvVariableCache + mVariableModuleGlobal-

NonVolatileLastVariableOffset, (UINT8 *)NextVariable, VarSize);

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

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




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


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

2019-01-15 Thread Zeng, Star

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

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

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

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

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

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


Acked-by: Laszlo Ersek 

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


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


Thanks,
Star



Thanks,
Laszlo



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


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 v

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] [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 b

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(&mVariableModuleGlobal-

VariableGlobal.VariableServicesLock);


-  NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64
(PcdFlashNvStorageVariableBase64);
-  if (NvStorageBase == 0) {
-NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32
(PcdFlashNvStorageVariableBase);
-  }
-  VariableStoreBase = NvStorageBase + (mNvFvHeaderCache-

HeaderLength);

-
-  //
-  // Let NonVolatileVariableBase point to flash variable store base directly
after FTW ready.
-  //
-  mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase =
VariableStoreBase;
-
//
// Check if the free area is really free.
//
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
index 938eb5de61fa..566e7268d187 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
@@ -2,7 +2,7 @@
The internal header file includes the common header files, defines
internal structure and functions used by Variable modules.

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

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 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 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntime

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

Re: [edk2] [PATCH 05/12] MdeModulePkg: Add PcdEmuVariableNvModeEnable in dsc

2019-01-14 Thread Zeng, Star

Hi Laszlo,

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


(1) the subject line should say "in dec", not "in dsc".


Oh, good catch.



Otherwise, this patch looks OK to me; in particular the FALSE default.

With the subject fixed:

Reviewed-by: Laszlo Ersek 


Thanks for the RB. :)

Thanks,
Star



Thanks,
Laszlo


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

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

2019-01-14 Thread Zeng, Star

Hi Laszlo,

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

Hi Star,

On 01/13/19 16:37, Star Zeng wrote:

9b18845a4b4cd1d2cf004cbc1cadf8a93ccb37ea changed the code
which read from physical MMIO address to read from memory cache.

The patch adds some missing changes for it.

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


Please update the commit message to clarify the change.

Commit 9b18845a4b4c ("MdeModulePkg Variable: Enhance variable
performance by reading from existed memory cache.", 2015-10-23) was a
performance optimization. Therefore, there can be two issues with it:

(a) it may have missed another opportunity for performance improvement,

(b) it may have introduced a regression.

Can you please clarify the issue? The explanation should be part of the
commit message.

Dependent on (a) vs. (b), the impact of this change could differ greatly.


Oh, got your point. :)
(a) is the issue, I can add it to be part of the commit message.
If V2 patch series is needed, it will be included in that series.

Thanks,
Star



Thanks!
Laszlo




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, &FvVolHdr);
  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_STOR

Re: [edk2] [Patch 0/2] Use correct field name.

2019-01-13 Thread Zeng, Star
Agree with Laszlo's comments to those two patches.

Reviewed-by: Star Zeng 

Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
Ersek
Sent: Friday, January 11, 2019 6:45 PM
To: Dong, Eric ; edk2-devel@lists.01.org
Cc: Ni, Ray ; Aleksiy 
Subject: Re: [edk2] [Patch 0/2] Use correct field name.

On 01/11/19 06:46, Eric Dong wrote:
> ((Facs->Flags & EFI_ACPI_4_0_OSPM_64BIT_WAKE__F) != 0))
> 
> In above code, Facs->OspmFlags should be used instead.
> EFI_ACPI_4_0_OSPM_64BIT_WAKE__F is a bit in OSPM Enabled Firmware 
> Control Structure Flags field, not in Firmware Control Structure 
> Feature Flags.
> 
> Update all related code to use correct field name.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1430
> 
> Cc: Aleksiy 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Jian Wang 
> Eric Dong (2):
>   UefiCpuPkg/S3Resume2Pei: Use correct field name.
>   MdeModulePkg/BootScriptExecuteorDxe: Use correct field name.
> 
>  MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c   | 4 ++--
>  MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c | 4 ++--
>  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c   | 6 
> +++---
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 

Regression-tested-by: Laszlo Ersek  
___
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 0/6] implement standalone MM versions of the variable runtime drivers

2019-01-13 Thread Zeng, Star

Ard,

FYI:
There is minor change overlap to VariableDxe/Smm.c between this patch 
series and the patch series at 
https://lists.01.org/pipermail/edk2-devel/2019-January/034921.html 
([PATCH 04/12]) I just sent.


After one patch series is pushed, the other patch series will need a 
simple rebase.



Thanks,
Star

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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 traditional SMM drivers
can use it as well. This is appropriate, considering that the PI
spec has rebranded traditional SMM as one implementation of the generic
MM framework.

Patch #1 is based on Jagadeesh's patch, and introduces the MmServicesTableLib
library class, but for all SMM flavours, not only for standalone MM.

Patch #2 implements MmServicesTableLib for traditional SMM implementations.

Patch #3 refactors FaultTolerantWriteDxe so that the parts of the SMM
driver that invoke boot services are separated from the core SMM pieces.

Patch #4 implements FaultTolerantWriteSmm for the standalone MM environment.

Patches #5 and #6 do the same, respectively, for the variable runtime driver.

This approach minimizes the delta, and thus the maintenance burden, between
the traditional SMM and standalone MM drivers, while not resorting to runtime
checks or other conditionals in the code to implement logic that should be
decided at build time.

Note that this series only covers part of the work contributed by Jagadeesh.
This series focuses on the MdePkg and MdeModulePkg changes that affect shared
code.

Cc: Laszlo Ersek 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Jagadeesh Ujja 
Cc: Achin Gupta 
Cc: Thomas Panakamattam Abraham 
Cc: Sami Mujawar 

Ard Biesheuvel (5):
   MdePkg: implement MmServicesTableLib based on traditional SMM
   MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
   MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
   MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
   MdeModulePkg/VariableRuntimeDxe: implement standalone MM version

Jagadeesh Ujja (1):
   MdePkg/Include: add MmServicesTableLib header file

  MdeModulePkg/MdeModulePkg.dsc |   1 +
  .../FaultTolerantWrite.h  |  22 ++-
  .../FaultTolerantWriteDxe.c   |  31 
  .../FaultTolerantWriteSmm.c   |  54 +++
  .../FaultTolerantWriteSmm.inf |   5 +-
  .../FaultTolerantWriteSmmCommon.h |  31 
  .../FaultTolerantWriteSmmDxe.c|   1 +
  .../FaultTolerantWriteStandaloneMm.c  |  70 +
  .../FaultTolerantWriteStandaloneMm.inf|  90 
  .../FaultTolerantWriteTraditionalMm.c |  94 
  .../UpdateWorkingBlock.c  |  10 +-
  .../Variable/RuntimeDxe/TcgMorLockSmm.c   |  18 +--
  .../Universal/Variable/RuntimeDxe/Variable.h  |  50 +++
  .../Variable/RuntimeDxe/VariableSmm.c |  59 +++-
  .../Variable/RuntimeDxe/VariableSmm.inf   |   5 +-
  .../RuntimeDxe/VariableStandaloneMm.c |  69 +
  .../RuntimeDxe/VariableStandaloneMm.inf   | 135 ++
  .../RuntimeDxe/VariableTraditionalMm.c| 114 +++
  MdePkg/Include/Library/MmServicesTableLib.h   |  25 
  .../MmServicesTableLib/MmServicesTableLib.c   |  63 
  .../MmServicesTableLib/MmServicesTableLib.inf |  45 ++
  .../MmServicesTableLib/MmServicesTableLib.uni |  22 +++
  MdePkg/MdePkg.dec |   4 +
  MdePkg/MdePkg.dsc |   1 +
  24 files changed, 916 insertions(+), 103 deletions(-)
  create mode 100644 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
  create mode 100644 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
  create mode 100644 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
  create mode 100644 
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
  create mode 100644 
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
  create mode 100644 
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
  create mode 100644 MdePkg/Include/Library/MmServicesTableLib.h
  create mode 100644 MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
  create mode 100644 MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
  create mode 100644 MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni



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


Re: [edk2] [PATCH 4/6] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version

2019-01-10 Thread Zeng, Star

On 2019/1/11 0:23, Ard Biesheuvel wrote:

On Thu, 10 Jan 2019 at 14:03, Laszlo Ersek  wrote:


On 01/10/19 08:59, Zeng, Star wrote:

On 2019/1/10 15:33, Ard Biesheuvel wrote:

On Thu, 10 Jan 2019 at 08:30, Zeng, Star  wrote:


Hi Ard,

Another minor feedback.

On 2019/1/10 14:47, Zeng, Star wrote:

Hi Ard,

Some minor feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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

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

MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c

| 70 +++

MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf

| 90 
2 files changed, 160 insertions(+)


Please add it into MdeModulePkg.dsc for package build verification.



Hello Star,

Thanks for all the feedback. I will respond in more detail later.

However, to the point raised here: it is not possible to add these
drivers to MdeModulePkg.dsc unless we add a dummy implementation of
StandaloneMmDriverEntryPoint to MdeModulePkg. Do you think we should
do that?


Oh, good information.
To have full code building coverage for the package, personally I think
we can move StandaloneMmDriverEntryPoint library class and instance into
MdePkg, and even the MmServicesTableLib for MM_STANDALONE, they should
be generic enough.

I do not want to block this patch set because of this. So let's discuss
this in parallel as separated topic.

Mike, Liming, Laszlo, Jian and Hao,\
What's your opinion?


It should be possible to build all library instances in a central
Package (well, all Packages really), using the Package's DSC file. To my
understanding, libraries built like this are not expected to be used in
actual (shipped) drivers / applications, nor is their indiscriminate
distribution (as LIBs) expected. For example, shipping a BaseXxxLibNull
library instance in binary form seems quite useless.

With that in mind, I think a Null instance for the entry point in
question makes sense, under MdeModulePkg.



I will look into this a bit deeper next week. I think it makes sense
for the core PI architected pieces to all live in MdePkg rather than
StandaloneMmPkg. For instance, MmServicesTableLib for standalone MM
should live there, MmEntryPoint should live there (and have
traditional and standalone MM implementation) and perhaps some other
core pieces as well.

This may be a slippery slope, so I will dedicate some time to look
into this carefully, at least with the goal to make the
FaultTolerantWrite and Variable driver buildable from within
MdeModulePkg.


Make sense to me. You'd better to submit a bugzilla to track this after 
this patchset is pushed.


Thanks,
Star






___
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-10 Thread Zeng, Star

We'd better have a bugzilla to track this change.
And since it will require platform change in platform dsc to add the new 
library mapping, we need add notes in 
https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Notes.



Thanks,
Star

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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 traditional SMM drivers
can use it as well. This is appropriate, considering that the PI
spec has rebranded traditional SMM as one implementation of the generic
MM framework.

Patch #1 is based on Jagadeesh's patch, and introduces the MmServicesTableLib
library class, but for all SMM flavours, not only for standalone MM.

Patch #2 implements MmServicesTableLib for traditional SMM implementations.

Patch #3 refactors FaultTolerantWriteDxe so that the parts of the SMM
driver that invoke boot services are separated from the core SMM pieces.

Patch #4 implements FaultTolerantWriteSmm for the standalone MM environment.

Patches #5 and #6 do the same, respectively, for the variable runtime driver.

This approach minimizes the delta, and thus the maintenance burden, between
the traditional SMM and standalone MM drivers, while not resorting to runtime
checks or other conditionals in the code to implement logic that should be
decided at build time.

Note that this series only covers part of the work contributed by Jagadeesh.
This series focuses on the MdePkg and MdeModulePkg changes that affect shared
code.

Cc: Laszlo Ersek 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Jagadeesh Ujja 
Cc: Achin Gupta 
Cc: Thomas Panakamattam Abraham 
Cc: Sami Mujawar 

Ard Biesheuvel (5):
   MdePkg: implement MmServicesTableLib based on traditional SMM
   MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
   MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
   MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
   MdeModulePkg/VariableRuntimeDxe: implement standalone MM version

Jagadeesh Ujja (1):
   MdePkg/Include: add MmServicesTableLib header file

  MdeModulePkg/MdeModulePkg.dsc |   1 +
  .../FaultTolerantWrite.h  |  22 ++-
  .../FaultTolerantWriteDxe.c   |  31 
  .../FaultTolerantWriteSmm.c   |  54 +++
  .../FaultTolerantWriteSmm.inf |   5 +-
  .../FaultTolerantWriteSmmCommon.h |  31 
  .../FaultTolerantWriteSmmDxe.c|   1 +
  .../FaultTolerantWriteStandaloneMm.c  |  70 +
  .../FaultTolerantWriteStandaloneMm.inf|  90 
  .../FaultTolerantWriteTraditionalMm.c |  94 
  .../UpdateWorkingBlock.c  |  10 +-
  .../Variable/RuntimeDxe/TcgMorLockSmm.c   |  18 +--
  .../Universal/Variable/RuntimeDxe/Variable.h  |  50 +++
  .../Variable/RuntimeDxe/VariableSmm.c |  59 +++-
  .../Variable/RuntimeDxe/VariableSmm.inf   |   5 +-
  .../RuntimeDxe/VariableStandaloneMm.c |  69 +
  .../RuntimeDxe/VariableStandaloneMm.inf   | 135 ++
  .../RuntimeDxe/VariableTraditionalMm.c| 114 +++
  MdePkg/Include/Library/MmServicesTableLib.h   |  25 
  .../MmServicesTableLib/MmServicesTableLib.c   |  63 
  .../MmServicesTableLib/MmServicesTableLib.inf |  45 ++
  .../MmServicesTableLib/MmServicesTableLib.uni |  22 +++
  MdePkg/MdePkg.dec |   4 +
  MdePkg/MdePkg.dsc |   1 +
  24 files changed, 916 insertions(+), 103 deletions(-)
  create mode 100644 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
  create mode 100644 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
  create mode 100644 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
  create mode 100644 
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
  create mode 100644 
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
  create mode 100644 
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
  create mode 100644 MdePkg/Include/Library/MmServicesTableLib.h
  create mode 100644 MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
  create mode 100644 MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
  create mode 100644 MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni



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


Re: [edk2] [PATCH 4/6] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version

2019-01-10 Thread Zeng, Star

On 2019/1/10 15:33, Ard Biesheuvel wrote:

On Thu, 10 Jan 2019 at 08:30, Zeng, Star  wrote:


Hi Ard,

Another minor feedback.

On 2019/1/10 14:47, Zeng, Star wrote:

Hi Ard,

Some minor feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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

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

MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
| 70 +++

MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
| 90 
   2 files changed, 160 insertions(+)


Please add it into MdeModulePkg.dsc for package build verification.



Hello Star,

Thanks for all the feedback. I will respond in more detail later.

However, to the point raised here: it is not possible to add these
drivers to MdeModulePkg.dsc unless we add a dummy implementation of
StandaloneMmDriverEntryPoint to MdeModulePkg. Do you think we should
do that?


Oh, good information.
To have full code building coverage for the package, personally I think 
we can move StandaloneMmDriverEntryPoint library class and instance into 
MdePkg, and even the MmServicesTableLib for MM_STANDALONE, they should 
be generic enough.


I do not want to block this patch set because of this. So let's discuss 
this in parallel as separated topic.


Mike, Liming, Laszlo, Jian and Hao,\
What's your opinion?


Thanks,
Star






diff --git
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c

new file mode 100644
index ..b6fbf6c64f8a
--- /dev/null
+++
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c

@@ -0,0 +1,70 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the
BSD License
+which accompanies this distribution.  The full text of the license
may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
IMPLIED.
+
+**/
+
+#include 
+#include 
+#include "FaultTolerantWrite.h"
+#include "FaultTolerantWriteSmmCommon.h"
+
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64Length
+  )
+{
+  return TRUE;
+}


Please add function comment header for it, otherwise some coding style
tool may report error.


+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (standalone SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer   A pointer to the buffer on which the
32-bit CRC is to be computed.
+  @param[in]  Length   The number of bytes in the buffer Data.
+
+  @retval Crc32The 32-bit CRC was computed for the data
buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID *Buffer,
+  IN  UINTNLength
+  )
+{
+  return CalculateCrc32 (Buffer, Length);
+}


Please add function comment header for it, otherwise some coding style
tool may report error.


+
+VOID
+FtwNotifySmmReady (
+  VOID
+  )
+{
+}


Please add function comment header for it, otherwise some coding style
tool may report error.

Thanks,
Star


+
+EFI_STATUS
+EFIAPI
+StandaloneMmFaultTolerantWriteInitialize (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}
diff --git
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf

new file mode 100644
index ..99bd62ad5ceb
--- /dev/null
+++
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf

@@ -0,0 +1,90 @@
+ ## @file
+#   Fault Tolerant Write Smm Driver.
+#
+#   This driver installs SMM Fault Tolerant Write (FTW) protocol,
which provides fault
+#   tolerant write capability in SMM environment for block devices.
Its implementation
+#   depends on the full functionality SMM FVB protocol that support
read, write/erase
+#   flash access.
+#
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of
th

Re: [edk2] [PATCH 4/6] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version

2019-01-09 Thread Zeng, Star

Hi Ard,

Another minor feedback.

On 2019/1/10 14:47, Zeng, Star wrote:

Hi Ard,

Some minor feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c   
| 70 +++
  
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 
| 90 

  2 files changed, 160 insertions(+)


Please add it into MdeModulePkg.dsc for package build verification.

Thanks,
Star



diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c 


new file mode 100644
index ..b6fbf6c64f8a
--- /dev/null
+++ 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c 


@@ -0,0 +1,70 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the 
BSD License
+which accompanies this distribution.  The full text of the license 
may be found at

+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.

+
+**/
+
+#include 
+#include 
+#include "FaultTolerantWrite.h"
+#include "FaultTolerantWriteSmmCommon.h"
+
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64    Length
+  )
+{
+  return TRUE;
+}


Please add function comment header for it, otherwise some coding style 
tool may report error.



+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (standalone SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer   A pointer to the buffer on which the 
32-bit CRC is to be computed.

+  @param[in]  Length   The number of bytes in the buffer Data.
+
+  @retval Crc32    The 32-bit CRC was computed for the data 
buffer.

+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID *Buffer,
+  IN  UINTN    Length
+  )
+{
+  return CalculateCrc32 (Buffer, Length);
+}


Please add function comment header for it, otherwise some coding style 
tool may report error.



+
+VOID
+FtwNotifySmmReady (
+  VOID
+  )
+{
+}


Please add function comment header for it, otherwise some coding style 
tool may report error.


Thanks,
Star


+
+EFI_STATUS
+EFIAPI
+StandaloneMmFaultTolerantWriteInitialize (
+  IN EFI_HANDLE    ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}
diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 


new file mode 100644
index ..99bd62ad5ceb
--- /dev/null
+++ 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 


@@ -0,0 +1,90 @@
+ ## @file
+#   Fault Tolerant Write Smm Driver.
+#
+#   This driver installs SMM Fault Tolerant Write (FTW) protocol, 
which provides fault
+#   tolerant write capability in SMM environment for block devices. 
Its implementation
+#   depends on the full functionality SMM FVB protocol that support 
read, write/erase

+#   flash access.
+#
+# Copyright (c) 2010 - 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.

+#
+##
+
+[Defines]
+  INF_VERSION    = 0x0001001A
+  BASE_NAME  = FaultTolerantWriteStandaloneMm
+  FILE_GUID  = 3aade4ec-63cc-4a48-a928-5a374dd463eb
+  MODULE_TYPE    = MM_STANDALONE
+  VERSION_STRING = 1.0
+  PI_SPECIFICATION_VERSION   = 0x00010032
+  ENTRY_POINT    = 
StandaloneMmFaultTolerantWriteInitialize

+
+#
+# The following information is for reference o

Re: [edk2] [PATCH 6/6] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version

2019-01-09 Thread Zeng, Star

Hi Ard,

Some minor feedback added below.
With them handled, Reviewed-by: Sta Zeng .

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c   |  69 
++
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 135 

  2 files changed, 204 insertions(+)


Please add it into MdeModulePkg.dsc for package build verification.



diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
new file mode 100644
index ..fbc99467c057
--- /dev/null
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
@@ -0,0 +1,69 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. 
+Copyright (c) 2018, Linaro, Ltd. All rights reserved. 
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD 
License
+which accompanies this distribution.  The full text of the license may be 
found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "Variable.h"
+
+BOOLEAN
+VariableSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64Length
+  )
+{
+  return TRUE;
+}


Please add function comment header for it.


+
+/**
+  Notify the system that the SMM variable driver is ready
+**/
+VOID
+VariableNotifySmmReady (
+  VOID
+  )
+{
+}
+
+/**
+  Notify the system that the SMM variable write driver is ready
+**/
+VOID
+VariableNotifySmmWriteReady (
+  VOID
+  )
+{
+}
+
+EFI_STATUS
+EFIAPI
+VariableServiceInitialize (
+  IN EFI_HANDLE   ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE  *MmSystemTable
+  )
+{
+  return MmVariableServiceInitialize ();
+}


Please add function comment header for it.


+
+/**
+  Whether the TCG or TCG2 protocols are installed in the UEFI protocol 
database.
+  This information is used by the MorLock code to infer whether an existing
+  MOR variable is legitimate or not.


Add a line for return description?

Thanks,
Star


+**/
+BOOLEAN
+VariableHaveTcgProtocols (
+  VOID
+  )
+{
+  return FALSE;
+}
diff --git 
a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
new file mode 100644
index ..54d647af914c
--- /dev/null
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
@@ -0,0 +1,135 @@
+## @file
+#  Provides SMM variable service.
+#
+#  This module installs SMM variable protocol into SMM protocol database,
+#  which can be used by SMM driver, and installs SMM variable protocol
+#  into BS protocol database, which can be used to notify the SMM Runtime
+#  Dxe driver that the SMM variable service is ready.
+#  This module should be used with SMM Runtime DXE module together. The
+#  SMM Runtime DXE module would install variable arch protocol and variable
+#  write arch protocol based on SMM variable module.
+#
+#  Caution: This module requires additional review when modified.
+#  This driver will have external input - variable data and communicate buffer 
in SMM mode.
+#  This external input must be validated carefully to avoid security issues 
such as
+#  buffer overflow or integer overflow.
+#The whole SMM authentication variable design relies on the integrity of 
flash part and SMM.
+#  which is assumed to be protected by platform.  All variable code and 
metadata in flash/SMM Memory
+#  may not be modified without authorization. If platform fails to protect 
these resources,
+#  the authentication service provided in this driver will be broken, and the 
behavior is undefined.
+#
+# Copyright (c) 2010 - 2016, 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = VariableStandaloneMm
+  FILE_GUID  = 7ee2c0c1-c21a-4113-a53a-66824a95696f
+  MODULE_TYPE= MM_STANDALONE
+  VERSION_STRING = 1.0
+  PI_SPECIFICATION_V

Re: [edk2] [PATCH 5/6] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses

2019-01-09 Thread Zeng, Star

Hi Ard,

Some minor feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c |  18 +---
  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h  |  50 
+
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c   |  59 
--
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf |   5 +-
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c | 114 

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

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c
index 28aa2893c6f8..009d96c3a65e 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c
@@ -21,7 +21,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
  #include 
  #include 
  #include 
-#include 
  #include "Variable.h"
  
  typedef struct {

@@ -419,8 +418,6 @@ MorLockInitAtEndOfDxe (
  {
UINTN  MorSize;
EFI_STATUS MorStatus;
-  EFI_STATUS TcgStatus;
-  VOID   *TcgInterface;
  
if (!mMorLockInitializationRequired) {

  //
@@ -458,20 +455,7 @@ MorLockInitAtEndOfDxe (
  // can be deduced from the absence of the TCG / TCG2 protocols, as edk2's
  // MOR implementation depends on (one of) those protocols.
  //
-TcgStatus = gBS->LocateProtocol (
-   &gEfiTcg2ProtocolGuid,
-   NULL, // Registration
-   &TcgInterface
-   );
-if (EFI_ERROR (TcgStatus)) {
-  TcgStatus = gBS->LocateProtocol (
- &gEfiTcgProtocolGuid,
- NULL,   // Registration
- &TcgInterface
- );
-}
-
-if (!EFI_ERROR (TcgStatus)) {
+if (VariableHaveTcgProtocols ()) {
//
// The MOR variable originates from the platform firmware; set the MOR
// Control Lock variable to report the locking capability to the OS.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
index 938eb5de61fa..11822575ac4d 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
@@ -924,4 +924,54 @@ VariableExLibAtRuntime (
VOID
);
  
+/**

+  Notify the system that the SMM variable driver is ready
+**/
+VOID
+VariableNotifySmmReady (
+  VOID
+  );
+
+/**
+  Notify the system that the SMM variable write driver is ready
+**/
+VOID
+VariableNotifySmmWriteReady (
+  VOID
+  );
+
+/**
+  Variable service MM driver entry point
+**/
+EFI_STATUS
+EFIAPI
+MmVariableServiceInitialize (
+  VOID
+  );
+
+/**
+  This function check if the buffer is valid per processor architecture and 
not overlap with SMRAM.
+
+  @param Buffer  The buffer start address to be checked.
+  @param Length  The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and not 
overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlap 
with SMRAM.
+**/
+BOOLEAN
+VariableSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64Length
+  );
+
+/**
+  Whether the TCG or TCG2 protocols are installed in the UEFI protocol 
database.
+  This information is used by the MorLock code to infer whether an existing
+  MOR variable is legitimate or not.


Add a line for return description?


+**/
+BOOLEAN
+VariableHaveTcgProtocols (
+  VOID
+  );
+
  #endif
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
index 8c53f84ff6e8..7245587052df 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
@@ -15,6 +15,7 @@
SmmVariableGetStatistics() should also do validation based on its own 
knowledge.
  
  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.

+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD 
License
  which accompanies this distribution.  The full text of the license may be 
found at
@@ -28,18 +29,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.

Re: [edk2] [PATCH 5/6] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses

2019-01-09 Thread Zeng, Star

On 2019/1/10 10:33, Wang, Jian J wrote:

Laszlo,

Regards,
Jian


-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com]
Sent: Tuesday, January 08, 2019 11:38 PM
To: Ard Biesheuvel ; edk2-devel@lists.01.org
Cc: Leif Lindholm ; Kinney, Michael D
; Gao, Liming ; Wang,
Jian J ; Wu, Hao A ; Jagadeesh
Ujja ; Achin Gupta ;
Thomas Panakamattam Abraham ; Sami Mujawar

Subject: Re: [PATCH 5/6] MdeModulePkg/VariableRuntimeDxe: factor out boot
service accesses

On 01/03/19 19:28, Ard Biesheuvel wrote:

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

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c |  18

+---

  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h  |  50

+

  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c   |  59

--

  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf |   5 +-
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c |

114 

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


I *vaguely* feel like we should extract the new functions to
"PrivilegePolymorphic.h", rather than to "Variable.h".

Please see initial commit 00663d047fc9
("MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new
header", 2017-10-10), and other commits that touched that file.

I realize this is not a 100% "constructive" suggestion, and I feel
appropriately bad about that. It's just that "Variable.h" has so many
internals that I feel it's not a good dumping ground for these new
functions. And the other header we have, looks closer in purpose.

For example, MorLockInitAtEndOfDxe() is already declared in
"PrivilegePolymorphic.h" (see commit f1304280435f,
"MdeModulePkg/Variable/RuntimeDxe: introduce MorLockInitAtEndOfDxe()
hook", 2017-10-10).

Admittedly, now that we're going to have three separate builds of this
driver, dedicating a separate header file to each "shared between A and
B" relationship is getting a bit too complex. In retrospect, introducing
"PrivilegePolymorphic.h" may not have been a "scalable" idea, after all,
and I should have just dumped those functions all in "Variable.h".

IOW, I think
- targeting "Variable.h" now is inconsistent with earlier code,
- extending "PrivilegePolymorphic.h" is also suboptimal (although still
better than the previous option),
- adding yet another header might be technically correct, but it would
be over-engineering,
- asking you to merge "PrivilegePolymorphic.h" back into "Variable.h"
feels awkward, especially after I argued *for* "PrivilegePolymorphic.h"
at length, when I originally introduced it. :/

Sigh. Can the variable driver maintainers comment please?

(I still plan to regression-test this series, but I feel like I should
force myself to at least skim the variable driver patches, beyond
testing them. Because, next time I can't avoid working with this very
complex driver, I wouldn't like to be *completely* lost.)



I agree "PrivilegePolymorphic.h" is more appropriate place for them.
Maybe Star have different opinion.


At current situation, I prefer PrivilegePolymorphic.h. :)

Some minor feedback will be added in another reply.

Thanks,
Star




Thanks,
Laszlo


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


Re: [edk2] [PATCH 2/6] MdePkg: implement MmServicesTableLib based on traditional SMM

2019-01-09 Thread Zeng, Star

Hi Ard,

Another minor feedback.

On 2019/1/10 14:14, Zeng, Star wrote:

Hi Ard,

Some minor feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

The definitions of the rebranded MM protocol stack were chosen such
that the existing SMM based core drivers can be reused. So let's
implement MmServicesTableLib based on gEfiMmBaseProtocolGuid, which
is simply gEfiSmmBase2ProtocolGuid under the hood.


Good commit log.



Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c   | 63 

  MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf | 45 
++

  MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni | 22 +++
  MdePkg/MdePkg.dsc    |  1 +
  4 files changed, 131 insertions(+)

diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c 
b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c

new file mode 100644
index ..f41d25e59805
--- /dev/null
+++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
@@ -0,0 +1,63 @@
+/** @file
+  MM Services Table Library.
+
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of 
the BSD License
+  which accompanies this distribution.  The full text of the license 
may be found at

+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS 
OR IMPLIED.

+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+EFI_MM_SYSTEM_TABLE   *gMmst = NULL;
+
+/**
+  The constructor function caches the pointer of SMM Services Table.


Use "MM" instead of "SMM" here?

Thanks,
Star


+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+MmServicesTableLibConstructor (
+  IN EFI_HANDLE    ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_MM_BASE_PROTOCOL    *InternalMmBase;
+
+  InternalMmBase = NULL;
+  //
+  // Retrieve MM Base Protocol,  Do not use gBS from 
UefiBootServicesTableLib on purpose
+  // to prevent inclusion of gBS, gST, and gImageHandle from SMM 
Drivers unless the

+  // MM driver explicity declares that dependency.
+  //
+  Status = SystemTable->BootServices->LocateProtocol (
+    &gEfiMmBaseProtocolGuid,
+    NULL,
+    (VOID **)&InternalMmBase
+    );
+  ASSERT_EFI_ERROR (Status);
+  ASSERT (InternalMmBase != NULL);
+
+  //
+  // We are in MM, retrieve the pointer to MM System Table
+  //
+  InternalMmBase->GetMmstLocation (InternalMmBase, &gMmst);
+  ASSERT (gMmst != NULL);
+
+  return EFI_SUCCESS;
+}
diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf 
b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf

new file mode 100644
index ..4418cc2f1464
--- /dev/null
+++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
@@ -0,0 +1,45 @@
+## @file
+# MM Services Table Library.
+#
+# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of 
the BSD License
+#  which accompanies this distribution. The full text of the license 
may be found at

+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS 
OR IMPLIED.

+#
+#
+##
+
+[Defines]
+  INF_VERSION    = 0x0001001B
+  BASE_NAME  = MmServicesTableLib
+  MODULE_UNI_FILE    = MmServicesTableLib.uni
+  FILE_GUID  = 9508ECFD-66D1-4B4C-9415-F25F0FFF9E93
+  MODULE_TYPE    = DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = MmServicesTableLib|DXE_SMM_DRIVER
+  PI_SPECIFICATION_VERSION   = 0x00010032
+  CONSTRUCTOR    = MmServicesTableLibConstructor
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  MmServicesTableLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+
+[Protocols]
+  gEfiMmBaseProtocolGuid  ## CONSUMES
+
+[Depex]
+  gEfiMmBaseProtocolGuid
diff --git a/MdePkg/L

Re: [edk2] [PATCH 4/6] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version

2019-01-09 Thread Zeng, Star

Hi Ard,

Some minor feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c 
  | 70 +++
  
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 
| 90 
  2 files changed, 160 insertions(+)

diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
new file mode 100644
index ..b6fbf6c64f8a
--- /dev/null
+++ 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
@@ -0,0 +1,70 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD 
License
+which accompanies this distribution.  The full text of the license may be 
found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include 
+#include 
+#include "FaultTolerantWrite.h"
+#include "FaultTolerantWriteSmmCommon.h"
+
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64Length
+  )
+{
+  return TRUE;
+}


Please add function comment header for it, otherwise some coding style 
tool may report error.



+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (standalone SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer   A pointer to the buffer on which the 32-bit CRC is 
to be computed.
+  @param[in]  Length   The number of bytes in the buffer Data.
+
+  @retval Crc32The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID *Buffer,
+  IN  UINTNLength
+  )
+{
+  return CalculateCrc32 (Buffer, Length);
+}


Please add function comment header for it, otherwise some coding style 
tool may report error.



+
+VOID
+FtwNotifySmmReady (
+  VOID
+  )
+{
+}


Please add function comment header for it, otherwise some coding style 
tool may report error.


Thanks,
Star


+
+EFI_STATUS
+EFIAPI
+StandaloneMmFaultTolerantWriteInitialize (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}
diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
new file mode 100644
index ..99bd62ad5ceb
--- /dev/null
+++ 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
@@ -0,0 +1,90 @@
+ ## @file
+#   Fault Tolerant Write Smm Driver.
+#
+#   This driver installs SMM Fault Tolerant Write (FTW) protocol, which 
provides fault
+#   tolerant write capability in SMM environment for block devices. Its 
implementation
+#   depends on the full functionality SMM FVB protocol that support read, 
write/erase
+#   flash access.
+#
+# Copyright (c) 2010 - 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = FaultTolerantWriteStandaloneMm
+  FILE_GUID  = 3aade4ec-63cc-4a48-a928-5a374dd463eb
+  MODULE_TYPE= MM_STANDALONE
+  VERSION_STRING = 1.0
+  PI_SPECIFICATION_VERSION   = 0x00010032
+  ENTRY_POINT= StandaloneMmFaultTolerantWriteInitialize
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = AARCH64
+#
+
+[Sources]
+  FtwMisc.c
+  UpdateWorkingBlock.c
+  FaultTolerantWrite.c
+  FaultTolerantWriteStandaloneMm.c
+  FaultTolerantWriteSmm.

Re: [edk2] [PATCH 3/6] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses

2019-01-09 Thread Zeng, Star

Hi Ard,

Some minor feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

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

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  MdeModulePkg/MdeModulePkg.dsc 
 |  1 +
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h 
 | 22 -
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c  
 | 31 +++
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c  
 | 54 +--
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
 |  5 +-
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
 | 31 +++
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c   
 |  1 +
  
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c 
| 94 
  MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c 
 | 10 +--
  9 files changed, 205 insertions(+), 44 deletions(-)

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

MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf

SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
  
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h

index 844cf3bee04d..8d146264b129 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
@@ -31,7 +31,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
  #include 
  #include 
  #include 
-#include 
  #include 
  
  //

@@ -766,4 +765,25 @@ WriteWorkSpaceData (
IN UINT8  *Buffer
);
  
+/**

+  Internal implementation of CRC32. Depending on the execution context
+  (traditional SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer   A pointer to the buffer on which the 32-bit CRC is 
to be computed.
+  @param[in]  Length   The number of bytes in the buffer Data.
+
+  @retval Crc32The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID *Buffer,
+  IN  UINTNLength
+  );
+
  #endif
diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
index 094e40f9d86c..24e507104bbe 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
@@ -51,6 +51,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
  
  **/
  
+#include 

  #include "FaultTolerantWrite.h"
  EFI_EVENT mFvbRegistration = NULL;
  
@@ -250,3 +251,33 @@ FaultTolerantWriteInitialize (
  
return EFI_SUCCESS;

  }
+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (traditional SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer   A pointer to the buffer on which the 32-bit CRC is 
to be computed.
+  @param[in]  Length   The number of bytes in the buffer Data.
+
+  @retval Crc32The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID *Buffer,
+  IN  UINTNLength
+  )
+{
+  EFI_STATUSStatus;
+  UINT32ReturnValue;
+
+  Status = gBS->CalculateCrc32 (Buffer, Length, &ReturnValue);
+  ASSERT_EFI_ERROR (Status);
+
+  return ReturnValue;
+}
diff --git 
a/MdeModulePkg/Universal/FaultT

Re: [edk2] [PATCH 4/6] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version

2019-01-09 Thread Zeng, Star

On 2019/1/10 9:41, Wang, Jian J wrote:

Ard,


Regards,
Jian



-Original Message-
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
Sent: Friday, January 04, 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 4/6] MdeModulePkg/FaultTolerantWriteDxe: implement
standalone MM version

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

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

MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandalon
eMm.c   | 70 +++

MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandalon
eMm.inf | 90 
  2 files changed, 160 insertions(+)

diff --git
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandal
oneMm.c
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandal
oneMm.c
new file mode 100644
index ..b6fbf6c64f8a
--- /dev/null
+++
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandal
oneMm.c
@@ -0,0 +1,70 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD
License
+which accompanies this distribution.  The full text of the license may be found
at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
OR IMPLIED.
+
+**/
+
+#include 
+#include 
+#include "FaultTolerantWrite.h"
+#include "FaultTolerantWriteSmmCommon.h"
+
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64Length
+  )
+{
+  return TRUE;
+}
+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (standalone SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer   A pointer to the buffer on which the 32-bit CRC is 
to be
computed.
+  @param[in]  Length   The number of bytes in the buffer Data.
+
+  @retval Crc32The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID *Buffer,
+  IN  UINTNLength
+  )
+{
+  return CalculateCrc32 (Buffer, Length);
+}
+
+VOID
+FtwNotifySmmReady (
+  VOID
+  )
+{
+}
+
+EFI_STATUS
+EFIAPI
+StandaloneMmFaultTolerantWriteInitialize (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}
diff --git
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandal
oneMm.inf
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandal
oneMm.inf
new file mode 100644
index ..99bd62ad5ceb
--- /dev/null
+++
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandal
oneMm.inf
@@ -0,0 +1,90 @@
+ ## @file
+#   Fault Tolerant Write Smm Driver.
+#
+#   This driver installs SMM Fault Tolerant Write (FTW) protocol, which 
provides
fault
+#   tolerant write capability in SMM environment for block devices. Its
implementation
+#   depends on the full functionality SMM FVB protocol that support read,
write/erase
+#   flash access.
+#
+# Copyright (c) 2010 - 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = FaultTolerantWriteStandaloneMm
+  FILE_GUID  = 3aade4ec-63cc-4a48-a928-5a374dd463eb
+  MODULE_TYPE= MM_STANDALONE
+  VERSION_STRING = 1.0
+  PI_SPECIFICATION_VERSION   = 0x00010032
+  ENTRY_POINT= StandaloneMmFaultTolerantWriteInitialize
+
+#
+# The following information is for reference only and not required by the build
tools.
+#
+#  VALID_ARCHITECTURES   = AARCH64
+#
+
+[Sources]
+  FtwMisc.c
+  UpdateWorkingBlock.c
+  

Re: [edk2] [PATCH 2/6] MdePkg: implement MmServicesTableLib based on traditional SMM

2019-01-09 Thread Zeng, Star

Hi Ard,

Some minor feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

The definitions of the rebranded MM protocol stack were chosen such
that the existing SMM based core drivers can be reused. So let's
implement MmServicesTableLib based on gEfiMmBaseProtocolGuid, which
is simply gEfiSmmBase2ProtocolGuid under the hood.


Good commit log.



Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
  MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c   | 63 

  MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf | 45 ++
  MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni | 22 +++
  MdePkg/MdePkg.dsc|  1 +
  4 files changed, 131 insertions(+)

diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c 
b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
new file mode 100644
index ..f41d25e59805
--- /dev/null
+++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
@@ -0,0 +1,63 @@
+/** @file
+  MM Services Table Library.
+
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+EFI_MM_SYSTEM_TABLE   *gMmst = NULL;
+
+/**
+  The constructor function caches the pointer of SMM Services Table.
+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+MmServicesTableLibConstructor (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_MM_BASE_PROTOCOL*InternalMmBase;
+
+  InternalMmBase = NULL;
+  //
+  // Retrieve MM Base Protocol,  Do not use gBS from UefiBootServicesTableLib 
on purpose
+  // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers 
unless the
+  // MM driver explicity declares that dependency.
+  //
+  Status = SystemTable->BootServices->LocateProtocol (
+&gEfiMmBaseProtocolGuid,
+NULL,
+(VOID **)&InternalMmBase
+);
+  ASSERT_EFI_ERROR (Status);
+  ASSERT (InternalMmBase != NULL);
+
+  //
+  // We are in MM, retrieve the pointer to MM System Table
+  //
+  InternalMmBase->GetMmstLocation (InternalMmBase, &gMmst);
+  ASSERT (gMmst != NULL);
+
+  return EFI_SUCCESS;
+}
diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf 
b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
new file mode 100644
index ..4418cc2f1464
--- /dev/null
+++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
@@ -0,0 +1,45 @@
+## @file
+# MM Services Table Library.
+#
+# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution. The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001B
+  BASE_NAME  = MmServicesTableLib
+  MODULE_UNI_FILE= MmServicesTableLib.uni
+  FILE_GUID  = 9508ECFD-66D1-4B4C-9415-F25F0FFF9E93
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = MmServicesTableLib|DXE_SMM_DRIVER
+  PI_SPECIFICATION_VERSION   = 0x00010032
+  CONSTRUCTOR= MmServicesTableLibConstructor
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  MmServicesTableLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+
+[Protocols]
+  gEfiMmBaseProtocolGuid  ## CONSUMES
+
+[Depex]
+  gEfiMmBaseProtocolGuid
diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni 
b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni
new file mode 100644
index ..2b2c7e14024c
--- /dev/null
+++ b/MdePkg/Library/MmServicesTa

Re: [edk2] [PATCH 1/6] MdePkg/Include: add MmServicesTableLib header file

2019-01-09 Thread Zeng, Star

Hi Ard,

Some feedback added inline.

On 2019/1/4 2:28, Ard Biesheuvel wrote:

From: Jagadeesh Ujja 

SMM has been rebranded as MM, and can be implemented in traditional
mode or standalone mode, using the same prototype for the services
table. Expose this table via MmServicesTableLib, permitting the
respective implementations to expose a traditional or standalone
version.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jagadeesh Ujja 
Signed-off-by: Ard Biesheuvel 
---
  MdePkg/Include/Library/MmServicesTableLib.h | 25 
  MdePkg/MdePkg.dec   |  4 
  2 files changed, 29 insertions(+)

diff --git a/MdePkg/Include/Library/MmServicesTableLib.h 
b/MdePkg/Include/Library/MmServicesTableLib.h
new file mode 100644
index ..12bd01e98641
--- /dev/null
+++ b/MdePkg/Include/Library/MmServicesTableLib.h
@@ -0,0 +1,25 @@
+/** @file
+  Provides a service to retrieve a pointer to the Standalone MM Services Table.
+  Only available to Standalone MM module types.


This line should be "Only available to MM_STANDALONE, SMM/DXE Combined 
and SMM module types." to match the comments added in MdePkg.dec for 
this library class, right?


With it handled, Reviewed-by: Star Zeng 

Thanks,
Star

+
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD 
License
+which accompanies this distribution.  The full text of the license may be 
found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __MM_SERVICES_TABLE_LIB_H__
+#define __MM_SERVICES_TABLE_LIB_H__
+
+#include 
+
+extern EFI_MM_SYSTEM_TABLE *gMmst;
+
+#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 712bd46dd3d3..a7383b6daafb 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -243,6 +243,10 @@ [LibraryClasses]
##
SafeIntLib|Include/Library/SafeIntLib.h
  
+  ## @libraryclass Provides a service to retrieve a pointer to the Standalone MM Services Table.

+  #Only available to MM_STANDALONE, SMM/DXE Combined and SMM 
module types.
+  MmServicesTableLib|Include/Library/MmServicesTableLib.h
+
  [LibraryClasses.IA32, LibraryClasses.X64]
##  @libraryclass  Abstracts both S/W SMI generation and detection.
##



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


Re: [edk2] [Patch v1 1/1] MdeModulePkg: fix comments in BaseSortLib

2019-01-08 Thread Zeng, Star
How about updating "2018" to "2019"? :)


With that, Reviewed-by: Star Zeng .

Thanks,
Star
-Original Message-
From: Carsey, Jaben 
Sent: Wednesday, January 9, 2019 5:58 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Wang, Jian J 
Subject: [Patch v1 1/1] MdeModulePkg: fix comments in BaseSortLib

The comments are incorrect for the base version of this lib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
Cc: Star Zeng 
Cc: Jian J Wang 
---
 MdeModulePkg/Library/BaseSortLib/BaseSortLib.c | 22 
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c 
b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c
index ab8a60585ee2..8f30c00971eb 100644
--- a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c
+++ b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c
@@ -1,7 +1,7 @@
 /** @file
   Library used for sorting routines.
 
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. 
+  Copyright (c) 2009 - 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 @@ -193,14 +193,12 @@ DevicePathCompare (  }
 
 /**
-  Function to compare 2 strings without regard to case of the characters.
+  Not supported in Base version.
 
-  @param[in] Buffer1Pointer to String to compare.
-  @param[in] Buffer2Pointer to second String to compare.
+  @param[in] Buffer1  Ignored.
+  @param[in] Buffer2  Ignored.
 
-  @retval 0 Buffer1 equal to Buffer2.
-  @return < 0   Buffer1 is less than Buffer2.
-  @return > 0   Buffer1 is greater than Buffer2.
+  ASSERT and return 0.
 **/
 INTN
 EFIAPI
@@ -215,14 +213,12 @@ StringNoCaseCompare (
 
 
 /**
-  Function to compare 2 strings.
+  Not supported in Base version.
 
-  @param[in] Buffer1Pointer to String to compare (CHAR16**).
-  @param[in] Buffer2Pointer to second String to compare (CHAR16**).
+  @param[in] Buffer1  Ignored.
+  @param[in] Buffer2  Ignored.
 
-  @retval 0 Buffer1 equal to Buffer2.
-  @return < 0   Buffer1 is less than Buffer2.
-  @return > 0   Buffer1 is greater than Buffer2.
+  ASSERT and return 0.
 **/
 INTN
 EFIAPI
--
2.16.2.windows.1

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


Re: [edk2] [patch] MdeModulePkg/NonDiscoverable: Use compare operator for comparison

2019-01-01 Thread Zeng, Star
  if (Attributes) {
  if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) {
return EFI_UNSUPPORTED;
  }
}

If ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) is TRUE, the Attributes 
must be not 0.
So " if (Attributes " could be removed.

BTW: This code block has indentation problem.


With them handled, Reviewed-by: Star Zeng 


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Dandan Bi
Sent: Friday, December 28, 2018 4:54 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A 
Subject: [edk2] [patch] MdeModulePkg/NonDiscoverable: Use compare operator for 
comparison

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

According to EDK II C Coding Standards Specification, Non-Boolean comparisons 
must use a compare operator.
This patch is to update the code to follow EDKII coding style.

Cc: Jian J Wang 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
index f0d3472ea5..a0fe3b9ffa 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
+++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePc
+++ iDeviceIo.c
@@ -1274,11 +1274,11 @@ PciIoAttributes (
   #define DEV_SUPPORTED_ATTRIBUTES \
 (EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE)
 
   Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
 
-  if (Attributes) {
+  if (Attributes != 0) {
   if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) {
 return EFI_UNSUPPORTED;
   }
 }
 
--
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 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement

2018-12-18 Thread Zeng, Star
Yi, Zailiang and David,

So, is it ok to give RB to the patch from you? :)


Thanks,
Star
-Original Message-
From: Qian, Yi 
Sent: Wednesday, December 19, 2018 9:21 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Sun, Zailiang ; Wei, David 
Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' 
statement

It's fine. Thank you for your update.

Thanks
Qian Yi

-Original Message-----
From: Zeng, Star 
Sent: Tuesday, December 18, 2018 7:01 PM
To: Qian, Yi ; edk2-devel@lists.01.org
Cc: Sun, Zailiang ; Wei, David ; 
Zeng, Star 
Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' 
statement

Yi,

Good question.

With the patch, the code can be compiled and the image can boot to setup.
The image could not find shell, but that is not related to the patch.
It is because 
https://github.com/tianocore/edk2/commit/2840bb51040bb79c1ad53b1eb1cbb86e5edf80ca#diff-0318cca23f8f1c46d1076b3a5891fadd
 updated the platform dsc and fdf to use 2.0 shell source build (with 2.0 shell 
file GUID), but the code at 
https://github.com/tianocore/edk2/blob/master/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c#L1365
 is still using PcdShellFile (which matches to EDK shell) to find shell file.


Thanks,
Star
-Original Message-
From: Qian, Yi 
Sent: Tuesday, December 18, 2018 10:08 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Sun, Zailiang 
Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' 
statement

Hi Star,
   This patch is good to me. Only one thing I need to know is whether you have 
done the unit test, at least, compilation, and boot into shell. 

Thanks
Qian Yi

-Original Message-----
From: Zeng, Star 
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Sun, Zailiang ; 
Qian, Yi 
Subject: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement

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

The codes have been updated to not use PcdPeiCoreMaxFvSupported, 
PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their statement in 
platform DSC could be removed.

Cc: Zailiang Sun 
Cc: Yi Qian 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 --
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 2 --
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 2 --
 3 files changed, 6 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index f8ad29df5986..d43611550285 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
   gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x40
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x1
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
   gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
   gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
 !if $(S4_ENABLE) == TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index ca3b2ff90287..a33816c4d18b 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
   gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x40
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x1
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
   gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
   gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
 !if $(S4_ENABLE) == TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 81f36bd73b28..b50731f25ffb 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
   gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x40
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x1
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
   gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
   gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000

Re: [edk2] [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement

2018-12-18 Thread Zeng, Star
Yi,

Good question.

With the patch, the code can be compiled and the image can boot to setup.
The image could not find shell, but that is not related to the patch.
It is because 
https://github.com/tianocore/edk2/commit/2840bb51040bb79c1ad53b1eb1cbb86e5edf80ca#diff-0318cca23f8f1c46d1076b3a5891fadd
 updated the platform dsc and fdf to use 2.0 shell source build (with 2.0 shell 
file GUID), but the code at 
https://github.com/tianocore/edk2/blob/master/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c#L1365
 is still using PcdShellFile (which matches to EDK shell) to find shell file.


Thanks,
Star
-Original Message-
From: Qian, Yi 
Sent: Tuesday, December 18, 2018 10:08 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Sun, Zailiang 
Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' 
statement

Hi Star,
   This patch is good to me. Only one thing I need to know is whether you have 
done the unit test, at least, compilation, and boot into shell. 

Thanks
Qian Yi

-Original Message-
From: Zeng, Star 
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Sun, Zailiang ; 
Qian, Yi 
Subject: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement

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

The codes have been updated to not use PcdPeiCoreMaxFvSupported, 
PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their statement in 
platform DSC could be removed.

Cc: Zailiang Sun 
Cc: Yi Qian 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 --
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 2 --
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 2 --
 3 files changed, 6 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index f8ad29df5986..d43611550285 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
   gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x40
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x1
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
   gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
   gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
 !if $(S4_ENABLE) == TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index ca3b2ff90287..a33816c4d18b 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
   gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x40
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x1
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
   gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
   gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
 !if $(S4_ENABLE) == TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 81f36bd73b28..b50731f25ffb 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
   gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x40
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x1
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
   gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
   gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
 !if $(S4_ENABLE) == TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
--
2.7.0.windows.1

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


Re: [edk2] [edk2-platforms PATCH 2/2] PurleyOpenBoardPkg: Remove PcdPeiCoreMaxXXX PCDs' statement

2018-12-18 Thread Zeng, Star
Could you help take a review to the patch? :)

Thanks,
Star
-Original Message-
From: Zeng, Star 
Sent: Friday, December 14, 2018 6:43 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Lu, Shifei A ; 
Zhou, Bowen ; Oram, Isaac W 
Subject: [edk2-platforms PATCH 2/2] PurleyOpenBoardPkg: Remove PcdPeiCoreMaxXXX 
PCDs' statement

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

The codes have been updated to not use PcdPeiCoreMaxFvSupported, 
PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their statement in 
platform DSC could be removed.

Cc: Shifei A Lu 
Cc: Xiaohu Zhou 
Cc: Isaac W Oram 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/PlatformPkgPcd.dsc | 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/PlatformPkgPcd.dsc 
b/Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/PlatformPkgPcd.dsc
index bfe32aba1c5c..bfdf5c0c3874 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/PlatformPkgPcd.dsc
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/PlatformPkgPcd.ds
+++ c
@@ -91,8 +91,6 @@ [PcdsFixedAtBuild.common]
   gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x0
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1
   gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize|0x10
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|32
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x170
 
   gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x40
--
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 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported

2018-12-17 Thread Zeng, Star
Jian,

Good observation. 
I did consider it. But they are handling different structures.


Thanks,
Star
-Original Message-
From: Wang, Jian J 
Sent: Tuesday, December 18, 2018 10:24 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Wu, Hao A ; Gao, Liming ; Ni, 
Ruiyu ; Kinney, Michael D ; 
Desimone, Nathaniel L ; Chiu, Chasel 

Subject: RE: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of 
PcdPeiCoreMaxPpiSupported

Star,

Please consider to extract the code to expand PPI buffer as a function or macro.
I found it repeated 3 times in this patch.

Regards,
Jian


> -Original Message-
> From: Zeng, Star
> Sent: Friday, December 14, 2018 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J 
> ; Wu, Hao A ; Gao, Liming 
> ; Ni, Ruiyu ; Kinney, 
> Michael D ; Desimone, Nathaniel L 
> ; Chiu, Chasel 
> Subject: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of 
> PcdPeiCoreMaxPpiSupported
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
> 
> Background as below.
> 
> Problem:
> As static configuration from the PCDs, the binary PeiCore (for example 
> in FSP binary with dispatch mode) could not predict how many FVs, 
> Files or PPIs for different platforms.
> 
> Burden:
> Platform developers need configure the PCDs accordingly for different 
> platforms.
> 
> To solve the problem and remove the burden, we can update code to 
> remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv 
> and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV, 
> File and PPI management.
> 
> This patch removes the using of PcdPeiCoreMaxPpiSupported in PeiCore.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Liming Gao 
> Cc: Ruiyu Ni 
> Cc: Michael D Kinney 
> Cc: Nate DeSimone 
> Cc: Chasel Chiu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c |   8 +-
>  MdeModulePkg/Core/Pei/PeiMain.h   |  59 +++--
>  MdeModulePkg/Core/Pei/PeiMain.inf |   1 -
>  MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  30 ++-
>  MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 355 
> ++
>  5 files changed, 254 insertions(+), 199 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index 71440bab9488..55a300adbdb8 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -1062,7 +1062,7 @@ PeiDispatcher (
>// Process the Notify list and dispatch any notifies for
>// newly installed PPIs.
>//
> -  ProcessNotifyList (Private);
> +  ProcessDispatchNotifyList (Private);
>  }
>}
>  }
> @@ -1209,10 +1209,10 @@ PeiDispatcher (
>  // Process the Notify list and dispatch any notifies for
>  // newly installed PPIs.
>  //
> -ProcessNotifyList (Private);
> +ProcessDispatchNotifyList (Private);
> 
>  //
> -// Recheck SwitchStackSignal after ProcessNotifyList()
> +// Recheck SwitchStackSignal after 
> + ProcessDispatchNotifyList()
>  // in case PeiInstallPeiMemory() is done in a callback with
>  // EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH.
>  //
> @@ -1253,7 +1253,7 @@ PeiDispatcher (
>// Process the Notify list and dispatch any notifies for
>// newly installed PPIs.
>//
> -  ProcessNotifyList (Private);
> +  ProcessDispatchNotifyList (Private);
>  }
>}
>  }
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.h 
> b/MdeModulePkg/Core/Pei/PeiMain.h index b248118087ad..c6c932c3e233 
> 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.h
> +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> @@ -66,37 +66,60 @@ typedef union {
>  } PEI_PPI_LIST_POINTERS;
> 
>  ///
> -/// PPI database structure which contains two link: PpiList and 
> NotifyList. PpiList -/// is in head of PpiListPtrs array and notify is in end 
> of PpiListPtrs.
> +/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out 
> +of
> room
>  ///
> +#define PPI_GROWTH_STEP 64
> +#define CALLBACK_NOTIFY_GROWTH_STEP 32 #define 
> +DISPATCH_NOTIFY_GROWTH_STEP 8
> +
>  typedef struct {
> +  UINTN CurrentCount;
> +  UINTN MaxCount;
> +  UINTN LastDispatchedCount;
>///
> -  /// index of end of PpiList link list.
> +  /// MaxCount number of entries.
>///
> -  INTN  

Re: [edk2] [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv

2018-12-17 Thread Zeng, Star
Good suggestion. It will make the buffer extension log consistent.
I will send V2 to cover it with some test.

Thanks,
Star
-Original Message-
From: Wang, Jian J 
Sent: Tuesday, December 18, 2018 10:04 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Wu, Hao A ; Gao, Liming ; Ni, 
Ruiyu ; Kinney, Michael D ; 
Desimone, Nathaniel L ; Chiu, Chasel 

Subject: RE: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of 
PcdPeiCoreMaxPeimPerFv

Star,

Just one place which might need refine. Please see it below.

Regards,
Jian


> -Original Message-
> From: Zeng, Star
> Sent: Friday, December 14, 2018 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J 
> ; Wu, Hao A ; Gao, Liming 
> ; Ni, Ruiyu ; Kinney, 
> Michael D ; Desimone, Nathaniel L 
> ; Chiu, Chasel 
> Subject: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of 
> PcdPeiCoreMaxPeimPerFv
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
> 
> Background as below.
> 
> Problem:
> As static configuration from the PCDs, the binary PeiCore (for example 
> in FSP binary with dispatch mode) could not predict how many FVs, 
> Files or PPIs for different platforms.
> 
> Burden:
> Platform developers need configure the PCDs accordingly for different 
> platforms.
> 
> To solve the problem and remove the burden, we can update code to 
> remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv 
> and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV, 
> File and PPI management.
> 
> This patch removes the using of PcdPeiCoreMaxPeimPerFv in PeiCore.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Liming Gao 
> Cc: Ruiyu Ni 
> Cc: Michael D Kinney 
> Cc: Nate DeSimone 
> Cc: Chasel Chiu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 199 
> 
> --
>  MdeModulePkg/Core/Pei/PeiMain.h   |  17 ++-
>  MdeModulePkg/Core/Pei/PeiMain.inf |   1 -
>  MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  48 +++
>  4 files changed, 157 insertions(+), 108 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index f6bb35a5fe8d..71440bab9488 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -41,7 +41,8 @@ DiscoverPeimsAndOrderWithApriori (
>UINTN   PeimCount;
>EFI_GUID*Guid;
>EFI_PEI_FILE_HANDLE *TempFileHandles;
> -  EFI_GUID*FileGuid;
> +  EFI_GUID*TempFileGuid;
> +  UINTN   TempPeimCount;
>EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
>EFI_FV_FILE_INFOFileInfo;
> 
> @@ -51,38 +52,106 @@ DiscoverPeimsAndOrderWithApriori (
>// Walk the FV and find all the PEIMs and the Apriori file.
>//
>AprioriFileHandle = NULL;
> -  Private->CurrentFvFileHandles[0] = NULL;
> +  Private->CurrentFvFileHandles = NULL;
>Guid = NULL;
> -  FileHandle = NULL;
> -  TempFileHandles = Private->FileHandles;
> -  FileGuid= Private->FileGuid;
> 
>//
> -  // If the current Fv has been scanned, directly get its cachable record.
> +  // If the current Fv has been scanned, directly get its cached records.
>//
> -  if (Private->Fv[Private->CurrentPeimFvCount].ScanFv) {
> -CopyMem (Private->CurrentFvFileHandles, Private->Fv[Private-
> >CurrentPeimFvCount].FvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * 
> >PcdGet32
> (PcdPeiCoreMaxPeimPerFv));
> +  if (CoreFileHandle->ScanFv) {
> +Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
>  return;
>}
> 
> +  if (Private->TempPeimCount == 0) {
> +//
> +// Initialize the temp buffers.
> +//
> +Private->TempPeimCount = 32;
> +Private->TempFileHandles = AllocatePool (sizeof 
> + (EFI_PEI_FILE_HANDLE) *
> 32);
> +ASSERT (Private->TempFileHandles != NULL);
> +Private->TempFileGuid= AllocatePool (sizeof (EFI_GUID) * 32);
> +ASSERT (Private->TempFileGuid != NULL);  }  TempFileHandles = 
> + Private->TempFileHandles;
> +  TempFileGuid= Private->TempFileGuid;
> +
>//
> -  // Go ahead to scan this Fv, and cache FileHandles within it.
> +  // Go ahead to scan this Fv, get PeimCount and cache FileHandles 
> + within it to
> TempFileHandles.
>//
> -  Status = EFI_NOT_FOUND;
> -  for (PeimCount = 0; PeimCount <= PcdGet32 (PcdPeiCoreMaxPei

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

2018-12-10 Thread Zeng, Star

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


Re: [edk2] [PATCH v2] Maintainers.txt: Change package maintainer of IntelFsp*Pkg

2018-12-04 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Chiu, Chasel 
Sent: Wednesday, December 5, 2018 8:49 AM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen ; Desimone, Nathaniel L 
; Zeng, Star ; Chiu, 
Chasel 
Subject: [PATCH v2] Maintainers.txt: Change package maintainer of IntelFsp*Pkg

Cc: Jiewen Yao 
Cc: Desimone Nathaniel L 
Cc: Zeng Star 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 Maintainers.txt | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/Maintainers.txt b/Maintainers.txt index 9a36f0232b..63edf01d56 
100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -147,21 +147,27 @@ M: Liming Gao 
 
 IntelFsp2Pkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2Pkg
-M: Jiewen Yao 
 M: Chasel Chiu 
+R: Nate DeSimone 
+R: Star Zeng 
 
 IntelFsp2WrapperPkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2WrapperPkg
-M: Jiewen Yao 
 M: Chasel Chiu 
+R: Nate DeSimone 
+R: Star Zeng 
 
 IntelFspPkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFspPkg
-M: Jiewen Yao 
+M: Chasel Chiu 
+R: Nate DeSimone 
+R: Star Zeng 
 
 IntelFspWrapperPkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFspWrapperPkg
-M: Jiewen Yao 
+M: Chasel Chiu 
+R: Nate DeSimone 
+R: Star Zeng 
 
 IntelSiliconPkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelSiliconPkg
--
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] MdeModulePkg: Correct PCD name in MdeModulePkg.uni

2018-11-28 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Gao, Liming 
Sent: Thursday, November 29, 2018 9:18 AM
To: edk2-devel@lists.01.org
Cc: Bi, Dandan ; Zeng, Star 
Subject: [Patch] MdeModulePkg: Correct PCD name in MdeModulePkg.uni

https://bugzilla.tianocore.org/show_bug.cgi?id=1363
New PCD PcdVpdBaseAddress64 is added in MdeModulePkg.dec.
Its string token in MdeModulePkg.uni should match to its name.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Bi Dandan 
Cc: Star Zeng 
---
 MdeModulePkg/MdeModulePkg.uni | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni 
index 9b1766b36a..c754d7bb15 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -1261,9 +1261,9 @@

   "On TRUE, the string FPDT record will be used to store 
every performance entry.\n"

   "On FALSE, the different FPDT record will be used to 
store the different performance entries."
 
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdVpdBaseAddress_PROMPT  #language 
en-US "64bit VPD base address"
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdVpdBaseAddress64_PROMPT  
#language en-US "64bit VPD base address"
 
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdVpdBaseAddress_HELP  #language 
en-US "VPD type PCD allows a developer to point to an absolute physical address 
PcdVpdBaseAddress64"
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdVpdBaseAddress64_HELP  #language 
en-US "VPD type PCD allows a developer to point to an absolute physical address 
PcdVpdBaseAddress64"

"to store PCD value. It will be DynamicExDefault only."

"It is used to set VPD region base address. So, it can't be DynamicExVpd 
PCD. Its value is"

"required to be accessed in PcdDxe driver entry point. So, its value must 
be set in PEI phase."
--
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] Edk2: Update FmpDevicePkg Maintainers

2018-11-27 Thread Zeng, Star
Philippe,

Good suggestion. :)
Let me send the patch.


Thanks,
Star
-Original Message-
From: Philippe Mathieu-Daudé [mailto:phi...@redhat.com] 
Sent: Tuesday, November 27, 2018 11:17 PM
To: Gao, Liming ; edk2-devel@lists.01.org
Cc: Zeng, Star 
Subject: Re: [edk2] [Patch] Edk2: Update FmpDevicePkg Maintainers

Hi,

On 27/11/18 15:59, Liming Gao wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Liming Gao 
> Cc: Star Zeng 

The usual workflow to hand over is the previous maintainer send the patch, and 
you Ack-by it.
Exceptions are acceptable but require an explanation in the commit message.

Regards,

Phil.

> ---
>  Maintainers.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Maintainers.txt b/Maintainers.txt index 
> 9a36f0232b..91a4657adc 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -133,7 +133,7 @@ T: git - 
> https://github.com/tianocore/edk2-FatPkg.git
>  
>  FmpDevicePkg
>  W: https://github.com/tianocore/tianocore.github.io/wiki/FmpDevicePkg
> -M: Star Zeng 
> +M: Liming Gao 
>  M: Michael D Kinney 
>  
>  IntelFrameworkModulePkg
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] Maintainers.txt: Update maintainer & reviewer info for MdeModulePkg

2018-11-26 Thread Zeng, Star
Reviewed-by: Star Zeng 

Hao and Jian, thanks to spend effort as the maintainer.


Star
-Original Message-
From: Wu, Hao A 
Sent: Tuesday, November 27, 2018 8:37 AM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Zeng, Star ; Wang, 
Jian J 
Subject: [PATCH] Maintainers.txt: Update maintainer & reviewer info for 
MdeModulePkg

Update Star as the reviewer of MdeModulePkg; Add Hao Wu as the 2nd maintainer 
of MdeModulePkg.

Cc: Star Zeng 
Cc: Jian J Wang 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 Maintainers.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Maintainers.txt b/Maintainers.txt index f3ead7c504..39a2bf261e 
100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -170,13 +170,14 @@ M: Rangasai V Chaganty 
 
 MdeModulePkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/MdeModulePkg
-M: Star Zeng 
 M: Jian J Wang 
+M: Hao Wu 
 M: NetworkPkg maintainers
   (Universal/Network and related libraries, header files)
 R: Ruiyu Ni 
   (especially for Bus, Universal/Console, Universal/Disk,
Universal/BdsDxe and related libraries, header files)
+R: Star Zeng 
 
 MdePkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/MdePkg
--
2.12.0.windows.1

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


Re: [edk2] [PATCH] MdeModulePkg/LockboxNullLib: clean up INF file.

2018-11-25 Thread Zeng, Star
Forgot to push this patch.

Just pushed it at ed3951ebbd20e1e29b093c753cf051e7e4b2bfae.

Thanks,
Star
-Original Message-
From: Zeng, Star 
Sent: Wednesday, January 17, 2018 12:38 PM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen ; Zeng, Star 
Subject: [PATCH] MdeModulePkg/LockboxNullLib: clean up INF file.

From: Jiewen Yao 

Remove unused module type restriction for NULL instance.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao 
Reviewed-by: Star Zeng 
---
 MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf 
b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
index 1018a69e8144..5994c68124ef 100644
--- a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
+++ b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  NULL LockBox library instance.
 #
-#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+#  Copyright (c) 2010 - 2018, Intel Corporation. All rights 
+reserved.
 #
 #  This program and the accompanying materials  #  are licensed and made 
available under the terms and conditions @@ -21,7 +21,7 @@ [Defines]
   FILE_GUID  = 0BA38EBD-E190-4df7-8EC4-0A6E2B43772D
   MODULE_TYPE= BASE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = LockBoxLib|PEIM DXE_DRIVER 
DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION DXE_SMM_DRIVER
+  LIBRARY_CLASS  = LockBoxLib
 
 
 #
--
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] MdeModulePkg PCD: Add DynamicEx PcdVpdBaseAddress64 for non SPI platform

2018-11-25 Thread Zeng, Star

On 2018/11/22 22:32, Liming Gao wrote:

https://bugzilla.tianocore.org/show_bug.cgi?id=1356
Current PcdVpdBaseAddress is 32bit static Pcd. NON SPI platform needs to
configure it as Dynamic PCD. Emulator platform (such as NT32) may set its
value to 64bit address.
To meet with this usage, 64bit DynamicEx PcdVpdBaseAddress64 is introduced.
If its value is not zero, it will be used.
If its value is zero, static PcdVpdBaseAddress will be used.
When NON SPI platform enables VPD PCD, they need to set PcdVpdBaseAddress64.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Dandan Bi 


Two minor comments at below, with them handled, Reviewed-by: Star Zeng 





---
  MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 16 
  MdeModulePkg/Universal/PCD/Dxe/Service.c |  3 ++-
  MdeModulePkg/Universal/PCD/Pei/Service.c | 15 ++-
  MdeModulePkg/MdeModulePkg.dec|  8 
  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf   |  3 ++-
  MdeModulePkg/Universal/PCD/Dxe/Service.h |  2 ++
  MdeModulePkg/Universal/PCD/Pei/Pcd.inf   |  3 ++-
  7 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c 
b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
index f977c7f18e..4e38a3844a 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
@@ -109,6 +109,7 @@ EFI_GET_PCD_INFO_PROTOCOL  mEfiGetPcdInfoInstance = {
  };
  
  EFI_HANDLE mPcdHandle = NULL;

+UINTN  mVpdBaseAddress = 0;
  
  /**

Main entry for PCD DXE driver.
@@ -175,6 +176,21 @@ PcdDxeInit (
  &Registration
  );
  
+  //

+  // Cache VpdBaseAddress in entry point for the following usage.
+  //
+
+  //
+  // PcdVpdBaseAddress64 is DynamicEx PCD only. So, DxePcdGet64Ex() is used to 
get its value.
+  //
+  mVpdBaseAddress = (UINTN) DxePcdGet64Ex (&gEfiMdeModulePkgTokenSpaceGuid, 
PcdToken (PcdVpdBaseAddress64));
+  if (mVpdBaseAddress == 0) {
+//
+// PcdVpdBaseAddress64 is not set, get value from PcdVpdBaseAddress.
+//
+mVpdBaseAddress = (UINTN) PcdGet32 (PcdVpdBaseAddress);
+  }
+
return Status;
  }
  
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c

index 0517152366..4b44153e13 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Service.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c
@@ -435,7 +435,8 @@ GetWorker (
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
  case PCD_TYPE_VPD:
VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
-  RetPtr = (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + 
VpdHead->Offset);
+  ASSERT (mVpdBaseAddress != 0);
+  RetPtr = (VOID *) (mVpdBaseAddress + VpdHead->Offset);
  
break;
  
diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c b/MdeModulePkg/Universal/PCD/Pei/Service.c

index bb4b52baf3..e1613e8af8 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Service.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Service.c
@@ -861,6 +861,7 @@ GetWorker (
UINT32  LocalTokenNumber;
UINT32  LocalTokenCount;
UINT8   *VaraiableDefaultBuffer;
+  UINTN   VpdBaseAddress;
  
//

// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
@@ -889,7 +890,19 @@ GetWorker (
  {
VPD_HEAD *VpdHead;
VpdHead = (VPD_HEAD *) ((UINT8 *)PeiPcdDb + Offset);
-  return (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);
+
+  //
+  // PcdVpdBaseAddress64 is DynamicEx PCD only. So, PeiPcdGet64Ex() is 
used to get its value.
+  //
+  VpdBaseAddress = (UINTN) PeiPcdGet64Ex (&gEfiMdeModulePkgTokenSpaceGuid, 
PcdToken (PcdVpdBaseAddress64));
+  if (VpdBaseAddress == 0) {
+//
+// PcdVpdBaseAddress64 is not set, get value from PcdVpdBaseAddress.
+//
+VpdBaseAddress = (UINTN) PcdGet32 (PcdVpdBaseAddress);
+  }
+  ASSERT (VpdBaseAddress != 0);
+  return (VOID *)(VpdBaseAddress + VpdHead->Offset);
  }
  
  case PCD_TYPE_HII|PCD_TYPE_STRING:

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 0abacc1a90..f46a4094ca 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -2022,5 +2022,13 @@
# @Prompt NV Storage Default Value Buffer

gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer|{0x0}|VOID*|0x00030005
  
+  ## VPD type PCD allows a developer to point to an absolute physical address PcdVpdBaseAddress


1. PcdVpdBaseAddress should be PcdVpdBaseAddress64, right?


+  #  to store PCD value. It will be DynamicExDefault only.
+  #  It is used to set VPD region base address. So, it can't be DynamicExVpd 
PCD. Its value is
+  #  required to be accessed in PcdDxe driver entry point. So, its value must 
be set in PEI phase.
+  #  It can't depend on EFI variable service, and can't be DynamicExHii PCD.
+  # @Prompt 64bit VPD base address.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseA

Re: [edk2] [PATCH v2] MdeModulePkg/Variable: add debug logs in VariableServiceSetVariable

2018-11-22 Thread Zeng, Star
Pushed at a90c7df7edeec375edee99bc9b116406543b9959.

Thanks,
Star
-Original Message-
From: Zeng, Star 
Sent: Thursday, November 22, 2018 8:57 AM
To: Vijayenthiran Subramaniam ; 
edk2-devel@lists.01.org; Wang, Jian J ; Ni, Ruiyu 

Cc: Zeng, Star 
Subject: RE: [PATCH v2] MdeModulePkg/Variable: add debug logs in 
VariableServiceSetVariable

Reviewed-by: Star Zeng 

-Original Message-
From: Vijayenthiran Subramaniam [mailto:vijayenthiran.subraman...@arm.com] 
Sent: Wednesday, November 21, 2018 11:29 PM
To: edk2-devel@lists.01.org; Zeng, Star ; Wang, Jian J 
; Ni, Ruiyu 
Cc: Vijayenthiran Subramaniam 
Subject: [PATCH v2] MdeModulePkg/Variable: add debug logs in 
VariableServiceSetVariable

Print debug messages if size of the VariableName plus DataSize exceeds 
Max(Auth|Voltaile)VariableSize bytes. The messages will be useful if any 
platform specific value of Max(Auth|Voltaile)VariableSize PCDs have to be 
changed.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vijayenthiran Subramaniam 
---
Thanks for the review. I have made changes based on Laszlo's and Star's 
suggestions.

- Vijayenthiran

 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 30 
 1 file changed, 30 insertions(+)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 8e8db71bd201..d100b1dcc552 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -3234,14 +3234,44 @@ VariableServiceSetVariable (
 //
 if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) {
   if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxAuthVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR,
+  "%a: Failed to set variable '%s' with Guid %g\n",
+  __FUNCTION__, VariableName, VendorGuid));
+DEBUG ((DEBUG_ERROR,
+  "NameSize(0x%x) + PayloadSize(0x%x) > "
+  "MaxAuthVariableSize(0x%x) - HeaderSize(0x%x)\n",
+  StrSize (VariableName), PayloadSize,
+  mVariableModuleGlobal->MaxAuthVariableSize,
+  GetVariableHeaderSize ()
+  ));
 return EFI_INVALID_PARAMETER;
   }
 } else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {
   if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR,
+  "%a: Failed to set variable '%s' with Guid %g\n",
+  __FUNCTION__, VariableName, VendorGuid));
+DEBUG ((DEBUG_ERROR,
+  "NameSize(0x%x) + PayloadSize(0x%x) > "
+  "MaxVariableSize(0x%x) - HeaderSize(0x%x)\n",
+  StrSize (VariableName), PayloadSize,
+  mVariableModuleGlobal->MaxVariableSize,
+  GetVariableHeaderSize ()
+  ));
 return EFI_INVALID_PARAMETER;
   }
 } else {
   if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxVolatileVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR,
+  "%a: Failed to set variable '%s' with Guid %g\n",
+  __FUNCTION__, VariableName, VendorGuid));
+DEBUG ((DEBUG_ERROR,
+  "NameSize(0x%x) + PayloadSize(0x%x) > "
+  "MaxVolatileVariableSize(0x%x) - HeaderSize(0x%x)\n",
+  StrSize (VariableName), PayloadSize,
+  mVariableModuleGlobal->MaxVolatileVariableSize,
+  GetVariableHeaderSize ()
+  ));
 return EFI_INVALID_PARAMETER;
   }
 }
--
2.17.1

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


Re: [edk2] [PATCH v2 0/2] Fix constant if statement issue

2018-11-22 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chasel, 
Chiu
Sent: Thursday, November 22, 2018 11:51 AM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Yao, Jiewen 
Subject: [edk2] [PATCH v2 0/2] Fix constant if statement issue

Internal code quality scanning found 2 constant if statements related to 
FixedPcdGet8 () usage.
Since the PCD can be PatchableInModule too, it should be changed to PcdGet8 () 
to fix this issue.
Also fixed the line ending format issue from previous patch.

Patch1 fixed line ending format issue on some files
Patch2 fixed constant if statement issue.

Cc: Jiewen Yao 
Cc: Desimone Nathaniel L 
Cc: Wu Hao A 

Chasel, Chiu (2):
  IntelFsp2WrapperPkg: Fix line ending format issue
  IntelFsp2WrapperPkg: Fix constant if statements issue

 IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c   | 32 

 IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c   | 24 

 IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf |  4 ++--  
IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf |  4 ++--
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec | 22 
+++---
 5 files changed, 43 insertions(+), 43 deletions(-)

--
2.13.3.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 v2] MdeModulePkg/Variable: add debug logs in VariableServiceSetVariable

2018-11-21 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Vijayenthiran Subramaniam [mailto:vijayenthiran.subraman...@arm.com] 
Sent: Wednesday, November 21, 2018 11:29 PM
To: edk2-devel@lists.01.org; Zeng, Star ; Wang, Jian J 
; Ni, Ruiyu 
Cc: Vijayenthiran Subramaniam 
Subject: [PATCH v2] MdeModulePkg/Variable: add debug logs in 
VariableServiceSetVariable

Print debug messages if size of the VariableName plus DataSize exceeds 
Max(Auth|Voltaile)VariableSize bytes. The messages will be useful if any 
platform specific value of Max(Auth|Voltaile)VariableSize PCDs have to be 
changed.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vijayenthiran Subramaniam 
---
Thanks for the review. I have made changes based on Laszlo's and Star's 
suggestions.

- Vijayenthiran

 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 30 
 1 file changed, 30 insertions(+)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 8e8db71bd201..d100b1dcc552 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -3234,14 +3234,44 @@ VariableServiceSetVariable (
 //
 if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) {
   if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxAuthVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR,
+  "%a: Failed to set variable '%s' with Guid %g\n",
+  __FUNCTION__, VariableName, VendorGuid));
+DEBUG ((DEBUG_ERROR,
+  "NameSize(0x%x) + PayloadSize(0x%x) > "
+  "MaxAuthVariableSize(0x%x) - HeaderSize(0x%x)\n",
+  StrSize (VariableName), PayloadSize,
+  mVariableModuleGlobal->MaxAuthVariableSize,
+  GetVariableHeaderSize ()
+  ));
 return EFI_INVALID_PARAMETER;
   }
 } else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {
   if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR,
+  "%a: Failed to set variable '%s' with Guid %g\n",
+  __FUNCTION__, VariableName, VendorGuid));
+DEBUG ((DEBUG_ERROR,
+  "NameSize(0x%x) + PayloadSize(0x%x) > "
+  "MaxVariableSize(0x%x) - HeaderSize(0x%x)\n",
+  StrSize (VariableName), PayloadSize,
+  mVariableModuleGlobal->MaxVariableSize,
+  GetVariableHeaderSize ()
+  ));
 return EFI_INVALID_PARAMETER;
   }
 } else {
   if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxVolatileVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR,
+  "%a: Failed to set variable '%s' with Guid %g\n",
+  __FUNCTION__, VariableName, VendorGuid));
+DEBUG ((DEBUG_ERROR,
+  "NameSize(0x%x) + PayloadSize(0x%x) > "
+  "MaxVolatileVariableSize(0x%x) - HeaderSize(0x%x)\n",
+  StrSize (VariableName), PayloadSize,
+  mVariableModuleGlobal->MaxVolatileVariableSize,
+  GetVariableHeaderSize ()
+  ));
 return EFI_INVALID_PARAMETER;
   }
 }
--
2.17.1

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


Re: [edk2] [PATCH 1/1] MdePkg ACPI: fix the typos in Acpi61.h and Acpi62.h

2018-11-20 Thread Zeng, Star

On 2018/11/20 22:37, Gao, Liming wrote:

Reviewed-by: Liming Gao 


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
Ersek
Sent: Tuesday, November 20, 2018 4:52 PM
To: Gary Lin ; edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Gao, Liming 

Subject: Re: [edk2] [PATCH 1/1] MdePkg ACPI: fix the typos in Acpi61.h and 
Acpi62.h

On 11/20/18 08:03, Gary Lin wrote:

The GUID for VIRTUAL_CD_REGION_PERSISTENT was using the closing
square bracket mistakenly.

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Gary Lin 
---
  MdePkg/Include/IndustryStandard/Acpi61.h | 2 +-
  MdePkg/Include/IndustryStandard/Acpi62.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)


Good catch!

Reviewed-by: Laszlo Ersek 


Reviewed-by: Star Zeng 

Thanks,
Star



Thanks
Laszlo


diff --git a/MdePkg/Include/IndustryStandard/Acpi61.h 
b/MdePkg/Include/IndustryStandard/Acpi61.h
index b2276b7d64d5..c66566e58647 100644
--- a/MdePkg/Include/IndustryStandard/Acpi61.h
+++ b/MdePkg/Include/IndustryStandard/Acpi61.h
@@ -1400,7 +1400,7 @@ typedef struct {
  #define 
EFI_ACPI_6_1_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_DISK_REGION_VOLATILE   { 
0x77AB535A, 0x45FC, 0x624B,

{ 0x55, 0x60, 0xF7, 0xB2, 0x81, 0xD1, 0xF9, 0x6E }}

  #define EFI_ACPI_6_1_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_CD_REGION_VOLATILE 
{ 0x3D5ABD30, 0x4175, 0x87CE,

{ 0x6D, 0x64, 0xD2, 0xAD, 0xE5, 0x23, 0xC4, 0xBB }}

  #define 
EFI_ACPI_6_1_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_DISK_REGION_PERSISTENT { 
0x5CEA02C9, 0x4D07, 0x69D3,

{ 0x26, 0x9F ,0x44, 0x96, 0xFB, 0xE0, 0x96, 0xF9 }}

-#define 
EFI_ACPI_6_1_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_CD_REGION_PERSISTENT   { 
0x08018188, 0x42CD, 0xBB48,

{ 0x10, 0x0F, 0x53, 0x87, 0xD5, 0x3D, 0xED, 0x3D ]}

+#define 
EFI_ACPI_6_1_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_CD_REGION_PERSISTENT   { 
0x08018188, 0x42CD, 0xBB48,

{ 0x10, 0x0F, 0x53, 0x87, 0xD5, 0x3D, 0xED, 0x3D }}

  typedef struct {
UINT16  Type;
UINT16  Length;
diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h 
b/MdePkg/Include/IndustryStandard/Acpi62.h
index 730365b521d1..11ce1c16fb91 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -1512,7 +1512,7 @@ typedef struct {
  #define 
EFI_ACPI_6_2_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_DISK_REGION_VOLATILE   { 
0x77AB535A, 0x45FC, 0x624B,

{ 0x55, 0x60, 0xF7, 0xB2, 0x81, 0xD1, 0xF9, 0x6E }}

  #define EFI_ACPI_6_2_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_CD_REGION_VOLATILE 
{ 0x3D5ABD30, 0x4175, 0x87CE,

{ 0x6D, 0x64, 0xD2, 0xAD, 0xE5, 0x23, 0xC4, 0xBB }}

  #define 
EFI_ACPI_6_2_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_DISK_REGION_PERSISTENT { 
0x5CEA02C9, 0x4D07, 0x69D3,

{ 0x26, 0x9F ,0x44, 0x96, 0xFB, 0xE0, 0x96, 0xF9 }}

-#define 
EFI_ACPI_6_2_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_CD_REGION_PERSISTENT   { 
0x08018188, 0x42CD, 0xBB48,

{ 0x10, 0x0F, 0x53, 0x87, 0xD5, 0x3D, 0xED, 0x3D ]}

+#define 
EFI_ACPI_6_2_NFIT_GUID_RAM_DISK_SUPPORTING_VIRTUAL_CD_REGION_PERSISTENT   { 
0x08018188, 0x42CD, 0xBB48,

{ 0x10, 0x0F, 0x53, 0x87, 0xD5, 0x3D, 0xED, 0x3D }}

  typedef struct {
UINT16  Type;
UINT16  Length;



___
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] MdeModulePkg/Variable: add debug logs in VariableServiceSetVariable

2018-11-20 Thread Zeng, Star

On 2018/11/20 19:17, Laszlo Ersek wrote:

On 11/20/18 11:38, Vijayenthiran Subramaniam wrote:

Print debug messages if size of the VariableName plus DataSize exceeds
Max(Auth|Voltaile)VariableSize bytes. The messages will be useful if any
platform specific value of Max(Auth|Voltaile)VariableSize PCDs have to
be changed.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vijayenthiran Subramaniam 
---
  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 8e8db71bd201..db54fa4412c0 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -3234,14 +3234,20 @@ VariableServiceSetVariable (
  //
  if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) {
if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxAuthVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR, "%a: Size of (%s) variable + DataSize exceeds 
MaxAuthVariableSize.\n",
+  __FUNCTION__, VariableName));
  return EFI_INVALID_PARAMETER;
}
  } else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {
if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR, "%a: Size of (%s) variable + DataSize exceeds 
MaxVariableSize.\n",
+  __FUNCTION__, VariableName));
  return EFI_INVALID_PARAMETER;
}
  } else {
if (StrSize (VariableName) + PayloadSize > 
mVariableModuleGlobal->MaxVolatileVariableSize - GetVariableHeaderSize ()) {
+DEBUG ((DEBUG_ERROR, "%a: Size of (%s) variable + DataSize exceeds 
MaxVolatileVariableSize.\n",
+  __FUNCTION__, VariableName));
  return EFI_INVALID_PARAMETER;
}
  }



You could make this more useful as well -- again, *if* the package
maintainers agree with the new log messages --; namely, the vendor GUID,
DataSize, and the limit in question should / could all be logged.


I agree to add these debug messages. I also think Laszlo's suggestion is 
good.


So, how about having the debug message like below?

DEBUG ((
  DEBUG_ERROR,
  "%a: %s:%g\n",
  __FUNCTION__,
  VariableName,
  VendorGuid
  ));
DEBUG ((
  DEBUG_ERROR,
  "  NameSize(0x%x) + PayloadSize(0x%x) > 
MaxAuthVariableSize(0x%x) - HeaderSize(0x%x)\n",

  StrSize (VariableName),
  PayloadSize,
  mVariableModuleGlobal->MaxAuthVariableSize,
  GetVariableHeaderSize ()
  ));

Thanks,
Star



Thanks
Laszlo



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


Re: [edk2] [PATCH 1/1] Platform/ARM/SgiPkg: increase max variable size to 8KB

2018-11-20 Thread Zeng, Star

On 2018/11/20 21:15, Leif Lindholm wrote:

On Tue, Nov 20, 2018 at 04:01:02PM +0530, Vijayenthiran Subramaniam wrote:

Commit dc37ca75 ("Edk2Platforms: Replace MdeModulePkg PXE/iSCSI/TCP with
NetworkPkg drivers") switched to using iSCSI driver from the NetworkPkg
package. This driver requires the platform to support a maximum variable
size of atleast 4KB.

So increase the maximum supported variable size to 8KB on the SGI
platforms. Without this, the iSCSI driver fails to load.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vijayenthiran Subramaniam 


Looks good to me, but I'd like an R-b from Thomas/Nariman.

On a separate note, MdeModulePkg maintainers - is this reason enough
to change the default of this Pcd?


Yes, the PCD is for platform to customize based on usage, so reasonable.

Thanks,
Star



/
 Leif


---
  Platform/ARM/SgiPkg/SgiPlatform.dsc | 1 +
  1 file changed, 1 insertion(+)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc 
b/Platform/ARM/SgiPkg/SgiPlatform.dsc
index 3f0ca9872e79..1c152fad2246 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -102,6 +102,7 @@
  
  [PcdsFixedAtBuild.common]

gArmTokenSpaceGuid.PcdVFPEnabled|1
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
  
# DRAM Block2 Base and Size

gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0x808000
--
2.17.1



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


Re: [edk2] [PATCH] IntelFsp2WrapperPkg: Revert 90c5bc08

2018-11-19 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Chiu, Chasel 
Sent: Tuesday, November 20, 2018 11:53 AM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen ; Zeng, Star ; Chiu, 
Chasel 
Subject: [PATCH] IntelFsp2WrapperPkg: Revert 90c5bc08

Commit message issue and reverted commit
90c5bc081d15d077606131a61114ddfdefe62e61.

Will re-submit with correct formats.

Cc: Jiewen Yao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c   | 20 

 IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c   | 14 ++
 IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf |  3 +--
 IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf |  3 +--
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec | 13 ++---
 5 files changed, 10 insertions(+), 43 deletions(-)

diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c 
b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
index fa0441ce6c..7b7c5f5d86 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register 
MemoryDiscoveredPpi
   notify to call FspSiliconInit API.
 
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2014 - 2017, 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
@@ -65,7 +65,7 @@ PeiFspMemoryInit (
   FspHobListPtr = NULL;
   FspmUpdDataPtr = NULL;
 
-  FspmHeaderPtr = (FSP_INFO_HEADER *) FspFindFspHeader (PcdGet32 
(PcdFspmBaseAddress));
+  FspmHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 
(PcdFspmBaseAddress));
   DEBUG ((DEBUG_INFO, "FspmHeaderPtr - 0x%x\n", FspmHeaderPtr));
   if (FspmHeaderPtr == NULL) {
 return EFI_DEVICE_ERROR;
@@ -155,20 +155,8 @@ FspmWrapperInit (
 {
   EFI_STATUS   Status;
 
-  Status = EFI_SUCCESS;
-
-  if (FixedPcdGet8 (PcdFspModeSelection) == 1) {
-Status = PeiFspMemoryInit ();
-ASSERT_EFI_ERROR (Status);
-  } else {
-PeiServicesInstallFvInfoPpi (
-  NULL,
-  (VOID *)(UINTN) PcdGet32 (PcdFspmBaseAddress),
-  (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFspmBaseAddress))->FvLength,
-  NULL,
-  NULL
-  );
-  }
+  Status = PeiFspMemoryInit ();
+  ASSERT_EFI_ERROR (Status);
 
   return Status;
 }
diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c 
b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
index 87dd61e5c5..70dac7a414 100644
--- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register 
MemoryDiscoveredPpi
   notify to call FspSiliconInit API.
 
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2014 - 2017, 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
@@ -349,17 +349,7 @@ FspsWrapperPeimEntryPoint (
 {
   DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));
 
-  if (FixedPcdGet8 (PcdFspModeSelection) == 1) {
-FspsWrapperInit ();
-  } else {
-PeiServicesInstallFvInfoPpi (
-  NULL,
-  (VOID *)(UINTN) PcdGet32 (PcdFspsBaseAddress),
-  (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFspsBaseAddress))->FvLength,
-  NULL,
-  NULL
-  );
-  }
+  FspsWrapperInit ();
 
   return EFI_SUCCESS;
 }
diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf 
b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
index b3776a80f3..542356b582 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
@@ -6,7 +6,7 @@
 # register TemporaryRamDonePpi to call TempRamExit API, and register 
MemoryDiscoveredPpi
 # notify to call FspSiliconInit API.
 #
-#  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2014 - 2017, 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
@@ -61,7 +61,6 @@
 [Pcd]
   gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress ## CONSUMES
   gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress  ## CONSUMES
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection## CONSUMES
 
 [Sources]
   FspmWrapperPeim.c
diff --git a/IntelFsp2WrapperPkg/FspsWrapperP

Re: [edk2] [PATCH v2] MdeModulePkg: Remove PcdIdentifyMappingPageTablePtr

2018-11-19 Thread Zeng, Star
Pushed at 316b3a719fd2ee97a01b0d941bba15ef06840d78.

Thanks,
Star
-Original Message-
From: Zeng, Star 
Sent: Monday, November 19, 2018 1:48 PM
To: Zhang, Shenglei ; edk2-devel@lists.01.org
Cc: Ni, Ruiyu ; Zeng, Star 
Subject: RE: [edk2] [PATCH v2] MdeModulePkg: Remove 
PcdIdentifyMappingPageTablePtr

Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Shenglei 
Zhang
Sent: Monday, November 19, 2018 12:39 PM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu ; Zeng, Star 
Subject: [edk2] [PATCH v2] MdeModulePkg: Remove PcdIdentifyMappingPageTablePtr

PcdIdentifyMappingPageTablePtr was used to share page table buffer between 
modules.
Buf after some changes on 2015/07/17, it was useless and could be removed.
https://bugzilla.tianocore.org/show_bug.cgi?id=1304

v2:
1.Remove PcdIdentifyMappingPageTablePtr in MdeModulePkg.uni.
2.Update the commit message.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shenglei 
---
 MdeModulePkg/MdeModulePkg.dec | 6 --  MdeModulePkg/MdeModulePkg.uni | 4 

 2 files changed, 10 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec 
index 428eeeb670..0abacc1a90 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -2007,12 +2007,6 @@
   # @ValidList  0x8001 | 0x0
   
gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr|0x0|UINT64|0x00030001
 
-  ## This dynamic PCD hold an address to point to the memory of page table. 
The page table establishes a 1:1
-  #  Virtual to Physical mapping according to the processor physical address 
bits.
-  # @Prompt Identify Mapping Page Table pointer.
-  # @ValidList  0x8001 | 0x0
-  
gEfiMdeModulePkgTokenSpaceGuid.PcdIdentifyMappingPageTablePtr|0x0|UINT64|0x00030002
-
   ## This dynamic PCD holds the information if there is any test key used by 
the platform.
   # @Prompt If there is any test key used by the platform.
   gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed|FALSE|BOOLEAN|0x00030003
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni 
index 5fa7a6ae30..038e848505 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -914,10 +914,6 @@

   "this PCD to be TURE if and only if all runtime driver has seperated 
Code/Data\n"

   "section. If PE code/data sections are merged, the result is 
unpredictable.\n"
 
-#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdIdentifyMappingPageTablePtr_PROMPT  
#language en-US "Identify Mapping Page Table pointer."
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdIdentifyMappingPageTablePtr_HELP 
 #language en-US "This dynamic PCD hold an address to point to the memory of 
page table. The page table establishes a 1:1\n"
-   
 "Virtual to Physical mapping according to the processor 
physical address bits."
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdShadowPeimOnBoot_HELP  #language 
en-US "Indicates if to shadow PEIM and PeiCore after memory is ready.\n"

  "This PCD is used on other boot path except for S3 boot.\n"

  "TRUE  - Shadow PEIM and PeiCore after memory is ready.\n"
--
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 v2] MdeModulePkg: Remove PcdIdentifyMappingPageTablePtr

2018-11-18 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Shenglei 
Zhang
Sent: Monday, November 19, 2018 12:39 PM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu ; Zeng, Star 
Subject: [edk2] [PATCH v2] MdeModulePkg: Remove PcdIdentifyMappingPageTablePtr

PcdIdentifyMappingPageTablePtr was used to share page table buffer between 
modules.
Buf after some changes on 2015/07/17, it was useless and could be removed.
https://bugzilla.tianocore.org/show_bug.cgi?id=1304

v2:
1.Remove PcdIdentifyMappingPageTablePtr in MdeModulePkg.uni.
2.Update the commit message.

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shenglei 
---
 MdeModulePkg/MdeModulePkg.dec | 6 --  MdeModulePkg/MdeModulePkg.uni | 4 

 2 files changed, 10 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec 
index 428eeeb670..0abacc1a90 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -2007,12 +2007,6 @@
   # @ValidList  0x8001 | 0x0
   
gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr|0x0|UINT64|0x00030001
 
-  ## This dynamic PCD hold an address to point to the memory of page table. 
The page table establishes a 1:1
-  #  Virtual to Physical mapping according to the processor physical address 
bits.
-  # @Prompt Identify Mapping Page Table pointer.
-  # @ValidList  0x8001 | 0x0
-  
gEfiMdeModulePkgTokenSpaceGuid.PcdIdentifyMappingPageTablePtr|0x0|UINT64|0x00030002
-
   ## This dynamic PCD holds the information if there is any test key used by 
the platform.
   # @Prompt If there is any test key used by the platform.
   gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed|FALSE|BOOLEAN|0x00030003
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni 
index 5fa7a6ae30..038e848505 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -914,10 +914,6 @@

   "this PCD to be TURE if and only if all runtime driver has seperated 
Code/Data\n"

   "section. If PE code/data sections are merged, the result is 
unpredictable.\n"
 
-#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdIdentifyMappingPageTablePtr_PROMPT  
#language en-US "Identify Mapping Page Table pointer."
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdIdentifyMappingPageTablePtr_HELP 
 #language en-US "This dynamic PCD hold an address to point to the memory of 
page table. The page table establishes a 1:1\n"
-   
 "Virtual to Physical mapping according to the processor 
physical address bits."
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdShadowPeimOnBoot_HELP  #language 
en-US "Indicates if to shadow PEIM and PeiCore after memory is ready.\n"

  "This PCD is used on other boot path except for S3 boot.\n"

  "TRUE  - Shadow PEIM and PeiCore after memory is ready.\n"
--
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 v2 1/2] MdeModulePkg/SmmCorePerfLib: [CVE-2017-5753] Fix bounds check bypass

2018-11-15 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Hao Wu
Sent: Friday, November 16, 2018 12:13 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Laszlo Ersek ; Yao, 
Jiewen ; Zeng, Star 
Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/SmmCorePerfLib: [CVE-2017-5753] Fix 
bounds check bypass

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

Speculative execution is used by processor to avoid having to wait for data to 
arrive from memory, or for previous operations to finish, the processor may 
speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions might 
leave hints such as which memory locations have been brought into cache. 
Malicious actors can use the bounds check bypass method (code gadgets with 
controlled external inputs) to infer data values that have been used in 
speculative operations to reveal secrets which should not otherwise be accessed.

This commit will focus on the SMI handler(s) registered within the 
SmmCorePerformanceLib and insert AsmLfence API to mitigate the bounds check 
bypass issue.

For SMI handler SmmPerformanceHandlerEx():

Under "case SMM_PERF_FUNCTION_GET_GAUGE_DATA :", 'SmmPerfCommData->LogEntryKey' 
can be a potential cross boundary access of the 'CommBuffer' (controlled 
external inputs) during speculative execution. This cross boundary access is 
then assign to parameter 'LogEntryKey'. And the value of 'LogEntryKey' can be 
inferred by code:

  CopyMem (
(UINT8 *) &GaugeDataEx[Index],
(UINT8 *) &GaugeEntryExArray[LogEntryKey++],
sizeof (GAUGE_DATA_ENTRY_EX)
);

One can observe which part of the content within 'GaugeEntryExArray' was 
brought into cache to possibly reveal the value of 'LogEntryKey'.

Hence, this commit adds a AsmLfence() after the boundary/range checks of 
'CommBuffer' to prevent the speculative execution.

And there is 1 similar case for SMI handler SmmPerformanceHandler() as well. 
This commit also handles it.

A more detailed explanation of the purpose of commit is under the 'Bounds check 
bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Cc: Star Zeng 
Cc: Jiewen Yao 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 16 
+++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c 
b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
index cd1f1a5d5f..63c1eea3a2 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
@@ -16,7 +16,7 @@
 
  SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted 
input and do basic validation.
 
-Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 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 @@ -538,6 +538,13 
@@ SmmPerformanceHandlerEx (
  break;
}
 
+   //
+   // The AsmLfence() call here is to ensure the previous range/content
+   // checks for the CommBuffer have been completed before calling
+   // CopyMem().
+   //
+   AsmLfence ();
+
GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
 
for (Index = 0; Index < NumberOfEntries; Index++) { @@ -650,6 +657,13 
@@ SmmPerformanceHandler (
  break;
}
 
+   //
+   // The AsmLfence() call here is to ensure the previous range/content
+   // checks for the CommBuffer have been completed before calling
+   // CopyMem().
+   //
+   AsmLfence ();
+
GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
 
for (Index = 0; Index < NumberOfEntries; Index++) {
--
2.12.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 v1 1/2] MdeModulePkg/SmmCorePerfLib: [CVE-2017-5753] Fix bounds check bypass

2018-11-15 Thread Zeng, Star

On 2018/11/16 9:37, Hao Wu wrote:

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

Speculative execution is used by processor to avoid having to wait for
data to arrive from memory, or for previous operations to finish, the
processor may speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions
might leave hints such as which memory locations have been brought into
cache. Malicious actors can use the bounds check bypass method (code
gadgets with controlled external inputs) to infer data values that have
been used in speculative operations to reveal secrets which should not
otherwise be accessed.

This commit will focus on the SMI handler(s) registered within the
TBD.


What does the 'TBD' mean here?

Thanks,
Star



Hence, this commit adds a AsmLfence() after the boundary/range checks of
'CommBuffer' to prevent the speculative execution.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Cc: Star Zeng 
Cc: Jiewen Yao 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
  MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 16 
+++-
  1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c 
b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
index cd1f1a5d5f..63c1eea3a2 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
@@ -16,7 +16,7 @@
  
   SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation.
  
-Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.

+Copyright (c) 2011 - 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
@@ -538,6 +538,13 @@ SmmPerformanceHandlerEx (
   break;
 }
  
+   //

+   // The AsmLfence() call here is to ensure the previous range/content
+   // checks for the CommBuffer have been completed before calling
+   // CopyMem().
+   //
+   AsmLfence ();
+
 GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
  
 for (Index = 0; Index < NumberOfEntries; Index++) {

@@ -650,6 +657,13 @@ SmmPerformanceHandler (
   break;
 }
  
+   //

+   // The AsmLfence() call here is to ensure the previous range/content
+   // checks for the CommBuffer have been completed before calling
+   // CopyMem().
+   //
+   AsmLfence ();
+
 GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
  
 for (Index = 0; Index < NumberOfEntries; Index++) {




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


Re: [edk2] [PATCH] MdeModulePkg: Remove PcdIdentifyMappingPageTablePtr

2018-11-15 Thread Zeng, Star
Hi Shenglei,

I would suggest including more description in BZ1304 into the commit message.
And please also remove the strings for PcdIdentifyMappingPageTablePtr in 
MdeModulePkg.uni.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Shenglei 
Zhang
Sent: Thursday, November 15, 2018 3:46 PM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu ; Zeng, Star 
Subject: [edk2] [PATCH] MdeModulePkg: Remove PcdIdentifyMappingPageTablePtr

PcdIdentifyMappingPageTablePtr is useless and could be removed.
https://bugzilla.tianocore.org/show_bug.cgi?id=1304

Cc: Star Zeng 
Cc: Jian J Wang 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shenglei 
---
 MdeModulePkg/MdeModulePkg.dec | 6 --
 1 file changed, 6 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec 
index 428eeeb670..0abacc1a90 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -2007,12 +2007,6 @@
   # @ValidList  0x8001 | 0x0
   
gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr|0x0|UINT64|0x00030001
 
-  ## This dynamic PCD hold an address to point to the memory of page table. 
The page table establishes a 1:1
-  #  Virtual to Physical mapping according to the processor physical address 
bits.
-  # @Prompt Identify Mapping Page Table pointer.
-  # @ValidList  0x8001 | 0x0
-  
gEfiMdeModulePkgTokenSpaceGuid.PcdIdentifyMappingPageTablePtr|0x0|UINT64|0x00030002
-
   ## This dynamic PCD holds the information if there is any test key used by 
the platform.
   # @Prompt If there is any test key used by the platform.
   gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed|FALSE|BOOLEAN|0x00030003
--
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


  1   2   3   4   5   6   7   8   9   10   >