Re: [edk2] [PATCH 6/6] NetworkPkg: Refine UintnToAscDecWithFormat functions logic

2016-12-14 Thread Wu, Jiaxin
Reviewed-by: Wu Jiaxin 


> -Original Message-
> From: Wu, Hao A
> Sent: Wednesday, December 14, 2016 7:27 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Fu, Siyuan ; Ye,
> Ting ; Wu, Jiaxin 
> Subject: [PATCH 6/6] NetworkPkg: Refine UintnToAscDecWithFormat
> functions logic
> 
> This commit refines the logic for HttpBootUintnToAscDecWithFormat and
> PxeBcUintnToAscDecWithFormat. It avoids using the decrement operator '--'
> for array index to prevent possible mis-reports by static code checkers.
> 
> Cc: Fu Siyuan 
> Cc: Ye Ting 
> Cc: Wu Jiaxin 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu 
> ---
>  NetworkPkg/HttpBootDxe/HttpBootSupport.c | 5 ++---
>  NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c   | 5 ++---
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
> b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
> index 9410bf9..bdb29ae 100644
> --- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
> +++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
> @@ -86,11 +86,10 @@ HttpBootUintnToAscDecWithFormat (  {
>UINTN  Remainder;
> 
> -  while (Length > 0) {
> -Length--;
> +  for (; Length > 0; Length--) {
>  Remainder  = Number % 10;
>  Number/= 10;
> -Buffer[Length] = (UINT8) ('0' + Remainder);
> +Buffer[Length - 1] = (UINT8) ('0' + Remainder);
>}
>  }
> 
> diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> index 00c652d..568360d 100644
> --- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> @@ -1383,11 +1383,10 @@ PxeBcUintnToAscDecWithFormat (  {
>UINTN  Remainder;
> 
> -  while (Length > 0) {
> -Length--;
> +  for (; Length > 0; Length--) {
>  Remainder  = Number % 10;
>  Number/= 10;
> -Buffer[Length] = (UINT8) ('0' + Remainder);
> +Buffer[Length - 1] = (UINT8) ('0' + Remainder);
>}
>  }
> 
> --
> 1.9.5.msysgit.0

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


Re: [edk2] [PATCH 5/6] MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic

2016-12-14 Thread Wu, Jiaxin
Reviewed-by: Wu Jiaxin 


> -Original Message-
> From: Wu, Hao A
> Sent: Wednesday, December 14, 2016 7:27 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Fu, Siyuan ; Ye,
> Ting ; Wu, Jiaxin 
> Subject: [PATCH 5/6] MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum
> function logic
> 
> This commit refines the logic for the CvtNum function. It avoids using the
> decrement operator '--' for array index to prevent possible mis-reports by
> static code checkers.
> 
> Cc: Fu Siyuan 
> Cc: Ye Ting 
> Cc: Wu Jiaxin 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c | 5 ++--
> -
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
> index 0865ddd..0779056 100644
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
> +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
> @@ -132,11 +132,10 @@ CvtNum (
>  {
>UINTN Remainder;
> 
> -  while (Length > 0) {
> +  for (; Length > 0; Length--) {
>  Remainder = Number % 10;
>  Number /= 10;
> -Length--;
> -Buffer[Length] = (UINT8) ('0' + Remainder);
> +Buffer[Length - 1] = (UINT8) ('0' + Remainder);
>}
>  }
> 
> --
> 1.9.5.msysgit.0

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


Re: [edk2] [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic

2016-12-14 Thread Wu, Jiaxin
Reviewed-by: Wu Jiaxin 


> -Original Message-
> From: Wu, Hao A
> Sent: Wednesday, December 14, 2016 7:27 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Fu, Siyuan ; Ye,
> Ting ; Wu, Jiaxin 
> Subject: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite
> NetblockChecksum function logic
> 
> This commit rewrites the logic for NetblockChecksum. It processes the
> checksum of the left-over byte first to prevent possible mis-reports by static
> code checkers.
> 
> Cc: Fu Siyuan 
> Cc: Ye Ting 
> Cc: Wu Jiaxin 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> index bbbdbc0..95cb717 100644
> --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> @@ -1,7 +1,7 @@
>  /** @file
>Network library functions providing net buffer operation support.
> 
> -Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 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
> @@ -1661,6 +1661,13 @@ NetblockChecksum (
> 
>Sum = 0;
> 
> +  //
> +  // Add left-over byte, if any
> +  //
> +  if (Len % 2 != 0) {
> +Sum += *(Bulk + Len - 1);
> +  }
> +
>while (Len > 1) {
>  Sum += *(UINT16 *) Bulk;
>  Bulk += 2;
> @@ -1668,13 +1675,6 @@ NetblockChecksum (
>}
> 
>//
> -  // Add left-over byte, if any
> -  //
> -  if (Len > 0) {
> -Sum += *(UINT8 *) Bulk;
> -  }
> -
> -  //
>// Fold 32-bit sum to 16 bits
>//
>while ((Sum >> 16) != 0) {
> --
> 1.9.5.msysgit.0

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


Re: [edk2] ArmLib : GIC Pcds in "ArmPkg/Library/ArmLib/ArmBaseLib.inf"

2016-12-14 Thread Meenakshi Aggarwal
Hi Ard,


Thanks for your reply.


Apologies for this mail before finding out which patch has introduced this 
change.

These Pcds were added by us only for GIC initialization, not available in 
linaro edk2.


Sorry for shooting this mail.


Thanks a lot for your reply.


Regards,
Meenakshi

-Original Message-
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org] 
Sent: Thursday, December 15, 2016 1:16 PM
To: Meenakshi Aggarwal 
Cc: edk2-devel@lists.01.org ; Leif Lindholm 

Subject: Re: ArmLib : GIC Pcds in "ArmPkg/Library/ArmLib/ArmBaseLib.inf"

On 15 December 2016 at 04:46, Meenakshi Aggarwal  
wrote:
> Hi,
>
>
> I need to modify GicDistributorBase and GicInterruptInterfaceBase Pcds on run 
> time, so I need these to be dynamic.
> But on doing same I am facing errors, because these Pcds are included under 
> [FixedPcd] section in ArmBaseLib.inf and I am using ArmLib.
>
>
> [FixedPcd]
>   gArmTokenSpaceGuid.PcdGicDistributorBase
>   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
>
>
> Is there any particular reason behind including these Pcds in ArmBaseLib.inf, 
> as ArmLib is not using these Pcds anywhere.
>
> I removed these Pcds from ArmBaseLib.inf and I didn't face any issue, neither 
> in compilation nor in execution.
>
>
> Please tell me the relevance of including these Pcds in ArmBaseLib.inf.
>

If they are not used in ArmLib, they should be dropped from the .INF

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


Re: [edk2] ArmLib : GIC Pcds in "ArmPkg/Library/ArmLib/ArmBaseLib.inf"

2016-12-14 Thread Ard Biesheuvel
On 15 December 2016 at 04:46, Meenakshi Aggarwal
 wrote:
> Hi,
>
>
> I need to modify GicDistributorBase and GicInterruptInterfaceBase Pcds on run 
> time, so I need these to be dynamic.
> But on doing same I am facing errors, because these Pcds are included under 
> [FixedPcd] section in ArmBaseLib.inf and I am using ArmLib.
>
>
> [FixedPcd]
>   gArmTokenSpaceGuid.PcdGicDistributorBase
>   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
>
>
> Is there any particular reason behind including these Pcds in ArmBaseLib.inf, 
> as ArmLib is not using these Pcds anywhere.
>
> I removed these Pcds from ArmBaseLib.inf and I didn't face any issue, neither 
> in compilation nor in execution.
>
>
> Please tell me the relevance of including these Pcds in ArmBaseLib.inf.
>

If they are not used in ArmLib, they should be dropped from the .INF

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


Re: [edk2] [patch 1/2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Add comments for functions

2016-12-14 Thread Ard Biesheuvel
Hello Dandan,

Thank you for doing this work. I am happy for these changes to go in.

However, I have a patch pending to implement non-coherent DMA support,
and Ray has not responded to that yet. These changes will likely
conflict with that patch, so could we please get the functionality
completed first before working on enhancements like this?

Ray?

Thanks,
Ard.


On 15 December 2016 at 07:11, Dandan Bi  wrote:
> Cc: Ard Biesheuvel 
> Cc: Ruiyu Ni 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi 
> ---
>  .../NonDiscoverablePciDeviceDxe/ComponentName.c|  47 
>  .../NonDiscoverablePciDeviceDxe.c  |  50 +++-
>  .../NonDiscoverablePciDeviceDxe.inf|  18 +-
>  .../NonDiscoverablePciDeviceIo.c   | 298 
> -
>  .../NonDiscoverablePciDeviceIo.h   |   6 +
>  5 files changed, 405 insertions(+), 14 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c 
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c
> index 6e51d00..0e6ebec 100644
> --- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c
> +++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c
> @@ -28,10 +28,31 @@ EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
>{ NULL, NULL   }
>  };
>
>  EFI_COMPONENT_NAME_PROTOCOL gComponentName;
>
> +/**
> +  Retrieves a Unicode string that is the user readable name of the UEFI 
> Driver.
> +
> +  @param This   A pointer to the EFI_COMPONENT_NAME_PROTOCOL 
> instance.
> +  @param Language   A pointer to a three character ISO 639-2 language 
> identifier.
> +This is the language of the driver name that that 
> the caller
> +is requesting, and it must match one of the 
> languages specified
> +in SupportedLanguages.  The number of languages 
> supported by a
> +driver is up to the driver writer.
> +  @param DriverName A pointer to the Unicode string to return.  This 
> Unicode string
> +is the name of the driver specified by This in the 
> language
> +specified by Language.
> +
> +  @retval EFI_SUCCESS   The Unicode string for the Driver specified 
> by This
> +and the language specified by Language was 
> returned
> +in DriverName.
> +  @retval EFI_INVALID_PARAMETER Language is NULL.
> +  @retval EFI_INVALID_PARAMETER DriverName is NULL.
> +  @retval EFI_UNSUPPORTED   The driver specified by This does not 
> support the
> +language specified by Language.
> +**/
>  STATIC
>  EFI_STATUS
>  EFIAPI
>  NonDiscoverablePciGetDriverName (
>IN  EFI_COMPONENT_NAME_PROTOCOL *This,
> @@ -46,10 +67,36 @@ NonDiscoverablePciGetDriverName (
> DriverName,
> (BOOLEAN)(This == ) // Iso639Language
> );
>  }
>
> +/**
> +  Retrieves a Unicode string that is the user readable name of the controller
> +  that is being managed by an UEFI Driver.
> +
> +  @param This   A pointer to the EFI_COMPONENT_NAME_PROTOCOL 
> instance.
> +  @param DeviceHandle   The handle of a controller that the driver 
> specified by
> +This is managing.  This handle specifies the 
> controller
> +whose name is to be returned.
> +  @param ChildHandleThe handle of the child controller to 
> retrieve the name
> +of.  This is an optional parameter that may 
> be NULL.  It
> +will be NULL for device drivers.  It will 
> also be NULL
> +for a bus drivers that wish to retrieve the 
> name of the
> +bus controller.  It will not be NULL for a 
> bus driver
> +that wishes to retrieve the name of a child 
> controller.
> +  @param Language   A pointer to a three character ISO 639-2 
> language
> +identifier.  This is the language of the 
> controller name
> +that that the caller is requesting, and it 
> must match one
> +of the languages specified in 
> SupportedLanguages.  The
> +number of languages supported by a driver is 
> up to the
> +driver writer.
> +  @param ControllerName A pointer to the Unicode string to return.  
> This Unicode
> +string is the name of the controller 
> specified by
> +ControllerHandle and ChildHandle in the 
> language
> +  

Re: [edk2] [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic

2016-12-14 Thread Ye, Ting
Reviewed-by: Ye Ting 


-Original Message-
From: Wu, Hao A 
Sent: Wednesday, December 14, 2016 7:27 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Fu, Siyuan ; Ye, Ting 
; Wu, Jiaxin 
Subject: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function 
logic

This commit rewrites the logic for NetblockChecksum. It processes the checksum 
of the left-over byte first to prevent possible mis-reports by static code 
checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c 
b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
index bbbdbc0..95cb717 100644
--- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
+++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
@@ -1,7 +1,7 @@
 /** @file
   Network library functions providing net buffer operation support.
 
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 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 @@ -1661,6 +1661,13 
@@ NetblockChecksum (
 
   Sum = 0;
 
+  //
+  // Add left-over byte, if any
+  //
+  if (Len % 2 != 0) {
+Sum += *(Bulk + Len - 1);
+  }
+
   while (Len > 1) {
 Sum += *(UINT16 *) Bulk;
 Bulk += 2;
@@ -1668,13 +1675,6 @@ NetblockChecksum (
   }
 
   //
-  // Add left-over byte, if any
-  //
-  if (Len > 0) {
-Sum += *(UINT8 *) Bulk;
-  }
-
-  //
   // Fold 32-bit sum to 16 bits
   //
   while ((Sum >> 16) != 0) {
--
1.9.5.msysgit.0

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


Re: [edk2] [PATCH 5/6] MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic

2016-12-14 Thread Ye, Ting
Reviewed-by: Ye Ting 


-Original Message-
From: Wu, Hao A 
Sent: Wednesday, December 14, 2016 7:27 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Fu, Siyuan ; Ye, Ting 
; Wu, Jiaxin 
Subject: [PATCH 5/6] MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic

This commit refines the logic for the CvtNum function. It avoids using the 
decrement operator '--' for array index to prevent possible mis-reports by 
static code checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
index 0865ddd..0779056 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
@@ -132,11 +132,10 @@ CvtNum (
 {
   UINTN Remainder;
 
-  while (Length > 0) {
+  for (; Length > 0; Length--) {
 Remainder = Number % 10;
 Number /= 10;
-Length--;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
--
1.9.5.msysgit.0

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


Re: [edk2] [PATCH 6/6] NetworkPkg: Refine UintnToAscDecWithFormat functions logic

2016-12-14 Thread Ye, Ting
Reviewed-by: Ye Ting  

-Original Message-
From: Wu, Hao A 
Sent: Wednesday, December 14, 2016 7:27 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Fu, Siyuan ; Ye, Ting 
; Wu, Jiaxin 
Subject: [PATCH 6/6] NetworkPkg: Refine UintnToAscDecWithFormat functions logic

This commit refines the logic for HttpBootUintnToAscDecWithFormat and 
PxeBcUintnToAscDecWithFormat. It avoids using the decrement operator '--'
for array index to prevent possible mis-reports by static code checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 NetworkPkg/HttpBootDxe/HttpBootSupport.c | 5 ++---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c   | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c 
b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index 9410bf9..bdb29ae 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -86,11 +86,10 @@ HttpBootUintnToAscDecWithFormat (  {
   UINTN  Remainder;
 
-  while (Length > 0) {
-Length--;
+  for (; Length > 0; Length--) {
 Remainder  = Number % 10;
 Number/= 10;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index 00c652d..568360d 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -1383,11 +1383,10 @@ PxeBcUintnToAscDecWithFormat (  {
   UINTN  Remainder;
 
-  while (Length > 0) {
-Length--;
+  for (; Length > 0; Length--) {
 Remainder  = Number % 10;
 Number/= 10;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
--
1.9.5.msysgit.0

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


[edk2] [PATCH] ShellPkg/setvar: Correct typo in setvar help message

2016-12-14 Thread Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni 
Cc: Jaben Carsey 
---
 .../UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
index bd1726b..06865a4 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
@@ -813,9 +813,9 @@
 "  3. If = is not specified, then the current variable contents are 
displayed.\r\n"
 "  4. If =data is specified, then the variable's value is changed to the 
value\r\n"
 " specified by data.\r\n"
-"  5. -bs, -rt and -nv are only useful if the variable already exists.\r\n"
-"  6. If the variable already exists and the attributes cannot be changed,\r\n"
-" then -1 is returned. \r\n"
+"  5. -bs, -rt and -nv are only useful if the variable does not exist.\r\n"
+"  6. If the variable already exists, the attributes cannot be changed, and 
the"
+" flags will be ignored.\r\n"
 ".SH RETURNVALUES\r\n"
 " \r\n"
 "RETURN VALUES:\r\n"
-- 
2.9.0.windows.1

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


Re: [edk2] [Patch 05/10] NetworkPkg/TlsDxe: TlsDxe driver implementation over OpenSSL

2016-12-14 Thread Wu, Jiaxin
Thanks Siyuan, I have refined the TlsEcryptPacket/TlsDecryptPacket function 
according your feedback.

[PATCH v2 05/10] NetworkPkg/TlsDxe: TlsDxe driver implementation over OpenSSL

Thanks,
Jiaxin

> -Original Message-
> From: Fu, Siyuan
> Sent: Wednesday, December 14, 2016 4:41 PM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Cc: Ye, Ting ; Zhang, Lubo ;
> Long, Qin ; Thomas Palmer 
> Subject: RE: [Patch 05/10] NetworkPkg/TlsDxe: TlsDxe driver implementation
> over OpenSSL
> 
> Hi, Jiaxin
> 
> Some comments as below:
> 
> In TlsImpl.c
> 
> Should the ASSERT in line 104 be an error handling? I mean is the input buffer
> coming from external input, and have we checked ContentType within it?
> 
> Seems the TempRecordHeader pointer will be modified in the while loop,
> shouldn't the 3rd parameter be the reminding buffer size of the output
> buffer?
> 
> Should we return error if the TlsCtrlTrafficOut return a failure?
> 
> Similar questions for the decrypt packet function.
> 
> 
> Best Regards,
> Siyuan
> 
> -Original Message-
> From: Wu, Jiaxin
> Sent: 2016年12月14日 15:34
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Zhang,
> Lubo ; Long, Qin ; Thomas
> Palmer ; Wu, Jiaxin 
> Subject: [Patch 05/10] NetworkPkg/TlsDxe: TlsDxe driver implementation
> over OpenSSL
> 
> This patch is the implementation of EFI TLS Service Binding
> Protocol, EFI TLS Protocol and EFI TLS Configuration Protocol
> Interfaces.
> 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Zhang Lubo 
> Cc: Long Qin 
> Cc: Thomas Palmer 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin 
> ---
>  NetworkPkg/TlsDxe/TlsConfigProtocol.c | 152 
>  NetworkPkg/TlsDxe/TlsDriver.c | 498
> +++
>  NetworkPkg/TlsDxe/TlsDriver.h | 237 +
>  NetworkPkg/TlsDxe/TlsDxe.inf  |  65 
>  NetworkPkg/TlsDxe/TlsDxe.uni  |  25 ++
>  NetworkPkg/TlsDxe/TlsDxeExtra.uni |  18 +
>  NetworkPkg/TlsDxe/TlsImpl.c   | 270 +++
>  NetworkPkg/TlsDxe/TlsImpl.h   | 315 +
>  NetworkPkg/TlsDxe/TlsProtocol.c   | 632
> ++
>  9 files changed, 2212 insertions(+)
>  create mode 100644 NetworkPkg/TlsDxe/TlsConfigProtocol.c
>  create mode 100644 NetworkPkg/TlsDxe/TlsDriver.c
>  create mode 100644 NetworkPkg/TlsDxe/TlsDriver.h
>  create mode 100644 NetworkPkg/TlsDxe/TlsDxe.inf
>  create mode 100644 NetworkPkg/TlsDxe/TlsDxe.uni
>  create mode 100644 NetworkPkg/TlsDxe/TlsDxeExtra.uni
>  create mode 100644 NetworkPkg/TlsDxe/TlsImpl.c
>  create mode 100644 NetworkPkg/TlsDxe/TlsImpl.h
>  create mode 100644 NetworkPkg/TlsDxe/TlsProtocol.c
> 
> diff --git a/NetworkPkg/TlsDxe/TlsConfigProtocol.c
> b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
> new file mode 100644
> index 000..2ec79c9
> --- /dev/null
> +++ b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
> @@ -0,0 +1,152 @@
> +/** @file
> +  Implementation of EFI TLS Configuration Protocol Interfaces.
> +
> +  Copyright (c) 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.
> +
> +**/
> +
> +#include "TlsImpl.h"
> +
> +EFI_TLS_CONFIGURATION_PROTOCOL  mTlsConfigurationProtocol = {
> +  TlsConfigurationSetData,
> +  TlsConfigurationGetData
> +};
> +
> +/**
> +  Set TLS configuration data.
> +
> +  The SetData() function sets TLS configuration to non-volatile storage or
> volatile
> +  storage.
> +
> +  @param[in]  ThisPointer to the
> EFI_TLS_CONFIGURATION_PROTOCOL instance.
> +  @param[in]  DataTypeConfiguration data type.
> +  @param[in]  DataPointer to configuration data.
> +  @param[in]  DataSizeTotal size of configuration data.
> +
> +  @retval EFI_SUCCESS The TLS configuration data is set 
> successfully.
> +  @retval EFI_INVALID_PARAMETER   One or more of the following
> conditions is TRUE:
> +  This is NULL.
> +  Data is NULL.
> +  DataSize is 0.
> +  @retval EFI_UNSUPPORTED The DataType is unsupported.
> +  @retval EFI_OUT_OF_RESOURCESRequired system resources could not
> be 

[edk2] [PATCH v2 05/10] NetworkPkg/TlsDxe: TlsDxe driver implementation over OpenSSL

2016-12-14 Thread Jiaxin Wu
v2:
* Refine the TlsEcryptPacket/TlsDecryptPacket function
according the community feedback.

This patch is the implementation of EFI TLS Service Binding
Protocol, EFI TLS Protocol and EFI TLS Configuration Protocol
Interfaces.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Long Qin 
Cc: Thomas Palmer 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/TlsDxe/TlsConfigProtocol.c | 152 
 NetworkPkg/TlsDxe/TlsDriver.c | 498 +++
 NetworkPkg/TlsDxe/TlsDriver.h | 237 +
 NetworkPkg/TlsDxe/TlsDxe.inf  |  65 
 NetworkPkg/TlsDxe/TlsDxe.uni  |  25 ++
 NetworkPkg/TlsDxe/TlsDxeExtra.uni |  18 +
 NetworkPkg/TlsDxe/TlsImpl.c   | 326 ++
 NetworkPkg/TlsDxe/TlsImpl.h   | 315 +
 NetworkPkg/TlsDxe/TlsProtocol.c   | 632 ++
 9 files changed, 2268 insertions(+)
 create mode 100644 NetworkPkg/TlsDxe/TlsConfigProtocol.c
 create mode 100644 NetworkPkg/TlsDxe/TlsDriver.c
 create mode 100644 NetworkPkg/TlsDxe/TlsDriver.h
 create mode 100644 NetworkPkg/TlsDxe/TlsDxe.inf
 create mode 100644 NetworkPkg/TlsDxe/TlsDxe.uni
 create mode 100644 NetworkPkg/TlsDxe/TlsDxeExtra.uni
 create mode 100644 NetworkPkg/TlsDxe/TlsImpl.c
 create mode 100644 NetworkPkg/TlsDxe/TlsImpl.h
 create mode 100644 NetworkPkg/TlsDxe/TlsProtocol.c

diff --git a/NetworkPkg/TlsDxe/TlsConfigProtocol.c 
b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
new file mode 100644
index 000..2ec79c9
--- /dev/null
+++ b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
@@ -0,0 +1,152 @@
+/** @file
+  Implementation of EFI TLS Configuration Protocol Interfaces.
+
+  Copyright (c) 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.
+
+**/
+
+#include "TlsImpl.h"
+
+EFI_TLS_CONFIGURATION_PROTOCOL  mTlsConfigurationProtocol = {
+  TlsConfigurationSetData,
+  TlsConfigurationGetData
+};
+
+/**
+  Set TLS configuration data.
+
+  The SetData() function sets TLS configuration to non-volatile storage or 
volatile
+  storage.
+
+  @param[in]  ThisPointer to the 
EFI_TLS_CONFIGURATION_PROTOCOL instance.
+  @param[in]  DataTypeConfiguration data type.
+  @param[in]  DataPointer to configuration data.
+  @param[in]  DataSizeTotal size of configuration data.
+
+  @retval EFI_SUCCESS The TLS configuration data is set 
successfully.
+  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is 
TRUE:
+  This is NULL.
+  Data is NULL.
+  DataSize is 0.
+  @retval EFI_UNSUPPORTED The DataType is unsupported.
+  @retval EFI_OUT_OF_RESOURCESRequired system resources could not be 
allocated.
+
+**/
+EFI_STATUS
+EFIAPI
+TlsConfigurationSetData (
+  IN EFI_TLS_CONFIGURATION_PROTOCOL  *This,
+  IN EFI_TLS_CONFIG_DATA_TYPEDataType,
+  IN VOID*Data,
+  IN UINTN   DataSize
+  )
+{
+  EFI_STATUSStatus;
+  TLS_INSTANCE  *Instance;
+  EFI_TPL   OldTpl;
+
+  Status = EFI_SUCCESS;
+
+  if (This == NULL ||  Data == NULL || DataSize == 0) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+
+  Instance = TLS_INSTANCE_FROM_CONFIGURATION_THIS (This);
+
+  switch (DataType) {
+  case EfiTlsConfigDataTypeCACertificate:
+Status = TlsSetCaCertificate (Instance->TlsConn, Data, DataSize);
+break;
+  case EfiTlsConfigDataTypeHostPublicCert:
+Status = TlsSetHostPublicCert (Instance->TlsConn, Data, DataSize);
+break;
+  case EfiTlsConfigDataTypeHostPrivateKey:
+Status = TlsSetHostPrivateKey (Instance->TlsConn, Data, DataSize);
+break;
+  case EfiTlsConfigDataTypeCertRevocationList:
+Status = TlsSetCertRevocationList (Data, DataSize);
+break;
+  default:
+ Status = EFI_UNSUPPORTED;
+  }
+
+  gBS->RestoreTPL (OldTpl);
+  return Status;
+}
+
+/**
+  Get TLS configuration data.
+
+  The GetData() function gets TLS configuration.
+
+  @param[in]   This   Pointer to the 
EFI_TLS_CONFIGURATION_PROTOCOL instance.
+  @param[in]   DataType   Configuration data type.
+  @param[in, out]  Data   Pointer to configuration data.
+  @param[in, out]  DataSize   Total size of configuration data. On 

[edk2] [patch 2/2] MdeModulePkg/NonDiscoverablePciDevice: Make variable definition follow rule

2016-12-14 Thread Dandan Bi
Cc: Ard Biesheuvel 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 .../Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c  | 2 +-
 .../Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
index a868ea2..921225b 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
+++ 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
@@ -19,11 +19,11 @@
 //
 // We only support the following device types
 //
 STATIC
 CONST EFI_GUID * CONST
-SupportedNonDiscoverableDevices [] = {
+SupportedNonDiscoverableDevices[] = {
   ,
   ,
   ,
   ,
   ,
diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
index 59b6076..a54313f 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
+++ 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
@@ -913,11 +913,12 @@ PciIoGetBarAttributes (
   OUT UINT64 *Supports OPTIONAL,
   OUT VOID   **Resources OPTIONAL
   )
 {
   NON_DISCOVERABLE_PCI_DEVICE   *Dev;
-  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor, *BarDesc;
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc;
   EFI_ACPI_END_TAG_DESCRIPTOR   *End;
   EFI_STATUSStatus;
 
   if (Supports == NULL && Resources == NULL) {
 return EFI_INVALID_PARAMETER;
-- 
1.9.5.msysgit.1

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


[edk2] [patch 1/2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Add comments for functions

2016-12-14 Thread Dandan Bi
Cc: Ard Biesheuvel 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 .../NonDiscoverablePciDeviceDxe/ComponentName.c|  47 
 .../NonDiscoverablePciDeviceDxe.c  |  50 +++-
 .../NonDiscoverablePciDeviceDxe.inf|  18 +-
 .../NonDiscoverablePciDeviceIo.c   | 298 -
 .../NonDiscoverablePciDeviceIo.h   |   6 +
 5 files changed, 405 insertions(+), 14 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c
index 6e51d00..0e6ebec 100644
--- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c
+++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c
@@ -28,10 +28,31 @@ EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
   { NULL, NULL   }
 };
 
 EFI_COMPONENT_NAME_PROTOCOL gComponentName;
 
+/**
+  Retrieves a Unicode string that is the user readable name of the UEFI Driver.
+
+  @param This   A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+  @param Language   A pointer to a three character ISO 639-2 language 
identifier.
+This is the language of the driver name that that the 
caller
+is requesting, and it must match one of the languages 
specified
+in SupportedLanguages.  The number of languages 
supported by a
+driver is up to the driver writer.
+  @param DriverName A pointer to the Unicode string to return.  This 
Unicode string
+is the name of the driver specified by This in the 
language
+specified by Language.
+
+  @retval EFI_SUCCESS   The Unicode string for the Driver specified by 
This
+and the language specified by Language was 
returned
+in DriverName.
+  @retval EFI_INVALID_PARAMETER Language is NULL.
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.
+  @retval EFI_UNSUPPORTED   The driver specified by This does not support 
the
+language specified by Language.
+**/
 STATIC
 EFI_STATUS
 EFIAPI
 NonDiscoverablePciGetDriverName (
   IN  EFI_COMPONENT_NAME_PROTOCOL *This,
@@ -46,10 +67,36 @@ NonDiscoverablePciGetDriverName (
DriverName,
(BOOLEAN)(This == ) // Iso639Language
);
 }
 
+/**
+  Retrieves a Unicode string that is the user readable name of the controller
+  that is being managed by an UEFI Driver.
+
+  @param This   A pointer to the EFI_COMPONENT_NAME_PROTOCOL 
instance.
+  @param DeviceHandle   The handle of a controller that the driver 
specified by
+This is managing.  This handle specifies the 
controller
+whose name is to be returned.
+  @param ChildHandleThe handle of the child controller to retrieve 
the name
+of.  This is an optional parameter that may be 
NULL.  It
+will be NULL for device drivers.  It will also 
be NULL
+for a bus drivers that wish to retrieve the 
name of the
+bus controller.  It will not be NULL for a bus 
driver
+that wishes to retrieve the name of a child 
controller.
+  @param Language   A pointer to a three character ISO 639-2 
language
+identifier.  This is the language of the 
controller name
+that that the caller is requesting, and it 
must match one
+of the languages specified in 
SupportedLanguages.  The
+number of languages supported by a driver is 
up to the
+driver writer.
+  @param ControllerName A pointer to the Unicode string to return.  
This Unicode
+string is the name of the controller specified 
by
+ControllerHandle and ChildHandle in the 
language
+specified by Language from the point of view 
of the
+driver specified by This.
+**/
 STATIC
 EFI_STATUS
 EFIAPI
 NonDiscoverablePciGetDeviceName (
   IN  EFI_COMPONENT_NAME_PROTOCOL *This,
diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
index ee765d7..a868ea2 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
+++ 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
@@ -45,10 +45,23 @@ 

[edk2] [PATCH 4/4] BaseTools: fix unused-result build warnings

2016-12-14 Thread Heyi Guo
Fix build warnings of "ignoring return value of ‘size_t fread(void*,
size_t, size_t, FILE*)’, declared with attribute warn_unused_result
[-Wunused-result]" for BaseTools, while using "gcc version 4.8.4
(Ubuntu 4.8.4-2ubuntu1~14.04.3)".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo 
Cc: Yonghong Zhu 
Cc: Liming Gao 
---
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp 
b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 3ca57ed..0ba7102 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -3395,7 +3395,9 @@ CVfrStringDB::GetVarStoreNameFormStringId (
 fclose (pInFile);
 return NULL;
   }
-  fread ((char *)StringPtr, sizeof (UINT8), Length, pInFile);
+  // Fix GCC build warning for ignoring return value
+  unsigned long TempResult = fread ((char *)StringPtr, sizeof (UINT8), Length, 
pInFile);
+  (void)TempResult;
   fclose (pInFile);
 
   PkgHeader = (EFI_HII_STRING_PACKAGE_HDR *) StringPtr;
-- 
1.9.1

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


[edk2] [PATCH 1/4] BaseTools: fix format-security build warnings

2016-12-14 Thread Heyi Guo
Fix build warnings of "format not a string literal and no format
arguments [-Wformat-security]" for BaseTools, while using "gcc version
4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo 
Cc: Yonghong Zhu 
Cc: Liming Gao 
---
 BaseTools/Source/C/VfrCompile/Pccts/antlr/fset2.c | 2 +-
 BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c   | 2 +-
 BaseTools/Source/C/VfrCompile/Pccts/antlr/lex.c   | 8 
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/fset2.c 
b/BaseTools/Source/C/VfrCompile/Pccts/antlr/fset2.c
index 7f686a5..fe1b4d6 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/fset2.c
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/fset2.c
@@ -2210,7 +2210,7 @@ void MR_backTraceReport()
   if (p->ntype != nToken) continue;
   tn=(TokNode *)p;
   if (depth != 0) fprintf(stdout," ");
-  fprintf(stdout,TerminalString(tn->token));
+  fprintf(stdout, "%s", TerminalString(tn->token));
   depth++;
   if (! MR_AmbAidMultiple) {
 if (set_nil(tn->tset)) {
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c 
b/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c
index 368a96b..b990545 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c
@@ -3866,7 +3866,7 @@ int file;
 /* MR10 */_gen(" *  ");
 /* MR10 */for (i=0 ; i < Save_argc ; i++) {
 /* MR10 */  _gen(" ");
-/* MR10 */  _gen(Save_argv[i]);
+/* MR10 */  _gen1("%s", Save_argv[i]);
 /* MR10 */};
_gen("\n");
_gen(" *\n");
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/lex.c 
b/BaseTools/Source/C/VfrCompile/Pccts/antlr/lex.c
index 8c524fe..a4e7f69 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/lex.c
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/lex.c
@@ -706,7 +706,7 @@ FILE *output;
 /* MR26 */ if (! (isalpha(*t) || isdigit(*t) || *t == '_' 
|| *t == '$')) break;
 /* MR26 */ }
 /* MR26 */ }
-/* MR26 */ fprintf(output,strBetween(pSymbol, t, pSeparator));
+/* MR26 */ fprintf(output, "%s", strBetween(pSymbol, t, pSeparator));
 
 *q = p;
 return (*pSeparator  == 0);
@@ -771,7 +771,7 @@ FILE *f;
  ,
  ,
  );
-   fprintf(f,strBetween(pDataType, pSymbol, pSeparator));
+   fprintf(f, "%s", strBetween(pDataType, pSymbol, pSeparator));
 }
 
 /* check to see if string e is a word in string s */
@@ -852,9 +852,9 @@ int i;
  ,
  );
fprintf(f,"\t");
-   fprintf(f,strBetween(pDataType, pSymbol, pSeparator));
+   fprintf(f, "%s", strBetween(pDataType, pSymbol, pSeparator));
fprintf(f," ");
-   fprintf(f,strBetween(pSymbol, pEqualSign, pSeparator));
+   fprintf(f, "%s", strBetween(pSymbol, pEqualSign, pSeparator));
fprintf(f,";\n");
 }
fprintf(f,"};\n");
-- 
1.9.1

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


[edk2] [PATCH 2/4] BaseTools: fix format type build warnings

2016-12-14 Thread Heyi Guo
Fix build warnings of "format ‘%d’ expects argument of type ‘int’, but
argument 5 has type ‘long unsigned int’ [-Wformat=]" for BaseTools,
while using "gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo 
Cc: Yonghong Zhu 
Cc: Liming Gao 
---
 BaseTools/Source/C/VfrCompile/Pccts/antlr/bits.c | 16 
 BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c  |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/bits.c 
b/BaseTools/Source/C/VfrCompile/Pccts/antlr/bits.c
index ddd9bd6..5cb657b 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/bits.c
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/bits.c
@@ -573,13 +573,13 @@ const char *suffix;
else
fprintf(DefFile, "extern SetWordType zzerr%d[];\n", esetnum);
if ( name!=NULL ) {
-   fprintf(ErrFile, "SetWordType %s%s[%d] = {",
+   fprintf(ErrFile, "SetWordType %s%s[%lu] = {",
name,
 suffix,
NumWords(TokenNum-1)*sizeof(unsigned));
}
else {
-   fprintf(ErrFile, "SetWordType zzerr%d[%d] = {",
+   fprintf(ErrFile, "SetWordType zzerr%d[%lu] = {",
esetnum,
NumWords(TokenNum-1)*sizeof(unsigned));
}
@@ -641,20 +641,20 @@ const char *suffix;
esetnum++;
 
if ( name!=NULL ) {
-   fprintf(Parser_h, "\tstatic SetWordType %s%s[%d];\n", name, 
suffix,
+   fprintf(Parser_h, "\tstatic SetWordType %s%s[%lu];\n", name, 
suffix,
NumWords(TokenNum-1)*sizeof(unsigned));
-   fprintf(Parser_c, "SetWordType %s::%s%s[%d] = {",
+   fprintf(Parser_c, "SetWordType %s::%s%s[%lu] = {",
CurrentClassName,
name,
suffix,
NumWords(TokenNum-1)*sizeof(unsigned));
}
else {
-   fprintf(Parser_c, "SetWordType %s::err%d[%d] = {",
+   fprintf(Parser_c, "SetWordType %s::err%d[%lu] = {",
CurrentClassName,
esetnum,
NumWords(TokenNum-1)*sizeof(unsigned));
-   fprintf(Parser_h, "\tstatic SetWordType err%d[%d];\n", esetnum,
+   fprintf(Parser_h, "\tstatic SetWordType err%d[%lu];\n", esetnum,
NumWords(TokenNum-1)*sizeof(unsigned));
}
 
@@ -787,7 +787,7 @@ GenParser_c_Hdr()
 
/* Build constructors */
fprintf(Parser_c, "\n%s::", CurrentClassName);
-   fprintf(Parser_c,   "%s(ANTLRTokenBuffer *input) : 
%s(input,%d,%d,%d,%d)\n",
+   fprintf(Parser_c,   "%s(ANTLRTokenBuffer *input) : 
%s(input,%d,%d,%d,%lu)\n",
CurrentClassName,
(BaseClassName == NULL ? 
"ANTLRParser" : BaseClassName),
OutputLL_k,
@@ -912,7 +912,7 @@ GenErrHdr( )
 #ifdef DUM
if ( LexGen ) fprintf(ErrFile, "#define zzEOF_TOKEN %d\n", 
(TokenInd!=NULL?TokenInd[EofToken]:EofToken));
 #endif
-   fprintf(ErrFile, "#define zzSET_SIZE %d\n", 
NumWords(TokenNum-1)*sizeof(unsigned));
+   fprintf(ErrFile, "#define zzSET_SIZE %lu\n", 
NumWords(TokenNum-1)*sizeof(unsigned));
if ( DemandLookahead ) fprintf(ErrFile, "#define DEMAND_LOOK\n");
fprintf(ErrFile, "#include \"antlr.h\"\n");
if ( GenAST ) fprintf(ErrFile, "#include \"ast.h\"\n");
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c 
b/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c
index b990545..d0a448d 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c
@@ -3911,7 +3911,7 @@ int file;
}
 #endif
/* ###WARNING: This will have to change when SetWordSize changes */
-   if ( !GenCC ) _gen1("#define zzSET_SIZE %d\n", 
NumWords(TokenNum-1)*sizeof(unsigned));
+   if ( !GenCC ) _gen1("#define zzSET_SIZE %lu\n", 
NumWords(TokenNum-1)*sizeof(unsigned));
 if (TraceGen) {
   _gen("#ifndef zzTRACE_RULES\n");  /* MR20 */
   _gen("#define zzTRACE_RULES\n");  /* MR20 */
@@ -4125,7 +4125,7 @@ char * gate;/* MR10 */
if ( LexGen ) fprintf(f, "#define zzEOF_TOKEN %d\n", 
(TokenInd!=NULL?TokenInd[EofToken]:EofToken));
 #endif
/* ###WARNING: This will have to change when SetWordSize changes */
-   fprintf(f, "#define zzSET_SIZE %d\n", 
NumWords(TokenNum-1)*sizeof(unsigned));
+   fprintf(f, "#define zzSET_SIZE %lu\n", 
NumWords(TokenNum-1)*sizeof(unsigned));
 if 

[edk2] [PATCH 0/4] Fix GCC build warnings for BaseTools

2016-12-14 Thread Heyi Guo
There are 28 warnings when I build BaseTools using gcc (version 4.8.4
(Ubuntu 4.8.4-2ubuntu1~14.04.3)). Below patches are to fix these build
warnings. I don't have a visual studio environment to test the build;
sorry for not testing the patches entirely.

There are still 10 warnings which I'm not very clear how to fix; could
anyone please help to fix them:

  ../support/set/set.c:557:2: warning: format ‘%d’ expects argument of type 
‘int’, but argument 3 has type ‘size_t’ [-Wformat=]
  VfrSyntax.g, line 1830: warning: predicate: LT(i) missing, bad, or with i=0; 
assuming i=1
  VfrSyntax.g, line 1835: warning: predicate: LT(i) missing, bad, or with i=0; 
assuming i=1
  VfrSyntax.g, line 3266: warning: alts 1 and 2 of {..} ambiguous upon ( ";" 
RefreshGuid GuidOp Locked Image EndIf InconsistentIf DisableIf SuppressIf 
Default GrayOutIf )
  VfrSyntax.g, line 3275: warning: alts 1 and 2 of {..} ambiguous upon ( ";" 
RefreshGuid GuidOp Locked Image EndIf InconsistentIf DisableIf SuppressIf 
Default GrayOutIf )
  VfrSyntax.g, line 3284: warning: alts 1 and 2 of {..} ambiguous upon ( ";" 
RefreshGuid GuidOp Locked Image EndIf InconsistentIf DisableIf SuppressIf 
Default GrayOutIf )
  VfrSyntax.g, line 3294: warning: alts 1 and 2 of {..} ambiguous upon ( ";" 
RefreshGuid GuidOp Locked Image EndIf InconsistentIf DisableIf SuppressIf 
Default GrayOutIf )
  VfrSyntax.g, line 3324: warning: alts 1 and 2 of {..} ambiguous upon ( ";" 
RefreshGuid GuidOp Locked Image EndIf InconsistentIf DisableIf SuppressIf 
Default GrayOutIf )
  VfrSyntax.g, line : warning: alts 1 and 2 of {..} ambiguous upon ( ";" 
RefreshGuid GuidOp Locked Image EndIf InconsistentIf DisableIf SuppressIf 
Default GrayOutIf )
  ../support/set/set.c:557:2: warning: format ‘%d’ expects argument of type 
‘int’, but argument 3 has type ‘size_t’ [-Wformat=]

Heyi Guo (4):
  BaseTools: fix format-security build warnings
  BaseTools: fix format type build warnings
  BaseTools: fix write-strings build warnings
  BaseTools: fix unused-result build warnings

 BaseTools/Source/C/VfrCompile/Pccts/antlr/bits.c  | 16 
 BaseTools/Source/C/VfrCompile/Pccts/antlr/fset2.c |  2 +-
 BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c   |  6 +++---
 BaseTools/Source/C/VfrCompile/Pccts/antlr/lex.c   |  8 
 BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp  |  2 +-
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp   |  4 +++-
 6 files changed, 20 insertions(+), 18 deletions(-)

-- 
1.9.1

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


Re: [edk2] $ escape sequence at build_rule.txt

2016-12-14 Thread peter.kirme...@ts.fujitsu.com
Hi Liming,

I filed a bug report and assigned it to you initially.
Hopefully I did it right because BugZilla was a pain to me in entering this 
issue :)

Best Regards,
  Peter

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

-Original Message-
From: Gao, Liming [mailto:liming@intel.com] 
Sent: Wednesday, December 14, 2016 8:06 AM
To: Kirmeier, Peter; af...@apple.com; Zhu, Yonghong
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] $ escape sequence at build_rule.txt

Peter:
  Thanks for your report this issue. Could you report it in bugzilla 
(bugzilla.tianocore.org)? We will follow up. 
 
Thanks
Liming
> -Original Message-
> From: peter.kirme...@ts.fujitsu.com 
> [mailto:peter.kirme...@ts.fujitsu.com]
> Sent: Wednesday, December 14, 2016 3:03 PM
> To: af...@apple.com; Zhu, Yonghong ; Gao, 
> Liming 
> Cc: edk2-devel@lists.01.org 
> Subject: RE: [edk2] $ escape sequence at build_rule.txt
> 
> Hi Andrew,
> 
> in the meantime I will work around this issue by using a script file 
> as AWK input, so the command is not part of build_rules.txt.
> Thanks for your help.
> 
> Dear Yonghong, Liming,
> 
> first I thought that my issue came by myself (not knowing how to 
> escape the dollar sign at build_rules.txt).
> But now I think this is a real issue of the build tools and that 
> build_rules.txt doesn't have the capability of escaping the $ sign.
> Therefore I hope that you could fix the tools accordingly.
> For example, by adding an "escape sequence" for the $ sign (or at 
> least by adding a predefined macro like "$(DOLLAR)" which expands to "$").
> 
> Thanks,
>   Peter
> 
> -Original Message-
> From: af...@apple.com [mailto:af...@apple.com]
> Sent: Tuesday, December 13, 2016 12:26 AM
> To: Peter Kirmeier
> Cc: Kirmeier, Peter; edk2-devel@lists.01.org
> Subject: Re: [edk2] $ escape sequence at build_rule.txt
> 
> 
> > On Dec 12, 2016, at 1:49 PM, Peter Kirmeier  wrote:
> >
> > Hi Andrew,
> >
> > the line I wrote first..
> >"$(TOOLS_DIR)\gawk.exe" "NF{gsub(/ *\\$$/,\"\"); print}" 
> > infile.in
> > > outfile.out .. failed with this error message..
> >makefile(527) : fatal error U1001: Syntaxfehler: ung³ltiges Zeichen "/"
> > in Makro
> >   (means syntax error due to invalid character "/" in macro) 
> > ..and brought this result at the makefile:
> >"$(TOOLS_DIR)\gawk.exe" "NF{gsub(/ *\\$/,\"\"); print}" infile.in 
> > > outfile.out
> >
> 
> Peter,
> 
> You can also looks at the makefile (GNUmakefile) produced by the build 
> as they will live in the Build/ output directories.
> 
> > Also with this line..
> >"$(TOOLS_DIR)\gawk.exe" "NF{gsub(/ *\\/,\"\"); print}"
> > infile.in > outfile.out .. I get exactly the same error and output 
> > (multiple dollars are stripped down to a single one)
> >
> > Tried to get some more details of how the macros work by looking at 
> > python scripts.
> > All I see is that only fixed macros are supported like ${s_base} or 
> > $(OUTPUT_DIR).
> > I couldn't find a way to actually espace the $(xx) sequence at all.
> >
> > Here are some more tries to figure out how the $ is processed:
> >
> > $() fails because no macro name is set but prints $() into the 
> > makefile,
> > $($) fails because second $ is unknown and prints $($) into the 
> > makefile, ${} fails because { is no valid character but prints ${} 
> > into the makefile, $ or $$ or $$$ or  .. fails because next 
> > character "/" invalid and prints a single $ into the makefile.
> >
> > It seems there is one exception that multiple $ signs will not be 
> > printed
> > 1:1 into the makefile.
> > All other tries were printed correctly into the makefile.
> > So if $$ would be printed 1:1, too, it should work as I expected.
> > Unfortunately I don't get $$ with anyone of them.
> >
> > Guess there is no support for any escape sequence yet, right?
> 
> Sorry I was just taking a guess. It looks like an issue in how the 
> file is parsed hopefully the maintainer can chime in with more details.
> 
> Short term can you make it work if you pass the pattern in via a file (awk 
> -f)?
> You should be able to use the existing macros to point to a file 
> checked into your source tree.
> 
> Thanks,
> 
> Andrew Fish
> 
> > Any idea to get this working and/or in case $$ should work in 
> > build_rules.txt, would you plan to fix this?
> >
> > Best Regards,
> >  Peter Kirmeier
> >
> > PS: Maybe a quick and simple solution could be to add a predefined
> > $(DOLLAR) marco or anything like that into the python scripts?
> >
> >
> > -Ursprüngliche Nachricht-
> > Von: edk2-devel [mailto:edk2-devel-boun...@ml01.01.org] Im Auftrag
> von
> > Andrew Fish
> > Gesendet: Montag, 12. Dezember 2016 18:27
> > An: peter.kirme...@ts.fujitsu.com
> > Cc: edk2-devel@lists.01.org
> > Betreff: Re: [edk2] $ escape sequence at build_rule.txt
> >
> >
> >> On Dec 12, 2016, at 2:31 AM, 

Re: [edk2] [patch] UefiCpuPkg/PiSmmCpuDxeSmm: Fix .S & .asm build failure

2016-12-14 Thread Fan, Jeff
Reviewed-by: Jeff Fan 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Feng Tian
Sent: Thursday, December 15, 2016 1:26 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D; Fan, Jeff
Subject: [edk2] [patch] UefiCpuPkg/PiSmmCpuDxeSmm: Fix .S & .asm build failure

Cc: Michael D Kinney 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S   | 1 +
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm | 2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S| 2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm  | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
index 378e065..62f1697 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
@@ -28,6 +28,7 @@ ASM_GLOBAL  ASM_PFX(mXdSupported)  ASM_GLOBAL  
ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))  ASM_GLOBAL  
ASM_PFX(gSmiHandlerIdtr)
 
+.equMSR_IA32_MISC_ENABLE, 0x1A0
 .equMSR_EFER, 0xc080
 .equMSR_EFER_XD, 0x800
 
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
index a4f4dcb..8296f36 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
@@ -202,7 +202,7 @@ _SmiHandler PROC
 calleax
 add esp, 4
 
-mov eax, mXdSupported
+mov eax, offset mXdSupported
 mov al, [eax]
 cmp al, 0
 jz  @f
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S 
b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
index f4761b0..600d862 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
@@ -158,7 +158,7 @@ L13:
 rdmsr
 orw $MSR_EFER_XD,%ax# enable NXE
 wrmsr
-jmp @NxeDone
+jmp NxeDone
 SkipNxe:
 subl$8, %esp
 NxeDone:
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
index e2fcb6f..c74f82a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
@@ -222,7 +222,7 @@ _SmiHandler:
 
 add rsp, 200h
 
-mov rax, ASM_PFX(mXdSupported)
+mov rax, offset ASM_PFX(mXdSupported)
 mov al, [rax]
 cmp al, 0
 jz  @f
--
2.7.1.windows.2

___
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] correct way to reserve memory from PrePi?

2016-12-14 Thread Michael Zimmermann
I've submitted the issue to bugzilla:
https://bugzilla.tianocore.org/show_bug.cgi?id=295

Thanks
Michael

On Thu, Dec 15, 2016 at 6:12 AM, Gao, Liming  wrote:
> Michael:
>   I agree this is an issue that DxeCore doesn't consider the allocated memory 
> range when it allocates the first memory range. Could you submit it in 
> bugzilla with the detail usage model? Then, we can continue to investgate how 
> to resolve it.
>
> Thanks
> Liming
>> -Original Message-
>> From: Michael Zimmermann [mailto:sigmaepsilo...@gmail.com]
>> Sent: Thursday, December 15, 2016 1:02 PM
>> To: Gao, Liming 
>> Cc: Ard Biesheuvel ; edk2-devel@lists.01.org
>> ; Zeng, Star ; Tian, Feng
>> 
>> Subject: Re: [edk2] correct way to reserve memory from PrePi?
>>
>> I do not want to allocate the full memory range, just small parts of
>> it. I have one or two ranges(depending on how the system config
>> reports it) for all ram. e.g a 2gb device usually uses either
>> 0x000-0x8000 or 0x-0x4000 and
>> 0x4000-0x4000.
>>
>> So I digged even further and it looks like upon boot, the highest
>> available memory resource descriptor is selected and allocated for the
>> DxeCore.
>> So if I have one memory resource only, the whole DRAM will be
>> allocated by/for DxeCore. Is that really the intended behavior?
>> Because this way I'm unable to reserve any RAM from the highest
>> resource descriptor. The reason why it works when I have split the
>> DRAM in two descriptors is that DxeCore will only allocate the upper
>> half and I'm usually trying to reserve a few low memory ranges - which
>> isn't always the case.
>>
>> Thanks
>> Michael
>>
>> On Thu, Dec 15, 2016 at 5:55 AM, Gao, Liming  wrote:
>> > Michael:
>> >   I understand your usage that BuildResourceDescriptorHob adds system
>> memory range, BuildMemoryAllocationHob allocate the full memory range as
>> reserved memory. Then, you expect they can be shown in EFI memory map.
>> Right?
>> >
>> >   BuildResourceDescriptorHob() with (start,size) 0x8000,0x8000,
>> then BuildMemoryAllocationHob() with (start,size) 0x8000,0x8000.
>> It doesn't work.
>> >   Two BuildResourceDescriptorHob() with (start,size)
>> 0x8000,0x4000 and 0xc000,0x4000, then two
>> BuildMemoryAllocationHob(). It does work. Right?
>> >
>> > Thanks
>> > Liming
>> >> -Original Message-
>> >> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>> >> Michael Zimmermann
>> >> Sent: Thursday, December 15, 2016 1:57 AM
>> >> To: Ard Biesheuvel 
>> >> Cc: edk2-devel@lists.01.org 
>> >> Subject: Re: [edk2] correct way to reserve memory from PrePi?
>> >>
>> >> I've enabled GCD debugging and apparently it doesn't accept the
>> allocation:
>> >>
>> GCD:AllocateMemorySpace(Base=9000,Length=1
>> >> 000)
>> >>   GcdAllocateType = AtAddress
>> >>   GcdMemoryType   = SystemMem
>> >>   Alignment   = 0001
>> >>   ImageHandle = FDE28F90
>> >>   DeviceHandle= 0
>> >> CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
>> >> CoreAllocateSpace:1130
>> >>   Status = Not Found
>> >> GCDMemType Range Capabilities
>> >> Attributes
>> >> == =
>> >> 
>> >> 
>> >> NonExist   -7FFF 
>> >> 
>> >> SystemMem  8000-FDFF 800E
>> >> *
>> >> NonExist   FE00-FE3F 
>> >> 
>> >> SystemMem  FE40-FFFE5FFF 800E
>> >> 
>> >> SystemMem  FFFE6000-FFFEEFFF 800E
>> >> *
>> >> SystemMem  FFFEF000- 800E
>> >> 
>> >>
>> >>
>> >> It fails in this line:
>> >>
>> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe
>> >> /Gcd/Gcd.c#L982
>> >> In this example I've used(start,size) 0x8000,0x8000 for the
>> >> resource descriptors.
>> >> If I use 0x8000,0x4000 and 0xc000,0x4000 everything
>> >> works just fine.
>> >>
>> >> Thanks
>> >> Michael
>> >>
>> >> On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
>> >>  wrote:
>> >> > As far as I know the proper way is to create resource descriptors
>> >> > using BuildResourceDescriptorHob and then allocate reserved areas
>> >> > using BuildMemoryAllocationHob. This way I don't have any overlapping
>> >> > descriptors - I just allocated some memory very early.
>> >> >
>> >> > I ran many tests and it looks like all calls to
>> >> > BuildMemoryAllocationHob get ignored if my dram hobs look like this:
>> >> > 0x - 0x4000
>> >> 

[edk2] [patch] UefiCpuPkg/PiSmmCpuDxeSmm: Fix .S & .asm build failure

2016-12-14 Thread Feng Tian
Cc: Michael D Kinney 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S   | 1 +
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm | 2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S| 2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm  | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
index 378e065..62f1697 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
@@ -28,6 +28,7 @@ ASM_GLOBAL  ASM_PFX(mXdSupported)
 ASM_GLOBAL  ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))
 ASM_GLOBAL  ASM_PFX(gSmiHandlerIdtr)
 
+.equMSR_IA32_MISC_ENABLE, 0x1A0
 .equMSR_EFER, 0xc080
 .equMSR_EFER_XD, 0x800
 
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
index a4f4dcb..8296f36 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
@@ -202,7 +202,7 @@ _SmiHandler PROC
 calleax
 add esp, 4
 
-mov eax, mXdSupported
+mov eax, offset mXdSupported
 mov al, [eax]
 cmp al, 0
 jz  @f
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S 
b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
index f4761b0..600d862 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
@@ -158,7 +158,7 @@ L13:
 rdmsr
 orw $MSR_EFER_XD,%ax# enable NXE
 wrmsr
-jmp @NxeDone
+jmp NxeDone
 SkipNxe:
 subl$8, %esp
 NxeDone:
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
index e2fcb6f..c74f82a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
@@ -222,7 +222,7 @@ _SmiHandler:
 
 add rsp, 200h
 
-mov rax, ASM_PFX(mXdSupported)
+mov rax, offset ASM_PFX(mXdSupported)
 mov al, [rax]
 cmp al, 0
 jz  @f
-- 
2.7.1.windows.2

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


Re: [edk2] correct way to reserve memory from PrePi?

2016-12-14 Thread Gao, Liming
Michael:
  I agree this is an issue that DxeCore doesn't consider the allocated memory 
range when it allocates the first memory range. Could you submit it in bugzilla 
with the detail usage model? Then, we can continue to investgate how to resolve 
it.  

Thanks
Liming
> -Original Message-
> From: Michael Zimmermann [mailto:sigmaepsilo...@gmail.com]
> Sent: Thursday, December 15, 2016 1:02 PM
> To: Gao, Liming 
> Cc: Ard Biesheuvel ; edk2-devel@lists.01.org
> ; Zeng, Star ; Tian, Feng
> 
> Subject: Re: [edk2] correct way to reserve memory from PrePi?
> 
> I do not want to allocate the full memory range, just small parts of
> it. I have one or two ranges(depending on how the system config
> reports it) for all ram. e.g a 2gb device usually uses either
> 0x000-0x8000 or 0x-0x4000 and
> 0x4000-0x4000.
> 
> So I digged even further and it looks like upon boot, the highest
> available memory resource descriptor is selected and allocated for the
> DxeCore.
> So if I have one memory resource only, the whole DRAM will be
> allocated by/for DxeCore. Is that really the intended behavior?
> Because this way I'm unable to reserve any RAM from the highest
> resource descriptor. The reason why it works when I have split the
> DRAM in two descriptors is that DxeCore will only allocate the upper
> half and I'm usually trying to reserve a few low memory ranges - which
> isn't always the case.
> 
> Thanks
> Michael
> 
> On Thu, Dec 15, 2016 at 5:55 AM, Gao, Liming  wrote:
> > Michael:
> >   I understand your usage that BuildResourceDescriptorHob adds system
> memory range, BuildMemoryAllocationHob allocate the full memory range as
> reserved memory. Then, you expect they can be shown in EFI memory map.
> Right?
> >
> >   BuildResourceDescriptorHob() with (start,size) 0x8000,0x8000,
> then BuildMemoryAllocationHob() with (start,size) 0x8000,0x8000.
> It doesn't work.
> >   Two BuildResourceDescriptorHob() with (start,size)
> 0x8000,0x4000 and 0xc000,0x4000, then two
> BuildMemoryAllocationHob(). It does work. Right?
> >
> > Thanks
> > Liming
> >> -Original Message-
> >> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> >> Michael Zimmermann
> >> Sent: Thursday, December 15, 2016 1:57 AM
> >> To: Ard Biesheuvel 
> >> Cc: edk2-devel@lists.01.org 
> >> Subject: Re: [edk2] correct way to reserve memory from PrePi?
> >>
> >> I've enabled GCD debugging and apparently it doesn't accept the
> allocation:
> >>
> GCD:AllocateMemorySpace(Base=9000,Length=1
> >> 000)
> >>   GcdAllocateType = AtAddress
> >>   GcdMemoryType   = SystemMem
> >>   Alignment   = 0001
> >>   ImageHandle = FDE28F90
> >>   DeviceHandle= 0
> >> CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
> >> CoreAllocateSpace:1130
> >>   Status = Not Found
> >> GCDMemType Range Capabilities
> >> Attributes
> >> == =
> >> 
> >> 
> >> NonExist   -7FFF 
> >> 
> >> SystemMem  8000-FDFF 800E
> >> *
> >> NonExist   FE00-FE3F 
> >> 
> >> SystemMem  FE40-FFFE5FFF 800E
> >> 
> >> SystemMem  FFFE6000-FFFEEFFF 800E
> >> *
> >> SystemMem  FFFEF000- 800E
> >> 
> >>
> >>
> >> It fails in this line:
> >>
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe
> >> /Gcd/Gcd.c#L982
> >> In this example I've used(start,size) 0x8000,0x8000 for the
> >> resource descriptors.
> >> If I use 0x8000,0x4000 and 0xc000,0x4000 everything
> >> works just fine.
> >>
> >> Thanks
> >> Michael
> >>
> >> On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
> >>  wrote:
> >> > As far as I know the proper way is to create resource descriptors
> >> > using BuildResourceDescriptorHob and then allocate reserved areas
> >> > using BuildMemoryAllocationHob. This way I don't have any overlapping
> >> > descriptors - I just allocated some memory very early.
> >> >
> >> > I ran many tests and it looks like all calls to
> >> > BuildMemoryAllocationHob get ignored if my dram hobs look like this:
> >> > 0x - 0x4000
> >> >
> >> > If I split this range into two Hob's like this everything seems to
> >> > work just fine:
> >> > 0x - 0x2000
> >> > 0x2000 - 0x2000
> >> >
> >> > I took a look at other platforms like Juno and they add big dram Hob's
> >> > (2GB and 6GB) too so why is this a problem?

Re: [edk2] correct way to reserve memory from PrePi?

2016-12-14 Thread Gao, Liming
Michael:
  I understand your usage that BuildResourceDescriptorHob adds system memory 
range, BuildMemoryAllocationHob allocate the full memory range as reserved 
memory. Then, you expect they can be shown in EFI memory map. Right? 

  BuildResourceDescriptorHob() with (start,size) 0x8000,0x8000, then 
BuildMemoryAllocationHob() with (start,size) 0x8000,0x8000. It doesn't 
work. 
  Two BuildResourceDescriptorHob() with (start,size) 0x8000,0x4000 and 
0xc000,0x4000, then two BuildMemoryAllocationHob(). It does work. Right?

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Michael Zimmermann
> Sent: Thursday, December 15, 2016 1:57 AM
> To: Ard Biesheuvel 
> Cc: edk2-devel@lists.01.org 
> Subject: Re: [edk2] correct way to reserve memory from PrePi?
> 
> I've enabled GCD debugging and apparently it doesn't accept the allocation:
> GCD:AllocateMemorySpace(Base=9000,Length=1
> 000)
>   GcdAllocateType = AtAddress
>   GcdMemoryType   = SystemMem
>   Alignment   = 0001
>   ImageHandle = FDE28F90
>   DeviceHandle= 0
> CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
> CoreAllocateSpace:1130
>   Status = Not Found
> GCDMemType Range Capabilities
> Attributes
> == =
> 
> 
> NonExist   -7FFF 
> 
> SystemMem  8000-FDFF 800E
> *
> NonExist   FE00-FE3F 
> 
> SystemMem  FE40-FFFE5FFF 800E
> 
> SystemMem  FFFE6000-FFFEEFFF 800E
> *
> SystemMem  FFFEF000- 800E
> 
> 
> 
> It fails in this line:
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe
> /Gcd/Gcd.c#L982
> In this example I've used(start,size) 0x8000,0x8000 for the
> resource descriptors.
> If I use 0x8000,0x4000 and 0xc000,0x4000 everything
> works just fine.
> 
> Thanks
> Michael
> 
> On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
>  wrote:
> > As far as I know the proper way is to create resource descriptors
> > using BuildResourceDescriptorHob and then allocate reserved areas
> > using BuildMemoryAllocationHob. This way I don't have any overlapping
> > descriptors - I just allocated some memory very early.
> >
> > I ran many tests and it looks like all calls to
> > BuildMemoryAllocationHob get ignored if my dram hobs look like this:
> > 0x - 0x4000
> >
> > If I split this range into two Hob's like this everything seems to
> > work just fine:
> > 0x - 0x2000
> > 0x2000 - 0x2000
> >
> > I took a look at other platforms like Juno and they add big dram Hob's
> > (2GB and 6GB) too so why is this a problem?
> >
> > Thanks
> > Michael
> >
> > On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
> >  wrote:
> >> On 14 December 2016 at 10:02, Michael Zimmermann
> >>  wrote:
> >>> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
> >>> but apparently they don't have any effect.
> >>> When I look at the output of the shell's memmap command there aren't
> >>> any reserved/unavailable pages.
> >>>
> >>> Furthermore, when using AllocatePages with one of the physical
> >>> addresses which I've reserved it succeeds which means that it's not
> >>> just a problem of how the memmap command works.
> >>>
> >>> Am I doing something wrong or is this a bug?
> >>>
> >>
> >> I think you need to ensure that they don't overlap existing resource
> >> descriptors: if you declare a region as reserved, you should not
> >> declare it as memory first
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] ArmLib : GIC Pcds in "ArmPkg/Library/ArmLib/ArmBaseLib.inf"

2016-12-14 Thread Meenakshi Aggarwal
Hi,


I need to modify GicDistributorBase and GicInterruptInterfaceBase Pcds on run 
time, so I need these to be dynamic.
But on doing same I am facing errors, because these Pcds are included under 
[FixedPcd] section in ArmBaseLib.inf and I am using ArmLib.


[FixedPcd]
  gArmTokenSpaceGuid.PcdGicDistributorBase
  gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase


Is there any particular reason behind including these Pcds in ArmBaseLib.inf, 
as ArmLib is not using these Pcds anywhere.

I removed these Pcds from ArmBaseLib.inf and I didn't face any issue, neither 
in compilation nor in execution.


Please tell me the relevance of including these Pcds in ArmBaseLib.inf.



Thanks & Regards,
Meenakshi



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


[edk2] GIC Pcds in "ArmPkg/Library/ArmLib/ArmBaseLib.inf"

2016-12-14 Thread Meenakshi Aggarwal
Hi,



I need to modify GicDistributorBase and GicInterruptInterfaceBase Pcds on run 
time, so I need these to be dynamic.
But on doing same I am facing errors, because these Pcds are included under 
[FixedPcd] section in ArmBaseLib.inf and I am using ArmLib.


[FixedPcd]
  gArmTokenSpaceGuid.PcdGicDistributorBase
  gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase


Is there any particular reason behind including these Pcds in ArmBaseLib.inf, 
as ArmLib is not using these Pcds anywhere.

I removed these Pcds from ArmBaseLib.inf and I didn't face any issue, neither 
in compilation nor in execution.


Please tell me the relevance of including these Pcds in ArmBaseLib.inf.


Thanks & Regards,
Meenakshi






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


Re: [edk2] OVMF: cross-filesystem copy broken? ("The source and destination are the same")

2016-12-14 Thread Gao, Liming
This should be root cause. 

edk2\MdePkg\Library\BaseLib\String.c line 554 to implement 
InternalCharToUpper() with EFIAPI.
CHAR16
EFIAPI
InternalCharToUpper (
  IN  CHAR16Char
  )

edk2\ShellPkg\Library\UefiShellLevel2CommandsLib\UefiShellLevel2CommandsLib.c 
line 271 declares it without EFIAPI. So, they don't match each other. 
CHAR16
InternalCharToUpper (
  IN CONST CHAR16Char
  );

Thanks
Liming
> -Original Message-
> From: Palmer, Thomas [mailto:thomas.pal...@hpe.com]
> Sent: Thursday, December 15, 2016 6:09 AM
> To: Laszlo Ersek ; Bruce Cran ;
> edk2-devel (edk2-devel@lists.01.org) 
> Cc: Wu, Hao A ; Ni, Ruiyu ; Gao,
> Liming 
> Subject: RE: [edk2] OVMF: cross-filesystem copy broken? ("The source and
> destination are the same")
> 
> Laszlo, et al~
> 
> I recently encountered a "cp" failure on OVMF whereby cp always thought
> my source and destination file paths were equivalent.  Turns out that
> StrniCmp function was broken b/c the InternalCharToUpper declaration in
> UefiShellLevel2CommandsLib.c was missing the EFIAPI token.  Once I added
> EFIAPI back, my cp command worked.
> 
> I'm on vacation so I can't write up a formal patch right now.   Give it a try 
> and
> if it works please write up a patch, else I'll get back to it when I get back.
> 
> 
> Regards,
> 
> Thomas Palmer
> 
> "I have only made this letter longer because I have not had the time to make
> it shorter" - Blaise Pascal
> 
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Laszlo Ersek
> Sent: Thursday, November 17, 2016 10:07 AM
> To: Bruce Cran ; edk2-devel (edk2-devel@lists.01.org)
> 
> Cc: Wu, Hao A ; Ni, Ruiyu ; Gao,
> Liming 
> Subject: Re: [edk2] OVMF: cross-filesystem copy broken? ("The source and
> destination are the same")
> 
> On 11/17/16 16:24, Bruce Cran wrote:
> > On 11/17/2016 2:35 AM, Laszlo Ersek wrote:
> >
> >> There's a patch on the list for said BZ:
> >> [edk2] [PATCH v2] API PathRemoveLastItem not handle root paths
> >> properly
> >>
> >> so if the BZ is indeed what you're encountering, then the patch
> >> should fix it for you. Can you please test it and report back in that 
> >> thread?
> >
> > Unfortunately the patch doesn't fix the problem I'm seeing.
> >
> 
> Thanks for trying it.
> 
> Unfortunately, I can't find the time to dig into this now. And, I think it's 
> likely
> related to ShellPkg anyway. Can you please help by filing a BZ for ShellPkg,
> and/or bisecting the issue (assuming you remember the same command
> working at some point)?
> 
> ... I observe that the least recent commit that affected "Cp.c" with any
> potential to break it like this could be
> 
> commit fbd2dfadfe6fb16ab7b49fca3764e05e65d97b8a
> Author: Qiu Shumin 
> Date:   Fri Oct 23 02:03:20 2015 +
> 
> ShellPkg: Follow spec to remove the last '\' char in return name of
> GetCurDir().
> 
> but that commit is more than a year old now... So I'm not sure. Could be one
> of the underlying helper functions. Time to pull out GDB and single step the
> code? :)
> 
> Thanks!
> Laszlo
> ___
> 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/6] NetworkPkg: Refine UintnToAscDecWithFormat functions logic

2016-12-14 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 


-Original Message-
From: Wu, Hao A 
Sent: 2016年12月14日 19:27
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Fu, Siyuan ; Ye, Ting 
; Wu, Jiaxin 
Subject: [PATCH 6/6] NetworkPkg: Refine UintnToAscDecWithFormat functions logic

This commit refines the logic for HttpBootUintnToAscDecWithFormat and 
PxeBcUintnToAscDecWithFormat. It avoids using the decrement operator '--'
for array index to prevent possible mis-reports by static code checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 NetworkPkg/HttpBootDxe/HttpBootSupport.c | 5 ++---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c   | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c 
b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index 9410bf9..bdb29ae 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -86,11 +86,10 @@ HttpBootUintnToAscDecWithFormat (  {
   UINTN  Remainder;
 
-  while (Length > 0) {
-Length--;
+  for (; Length > 0; Length--) {
 Remainder  = Number % 10;
 Number/= 10;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index 00c652d..568360d 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -1383,11 +1383,10 @@ PxeBcUintnToAscDecWithFormat (  {
   UINTN  Remainder;
 
-  while (Length > 0) {
-Length--;
+  for (; Length > 0; Length--) {
 Remainder  = Number % 10;
 Number/= 10;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
--
1.9.5.msysgit.0

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


Re: [edk2] [PATCH 5/6] MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic

2016-12-14 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 


-Original Message-
From: Wu, Hao A 
Sent: 2016年12月14日 19:27
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Fu, Siyuan ; Ye, Ting 
; Wu, Jiaxin 
Subject: [PATCH 5/6] MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic

This commit refines the logic for the CvtNum function. It avoids using the 
decrement operator '--' for array index to prevent possible mis-reports by 
static code checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
index 0865ddd..0779056 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
@@ -132,11 +132,10 @@ CvtNum (
 {
   UINTN Remainder;
 
-  while (Length > 0) {
+  for (; Length > 0; Length--) {
 Remainder = Number % 10;
 Number /= 10;
-Length--;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
--
1.9.5.msysgit.0

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


Re: [edk2] [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic

2016-12-14 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 


-Original Message-
From: Wu, Hao A 
Sent: 2016年12月14日 19:27
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Fu, Siyuan ; Ye, Ting 
; Wu, Jiaxin 
Subject: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function 
logic

This commit rewrites the logic for NetblockChecksum. It processes the checksum 
of the left-over byte first to prevent possible mis-reports by static code 
checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c 
b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
index bbbdbc0..95cb717 100644
--- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
+++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
@@ -1,7 +1,7 @@
 /** @file
   Network library functions providing net buffer operation support.
 
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 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 @@ -1661,6 +1661,13 
@@ NetblockChecksum (
 
   Sum = 0;
 
+  //
+  // Add left-over byte, if any
+  //
+  if (Len % 2 != 0) {
+Sum += *(Bulk + Len - 1);
+  }
+
   while (Len > 1) {
 Sum += *(UINT16 *) Bulk;
 Bulk += 2;
@@ -1668,13 +1675,6 @@ NetblockChecksum (
   }
 
   //
-  // Add left-over byte, if any
-  //
-  if (Len > 0) {
-Sum += *(UINT8 *) Bulk;
-  }
-
-  //
   // Fold 32-bit sum to 16 bits
   //
   while ((Sum >> 16) != 0) {
--
1.9.5.msysgit.0

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


Re: [edk2] [PATCH v2 10/10] Nt32Pkg: Enable HTTPS boot feature for Nt32 platform

2016-12-14 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 





-Original Message-
From: Wu, Jiaxin 
Sent: 2016年12月14日 16:05
To: edk2-devel@lists.01.org
Cc: Long, Qin ; Ni, Ruiyu ; Ye, Ting 
; Fu, Siyuan ; Zhang, Lubo 
; Thomas Palmer ; Yao, Jiewen 
; Wu, Jiaxin 
Subject: [PATCH v2 10/10] Nt32Pkg: Enable HTTPS boot feature for Nt32 platform

v2:
* Rename flag: HTTPS_BOOT_ENABLE -> TLS_ENABLE

This path is used to enable HTTPS boot feature for Nt32 platform.

Cc: Long Qin 
Cc: Ni Ruiyu 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Thomas Palmer 
Cc: Yao Jiewen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 Nt32Pkg/Nt32Pkg.dsc | 15 ++-  Nt32Pkg/Nt32Pkg.fdf |  4 
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc index 79ab2f7..0a59e46 
100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -43,10 +43,17 @@
   #
   # Defines for default states.  These can be changed on the command line.
   # -D FLAG=VALUE
   #
   DEFINE SECURE_BOOT_ENABLE  = FALSE
+  
+  #
+  # This flag is to enable or disable TLS feature.  
+  # These can be changed on the command line.
+  # -D FLAG=VALUE
+  #
+  DEFINE TLS_ENABLE  = TRUE
 
 

 #
 # SKU Identification section - list of all SKU IDs supported by this
 #  Platform.
@@ -189,10 +196,11 @@
   
OemHookStatusCodeLib|Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.inf
   
PeCoffExtraActionLib|Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.inf
   
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
   WinNtLib|Nt32Pkg/Library/DxeWinNtLib/DxeWinNtLib.inf
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+  TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
 
 [LibraryClasses.common.DXE_CORE]
   HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
   
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
@@ -232,11 +240,11 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x1f
   gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume|L"..\\Fv\\Nt32.fd"
   gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareBlockSize|0x1
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
-!if $(SECURE_BOOT_ENABLE) == TRUE
+!if $(SECURE_BOOT_ENABLE) == TRUE || $(TLS_ENABLE) == TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
 !endif
 
 !ifndef $(USE_OLD_SHELL)
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 
0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } 
@@ -437,10 +445,15 @@
 
   NetworkPkg/HttpBootDxe/HttpBootDxe.inf
   NetworkPkg/DnsDxe/DnsDxe.inf
   NetworkPkg/HttpDxe/HttpDxe.inf
   NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
+   
+!if $(TLS_ENABLE) == TRUE
+  NetworkPkg/TlsDxe/TlsDxe.inf
+  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
+!endif
 
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   MdeModulePkg/Application/UiApp/UiApp.inf{
 
   NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf index cf00a13..c198d73 
100644
--- a/Nt32Pkg/Nt32Pkg.fdf
+++ b/Nt32Pkg/Nt32Pkg.fdf
@@ -260,10 +260,14 @@ INF  
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
 INF  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
 INF  NetworkPkg/HttpBootDxe/HttpBootDxe.inf
 INF  NetworkPkg/DnsDxe/DnsDxe.inf
 INF  NetworkPkg/HttpDxe/HttpDxe.inf
 INF  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
+!if $(TLS_ENABLE) == TRUE
+INF  NetworkPkg/TlsDxe/TlsDxe.inf
+INF  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
+!endif
 INF  MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
 

 #
 # FILE statements are provided so that a platform integrator can include  # 
complete EFI FFS files, as well as a method for constructing FFS files
--
1.9.5.msysgit.1

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


Re: [edk2] [Patch 07/10] NetworkPkg/HttpDxe: HTTPS support over IPv4 and IPv6

2016-12-14 Thread Fu, Siyuan
Hi, Jiaxin

In function IsHttpsUrl(), I suggest to search string "https://; instead of only 
"https", in case of some incorrect scheme like "httpsabc://".
However, since there is already code to parse the URL by using HttpParseUrl(), 
the scheme should already been known by the Http url parser, I think it better 
to add a new function to the HttpLib like HttpUrlGetScheme().

Reviewed-by: Fu Siyuan 


-Original Message-
From: Wu, Jiaxin 
Sent: 2016年12月14日 15:34
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Zhang, Lubo 
; Long, Qin ; Thomas Palmer 
; Wu, Jiaxin 
Subject: [Patch 07/10] NetworkPkg/HttpDxe: HTTPS support over IPv4 and IPv6

This patch is used to enable HTTPS feature. HttpDxe driver
will consume TlsDxe driver. It can both support http and https
feature, that’s depended on the information of URL, the HTTP
instance can be able to determine whether to use http or https.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Long Qin 
Cc: Thomas Palmer 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpDriver.h   |   10 +-
 NetworkPkg/HttpDxe/HttpDxe.inf|   12 +-
 NetworkPkg/HttpDxe/HttpImpl.c |  252 +-
 NetworkPkg/HttpDxe/HttpProto.c|  464 +++---
 NetworkPkg/HttpDxe/HttpProto.h|   65 +-
 NetworkPkg/HttpDxe/HttpsSupport.c | 1692 +
 NetworkPkg/HttpDxe/HttpsSupport.h |  260 ++
 7 files changed, 2601 insertions(+), 154 deletions(-)
 create mode 100644 NetworkPkg/HttpDxe/HttpsSupport.c
 create mode 100644 NetworkPkg/HttpDxe/HttpsSupport.h

diff --git a/NetworkPkg/HttpDxe/HttpDriver.h b/NetworkPkg/HttpDxe/HttpDriver.h
index fa2372c..93a412a 100644
--- a/NetworkPkg/HttpDxe/HttpDriver.h
+++ b/NetworkPkg/HttpDxe/HttpDriver.h
@@ -22,10 +22,11 @@
 
 //
 // Libraries
 //
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
@@ -48,17 +49,23 @@
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
-
+#include 
 //
 // Produced Protocols
 //
 #include 
 
+#include 
+
+#include 
+
 //
 // Driver Version
 //
 #define HTTP_DRIVER_VERSION 0xa
 
@@ -77,10 +84,11 @@ extern EFI_HTTP_UTILITIES_PROTOCOL  *mHttpUtilities;
 // Include files with function prototypes
 //
 #include "ComponentName.h"
 #include "HttpImpl.h"
 #include "HttpProto.h"
+#include "HttpsSupport.h"
 #include "HttpDns.h"
 
 typedef struct {
   EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
   UINTN NumberOfChildren;
diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf b/NetworkPkg/HttpDxe/HttpDxe.inf
index bf2cbee..1118181 100644
--- a/NetworkPkg/HttpDxe/HttpDxe.inf
+++ b/NetworkPkg/HttpDxe/HttpDxe.inf
@@ -1,9 +1,9 @@
 ## @file
 #  Implementation of EFI HTTP protocol interfaces.
 #
-#  Copyright (c) 2015, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 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.
@@ -24,10 +24,11 @@
   MODULE_UNI_FILE   = HttpDxe.uni
 
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
+  NetworkPkg/NetworkPkg.dec
 
 [Sources]
   ComponentName.h
   ComponentName.c
   HttpDns.h
@@ -36,14 +37,17 @@
   HttpDriver.c
   HttpImpl.h
   HttpImpl.c
   HttpProto.h
   HttpProto.c
+  HttpsSupport.h
+  HttpsSupport.c
 
 [LibraryClasses]
   UefiDriverEntryPoint
   UefiBootServicesTableLib
+  UefiRuntimeServicesTableLib
   MemoryAllocationLib
   BaseLib
   UefiLib
   DebugLib
   NetLib
@@ -62,8 +66,14 @@
   gEfiDns4ProtocolGuid ## SOMETIMES_CONSUMES
   gEfiDns6ServiceBindingProtocolGuid   ## SOMETIMES_CONSUMES
   gEfiDns6ProtocolGuid ## SOMETIMES_CONSUMES
   gEfiIp4Config2ProtocolGuid   ## SOMETIMES_CONSUMES
   gEfiIp6ConfigProtocolGuid## SOMETIMES_CONSUMES
+  gEfiTlsServiceBindingProtocolGuid## SOMETIMES_CONSUMES
+  gEfiTlsProtocolGuid  ## SOMETIMES_CONSUMES
+  gEfiTlsConfigurationProtocolGuid ## SOMETIMES_CONSUMES
+
+[Guids]
+  gEfiTlsCaCertificateGuid ## CONSUMES  ## GUID
 
 [UserExtensions.TianoCore."ExtraFiles"]
   HttpDxeExtra.uni
\ No newline at end of file
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 6fcb0b7..77aa64a 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -239,10 +239,11 @@ EfiHttpRequest (
   

Re: [edk2] [Patch 08/10] NetworkPkg/NetworkPkg.dsc: Enable TlsDxe and TlsAuthConfigDxe module

2016-12-14 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 





-Original Message-
From: Wu, Jiaxin 
Sent: 2016年12月14日 15:34
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Zhang, Lubo 
; Long, Qin ; Thomas Palmer 
; Wu, Jiaxin 
Subject: [Patch 08/10] NetworkPkg/NetworkPkg.dsc: Enable TlsDxe and 
TlsAuthConfigDxe module

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Long Qin 
Cc: Thomas Palmer 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/NetworkPkg.dsc | 4 
 1 file changed, 4 insertions(+)

diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc index 
1ef353e..3d881e9 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -53,12 +53,14 @@
   TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
   HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
   IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
  
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+  
+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.i
+ nf
   SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
 
 [LibraryClasses.common.UEFI_DRIVER]
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -111,10 +113,12 @@
   NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf
   NetworkPkg/DnsDxe/DnsDxe.inf
   NetworkPkg/HttpDxe/HttpDxe.inf
   NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
   NetworkPkg/HttpBootDxe/HttpBootDxe.inf
+  NetworkPkg/TlsDxe/TlsDxe.inf
+  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
 
   NetworkPkg/Application/IfConfig6/IfConfig6.inf
   NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
   NetworkPkg/Application/VConfig/VConfig.inf
 
--
1.9.5.msysgit.1

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


Re: [edk2] [PATCH v5] BaseTools/Scripts/PatchCheck.py: Extended patch style check for c code

2016-12-14 Thread Jordan Justen
The patch subject seems too generic, but I think that is because the
patch is doing too many things at once.

(See more comments below.)

On 2016-12-13 06:15:18, Daniil Egranov wrote:
> Corrected code checking for multi-line and commented lines. Both 
> multi-line and open comment flags will be reset when leaving
> diff "+" area of the patch.
> Changed version of the tool to 0.2.
>  
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Daniil Egranov 
> ---
> Changelog:
> 
> v4
> Corrected maximum code line size to 120 characters.
> 
> v3
> Corrected space detection before parentheses. 
> 
> v2:
> Fixed several indentation cases
> 
> v1:
> Fixed reporting signature error for a cover letter.
> Fixed reporting line size error for a file change information
> included in the commit message.
> Fixed line number reported in PatchCheck error messages. It
> points to the correct line in the diff file.
> The patch extends style checking for c code:
>  Added check for code indentation.
>  Added report line size greater than 80 characters.
>  Added checking for space before '('.
>  Added checking for space before '{'.
>  Added checking for '}' to be on a new line and have spaces
>  for "} else {" or "} while ()" cases.
> 
>  BaseTools/Scripts/PatchCheck.py | 263 
> 
>  1 file changed, 238 insertions(+), 25 deletions(-)
> 
> diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
> index 7c30082..2406601 100755
> --- a/BaseTools/Scripts/PatchCheck.py
> +++ b/BaseTools/Scripts/PatchCheck.py
> @@ -15,7 +15,7 @@
>  
>  from __future__ import print_function
>  
> -VersionNumber = '0.1'
> +VersionNumber = '0.2'
>  __copyright__ = "Copyright (c) 2015 - 2016, Intel Corporation  All rights 
> reserved."
>  
>  import email
> @@ -32,7 +32,7 @@ class Verbose:
>  class CommitMessageCheck:
>  """Checks the contents of a git commit message."""
>  
> -def __init__(self, subject, message):
> +def __init__(self, subject, message, message_offset, cover):
>  self.ok = True
>  
>  if subject is None and  message is None:
> @@ -41,9 +41,15 @@ class CommitMessageCheck:
>  
>  self.subject = subject
>  self.msg = message
> +self.msg_offset = message_offset
> +self.cover = cover
> +
> +if not cover:
> +self.check_contributed_under()
> +self.check_signed_off_by()
> +else:
> +print('The commit message is cover letter.')

I think this patch is doing way too many things for a single patch.
For example, I think this cover letter check should be a separate
patch.

>  
> -self.check_contributed_under()
> -self.check_signed_off_by()
>  self.check_misc_signatures()
>  self.check_overall_format()
>  self.report_message_result()
> @@ -180,6 +186,9 @@ class CommitMessageCheck:
>  for sig in self.sig_types:
>  self.find_signatures(sig)
>  
> +diff_change_info_re = \
> +re.compile(r'.*\|\s+(\d|Bin)*\s.*[\+\-]')
> +
>  def check_overall_format(self):
>  lines = self.msg.splitlines()
>  
> @@ -197,9 +206,10 @@ class CommitMessageCheck:
>  self.error('Empty commit message!')
>  return
>  
> -if count >= 1 and len(lines[0]) >= 72:
> +if count >= 1 and len(lines[0]) > 72:

I think you are reverting e61406708c83f96d3dc2e8899716cce43c058491
here, but I don't think you meant too. If you had smaller, focused
patches, it would less likely for things like this to get lost in the
noise...

>  self.error('First line of commit message (subject line) ' +
> -   'is too long.')
> +   'is too long (%d) (max 72 characters):' 
> %(len(lines[0])))
> +print(lines[0], '\n')

Why is the extra print added here?

>  
>  if count >= 1 and len(lines[0].strip()) == 0:
>  self.error('First line of commit message (subject line) ' +
> @@ -210,10 +220,13 @@ class CommitMessageCheck:
> 'empty.')
>  
>  for i in range(2, count):
> -if (len(lines[i]) >= 76 and
> +if (len(lines[i]) > 76 and
>  len(lines[i].split()) > 1 and
> -not lines[i].startswith('git-svn-id:')):
> -self.error('Line %d of commit message is too long.' % (i + 
> 1))
> +not lines[i].startswith('git-svn-id:') and
> +self.diff_change_info_re.search(lines[i]) is None):
> +self.error('Line %d of commit message is too long (%d) (max 
> 76 characters):' \

I don't think you need the '\' here since python keeps looking on
lines if it is within '(' like in the function call to self.error. In
fact, I think it is best to try to avoid code that requires the '\',
although in rare cases, it might be okay.

> +   % (i + self.msg_offset - 1, 

Re: [edk2] [Patch 06/10] NetworkPkg/TlsAuthConfigDxe: Provide the UI to support TLS auth configuration

2016-12-14 Thread Fu, Siyuan
Hi, Jiaxin

PrintLib support "%g" to print a GUID so you don't need to use 
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" in GuidToString(). 
Beside of that, I do see a lot of drivers has similar internal function 
StringToGuid() or StrToGuid(), do we have a common library interface for this? 
if not I think it may worth to create one.

Other parts are good with me.
Reviewed-by: Fu Siyuan 


Best Regards
Siyuan

-Original Message-
From: Wu, Jiaxin 
Sent: 2016年12月14日 15:34
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Zhang, Lubo 
; Long, Qin ; Thomas Palmer 
; Wu, Jiaxin 
Subject: [Patch 06/10] NetworkPkg/TlsAuthConfigDxe: Provide the UI to support 
TLS auth configuration

This patch provides the UI to support TLS auth configuration.
* EFI_SIGNATURE_LIST format is used for 'TlsCaCertificate'
variable. So, TLS supports multiple certificate configuration.
* The variable attribute is BS with NV, which only target at
preventing runtime phase attack.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Long Qin 
Cc: Thomas Palmer 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/Include/Guid/TlsAuthConfigHii.h |   25 +
 NetworkPkg/Include/Guid/TlsAuthentication.h|   29 +
 NetworkPkg/NetworkPkg.dec  |7 +
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c |  135 ++
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf   |   73 +
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.uni   |   21 +
 .../TlsAuthConfigDxe/TlsAuthConfigDxeExtra.uni |   19 +
 .../TlsAuthConfigDxe/TlsAuthConfigDxeStrings.uni   |   39 +
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c| 1841 
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.h|  282 +++
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigNvData.h  |   49 +
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigVfr.vfr   |  152 ++
 12 files changed, 2672 insertions(+)
 create mode 100644 NetworkPkg/Include/Guid/TlsAuthConfigHii.h
 create mode 100644 NetworkPkg/Include/Guid/TlsAuthentication.h
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.uni
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxeExtra.uni
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxeStrings.uni
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.h
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigNvData.h
 create mode 100644 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigVfr.vfr

diff --git a/NetworkPkg/Include/Guid/TlsAuthConfigHii.h 
b/NetworkPkg/Include/Guid/TlsAuthConfigHii.h
new file mode 100644
index 000..9d21426
--- /dev/null
+++ b/NetworkPkg/Include/Guid/TlsAuthConfigHii.h
@@ -0,0 +1,25 @@
+/** @file
+  GUIDs used as HII FormSet and HII Package list GUID in TlsAuthConfigDxe 
driver. 
+  
+Copyright (c) 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 that 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 __TLS_AUTH_CONFIG_HII_GUID_H__
+#define __TLS_AUTH_CONFIG_HII_GUID_H__
+
+#define TLS_AUTH_CONFIG_GUID \
+  { \
+0xb0eae4f8, 0x9a04, 0x4c6d, { 0xa7, 0x48, 0x79, 0x3d, 0xaa, 0xf, 0x65, 
0xdf } \
+  }
+
+extern EFI_GUID gTlsAuthConfigGuid;
+
+#endif
diff --git a/NetworkPkg/Include/Guid/TlsAuthentication.h 
b/NetworkPkg/Include/Guid/TlsAuthentication.h
new file mode 100644
index 000..2e800dc
--- /dev/null
+++ b/NetworkPkg/Include/Guid/TlsAuthentication.h
@@ -0,0 +1,29 @@
+/** @file
+  This file defines TlsCaCertificate variable.
+  
+Copyright (c) 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 that 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 __TLS_AUTHENTICATION_H__
+#define 

Re: [edk2] OVMF: cross-filesystem copy broken? ("The source and destination are the same")

2016-12-14 Thread Palmer, Thomas
Laszlo, et al~

I recently encountered a "cp" failure on OVMF whereby cp always thought my 
source and destination file paths were equivalent.  Turns out that StrniCmp 
function was broken b/c the InternalCharToUpper declaration in 
UefiShellLevel2CommandsLib.c was missing the EFIAPI token.  Once I added EFIAPI 
back, my cp command worked.

I'm on vacation so I can't write up a formal patch right now.   Give it a try 
and if it works please write up a patch, else I'll get back to it when I get 
back.


Regards,

Thomas Palmer

"I have only made this letter longer because I have not had the time to make it 
shorter" - Blaise Pascal


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
Ersek
Sent: Thursday, November 17, 2016 10:07 AM
To: Bruce Cran ; edk2-devel (edk2-devel@lists.01.org) 

Cc: Wu, Hao A ; Ni, Ruiyu ; Gao, Liming 

Subject: Re: [edk2] OVMF: cross-filesystem copy broken? ("The source and 
destination are the same")

On 11/17/16 16:24, Bruce Cran wrote:
> On 11/17/2016 2:35 AM, Laszlo Ersek wrote:
> 
>> There's a patch on the list for said BZ:
>> [edk2] [PATCH v2] API PathRemoveLastItem not handle root paths 
>> properly
>>
>> so if the BZ is indeed what you're encountering, then the patch 
>> should fix it for you. Can you please test it and report back in that thread?
> 
> Unfortunately the patch doesn't fix the problem I'm seeing.
> 

Thanks for trying it.

Unfortunately, I can't find the time to dig into this now. And, I think it's 
likely related to ShellPkg anyway. Can you please help by filing a BZ for 
ShellPkg, and/or bisecting the issue (assuming you remember the same command 
working at some point)?

... I observe that the least recent commit that affected "Cp.c" with any 
potential to break it like this could be

commit fbd2dfadfe6fb16ab7b49fca3764e05e65d97b8a
Author: Qiu Shumin 
Date:   Fri Oct 23 02:03:20 2015 +

ShellPkg: Follow spec to remove the last '\' char in return name of 
GetCurDir().

but that commit is more than a year old now... So I'm not sure. Could be one of 
the underlying helper functions. Time to pull out GDB and single step the code? 
:)

Thanks!
Laszlo
___
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] correct way to reserve memory from PrePi?

2016-12-14 Thread Michael Zimmermann
I've enabled GCD debugging and apparently it doesn't accept the allocation:
GCD:AllocateMemorySpace(Base=9000,Length=1000)
  GcdAllocateType = AtAddress
  GcdMemoryType   = SystemMem
  Alignment   = 0001
  ImageHandle = FDE28F90
  DeviceHandle= 0
CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
CoreAllocateSpace:1130
  Status = Not Found
GCDMemType Range Capabilities
Attributes
== = 

NonExist   -7FFF 

SystemMem  8000-FDFF 800E
*
NonExist   FE00-FE3F 

SystemMem  FE40-FFFE5FFF 800E

SystemMem  FFFE6000-FFFEEFFF 800E
*
SystemMem  FFFEF000- 800E 


It fails in this line:
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Gcd/Gcd.c#L982
In this example I've used(start,size) 0x8000,0x8000 for the
resource descriptors.
If I use 0x8000,0x4000 and 0xc000,0x4000 everything
works just fine.

Thanks
Michael

On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
 wrote:
> As far as I know the proper way is to create resource descriptors
> using BuildResourceDescriptorHob and then allocate reserved areas
> using BuildMemoryAllocationHob. This way I don't have any overlapping
> descriptors - I just allocated some memory very early.
>
> I ran many tests and it looks like all calls to
> BuildMemoryAllocationHob get ignored if my dram hobs look like this:
> 0x - 0x4000
>
> If I split this range into two Hob's like this everything seems to
> work just fine:
> 0x - 0x2000
> 0x2000 - 0x2000
>
> I took a look at other platforms like Juno and they add big dram Hob's
> (2GB and 6GB) too so why is this a problem?
>
> Thanks
> Michael
>
> On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
>  wrote:
>> On 14 December 2016 at 10:02, Michael Zimmermann
>>  wrote:
>>> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
>>> but apparently they don't have any effect.
>>> When I look at the output of the shell's memmap command there aren't
>>> any reserved/unavailable pages.
>>>
>>> Furthermore, when using AllocatePages with one of the physical
>>> addresses which I've reserved it succeeds which means that it's not
>>> just a problem of how the memmap command works.
>>>
>>> Am I doing something wrong or is this a bug?
>>>
>>
>> I think you need to ensure that they don't overlap existing resource
>> descriptors: if you declare a region as reserved, you should not
>> declare it as memory first
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] correct way to reserve memory from PrePi?

2016-12-14 Thread Michael Zimmermann
As far as I know the proper way is to create resource descriptors
using BuildResourceDescriptorHob and then allocate reserved areas
using BuildMemoryAllocationHob. This way I don't have any overlapping
descriptors - I just allocated some memory very early.

I ran many tests and it looks like all calls to
BuildMemoryAllocationHob get ignored if my dram hobs look like this:
0x - 0x4000

If I split this range into two Hob's like this everything seems to
work just fine:
0x - 0x2000
0x2000 - 0x2000

I took a look at other platforms like Juno and they add big dram Hob's
(2GB and 6GB) too so why is this a problem?

Thanks
Michael

On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
 wrote:
> On 14 December 2016 at 10:02, Michael Zimmermann
>  wrote:
>> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
>> but apparently they don't have any effect.
>> When I look at the output of the shell's memmap command there aren't
>> any reserved/unavailable pages.
>>
>> Furthermore, when using AllocatePages with one of the physical
>> addresses which I've reserved it succeeds which means that it's not
>> just a problem of how the memmap command works.
>>
>> Am I doing something wrong or is this a bug?
>>
>
> I think you need to ensure that they don't overlap existing resource
> descriptors: if you declare a region as reserved, you should not
> declare it as memory first
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 0/6] Refine code logics to prevent possible mis-reports by static code checkers

2016-12-14 Thread Hao Wu
The series refines the loop logic (e.g. for, while) of some functions to
be more straightforward. This will help to prevent some possible
mis-reports by static code checkers

Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 

Hao Wu (6):
  MdePkg/BaseLib: Refine (Ascii)StrnLenS functions logic
  MdePkg/BaseLib: Add an additional check within (Ascii)StrnCmp
  MdePkg/MemoryLib: Refine InternalMemSetMem16|32|64 functions logic
  MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic
  MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic
  NetworkPkg: Refine UintnToAscDecWithFormat functions logic

 MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 16 
 .../Universal/Network/UefiPxeBcDxe/PxeBcSupport.c  |  5 ++---
 MdePkg/Library/BaseLib/SafeString.c| 16 
 MdePkg/Library/BaseLib/String.c|  4 +++-
 MdePkg/Library/BaseMemoryLib/MemLibGeneric.c   | 18 +-
 MdePkg/Library/PeiMemoryLib/MemLibGeneric.c| 18 +-
 MdePkg/Library/UefiMemoryLib/MemLibGeneric.c   | 18 +-
 NetworkPkg/HttpBootDxe/HttpBootSupport.c   |  5 ++---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c |  5 ++---
 9 files changed, 56 insertions(+), 49 deletions(-)

-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 1/6] MdePkg/BaseLib: Refine (Ascii)StrnLenS functions logic

2016-12-14 Thread Hao Wu
This commit refines the logic for AsciiStrnLenS and StrnLenS. It makes the
logic more straightforward to prevent possible mis-reports by static code
checkers.

Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdePkg/Library/BaseLib/SafeString.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseLib/SafeString.c 
b/MdePkg/Library/BaseLib/SafeString.c
index ede2f4c..3247d28 100644
--- a/MdePkg/Library/BaseLib/SafeString.c
+++ b/MdePkg/Library/BaseLib/SafeString.c
@@ -143,8 +143,12 @@ StrnLenS (
   // String then StrnLenS returns MaxSize. At most the first MaxSize 
characters of String shall
   // be accessed by StrnLenS.
   //
-  for (Length = 0; (Length < MaxSize) && (*String != 0); String++, Length++) {
-;
+  Length = 0;
+  while (String[Length] != 0) {
+if (Length >= MaxSize) {
+  break;
+}
+Length++;
   }
   return Length;
 }
@@ -571,8 +575,12 @@ AsciiStrnLenS (
   // String then AsciiStrnLenS returns MaxSize. At most the first MaxSize 
characters of String shall
   // be accessed by AsciiStrnLenS.
   //
-  for (Length = 0; (Length < MaxSize) && (*String != 0); String++, Length++) {
-;
+  Length = 0;
+  while (String[Length] != 0) {
+if (Length >= MaxSize) {
+  break;
+}
+Length++;
   }
   return Length;
 }
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 2/6] MdePkg/BaseLib: Add an additional check within (Ascii)StrnCmp

2016-12-14 Thread Hao Wu
This commit adds an addtional check in AsciiStrnCmp and StrnCmp. It
explicitly checks the end of the sting pointed by 'SecondString' to make
the code logic easier for reading and to prevent possible mis-reports by
static code checkers.

Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdePkg/Library/BaseLib/String.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c
index 25962f8..fa96d1c 100644
--- a/MdePkg/Library/BaseLib/String.c
+++ b/MdePkg/Library/BaseLib/String.c
@@ -1,7 +1,7 @@
 /** @file
   Unicode and ASCII string primitives.
 
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 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
@@ -315,6 +315,7 @@ StrnCmp (
   }
 
   while ((*FirstString != L'\0') &&
+ (*SecondString != L'\0') &&
  (*FirstString == *SecondString) &&
  (Length > 1)) {
 FirstString++;
@@ -1474,6 +1475,7 @@ AsciiStrnCmp (
   }
 
   while ((*FirstString != '\0') &&
+ (*SecondString != '\0') &&
  (*FirstString == *SecondString) &&
  (Length > 1)) {
 FirstString++;
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 6/6] NetworkPkg: Refine UintnToAscDecWithFormat functions logic

2016-12-14 Thread Hao Wu
This commit refines the logic for HttpBootUintnToAscDecWithFormat and
PxeBcUintnToAscDecWithFormat. It avoids using the decrement operator '--'
for array index to prevent possible mis-reports by static code checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 NetworkPkg/HttpBootDxe/HttpBootSupport.c | 5 ++---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c   | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c 
b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index 9410bf9..bdb29ae 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -86,11 +86,10 @@ HttpBootUintnToAscDecWithFormat (
 {
   UINTN  Remainder;
 
-  while (Length > 0) {
-Length--;
+  for (; Length > 0; Length--) {
 Remainder  = Number % 10;
 Number/= 10;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index 00c652d..568360d 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -1383,11 +1383,10 @@ PxeBcUintnToAscDecWithFormat (
 {
   UINTN  Remainder;
 
-  while (Length > 0) {
-Length--;
+  for (; Length > 0; Length--) {
 Remainder  = Number % 10;
 Number/= 10;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 5/6] MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic

2016-12-14 Thread Hao Wu
This commit refines the logic for the CvtNum function. It avoids using the
decrement operator '--' for array index to prevent possible mis-reports by
static code checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
index 0865ddd..0779056 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
@@ -132,11 +132,10 @@ CvtNum (
 {
   UINTN Remainder;
 
-  while (Length > 0) {
+  for (; Length > 0; Length--) {
 Remainder = Number % 10;
 Number /= 10;
-Length--;
-Buffer[Length] = (UINT8) ('0' + Remainder);
+Buffer[Length - 1] = (UINT8) ('0' + Remainder);
   }
 }
 
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic

2016-12-14 Thread Hao Wu
This commit rewrites the logic for NetblockChecksum. It processes the
checksum of the left-over byte first to prevent possible mis-reports by
static code checkers.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c 
b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
index bbbdbc0..95cb717 100644
--- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
+++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
@@ -1,7 +1,7 @@
 /** @file
   Network library functions providing net buffer operation support.
 
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 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
@@ -1661,6 +1661,13 @@ NetblockChecksum (
 
   Sum = 0;
 
+  //
+  // Add left-over byte, if any
+  //
+  if (Len % 2 != 0) {
+Sum += *(Bulk + Len - 1);
+  }
+
   while (Len > 1) {
 Sum += *(UINT16 *) Bulk;
 Bulk += 2;
@@ -1668,13 +1675,6 @@ NetblockChecksum (
   }
 
   //
-  // Add left-over byte, if any
-  //
-  if (Len > 0) {
-Sum += *(UINT8 *) Bulk;
-  }
-
-  //
   // Fold 32-bit sum to 16 bits
   //
   while ((Sum >> 16) != 0) {
-- 
1.9.5.msysgit.0

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


[edk2] [PATCH 3/6] MdePkg/MemoryLib: Refine InternalMemSetMem16|32|64 functions logic

2016-12-14 Thread Hao Wu
This commit refines the logic for InternalMemSetMem16|32|64 functions. It
avoids using the decrement operator '--' for array index to prevent
possible mis-reports by static code checkers.

Please note that those modified functions are only consumed within
MemoryLib by APIs SetMem16|32|64, and those APIs will handle the case when
the input number of bytes to set is 0. Hence, the behavior of APIs
SetMem16|32|64 is not changed.

Cc: Jiewen Yao 
Cc: Liming Gao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 MdePkg/Library/BaseMemoryLib/MemLibGeneric.c | 18 +-
 MdePkg/Library/PeiMemoryLib/MemLibGeneric.c  | 18 +-
 MdePkg/Library/UefiMemoryLib/MemLibGeneric.c | 18 +-
 3 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/MdePkg/Library/BaseMemoryLib/MemLibGeneric.c 
b/MdePkg/Library/BaseMemoryLib/MemLibGeneric.c
index b058be8..cf40ace 100644
--- a/MdePkg/Library/BaseMemoryLib/MemLibGeneric.c
+++ b/MdePkg/Library/BaseMemoryLib/MemLibGeneric.c
@@ -37,9 +37,9 @@ InternalMemSetMem16 (
   IN  UINT16Value
   )
 {
-  do {
-((UINT16*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT16*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
@@ -61,9 +61,9 @@ InternalMemSetMem32 (
   IN  UINT32Value
   )
 {
-  do {
-((UINT32*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT32*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
@@ -85,9 +85,9 @@ InternalMemSetMem64 (
   IN  UINT64Value
   )
 {
-  do {
-((UINT64*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT64*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
diff --git a/MdePkg/Library/PeiMemoryLib/MemLibGeneric.c 
b/MdePkg/Library/PeiMemoryLib/MemLibGeneric.c
index 490b244..ed18b57 100644
--- a/MdePkg/Library/PeiMemoryLib/MemLibGeneric.c
+++ b/MdePkg/Library/PeiMemoryLib/MemLibGeneric.c
@@ -37,9 +37,9 @@ InternalMemSetMem16 (
   IN  UINT16Value
   )
 {
-  do {
-((UINT16*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT16*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
@@ -61,9 +61,9 @@ InternalMemSetMem32 (
   IN  UINT32Value
   )
 {
-  do {
-((UINT32*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT32*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
@@ -85,9 +85,9 @@ InternalMemSetMem64 (
   IN  UINT64Value
   )
 {
-  do {
-((UINT64*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT64*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
diff --git a/MdePkg/Library/UefiMemoryLib/MemLibGeneric.c 
b/MdePkg/Library/UefiMemoryLib/MemLibGeneric.c
index da02b6c..f1efdbb 100644
--- a/MdePkg/Library/UefiMemoryLib/MemLibGeneric.c
+++ b/MdePkg/Library/UefiMemoryLib/MemLibGeneric.c
@@ -37,9 +37,9 @@ InternalMemSetMem16 (
   IN  UINT16Value
   )
 {
-  do {
-((UINT16*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT16*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
@@ -61,9 +61,9 @@ InternalMemSetMem32 (
   IN  UINT32Value
   )
 {
-  do {
-((UINT32*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT32*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
@@ -85,9 +85,9 @@ InternalMemSetMem64 (
   IN  UINT64Value
   )
 {
-  do {
-((UINT64*)Buffer)[--Length] = Value;
-  } while (Length != 0);
+  for (; Length != 0; Length--) {
+((UINT64*)Buffer)[Length - 1] = Value;
+  }
   return Buffer;
 }
 
-- 
1.9.5.msysgit.0

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


Re: [edk2] correct way to reserve memory from PrePi?

2016-12-14 Thread Ard Biesheuvel
On 14 December 2016 at 10:02, Michael Zimmermann
 wrote:
> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
> but apparently they don't have any effect.
> When I look at the output of the shell's memmap command there aren't
> any reserved/unavailable pages.
>
> Furthermore, when using AllocatePages with one of the physical
> addresses which I've reserved it succeeds which means that it's not
> just a problem of how the memmap command works.
>
> Am I doing something wrong or is this a bug?
>

I think you need to ensure that they don't overlap existing resource
descriptors: if you declare a region as reserved, you should not
declare it as memory first
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] FatPkg/EnhancedFatDxe: Fix potential hang in async file IO

2016-12-14 Thread Ni, Ruiyu
Boaz,
Could you please verify this patch in your failed system?
I cannot reproduce the issue in my environment.

Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Wednesday, December 14, 2016 6:01 PM
> To: edk2-devel@lists.01.org
> Cc: Tian, Feng ; Boaz Kahana
> 
> Subject: [edk2] [PATCH] FatPkg/EnhancedFatDxe: Fix potential hang in async
> file IO
> 
> FatQueueTask() is running at TPL_APPLICATION, while
> FatDestroySubtask() is running at TPL_NOTIFY, it's possible for a task
> containing 2 sub tasks, when the for-loop executes GetNextNode (
> >Subtasks, Link), the memory occupied by Link is freed in
> FatDestroySubtask().
> 
> The fix stores the next link in NextLink so that the delete in
> FatDestroySubtask() is safe.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Feng Tian 
> Cc: Boaz Kahana 
> ---
>  FatPkg/EnhancedFatDxe/Misc.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/FatPkg/EnhancedFatDxe/Misc.c b/FatPkg/EnhancedFatDxe/Misc.c
> index c035670..cef1acd 100644
> --- a/FatPkg/EnhancedFatDxe/Misc.c
> +++ b/FatPkg/EnhancedFatDxe/Misc.c
> @@ -1,7 +1,7 @@
>  /** @file
>Miscellaneous functions.
> 
> -Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 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
> @@ -132,6 +132,7 @@ FatQueueTask (  {
>EFI_STATUS  Status;
>LIST_ENTRY  *Link;
> +  LIST_ENTRY  *NextLink;
>FAT_SUBTASK *Subtask;
> 
>//
> @@ -149,9 +150,13 @@ FatQueueTask (
>EfiReleaseLock ();
> 
>Status = EFI_SUCCESS;
> -  for ( Link = GetFirstNode (>Subtasks)
> +  //
> +  // Use NextLink to store the next link since Link might be freed in
> + the end of previous loop,  // resulting next link cannot be retrieved from
> Link.
> +  //
> +  for ( Link = GetFirstNode (>Subtasks), NextLink = GetNextNode
> + (>Subtasks, Link)
>; !IsNull (>Subtasks, Link)
> -  ; Link = GetNextNode (>Subtasks, Link)
> +  ; Link = NextLink, NextLink = GetNextNode (>Subtasks, Link)
>) {
>  Subtask = CR (Link, FAT_SUBTASK, Link, FAT_SUBTASK_SIGNATURE);
>  if (Subtask->Write) {
> --
> 2.9.0.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] correct way to reserve memory from PrePi?

2016-12-14 Thread Michael Zimmermann
I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
but apparently they don't have any effect.
When I look at the output of the shell's memmap command there aren't
any reserved/unavailable pages.

Furthermore, when using AllocatePages with one of the physical
addresses which I've reserved it succeeds which means that it's not
just a problem of how the memmap command works.

Am I doing something wrong or is this a bug?

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


[edk2] [PATCH] FatPkg/EnhancedFatDxe: Fix potential hang in async file IO

2016-12-14 Thread Ruiyu Ni
FatQueueTask() is running at TPL_APPLICATION, while
FatDestroySubtask() is running at TPL_NOTIFY, it's possible
for a task containing 2 sub tasks, when the for-loop
executes GetNextNode (>Subtasks, Link), the memory
occupied by Link is freed in FatDestroySubtask().

The fix stores the next link in NextLink so that the delete
in FatDestroySubtask() is safe.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni 
Cc: Feng Tian 
Cc: Boaz Kahana 
---
 FatPkg/EnhancedFatDxe/Misc.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/FatPkg/EnhancedFatDxe/Misc.c b/FatPkg/EnhancedFatDxe/Misc.c
index c035670..cef1acd 100644
--- a/FatPkg/EnhancedFatDxe/Misc.c
+++ b/FatPkg/EnhancedFatDxe/Misc.c
@@ -1,7 +1,7 @@
 /** @file
   Miscellaneous functions.
 
-Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 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
@@ -132,6 +132,7 @@ FatQueueTask (
 {
   EFI_STATUS  Status;
   LIST_ENTRY  *Link;
+  LIST_ENTRY  *NextLink;
   FAT_SUBTASK *Subtask;
 
   //
@@ -149,9 +150,13 @@ FatQueueTask (
   EfiReleaseLock ();
 
   Status = EFI_SUCCESS;
-  for ( Link = GetFirstNode (>Subtasks)
+  //
+  // Use NextLink to store the next link since Link might be freed in the end 
of previous loop,
+  // resulting next link cannot be retrieved from Link.
+  //
+  for ( Link = GetFirstNode (>Subtasks), NextLink = GetNextNode 
(>Subtasks, Link)
   ; !IsNull (>Subtasks, Link)
-  ; Link = GetNextNode (>Subtasks, Link)
+  ; Link = NextLink, NextLink = GetNextNode (>Subtasks, Link)
   ) {
 Subtask = CR (Link, FAT_SUBTASK, Link, FAT_SUBTASK_SIGNATURE);
 if (Subtask->Write) {
-- 
2.9.0.windows.1

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


Re: [edk2] [PATCH v6 1/2] MdeModulePkg/NonDiscoverablePciDeviceDxe: add support for non-coherent DMA

2016-12-14 Thread Ard Biesheuvel
Ray,

Do you have any comments on this version?

Thanks,
Ard.


On 9 December 2016 at 15:04, Ard Biesheuvel  wrote:
> Add support for non-coherent DMA, either by performing explicit cache
> maintenance when DMA mappings are aligned to the CPU's DMA buffer alignment,
> or by bounce buffering via uncached mappings otherwise.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> Tested-by: Marcin Wojtas 
> ---
>  
> MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
>|  14 +-
>  
> MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
>  |   2 +
>  
> MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c 
>| 329 
>  
> MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.h 
>|  29 ++
>  4 files changed, 367 insertions(+), 7 deletions(-)
>
> diff --git 
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
>  
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
> index ee765d7a5d9c..0fcf2b2ec1bf 100644
> --- 
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
> +++ 
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c
> @@ -16,6 +16,8 @@
>
>  #include 
>
> +EFI_CPU_ARCH_PROTOCOL  *mCpu;
> +
>  //
>  // We only support the following device types
>  //
> @@ -69,14 +71,7 @@ NonDiscoverablePciDeviceSupported (
>  return Status;
>}
>
> -  //
> -  // Restricted to DMA coherent for now
> -  //
>Status = EFI_UNSUPPORTED;
> -  if (Device->DmaType != NonDiscoverableDeviceDmaTypeCoherent) {
> -goto CloseProtocol;
> -  }
> -
>for (Idx = 0; Idx < ARRAY_SIZE (SupportedNonDiscoverableDevices); Idx++) {
>  if (CompareGuid (Device->Type, SupportedNonDiscoverableDevices [Idx])) {
>Status = EFI_SUCCESS;
> @@ -224,6 +219,11 @@ NonDiscoverablePciDeviceDxeEntryPoint (
>IN EFI_SYSTEM_TABLE *SystemTable
>)
>  {
> +  EFI_STATUS  Status;
> +
> +  Status = gBS->LocateProtocol (, NULL, (VOID 
> **));
> +  ASSERT_EFI_ERROR(Status);
> +
>return EfiLibInstallDriverBindingComponentName2 (
> ImageHandle,
> SystemTable,
> diff --git 
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
>  
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
> index 996fe310e0e3..5faa8945134c 100644
> --- 
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
> +++ 
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
> @@ -32,6 +32,7 @@ [Packages]
>  [LibraryClasses]
>BaseMemoryLib
>DebugLib
> +  DxeServicesTableLib
>MemoryAllocationLib
>UefiBootServicesTableLib
>UefiDriverEntryPoint
> @@ -40,6 +41,7 @@ [LibraryClasses]
>  [Protocols]
>gEfiPciIoProtocolGuid ## BY_START
>gEdkiiNonDiscoverableDeviceProtocolGuid   ## TO_START
> +  gEfiCpuArchProtocolGuid   ## CONSUMES
>
>  [Guids]
>gEdkiiNonDiscoverableAhciDeviceGuid
> diff --git 
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
>  
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> index 56482e3353c0..814f7643ae4c 100644
> --- 
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> +++ 
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
> @@ -15,6 +15,8 @@
>
>  #include "NonDiscoverablePciDeviceIo.h"
>
> +#include 
> +
>  #include 
>
>  #include 
> @@ -537,6 +539,324 @@ CoherentPciIoFreeBuffer (
>return EFI_SUCCESS;
>  }
>
> +STATIC
> +EFI_STATUS
> +EFIAPI
> +NonCoherentPciIoFreeBuffer (
> +  IN  EFI_PCI_IO_PROTOCOL *This,
> +  IN  UINTN   Pages,
> +  IN  VOID*HostAddress
> +  )
> +{
> +  NON_DISCOVERABLE_PCI_DEVICE   *Dev;
> +  LIST_ENTRY*Entry;
> +  EFI_STATUSStatus;
> +  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION   *Alloc;
> +  BOOLEAN   Found;
> +
> +  Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
> +
> +  Found = FALSE;
> +
> +  //
> +  // Find the uncached allocation list entry associated
> +  // with this allocation
> +  //
> +  for (Entry = Dev->UncachedAllocationList.ForwardLink;
> +   Entry != >UncachedAllocationList;
> +   Entry = Entry->ForwardLink) {
> +
> +Alloc = BASE_CR (Entry, NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, 
> List);
> +if (Alloc->HostAddress == HostAddress && Alloc->NumPages == Pages) {
> +  //
> +  // We are freeing the exact allocation we were given
> +  // before by AllocateBuffer()
> +  //
> +   

Re: [edk2] [Patch 02/10] MdePkg: Add a header to standardize TLS definitions

2016-12-14 Thread Fu, Siyuan
Reviewed-by: Fu Siyuan 


-Original Message-
From: Wu, Jiaxin 
Sent: 2016年12月14日 15:34
To: edk2-devel@lists.01.org
Cc: Long, Qin ; Ye, Ting ; Fu, Siyuan 
; Zhang, Lubo ; Gao, Liming 
; Kinney, Michael D ; Thomas 
Palmer ; Wu, Jiaxin 
Subject: [Patch 02/10] MdePkg: Add a header to standardize TLS definitions

This path is used to standardize TLS definitions from related RFCs. Including 
TLS Cipher Suites, TLS Version, TLS Content Type and TLS Record Header, etc.

Cc: Long Qin 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Thomas Palmer 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdePkg/Include/IndustryStandard/Tls1.h | 93 ++
 1 file changed, 93 insertions(+)
 create mode 100644 MdePkg/Include/IndustryStandard/Tls1.h

diff --git a/MdePkg/Include/IndustryStandard/Tls1.h 
b/MdePkg/Include/IndustryStandard/Tls1.h
new file mode 100644
index 000..14eb265
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Tls1.h
@@ -0,0 +1,93 @@
+/** @file
+  Transport Layer Security  -- TLS 1.0/1.1/1.2 Standard definitions, from RFC 
2246/4346/5246
+
+  This file contains common TLS 1.0/1.1/1.2 definitions from RFC 
+ 2246/4346/5246
+
+  Copyright (c) 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.
+**/
+
+#ifndef __TLS_1_H__
+#define __TLS_1_H__
+
+#pragma pack(1)
+
+///
+/// TLS Cipher Suite, refers to A.5 of rfc-2246, rfc-4346 and rfc-5246.
+///
+#define TLS_RSA_WITH_NULL_MD5{0x00, 0x01}
+#define TLS_RSA_WITH_NULL_SHA{0x00, 0x02}
+#define TLS_RSA_WITH_RC4_128_MD5 {0x00, 0x04}
+#define TLS_RSA_WITH_RC4_128_SHA {0x00, 0x05}
+#define TLS_RSA_WITH_IDEA_CBC_SHA{0x00, 0x07}
+#define TLS_RSA_WITH_DES_CBC_SHA {0x00, 0x09}
+#define TLS_RSA_WITH_3DES_EDE_CBC_SHA{0x00, 0x0A}
+#define TLS_DH_DSS_WITH_DES_CBC_SHA  {0x00, 0x0C}
+#define TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA {0x00, 0x0D}
+#define TLS_DH_RSA_WITH_DES_CBC_SHA  {0x00, 0x0F}
+#define TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA {0x00, 0x10}
+#define TLS_DHE_DSS_WITH_DES_CBC_SHA {0x00, 0x12}
+#define TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA{0x00, 0x13}
+#define TLS_DHE_RSA_WITH_DES_CBC_SHA {0x00, 0x15}
+#define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA{0x00, 0x16}
+#define TLS_RSA_WITH_AES_128_CBC_SHA {0x00, 0x2F}
+#define TLS_DH_DSS_WITH_AES_128_CBC_SHA  {0x00, 0x30}
+#define TLS_DH_RSA_WITH_AES_128_CBC_SHA  {0x00, 0x31}
+#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA {0x00, 0x32}
+#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA {0x00, 0x33}
+#define TLS_RSA_WITH_AES_256_CBC_SHA {0x00, 0x35}
+#define TLS_DH_DSS_WITH_AES_256_CBC_SHA  {0x00, 0x36}
+#define TLS_DH_RSA_WITH_AES_256_CBC_SHA  {0x00, 0x37}
+#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA {0x00, 0x38}
+#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA {0x00, 0x39}
+#define TLS_RSA_WITH_NULL_SHA256 {0x00, 0x3B}
+#define TLS_RSA_WITH_AES_128_CBC_SHA256  {0x00, 0x3C}
+#define TLS_RSA_WITH_AES_256_CBC_SHA256  {0x00, 0x3D}
+#define TLS_DH_DSS_WITH_AES_128_CBC_SHA256   {0x00, 0x3E}
+#define TLS_DH_RSA_WITH_AES_128_CBC_SHA256   {0x00, 0x3F}
+#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA256  {0x00, 0x40}
+#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256  {0x00, 0x67}
+#define TLS_DH_DSS_WITH_AES_256_CBC_SHA256   {0x00, 0x68}
+#define TLS_DH_RSA_WITH_AES_256_CBC_SHA256   {0x00, 0x69}
+#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA256  {0x00, 0x6A}
+#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256  {0x00, 0x6B}
+
+///
+/// TLS Version, refers to A.1 of rfc-2246, rfc-4346 and rfc-5246.
+///
+#define TLS10_PROTOCOL_VERSION_MAJOR  0x03 #define 
+TLS10_PROTOCOL_VERSION_MINOR  0x01 #define TLS11_PROTOCOL_VERSION_MAJOR  
+0x03 #define TLS11_PROTOCOL_VERSION_MINOR  0x02 #define 
+TLS12_PROTOCOL_VERSION_MAJOR  0x03 #define TLS12_PROTOCOL_VERSION_MINOR  
+0x03
+
+///
+/// TLS Content Type, refers to A.1 of rfc-2246, rfc-4346 and rfc-5246.
+///
+typedef enum {
+  

Re: [edk2] [Patch 01/10] MdePkg: Add TLS related protocol definition

2016-12-14 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 




-Original Message-
From: Wu, Jiaxin 
Sent: 2016年12月14日 15:34
To: edk2-devel@lists.01.org
Cc: Long, Qin ; Ye, Ting ; Fu, Siyuan 
; Zhang, Lubo ; Gao, Liming 
; Kinney, Michael D ; Thomas 
Palmer ; Wu, Jiaxin 
Subject: [Patch 01/10] MdePkg: Add TLS related protocol definition

This patch is used to add Tls.h and TlsConfig.h header files to define EFI TLS 
Configuration Protocol, EFI TLS Service Binding Protocol and EFI TLS 
Configuration Protocol.

Cc: Long Qin 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Thomas Palmer 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdePkg/Include/Protocol/Tls.h   | 460 
 MdePkg/Include/Protocol/TlsConfig.h | 132 +++
 MdePkg/MdePkg.dec   |   9 +
 3 files changed, 601 insertions(+)
 create mode 100644 MdePkg/Include/Protocol/Tls.h  create mode 100644 
MdePkg/Include/Protocol/TlsConfig.h

diff --git a/MdePkg/Include/Protocol/Tls.h b/MdePkg/Include/Protocol/Tls.h new 
file mode 100644 index 000..51a3cda
--- /dev/null
+++ b/MdePkg/Include/Protocol/Tls.h
@@ -0,0 +1,460 @@
+/** @file
+  EFI TLS Protocols as defined in UEFI 2.5.
+
+  The EFI TLS Service Binding Protocol is used to locate EFI TLS 
+ Protocol drivers  to create and destroy child of the driver to 
+ communicate with other host using  TLS protocol.
+  The EFI TLS Protocol provides the ability to manage TLS session.
+
+  Copyright (c) 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.
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.5
+
+**/
+
+#ifndef __EFI_TLS_PROTOCOL_H__
+#define __EFI_TLS_PROTOCOL_H__
+
+///
+/// The EFI TLS Service Binding Protocol is used to locate EFI TLS 
+Protocol drivers to /// create and destroy child of the driver to 
+communicate with other host using TLS /// protocol.
+///
+#define EFI_TLS_SERVICE_BINDING_PROTOCOL_GUID \
+  { \
+0x952cb795, 0xff36, 0x48cf, {0xa2, 0x49, 0x4d, 0xf4, 0x86, 0xd6, 
+0xab, 0x8d } \
+  }
+
+///
+/// The EFI TLS protocol provides the ability to manage TLS session.
+///
+#define EFI_TLS_PROTOCOL_GUID \
+  { \
+0xca959f, 0x6cfa, 0x4db1, {0x95, 0xbc, 0xe4, 0x6c, 0x47, 0x51, 
+0x43, 0x90 } \
+  }
+
+typedef struct _EFI_TLS_PROTOCOL EFI_TLS_PROTOCOL;
+
+///
+/// EFI_TLS_SESSION_DATA_TYPE
+///
+typedef enum {
+  ///
+  /// Session Configuration
+  ///
+
+  ///
+  /// TLS session Version. The corresponding Data is of type EFI_TLS_VERSION.
+  ///
+  EfiTlsVersion,
+  ///
+  /// TLS session as client or as server. The corresponding Data is of  
+ /// EFI_TLS_CONNECTION_END.
+  ///
+  EfiTlsConnectionEnd,
+  ///
+  /// A priority list of preferred algorithms for the TLS session.
+  /// The corresponding Data is a list of EFI_TLS_CIPHER.
+  ///
+  EfiTlsCipherList,
+  ///
+  /// TLS session compression method.
+  /// The corresponding Data is of type EFI_TLS_COMPRESSION.
+  ///
+  EfiTlsCompressionMethod,
+  ///
+  /// TLS session extension data.
+  /// The corresponding Data is a list of type EFI_TLS_EXTENDION.
+  ///
+  EfiTlsExtensionData,
+  ///
+  /// TLS session verify method.
+  /// The corresponding Data is of type EFI_TLS_VERIFY.
+  ///
+  EfiTlsVerifyMethod,
+  ///
+  /// TLS session data session ID.
+  /// For SetSessionData(), it is TLS session ID used for session resumption.
+  /// For GetSessionData(), it is the TLS session ID used for current session.
+  /// The corresponding Data is of type EFI_TLS_SESSION_ID.
+  ///
+  EfiTlsSessionID,
+  ///
+  /// TLS session data session state.
+  /// The corresponding Data is of type EFI_TLS_SESSION_STATE.
+  ///
+  EfiTlsSessionState,
+
+  ///
+  /// Session information
+  ///
+
+  ///
+  /// TLS session data client random.
+  /// The corresponding Data is of type EFI_TLS_RANDOM.
+  ///
+  EfiTlsClientRandom,
+  ///
+  /// TLS session data server random.
+  /// The corresponding Data is of type EFI_TLS_RANDOM.
+  ///
+  EfiTlsServerRandom,
+  ///
+  /// TLS session data key material.
+  /// The corresponding Data is of type EFI_TLS_MASTER_SECRET.
+  ///
+  EfiTlsKeyMaterial,
+
+  EfiTlsSessionDataTypeMaximum
+

Re: [edk2] [Patch 02/10] MdePkg: Add a header to standardize TLS definitions

2016-12-14 Thread Long, Qin
Reviewed-by: Qin Long 


> -Original Message-
> From: Wu, Jiaxin
> Sent: Wednesday, December 14, 2016 3:34 PM
> To: edk2-devel@lists.01.org
> Cc: Long, Qin; Ye, Ting; Fu, Siyuan; Zhang, Lubo; Gao, Liming; Kinney, Michael
> D; Thomas Palmer; Wu, Jiaxin
> Subject: [Patch 02/10] MdePkg: Add a header to standardize TLS definitions
> 
> This path is used to standardize TLS definitions from related RFCs. Including
> TLS Cipher Suites, TLS Version, TLS Content Type and TLS Record Header, etc.
> 
> Cc: Long Qin 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Zhang Lubo 
> Cc: Liming Gao 
> Cc: Michael D Kinney 
> Cc: Thomas Palmer 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin 
> ---
>  MdePkg/Include/IndustryStandard/Tls1.h | 93
> ++
>  1 file changed, 93 insertions(+)
>  create mode 100644 MdePkg/Include/IndustryStandard/Tls1.h
> 
> diff --git a/MdePkg/Include/IndustryStandard/Tls1.h
> b/MdePkg/Include/IndustryStandard/Tls1.h
> new file mode 100644
> index 000..14eb265
> --- /dev/null
> +++ b/MdePkg/Include/IndustryStandard/Tls1.h
> @@ -0,0 +1,93 @@
> +/** @file
> +  Transport Layer Security  -- TLS 1.0/1.1/1.2 Standard definitions, from RFC
> 2246/4346/5246
> +
> +  This file contains common TLS 1.0/1.1/1.2 definitions from RFC
> + 2246/4346/5246
> +
> +  Copyright (c) 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.
> +**/
> +
> +#ifndef __TLS_1_H__
> +#define __TLS_1_H__
> +
> +#pragma pack(1)
> +
> +///
> +/// TLS Cipher Suite, refers to A.5 of rfc-2246, rfc-4346 and rfc-5246.
> +///
> +#define TLS_RSA_WITH_NULL_MD5{0x00, 0x01}
> +#define TLS_RSA_WITH_NULL_SHA{0x00, 0x02}
> +#define TLS_RSA_WITH_RC4_128_MD5 {0x00, 0x04}
> +#define TLS_RSA_WITH_RC4_128_SHA {0x00, 0x05}
> +#define TLS_RSA_WITH_IDEA_CBC_SHA{0x00, 0x07}
> +#define TLS_RSA_WITH_DES_CBC_SHA {0x00, 0x09}
> +#define TLS_RSA_WITH_3DES_EDE_CBC_SHA{0x00, 0x0A}
> +#define TLS_DH_DSS_WITH_DES_CBC_SHA  {0x00, 0x0C}
> +#define TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA {0x00, 0x0D}
> +#define TLS_DH_RSA_WITH_DES_CBC_SHA  {0x00, 0x0F}
> +#define TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA {0x00, 0x10}
> +#define TLS_DHE_DSS_WITH_DES_CBC_SHA {0x00, 0x12}
> +#define TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA{0x00, 0x13}
> +#define TLS_DHE_RSA_WITH_DES_CBC_SHA {0x00, 0x15}
> +#define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA{0x00, 0x16}
> +#define TLS_RSA_WITH_AES_128_CBC_SHA {0x00, 0x2F}
> +#define TLS_DH_DSS_WITH_AES_128_CBC_SHA  {0x00, 0x30}
> +#define TLS_DH_RSA_WITH_AES_128_CBC_SHA  {0x00, 0x31}
> +#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA {0x00, 0x32}
> +#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA {0x00, 0x33}
> +#define TLS_RSA_WITH_AES_256_CBC_SHA {0x00, 0x35}
> +#define TLS_DH_DSS_WITH_AES_256_CBC_SHA  {0x00, 0x36}
> +#define TLS_DH_RSA_WITH_AES_256_CBC_SHA  {0x00, 0x37}
> +#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA {0x00, 0x38}
> +#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA {0x00, 0x39}
> +#define TLS_RSA_WITH_NULL_SHA256 {0x00, 0x3B}
> +#define TLS_RSA_WITH_AES_128_CBC_SHA256  {0x00, 0x3C}
> +#define TLS_RSA_WITH_AES_256_CBC_SHA256  {0x00, 0x3D}
> +#define TLS_DH_DSS_WITH_AES_128_CBC_SHA256   {0x00, 0x3E}
> +#define TLS_DH_RSA_WITH_AES_128_CBC_SHA256   {0x00, 0x3F}
> +#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA256  {0x00, 0x40}
> +#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256  {0x00, 0x67}
> +#define TLS_DH_DSS_WITH_AES_256_CBC_SHA256   {0x00, 0x68}
> +#define TLS_DH_RSA_WITH_AES_256_CBC_SHA256   {0x00, 0x69}
> +#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA256  {0x00, 0x6A}
> +#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256  {0x00, 0x6B}
> +
> +///
> +/// TLS Version, refers to A.1 of rfc-2246, rfc-4346 and rfc-5246.
> +///
> +#define TLS10_PROTOCOL_VERSION_MAJOR  0x03 #define
> +TLS10_PROTOCOL_VERSION_MINOR  0x01 #define
> TLS11_PROTOCOL_VERSION_MAJOR
> +0x03 #define TLS11_PROTOCOL_VERSION_MINOR  0x02 #define
> +TLS12_PROTOCOL_VERSION_MAJOR  0x03 #define
> TLS12_PROTOCOL_VERSION_MINOR
> +0x03
> +
> +///
> +/// TLS Content Type, refers to A.1 of rfc-2246, rfc-4346 and 

Re: [edk2] [Patch 05/10] NetworkPkg/TlsDxe: TlsDxe driver implementation over OpenSSL

2016-12-14 Thread Fu, Siyuan
Hi, Jiaxin

Some comments as below:

In TlsImpl.c

Should the ASSERT in line 104 be an error handling? I mean is the input buffer 
coming from external input, and have we checked ContentType within it?

Seems the TempRecordHeader pointer will be modified in the while loop, 
shouldn't the 3rd parameter be the reminding buffer size of the output buffer?

Should we return error if the TlsCtrlTrafficOut return a failure?

Similar questions for the decrypt packet function.


Best Regards,
Siyuan

-Original Message-
From: Wu, Jiaxin 
Sent: 2016年12月14日 15:34
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Zhang, Lubo 
; Long, Qin ; Thomas Palmer 
; Wu, Jiaxin 
Subject: [Patch 05/10] NetworkPkg/TlsDxe: TlsDxe driver implementation over 
OpenSSL

This patch is the implementation of EFI TLS Service Binding
Protocol, EFI TLS Protocol and EFI TLS Configuration Protocol
Interfaces.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Long Qin 
Cc: Thomas Palmer 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/TlsDxe/TlsConfigProtocol.c | 152 
 NetworkPkg/TlsDxe/TlsDriver.c | 498 +++
 NetworkPkg/TlsDxe/TlsDriver.h | 237 +
 NetworkPkg/TlsDxe/TlsDxe.inf  |  65 
 NetworkPkg/TlsDxe/TlsDxe.uni  |  25 ++
 NetworkPkg/TlsDxe/TlsDxeExtra.uni |  18 +
 NetworkPkg/TlsDxe/TlsImpl.c   | 270 +++
 NetworkPkg/TlsDxe/TlsImpl.h   | 315 +
 NetworkPkg/TlsDxe/TlsProtocol.c   | 632 ++
 9 files changed, 2212 insertions(+)
 create mode 100644 NetworkPkg/TlsDxe/TlsConfigProtocol.c
 create mode 100644 NetworkPkg/TlsDxe/TlsDriver.c
 create mode 100644 NetworkPkg/TlsDxe/TlsDriver.h
 create mode 100644 NetworkPkg/TlsDxe/TlsDxe.inf
 create mode 100644 NetworkPkg/TlsDxe/TlsDxe.uni
 create mode 100644 NetworkPkg/TlsDxe/TlsDxeExtra.uni
 create mode 100644 NetworkPkg/TlsDxe/TlsImpl.c
 create mode 100644 NetworkPkg/TlsDxe/TlsImpl.h
 create mode 100644 NetworkPkg/TlsDxe/TlsProtocol.c

diff --git a/NetworkPkg/TlsDxe/TlsConfigProtocol.c 
b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
new file mode 100644
index 000..2ec79c9
--- /dev/null
+++ b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
@@ -0,0 +1,152 @@
+/** @file
+  Implementation of EFI TLS Configuration Protocol Interfaces.
+
+  Copyright (c) 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.
+
+**/
+
+#include "TlsImpl.h"
+
+EFI_TLS_CONFIGURATION_PROTOCOL  mTlsConfigurationProtocol = {
+  TlsConfigurationSetData,
+  TlsConfigurationGetData
+};
+
+/**
+  Set TLS configuration data.
+
+  The SetData() function sets TLS configuration to non-volatile storage or 
volatile
+  storage.
+
+  @param[in]  ThisPointer to the 
EFI_TLS_CONFIGURATION_PROTOCOL instance.
+  @param[in]  DataTypeConfiguration data type.
+  @param[in]  DataPointer to configuration data.
+  @param[in]  DataSizeTotal size of configuration data.
+
+  @retval EFI_SUCCESS The TLS configuration data is set 
successfully.
+  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is 
TRUE:
+  This is NULL.
+  Data is NULL.
+  DataSize is 0.
+  @retval EFI_UNSUPPORTED The DataType is unsupported.
+  @retval EFI_OUT_OF_RESOURCESRequired system resources could not be 
allocated.
+
+**/
+EFI_STATUS
+EFIAPI
+TlsConfigurationSetData (
+  IN EFI_TLS_CONFIGURATION_PROTOCOL  *This,
+  IN EFI_TLS_CONFIG_DATA_TYPEDataType,
+  IN VOID*Data,
+  IN UINTN   DataSize
+  )
+{
+  EFI_STATUSStatus;
+  TLS_INSTANCE  *Instance;
+  EFI_TPL   OldTpl;
+
+  Status = EFI_SUCCESS;
+
+  if (This == NULL ||  Data == NULL || DataSize == 0) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+
+  Instance = TLS_INSTANCE_FROM_CONFIGURATION_THIS (This);
+
+  switch (DataType) {
+  case EfiTlsConfigDataTypeCACertificate:
+Status = TlsSetCaCertificate (Instance->TlsConn, Data, DataSize);
+break;
+  case EfiTlsConfigDataTypeHostPublicCert:
+

Re: [edk2] [Patch 01/10] MdePkg: Add TLS related protocol definition

2016-12-14 Thread Wu, Jiaxin
Thanks Qin, I will correct it before commit this patch.

Best Regards!
Jiaxin

> -Original Message-
> From: Long, Qin
> Sent: Wednesday, December 14, 2016 4:36 PM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Zhang,
> Lubo ; Gao, Liming ; Kinney,
> Michael D ; Thomas Palmer
> 
> Subject: RE: [Patch 01/10] MdePkg: Add TLS related protocol definition
> 
> Reviewed-by: Qin Long 
> 
> Please correct some typos later:
> EFI_TLS_EXTENDION  --> EFI_TLS_EXTENSION TLS/SSLhandshake --> TLS/SSL
> handshake cerfificate --> certificate cypher --> cipher
> binaryX.509 --> binary X.509
> PEMencoded --> PEM-encoded
> 
> Best Regards & Thanks,
> LONG, Qin
> 
> > -Original Message-
> > From: Wu, Jiaxin
> > Sent: Wednesday, December 14, 2016 3:34 PM
> > To: edk2-devel@lists.01.org
> > Cc: Long, Qin; Ye, Ting; Fu, Siyuan; Zhang, Lubo; Gao, Liming; Kinney,
> > Michael D; Thomas Palmer; Wu, Jiaxin
> > Subject: [Patch 01/10] MdePkg: Add TLS related protocol definition
> >
> > This patch is used to add Tls.h and TlsConfig.h header files to define
> > EFI TLS Configuration Protocol, EFI TLS Service Binding Protocol and
> > EFI TLS Configuration Protocol.
> >
> > Cc: Long Qin 
> > Cc: Ye Ting 
> > Cc: Fu Siyuan 
> > Cc: Zhang Lubo 
> > Cc: Liming Gao 
> > Cc: Michael D Kinney 
> > Cc: Thomas Palmer 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Wu Jiaxin 
> > ---
> >  MdePkg/Include/Protocol/Tls.h   | 460
> > 
> >  MdePkg/Include/Protocol/TlsConfig.h | 132 +++
> >  MdePkg/MdePkg.dec   |   9 +
> >  3 files changed, 601 insertions(+)
> >  create mode 100644 MdePkg/Include/Protocol/Tls.h  create mode 100644
> > MdePkg/Include/Protocol/TlsConfig.h
> >
> > diff --git a/MdePkg/Include/Protocol/Tls.h
> > b/MdePkg/Include/Protocol/Tls.h new file mode 100644 index
> > 000..51a3cda
> > --- /dev/null
> > +++ b/MdePkg/Include/Protocol/Tls.h
> > @@ -0,0 +1,460 @@
> > +/** @file
> > +  EFI TLS Protocols as defined in UEFI 2.5.
> > +
> > +  The EFI TLS Service Binding Protocol is used to locate EFI TLS
> > + Protocol drivers  to create and destroy child of the driver to
> > + communicate with other host using  TLS protocol.
> > +  The EFI TLS Protocol provides the ability to manage TLS session.
> > +
> > +  Copyright (c) 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.
> > +
> > +  @par Revision Reference:
> > +  This Protocol is introduced in UEFI Specification 2.5
> > +
> > +**/
> > +
> > +#ifndef __EFI_TLS_PROTOCOL_H__
> > +#define __EFI_TLS_PROTOCOL_H__
> > +
> > +///
> > +/// The EFI TLS Service Binding Protocol is used to locate EFI TLS
> > +Protocol drivers to /// create and destroy child of the driver to
> > +communicate with other host using TLS /// protocol.
> > +///
> > +#define EFI_TLS_SERVICE_BINDING_PROTOCOL_GUID \
> > +  { \
> > +0x952cb795, 0xff36, 0x48cf, {0xa2, 0x49, 0x4d, 0xf4, 0x86, 0xd6,
> > +0xab, 0x8d } \
> > +  }
> > +
> > +///
> > +/// The EFI TLS protocol provides the ability to manage TLS session.
> > +///
> > +#define EFI_TLS_PROTOCOL_GUID \
> > +  { \
> > +0xca959f, 0x6cfa, 0x4db1, {0x95, 0xbc, 0xe4, 0x6c, 0x47, 0x51,
> > +0x43, 0x90 } \
> > +  }
> > +
> > +typedef struct _EFI_TLS_PROTOCOL EFI_TLS_PROTOCOL;
> > +
> > +///
> > +/// EFI_TLS_SESSION_DATA_TYPE
> > +///
> > +typedef enum {
> > +  ///
> > +  /// Session Configuration
> > +  ///
> > +
> > +  ///
> > +  /// TLS session Version. The corresponding Data is of type
> > EFI_TLS_VERSION.
> > +  ///
> > +  EfiTlsVersion,
> > +  ///
> > +  /// TLS session as client or as server. The corresponding Data is
> > + of /// EFI_TLS_CONNECTION_END.
> > +  ///
> > +  EfiTlsConnectionEnd,
> > +  ///
> > +  /// A priority list of preferred algorithms for the TLS session.
> > +  /// The corresponding Data is a list of EFI_TLS_CIPHER.
> > +  ///
> > +  EfiTlsCipherList,
> > +  ///
> > +  /// TLS session compression method.
> > +  /// The corresponding Data is of type EFI_TLS_COMPRESSION.
> > +  ///
> > +  EfiTlsCompressionMethod,
> > +  ///
> > +  /// TLS session extension data.
> > +  /// The corresponding Data is a list of type 

Re: [edk2] [Patch 01/10] MdePkg: Add TLS related protocol definition

2016-12-14 Thread Long, Qin
Reviewed-by: Qin Long 

Please correct some typos later:
EFI_TLS_EXTENDION  --> EFI_TLS_EXTENSION
TLS/SSLhandshake --> TLS/SSL handshake
cerfificate --> certificate
cypher --> cipher
binaryX.509 --> binary X.509
PEMencoded --> PEM-encoded

Best Regards & Thanks,
LONG, Qin

> -Original Message-
> From: Wu, Jiaxin
> Sent: Wednesday, December 14, 2016 3:34 PM
> To: edk2-devel@lists.01.org
> Cc: Long, Qin; Ye, Ting; Fu, Siyuan; Zhang, Lubo; Gao, Liming; Kinney, Michael
> D; Thomas Palmer; Wu, Jiaxin
> Subject: [Patch 01/10] MdePkg: Add TLS related protocol definition
> 
> This patch is used to add Tls.h and TlsConfig.h header files to define EFI TLS
> Configuration Protocol, EFI TLS Service Binding Protocol and EFI TLS
> Configuration Protocol.
> 
> Cc: Long Qin 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Zhang Lubo 
> Cc: Liming Gao 
> Cc: Michael D Kinney 
> Cc: Thomas Palmer 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin 
> ---
>  MdePkg/Include/Protocol/Tls.h   | 460
> 
>  MdePkg/Include/Protocol/TlsConfig.h | 132 +++
>  MdePkg/MdePkg.dec   |   9 +
>  3 files changed, 601 insertions(+)
>  create mode 100644 MdePkg/Include/Protocol/Tls.h  create mode 100644
> MdePkg/Include/Protocol/TlsConfig.h
> 
> diff --git a/MdePkg/Include/Protocol/Tls.h b/MdePkg/Include/Protocol/Tls.h
> new file mode 100644 index 000..51a3cda
> --- /dev/null
> +++ b/MdePkg/Include/Protocol/Tls.h
> @@ -0,0 +1,460 @@
> +/** @file
> +  EFI TLS Protocols as defined in UEFI 2.5.
> +
> +  The EFI TLS Service Binding Protocol is used to locate EFI TLS
> + Protocol drivers  to create and destroy child of the driver to
> + communicate with other host using  TLS protocol.
> +  The EFI TLS Protocol provides the ability to manage TLS session.
> +
> +  Copyright (c) 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.
> +
> +  @par Revision Reference:
> +  This Protocol is introduced in UEFI Specification 2.5
> +
> +**/
> +
> +#ifndef __EFI_TLS_PROTOCOL_H__
> +#define __EFI_TLS_PROTOCOL_H__
> +
> +///
> +/// The EFI TLS Service Binding Protocol is used to locate EFI TLS
> +Protocol drivers to /// create and destroy child of the driver to
> +communicate with other host using TLS /// protocol.
> +///
> +#define EFI_TLS_SERVICE_BINDING_PROTOCOL_GUID \
> +  { \
> +0x952cb795, 0xff36, 0x48cf, {0xa2, 0x49, 0x4d, 0xf4, 0x86, 0xd6,
> +0xab, 0x8d } \
> +  }
> +
> +///
> +/// The EFI TLS protocol provides the ability to manage TLS session.
> +///
> +#define EFI_TLS_PROTOCOL_GUID \
> +  { \
> +0xca959f, 0x6cfa, 0x4db1, {0x95, 0xbc, 0xe4, 0x6c, 0x47, 0x51,
> +0x43, 0x90 } \
> +  }
> +
> +typedef struct _EFI_TLS_PROTOCOL EFI_TLS_PROTOCOL;
> +
> +///
> +/// EFI_TLS_SESSION_DATA_TYPE
> +///
> +typedef enum {
> +  ///
> +  /// Session Configuration
> +  ///
> +
> +  ///
> +  /// TLS session Version. The corresponding Data is of type
> EFI_TLS_VERSION.
> +  ///
> +  EfiTlsVersion,
> +  ///
> +  /// TLS session as client or as server. The corresponding Data is of
> + /// EFI_TLS_CONNECTION_END.
> +  ///
> +  EfiTlsConnectionEnd,
> +  ///
> +  /// A priority list of preferred algorithms for the TLS session.
> +  /// The corresponding Data is a list of EFI_TLS_CIPHER.
> +  ///
> +  EfiTlsCipherList,
> +  ///
> +  /// TLS session compression method.
> +  /// The corresponding Data is of type EFI_TLS_COMPRESSION.
> +  ///
> +  EfiTlsCompressionMethod,
> +  ///
> +  /// TLS session extension data.
> +  /// The corresponding Data is a list of type EFI_TLS_EXTENDION.
> +  ///
> +  EfiTlsExtensionData,
> +  ///
> +  /// TLS session verify method.
> +  /// The corresponding Data is of type EFI_TLS_VERIFY.
> +  ///
> +  EfiTlsVerifyMethod,
> +  ///
> +  /// TLS session data session ID.
> +  /// For SetSessionData(), it is TLS session ID used for session resumption.
> +  /// For GetSessionData(), it is the TLS session ID used for current 
> session.
> +  /// The corresponding Data is of type EFI_TLS_SESSION_ID.
> +  ///
> +  EfiTlsSessionID,
> +  ///
> +  /// TLS session data session state.
> +  /// The corresponding Data is of type EFI_TLS_SESSION_STATE.
> +  ///
> +  EfiTlsSessionState,
> +
> +  ///
> +  /// Session information
> +  ///
> +
> +  ///
> +  /// TLS session data client random.
> +  /// The corresponding Data is of type 

[edk2] [PATCH 2/4] UefiCpuPkg/Include: Update Skylake MSR header file with SDM (Sep.2016)

2016-12-14 Thread Hao Wu
https://bugzilla.tianocore.org/show_bug.cgi?id=176

Update the MSR header file of Skylake processor according to Intel(R) 64
and IA-32 Architectures Software Developer's Manual, Volume 3, September
2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.15.

Summary of incompatible changes:
1. MSR (address 38EH) IA32_PERF_GLOBAL_STAUS has been renamed to
IA32_PERF_GLOBAL_STATUS
Typo 'STAUS' has been fixed in SDM.

Cc: Michael Kinney 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
Reviewed-by: Jeff Fan 
---
 UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h | 1189 +-
 1 file changed, 1169 insertions(+), 20 deletions(-)

diff --git a/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h 
b/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h
index 604b98f..23ca3e1 100644
--- a/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h
+++ b/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h
@@ -17,7 +17,7 @@
 
   @par Specification Reference:
   Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3,
-  December 2015, Chapter 35 Model-Specific-Registers (MSR), Section 35-14.
+  September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.15.
 
 **/
 
@@ -146,28 +146,28 @@ typedef union {
 
 
 /**
-  See Table 35-2. See Section 18.2.2.3, "Full-Width Writes to Performance
-  Counter Registers.".
+  See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring
+  Version 4.".
 
-  @param  ECX  MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS (0x038E)
+  @param  ECX  MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS (0x038E)
   @param  EAX  Lower 32-bits of MSR value.
-   Described by the type 
MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS_REGISTER.
+   Described by the type 
MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER.
   @param  EDX  Upper 32-bits of MSR value.
-   Described by the type 
MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS_REGISTER.
+   Described by the type 
MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER.
 
   Example usage
   @code
-  MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS_REGISTER  Msr;
+  MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER  Msr;
 
-  Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS);
-  AsmWriteMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS, Msr.Uint64);
+  Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS);
+  AsmWriteMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS, Msr.Uint64);
   @endcode
-  @note MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS is defined as 
IA32_PERF_GLOBAL_STAUS in SDM.
+  @note MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS is defined as 
IA32_PERF_GLOBAL_STATUS in SDM.
 **/
-#define MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS   0x038E
+#define MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS  0x038E
 
 /**
-  MSR information returned for MSR index #MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS
+  MSR information returned for MSR index #MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS
 **/
 typedef union {
   ///
@@ -254,12 +254,12 @@ typedef union {
   /// All bit fields as a 64-bit value
   ///
   UINT64  Uint64;
-} MSR_SKYLAKE_IA32_PERF_GLOBAL_STAUS_REGISTER;
+} MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER;
 
 
 /**
-  See Table 35-2. See Section 18.2.2.3, "Full-Width Writes to Performance
-  Counter Registers.".
+  See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring
+  Version 4.".
 
   @param  ECX  MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET (0x0390)
   @param  EAX  Lower 32-bits of MSR value.
@@ -371,8 +371,8 @@ typedef union {
 
 
 /**
-  See Table 35-2. See Section 18.2.2.3, "Full-Width Writes to Performance
-  Counter Registers.".
+  See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring
+  Version 4.".
 
   @param  ECX  MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET (0x0391)
   @param  EAX  Lower 32-bits of MSR value.
@@ -541,6 +541,25 @@ typedef union {
 
 
 /**
+  Package. PP0 Energy Status (R/O)  See Section 14.9.4, "PP0/PP1 RAPL
+  Domains.".
+
+  @param  ECX  MSR_SKYLAKE_PP0_ENERGY_STATUS (0x0639)
+  @param  EAX  Lower 32-bits of MSR value.
+  @param  EDX  Upper 32-bits of MSR value.
+
+  Example usage
+  @code
+  UINT64  Msr;
+
+  Msr = AsmReadMsr64 (MSR_SKYLAKE_PP0_ENERGY_STATUS);
+  @endcode
+  @note MSR_SKYLAKE_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in 
SDM.
+**/
+#define MSR_SKYLAKE_PP0_ENERGY_STATUS0x0639
+
+
+/**
   Platform*. Platform Energy Counter. (R/O). This MSR is valid only if both
   platform vendor hardware implementation and BIOS enablement support it. This
   MSR will read 0 if not valid.
@@ -611,6 +630,187 @@ typedef union {
 
 
 /**
+  Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency
+  refers to processor core frequency).
+
+  @param  ECX  MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS (0x064F)
+  @param  EAX  Lower 32-bits of MSR value.
+   Described by the type 

[edk2] [PATCH 3/4] UefiCpuPkg/Include: Add Goldmont MSR header file with SDM (Sep.2016)

2016-12-14 Thread Hao Wu
https://bugzilla.tianocore.org/show_bug.cgi?id=176

Add the MSR header file of Goldmont processor according to Intel(R) 64 and
IA-32 Architectures Software Developer's Manual, Volume 3, September 2016,
Chapter 35 Model-Specific-Registers (MSR), Section 35.5.

Cc: Michael Kinney 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
Reviewed-by: Jeff Fan 
---
 UefiCpuPkg/Include/Register/Msr.h |3 +-
 UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h | 2515 +
 2 files changed, 2517 insertions(+), 1 deletion(-)
 create mode 100644 UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h

diff --git a/UefiCpuPkg/Include/Register/Msr.h 
b/UefiCpuPkg/Include/Register/Msr.h
index ffa6d44..0ac8d5b 100644
--- a/UefiCpuPkg/Include/Register/Msr.h
+++ b/UefiCpuPkg/Include/Register/Msr.h
@@ -17,7 +17,7 @@
 
   @par Specification Reference:
   Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3,
-  December 2015, Chapter 35 Model-Specific-Registers (MSR), Chapter 35.
+  September 2016, Chapter 35 Model-Specific-Registers (MSR), Chapter 35.
 
 **/
 
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h 
b/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h
new file mode 100644
index 000..58b9c57
--- /dev/null
+++ b/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h
@@ -0,0 +1,2515 @@
+/** @file
+  MSR Definitions for Intel Atom processors based on the Goldmont 
microarchitecture.
+
+  Provides defines for Machine Specific Registers(MSR) indexes. Data structures
+  are provided for MSRs that contain one or more bit fields.  If the MSR value
+  returned is a single 32-bit or 64-bit value, then a data structure is not
+  provided for that MSR.
+
+  Copyright (c) 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.
+
+  @par Specification Reference:
+  Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3,
+  September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.5.
+
+**/
+
+#ifndef __GOLDMONT_MSR_H__
+#define __GOLDMONT_MSR_H__
+
+#include 
+
+/**
+  Core. Control Features in Intel 64Processor (R/W).
+
+  @param  ECX  MSR_GOLDMONT_FEATURE_CONTROL (0x003A)
+  @param  EAX  Lower 32-bits of MSR value.
+   Described by the type MSR_GOLDMONT_FEATURE_CONTROL_REGISTER.
+  @param  EDX  Upper 32-bits of MSR value.
+   Described by the type MSR_GOLDMONT_FEATURE_CONTROL_REGISTER.
+
+  Example usage
+  @code
+  MSR_GOLDMONT_FEATURE_CONTROL_REGISTER  Msr;
+
+  Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_FEATURE_CONTROL);
+  AsmWriteMsr64 (MSR_GOLDMONT_FEATURE_CONTROL, Msr.Uint64);
+  @endcode
+  @note MSR_GOLDMONT_FEATURE_CONTROL is defined as IA32_FEATURE_CONTROL in SDM.
+**/
+#define MSR_GOLDMONT_FEATURE_CONTROL 0x003A
+
+/**
+  MSR information returned for MSR index #MSR_GOLDMONT_FEATURE_CONTROL
+**/
+typedef union {
+  ///
+  /// Individual bit fields
+  ///
+  struct {
+///
+/// [Bit 0] Lock bit (R/WL)
+///
+UINT32  Lock:1;
+///
+/// [Bit 1] Enable VMX inside SMX operation (R/WL)
+///
+UINT32  EnableVmxInsideSmx:1;
+///
+/// [Bit 2] Enable VMX outside SMX operation (R/WL)
+///
+UINT32  EnableVmxOutsideSmx:1;
+UINT32  Reserved1:5;
+///
+/// [Bits 14:8] SENTER local function enables (R/WL)
+///
+UINT32  SenterLocalFunctionEnables:7;
+///
+/// [Bit 15] SENTER global functions enable (R/WL)
+///
+UINT32  SenterGlobalEnable:1;
+UINT32  Reserved2:2;
+///
+/// [Bit 18] SGX global functions enable (R/WL)
+///
+UINT32  SgxEnable:1;
+UINT32  Reserved3:13;
+UINT32  Reserved4:32;
+  } Bits;
+  ///
+  /// All bit fields as a 32-bit value
+  ///
+  UINT32  Uint32;
+  ///
+  /// All bit fields as a 64-bit value
+  ///
+  UINT64  Uint64;
+} MSR_GOLDMONT_FEATURE_CONTROL_REGISTER;
+
+
+/**
+  Package. See http://biosbits.org.
+
+  @param  ECX  MSR_GOLDMONT_PLATFORM_INFO (0x00CE)
+  @param  EAX  Lower 32-bits of MSR value.
+   Described by the type MSR_GOLDMONT_PLATFORM_INFO_REGISTER.
+  @param  EDX  Upper 32-bits of MSR value.
+   Described by the type MSR_GOLDMONT_PLATFORM_INFO_REGISTER.
+
+  Example usage
+  @code
+  MSR_GOLDMONT_PLATFORM_INFO_REGISTER  Msr;
+
+  Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PLATFORM_INFO);
+  AsmWriteMsr64 

[edk2] [PATCH 0/4] Update CPUID & MSR header files with SDM (Sep.2016)

2016-12-14 Thread Hao Wu
https://bugzilla.tianocore.org/show_bug.cgi?id=176

According to the latest version (Sep.'16) of Intel(R) 64 and IA-32
Architectures Software Developer's Manual (SDM), this patch series will
update the MSR and CPUID related definitions in .h files under
UefiCpuPkg/Include/Register.

Cc: Michael Kinney 
Cc: Jeff Fan 

Hao Wu (4):
  UefiCpuPkg/Include: Update MSR header files with SDM (Sep.2016)
  UefiCpuPkg/Include: Update Skylake MSR header file with SDM (Sep.2016)
  UefiCpuPkg/Include: Add Goldmont MSR header file with SDM (Sep.2016)
  UefiCpuPkg/Cpuid.h: Update CPUID definitions with SDM (Sep.2016)

 UefiCpuPkg/Application/Cpuid/Cpuid.c |  115 +-
 UefiCpuPkg/Include/Register/ArchitecturalMsr.h   |  159 +-
 UefiCpuPkg/Include/Register/Cpuid.h  |  363 +++-
 UefiCpuPkg/Include/Register/Msr.h|3 +-
 UefiCpuPkg/Include/Register/Msr/AtomMsr.h|  167 +-
 UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h   |   43 +-
 UefiCpuPkg/Include/Register/Msr/Core2Msr.h   |  286 +--
 UefiCpuPkg/Include/Register/Msr/CoreMsr.h|   64 +-
 UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h| 2515 ++
 UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h|  451 ++--
 UefiCpuPkg/Include/Register/Msr/HaswellMsr.h |   62 +-
 UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h   |  416 ++--
 UefiCpuPkg/Include/Register/Msr/NehalemMsr.h |  340 +--
 UefiCpuPkg/Include/Register/Msr/P6Msr.h  |6 +-
 UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h|  146 +-
 UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h|   26 +-
 UefiCpuPkg/Include/Register/Msr/PentiumMsr.h |8 +-
 UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h |  537 ++---
 UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h  |  411 ++--
 UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h | 1189 +-
 UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h|2 +-
 UefiCpuPkg/Include/Register/Msr/XeonDMsr.h   |  456 +---
 UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h  |   74 +-
 UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h |  314 +--
 24 files changed, 5323 insertions(+), 2830 deletions(-)
 create mode 100644 UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h

-- 
1.9.5.msysgit.0

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


Re: [edk2] [PATCH v2 10/10] Nt32Pkg: Enable HTTPS boot feature for Nt32 platform

2016-12-14 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: Wu, Jiaxin
> Sent: Wednesday, December 14, 2016 4:05 PM
> To: edk2-devel@lists.01.org
> Cc: Long, Qin ; Ni, Ruiyu ; Ye, Ting
> ; Fu, Siyuan ; Zhang, Lubo
> ; Thomas Palmer ; Yao,
> Jiewen ; Wu, Jiaxin 
> Subject: [PATCH v2 10/10] Nt32Pkg: Enable HTTPS boot feature for Nt32
> platform
> 
> v2:
> * Rename flag: HTTPS_BOOT_ENABLE -> TLS_ENABLE
> 
> This path is used to enable HTTPS boot feature for Nt32 platform.
> 
> Cc: Long Qin 
> Cc: Ni Ruiyu 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Zhang Lubo 
> Cc: Thomas Palmer 
> Cc: Yao Jiewen 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin 
> ---
>  Nt32Pkg/Nt32Pkg.dsc | 15 ++-  Nt32Pkg/Nt32Pkg.fdf |  4
> 
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc index
> 79ab2f7..0a59e46 100644
> --- a/Nt32Pkg/Nt32Pkg.dsc
> +++ b/Nt32Pkg/Nt32Pkg.dsc
> @@ -43,10 +43,17 @@
>#
># Defines for default states.  These can be changed on the command line.
># -D FLAG=VALUE
>#
>DEFINE SECURE_BOOT_ENABLE  = FALSE
> +
> +  #
> +  # This flag is to enable or disable TLS feature.
> +  # These can be changed on the command line.
> +  # -D FLAG=VALUE
> +  #
> +  DEFINE TLS_ENABLE  = TRUE
> 
> 
> ##
> ##
>  #
>  # SKU Identification section - list of all SKU IDs supported by this
>  #  Platform.
> @@ -189,10 +196,11 @@
> 
> OemHookStatusCodeLib|Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/
> DxeNt32OemHookStatusCodeLib.inf
> 
> PeCoffExtraActionLib|Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt
> 32PeCoffExtraActionLib.inf
> 
> ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeE
> xtractGuidedSectionLib.inf
>WinNtLib|Nt32Pkg/Library/DxeWinNtLib/DxeWinNtLib.inf
>BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> +  TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
> 
>  [LibraryClasses.common.DXE_CORE]
>HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
> 
> MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLi
> b/DxeCoreMemoryAllocationLib.inf
>PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> @@ -232,11 +240,11 @@
>gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x1f
> 
> gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume|L"..\\Fv\\Nt32.fd"
>gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareBlockSize|0x1
>gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
> hange|FALSE
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> +!if $(SECURE_BOOT_ENABLE) == TRUE || $(TLS_ENABLE) == TRUE
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
>  !endif
> 
>  !ifndef $(USE_OLD_SHELL)
>gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5,
> 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4,
> 0xD1 } @@ -437,10 +445,15 @@
> 
>NetworkPkg/HttpBootDxe/HttpBootDxe.inf
>NetworkPkg/DnsDxe/DnsDxe.inf
>NetworkPkg/HttpDxe/HttpDxe.inf
>NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
> +
> +!if $(TLS_ENABLE) == TRUE
> +  NetworkPkg/TlsDxe/TlsDxe.inf
> +  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
> +!endif
> 
>MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
>MdeModulePkg/Application/UiApp/UiApp.inf{
>  
> 
> NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
> diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf index
> cf00a13..c198d73 100644
> --- a/Nt32Pkg/Nt32Pkg.fdf
> +++ b/Nt32Pkg/Nt32Pkg.fdf
> @@ -260,10 +260,14 @@ INF
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
>  INF  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
>  INF  NetworkPkg/HttpBootDxe/HttpBootDxe.inf
>  INF  NetworkPkg/DnsDxe/DnsDxe.inf
>  INF  NetworkPkg/HttpDxe/HttpDxe.inf
>  INF  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
> +!if $(TLS_ENABLE) == TRUE
> +INF  NetworkPkg/TlsDxe/TlsDxe.inf
> +INF  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
> +!endif
>  INF
> MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuAp
> p.inf
> 
> ##
> ##
>  #
>  # FILE statements are provided so that a platform integrator can include  #
> complete EFI FFS files, as well as a method for constructing FFS files
> --
> 1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org

[edk2] [PATCH v2 10/10] Nt32Pkg: Enable HTTPS boot feature for Nt32 platform

2016-12-14 Thread Jiaxin Wu
v2:
* Rename flag: HTTPS_BOOT_ENABLE -> TLS_ENABLE

This path is used to enable HTTPS boot feature for Nt32 platform.

Cc: Long Qin 
Cc: Ni Ruiyu 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Cc: Thomas Palmer 
Cc: Yao Jiewen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 Nt32Pkg/Nt32Pkg.dsc | 15 ++-
 Nt32Pkg/Nt32Pkg.fdf |  4 
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc
index 79ab2f7..0a59e46 100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -43,10 +43,17 @@
   #
   # Defines for default states.  These can be changed on the command line.
   # -D FLAG=VALUE
   #
   DEFINE SECURE_BOOT_ENABLE  = FALSE
+  
+  #
+  # This flag is to enable or disable TLS feature.  
+  # These can be changed on the command line.
+  # -D FLAG=VALUE
+  #
+  DEFINE TLS_ENABLE  = TRUE
 
 

 #
 # SKU Identification section - list of all SKU IDs supported by this
 #  Platform.
@@ -189,10 +196,11 @@
   
OemHookStatusCodeLib|Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.inf
   
PeCoffExtraActionLib|Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.inf
   
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
   WinNtLib|Nt32Pkg/Library/DxeWinNtLib/DxeWinNtLib.inf
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+  TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
 
 [LibraryClasses.common.DXE_CORE]
   HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
   
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
@@ -232,11 +240,11 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x1f
   gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume|L"..\\Fv\\Nt32.fd"
   gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareBlockSize|0x1
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
-!if $(SECURE_BOOT_ENABLE) == TRUE
+!if $(SECURE_BOOT_ENABLE) == TRUE || $(TLS_ENABLE) == TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
 !endif
 
 !ifndef $(USE_OLD_SHELL)
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 
0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
@@ -437,10 +445,15 @@
 
   NetworkPkg/HttpBootDxe/HttpBootDxe.inf
   NetworkPkg/DnsDxe/DnsDxe.inf
   NetworkPkg/HttpDxe/HttpDxe.inf
   NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
+   
+!if $(TLS_ENABLE) == TRUE
+  NetworkPkg/TlsDxe/TlsDxe.inf
+  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
+!endif
 
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   MdeModulePkg/Application/UiApp/UiApp.inf{
 
   NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf
index cf00a13..c198d73 100644
--- a/Nt32Pkg/Nt32Pkg.fdf
+++ b/Nt32Pkg/Nt32Pkg.fdf
@@ -260,10 +260,14 @@ INF  
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
 INF  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
 INF  NetworkPkg/HttpBootDxe/HttpBootDxe.inf
 INF  NetworkPkg/DnsDxe/DnsDxe.inf
 INF  NetworkPkg/HttpDxe/HttpDxe.inf
 INF  NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
+!if $(TLS_ENABLE) == TRUE
+INF  NetworkPkg/TlsDxe/TlsDxe.inf
+INF  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
+!endif
 INF  MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
 

 #
 # FILE statements are provided so that a platform integrator can include
 # complete EFI FFS files, as well as a method for constructing FFS files
-- 
1.9.5.msysgit.1

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