[edk2] [PATCH 1/4] BaseTools/TianoCompress: Improve performance of boundary validation

2019-02-24 Thread Shenglei Zhang
The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang 
---
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c 
b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 29b11c597f..e79b287ea4 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -2281,13 +2281,14 @@ Returns:
 
 if (Len <= TableBits) {
 
-  for (Index = Start[Len]; Index < NextCode; Index++) {
-if (Index >= MaxTableLength) {
-  return (UINT16) BAD_TABLE;
-}
+  if (Start[Len] + NextCode > MaxTableLength) {
+return (UINT16) BAD_TABLE;
+  }
+ for (Index = Start[Len]; Index < NextCode; Index++) {
 Table[Index] = Char;
   }
 
+
 } else {
 
   Index3  = Start[Len];
-- 
2.18.0.windows.1

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


[edk2] [PATCH 0/4] Improve performance of boundary validation in MakeTable()

2019-02-24 Thread Shenglei Zhang
The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Michael D Kinney 
Shenglei Zhang (4):
  BaseTools/TianoCompress: Improve performance of boundary validation
  BaseTools/C/Common: Improve performance of boundary validation
  IntelFrameworkModulePkg: Improve performance of boundary validation
  MdePkg/BaseUefiDecompressLib: Improve performance of boundary
validation

 BaseTools/Source/C/Common/Decompress.c  | 13 +++--
 BaseTools/Source/C/TianoCompress/TianoCompress.c|  9 +
 .../BaseUefiTianoCustomDecompressLib.c  | 12 ++--
 .../BaseUefiDecompressLib/BaseUefiDecompressLib.c   |  8 
 4 files changed, 22 insertions(+), 20 deletions(-)

-- 
2.18.0.windows.1

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


[edk2] [PATCH 2/4] BaseTools/C/Common: Improve performance of boundary validation

2019-02-24 Thread Shenglei Zhang
The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang 
---
 BaseTools/Source/C/Common/Decompress.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/C/Common/Decompress.c 
b/BaseTools/Source/C/Common/Decompress.c
index 0e9ba0a982..adac66c5c2 100644
--- a/BaseTools/Source/C/Common/Decompress.c
+++ b/BaseTools/Source/C/Common/Decompress.c
@@ -254,12 +254,13 @@ Returns:
 
 if (Len <= TableBits) {
 
-  for (Index = Start[Len]; Index < NextCode; Index++) {
-if (Index >= MaxTableLength) {
-  return (UINT16) BAD_TABLE;
-}
-Table[Index] = Char;
-  }
+   if (Start[Len] + NextCode > MaxTableLength) {
+ return (UINT16) BAD_TABLE;
+   }
+   for (Index = Start[Len]; Index < NextCode; Index++) {
+ Table[Index] = Char;
+   }
+
 
 } else {
 
-- 
2.18.0.windows.1

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


[edk2] [PATCH 4/4] MdePkg/BaseUefiDecompressLib: Improve performance of boundary validation

2019-02-24 Thread Shenglei Zhang
The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang 
---
 .../Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c 
b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
index c1e8c5581a..e979b18f0f 100644
--- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
+++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
@@ -222,10 +222,10 @@ MakeTable (
 
 if (Len <= TableBits) {
 
-  for (Index = Start[Len]; Index < NextCode; Index++) {
-if (Index >= MaxTableLength) {
-  return (UINT16) BAD_TABLE;
-}
+  if (Start[Len] + NextCode > MaxTableLength) {
+return (UINT16) BAD_TABLE;
+  }
+ for (Index = Start[Len]; Index < NextCode; Index++) {
 Table[Index] = Char;
   }
 
-- 
2.18.0.windows.1

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


[edk2] [PATCH 3/4] IntelFrameworkModulePkg: Improve performance of boundary validation

2019-02-24 Thread Shenglei Zhang
The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang 
---
 .../BaseUefiTianoCustomDecompressLib.c   | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
 
b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
index 970795b1da..a7ff94920e 100644
--- 
a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
+++ 
b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
@@ -213,12 +213,12 @@ MakeTable (
 
 if (Len <= TableBits) {
 
-  for (Index = Start[Len]; Index < NextCode; Index++) {
-if (Index >= MaxTableLength) {
-  return (UINT16) BAD_TABLE;
-}
-Table[Index] = Char;
-  }
+   if (Start[Len] + NextCode > MaxTableLength) {
+ return (UINT16) BAD_TABLE;
+   }
+   for (Index = Start[Len]; Index < NextCode; Index++) {
+ Table[Index] = Char;
+   }
 
 } else {
 
-- 
2.18.0.windows.1

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


[edk2] [PATCH V2] BaseTools:PackageDocumentTools import lib error occurs.

2019-02-24 Thread Fan, ZhijuX
Steps:
 1. Download edk2 tree
 2. Build BaseTools
 3. Go to edk2\BaseTools\Scripts\PackageDocumentTools
to run packagedoc_cli.py

An error occurs if relative imports are used when running
a file alone

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py   |  4 ++--
 .../plugins/EdkPlugins/basemodel/doxygen.py|  2 +-
 .../plugins/EdkPlugins/basemodel/ini.py|  4 ++--
 .../plugins/EdkPlugins/edk2/model/baseobject.py| 14 +++---
 .../plugins/EdkPlugins/edk2/model/dec.py   |  4 ++--
 .../plugins/EdkPlugins/edk2/model/doxygengen.py|  8 
 .../plugins/EdkPlugins/edk2/model/doxygengen_spec.py   |  8 
 .../plugins/EdkPlugins/edk2/model/dsc.py   |  4 ++--
 .../plugins/EdkPlugins/edk2/model/inf.py   |  4 ++--
 9 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py 
b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
index e404a07cd7..5c65842a72 100644
--- a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
+++ b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
@@ -16,8 +16,8 @@ from __future__ import print_function
 import os, sys, logging, traceback, subprocess
 from optparse import OptionParser
 
-from .plugins.EdkPlugins.edk2.model import baseobject
-from .plugins.EdkPlugins.edk2.model import doxygengen
+from plugins.EdkPlugins.edk2.model import baseobject
+from plugins.EdkPlugins.edk2.model import doxygengen
 
 gArchMarcoDict = {'ALL'  : 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC 
MDE_CPU_IPF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER',
   'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS',
diff --git 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
index ae47ff1344..a510808842 100644
--- 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
+++ 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
@@ -92,7 +92,7 @@ class Page(BaseDoxygeItem):
 self.mText.insert(endIndex, '')
 endIndex += 1
 if self.mIsSort:
-self.mSubPages.sort(cmp=lambda x, y: cmp(x.mName.lower(), 
y.mName.lower()))
+self.mSubPages.sort(key=lambda x: x.mName.lower())
 for page in self.mSubPages:
 self.mText.insert(endIndex, '\subpage %s \"%s\" ' % 
(page.mTag, page.mName))
 endIndex += 1
diff --git 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
index 6e6f3f4b97..bac2f5e2e6 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
@@ -25,7 +25,7 @@ class BaseINIFile(object):
 @return: instance of this class
 
 """
-if len(args) == 0: return object.__new__(cls, *args, **kwargs)
+if len(args) == 0: return object.__new__(cls)
 filename = args[0]
 parent   = None
 if len(args) > 1:
@@ -33,7 +33,7 @@ class BaseINIFile(object):
 
 key = os.path.normpath(filename)
 if key not in cls._objs.keys():
-cls._objs[key] = object.__new__(cls, *args, **kwargs)
+cls._objs[key] = object.__new__(cls)
 
 if parent is not None:
 cls._objs[key].AddParent(parent)
diff --git 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/baseobject.py
 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/baseobject.py
index 0159bd5269..7b47fd76b9 100644
--- 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/baseobject.py
+++ 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/baseobject.py
@@ -10,12 +10,12 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
-from ...basemodel import ini
-from ...edk2.model import dsc
-from ...edk2.model import inf
-from ...edk2.model import dec
+from plugins.EdkPlugins.basemodel import ini
+from plugins.EdkPlugins.edk2.model import dsc
+from plugins.EdkPlugins.edk2.model import inf
+from plugins.EdkPlugins.edk2.model import dec
 import os
-from ...basemodel.message import *
+from plugins.EdkPlugins.basemodel.message import *
 
 class SurfaceObject(object):
 _objs = {}
@@ -25,7 +25,7 @@ class SurfaceObject(object):
 @return: instance of this class
 
 """
-obj = object.__new__(cls, *args, **kwargs)
+obj = object.__new__(cls)
 if "None" not in cls._objs:
 

[edk2] [Patch] Revert "BaseTools:BaseTools supports to the driver combination."

2019-02-24 Thread Liming Gao
This reverts commit 838bc257bae3f9fc6723f41f3980f6cfbedb77e5.
After further evaluation, there are the unclear behavior in for the
driver combination feature. To not impact Q1 stable tag, remove it first.
1. If the drivers to be combined have the different PCD or library instance
   setting, build should not combine them and report build break. But this
   commit doesn't consider this case.
2. When start the sub driver fail, continue to start other sub driver. This
   behavior is required to be clarifed in build spec. 
3. Unload the sub driver when the combined driver start fail. This case need 
   to call the sub driver unload function for the driver start fail only.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 BaseTools/Source/Python/AutoGen/GenC.py| 32 --
 .../Source/Python/Workspace/WorkspaceCommon.py |  8 --
 2 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index 0f1b3bb9a3..a922464f56 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1457,25 +1457,10 @@ def CreateLibraryDestructorCode(Info, AutoGenC, 
AutoGenH):
 def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, 
SUP_MODULE_SEC]:
 return
-ModuleEntryPointList = []
-for Lib in Info.DependentLibraryList:
-if len(Lib.ModuleEntryPointList) > 0:
-if Lib.ModuleType == Info.ModuleType:
-ModuleEntryPointList = ModuleEntryPointList + 
Lib.ModuleEntryPointList
-else:
-EdkLogger.error(
-"build",
-PREBUILD_ERROR,
-"Driver's ModuleType must be consistent [%s]"%(str(Lib)),
-File=str(Info.PlatformInfo),
-ExtraData="consumed by [%s]" % str(Info.MetaFile)
-)
-ModuleEntryPointList = ModuleEntryPointList + 
Info.Module.ModuleEntryPointList
-
 #
 # Module Entry Points
 #
-NumEntryPoints = len(ModuleEntryPointList)
+NumEntryPoints = len(Info.Module.ModuleEntryPointList)
 if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification:
 PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION']
 else:
@@ -1485,7 +1470,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 else:
 UefiSpecVersion = '0x'
 Dict = {
-'Function'   :   ModuleEntryPointList,
+'Function'   :   Info.Module.ModuleEntryPointList,
 'PiSpecVersion'  :   PiSpecVersion + 'U',
 'UefiSpecVersion':   UefiSpecVersion + 'U'
 }
@@ -1498,7 +1483,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
   AUTOGEN_ERROR,
   '%s must have exactly one entry point' % Info.ModuleType,
   File=str(Info),
-  ExtraData= ", ".join(ModuleEntryPointList)
+  ExtraData= ", ".join(Info.Module.ModuleEntryPointList)
   )
 if Info.ModuleType == SUP_MODULE_PEI_CORE:
 AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))
@@ -1552,18 +1537,11 @@ def CreateModuleEntryPointCode(Info, AutoGenC, 
AutoGenH):
 def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
 if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, 
SUP_MODULE_BASE, SUP_MODULE_SEC]:
 return
-
-ModuleUnloadImageList = []
-for Lib in Info.DependentLibraryList:
-if len(Lib.ModuleUnloadImageList) > 0:
-ModuleUnloadImageList = ModuleUnloadImageList + 
Lib.ModuleUnloadImageList
-ModuleUnloadImageList = ModuleUnloadImageList + 
Info.Module.ModuleUnloadImageList
-
 #
 # Unload Image Handlers
 #
-NumUnloadImage = len(ModuleUnloadImageList)
-Dict = {'Count':str(NumUnloadImage) + 'U', 
'Function':ModuleUnloadImageList}
+NumUnloadImage = len(Info.Module.ModuleUnloadImageList)
+Dict = {'Count':str(NumUnloadImage) + 'U', 
'Function':Info.Module.ModuleUnloadImageList}
 if NumUnloadImage < 2:
 AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict))
 else:
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py 
b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index 22abda8743..b79280bc2e 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -20,8 +20,6 @@ from Workspace.BuildClassObject import StructurePcd
 from Common.BuildToolError import RESOURCE_NOT_AVAILABLE
 from Common.BuildToolError import OPTION_MISSING
 from Common.BuildToolError import BUILD_ERROR
-from Common.BuildToolError import PREBUILD_ERROR
-import Common.EdkLogger as EdkLogError
 
 class OrderedListDict(OrderedDict):
 def __init__(self, *args, **kwargs):
@@ -140,12 +138,6