[edk2] [Patch] BaseTools: refactor the error for PCD value is negative or exceed max

2018-09-28 Thread Yonghong Zhu
From: zhijufan 

refactor the error handling for the PCD value that is negative or it
exceed the max value.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/GenC.py | 57 -
 BaseTools/Source/Python/BPDG/GenVpd.py  | 44 -
 BaseTools/Source/Python/Common/Misc.py  |  4 +++
 3 files changed, 30 insertions(+), 75 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index f455f83..09626d0 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1013,54 +1013,23 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
 ValueNumber = int (Value, 0)
 except:
 EdkLogger.error("build", AUTOGEN_ERROR,
 "PCD value is not valid dec or hex number for 
datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, 
TokenCName),
 ExtraData="[%s]" % str(Info))
-if Pcd.DatumType == TAB_UINT64:
-if ValueNumber < 0:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"PCD can't be set to negative value for 
datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, 
TokenCName),
-ExtraData="[%s]" % str(Info))
-elif ValueNumber >= 0x1:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"Too large PCD value for datum type [%s] 
of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
-ExtraData="[%s]" % str(Info))
-if not Value.endswith('ULL'):
-Value += 'ULL'
-elif Pcd.DatumType == TAB_UINT32:
-if ValueNumber < 0:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"PCD can't be set to negative value for 
datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, 
TokenCName),
-ExtraData="[%s]" % str(Info))
-elif ValueNumber >= 0x1:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"Too large PCD value for datum type [%s] 
of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
-ExtraData="[%s]" % str(Info))
-if not Value.endswith('U'):
-Value += 'U'
-elif Pcd.DatumType == TAB_UINT16:
-if ValueNumber < 0:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"PCD can't be set to negative value for 
datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, 
TokenCName),
-ExtraData="[%s]" % str(Info))
-elif ValueNumber >= 0x1:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"Too large PCD value for datum type [%s] 
of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
-ExtraData="[%s]" % str(Info))
-if not Value.endswith('U'):
-Value += 'U'
-elif Pcd.DatumType == TAB_UINT8:
-if ValueNumber < 0:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"PCD can't be set to negative value for 
datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, 
TokenCName),
-ExtraData="[%s]" % str(Info))
-elif ValueNumber >= 0x100:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"Too large PCD value for datum type [%s] 
of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
-ExtraData="[%s]" % str(Info))
-if not Value.endswith('U'):
-Value += 'U'
+if ValueNumber < 0:
+EdkLogger.error("build", AUTOGEN_ERROR,
+"PCD can't be set to negative value for datum 
type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
+ExtraData="[%s]" % str(Info))
+elif ValueNumber > MAX_VAL_TYPE[Pcd.DatumType]:
+EdkLogger.error("build", AUTOGEN_ERROR,
+"Too large PCD value for datum type [%s] of 
PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
+ExtraData="[%s]" % str(Info))
+if Pcd.DatumType == TAB_UINT64 and not Value.endswith('ULL'):
+

[edk2] [PATCH v3] MdeModulePkg/RegularExpressionDxe:disable wraning to pass gcc4.8 build

2018-09-28 Thread Dongao Guo
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dongao Guo 
---
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf 
b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
index 16e91bd..07bc02e 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
@@ -109,3 +109,6 @@
 
   # Oniguruma: error: variable 'fp' set but not used
   GCC:*_*_*_CC_FLAGS = -Wno-error=unused-but-set-variable
+
+  # Oniguruma: tag_end in parse_callout_of_name
+  GCC:*_*_*_CC_FLAGS = -Wno-error=maybe-uninitialized
-- 
2.6.1.windows.1

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


Re: [edk2] [PATCH v2 1/5] MdePkg/BaseLib: Add new AsmLfence API

2018-09-28 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Wu, Hao A
> Sent: Tuesday, September 25, 2018 2:13 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Ard Biesheuvel 
> ; Leif Lindholm ; Laszlo
> Ersek ; Yao, Jiewen ; Kinney, 
> Michael D ; Gao, Liming
> 
> Subject: [PATCH v2 1/5] MdePkg/BaseLib: Add new AsmLfence API
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1193
> 
> This commit will add a new BaseLib API AsmLfence(). This API will perform
> a serializing operation on all load-from-memory instructions that were
> issued prior to the call of this function. Please note that this API is
> only available on IA-32 and x64.
> 
> The purpose of adding this API is to mitigate of the [CVE-2017-5753]
> Bounds Check Bypass issue when untrusted data are being processed within
> SMM. More details can be referred at the 'Bounds check bypass mitigation'
> section at the below link:
> 
> https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation
> 
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Laszlo Ersek 
> Cc: Jiewen Yao 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdePkg/Include/Library/BaseLib.h| 13 +++
>  MdePkg/Library/BaseLib/BaseLib.inf  |  2 ++
>  MdePkg/Library/BaseLib/Ia32/Lfence.nasm | 37 +++
>  MdePkg/Library/BaseLib/X64/Lfence.nasm  | 38 
>  4 files changed, 90 insertions(+)
> 
> diff --git a/MdePkg/Include/Library/BaseLib.h 
> b/MdePkg/Include/Library/BaseLib.h
> index 123ae19dc2..656b7736b1 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -9139,6 +9139,19 @@ AsmWriteTr (
>);
> 
>  /**
> +  Performs a serializing operation on all load-from-memory instructions that
> +  were issued prior the AsmLfence function.
> +
> +  Executes a LFENCE instruction. This function is only available on IA-32 
> and x64.
> +
> +**/
> +VOID
> +EFIAPI
> +AsmLfence (
> +  VOID
> +  );
> +
> +/**
>Patch the immediate operand of an IA32 or X64 instruction such that the 
> byte,
>word, dword or qword operand is encoded at the end of the instruction's
>binary representation.
> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf 
> b/MdePkg/Library/BaseLib/BaseLib.inf
> index a1b5ec4b75..ed15c025f9 100644
> --- a/MdePkg/Library/BaseLib/BaseLib.inf
> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
> @@ -68,6 +68,7 @@
> 
>  [Sources.Ia32]
>Ia32/WriteTr.nasm
> +  Ia32/Lfence.nasm
> 
>Ia32/Wbinvd.c | MSFT
>Ia32/WriteMm7.c | MSFT
> @@ -346,6 +347,7 @@
>X64/EnableCache.nasm
>X64/DisableCache.nasm
>X64/WriteTr.nasm
> +  X64/Lfence.nasm
> 
>X64/CpuBreakpoint.c | MSFT
>X64/WriteMsr64.c | MSFT
> diff --git a/MdePkg/Library/BaseLib/Ia32/Lfence.nasm 
> b/MdePkg/Library/BaseLib/Ia32/Lfence.nasm
> new file mode 100644
> index 00..f8b2550ef8
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/Ia32/Lfence.nasm
> @@ -0,0 +1,37 @@
> +;--
>  ;
> +; Copyright (c) 2018, Intel Corporation. All rights reserved.
> +; This program and the accompanying materials
> +; are licensed and made available under the terms and conditions of the BSD 
> License
> +; which accompanies this distribution.  The full text of the license may be 
> found at
> +; http://opensource.org/licenses/bsd-license.php.
> +;
> +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +;
> +; Module Name:
> +;
> +;   Lfence.nasm
> +;
> +; Abstract:
> +;
> +;   Performs a serializing operation on all load-from-memory instructions 
> that
> +;   were issued prior to the call of this function.
> +;
> +; Notes:
> +;
> +;--
> +
> +SECTION .text
> +
> +;--
> +; VOID
> +; EFIAPI
> +; AsmLfence (
> +;   VOID
> +;   );
> +;--
> +global ASM_PFX(AsmLfence)
> +ASM_PFX(AsmLfence):
> +lfence
> +ret
> +
> diff --git a/MdePkg/Library/BaseLib/X64/Lfence.nasm 
> b/MdePkg/Library/BaseLib/X64/Lfence.nasm
> new file mode 100644
> index 00..e81c77964b
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/X64/Lfence.nasm
> @@ -0,0 +1,38 @@
> +;--
>  ;
> +; Copyright (c) 2018, Intel Corporation. All rights reserved.
> +; This program and the accompanying materials
> +; are licensed and made available under the terms and conditions of the BSD 
> License
> +; which accompanies this distribution.  The full text of the license may be 
> found at
> +; http://opensource.org/licenses/bsd-license.php.
> +;
> +; THE 

[edk2] [PATCH V2] MdeModulePkg/RegularExpressionDxe:disable wraning to pass gcc4.8 build

2018-09-28 Thread Dongao Guo
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
---
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf 
b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
index 16e91bd..07bc02e 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
@@ -109,3 +109,6 @@
 
   # Oniguruma: error: variable 'fp' set but not used
   GCC:*_*_*_CC_FLAGS = -Wno-error=unused-but-set-variable
+
+  # Oniguruma: tag_end in parse_callout_of_name
+  GCC:*_*_*_CC_FLAGS = -Wno-error=maybe-uninitialized
-- 
2.6.1.windows.1

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


Re: [edk2] [PATCH] MdeModulePkg:disable wraning to pass gcc4.8 build

2018-09-28 Thread Zeng, Star
No Signed-off-by?

Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Dongao 
Guo
Sent: Saturday, September 29, 2018 9:55 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming 
Subject: [edk2] [PATCH] MdeModulePkg:disable wraning to pass gcc4.8 build

Change-Id: I782962e4994a8edf14beb7ede8b1aabe233dc3a8
Contributed-under: TianoCore Contribution Agreement 1.1
---
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf 
b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
index 16e91bd..07bc02e 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.i
+++ nf
@@ -109,3 +109,6 @@
 
   # Oniguruma: error: variable 'fp' set but not used
   GCC:*_*_*_CC_FLAGS = -Wno-error=unused-but-set-variable
+
+  # Oniguruma: tag_end in parse_callout_of_name  GCC:*_*_*_CC_FLAGS = 
+ -Wno-error=maybe-uninitialized
--
2.6.1.windows.1

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


Re: [edk2] [PATCH] MdeModulePkg:disable wraning to pass gcc4.8 build

2018-09-28 Thread Gao, Liming
Dongao:
  Please remove Change-id in commit message. And, update commit title: 
MdeModulePkg RegularExpressionDxe: Disable warning to pass gcc4.8 build

Thanks
Liming
> -Original Message-
> From: Guo, Dongao
> Sent: Saturday, September 29, 2018 9:55 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [PATCH] MdeModulePkg:disable wraning to pass gcc4.8 build
> 
> Change-Id: I782962e4994a8edf14beb7ede8b1aabe233dc3a8
> Contributed-under: TianoCore Contribution Agreement 1.1
> ---
>  MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git 
> a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
> b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
> index 16e91bd..07bc02e 100644
> --- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
> +++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
> @@ -109,3 +109,6 @@
> 
># Oniguruma: error: variable 'fp' set but not used
>GCC:*_*_*_CC_FLAGS = -Wno-error=unused-but-set-variable
> +
> +  # Oniguruma: tag_end in parse_callout_of_name
> +  GCC:*_*_*_CC_FLAGS = -Wno-error=maybe-uninitialized
> --
> 2.6.1.windows.1

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


[edk2] [PATCH] MdeModulePkg:disable wraning to pass gcc4.8 build

2018-09-28 Thread Dongao Guo
Change-Id: I782962e4994a8edf14beb7ede8b1aabe233dc3a8
Contributed-under: TianoCore Contribution Agreement 1.1
---
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf 
b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
index 16e91bd..07bc02e 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
@@ -109,3 +109,6 @@
 
   # Oniguruma: error: variable 'fp' set but not used
   GCC:*_*_*_CC_FLAGS = -Wno-error=unused-but-set-variable
+
+  # Oniguruma: tag_end in parse_callout_of_name
+  GCC:*_*_*_CC_FLAGS = -Wno-error=maybe-uninitialized
-- 
2.6.1.windows.1

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


[edk2] [Patch] UefiCpuPkg/Include/Register/Msr/GoldmontPlusMsr.h: Change to DOS format file.

2018-09-28 Thread Eric Dong
Follow EDKII coding style, change file format to dos style.

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

Cc: Dandan Bi 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/Include/Register/Msr/GoldmontPlusMsr.h | 544 +++---
 1 file changed, 272 insertions(+), 272 deletions(-)

diff --git a/UefiCpuPkg/Include/Register/Msr/GoldmontPlusMsr.h 
b/UefiCpuPkg/Include/Register/Msr/GoldmontPlusMsr.h
index d050464b7f..64f3e14db3 100644
--- a/UefiCpuPkg/Include/Register/Msr/GoldmontPlusMsr.h
+++ b/UefiCpuPkg/Include/Register/Msr/GoldmontPlusMsr.h
@@ -1,272 +1,272 @@
-/** @file
-  MSR Defintions for Intel Atom processors based on the Goldmont Plus 
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) 2018, Intel Corporation. All rights reserved.
-  This program and the accompanying materials
-  are licensed and made available under the terms and conditions of the BSD 
License
-  which accompanies this distribution.  The full text of the license may be 
found at
-  http://opensource.org/licenses/bsd-license.php
-
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-  @par Specification Reference:
-  Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 4,
-  May 2018, Volume 4: Model-Specific-Registers (MSR)
-
-**/
-
-#ifndef __GOLDMONT_PLUS_MSR_H__
-#define __GOLDMONT_PLUS_MSR_H__
-
-#include 
-
-/**
-  Is Intel Atom processors based on the Goldmont plus microarchitecture?
-
-  @param   DisplayFamily  Display Family ID
-  @param   DisplayModel   Display Model ID
-
-  @retval  TRUE   Yes, it is.
-  @retval  FALSE  No, it isn't.
-**/
-#define IS_GOLDMONT_PLUS_PROCESSOR(DisplayFamily, DisplayModel) \
-  (DisplayFamily == 0x06 && \
-   (\
-DisplayModel == 0x7A\
-)   \
-   )
-
-/**
-  Core. (R/W) See Table 2-2. See Section 18.6.2.4, "Processor Event Based
-  Sampling (PEBS).".
-
-  @param  ECX  MSR_GOLDMONT_PLUS_PEBS_ENABLE (0x03F1)
-  @param  EAX  Lower 32-bits of MSR value.
-   Described by the type MSR_GOLDMONT_PLUS_PEBS_ENABLE_REGISTER.
-  @param  EDX  Upper 32-bits of MSR value.
-   Described by the type MSR_GOLDMONT_PLUS_PEBS_ENABLE_REGISTER.
-
-  Example usage
-  @code
-  MSR_GOLDMONT_PLUS_PEBS_ENABLE_REGISTER  Msr;
-
-  Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PLUS_PEBS_ENABLE);
-  AsmWriteMsr64 (MSR_GOLDMONT_PLUS_PEBS_ENABLE, Msr.Uint64);
-  @endcode
-**/
-#define MSR_GOLDMONT_PLUS_PEBS_ENABLE0x03F1
-
-/**
-  MSR information returned for MSR index #MSR_GOLDMONT_PLUS_PEBS_ENABLE
-**/
-typedef union {
-  ///
-  /// Individual bit fields
-  ///
-  struct {
-///
-/// [Bit 0] Enable PEBS trigger and recording for the programmed event
-/// (precise or otherwise) on IA32_PMC0.
-///
-UINT32  Fix_Me_1:1;
-///
-/// [Bit 1] Enable PEBS trigger and recording for the programmed event
-/// (precise or otherwise) on IA32_PMC1.
-///
-UINT32  Fix_Me_2:1;
-///
-/// [Bit 2] Enable PEBS trigger and recording for the programmed event
-/// (precise or otherwise) on IA32_PMC2.
-///
-UINT32  Fix_Me_3:1;
-///
-/// [Bit 3] Enable PEBS trigger and recording for the programmed event
-/// (precise or otherwise) on IA32_PMC3.
-///
-UINT32  Fix_Me_4:1;
-UINT32  Reserved1:28;
-///
-/// [Bit 32] Enable PEBS trigger and recording for IA32_FIXED_CTR0.
-///
-UINT32  Fix_Me_5:1;
-///
-/// [Bit 33] Enable PEBS trigger and recording for IA32_FIXED_CTR1.
-///
-UINT32  Fix_Me_6:1;
-///
-/// [Bit 34] Enable PEBS trigger and recording for IA32_FIXED_CTR2.
-///
-UINT32  Fix_Me_7:1;
-UINT32  Reserved2:29;
-  } Bits;
-  ///
-  /// All bit fields as a 64-bit value
-  ///
-  UINT64  Uint64;
-} MSR_GOLDMONT_PLUS_PEBS_ENABLE_REGISTER;
-
-
-/**
-  Core. Last Branch Record N From IP (R/W) One of the three MSRs that make up
-  the first entry of the 32-entry LBR stack. The From_IP part of the stack
-  contains pointers to the source instruction. See also: -  Last Branch Record
-  Stack TOS at 1C9H. -  Section 17.7, "Last Branch, Call Stack, Interrupt, and
-  .. Exception Recording for Processors based on Goldmont Plus
-  Microarchitecture.".
-
-  @param  ECX  MSR_GOLDMONT_PLUS_LASTBRANCH_N_FROM_IP (0x068N)
-  @param  EAX  Lower 32-bits of MSR value.
-  @param  EDX  Upper 32-bits of MSR value.
-
-  Example usage
-  @code
-  UINT64  Msr;
-
-  Msr = AsmReadMsr64 (MSR_GOLDMONT_PLUS_LASTBRANCH_N_FROM_IP);
-  AsmWriteMsr64 (MSR_GOLDMONT_PLUS_LASTBRANCH_N_FROM_IP, Msr);
-  

[edk2] [PATCH v2 7/7] BaseTools/GenFds: create and use new variable in FdfParser

2018-09-28 Thread Jaben Carsey
replace lots of '}' and "}" with a shared new consistent variable.

Cc: Bob Feng 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 45 ++--
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 5a59a0a0d854..3645b4f0fff6 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -65,8 +65,9 @@ T_CHAR_TAB = '\t'
 T_CHAR_DOUBLE_QUOTE = '\"'
 T_CHAR_SINGLE_QUOTE = '\''
 T_CHAR_STAR = '*'
+T_CHAR_BRACE_R = '}'
 
-SEPARATORS = {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{', '}'}
+SEPARATORS = {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{', 
T_CHAR_BRACE_R}
 ALIGNMENTS = {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K", 
"64K", "128K",
 "256K", "512K", "1M", "2M", "4M", "8M", 
"16M"}
 ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
@@ -2021,7 +2022,7 @@ class FdfParser:
 DataString += self._Token
 DataString += TAB_COMMA_SPLIT
 
-if not self._IsToken("}"):
+if not self._IsToken(T_CHAR_BRACE_R):
 raise Warning.ExpectedCurlyClose(self.FileName, 
self.CurrentLineNumber)
 
 DataString = DataString.rstrip(TAB_COMMA_SPLIT)
@@ -2061,7 +2062,7 @@ class FdfParser:
 DataString += self._Token
 DataString += TAB_COMMA_SPLIT
 
-if not self._IsToken("}"):
+if not self._IsToken(T_CHAR_BRACE_R):
 raise Warning.ExpectedCurlyClose(self.FileName, 
self.CurrentLineNumber)
 
 DataString = DataString.rstrip(TAB_COMMA_SPLIT)
@@ -2329,10 +2330,10 @@ class FdfParser:
 DataString += self._Token
 DataString += TAB_COMMA_SPLIT
 
-if not self._IsToken("}"):
+if not self._IsToken(T_CHAR_BRACE_R):
 raise Warning.ExpectedCurlyClose(self.FileName, 
self.CurrentLineNumber)
 
-if not self._IsToken("}"):
+if not self._IsToken(T_CHAR_BRACE_R):
 raise Warning.ExpectedCurlyClose(self.FileName, 
self.CurrentLineNumber)
 
 DataString = DataString.rstrip(TAB_COMMA_SPLIT)
@@ -2347,7 +2348,7 @@ class FdfParser:
 
 FvObj.FvExtEntryData.append(self._Token)
 
-if not self._IsToken("}"):
+if not self._IsToken(T_CHAR_BRACE_R):
 raise Warning.ExpectedCurlyClose(self.FileName, 
self.CurrentLineNumber)
 
 return True
@@ -2383,7 +2384,7 @@ class FdfParser:
 if not IsInf and not IsFile:
 break
 
-if not self._IsToken("}"):
+if not self._IsToken(T_CHAR_BRACE_R):
 raise Warning.ExpectedCurlyClose(self.FileName, 
self.CurrentLineNumber)
 
 FvObj.AprioriSectionList.append(AprSectionObj)
@@ -2658,7 +2659,7 @@ class FdfParser:
 FfsFileObj.FileName = self._Token.replace('$(SPACE)', ' ')
 self._VerifyFile(FfsFileObj.FileName)
 
-if not self._IsToken("}"):
+if not self._IsToken(T_CHAR_BRACE_R):
 raise Warning.ExpectedCurlyClose(self.FileName, 
self.CurrentLineNumber)
 
 ## _GetRAWData() method
@@ -2683,7 +2684,7 @@ class FdfParser:
 raise Warning.Expected("Filename value", self.FileName, 
self.CurrentLineNumber)
 
 FileName = self._Token.replace('$(SPACE)', ' ')
-if FileName == '}':
+if FileName == T_CHAR_BRACE_R:
 self._UndoToken()
 raise Warning.Expected("Filename value", self.FileName, 
self.CurrentLineNumber)
 
@@ -2692,7 +2693,7 @@ class FdfParser:
 FfsFileObj.FileName.append(File.Path)
 FfsFileObj.SubAlignment.append(AlignValue)
 
-if self._IsToken("}"):
+if self._IsToken(T_CHAR_BRACE_R):
 self._UndoToken()
 break
 
@@ -2864,7 +2865,7 @@ class FdfParser:
 if not IsInf and not IsFile:
 break
 
-if not self._IsToken("}"):
+if not self._IsToken(T_CHAR_BRACE_R):
 raise Warning.ExpectedCurlyClose(self.FileName, 
self.CurrentLineNumber)
 
 FvImageSectionObj = FvImageSection()
@@ -2889,10 +2890,10 @@ class FdfParser:
 raise Warning.ExpectedEquals(self.FileName, 
self.CurrentLineNumber)
 if not self._IsToken("{"):
 raise Warning.ExpectedCurlyOpen(self.FileName, 
self.CurrentLineNumber)
-if not self._SkipToToken("}"):
+if not self._SkipToToken(T_CHAR_BRACE_R):
 raise Warning.Expected("Depex expression ending '}'", 
self.FileName, self.CurrentLineNumber)
 
-DepexSectionObj.Expression = 

[edk2] [PATCH v2 4/7] BaseTools/GenFds: remove MacroDict parameter

2018-09-28 Thread Jaben Carsey
The MacroDict parameter goes around in circles through 4 functions without use.
1. GetSectionData calls into GetLeafSection, otherwise doesn’t use MacroDict
2. GetLeafSection calls into GetFileStatement, otherwise doesn’t use MacroDict
3. GetFileStatement calls into GetFilePart, otherwise doesn’t use MacroDict
4. GetFilePart calls into GetSectionData, otherwise doesn’t use MacroDict
Go to 1 and repeat forever.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 48 +++-
 1 file changed, 16 insertions(+), 32 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index fa82d8f174d5..f8fefdc2e737 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -2113,12 +2113,12 @@ class FdfParser:
 if FvObj.FvNameString == 'TRUE' and not FvObj.FvNameGuid:
 raise Warning("FvNameString found but FvNameGuid was not found", 
self.FileName, self.CurrentLineNumber)
 
-self._GetAprioriSection(FvObj, FvObj.DefineVarDict.copy())
-self._GetAprioriSection(FvObj, FvObj.DefineVarDict.copy())
+self._GetAprioriSection(FvObj)
+self._GetAprioriSection(FvObj)
 
 while True:
 isInf = self._GetInfStatement(FvObj)
-isFile = self._GetFileStatement(FvObj, MacroDict = 
FvObj.DefineVarDict.copy())
+isFile = self._GetFileStatement(FvObj)
 if not isInf and not isFile:
 break
 
@@ -2353,11 +2353,10 @@ class FdfParser:
 #
 #   @param  selfThe object pointer
 #   @param  FvObj   for whom apriori is got
-#   @param  MacroDict   dictionary used to replace macro
 #   @retval TrueSuccessfully find apriori statement
 #   @retval False   Not able to find apriori statement
 #
-def _GetAprioriSection(self, FvObj, MacroDict = {}):
+def _GetAprioriSection(self, FvObj):
 if not self._IsKeyword("APRIORI"):
 return False
 
@@ -2372,7 +2371,6 @@ class FdfParser:
 AprSectionObj.AprioriType = AprType
 
 self._GetDefineStatements(AprSectionObj)
-MacroDict.update(AprSectionObj.DefineVarDict)
 
 while True:
 IsInf = self._GetInfStatement(AprSectionObj)
@@ -2526,11 +2524,10 @@ class FdfParser:
 #
 #   @param  selfThe object pointer
 #   @param  Obj for whom FILE statement is got
-#   @param  MacroDict   dictionary used to replace macro
 #   @retval TrueSuccessfully find FILE statement
 #   @retval False   Not able to find FILE statement
 #
-def _GetFileStatement(self, Obj, ForCapsule = False, MacroDict = {}):
+def _GetFileStatement(self, Obj, ForCapsule = False):
 if not self._IsKeyword("FILE"):
 return False
 
@@ -2561,7 +2558,7 @@ class FdfParser:
 
 FfsFileObj.NameGuid = self._Token
 
-self._GetFilePart(FfsFileObj, MacroDict.copy())
+self._GetFilePart(FfsFileObj)
 
 if ForCapsule:
 capsuleFfs = CapsuleFfs()
@@ -2608,9 +2605,8 @@ class FdfParser:
 #
 #   @param  selfThe object pointer
 #   @param  FfsFileObj   for whom component is got
-#   @param  MacroDict   dictionary used to replace macro
 #
-def _GetFilePart(self, FfsFileObj, MacroDict = {}):
+def _GetFilePart(self, FfsFileObj):
 self._GetFileOpts(FfsFileObj)
 
 if not self._IsToken("{"):
@@ -2645,11 +2641,11 @@ class FdfParser:
 
 elif self._Token in {TAB_DEFINE, "APRIORI", "SECTION"}:
 self._UndoToken()
-self._GetSectionData(FfsFileObj, MacroDict)
+self._GetSectionData(FfsFileObj)
 
 elif hasattr(FfsFileObj, 'FvFileType') and FfsFileObj.FvFileType == 
'RAW':
 self._UndoToken()
-self._GetRAWData(FfsFileObj, MacroDict)
+self._GetRAWData(FfsFileObj)
 
 else:
 FfsFileObj.CurrentLineNum = self.CurrentLineNumber
@@ -2666,9 +2662,8 @@ class FdfParser:
 #
 #   @param  self The object pointer
 #   @param  FfsFileObj   for whom section is got
-#   @param  MacroDictdictionary used to replace macro
 #
-def _GetRAWData(self, FfsFileObj, MacroDict = {}):
+def _GetRAWData(self, FfsFileObj):
 FfsFileObj.FileName = []
 FfsFileObj.SubAlignment = []
 while True:
@@ -2756,26 +2751,18 @@ class FdfParser:
 
 return False
 
-## _GetFilePart() method
+## _GetSectionData() method
 #
 #   Get section data for FILE statement
 #
 #   @param  selfThe object pointer
 #   @param  FfsFileObj   for whom section is got
-#   @param  MacroDict   dictionary used to replace macro
 #
-def _GetSectionData(self, FfsFileObj, MacroDict = {}):
-Dict = {}
-

[edk2] [PATCH v2 2/7] BaseTools/GenFds: change objects to sets

2018-09-28 Thread Jaben Carsey
Change lists and tuples used solely for "in" testing to sets.
These operations are not order dependent.
fixed some line length for PEP8 compliance on some.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 222 +++-
 1 file changed, 123 insertions(+), 99 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 814874d93997..29c5a60d6afe 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -70,6 +70,7 @@ SEPARATORS = {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, 
TAB_COMMA_SPLIT, '{', '}'}
 ALIGNMENTS = {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K", 
"64K", "128K",
 "256K", "512K", "1M", "2M", "4M", "8M", 
"16M"}
 ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
+CR_LB_SET = {T_CHAR_CR, TAB_LINE_BREAK}
 
 RegionSizePattern = 
compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*")
 RegionSizeGuidPattern = 
compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P\w+\.\w+[\.\w\[\]]*)\s*")
@@ -266,7 +267,7 @@ class FdfParser:
 #
 def _SkipWhiteSpace(self):
 while not self._EndOfFile():
-if self._CurrentChar() in (TAB_PRINTCHAR_NUL, T_CHAR_CR, 
TAB_LINE_BREAK, TAB_SPACE_SPLIT, T_CHAR_TAB):
+if self._CurrentChar() in {TAB_PRINTCHAR_NUL, T_CHAR_CR, 
TAB_LINE_BREAK, TAB_SPACE_SPLIT, T_CHAR_TAB}:
 self._SkippedChars += str(self._CurrentChar())
 self._GetOneChar()
 else:
@@ -406,14 +407,14 @@ class FdfParser:
 return
 
 Offset = StartPos[1]
-while self.Profile.FileLinesList[StartPos[0]][Offset] not in 
(T_CHAR_CR, TAB_LINE_BREAK):
+while self.Profile.FileLinesList[StartPos[0]][Offset] not in CR_LB_SET:
 self.Profile.FileLinesList[StartPos[0]][Offset] = Value
 Offset += 1
 
 Line = StartPos[0]
 while Line < EndPos[0]:
 Offset = 0
-while self.Profile.FileLinesList[Line][Offset] not in (T_CHAR_CR, 
TAB_LINE_BREAK):
+while self.Profile.FileLinesList[Line][Offset] not in CR_LB_SET:
 self.Profile.FileLinesList[Line][Offset] = Value
 Offset += 1
 Line += 1
@@ -707,7 +708,7 @@ class FdfParser:
 PreIndex = 0
 StartPos = CurLine.find('$(', PreIndex)
 EndPos = CurLine.find(')', StartPos+2)
-while StartPos != -1 and EndPos != -1 and self._Token not 
in [TAB_IF_DEF, TAB_IF_N_DEF, TAB_IF, TAB_ELSE_IF]:
+while StartPos != -1 and EndPos != -1 and self._Token not 
in {TAB_IF_DEF, TAB_IF_N_DEF, TAB_IF, TAB_ELSE_IF}:
 MacroName = CurLine[StartPos+2: EndPos]
 MacorValue = self._GetMacroValue(MacroName)
 if MacorValue is not None:
@@ -759,7 +760,7 @@ class FdfParser:
 self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple
 
 self._WipeOffArea.append(((SetLine, SetOffset), 
(self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
-elif self._Token in (TAB_IF_DEF, TAB_IF_N_DEF, TAB_IF):
+elif self._Token in {TAB_IF_DEF, TAB_IF_N_DEF, TAB_IF}:
 IfStartPos = (self.CurrentLineNumber - 1, 
self.CurrentOffsetWithinLine - len(self._Token))
 IfList.append([IfStartPos, None, None])
 
@@ -777,7 +778,7 @@ class FdfParser:
 IfList[-1] = [IfList[-1][0], ConditionSatisfied, 
BranchDetermined]
 if ConditionSatisfied:
 self._WipeOffArea.append((IfList[-1][0], 
(self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
-elif self._Token in (TAB_ELSE_IF, '!else'):
+elif self._Token in {TAB_ELSE_IF, TAB_ELSE}:
 ElseStartPos = (self.CurrentLineNumber - 1, 
self.CurrentOffsetWithinLine - len(self._Token))
 if len(IfList) <= 0:
 raise Warning("Missing !if statement", self.FileName, 
self.CurrentLineNumber)
@@ -860,13 +861,12 @@ class FdfParser:
 
 MacroDict.update(GlobalData.gGlobalDefines)
 MacroDict.update(GlobalData.gCommandLineDefines)
-if GlobalData.BuildOptionPcd:
-for Item in GlobalData.BuildOptionPcd:
-if isinstance(Item, tuple):
-continue
-PcdName, TmpValue = Item.split(TAB_EQUAL_SPLIT)
-TmpValue = BuildOptionValue(TmpValue, {})
-MacroDict[PcdName.strip()] = TmpValue
+for Item in GlobalData.BuildOptionPcd:
+if isinstance(Item, tuple):
+continue
+PcdName, TmpValue = Item.split(TAB_EQUAL_SPLIT)
+TmpValue = BuildOptionValue(TmpValue, {})
+

[edk2] [PATCH v2 6/7] BaseTools/GenFds: Remove duplicate function calls

2018-09-28 Thread Jaben Carsey
every call to GetAprioriSection() is duplicated on the line below.
remove one of the calls.

Cc: Bob Feng 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index d8fb9ce60161..5a59a0a0d854 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -2122,7 +2122,6 @@ class FdfParser:
 raise Warning("FvNameString found but FvNameGuid was not found", 
self.FileName, self.CurrentLineNumber)
 
 self._GetAprioriSection(FvObj)
-self._GetAprioriSection(FvObj)
 
 while True:
 isInf = self._GetInfStatement(FvObj)
@@ -3781,7 +3780,6 @@ class FdfParser:
 self._GetFvAlignment(FvObj)
 self._GetFvAttributes(FvObj)
 self._GetAprioriSection(FvObj)
-self._GetAprioriSection(FvObj)
 
 while True:
 IsInf = self._GetInfStatement(FvObj)
-- 
2.16.2.windows.1

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


[edk2] [PATCH v2 5/7] BaseTools/GenFds: refactor FdfParser warnings

2018-09-28 Thread Jaben Carsey
make functions for common error messages
refactor to use these functions

Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 603 ++--
 1 file changed, 303 insertions(+), 300 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index f8fefdc2e737..d8fb9ce60161 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -129,6 +129,24 @@ class Warning (Exception):
 def __str__(self):
 return self.Message
 
+# helper functions to facilitate consistency in warnings
+# each function is for a different common warning
+@staticmethod
+def Expected(Str, File, Line):
+return Warning("expected {}".format(Str), File, Line)
+@staticmethod
+def ExpectedEquals(File, Line):
+return Warning.Expected("'='", File, Line)
+@staticmethod
+def ExpectedCurlyOpen(File, Line):
+return Warning.Expected("'{'", File, Line)
+@staticmethod
+def ExpectedCurlyClose(File, Line):
+return Warning.Expected("'}'", File, Line)
+@staticmethod
+def ExpectedBracketClose(File, Line):
+return Warning.Expected("']'", File, Line)
+
 ## The Include file content class that used to record file data when parsing 
include file
 #
 # May raise Exception when opening file.
@@ -184,8 +202,6 @@ class IncludeFileProfile:
 
 return (self.FileName, Line - InsertedLines + 1)
 
-
-
 ## The FDF content class that used to record file data when parsing FDF
 #
 # May raise Exception when opening file.
@@ -563,10 +579,10 @@ class FdfParser:
 
 if self._Token == TAB_DEFINE:
 if not self._GetNextToken():
-raise Warning("expected Macro name", self.FileName, 
self.CurrentLineNumber)
+raise Warning.Expected("Macro name", self.FileName, 
self.CurrentLineNumber)
 Macro = self._Token
 if not self._IsToken(TAB_EQUAL_SPLIT):
-raise Warning("expected '='", self.FileName, 
self.CurrentLineNumber)
+raise Warning.ExpectedEquals(self.FileName, 
self.CurrentLineNumber)
 Value = self._GetExpression()
 MacroDict[Macro] = Value
 
@@ -575,7 +591,7 @@ class FdfParser:
 IncludeLine = self.CurrentLineNumber
 IncludeOffset = self.CurrentOffsetWithinLine - len(TAB_INCLUDE)
 if not self._GetNextToken():
-raise Warning("expected include file name", self.FileName, 
self.CurrentLineNumber)
+raise Warning.Expected("include file name", self.FileName, 
self.CurrentLineNumber)
 IncFileName = self._Token
 PreIndex = 0
 StartPos = IncFileName.find('$(', PreIndex)
@@ -731,10 +747,10 @@ class FdfParser:
 DefineLine = self.CurrentLineNumber - 1
 DefineOffset = self.CurrentOffsetWithinLine - 
len(TAB_DEFINE)
 if not self._GetNextToken():
-raise Warning("expected Macro name", self.FileName, 
self.CurrentLineNumber)
+raise Warning.Expected("Macro name", self.FileName, 
self.CurrentLineNumber)
 Macro = self._Token
 if not self._IsToken(TAB_EQUAL_SPLIT):
-raise Warning("expected '='", self.FileName, 
self.CurrentLineNumber)
+raise Warning.ExpectedEquals(self.FileName, 
self.CurrentLineNumber)
 
 Value = self._GetExpression()
 self._SetMacroValue(Macro, Value)
@@ -747,7 +763,7 @@ class FdfParser:
 PcdPair = self._GetNextPcdSettings()
 PcdName = "%s.%s" % (PcdPair[1], PcdPair[0])
 if not self._IsToken(TAB_EQUAL_SPLIT):
-raise Warning("expected '='", self.FileName, 
self.CurrentLineNumber)
+raise Warning.ExpectedEquals(self.FileName, 
self.CurrentLineNumber)
 
 Value = self._GetExpression()
 Value = self._EvaluateConditional(Value, 
self.CurrentLineNumber, 'eval', True)
@@ -1179,20 +1195,20 @@ class FdfParser:
 
 def _GetNextPcdSettings(self):
 if not self._GetNextWord():
-raise Warning("expected format of 
.", self.FileName, self.CurrentLineNumber)
+raise Warning.Expected("", self.FileName, 
self.CurrentLineNumber)
 pcdTokenSpaceCName = self._Token
 
 if not self._IsToken(TAB_SPLIT):
-raise Warning("expected format of 
.", self.FileName, self.CurrentLineNumber)
+raise Warning.Expected(".", self.FileName, self.CurrentLineNumber)
 
 if not self._GetNextWord():
-raise Warning("expected format of 
.", self.FileName, 

[edk2] [PATCH v2 0/7] BaseTools/GenFds: cleanup GenFds

2018-09-28 Thread Jaben Carsey
Cleanup to many files for GenFds. No command line visible changes are included.
1) refactor imports to reduce namespace clutter.
2) refactor to use existing sharable objects (and create a few new)
3) eliminate shadowing of names
4) remove double underscored private methods for PEP8
5) eliminate unused code/parameters/variables
6) add standard warnings and use them for common code

changes from v1:
1) do not shadow CapsuleFV.
2) rebase on master


Jaben Carsey (7):
  BaseTools/GenFds: cleanup GenFds
  BaseTools/GenFds: change objects to sets
  Basetools/GenFds: refactor class FV
  BaseTools/GenFds: remove MacroDict parameter
  BaseTools/GenFds: refactor FdfParser warnings
  BaseTools/GenFds: Remove duplicate function calls
  BaseTools/GenFds: create and use new variable in FdfParser

 BaseTools/Source/Python/CommonDataClass/FdfClass.py|   73 -
 BaseTools/Source/Python/Eot/Eot.py |   11 +-
 BaseTools/Source/Python/GenFds/AprioriSection.py   |   45 +-
 BaseTools/Source/Python/GenFds/Capsule.py  |   26 +-
 BaseTools/Source/Python/GenFds/CapsuleData.py  |1 -
 BaseTools/Source/Python/GenFds/CompressSection.py  |4 +-
 BaseTools/Source/Python/GenFds/DataSection.py  |4 +-
 BaseTools/Source/Python/GenFds/DepexSection.py |5 +-
 BaseTools/Source/Python/GenFds/EfiSection.py   |   16 +-
 BaseTools/Source/Python/GenFds/FdfParser.py| 3754 
++--
 BaseTools/Source/Python/GenFds/Ffs.py  |   82 +-
 BaseTools/Source/Python/GenFds/FfsFileStatement.py |   37 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py  |   10 +-
 BaseTools/Source/Python/GenFds/Fv.py   |   54 +-
 BaseTools/Source/Python/GenFds/FvImageSection.py   |6 +-
 BaseTools/Source/Python/GenFds/GenFds.py   |  160 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  208 +-
 BaseTools/Source/Python/GenFds/GuidSection.py  |4 +-
 BaseTools/Source/Python/GenFds/OptionRom.py|6 +-
 BaseTools/Source/Python/GenFds/Region.py   |   12 +-
 BaseTools/Source/Python/GenFds/UiSection.py|4 +-
 BaseTools/Source/Python/GenFds/VerSection.py   |   16 +-
 BaseTools/Source/Python/GenFds/Vtf.py  |   48 +-
 BaseTools/Source/Python/build/BuildReport.py   |5 +-
 24 files changed, 2199 insertions(+), 2392 deletions(-)

-- 
2.16.2.windows.1

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


[edk2] [PATCH v2 3/7] Basetools/GenFds: refactor class FV

2018-09-28 Thread Jaben Carsey
1) initialize UiFvName via __init__ parameter. No change to default behavior.
2) initialize 3 empty lists in __init__. Curently not guarenteed initialized.

Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 6 +-
 BaseTools/Source/Python/GenFds/Fv.py| 9 +
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 29c5a60d6afe..fa82d8f174d5 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -2090,8 +2090,7 @@ class FdfParser:
 if not self._IsToken(TAB_SECTION_END):
 raise Warning("expected ']'", self.FileName, 
self.CurrentLineNumber)
 
-FvObj = FV()
-FvObj.UiFvName = self.CurrentFvName
+FvObj = FV(Name=self.CurrentFvName)
 self.Profile.FvDict[self.CurrentFvName] = FvObj
 
 Status = self._GetCreateFile(FvObj)
@@ -2102,9 +2101,6 @@ class FdfParser:
 
 self._GetAddressStatements(FvObj)
 
-FvObj.FvExtEntryTypeValue = []
-FvObj.FvExtEntryType = []
-FvObj.FvExtEntryData = []
 while True:
 self._GetSetStatements(FvObj)
 
diff --git a/BaseTools/Source/Python/GenFds/Fv.py 
b/BaseTools/Source/Python/GenFds/Fv.py
index acb133573d72..cd19dff6c325 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -37,8 +37,8 @@ class FV (object):
 #
 #   @param  selfThe object pointer
 #
-def __init__(self):
-self.UiFvName = None
+def __init__(self, Name=None):
+self.UiFvName = Name
 self.CreateFileName = None
 self.BlockSizeList = []
 self.DefineVarDict = {}
@@ -61,7 +61,9 @@ class FV (object):
 self.FvForceRebase = None
 self.FvRegionInFD = None
 self.UsedSizeEnable = False
-
+self.FvExtEntryTypeValue = []
+self.FvExtEntryType = []
+self.FvExtEntryData = []
 ## AddToBuffer()
 #
 #   Generate Fv and add it to the Buffer
@@ -77,7 +79,6 @@ class FV (object):
 #   @retval string  Generated FV file path
 #
 def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, 
BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False):
-
 if BaseAddress is None and self.UiFvName.upper() + 'fv' in 
GenFdsGlobalVariable.ImageBinDict:
 return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 
'fv']
 
-- 
2.16.2.windows.1

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


[edk2] UEFI PI Spec 1.6 SPI stack question

2018-09-28 Thread Kirkendall, Garrett
Is there any example implementation in EDK2 of the UEFI PI spec 1.6 SPI stack?

I'm finding there are some things that aren't defined in the spec or the header 
support in EDK2.  (at least in UDK2018)

Garrett Kirkendall
SMTS Firmware Engineer | CTE
7171 Southwest Parkway, Austin, TX 78735 USA
AMD   facebook  |  amd.com

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


Re: [edk2] [PATCH v2 0/5] [CVE-2017-5753] Bounds Check Bypass issue in SMI handlers

2018-09-28 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Wu, Hao A
> Sent: Tuesday, September 25, 2018 2:13 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Ard Biesheuvel
> ; Leif Lindholm ;
> Laszlo Ersek ; Yao, Jiewen ;
> Kinney, Michael D ; Gao, Liming
> ; Zeng, Star ; Dong, Eric
> 
> Subject: [PATCH v2 0/5] [CVE-2017-5753] Bounds Check Bypass issue in SMI
> handlers
> 
> V2 changes:
> A. Rename the newly introduced BaseLib API to 'AsmLfence', and makes it
>IA32/X64 specific.
> 
> B. Add brief comments before calls of the AsmLfence() to state the
>purpose.
> 
> C. Refine the patch for Variable/RuntimeDxe driver and make the change
>focus on the SMM code.
> 
> V1 history:
> The series aims to mitigate the Bounds Check Bypass (CVE-2017-5753) issues
> within SMI handlers.
> 
> A more detailed explanation of the purpose of the series is under the
> 'Bounds check bypass mitigation' section of the below link:
> https://software.intel.com/security-software-guidance/insights/host-firmw
> are-speculative-execution-side-channel-mitigation
> 
> And the document at:
> https://software.intel.com/security-software-guidance/api-app/sites/defaul
> t/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf
> 
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Laszlo Ersek 
> Cc: Jiewen Yao 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Star Zeng 
> Cc: Eric Dong 
> 
> Hao Wu (5):
>   MdePkg/BaseLib: Add new AsmLfence API
>   MdeModulePkg/FaultTolerantWrite:[CVE-2017-5753]Fix bounds check
> bypass
>   MdeModulePkg/SmmLockBox: [CVE-2017-5753] Fix bounds check bypass
>   MdeModulePkg/Variable: [CVE-2017-5753] Fix bounds check bypass
>   UefiCpuPkg/PiSmmCpuDxeSmm: [CVE-2017-5753] Fix bounds check
> bypass
> 
> 
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
> |  7 
> 
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.in
> f |  1 +
>  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c
> | 10 ++
>  MdeModulePkg/Universal/Variable/RuntimeDxe/LoadFenceDxe.c
> | 31 
>  MdeModulePkg/Universal/Variable/RuntimeDxe/LoadFenceSmm.c
> | 30 
>  MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> | 13 ++-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
> |  6 
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> |  1 +
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> | 18 ++
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
> |  1 +
>  MdePkg/Include/Library/BaseLib.h
> | 13 +++
>  MdePkg/Library/BaseLib/BaseLib.inf
> |  2 ++
>  MdePkg/Library/BaseLib/Ia32/Lfence.nasm
> | 37 +++
>  MdePkg/Library/BaseLib/X64/Lfence.nasm
> | 38 
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> |  5 +++
>  15 files changed, 212 insertions(+), 1 deletion(-)
>  create mode 100644
> MdeModulePkg/Universal/Variable/RuntimeDxe/LoadFenceDxe.c
>  create mode 100644
> MdeModulePkg/Universal/Variable/RuntimeDxe/LoadFenceSmm.c
>  create mode 100644 MdePkg/Library/BaseLib/Ia32/Lfence.nasm
>  create mode 100644 MdePkg/Library/BaseLib/X64/Lfence.nasm
> 
> --
> 2.12.0.windows.1

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


Re: [edk2] [PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header file

2018-09-28 Thread Leif Lindholm
Hi Sumit,

On Fri, Sep 28, 2018 at 11:59:33AM +0530, Sumit Garg wrote:
> > > Please help to answer below query from Michael regarding licensing
> > > concerns for using Global Platform specs content in OP-TEE.
> >
> > This dates back to ~2014 before OP-TEE had been pushed as an open source
> > project and indeed the click-through license was one thing that was
> > discussed before we decided to publish this. Having that said, the legal
> > people at ST (back then the project was owned by ST) concluded that we
> > could use the GP click-through license for the APIs, this is a
> > copy/paste from an email discussion with ST (in 2014).
> >
> > "On the legal side, one week ago our legal dedicated to this matter
> > wrote “Progress! Finally, having discussed with colleagues, we have
> > concluded that we can use the GP click-through license for the APIs.
> > Therefore I just need to tidy up the following points and we will be
> > able to provide both the CLA and the license terms for the distribution
> > quite quickly […].”
> >
> > I don't know how the discussion went inside ST nor who the legal person
> > was, but since ST had people on GlobalPlatform boards back then, I
> > suppose that the ST legal people went that way. The only way to find out
> > more about this is to talk directly to ST legal people who were involved
> > in this back in the days.
> 
> Thanks Joakim for this info.
> 
> Mike,
> 
> Please share your views on this and if we could include content from
> Global Platform spec into MdePkg as an industry standard.

Having had a discussion about this, the bit that concerns us the most
is the export restrictions clause of the click-through license which
contains the very unfortunate part "or any product complying with the
Specification.".

Someone must have thought this interface defines cryptography, rather
than an API through which to call cryptography functions.

I don't like it, but without a change in that license I don't see how
we can include this interface in edk2. One workaround would be to
publish this in a separate repository on https://github.com/OP-TEE/
which could be included in builds using PACKAGES_PATH (like we do with
edk2-platforms and edk2-non-osi).

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


Re: [edk2] [PATCH v3 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol

2018-09-28 Thread Zeng, Star
Good questions.

1. The emulator needs three interfaces currently. The Version I mentioned is 
for the case that the emulator may need extra interface later in future for 
some new consideration, then we can just update the Version value and extend 
the structure with new interface, and no new protocol2 needs to be introduced.

2. I just tried to confirm Mike's idea as Mike replied to Ard with " This also 
allows the option to update the DXE Core module to optionally support emulators 
using a PCD Feature Flag and remove some logic if emulators are not required on 
a specific platform. ".


Thanks,
Star
-Original Message-
From: Ni, Ruiyu 
Sent: Friday, September 28, 2018 2:34 PM
To: Zeng, Star ; Kinney, Michael D 
; Ard Biesheuvel 
Cc: edk2-devel@lists.01.org; Zimmer, Vincent ; 
Richardson, Brian ; Andrew Fish ; 
Leif Lindholm ; Dong, Eric ; 
Gao, Liming ; Carsey, Jaben ; 
Shi, Steven 
Subject: Re: [PATCH v3 1/7] MdeModulePkg: introduce PE/COFF image emulator 
protocol

On 9/28/2018 11:08 AM, Zeng, Star wrote:
> Good idea.
> You prefer to introduce a new feature PCD for this with default value = TRUE?
> 
> Could we group the emulator APIs to one structure like below? And add a 
> Version field for potential further extension?
> 
> typedef struct {
>UINTN   Version;
>EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED  IsImageSupported;
>EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE  RegisterImage;
>EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGEUnregisterImage;
> } PECOFF_IMAGE_EMULATOR;

Star,
What's the reason for the "Version" field? Can you explain the usage case?

And why do we need the PCD to control?

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


Re: [edk2] [PATCH v3 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol

2018-09-28 Thread Ni, Ruiyu

On 9/28/2018 11:08 AM, Zeng, Star wrote:

Good idea.
You prefer to introduce a new feature PCD for this with default value = TRUE?

Could we group the emulator APIs to one structure like below? And add a Version 
field for potential further extension?

typedef struct {
   UINTN   Version;
   EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED  IsImageSupported;
   EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE  RegisterImage;
   EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGEUnregisterImage;
} PECOFF_IMAGE_EMULATOR;


Star,
What's the reason for the "Version" field? Can you explain the usage case?

And why do we need the PCD to control?

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


Re: [edk2] [PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header file

2018-09-28 Thread Sumit Garg
On Thu, 27 Sep 2018 at 18:21, Joakim Bech  wrote:
>
> Hi,
>
> On Thu, Sep 27, 2018 at 05:40:49PM +0530, Sumit Garg wrote:
> > +Joakim
> >
> > Joakim,
> >
> > Please help to answer below query from Michael regarding licensing
> > concerns for using Global Platform specs content in OP-TEE.
> >
> This dates back to ~2014 before OP-TEE had been pushed as an open source
> project and indeed the click-through license was one thing that was
> discussed before we decided to publish this. Having that said, the legal
> people at ST (back then the project was owned by ST) concluded that we
> could use the GP click-through license for the APIs, this is a
> copy/paste from an email discussion with ST (in 2014).
>
> "On the legal side, one week ago our legal dedicated to this matter
> wrote “Progress! Finally, having discussed with colleagues, we have
> concluded that we can use the GP click-through license for the APIs.
> Therefore I just need to tidy up the following points and we will be
> able to provide both the CLA and the license terms for the distribution
> quite quickly […].”
>
> I don't know how the discussion went inside ST nor who the legal person
> was, but since ST had people on GlobalPlatform boards back then, I
> suppose that the ST legal people went that way. The only way to find out
> more about this is to talk directly to ST legal people who were involved
> in this back in the days.
>

Thanks Joakim for this info.

Mike,

Please share your views on this and if we could include content from
Global Platform spec into MdePkg as an industry standard.

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


Re: [edk2] [RFC MdeModulePkg/UefiBootManagerLib v1 1/1] MdeModulePkg/UefiBootManagerLib: Fix raid card repair fail issue

2018-09-28 Thread Ming Huang



On 9/26/2018 1:00 PM, Ni, Ruiyu wrote:
>> @@ -507,12 +552,13 @@ BmRepairAllControllers (
>> FormBrowser2,
>> [Index],
>> 1,
>> -   PcdGetPtr (PcdDriverHealthConfigureForm),
>> +   ,
> 
> I still don't quite understand the changes.
> But the above specific change removes the PcdDriverHealthConfigureForm form 
> pop up.
> Instead it pops up each driver health form one by one.
> Why?

This change is refer to the below function:
ProcessSingleControllerHealth 
(IntelFrameworkModulePkg/Universal/Bdsdxe/DeviceMngr/DeviceManager.c).
I don't real understand it also, but it works.

> 
>> 0,
>> NULL,
>> NULL
>> );
>>if (!EFI_ERROR (Status)) {
>> +ShowConfigureForm (FormBrowser2,
>> + InfoConfigurationRequired);
>>  break;
>>}
>>  }
>> --
>> 2.18.0
>>
>> ___
>> 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