[edk2] [Patch 1/2] SecurityPkg/TcgStorageOpalLib: Return AUTHORITY_LOCKED_OUT error.

2018-07-09 Thread Eric Dong
Caller need to known this error to handle specially, but current
error status not has specified value for this type. In order to
keep compatibility, here use TcgResultFailureInvalidType as an
replacement.

Cc: Hao, Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalUtil.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalUtil.c 
b/SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalUtil.c
index 756f9b8f2d..b738ab91ee 100644
--- a/SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalUtil.c
+++ b/SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalUtil.c
@@ -788,7 +788,15 @@ OpalUtilUpdateGlobalLockingRange(
 
 done:
   if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
-Ret = TcgResultFailure;
+if (MethodStatus == TCG_METHOD_STATUS_CODE_AUTHORITY_LOCKED_OUT) {
+  //
+  // Caller need to know this special error, but return status not has 
type for it.
+  // so here use TcgResultFailureInvalidType as an replacement.
+  //
+  Ret = TcgResultFailureInvalidType;
+} else {
+  Ret = TcgResultFailure;
+}
   }
   return Ret;
 }
-- 
2.15.0.windows.1

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


[edk2] [Patch 0/2] Fixed correct password not works issue

2018-07-09 Thread Eric Dong
Opal device may have an count in firmware to decide whether to resistent 
user input password. If yes, even correct password will be reject by device
firmware. This count will be reset only after an cold reboot or user input
correct password.

Opal driver also has an internal count to decide whether allowed user to input 
password. A reboot (code or hot) action will reset this count.

Current implementation just base on the count in opal driver to decide whether
allow user to input password again. In this case, if the count in opal device
already exceeded, even an correct password will be rejected.

New solution will check both count, either cout exceed will cause opal driver 
report count exceed and a shutdown required.

Eric Dong (2):
  SecurityPkg/TcgStorageOpalLib: Return AUTHORITY_LOCKED_OUT error.
  SecurityPkg/OpalPassword: Fixed input correct password not works issue

 SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalUtil.c | 10 +-
 SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c |  9 +
 2 files changed, 18 insertions(+), 1 deletion(-)

-- 
2.15.0.windows.1

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


[edk2] [Patch 2/2] SecurityPkg/OpalPassword: Fixed input correct password not works issue

2018-07-09 Thread Eric Dong
When user input error password exceed the max allowed times, opal device
will return Invalid type error code even user input the correct password.
In this case, opal driver needs to force user shutdown the system before
let user input new password.

Cc: Hao, Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c 
b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
index 5d1638d5cf..cf1f4cd64e 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
@@ -1076,6 +1076,15 @@ OpalDriverRequestPassword (
 break;
   }
 
+  //
+  // Check whether opal device's Tries value has reach the TryLimit value, 
if yes, force a shutdown 
+  // before accept new password.
+  //
+  if (Ret == TcgResultFailureInvalidType) {
+Count = MAX_PASSWORD_TRY_COUNT;
+break;
+  }
+
   Count++;
 
   do {
-- 
2.15.0.windows.1

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


[edk2] [PATCH 09/14] BaseTools: Use absolute import in ECC

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/Ecc/CParser.py  |  5 ++--
 BaseTools/Source/Python/Ecc/Check.py|  9 +++
 BaseTools/Source/Python/Ecc/CodeFragmentCollector.py| 13 +-
 BaseTools/Source/Python/Ecc/Database.py |  7 +++---
 BaseTools/Source/Python/Ecc/Ecc.py  | 25 
++--
 BaseTools/Source/Python/Ecc/Exception.py|  3 ++-
 BaseTools/Source/Python/Ecc/FileProfile.py  |  5 ++--
 BaseTools/Source/Python/Ecc/MetaDataParser.py   |  5 ++--
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py |  3 ++-
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py  |  5 ++--
 BaseTools/Source/Python/Ecc/c.py| 13 +-
 11 files changed, 51 insertions(+), 42 deletions(-)

diff --git a/BaseTools/Source/Python/Ecc/CParser.py 
b/BaseTools/Source/Python/Ecc/CParser.py
index b66ac2d8d545..0b74b53ae7a5 100644
--- a/BaseTools/Source/Python/Ecc/CParser.py
+++ b/BaseTools/Source/Python/Ecc/CParser.py
@@ -1,6 +1,7 @@
 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
 
 from __future__ import print_function
+from __future__ import absolute_import
 from antlr3 import *
 from antlr3.compat import set, frozenset
 
@@ -23,8 +24,8 @@ from antlr3.compat import set, frozenset
 #
 ##
 
-import CodeFragment
-import FileProfile
+from . import CodeFragment
+from . import FileProfile
 
 
 
diff --git a/BaseTools/Source/Python/Ecc/Check.py 
b/BaseTools/Source/Python/Ecc/Check.py
index 540d9cb7edc7..0b81013d77e9 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -10,14 +10,15 @@
 # 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 __future__ import absolute_import
 import Common.LongFilePathOs as os
 import re
 from CommonDataClass.DataClass import *
 import Common.DataType as DT
-from EccToolError import *
-from MetaDataParser import ParseHeaderCommentSection
-import EccGlobalData
-import c
+from .EccToolError import *
+from .MetaDataParser import ParseHeaderCommentSection
+from . import EccGlobalData
+from . import c
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 
diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py 
b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
index b4f421342f60..28b4e0196f50 100644
--- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
@@ -17,18 +17,19 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 import re
 import Common.LongFilePathOs as os
 import sys
 
 import antlr3
-from CLexer import CLexer
-from CParser import CParser
+from .CLexer import CLexer
+from .CParser import CParser
 
-import FileProfile
-from CodeFragment import Comment
-from CodeFragment import PP_Directive
-from ParserWarning import Warning
+from . import FileProfile
+from .CodeFragment import Comment
+from .CodeFragment import PP_Directive
+from .ParserWarning import Warning
 
 
 ##define T_CHAR_SPACE' '
diff --git a/BaseTools/Source/Python/Ecc/Database.py 
b/BaseTools/Source/Python/Ecc/Database.py
index 204117512452..34f49f3cba8b 100644
--- a/BaseTools/Source/Python/Ecc/Database.py
+++ b/BaseTools/Source/Python/Ecc/Database.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import sqlite3
 import Common.LongFilePathOs as os, time
 
@@ -26,9 +27,9 @@ from Table.TableFunction import TableFunction
 from Table.TablePcd import TablePcd
 from Table.TableIdentifier import TableIdentifier
 from Table.TableReport import TableReport
-from MetaFileWorkspace.MetaFileTable import ModuleTable
-from MetaFileWorkspace.MetaFileTable import PackageTable
-from MetaFileWorkspace.MetaFileTable import PlatformTable
+from .MetaFileWorkspace.MetaFileTable import ModuleTable
+from .MetaFileWorkspace.MetaFileTable import PackageTable
+from .MetaFileWorkspace.MetaFileTable import PlatformTable
 from Table.TableFdf import TableFdf
 
 ##
diff --git a/BaseTools/Source/Python/Ecc/Ecc.py 
b/BaseTools/Source/Python/Ecc/Ecc.py
index ccd563a4660e..8f96bdf9778c 100644
--- a/BaseTools/Source/Python/Ecc/Ecc.py
+++ b/BaseTools/Source/Python/Ecc/Ecc.py
@@ -14,14 +14,15 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os, time, glob, sys
 import Common.EdkLogger as EdkLogger
-import Database
-import EccGlobalData
-from MetaDataParser import *
+from . import Database
+from . import EccGlobalData
+from .MetaDataParser import *
 

[edk2] [PATCH 13/14] BaseTools: Use absolute import in Workspace

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/Workspace/DscBuildData.py  | 9 +
 BaseTools/Source/Python/Workspace/InfBuildData.py  | 3 ++-
 BaseTools/Source/Python/Workspace/MetaFileParser.py| 5 +++--
 BaseTools/Source/Python/Workspace/MetaFileTable.py | 5 +++--
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py   | 3 ++-
 BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 7 ---
 6 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 5cc814185eb9..65fc0882d8b4 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -18,6 +18,7 @@
 # into PlatformBuildClassObject form for easier use for AutoGen.
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from Common.StringUtils import *
 from Common.DataType import *
 from Common.Misc import *
@@ -26,11 +27,11 @@ from Common.Expression import *
 from CommonDataClass.CommonClass import SkuInfoClass
 from Common.TargetTxtClassObject import *
 from Common.ToolDefClassObject import *
-from MetaDataTable import *
-from MetaFileTable import *
-from MetaFileParser import *
+from .MetaDataTable import *
+from .MetaFileTable import *
+from .MetaFileParser import *
 
-from WorkspaceCommon import GetDeclaredPcd
+from .WorkspaceCommon import GetDeclaredPcd
 from Common.Misc import AnalyzeDscPcd
 from Common.Misc import ProcessDuplicatedInf
 import re
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py 
b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 165e03f78964..f79ffe28d804 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -12,11 +12,12 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 from Common.StringUtils import *
 from Common.DataType import *
 from Common.Misc import *
 from types import *
-from MetaFileParser import *
+from .MetaFileParser import *
 from collections import OrderedDict
 
 from Workspace.BuildClassObject import ModuleBuildClassObject, 
LibraryClassObject, PcdClassObject
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 0aa72d8302a0..fbfc182c8bff 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -16,6 +16,7 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import re
 import time
@@ -33,8 +34,8 @@ from Common.Expression import *
 from CommonDataClass.Exceptions import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from collections import defaultdict
-from MetaFileTable import MetaFileStorage
-from MetaFileCommentParser import CheckInfComment
+from .MetaFileTable import MetaFileStorage
+from .MetaFileCommentParser import CheckInfComment
 
 ## RegEx for finding file versions
 hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py 
b/BaseTools/Source/Python/Workspace/MetaFileTable.py
index ee1c7fffca3b..e0a0b8d92351 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py
@@ -14,13 +14,14 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import uuid
 
 import Common.EdkLogger as EdkLogger
 from Common.BuildToolError import FORMAT_INVALID
 
-from MetaDataTable import Table, TableFile
-from MetaDataTable import ConvertToSqlString
+from .MetaDataTable import Table, TableFile
+from .MetaDataTable import ConvertToSqlString
 from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, 
MODEL_FILE_INF, \
   MODEL_FILE_OTHERS
 from Common.DataType import *
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py 
b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index e8f159b26204..d987bbf441ea 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -11,9 +11,10 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 from collections import OrderedDict, defaultdict
 from Common.DataType import SUP_MODULE_USER_DEFINED
-from BuildClassObject import LibraryClassObject
+from .BuildClassObject import LibraryClassObject
 import Common.GlobalData as GlobalData
 from Workspace.BuildClassObject import StructurePcd
 from Common.BuildToolError import RESOURCE_NOT_AVAILABLE
diff --git 

[edk2] [PATCH 08/14] BaseTools: Use absolute import in Common

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/Common/Database.py | 8 
 BaseTools/Source/Python/Common/EdkLogger.py| 3 ++-
 BaseTools/Source/Python/Common/Expression.py   | 3 ++-
 BaseTools/Source/Python/Common/LongFilePathOs.py   | 3 ++-
 BaseTools/Source/Python/Common/Misc.py | 9 +
 BaseTools/Source/Python/Common/Parsing.py  | 5 +++--
 BaseTools/Source/Python/Common/StringUtils.py  | 9 +
 BaseTools/Source/Python/Common/TargetTxtClassObject.py | 9 +
 BaseTools/Source/Python/Common/ToolDefClassObject.py   | 9 +
 9 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Database.py 
b/BaseTools/Source/Python/Common/Database.py
index 6abfa1f15e35..1c543aeb41b1 100644
--- a/BaseTools/Source/Python/Common/Database.py
+++ b/BaseTools/Source/Python/Common/Database.py
@@ -14,13 +14,14 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import sqlite3
 import Common.LongFilePathOs as os
 
-import EdkLogger as EdkLogger
+from . import EdkLogger as EdkLogger
 from CommonDataClass.DataClass import *
-from StringUtils import *
-from DataType import *
+from .StringUtils import *
+from .DataType import *
 
 from Table.TableDataModel import TableDataModel
 from Table.TableFile import TableFile
@@ -117,4 +118,3 @@ if __name__ == '__main__':
 Db.QueryTable(Db.TblFile)
 Db.QueryTable(Db.TblDsc)
 Db.Close()
-
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py 
b/BaseTools/Source/Python/Common/EdkLogger.py
index 3f462df49ada..19749066ecee 100644
--- a/BaseTools/Source/Python/Common/EdkLogger.py
+++ b/BaseTools/Source/Python/Common/EdkLogger.py
@@ -12,9 +12,10 @@
 #
 
 ## Import modules
+from __future__ import absolute_import
 import Common.LongFilePathOs as os, sys, logging
 import traceback
-from  BuildToolError import *
+from  .BuildToolError import *
 
 ## Log level constants
 DEBUG_0 = 1
diff --git a/BaseTools/Source/Python/Common/Expression.py 
b/BaseTools/Source/Python/Common/Expression.py
index 51e8d2174a8f..ccc736846afa 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -13,10 +13,11 @@
 ## Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from Common.GlobalData import *
 from CommonDataClass.Exceptions import BadExpression
 from CommonDataClass.Exceptions import WrnExpression
-from Misc import GuidStringToGuidStructureString, ParseFieldValue, 
IsFieldValueAnArray
+from .Misc import GuidStringToGuidStructureString, ParseFieldValue, 
IsFieldValueAnArray
 import Common.EdkLogger as EdkLogger
 import copy
 from Common.DataType import *
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py 
b/BaseTools/Source/Python/Common/LongFilePathOs.py
index 4939a8bc733c..53528546b782 100644
--- a/BaseTools/Source/Python/Common/LongFilePathOs.py
+++ b/BaseTools/Source/Python/Common/LongFilePathOs.py
@@ -11,8 +11,9 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 import os
-import LongFilePathOsPath
+from . import LongFilePathOsPath
 from Common.LongFilePathSupport import LongFilePath
 from Common.LongFilePathSupport import UniToStr
 import time
diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index b56ddd532471..79d1ff28f50b 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import sys
 import string
@@ -30,10 +31,10 @@ from UserList import UserList
 
 from Common import EdkLogger as EdkLogger
 from Common import GlobalData as GlobalData
-from DataType import *
-from BuildToolError import *
+from .DataType import *
+from .BuildToolError import *
 from CommonDataClass.DataClass import *
-from Parsing import GetSplitValueList
+from .Parsing import GetSplitValueList
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 import uuid
@@ -474,7 +475,7 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
 try:
 if GlobalData.gIsWindows:
 try:
-from PyUtility import SaveFileToDisk
+from .PyUtility import SaveFileToDisk
 if not SaveFileToDisk(File, Content):
 EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=File)
 except:
diff --git a/BaseTools/Source/Python/Common/Parsing.py 
b/BaseTools/Source/Python/Common/Parsing.py
index 527852a50c09..889251b69935 100644
--- a/BaseTools/Source/Python/Common/Parsing.py
+++ 

[edk2] [PATCH 11/14] BaseTools: Use absolute import in Table

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/Table/TableDataModel.py  | 3 ++-
 BaseTools/Source/Python/Table/TableDec.py| 3 ++-
 BaseTools/Source/Python/Table/TableDsc.py| 3 ++-
 BaseTools/Source/Python/Table/TableEotReport.py  | 3 ++-
 BaseTools/Source/Python/Table/TableFdf.py| 3 ++-
 BaseTools/Source/Python/Table/TableFile.py   | 3 ++-
 BaseTools/Source/Python/Table/TableFunction.py   | 3 ++-
 BaseTools/Source/Python/Table/TableIdentifier.py | 3 ++-
 BaseTools/Source/Python/Table/TableInf.py| 3 ++-
 BaseTools/Source/Python/Table/TablePcd.py| 3 ++-
 BaseTools/Source/Python/Table/TableQuery.py  | 3 ++-
 BaseTools/Source/Python/Table/TableReport.py | 3 ++-
 12 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/BaseTools/Source/Python/Table/TableDataModel.py 
b/BaseTools/Source/Python/Table/TableDataModel.py
index f167e433599a..ea0996f66332 100644
--- a/BaseTools/Source/Python/Table/TableDataModel.py
+++ b/BaseTools/Source/Python/Table/TableDataModel.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableDataModel
diff --git a/BaseTools/Source/Python/Table/TableDec.py 
b/BaseTools/Source/Python/Table/TableDec.py
index faa18e309d72..bbae3e857e1a 100644
--- a/BaseTools/Source/Python/Table/TableDec.py
+++ b/BaseTools/Source/Python/Table/TableDec.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableDec
diff --git a/BaseTools/Source/Python/Table/TableDsc.py 
b/BaseTools/Source/Python/Table/TableDsc.py
index 227748951841..6436973c4534 100644
--- a/BaseTools/Source/Python/Table/TableDsc.py
+++ b/BaseTools/Source/Python/Table/TableDsc.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 ## @file
 # This file is used to create/update/query/erase table for dsc datas
 #
@@ -16,7 +17,7 @@
 #
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableDsc
diff --git a/BaseTools/Source/Python/Table/TableEotReport.py 
b/BaseTools/Source/Python/Table/TableEotReport.py
index e8291b48d7c3..0a490161cda8 100644
--- a/BaseTools/Source/Python/Table/TableEotReport.py
+++ b/BaseTools/Source/Python/Table/TableEotReport.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import Common.LongFilePathOs as os, time
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString2
 import Eot.EotToolError as EotToolError
 import Eot.EotGlobalData as EotGlobalData
diff --git a/BaseTools/Source/Python/Table/TableFdf.py 
b/BaseTools/Source/Python/Table/TableFdf.py
index 872afc79ef44..80be9532cae1 100644
--- a/BaseTools/Source/Python/Table/TableFdf.py
+++ b/BaseTools/Source/Python/Table/TableFdf.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableFdf
diff --git a/BaseTools/Source/Python/Table/TableFile.py 
b/BaseTools/Source/Python/Table/TableFile.py
index 34a0b47418dc..689264c2578a 100644
--- a/BaseTools/Source/Python/Table/TableFile.py
+++ b/BaseTools/Source/Python/Table/TableFile.py
@@ -14,8 +14,9 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 import Common.LongFilePathOs as os
 from CommonDataClass.DataClass import FileClass
diff --git a/BaseTools/Source/Python/Table/TableFunction.py 
b/BaseTools/Source/Python/Table/TableFunction.py
index bf301fd2620c..166718060600 100644
--- a/BaseTools/Source/Python/Table/TableFunction.py
+++ b/BaseTools/Source/Python/Table/TableFunction.py
@@ -14,8 +14,9 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableFunction
diff --git a/BaseTools/Source/Python/Table/TableIdentifier.py 
b/BaseTools/Source/Python/Table/TableIdentifier.py
index 5ce528b26a4c..8b4dd1d310ec 100644
--- a/BaseTools/Source/Python/Table/TableIdentifier.py
+++ 

[edk2] [PATCH 10/14] BaseTools: Use absolute import in Eot

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/Eot/CParser.py   |  5 +++--
 BaseTools/Source/Python/Eot/CodeFragmentCollector.py | 11 +-
 BaseTools/Source/Python/Eot/Eot.py   | 21 ++--
 BaseTools/Source/Python/Eot/FileProfile.py   |  3 ++-
 BaseTools/Source/Python/Eot/InfParserLite.py |  5 +++--
 BaseTools/Source/Python/Eot/Parser.py|  3 ++-
 BaseTools/Source/Python/Eot/Report.py|  3 ++-
 BaseTools/Source/Python/Eot/c.py |  9 +
 8 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/BaseTools/Source/Python/Eot/CParser.py 
b/BaseTools/Source/Python/Eot/CParser.py
index b66ac2d8d545..0b74b53ae7a5 100644
--- a/BaseTools/Source/Python/Eot/CParser.py
+++ b/BaseTools/Source/Python/Eot/CParser.py
@@ -1,6 +1,7 @@
 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
 
 from __future__ import print_function
+from __future__ import absolute_import
 from antlr3 import *
 from antlr3.compat import set, frozenset
 
@@ -23,8 +24,8 @@ from antlr3.compat import set, frozenset
 #
 ##
 
-import CodeFragment
-import FileProfile
+from . import CodeFragment
+from . import FileProfile
 
 
 
diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py 
b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
index 1e30e2ce62e2..8a5e5df17e5a 100644
--- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
@@ -16,17 +16,18 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import re
 import Common.LongFilePathOs as os
 import sys
 
 import antlr3
-from CLexer import CLexer
-from CParser import CParser
+from .CLexer import CLexer
+from .CParser import CParser
 
-import FileProfile
-from CodeFragment import PP_Directive
-from ParserWarning import Warning
+from . import FileProfile
+from .CodeFragment import PP_Directive
+from .ParserWarning import Warning
 
 
 ##define T_CHAR_SPACE' '
diff --git a/BaseTools/Source/Python/Eot/Eot.py 
b/BaseTools/Source/Python/Eot/Eot.py
index 297847cdab91..6fb882642bff 100644
--- a/BaseTools/Source/Python/Eot/Eot.py
+++ b/BaseTools/Source/Python/Eot/Eot.py
@@ -14,20 +14,21 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os, time, glob
 import Common.EdkLogger as EdkLogger
-import EotGlobalData
+from . import EotGlobalData
 from optparse import OptionParser
 from Common.StringUtils import NormPath
 from Common import BuildToolError
 from Common.Misc import GuidStructureStringToGuidString, sdict
-from InfParserLite import *
-import c
-import Database
+from .InfParserLite import *
+from . import c
+from . import Database
 from array import array
-from Report import Report
+from .Report import Report
 from Common.BuildVersion import gBUILD_VERSION
-from Parser import ConvertGuid
+from .Parser import ConvertGuid
 from Common.LongFilePathSupport import OpenLongFilePath as open
 import struct
 import uuid
@@ -153,7 +154,7 @@ class CompressedImage(Image):
 
 def _GetSections(m):
 try:
-import EfiCompressor
+from . import EfiCompressor
 TmpData = EfiCompressor.FrameworkDecompress(
 m[m._HEADER_SIZE_:],
 len(m) - m._HEADER_SIZE_
@@ -161,7 +162,7 @@ class CompressedImage(Image):
 DecData = array('B')
 DecData.fromstring(TmpData)
 except:
-import EfiCompressor
+from . import EfiCompressor
 TmpData = EfiCompressor.UefiDecompress(
 m[m._HEADER_SIZE_:],
 len(m) - m._HEADER_SIZE_
@@ -748,7 +749,7 @@ class GuidDefinedImage(Image):
 SectionList.append(Sec)
 elif Guid == m.TIANO_COMPRESS_GUID:
 try:
-import EfiCompressor
+from . import EfiCompressor
 # skip the header
 Offset = m.DataOffset - 4
 TmpData = EfiCompressor.FrameworkDecompress(m[Offset:], 
len(m)-Offset)
@@ -769,7 +770,7 @@ class GuidDefinedImage(Image):
 pass
 elif Guid == m.LZMA_COMPRESS_GUID:
 try:
-import LzmaCompressor
+from . import LzmaCompressor
 # skip the header
 Offset = m.DataOffset - 4
 TmpData = LzmaCompressor.LzmaDecompress(m[Offset:], 
len(m)-Offset)
diff --git a/BaseTools/Source/Python/Eot/FileProfile.py 
b/BaseTools/Source/Python/Eot/FileProfile.py
index 0544c0d55b44..3846279cad4c 100644
--- a/BaseTools/Source/Python/Eot/FileProfile.py
+++ 

[edk2] [PATCH 07/14] BaseTools: Use absolute import in BPDG

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/BPDG/BPDG.py   | 5 +++--
 BaseTools/Source/Python/BPDG/GenVpd.py | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/BPDG/BPDG.py 
b/BaseTools/Source/Python/BPDG/BPDG.py
index 07cee8976208..2ec1516c0a08 100644
--- a/BaseTools/Source/Python/BPDG/BPDG.py
+++ b/BaseTools/Source/Python/BPDG/BPDG.py
@@ -21,6 +21,7 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import sys
 import encodings.ascii
@@ -30,8 +31,8 @@ from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.BuildVersion import gBUILD_VERSION
 
-import StringTable as st
-import GenVpd
+from . import StringTable as st
+from . import GenVpd
 
 PROJECT_NAME   = st.LBL_BPDG_LONG_UNI
 VERSION= (st.LBL_BPDG_VERSION + " Build " + gBUILD_VERSION)
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py 
b/BaseTools/Source/Python/BPDG/GenVpd.py
index 2eefcc24905f..cd272a2d9a79 100644
--- a/BaseTools/Source/Python/BPDG/GenVpd.py
+++ b/BaseTools/Source/Python/BPDG/GenVpd.py
@@ -13,9 +13,10 @@
 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
 #
 
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 from io import BytesIO
-import StringTable as st
+from . import StringTable as st
 import array
 import re
 from Common.LongFilePathSupport import OpenLongFilePath as open
-- 
2.18.0

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


[edk2] [PATCH 12/14] BaseTools: Use absolute import in UPT

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/UPT/Library/Parsing.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/UPT/Library/Parsing.py 
b/BaseTools/Source/Python/UPT/Library/Parsing.py
index 5c4666399e29..81729d6cdbf7 100644
--- a/BaseTools/Source/Python/UPT/Library/Parsing.py
+++ b/BaseTools/Source/Python/UPT/Library/Parsing.py
@@ -16,6 +16,7 @@
 '''
 Parsing
 '''
+from __future__ import absolute_import
 
 ##
 # Import Modules
@@ -42,7 +43,7 @@ from Logger import StringTable as ST
 import Logger.Log as Logger
 
 from Parser.DecParser import Dec
-import GlobalData
+from . import GlobalData
 
 gPKG_INFO_DICT = {}
 
-- 
2.18.0

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


[edk2] [PATCH 14/14] BaseTools: Use absolute import in Scripts

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py 
| 3 ++-
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py 
| 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
index b5ab213cd7f0..d1e21135cf05 100644
--- 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
+++ 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
@@ -12,9 +12,10 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 import os
 
-from message import *
+from .message import *
 
 class BaseDoxygeItem:
 def __init__(self, name, tag=''):
diff --git 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
index ccfef6b6e280..6e6f3f4b9795 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
@@ -11,7 +11,8 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
-from message import *
+from __future__ import absolute_import
+from .message import *
 import re
 import os
 
-- 
2.18.0

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


[edk2] [PATCH 06/14] BaseTools: Use absolute import in AutoGen

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py| 17 +
 BaseTools/Source/Python/AutoGen/GenC.py   |  7 ---
 BaseTools/Source/Python/AutoGen/GenMake.py|  3 ++-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py   |  7 ---
 BaseTools/Source/Python/AutoGen/IdfClassObject.py |  3 ++-
 BaseTools/Source/Python/AutoGen/StrGather.py  |  3 ++-
 6 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index d100648606f7..207f2a7258b5 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -16,19 +16,20 @@
 ## Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import re
 import os.path as path
 import copy
 import uuid
 
-import GenC
-import GenMake
-import GenDepex
+from . import GenC
+from . import GenMake
+from . import GenDepex
 from io import BytesIO
 
-from StrGather import *
-from BuildEngine import BuildRule
+from .StrGather import *
+from .BuildEngine import BuildRule
 
 from Common.LongFilePathSupport import CopyLongFilePath
 from Common.BuildToolError import *
@@ -41,14 +42,14 @@ from CommonDataClass.CommonClass import SkuInfoClass
 from Workspace.BuildClassObject import *
 from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile
 import Common.VpdInfoFile as VpdInfoFile
-from GenPcdDb import CreatePcdDatabaseCode
+from .GenPcdDb import CreatePcdDatabaseCode
 from Workspace.MetaFileCommentParser import UsageList
 from Workspace.WorkspaceCommon import GetModuleLibInstances
 from Common.MultipleWorkspace import MultipleWorkspace as mws
-import InfSectionParser
+from . import InfSectionParser
 import datetime
 import hashlib
-from GenVar import VariableMgr, var_info
+from .GenVar import VariableMgr, var_info
 from collections import OrderedDict
 from collections import defaultdict
 from Workspace.WorkspaceCommon import OrderedListDict
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index eac41ed9bf81..528be0f77e3d 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -13,6 +13,7 @@
 
 ## Import Modules
 #
+from __future__ import absolute_import
 import string
 import collections
 import struct
@@ -22,9 +23,9 @@ from Common.BuildToolError import *
 from Common.DataType import *
 from Common.Misc import *
 from Common.StringUtils import StringToArray
-from StrGather import *
-from GenPcdDb import CreatePcdDatabaseCode
-from IdfClassObject import *
+from .StrGather import *
+from .GenPcdDb import CreatePcdDatabaseCode
+from .IdfClassObject import *
 
 ## PCD type string
 gItemTypeStringDatabase  = {
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py 
b/BaseTools/Source/Python/AutoGen/GenMake.py
index 992de5490dff..f1dc14754154 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -13,6 +13,7 @@
 
 ## Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import sys
 import string
@@ -23,7 +24,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
 from Common.BuildToolError import *
 from Common.Misc import *
 from Common.StringUtils import *
-from BuildEngine import *
+from .BuildEngine import *
 import Common.GlobalData as GlobalData
 from collections import OrderedDict
 
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py 
b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index c90b814e7dbd..2176bbefeb52 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -10,13 +10,14 @@
 # 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 __future__ import absolute_import
 from io import BytesIO
 from Common.Misc import *
 from Common.StringUtils import StringToArray
 from struct import pack
-from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER
-from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB
-from ValidCheckingInfoObject import GetValidationObject
+from .ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER
+from .ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB
+from .ValidCheckingInfoObject import GetValidationObject
 from Common.VariableAttributes import VariableAttributes
 import copy
 from struct import unpack
diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py 
b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
index b656bd83e3ba..b227b10258da 100644
--- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py
+++ 

[edk2] [PATCH 05/14] BaseTools: Move ImageBinDict to GenFdsGlobalVariable.py

2018-07-09 Thread Gary Lin
Move "ImageBinDict" from GenFds.py to GenFdsGlobalVariable.py so that we
can remove the requirement to import GenFds.GenFds in Capsule.py, Fd.py and
Fv.py. This breaks the following circular imports:

* GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds => GenFds.FdfParser
* GenFds.FdfParser => GenFds.Fd => GenFds.GenFds => GenFds.FdfParser
* GenFds.FdfParser => GenFds.Fd => GenFds.Fv => GenFds.GenFds =>
  GenFds.FdfParser

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/GenFds/Capsule.py  |  7 +++
 BaseTools/Source/Python/GenFds/Fd.py   | 15 +++
 BaseTools/Source/Python/GenFds/Fv.py   | 11 +--
 BaseTools/Source/Python/GenFds/GenFds.py   |  2 --
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  3 +++
 5 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/Capsule.py 
b/BaseTools/Source/Python/GenFds/Capsule.py
index 8471cd5d0f7a..baa6e1dfa2ab 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -201,9 +201,8 @@ class Capsule (CapsuleClassObject) :
 #   @retval string  Generated Capsule file path
 #
 def GenCapsule(self):
-from .GenFds import GenFds
-if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:
-return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
+if self.UiCapsuleName.upper() + 'cap' in 
GenFdsGlobalVariable.ImageBinDict:
+return 
GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
 
 GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" 
%self.UiCapsuleName)
 if ('CAPSULE_GUID' in self.TokensDict and
@@ -237,7 +236,7 @@ class Capsule (CapsuleClassObject) :
 
 GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s Capsule 
Successfully" %self.UiCapsuleName)
 GenFdsGlobalVariable.SharpCounter = 0
-GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] = CapOutputFile
+GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] 
= CapOutputFile
 return CapOutputFile
 
 ## Generate inf file for capsule
diff --git a/BaseTools/Source/Python/GenFds/Fd.py 
b/BaseTools/Source/Python/GenFds/Fd.py
index 53318c9ea5c0..bfae1217984a 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -47,9 +47,8 @@ class FD(FDClassObject):
 #   @retval string  Generated FD file name
 #
 def GenFd (self, Flag = False):
-from .GenFds import GenFds
-if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict:
-return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']
+if self.FdUiName.upper() + 'fd' in GenFdsGlobalVariable.ImageBinDict:
+return GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 
'fd']
 
 #
 # Print Information
@@ -94,7 +93,7 @@ class FD(FDClassObject):
 PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
 PadRegion.Size = RegionObj.Offset - PadRegion.Offset
 if not Flag:
-PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, 
self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, 
self.DefineVarDict)
+PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, 
self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, 
self.vtfRawDict, self.DefineVarDict)
 PreviousRegionStart = RegionObj.Offset
 PreviousRegionSize = RegionObj.Size
 #
@@ -103,7 +102,7 @@ class FD(FDClassObject):
 if PreviousRegionSize > self.Size:
 pass
 GenFdsGlobalVariable.VerboseLogger('Call each region\'s 
AddToBuffer function')
-RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, 
self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, 
self.DefineVarDict)
+RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, 
self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, 
self.vtfRawDict, self.DefineVarDict)
 
 FdBuffer = BytesIO('')
 PreviousRegionStart = -1
@@ -124,7 +123,7 @@ class FD(FDClassObject):
 PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
 PadRegion.Size = RegionObj.Offset - PadRegion.Offset
 if not Flag:
-PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, 
self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, 
self.DefineVarDict)
+PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, 
self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, 
self.vtfRawDict, self.DefineVarDict)
 

[edk2] [PATCH 02/14] BaseTools: Use absolute import in GenFds

2018-07-09 Thread Gary Lin
Based on "futurize -f libfuturize.fixes.fix_absolute_import"

Since circular import is not allowed after adopting absolute import, the
following changes are applied to break the circles.

* BaseTools/Source/Python/GenFds/Capsule.py
  - Delay "from .GenFds import GenFds" until GenCapsule()
  - Delay "from .GenFds import FindExtendTool" until GenFmpCapsule()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds =>
  GenFds.FdfParser

* BaseTools/Source/Python/GenFds/Fd.py
  - Delay "from .GenFds import GenFds" until GenFd()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.GenFds =>
  GenFds.FdfParser

* BaseTools/Source/Python/GenFds/Fv.py
  - Delay "from .GenFds import GenFds" until AddToBuffer()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.Fv =>
  GenFds.GenFds => GenFds.FdfParser

* BaseTools/Source/Python/GenFds/GuidSection.py
  - Delay "from .GenFds import FindExtendTool" until GuidSection()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.Fv =>
  GenFds.AprioriSection => GenFds.FfsFileStatement => GenFds.GuidSection =>
  GenFds.GenFds => GenFds.FdfParser

* BaseTools/Source/Python/GenFds/OptRomInfStatement.py
  - Delay "from . import OptionRom" until __GetOptRomParams()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.OptionRom =>
  GenFds.OptRomInfStatement => GenFds.OptionRom

* BaseTools/Source/Python/GenFds/OptionRom.py
  - Remove the unused "from GenFds import GenFds"
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.OptionRom =>
  GenFds.GenFds => GenFds.FdfParser

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/GenFds/AprioriSection.py  |  5 +-
 BaseTools/Source/Python/GenFds/Capsule.py |  7 +--
 BaseTools/Source/Python/GenFds/CapsuleData.py |  5 +-
 BaseTools/Source/Python/GenFds/CompressSection.py |  7 +--
 BaseTools/Source/Python/GenFds/DataSection.py |  7 +--
 BaseTools/Source/Python/GenFds/DepexSection.py|  7 +--
 BaseTools/Source/Python/GenFds/EfiSection.py  |  7 +--
 BaseTools/Source/Python/GenFds/Fd.py  |  9 ++--
 BaseTools/Source/Python/GenFds/FdfParser.py   | 55 ++--
 BaseTools/Source/Python/GenFds/FfsFileStatement.py| 11 ++--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py | 19 +++
 BaseTools/Source/Python/GenFds/Fv.py  | 11 ++--
 BaseTools/Source/Python/GenFds/FvImageSection.py  |  7 +--
 BaseTools/Source/Python/GenFds/GenFds.py  | 11 ++--
 BaseTools/Source/Python/GenFds/GuidSection.py | 11 ++--
 BaseTools/Source/Python/GenFds/OptRomFileStatement.py |  3 +-
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py  | 16 +++---
 BaseTools/Source/Python/GenFds/OptionRom.py   |  6 +--
 BaseTools/Source/Python/GenFds/Region.py  |  3 +-
 BaseTools/Source/Python/GenFds/RuleComplexFile.py |  3 +-
 BaseTools/Source/Python/GenFds/RuleSimpleFile.py  |  3 +-
 BaseTools/Source/Python/GenFds/Section.py |  3 +-
 BaseTools/Source/Python/GenFds/UiSection.py   |  7 +--
 BaseTools/Source/Python/GenFds/VerSection.py  |  7 +--
 BaseTools/Source/Python/GenFds/Vtf.py |  3 +-
 25 files changed, 127 insertions(+), 106 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py 
b/BaseTools/Source/Python/GenFds/AprioriSection.py
index b3e7b5fc64a3..7196f7f2c753 100644
--- a/BaseTools/Source/Python/GenFds/AprioriSection.py
+++ b/BaseTools/Source/Python/GenFds/AprioriSection.py
@@ -15,11 +15,12 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from struct import *
 import Common.LongFilePathOs as os
 from io import BytesIO
-import FfsFileStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from . import FfsFileStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import AprioriSectionClassObject
 from Common.StringUtils import *
 from Common.Misc import SaveFileOnChange, PathClass
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py 
b/BaseTools/Source/Python/GenFds/Capsule.py
index 35a25bd38037..27932ef0020c 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -15,17 +15,16 @@
 ##
 # Import Modules
 #
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import CapsuleClassObject
 import Common.LongFilePathOs as os
 import subprocess
 from io import BytesIO
 from Common.Misc import SaveFileOnChange
-from GenFds import GenFds
 from Common.Misc import PackRegistryFormatGuid
 import uuid
 from struct import pack
-from GenFds import FindExtendTool
 

[edk2] [PATCH 03/14] BaseTools: Move OverrideAttribs to OptRomInfStatement.py

2018-07-09 Thread Gary Lin
Move "class OverrideAttribs" to OptRomInfStatement.py to remove
"import OptionRom" which may form a circular import:
GenFds.OptionRom => GenFds.OptRomInfStatement => GenFds.OptionRom

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/GenFds/FdfParser.py  |  2 +-
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py | 17 +++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index c890f2d3afb6..8125ffaf32be 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -4440,7 +4440,7 @@ class FdfParser:
 #
 def __GetOptRomOverrides(self, Obj):
 if self.__IsToken('{'):
-Overrides = OptionRom.OverrideAttribs()
+Overrides = OptRomInfStatement.OverrideAttribs()
 while True:
 if self.__IsKeyword( "PCI_VENDOR_ID"):
 if not self.__IsToken( "="):
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py 
b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
index dfeba5d0b140..e416b838d1e4 100644
--- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
@@ -45,9 +45,8 @@ class OptRomInfStatement (FfsInfStatement):
 #   @param  selfThe object pointer
 #
 def __GetOptRomParams(self):
-from . import OptionRom
 if self.OverrideAttribs is None:
-self.OverrideAttribs = OptionRom.OverrideAttribs()
+self.OverrideAttribs = OverrideAttribs()
 
 if self.OverrideAttribs.NeedCompress is None:
 self.OverrideAttribs.NeedCompress = self.OptRomDefs.get 
('PCI_COMPRESS')
@@ -150,3 +149,17 @@ class OptRomInfStatement (FfsInfStatement):
 OutputFileList.extend(FileList)
 
 return OutputFileList
+
+class OverrideAttribs:
+
+## The constructor
+#
+#   @param  selfThe object pointer
+#
+def __init__(self):
+
+self.PciVendorId = None
+self.PciClassCode = None
+self.PciDeviceId = None
+self.PciRevision = None
+self.NeedCompress = None
-- 
2.18.0

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


[edk2] [PATCH 04/14] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py

2018-07-09 Thread Gary Lin
Importing "FindExtendTool" from GenFds.GenFds could create the following
circular imports:

* GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds => GenFds.FdfParser
* GenFds.FdfParser => GenFds.Fd => GenFds.Fv => GenFds.AprioriSection =>
  GenFds.FfsFileStatement => GenFds.GuidSection => GenFds.GenFds =>
  GenFds.FdfParser

This commit moves "FindExtendTool" to GenFdsGlobalVariable.py to break
the circles. Besides, FindExtendTool is tweaked slightly with the
following changes:

ToolDefClassObject.ToolDefDict => ToolDefDict
TAB_GUID => DataType.TAB_GUID
TAB_TOD_DEFINES_TARGET => DataType.TAB_TOD_DEFINES_TARGET
TAB_TOD_DEFINES_TOOL_CHAIN_TAG => DataType.TAB_TOD_DEFINES_TOOL_CHAIN_TAG
TAB_TOD_DEFINES_TARGET_ARCH => DataType.TAB_TOD_DEFINES_TARGET_ARCH

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/Source/Python/GenFds/Capsule.py  |  2 +-
 BaseTools/Source/Python/GenFds/GenFds.py   | 92 ---
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 94 
+++-
 BaseTools/Source/Python/GenFds/GuidSection.py  |  2 +-
 4 files changed, 95 insertions(+), 95 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/Capsule.py 
b/BaseTools/Source/Python/GenFds/Capsule.py
index 27932ef0020c..8471cd5d0f7a 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -17,6 +17,7 @@
 #
 from __future__ import absolute_import
 from .GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import FindExtendTool
 from CommonDataClass.FdfClass import CapsuleClassObject
 import Common.LongFilePathOs as os
 import subprocess
@@ -65,7 +66,6 @@ class Capsule (CapsuleClassObject) :
 # UINT32CapsuleImageSize;
 # } EFI_CAPSULE_HEADER;
 #
-from .GenFds import FindExtendTool
 Header = BytesIO()
 #
 # Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py 
b/BaseTools/Source/Python/GenFds/GenFds.py
index c0b60b9b3c1f..865c5099d1eb 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -368,98 +368,6 @@ def SingleCheckCallback(option, opt_str, value, parser):
 else:
 parser.error("Option %s only allows one instance in command line!" % 
option)
 
-## FindExtendTool()
-#
-#  Find location of tools to process data
-#
-#  @param  KeyStringListFilter for inputs of section generation
-#  @param  CurrentArchList  Arch list
-#  @param  NameGuid The Guid name
-#
-def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
-ToolDb = 
ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase
-# if user not specify filter, try to deduce it from global data.
-if KeyStringList is None or KeyStringList == []:
-Target = GenFdsGlobalVariable.TargetName
-ToolChain = GenFdsGlobalVariable.ToolChainTag
-if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:
-EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external 
tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)
-KeyStringList = [Target + '_' + ToolChain + '_' + CurrentArchList[0]]
-for Arch in CurrentArchList:
-if Target + '_' + ToolChain + '_' + Arch not in KeyStringList:
-KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)
-
-if GenFdsGlobalVariable.GuidToolDefinition:
-if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:
-return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]
-
-ToolDefinition = 
ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
-ToolPathTmp = None
-ToolOption = None
-ToolPathKey = None
-ToolOptionKey = None
-KeyList = None
-for ToolDef in ToolDefinition.items():
-if NameGuid.lower() == ToolDef[1].lower() :
-KeyList = ToolDef[0].split('_')
-Key = KeyList[0] + \
-  '_' + \
-  KeyList[1] + \
-  '_' + \
-  KeyList[2]
-if Key in KeyStringList and KeyList[4] == TAB_GUID:
-ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
-ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
-ToolPath = ToolDefinition.get(ToolPathKey)
-ToolOption = ToolDefinition.get(ToolOptionKey)
-if ToolPathTmp is None:
-ToolPathTmp = ToolPath
-else:
-if ToolPathTmp != ToolPath:
-EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know 
which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))
-
-BuildOption = {}
-for Arch in CurrentArchList:
-Platform = 

[edk2] [PATCH 01/14] BaseTools: Treat GenFds.py as a python module

2018-07-09 Thread Gary Lin
Since GenFds.py import modules from its own directory, add "-m" to the
python parameters so that they can import its own modules after adopting
absolute import.

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 
---
 BaseTools/BinWrappers/PosixLike/GenFds   | 2 +-
 BaseTools/BinWrappers/WindowsLike/GenFds.bat | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/BaseTools/BinWrappers/PosixLike/GenFds 
b/BaseTools/BinWrappers/PosixLike/GenFds
index 01ae23ddeb4f..276c7ea20733 100755
--- a/BaseTools/BinWrappers/PosixLike/GenFds
+++ b/BaseTools/BinWrappers/PosixLike/GenFds
@@ -11,4 +11,4 @@ dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
 export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
-exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
+exec "${python_exe:-python}" -m $cmd.$cmd "$@"
diff --git a/BaseTools/BinWrappers/WindowsLike/GenFds.bat 
b/BaseTools/BinWrappers/WindowsLike/GenFds.bat
index 9fbb704a6eb0..98095cfbd439 100644
--- a/BaseTools/BinWrappers/WindowsLike/GenFds.bat
+++ b/BaseTools/BinWrappers/WindowsLike/GenFds.bat
@@ -1,3 +1,4 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON_HOME%\python.exe 
%BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
+@%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %*
-- 
2.18.0

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


[edk2] [PATCH 00/14] BaseTools: Adopt absolute import

2018-07-09 Thread Gary Lin
This patch series is based on "libfuturize.fixes.fix_absolute_import"
to adopt abolute import since relative import is not allowed in python3.

The command is applied to BaseTools modules individually. Most of the
patches are straightforward except the GenFds patches. It's because
there are several circular imports in GenFds and circular import is not
compatible with absolute import. To make the patches bisectable, I delay
the import of some modules in the first GenFds patch and refactor the
code in the follow-up patches to remove circular import completely.

The patch set is also available in my github branch:

https://github.com/lcp/edk2/tree/python3-absolute-import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu 
Cc: Liming Gao 
Signed-off-by: Gary Lin 

Gary Lin (14):
  BaseTools: Treat GenFds.py as a python module
  BaseTools: Use absolute import in GenFds
  BaseTools: Move OverrideAttribs to OptRomInfStatement.py
  BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py
  BaseTools: Move ImageBinDict to GenFdsGlobalVariable.py
  BaseTools: Use absolute import in AutoGen
  BaseTools: Use absolute import in BPDG
  BaseTools: Use absolute import in Common
  BaseTools: Use absolute import in ECC
  BaseTools: Use absolute import in Eot
  BaseTools: Use absolute import in Table
  BaseTools: Use absolute import in UPT
  BaseTools: Use absolute import in Workspace
  BaseTools: Use absolute import in Scripts

 BaseTools/BinWrappers/PosixLike/GenFds|   2 +-
 BaseTools/BinWrappers/WindowsLike/GenFds.bat  |   3 +-
 .../plugins/EdkPlugins/basemodel/doxygen.py   |   3 +-
 .../plugins/EdkPlugins/basemodel/ini.py   |   3 +-
 BaseTools/Source/Python/AutoGen/AutoGen.py|  17 +--
 BaseTools/Source/Python/AutoGen/GenC.py   |   7 +-
 BaseTools/Source/Python/AutoGen/GenMake.py|   3 +-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py   |   7 +-
 .../Source/Python/AutoGen/IdfClassObject.py   |   3 +-
 BaseTools/Source/Python/AutoGen/StrGather.py  |   3 +-
 BaseTools/Source/Python/BPDG/BPDG.py  |   5 +-
 BaseTools/Source/Python/BPDG/GenVpd.py|   3 +-
 BaseTools/Source/Python/Common/Database.py|   8 +-
 BaseTools/Source/Python/Common/EdkLogger.py   |   3 +-
 BaseTools/Source/Python/Common/Expression.py  |   3 +-
 .../Source/Python/Common/LongFilePathOs.py|   3 +-
 BaseTools/Source/Python/Common/Misc.py|   9 +-
 BaseTools/Source/Python/Common/Parsing.py |   5 +-
 BaseTools/Source/Python/Common/StringUtils.py |   9 +-
 .../Python/Common/TargetTxtClassObject.py |   9 +-
 .../Python/Common/ToolDefClassObject.py   |   9 +-
 BaseTools/Source/Python/Ecc/CParser.py|   5 +-
 BaseTools/Source/Python/Ecc/Check.py  |   9 +-
 .../Python/Ecc/CodeFragmentCollector.py   |  13 ++-
 BaseTools/Source/Python/Ecc/Database.py   |   7 +-
 BaseTools/Source/Python/Ecc/Ecc.py|  25 +++--
 BaseTools/Source/Python/Ecc/Exception.py  |   3 +-
 BaseTools/Source/Python/Ecc/FileProfile.py|   5 +-
 BaseTools/Source/Python/Ecc/MetaDataParser.py |   5 +-
 .../Ecc/MetaFileWorkspace/MetaFileParser.py   |   3 +-
 .../Ecc/MetaFileWorkspace/MetaFileTable.py|   5 +-
 BaseTools/Source/Python/Ecc/c.py  |  13 ++-
 BaseTools/Source/Python/Eot/CParser.py|   5 +-
 .../Python/Eot/CodeFragmentCollector.py   |  11 +-
 BaseTools/Source/Python/Eot/Eot.py|  21 ++--
 BaseTools/Source/Python/Eot/FileProfile.py|   3 +-
 BaseTools/Source/Python/Eot/InfParserLite.py  |   5 +-
 BaseTools/Source/Python/Eot/Parser.py |   3 +-
 BaseTools/Source/Python/Eot/Report.py |   3 +-
 BaseTools/Source/Python/Eot/c.py  |   9 +-
 .../Source/Python/GenFds/AprioriSection.py|   5 +-
 BaseTools/Source/Python/GenFds/Capsule.py |  12 +-
 BaseTools/Source/Python/GenFds/CapsuleData.py |   5 +-
 .../Source/Python/GenFds/CompressSection.py   |   7 +-
 BaseTools/Source/Python/GenFds/DataSection.py |   7 +-
 .../Source/Python/GenFds/DepexSection.py  |   7 +-
 BaseTools/Source/Python/GenFds/EfiSection.py  |   7 +-
 BaseTools/Source/Python/GenFds/Fd.py  |  22 ++--
 BaseTools/Source/Python/GenFds/FdfParser.py   |  57 +-
 .../Source/Python/GenFds/FfsFileStatement.py  |  11 +-
 .../Source/Python/GenFds/FfsInfStatement.py   |  19 ++--
 BaseTools/Source/Python/GenFds/Fv.py  |  20 ++--
 .../Source/Python/GenFds/FvImageSection.py|   7 +-
 BaseTools/Source/Python/GenFds/GenFds.py  | 105 +-
 .../Python/GenFds/GenFdsGlobalVariable.py |  97 +++-
 BaseTools/Source/Python/GenFds/GuidSection.py |  11 +-
 .../Python/GenFds/OptRomFileStatement.py  |   3 +-
 .../Python/GenFds/OptRomInfStatement.py   |  27 +++--
 BaseTools/Source/Python/GenFds/OptionRom.py   |   6 +-
 BaseTools/Source/Python/GenFds/Region.py  |   3 +-
 .../Source/Python/GenFds/RuleComplexFile.py   |   3 +-
 .../Source/Python/GenFds/RuleSimpleFile.py|   3 +-
 

[edk2] [Patch] BaseTools: Remove a unused function.

2018-07-09 Thread BobCF
the call statement of _CheckDuplicateInFV() was commented out
in 2014. There is no call statement of _CheckDuplicateInFV(),
so remove it.

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

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index d100648606..57a4b4923f 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -617,13 +617,10 @@ class WorkspaceAutoGen(AutoGen):
 #
 # Check PCD type and definition between DSC and DEC
 #
 self._CheckPcdDefineAndType()
 
-# if self.FdfFile:
-# self._CheckDuplicateInFV(Fdf)
-
 #
 # Create BuildOptions Macro & PCD metafile, also add the Active 
Platform and FDF file.
 #
 content = 'gCommandLineDefines: '
 content += str(GlobalData.gCommandLineDefines)
@@ -759,135 +756,10 @@ class WorkspaceAutoGen(AutoGen):
 for filePath in self.BuildDatabase[self.MetaFile, Arch, Target, 
Toolchain]._RawData.IncludedFiles:
 AllWorkSpaceMetaFiles.add(filePath.Path)
 
 return AllWorkSpaceMetaFiles
 
-## _CheckDuplicateInFV() method
-#
-# Check whether there is duplicate modules/files exist in FV section.
-# The check base on the file GUID;
-#
-def _CheckDuplicateInFV(self, Fdf):
-for Fv in Fdf.Profile.FvDict:
-_GuidDict = {}
-for FfsFile in Fdf.Profile.FvDict[Fv].FfsList:
-if FfsFile.InfFileName and FfsFile.NameGuid is None:
-#
-# Get INF file GUID
-#
-InfFoundFlag = False
-for Pa in self.AutoGenObjectList:
-if InfFoundFlag:
-break
-for Module in Pa.ModuleAutoGenList:
-if path.normpath(Module.MetaFile.File) == 
path.normpath(FfsFile.InfFileName):
-InfFoundFlag = True
-if Module.Guid.upper() not in _GuidDict:
-_GuidDict[Module.Guid.upper()] = FfsFile
-break
-else:
-EdkLogger.error("build",
-FORMAT_INVALID,
-"Duplicate GUID found for 
these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,
-   
FfsFile.CurrentLineContent,
-   

_GuidDict[Module.Guid.upper()].CurrentLineNum,
-   

_GuidDict[Module.Guid.upper()].CurrentLineContent,
-   
Module.Guid.upper()),
-ExtraData=self.FdfFile)
-#
-# Some INF files not have entity in DSC file.
-#
-if not InfFoundFlag:
-if FfsFile.InfFileName.find('$') == -1:
-InfPath = NormPath(FfsFile.InfFileName)
-if not os.path.exists(InfPath):
-EdkLogger.error('build', GENFDS_ERROR, 
"Non-existant Module %s !" % (FfsFile.InfFileName))
-
-PathClassObj = PathClass(FfsFile.InfFileName, 
self.WorkspaceDir)
-#
-# Here we just need to get FILE_GUID from INF 
file, use 'COMMON' as ARCH attribute. and use
-# BuildObject from one of AutoGenObjectList is 
enough.
-#
-InfObj = 
self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, 
TAB_ARCH_COMMON, self.BuildTarget, self.ToolChain]
-if InfObj.Guid.upper() not in _GuidDict:
-_GuidDict[InfObj.Guid.upper()] = FfsFile
-else:
-EdkLogger.error("build",
-FORMAT_INVALID,
-"Duplicate GUID found for 
these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,
-   

Re: [edk2] [PATCH v1] SecurityPkg: Fix assert when setting key from FAT formatted eMMC/SD/USB

2018-07-09 Thread Roman Bacik
Laszlo,

Thank you very much for your comments. I will address them and post another
patch.
Regards,

Roman

On Mon, Jul 9, 2018 at 5:24 PM, Laszlo Ersek  wrote:

> On 07/10/18 02:02, Laszlo Ersek wrote:
> > On 07/10/18 00:11, Roman Bacik wrote:
>
> >> +PathName = AllocateZeroPool (PathLength);
> >> +CopyMem (PathName, ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,
> >> PathLength);
> >
> > (3) I think it's not necessary to zero-fill the buffer, we're going to
> > overwrite it right after the allocation.
> >
> > There's a convenience function for that: AllocateCopyPool().
> >
> > (4) The number of bytes is not correct IMO. "PathLength" stands for the
> > number of bytes in the entire device path node (FILEPATH_DEVICE_PATH),
> > including Header and PathName. So, for getting the number of bytes in
> > just PathName, we should subtract the size of Header.
> >
> > Presently, we over-read the source buffer; it's not causing problems
> > because PathName is NUL-terminated.
>
> Sorry, I was unclear; I meant there were no *observable* problems. The
> over-read of the source buffer results in garbage at the end of the
> target buffer, which are later not consumed due to the terminating NUL
> appearing earlier. Still, we should not over-read the source buffer.
>
> Thanks
> Laszlo
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1] SecurityPkg: Fix assert when setting key from FAT formatted eMMC/SD/USB

2018-07-09 Thread Laszlo Ersek
On 07/10/18 02:02, Laszlo Ersek wrote:
> On 07/10/18 00:11, Roman Bacik wrote:

>> +PathName = AllocateZeroPool (PathLength);
>> +CopyMem (PathName, ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,
>> PathLength);
> 
> (3) I think it's not necessary to zero-fill the buffer, we're going to
> overwrite it right after the allocation.
> 
> There's a convenience function for that: AllocateCopyPool().
> 
> (4) The number of bytes is not correct IMO. "PathLength" stands for the
> number of bytes in the entire device path node (FILEPATH_DEVICE_PATH),
> including Header and PathName. So, for getting the number of bytes in
> just PathName, we should subtract the size of Header.
> 
> Presently, we over-read the source buffer; it's not causing problems
> because PathName is NUL-terminated.

Sorry, I was unclear; I meant there were no *observable* problems. The
over-read of the source buffer results in garbage at the end of the
target buffer, which are later not consumed due to the terminating NUL
appearing earlier. Still, we should not over-read the source buffer.

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


Re: [edk2] GPT Partitions on RAID Disks

2018-07-09 Thread Robinson, Herbie
I wanted to hold off on responding to this for a while to see if anyone else 
chimed in and because it required quite a bit of thought.  In the end I thought 
I should probably post what I ended up doing in case anyone scans the e-mail 
archives.  [I edited the awful quoting job this employer mandated e-mail client 
does to hopefully make it a little more readable.]

Background:

I have been tasked with implementing UEFI boot in our VOS operating system.  
We've been using GPT partitions for more than 15 years, but only within our own 
OS...  We haven't had to interact with any other software before this.  We have 
a fault tolerant OS; so, all disks are RAID1 (software supported).  We don't 
expose the GPT partitioning to our user interface:  We have just use it as a 
wrapper for boot support to keep BIOS from being confused.  The intent was to 
set it up to boot with either the legacy BIOS or UEFI.  At the time, we only 
had a legacy BIOS to test with; so, we never finished the UEFI boot.

I've reviewed our current implementation and found a few minor things wrong; 
so, I have been working on a utility to fix them.  But the might be some more 
issues.  I have three questions, but relating to RAID 1.

1.   We have historically paired entire disks when we do RAID1, not 
partitions (we have never supported multiple file system partitions on one 
disk, because it didn't make sense from a performance standpoint).  I believe 
the current initialization uses the same DiskGUID in the GPT header for both 
disks.  I'm assuming that is not going to work properly.  Is that correct?
[Andrew Fish] Herbie,

I'm not sure that a unique  DiskGUID is required for RAID1 given the disks are 
mirrors. I think the ask is that each unique GPT (some software has to create 
it) always gets a new GUID/UUID.
[Robinson, Herbie] I ended up deciding that the GPT partitions should be unique 
and that only the contents of our specific partition should be treated as 
mirrored.  The main reasoning behind this was because the UEFI firmware (and 
third party tools) wouldn't treat the GPT partitions as paired and update them 
simultaneously - If anything, the firmware would just be confused by the 
duplicated GUIDs.  Another factor is that the disks could be different sizes.  
Also, one would also be obligated to keep the ESPs in sync.  It would entail a 
lot more work, might not be compatible with other software and wouldn't really 
buy anything useful functionally.

3.   We have learned over the years that one doesn't allocate an entire 
disk for a RAID (because one may have to replace a drive and replacement may 
not come with exactly the same ending LBA).  We are currently leaving off some 
space at the end.  When we do that, we are not putting the backup GPT header at 
the last LBA the devices.  By my reading of the spec, that is a mistake.  I do 
believe the spec allows me to leave a large gap between the LastUsableLBA in 
the backup GPT header with the backup table placed anywhere within that gap.  
Is that correct?
[Andrew Fish] There has been language added over the years to try to help 
people deal with issues like this. The ATA8-ACS language and this section:
"To avoid the need to determine the physical block size and the optimal 
transfer length granularity, software may align GPT partitions at significantly 
larger boundaries. For example, assuming logical block 0 is aligned, it may use 
LBAs that are multiples of 2,048 to align to 1,048,576 byte (1 MiB) boundaries, 
which supports most common physical block sizes and RAID stripe sizes."

I think the "software may align GPT partitions at significantly larger 
boundaries." in the section above grants you a lot of latitude about how you 
layout the disks.
[Robinson, Herbie] I did, in fact leave a large hole between the backup 
partition table and the backup GPT header and at least our bios is happy with 
it.

And again, thanks for the help.


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


Re: [edk2] [PATCH v1] SecurityPkg: Fix assert when setting key from FAT formatted eMMC/SD/USB

2018-07-09 Thread Laszlo Ersek
I'm not officially a reviewer for SecurityPkg, so just some light comments:

(1) Can you send out the patch with git-send-email? Currently it looks
like the patch was pasted into a desktop or web mail client, and that
makes it hard to apply the patch (it's wrapped etc).

On 07/10/18 00:11, Roman Bacik wrote:
> When secure boot is enabled, if one loads keys from a FAT formatted
> eMMC/SD/USB
> when trying to provision PK/KEK/DB keys via the menu, an assert in StrLen()
> occurs.
> This is because the filename starts on odd address, which is not a uint16
> aligned
> boundary: https://bugzilla.tianocore.org/show_bug.cgi?id=1003
> 
> Cc: Chao Zhang 
> Cc: Jiewen Yao 
> Cc: Laszlo Ersek 
> Cc: Vladimir Olovyannikov 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Roman Bacik 
> ---
>  .../SecureBootConfigFileExplorer.c   | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git
> a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
> b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
> index 1b6f88804275..d5338406957c 100644
> ---
> a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
> +++
> b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
> @@ -123,6 +123,8 @@ OpenFileByDevicePath(
>EFI_FILE_PROTOCOL   *Handle1;
>EFI_FILE_PROTOCOL   *Handle2;
>EFI_HANDLE  DeviceHandle;
> +  CHAR16  *PathName;
> +  UINT16  PathLength;
> 
>if ((FilePath == NULL || FileHandle == NULL)) {
>  return EFI_INVALID_PARAMETER;
> @@ -173,6 +175,10 @@ OpenFileByDevicePath(
>  //
>  Handle2  = Handle1;
>  Handle1 = NULL;
> +PathLength = ((FILEPATH_DEVICE_PATH*)*FilePath)->Header.Length[0] |
> + ((FILEPATH_DEVICE_PATH*)*FilePath)->Header.Length[1] << 8;

(2) Can we use DevicePathNodeLength() from
"MdePkg/Include/Library/DevicePathLib.h" here? (For that, we should also
switch PathLength to UINTN.)

This module already depends on the DevicePathLib class.

Apologies that I didn't suggest this in the BZ.

> +PathName = AllocateZeroPool (PathLength);
> +CopyMem (PathName, ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,
> PathLength);

(3) I think it's not necessary to zero-fill the buffer, we're going to
overwrite it right after the allocation.

There's a convenience function for that: AllocateCopyPool().

(4) The number of bytes is not correct IMO. "PathLength" stands for the
number of bytes in the entire device path node (FILEPATH_DEVICE_PATH),
including Header and PathName. So, for getting the number of bytes in
just PathName, we should subtract the size of Header.

Presently, we over-read the source buffer; it's not causing problems
because PathName is NUL-terminated.

(5) Can you please check whether the allocation succeeds?

If it fails (PathName == NULL), we should return EFI_OUT_OF_RESOURCES.
It seems OK to return this error from the loop body.

> 
>  //
>  // Try to test opening an existing file
> @@ -180,7 +186,7 @@ OpenFileByDevicePath(
>  Status = Handle2->Open (
>Handle2,
>,
> -  ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,
> +  PathName,
>OpenMode &~EFI_FILE_MODE_CREATE,
>0
>   );
> @@ -192,7 +198,7 @@ OpenFileByDevicePath(
>Status = Handle2->Open (
>  Handle2,
>  ,
> -((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,
> +PathName,
>  OpenMode,
>  Attributes
> );
> @@ -202,6 +208,8 @@ OpenFileByDevicePath(
>  //
>  Handle2->Close (Handle2);
> 
> +FreePool (PathName);
> +
>  if (EFI_ERROR(Status)) {
>return (Status);
>  }
> 

Right, this logic appears fine to me; no leaks.

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


[edk2] [PATCH v1] SecurityPkg: Fix assert when setting key from FAT formatted eMMC/SD/USB

2018-07-09 Thread Roman Bacik
When secure boot is enabled, if one loads keys from a FAT formatted
eMMC/SD/USB
when trying to provision PK/KEK/DB keys via the menu, an assert in StrLen()
occurs.
This is because the filename starts on odd address, which is not a uint16
aligned
boundary: https://bugzilla.tianocore.org/show_bug.cgi?id=1003

Cc: Chao Zhang 
Cc: Jiewen Yao 
Cc: Laszlo Ersek 
Cc: Vladimir Olovyannikov 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Roman Bacik 
---
 .../SecureBootConfigFileExplorer.c   | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
index 1b6f88804275..d5338406957c 100644
---
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
+++
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
@@ -123,6 +123,8 @@ OpenFileByDevicePath(
   EFI_FILE_PROTOCOL   *Handle1;
   EFI_FILE_PROTOCOL   *Handle2;
   EFI_HANDLE  DeviceHandle;
+  CHAR16  *PathName;
+  UINT16  PathLength;

   if ((FilePath == NULL || FileHandle == NULL)) {
 return EFI_INVALID_PARAMETER;
@@ -173,6 +175,10 @@ OpenFileByDevicePath(
 //
 Handle2  = Handle1;
 Handle1 = NULL;
+PathLength = ((FILEPATH_DEVICE_PATH*)*FilePath)->Header.Length[0] |
+ ((FILEPATH_DEVICE_PATH*)*FilePath)->Header.Length[1] << 8;
+PathName = AllocateZeroPool (PathLength);
+CopyMem (PathName, ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,
PathLength);

 //
 // Try to test opening an existing file
@@ -180,7 +186,7 @@ OpenFileByDevicePath(
 Status = Handle2->Open (
   Handle2,
   ,
-  ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,
+  PathName,
   OpenMode &~EFI_FILE_MODE_CREATE,
   0
  );
@@ -192,7 +198,7 @@ OpenFileByDevicePath(
   Status = Handle2->Open (
 Handle2,
 ,
-((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,
+PathName,
 OpenMode,
 Attributes
);
@@ -202,6 +208,8 @@ OpenFileByDevicePath(
 //
 Handle2->Close (Handle2);

+FreePool (PathName);
+
 if (EFI_ERROR(Status)) {
   return (Status);
 }
-- 
2.17.1
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/1] MdeModulePkg/PciBusDxe: Fix small memory leak in FreePciDevice

2018-07-09 Thread Palmer, Thomas
I can wait, thanks for the heads up

-Original Message-
From: Zeng, Star [mailto:star.z...@intel.com] 
Sent: Friday, July 6, 2018 2:34 AM
To: Palmer, Thomas ; edk2-devel@lists.01.org
Cc: Dong, Eric ; Ni, Ruiyu ; Li, Gary 
(HPS SW) ; Shifflett, Joseph ; Zeng, 
Star 
Subject: RE: [PATCH 1/1] MdeModulePkg/PciBusDxe: Fix small memory leak in 
FreePciDevice

Hi Thomas,

Basically, I agree with this patch as PciIoDevice->BusNumberRanges equals 
Configuration from PciResAlloc->StartBusEnumeration, and according to PI spec 
"Because the size of ACPI resource descriptors is not fixed, 
StartBusEnumeration() is responsible for allocating memory for the buffer 
Configuration".

But I hope Ruiyu can double confirm it.
Since Ruiyu is taking leave for some days, could you wait?



Thanks,
Star
-Original Message-
From: Thomas Palmer [mailto:thomas.pal...@hpe.com] 
Sent: Tuesday, July 3, 2018 11:33 PM
To: edk2-devel@lists.01.org
Cc: Dong, Eric ; Zeng, Star ; Ni, 
Ruiyu ; gar...@hpe.com; joseph.shiffl...@hpe.com; Thomas 
Palmer 
Subject: [PATCH 1/1] MdeModulePkg/PciBusDxe: Fix small memory leak in 
FreePciDevice

When cleaning the PciIoDevice, also free the BusNumberRange

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Thomas Palmer 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index ad7a2337f578..48cf57a24f8f 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -2,6 +2,7 @@
   Supporting functions implementaion for PCI devices management.
 
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+(C) Copyright 2018 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -105,6 +106,10 
@@ FreePciDevice (
 FreePool (PciIoDevice->DevicePath);
   }
 
+  if (PciIoDevice->BusNumberRanges != NULL) {
+FreePool (PciIoDevice->BusNumberRanges);  }
+
   FreePool (PciIoDevice);
 }
 
--
2.7.4

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


Re: [edk2] [PATCH 09/10] StandaloneMmPkg: Add CPU driver suitable for ARM Platforms.

2018-07-09 Thread Achin Gupta
Hi Sughosh,

CIL.

On Tue, Jul 03, 2018 at 03:12:52PM +0530, Supreeth Venkatesh wrote:
> This patch adds a simple CPU driver that exports the
> EFI_MM_CONFIGURATION_PROTOCOL to allow registration of the Standalone
> MM Foundation entry point. It preserves the existing notification
> mechanism for the configuration protocol.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> Cc: Jiewen Yao 
> Cc: Achin Gupta 
> ---
>  .../Drivers/StandaloneMmCpu/AArch64/EventHandle.c  | 208 +++
>  .../StandaloneMmCpu/AArch64/StandaloneMmCpu.c  | 219 
> +
>  .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h  |  64 ++
>  .../StandaloneMmCpu/AArch64/StandaloneMmCpu.inf|  59 ++
>  StandaloneMmPkg/Include/Guid/MpInformation.h   |  41 
>  5 files changed, 591 insertions(+)
>  create mode 100644 
> StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
>  create mode 100644 
> StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c
>  create mode 100644 
> StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
>  create mode 100644 
> StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf
>  create mode 100644 StandaloneMmPkg/Include/Guid/MpInformation.h
> 
> diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c 
> b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
> new file mode 100644
> index 000..5f39216
> --- /dev/null
> +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
> @@ -0,0 +1,208 @@
> +/** @file
> +
> +  Copyright (c) 2016 HP Development Company, L.P.
> +  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD 
> License
> +  which accompanies this distribution.  The full text of the license may be 
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +
> +**/
> +
> +#include 
> +#include 
> +
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include  // for EFI_SYSTEM_CONTEXT
> +
> +#include 
> +#include 
> +
> +#include 
> +
> +#include "StandaloneMmCpu.h"
> +
> +EFI_STATUS
> +EFIAPI
> +MmFoundationEntryRegister(
> +  IN CONST EFI_MM_CONFIGURATION_PROTOCOL  *This,
> +  IN EFI_MM_ENTRY_POINTMmEntryPoint
> +  );
> +
> +//
> +// On ARM platforms every event is expected to have a GUID associated with
> +// it. It will be used by the MM Entry point to find the handler for the
> +// event. It will either be populated in a EFI_MM_COMMUNICATE_HEADER by the
> +// caller of the event (e.g. MM_COMMUNICATE SMC) or by the CPU driver
> +// (e.g. during an asynchronous event). In either case, this context is
> +// maintained in an array which has an entry for each CPU. The pointer to 
> this
> +// array is held in PerCpuGuidedEventContext. Memory is allocated once the
> +// number of CPUs in the system are made known through the
> +// MP_INFORMATION_HOB_DATA.
> +//
> +EFI_MM_COMMUNICATE_HEADER **PerCpuGuidedEventContext = NULL;
> +
> +// Descriptor with whereabouts of memory used for communication with the 
> normal world
> +EFI_MMRAM_DESCRIPTOR  mNsCommBuffer;
> +
> +MP_INFORMATION_HOB_DATA *mMpInformationHobData;
> +
> +EFI_MM_CONFIGURATION_PROTOCOL mMmConfig = {
> +  0,
> +  MmFoundationEntryRegister
> +};
> +
> +static EFI_MM_ENTRY_POINT mMmEntryPoint = NULL;
> +
> +EFI_STATUS
> +PiMmStandloneArmTfCpuDriverEntry (
> +  IN UINTN EventId,
> +  IN UINTN CpuNumber,
> +  IN UINTN NsCommBufferAddr
> +  )
> +{
> +  EFI_MM_COMMUNICATE_HEADER *GuidedEventContext = NULL;
> +  EFI_MM_ENTRY_CONTEXTMmEntryPointContext = {0};
> +  EFI_STATUS  Status;
> +  UINTN   NsCommBufferSize;
> +
> +  DEBUG ((DEBUG_INFO, "Received event - 0x%x on cpu %d\n", EventId, 
> CpuNumber));
> +
> +  Status = EFI_SUCCESS;
> +  //
> +  // ARM TF passes SMC FID of the MM_COMMUNICATE interface as the Event ID 
> upon
> +  // receipt of a synchronous MM request. Use the Event ID to distinguish
> +  // between synchronous and asynchronous events.
> +  //
> +  if (ARM_SMC_ID_MM_COMMUNICATE_AARCH64 != EventId) {
> +DEBUG ((DEBUG_INFO, "UnRecognized Event - 0x%x\n", EventId));
> +return EFI_INVALID_PARAMETER;
> +  } else {

Since the 'if' checks and error condition and returns, there is no need for the
'else'.

> +// Perform parameter validation of NsCommBufferAddr
> +
> +if (NsCommBufferAddr && (NsCommBufferAddr < mNsCommBuffer.PhysicalStart))
> +  return EFI_ACCESS_DENIED;

Had left a comment in the previous version which I did not quite bottom out with
Supreeth. Here goes again!

This check is not enough before 

Re: [edk2] [PATCH 08/10] StandaloneMmPkg: Add an AArch64 specific entry point library.

2018-07-09 Thread Achin Gupta
Hi Sughosh,

Thanks a lot for picking this up. CIL..

On Tue, Jul 03, 2018 at 03:12:39PM +0530, Supreeth Venkatesh wrote:
> The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
> Platforms and is initialised during the SEC phase. ARM Trusted firmware
> in EL3 is responsible for initialising the architectural context for
> S-EL0 and loading the Standalone MM image. The memory allocated to this
> image is marked as RO+X. Heap memory is marked as RW+XN.
> 
> Certain actions have to be completed prior to executing the generic code
> in the Standalone MM Core module. These are:
> 
> 1. Memory permission attributes for each section of the Standalone MM
>Core module need to be changed prior to accessing any RW data.
> 
> 2. A Hob list has to be created with information that allows the MM
>environment to initialise and dispatch drivers.
> 
> Furthermore, this module is responsible for handing over runtime MM
> events to the Standalone MM CPU driver and returning control to ARM
> Trusted Firmware upon event completion. Hence it needs to know the CPU
> driver entry point.
> 
> This patch implements an entry point module that ARM Trusted Firmware
> jumps to in S-EL0. It then performs the above actions before calling the
> Standalone MM Foundation entry point and handling subsequent MM events.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> Cc: Jiewen Yao 
> Cc: Achin Gupta 
> ---
>  .../Library/AArch64/StandaloneMmCoreEntryPoint.h   | 214 +++
>  .../AArch64/CreateHobList.c| 200 ++
>  .../AArch64/SetPermissions.c   | 275 
>  .../AArch64/StandaloneMmCoreEntryPoint.c   | 287 
> +
>  .../StandaloneMmCoreEntryPoint.inf |  55 
>  5 files changed, 1031 insertions(+)
>  create mode 100644 
> StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
>  create mode 100644 
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c
>  create mode 100644 
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c
>  create mode 100644 
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
>  create mode 100644 
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> 
> diff --git 
> a/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h 
> b/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
> new file mode 100644
> index 000..6eb74af
> --- /dev/null
> +++ b/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
> @@ -0,0 +1,214 @@
> +/** @file
> +  Entry point to the Standalone MM Foundation when initialized during the SEC
> +  phase on ARM platforms
> +
> +Copyright (c) 2017 - 2018, ARM Ltd. All rights reserved.
> +This program and the accompanying materials
> +are licensed and made available under the terms and conditions of the BSD 
> License
> +which accompanies this distribution.  The full text of the license may be 
> found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __STANDALONEMMCORE_ENTRY_POINT_H__
> +#define __STANDALONEMMCORE_ENTRY_POINT_H__
> +
> +#include 
> +#include 
> +
> +#define CPU_INFO_FLAG_PRIMARY_CPU  0x0001
> +
> +typedef struct {
> +  UINT8  Type;   /* type of the structure */
> +  UINT8  Version;/* version of this structure */
> +  UINT16 Size;  /* size of this structure in bytes */
> +  UINT32 Attr;  /* attributes: unused bits SBZ */
> +} EFI_PARAM_HEADER;
> +
> +typedef struct {
> +  UINT64 Mpidr;
> +  UINT32 LinearId;
> +  UINT32 Flags;
> +} EFI_SECURE_PARTITION_CPU_INFO;
> +
> +typedef struct {
> +  EFI_PARAM_HEADER  Header;
> +  UINT64SpMemBase;
> +  UINT64SpMemLimit;
> +  UINT64SpImageBase;
> +  UINT64SpStackBase;
> +  UINT64SpHeapBase;
> +  UINT64SpNsCommBufBase;
> +  UINT64SpSharedBufBase;
> +  UINT64SpImageSize;
> +  UINT64SpPcpuStackSize;
> +  UINT64SpHeapSize;
> +  UINT64SpNsCommBufSize;
> +  UINT64SpPcpuSharedBufSize;
> +  UINT32NumSpMemRegions;
> +  UINT32NumCpus;
> +  EFI_SECURE_PARTITION_CPU_INFO *CpuInfo;
> +} EFI_SECURE_PARTITION_BOOT_INFO;
> +
> +typedef
> +EFI_STATUS
> +(*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) (
> +  IN UINTN EventId,
> +  IN UINTN CpuNumber,
> +  IN UINTN NsCommBufferAddr
> +  );
> +
> +typedef struct {
> +  

[edk2] [PATCH v4] BaseTools/GenFw: Add X64 GOTPCREL Support to GenFw

2018-07-09 Thread Zenith432


Adds support for the following X64 ELF relocations to GenFw
  R_X86_64_GOTPCREL
  R_X86_64_GOTPCRELX
  R_X86_64_REX_GOTPCRELX

Background:
The GCC49 and GCC5 toolchains use the small pie model for X64.  In the
small pie model, gcc emits a GOTPCREL relocation whenever C code takes
the address of a global function.  The emission of GOTPCREL is mitigated
by several factors
1. In GCC49, all global symbols are declared hidden thereby eliminating
the emission of GOTPCREL.
2. In GCC5, LTO is used.  In LTO, the complier first creates intermediate
representation (IR) files.  During the static link stage, the LTO compiler
combines all IR files as a single compilation unit, using linker symbol
assistance to generate code.  Any global symbols defined in the IR that
are not referenced from outside the IR are converted to local symbols -
thereby eliminating the emission of GOTPCREL for them.
3. The linker (binutils ld) further transforms any GOTPCREL used with
the movq opcode to a direct rip-relative relocation used with the leaq
opcode.  This linker optimization can be disabled with the option
-Wl,--no-relax.  Furthermore, gcc is able to emit GOTPCREL with other
opcodes
  - pushq opcode for passing arguments to functions.
  - addq/subq opcodes for pointer arithmetic.
These other opcode uses are not transformed by the linker.
Ultimately, in GCC5 there are some emissions of GOTPCREL that survive
all these mitigations - if C code takes the address of a global function
defined in assembly code - and performs pointer arithmetic on the
address - then the GOTPCREL remains in the final linker product.
A GOTPCREL relocation today causes the build to stop since GenFw does
not handle them.  It is possible to eliminate any remaining GOTPCREL
emissions by manually declaring the global symbols causing them to have
hidden visibility.  This patch is offered instead to allow GenFw to
handle any residual GOTPCREL.

Cc: Shi Steven 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 
---
 BaseTools/Source/C/GenFw/Elf64Convert.c | 203 +++-
 BaseTools/Source/C/GenFw/elf_common.h   |  17 ++
 2 files changed, 219 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c 
b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 4636cfee..90351125 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -94,6 +94,15 @@ STATIC Elf_Ehdr *mEhdr;
 STATIC Elf_Shdr *mShdrBase;
 STATIC Elf_Phdr *mPhdrBase;
 
+//
+// GOT information
+//
+STATIC Elf_Shdr *mGOTShdr = NULL;
+STATIC UINT32   mGOTShindex = 0;
+STATIC UINT32   *mGOTCoffEntries = NULL;
+STATIC UINT32   mGOTMaxCoffEntries = 0;
+STATIC UINT32   mGOTNumCoffEntries = 0;
+
 //
 // Coff information
 //
@@ -322,6 +331,134 @@ GetSymName (
   return StrtabContents + Sym->st_name;
 }
 
+//
+// Find the ELF section hosting the GOT from an ELF Rva
+//   of a single GOT entry.  Normally, GOT is placed in
+//   ELF .text section, so assume once we find in which
+//   section the GOT is, all GOT entries are there, and
+//   just verify this.
+//
+STATIC
+VOID
+FindElfGOTSectionFromGOTEntryElfRva (
+  Elf64_Addr GOTEntryElfRva
+  )
+{
+  UINT32 i;
+  if (mGOTShdr != NULL) {
+if (GOTEntryElfRva >= mGOTShdr->sh_addr &&
+GOTEntryElfRva <  mGOTShdr->sh_addr + mGOTShdr->sh_size) {
+  return;
+}
+Error (NULL, 0, 3000, "Unsupported", "FindElfGOTSectionFromGOTEntryElfRva: 
GOT entries found in multiple sections.");
+exit(EXIT_FAILURE);
+  }
+  for (i = 0; i < mEhdr->e_shnum; i++) {
+Elf_Shdr *shdr = GetShdrByIndex(i);
+if (GOTEntryElfRva >= shdr->sh_addr &&
+GOTEntryElfRva <  shdr->sh_addr + shdr->sh_size) {
+  mGOTShdr = shdr;
+  mGOTShindex = i;
+  return;
+}
+  }
+  Error (NULL, 0, 3000, "Invalid", "FindElfGOTSectionFromGOTEntryElfRva: 
ElfRva 0x%016LX for GOT entry not found in any section.", GOTEntryElfRva);
+  exit(EXIT_FAILURE);
+}
+
+//
+// Stores locations of GOT entries in COFF image.
+//   Returns TRUE if GOT entry is new.
+//   Simple implementation as number of GOT
+//   entries is expected to be low.
+//
+
+STATIC
+BOOLEAN
+AccumulateCoffGOTEntries (
+  UINT32 GOTCoffEntry
+  )
+{
+  UINT32 i;
+  if (mGOTCoffEntries != NULL) {
+for (i = 0; i < mGOTNumCoffEntries; i++) {
+  if (mGOTCoffEntries[i] == GOTCoffEntry) {
+return FALSE;
+  }
+}
+  }
+  if (mGOTCoffEntries == NULL) {
+mGOTCoffEntries = (UINT32*)malloc(5 * sizeof *mGOTCoffEntries);
+if (mGOTCoffEntries == NULL) {
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+}
+assert (mGOTCoffEntries != NULL);
+mGOTMaxCoffEntries = 5;
+mGOTNumCoffEntries = 0;
+  } else if (mGOTNumCoffEntries == mGOTMaxCoffEntries) {
+mGOTCoffEntries = (UINT32*)realloc(mGOTCoffEntries, 2 * mGOTMaxCoffEntries 
* sizeof *mGOTCoffEntries);
+if (mGOTCoffEntries == NULL) {
+  Error (NULL, 0, 

[edk2] [Patch] BaseTools: Fix the bug that incorrect size info in the Lib autogen

2018-07-09 Thread Yonghong Zhu
The case is a PCD used in one library only, and in DSC component
section the PCD value is override in one of module inf. Then it cause
the bug the PCD size in the Lib autogen use the PCD value in the DSC
PCD section, but not use the override value.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 6d76afd..3908697 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1291,16 +1291,21 @@ class PlatformAutoGen(AutoGen):
 for LibAuto in self.LibraryAutoGenList:
 FixedAtBuildPcds = {}  
 ShareFixedAtBuildPcdsSameValue = {} 
 for Module in LibAuto._ReferenceModules:
 for Pcd in Module.FixedAtBuildPcds + LibAuto.FixedAtBuildPcds:
+DefaultValue = Pcd.DefaultValue
+# Cover the case: DSC component override the Pcd value and 
the Pcd only used in one Lib
+if Pcd in Module.LibraryPcdList:
+Index = Module.LibraryPcdList.index(Pcd)
+DefaultValue = 
Module.LibraryPcdList[Index].DefaultValue
 key = ".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
 if key not in FixedAtBuildPcds:
 ShareFixedAtBuildPcdsSameValue[key] = True
-FixedAtBuildPcds[key] = Pcd.DefaultValue
+FixedAtBuildPcds[key] = DefaultValue
 else:
-if FixedAtBuildPcds[key] != Pcd.DefaultValue:
+if FixedAtBuildPcds[key] != DefaultValue:
 ShareFixedAtBuildPcdsSameValue[key] = False  
 for Pcd in LibAuto.FixedAtBuildPcds:
 key = ".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
 if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in 
self.NonDynamicPcdDict:
 continue
-- 
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 2/6] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2018-07-09 Thread Leif Lindholm
On Mon, Jul 09, 2018 at 02:05:32PM +0530, Sughosh Ganu wrote:
> hi Leif,
> 
> On Tue, Jul 3, 2018 at 7:42 PM, Leif Lindholm  
> wrote:
> > On Tue, Jul 03, 2018 at 03:25:11PM +0530, Supreeth Venkatesh wrote:
> >> PI v1.5 Specification Volume 4 defines Management Mode Core Interface
> >> and defines EFI_MM_COMMUNICATION_PROTOCOL. This protocol provides a
> >> means of communicating between drivers outside of MM and MMI
> >> handlers inside of MM.
> >>
> >> This patch implements the EFI_MM_COMMUNICATION_PROTOCOL DXE runtime
> >> driver for AARCH64 platforms. It uses SMCs allocated from the standard
> >> SMC range defined in DEN0060A_ARM_MM_Interface_Specification.pdf
> >
> > I would prefer the document to be referred to by its official name and
> > its document number:
> > ARM Management Mode Interface Specification (ARM DEN0060A)
> >
> >> to communicate with the standalone MM environment in the secure world.
> >>
> >> This patch also adds the MM Communication driver (.inf) file to
> >> define entry point for this driver and other compile
> >> related information the driver needs.
> >>
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Achin Gupta 
> >> Signed-off-by: Supreeth Venkatesh 
> >
> > Oh, and only one Signed-off-by per patch please.
> > If authorship is to be indicated, ensure that's correct in git before
> > calling format-patch.
> 
> Supreeth has moved onto some other work, hence I will be working on
> the upstreaming of these patches henceforth.

Splendid, welcome aboard.

> Will handle your comments
> on all the patches and send an updated version. Regarding the
> inclusion of a single Signed-off-By, i have a doubt. Work on these
> patches was initially done by Achin, and then Supreeth. I will be
> handling your review comments and posting the updated version. You
> have posted a comment saying that we can have only a single s-o-b in
> any given patch. In such a scenario, how can we attribute the work
> done by all the engineers for these patches. Can you please let me
> know on this. As per my understanding, other projects do allow
> multiple s-o-b's per patch. Thanks.

We do permit multiple s-o-b.
When multiple developers are working together in public, adding
non-trivial bits to a patch in flight, you can add multiple s-o-b.

What is not appropriate is to post a patch containing company-internal
details about who handled the patch before it was sent public.
The signed-off-by is a statement regarding the suitability of the
contribution - it is not attribution.
The Author field is the only attribution.

Regards,

Leif

p.s.
I presume you're taking the set over because you work for ARM - so
please communicate with the mailing list from your @arm.com account.

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


[edk2] [PATCH] BaseTools/GenFw: Disable support for R_X86_64_32S

2018-07-09 Thread Zenith432


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

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 
---
 BaseTools/Source/C/GenFw/Elf64Convert.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c 
b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 4636cfee..a4feaf7c 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -993,7 +993,30 @@ WriteRelocations64 (
 + (Rel->r_offset - SecShdr->sh_addr)),
 EFI_IMAGE_REL_BASED_DIR64);
   break;
+#if 0
+//
+// R_X86_64_32 and R_X86_64_32S are ELF64 relocations emitted when 
using
+//   the SYSV X64 ABI small non-position-independent code model.
+//   R_X86_64_32 is used for unsigned 32-bit immediates with a 
32-bit operand
+//   size.  The value is either not extended, or zero-extended to 
64 bits.
+//   R_X86_64_32S is used for either signed 32-bit 
non-rip-relative displacements
+//   or signed 32-bit immediates with a 64-bit operand size.  The 
value is
+//   sign-extended to 64 bits.
+//   EFI_IMAGE_REL_BASED_HIGHLOW is a PE relocation that uses 
32-bit arithmetic
+//   for rebasing an image.
+//   EFI PE binaries declare themselves 
EFI_IMAGE_FILE_LARGE_ADDRESS_AWARE and
+//   may load above 2GB.  If an EFI PE binary with a converted 
R_X86_64_32S
+//   relocation is loaded above 2GB, the value will get 
sign-extended to the
+//   negative part of the 64-bit address space.  The negative part 
of the 64-bit
+//   address space is unmapped, so accessing such an address 
page-faults.
+//   In order to support R_X86_64_32S, it is necessary to unset
+//   EFI_IMAGE_FILE_LARGE_ADDRESS_AWARE, and the EFI PE loader 
must implement
+//   this flag and abstain from loading such a PE binary above 2GB.
+//   Since this feature is not supported, support for R_X86_64_32S 
(and hence
+//   the small non-position-independent code model) is disabled.
+//
 case R_X86_64_32S:
+#endif
 case R_X86_64_32:
   VerboseMsg ("EFI_IMAGE_REL_BASED_HIGHLOW Offset: 0x%08X",
 mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - 
SecShdr->sh_addr));
-- 
2.17.1

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


Re: [edk2] 答复: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number performance.

2018-07-09 Thread Laszlo Ersek
On 07/09/18 08:13, Dong, Eric wrote:
> Hi Laszlo,
> 
> I have created https://bugzilla.tianocore.org/show_bug.cgi?id=1002 to request 
> to add AsmReadEsp() / AsmReadRsp().

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


Re: [edk2] 答复: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number performance.

2018-07-09 Thread Laszlo Ersek
On 07/09/18 05:04, Dong, Eric wrote:
> Hi Laszlo,
> 
>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Thursday, July 5, 2018 9:04 PM
>> To: Fan Jeff ; Dong, Eric ;
>> edk2-devel@lists.01.org
>> Cc: Ni, Ruiyu 
>> Subject: Re: [edk2] 答复: [Patch] UefiCpuPkg/MpInitLib: Optimize get
>> processor number performance.
>>
>> Hi Jeff,
>>
>> On 07/04/18 11:39, Fan Jeff wrote:
>>> Eric,
>>>
>>> Current implementation does not call GetApicid() many times,  Please
>> correct you commit message. Your fix is to improve the performance against
>> the current implementation.
>>
>> I think the original commit message does make sense. Without the patch,
>> GetProcessorNumber() may call GetApicId() up to TotalProcessorNumber
>> times. With the patch, even if we skip the stack range search,
>> GetProcessorNumber() will call GetApicId() just once.
>>
>> [...]
>>
>> Some more questions below, for the patch:
>>
>>> 发件人: Eric Dong 
>>> 发送时间: Wednesday, July 4, 2018 4:37:36 PM
>>> 收件人: edk2-devel@lists.01.org
>>> 抄送: Ruiyu Ni; Jeff Fan; Laszlo Ersek
>>> 主题: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number
>> performance.
>>>
>>> Current function has low performance because it calls GetApicId many
>>> times.
>>>
>>> New logic first try to base on the stack range used by AP to find the
>>> processor number. If this solution failed, then call GetApicId once
>>> and base on this value to search the processor.
>>>
>>> Cc: Ruiyu Ni 
>>> Cc: Jeff Fan 
>>> Cc: Laszlo Ersek 
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Eric Dong 
>>> ---
>>>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 25 ++---
>>>  1 file changed, 22 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
>>> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
>>> index eb2765910c..abd65bee1a 100644
>>> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
>>> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
>>> @@ -418,7 +418,8 @@ ApInitializeSync (  }
>>>
>>>  /**
>>> -  Find the current Processor number by APIC ID.
>>> +  First try to find the current Processor number by stack address,
>>> + if it failed, then base on APIC ID.
>>>
>>>@param[in]  CpuMpData Pointer to PEI CPU MP Data
>>>@param[out] ProcessorNumber   Return the pocessor number found
>>> @@ -435,16 +436,34 @@ GetProcessorNumber (
>>>UINTN   TotalProcessorNumber;
>>>UINTN   Index;
>>>CPU_INFO_IN_HOB *CpuInfoInHob;
>>> +  UINT32  CurrentApicId;
>>>
>>> +  TotalProcessorNumber = CpuMpData->CpuCount;
>>>CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData-
>>> CpuInfoInHob;
>>>
>>> -  TotalProcessorNumber = CpuMpData->CpuCount;
>>> +  //
>>> +  // First try to base on current stack address to find the AP index.
>>> +  //  value located in the stack range.
>>> +  //
>>>for (Index = 0; Index < TotalProcessorNumber; Index ++) {
>>> -if (CpuInfoInHob[Index].ApicId == GetApicId ()) {
>>> +if ((CpuInfoInHob[Index].ApTopOfStack > (UINTN)
>> ()) &&
>>> +(CpuInfoInHob[Index].ApTopOfStack - CpuMpData->CpuApStackSize
>>> + < (UINTN) ())) {
>>>*ProcessorNumber = Index;
>>>return EFI_SUCCESS;
>>>  }
>>>}
>>
>> (1) If I understand correctly, ApTopOfStack is the exclusive end (highest
>> address) of the AP stack, so any local variable is supposed to start strictly
>> below it (the stack grows down). This seems to justify the ">" relational
>> operator, in the first subcondition; OK.
>>
>> However, what guarantees that the TotalProcessorNumber local variable is
>> not located exactly at the (inclusive) base of the AP stack? IOW, why is "<"
>> correct, in the second subcondition, rather than "<="?
>>
> 
> [Eric]  TotalProcessorNumber is the first local variable in this function, 
> also exist other local variables in this function, so I just use "<" here.

Unfortunately, this argument does not work in GCC builds. The ISO C
standard does not say anything about the addresses of local variables,
and indeed GCC occasionally rearranges local variables between each other.

Please see commit f98f5ec304ec ("UefiCpuPkg: S3Resume2Pei: align return
stacks explicitly", 2013-12-13) as an example.

>> (2) I'm generally unhappy about taking the address of local variables, in 
>> order
>> to determine stack location in C language. Instead, I think we should have
>> AsmReadEsp() / AsmReadRsp() functions -- we used to have
>> AsmReadSp() for Itanium. Please see the following sub-thread, where Jordan
>> originally suggested AsmReadEsp() / AsmReadRsp():
>>
>> http://mid.mail-
>> archive.com/151056410867.15809.659701894226687543@jljusten-skl
>>
>> http://mid.mail-
>> archive.com/151059627258.20614.16505766191415005802@jljusten-skl
>>
>> Should I file a Feature Request for BaseLib, about adding AsmReadEsp() /
>> AsmReadRsp()?
>>
>> I'm not suggesting that we block this patch with that feature request, but
>> perhaps we 

Re: [edk2] [PATCH 2/6] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2018-07-09 Thread Sughosh Ganu
hi Leif,

On Tue, Jul 3, 2018 at 7:42 PM, Leif Lindholm  wrote:
> On Tue, Jul 03, 2018 at 03:25:11PM +0530, Supreeth Venkatesh wrote:
>> PI v1.5 Specification Volume 4 defines Management Mode Core Interface
>> and defines EFI_MM_COMMUNICATION_PROTOCOL. This protocol provides a
>> means of communicating between drivers outside of MM and MMI
>> handlers inside of MM.
>>
>> This patch implements the EFI_MM_COMMUNICATION_PROTOCOL DXE runtime
>> driver for AARCH64 platforms. It uses SMCs allocated from the standard
>> SMC range defined in DEN0060A_ARM_MM_Interface_Specification.pdf
>
> I would prefer the document to be referred to by its official name and
> its document number:
> ARM Management Mode Interface Specification (ARM DEN0060A)
>
>> to communicate with the standalone MM environment in the secure world.
>>
>> This patch also adds the MM Communication driver (.inf) file to
>> define entry point for this driver and other compile
>> related information the driver needs.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Achin Gupta 
>> Signed-off-by: Supreeth Venkatesh 
>
> Oh, and only one Signed-off-by per patch please.
> If authorship is to be indicated, ensure that's correct in git before
> calling format-patch.

Supreeth has moved onto some other work, hence I will be working on
the upstreaming of these patches henceforth. Will handle your comments
on all the patches and send an updated version. Regarding the
inclusion of a single Signed-off-By, i have a doubt. Work on these
patches was initially done by Achin, and then Supreeth. I will be
handling your review comments and posting the updated version. You
have posted a comment saying that we can have only a single s-o-b in
any given patch. In such a scenario, how can we attribute the work
done by all the engineers for these patches. Can you please let me
know on this. As per my understanding, other projects do allow
multiple s-o-b's per patch. Thanks.

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


Re: [edk2] question about uefi shell pipe.

2018-07-09 Thread Gao, Liming
Krishna:
 Sorry, I am not clear what's your question here? Would you like to share this 
grep.efi tool? Or you meet with the problem in this grep.efi tool?

Thanks
Liming
>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>krishnaLee
>Sent: Friday, July 06, 2018 11:35 AM
>To: krishnaLee 
>Cc: edk2-devel@lists.01.org
>Subject: Re: [edk2] question about uefi shell pipe.
>
>
>
>Hi,All:
>may be I should reply this to EDK2 group,I had attached my file again.
>
>
>After many test,my right key of "ls | grep -trim-last 0 | grep -trim-last 0" 
>is:
>  1,before pipe out the buffer,trim off all in-visible wchars at end of this 
> buffer,
>(the trimed of wchar  is "like ASCII's range of" 0x~0x0020. )
>  2,always make sure outputBuffer[lastTwoWchar] = { 0x000A,0x000D },it will
>also bypass many other strange result.
>
>
>thank you,
>by krishna.
>
>
>
>
>
>At 2018-07-06 11:07:05, "krishnaLee"  wrote:
>
>Jim,
>I attached the smalltest.efi if you have not compiled the test code.
>
>
>I am in developing of  this grep.efi tool,I can now bypass the test-1 question
>by follow command:
>ls | grep -trim-last 0
>ls | grep -trim-last 0 | grep -trim-last 0
>
>
>I also attached this grep.efi  tool, it almost ok :)
>
>
>//draft usage guide-
>
>
>//if find ok,returncode 1,Print(string);else returncode 0;
>grep.efi -find string
>
>
>//get first word,
>//the front and the end in-visible chars of this word will be trimed off;
>grep.efi -first
>
>
>//get back part after the string.
>
>grep.efi -begin-at string
>
>
>//get front part before the string
>grep.efi -end-at string
>
>
>//trim off first n chars at front
>//before start -trim-first,the front in-visible chars will be trimed off;
>grep.efi -trim-first n
>
>
>//trim off back n chars at end,
>//before start -trim-last,the end in-visible chars will be trimed off;
>grep.efi -trim-last n
>
>
>//trim off whitespace at front and end,
>//trim off in-visible chars infact;
>grep.efi -trim-space
>
>
>
>
>thank you,
>by krishna.
>___
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 4/4] UefiCpuPkg: Removing ipf which is no longer supported from edk2.

2018-07-09 Thread Dong, Eric
Reviewed-by: Eric Dong 

> -Original Message-
> From: Chen, Chen A
> Sent: Monday, July 9, 2018 2:04 PM
> To: edk2-devel@lists.01.org
> Cc: Chen, Chen A ; Dong, Eric 
> Subject: [PATCH V2 4/4] UefiCpuPkg: Removing ipf which is no longer
> supported from edk2.
> 
> Merge [Sources.Ia32, Sources.X64] to [Sources] after removing IPF. Also
> change other similar parts in this file.
> 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chen A Chen 
> ---
>  .../Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf   | 6
> +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git
> a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu
> .inf
> b/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu
> .inf
> index f8bf628a66..03ba8a4ad3 100644
> ---
> a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu
> .inf
> +++
> b/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiC
> +++ pu.inf
> @@ -39,7 +39,7 @@
>  #  VALID_ARCHITECTURES   = IA32 X64
>  #
> 
> -[Sources.Ia32, Sources.X64]
> +[Sources]
>X86TimerLib.c
> 
>  [Packages]
> @@ -49,11 +49,11 @@
>  [LibraryClasses]
>BaseLib
> 
> -[LibraryClasses.IA32, LibraryClasses.X64]
> +[LibraryClasses]
>PcdLib
>DebugLib
>LocalApicLib
> 
> -[Pcd.IA32, Pcd.X64]
> +[Pcd]
>gEfiMdePkgTokenSpaceGuid.PcdFSBClock  ## SOMETIMES_CONSUMES
> 
> --
> 2.16.2.windows.1

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


Re: [edk2] 答复: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number performance.

2018-07-09 Thread Dong, Eric
Hi Laszlo,

I have created https://bugzilla.tianocore.org/show_bug.cgi?id=1002 to request 
to add AsmReadEsp() / AsmReadRsp().

Thanks,
Eric

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Dong, Eric
> Sent: Monday, July 9, 2018 11:04 AM
> To: Laszlo Ersek ; Fan Jeff ;
> edk2-devel@lists.01.org
> Cc: Ni, Ruiyu 
> Subject: Re: [edk2] 答复: [Patch] UefiCpuPkg/MpInitLib: Optimize get
> processor number performance.
> 
> Hi Laszlo,
> 
> > -Original Message-
> > From: Laszlo Ersek [mailto:ler...@redhat.com]
> > Sent: Thursday, July 5, 2018 9:04 PM
> > To: Fan Jeff ; Dong, Eric
> > ; edk2-devel@lists.01.org
> > Cc: Ni, Ruiyu 
> > Subject: Re: [edk2] 答复: [Patch] UefiCpuPkg/MpInitLib: Optimize get
> > processor number performance.
> >
> > Hi Jeff,
> >
> > On 07/04/18 11:39, Fan Jeff wrote:
> > > Eric,
> > >
> > > Current implementation does not call GetApicid() many times,  Please
> > correct you commit message. Your fix is to improve the performance
> > against the current implementation.
> >
> > I think the original commit message does make sense. Without the
> > patch,
> > GetProcessorNumber() may call GetApicId() up to TotalProcessorNumber
> > times. With the patch, even if we skip the stack range search,
> > GetProcessorNumber() will call GetApicId() just once.
> >
> > [...]
> >
> > Some more questions below, for the patch:
> >
> > > 发件人: Eric Dong 
> > > 发送时间: Wednesday, July 4, 2018 4:37:36 PM
> > > 收件人: edk2-devel@lists.01.org
> > > 抄送: Ruiyu Ni; Jeff Fan; Laszlo Ersek
> > > 主题: [Patch] UefiCpuPkg/MpInitLib: Optimize get processor number
> > performance.
> > >
> > > Current function has low performance because it calls GetApicId many
> > > times.
> > >
> > > New logic first try to base on the stack range used by AP to find
> > > the processor number. If this solution failed, then call GetApicId
> > > once and base on this value to search the processor.
> > >
> > > Cc: Ruiyu Ni 
> > > Cc: Jeff Fan 
> > > Cc: Laszlo Ersek 
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Eric Dong 
> > > ---
> > >  UefiCpuPkg/Library/MpInitLib/MpLib.c | 25 ++---
> > >  1 file changed, 22 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > > b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > > index eb2765910c..abd65bee1a 100644
> > > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > > @@ -418,7 +418,8 @@ ApInitializeSync (  }
> > >
> > >  /**
> > > -  Find the current Processor number by APIC ID.
> > > +  First try to find the current Processor number by stack address,
> > > + if it failed, then base on APIC ID.
> > >
> > >@param[in]  CpuMpData Pointer to PEI CPU MP Data
> > >@param[out] ProcessorNumber   Return the pocessor number found
> > > @@ -435,16 +436,34 @@ GetProcessorNumber (
> > >UINTN   TotalProcessorNumber;
> > >UINTN   Index;
> > >CPU_INFO_IN_HOB *CpuInfoInHob;
> > > +  UINT32  CurrentApicId;
> > >
> > > +  TotalProcessorNumber = CpuMpData->CpuCount;
> > >CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData-
> > >CpuInfoInHob;
> > >
> > > -  TotalProcessorNumber = CpuMpData->CpuCount;
> > > +  //
> > > +  // First try to base on current stack address to find the AP index.
> > > +  //  value located in the stack range.
> > > +  //
> > >for (Index = 0; Index < TotalProcessorNumber; Index ++) {
> > > -if (CpuInfoInHob[Index].ApicId == GetApicId ()) {
> > > +if ((CpuInfoInHob[Index].ApTopOfStack > (UINTN)
> > ()) &&
> > > +(CpuInfoInHob[Index].ApTopOfStack -
> > > + CpuMpData->CpuApStackSize < (UINTN) ())) {
> > >*ProcessorNumber = Index;
> > >return EFI_SUCCESS;
> > >  }
> > >}
> >
> > (1) If I understand correctly, ApTopOfStack is the exclusive end
> > (highest
> > address) of the AP stack, so any local variable is supposed to start
> > strictly below it (the stack grows down). This seems to justify the
> > ">" relational operator, in the first subcondition; OK.
> >
> > However, what guarantees that the TotalProcessorNumber local variable
> > is not located exactly at the (inclusive) base of the AP stack? IOW, why is 
> > "<"
> > correct, in the second subcondition, rather than "<="?
> >
> 
> [Eric]  TotalProcessorNumber is the first local variable in this function, 
> also
> exist other local variables in this function, so I just use "<" here.
> 
> >
> > (2) I'm generally unhappy about taking the address of local variables,
> > in order to determine stack location in C language. Instead, I think
> > we should have
> > AsmReadEsp() / AsmReadRsp() functions -- we used to have
> > AsmReadSp() for Itanium. Please see the following sub-thread, where
> > Jordan originally suggested AsmReadEsp() / AsmReadRsp():
> >
> > http://mid.mail-
> > 

[edk2] [PATCH V2 4/4] UefiCpuPkg: Removing ipf which is no longer supported from edk2.

2018-07-09 Thread Chen A Chen
Merge [Sources.Ia32, Sources.X64] to [Sources] after removing IPF. Also
change other similar parts in this file.

Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
---
 .../Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf 
b/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf
index f8bf628a66..03ba8a4ad3 100644
--- a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf
+++ b/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf
@@ -39,7 +39,7 @@
 #  VALID_ARCHITECTURES   = IA32 X64
 #
 
-[Sources.Ia32, Sources.X64]
+[Sources]
   X86TimerLib.c
 
 [Packages]
@@ -49,11 +49,11 @@
 [LibraryClasses]
   BaseLib
 
-[LibraryClasses.IA32, LibraryClasses.X64]
+[LibraryClasses]
   PcdLib
   DebugLib
   LocalApicLib
 
-[Pcd.IA32, Pcd.X64]
+[Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock  ## SOMETIMES_CONSUMES
 
-- 
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 1/4] CryptoPkg: Removing ipf which is no longer supported from edk2.

2018-07-09 Thread Chen A Chen
Removing rules for Ipf sources file:
* Remove the source file which path with "ipf" and also listed in
  [Sources.IPF] section of INF file.
* Remove the source file which listed in [Components.IPF] section
  of DSC file and not listed in any other [Components] section.
* Remove the embedded Ipf code for MDE_CPU_IPF.

Removing rules for Inf file:
* Remove IPF from VALID_ARCHITECTURES comments.
* Remove DXE_SAL_DRIVER from LIBRARY_CLASS in [Defines] section.
* Remove the INF which only listed in [Components.IPF] section in DSC.
* Remove statements from [BuildOptions] that provide IPF specific flags.
* Remove any IPF sepcific sections.

Removing rules for Dec file:
* Remove [Includes.IPF] section from Dec.

Removing rules for Dsc file:
* Remove IPF from SUPPORTED_ARCHITECTURES in [Defines] section of DSC.
* Remove any IPF specific sections.
* Remove statements from [BuildOptions] that provide IPF specific flags.

The following rules are specially proposed by package owner:
* Remove whole "CryptRuntimeDxe" folder which was designed for IPF.
* Remove whole "Include/Protocol" folder
* Update .Dec and .Dsc file accordingly.

Cc: Qin Long 
Cc: Ting Ye 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
---
 CryptoPkg/CryptRuntimeDxe/CryptRuntime.c   | 248 
 CryptoPkg/CryptRuntimeDxe/CryptRuntime.h   | 186 -
 CryptoPkg/CryptRuntimeDxe/CryptRuntimeDxe.inf  |  54 ---
 CryptoPkg/CryptRuntimeDxe/CryptRuntimeDxe.uni  |  22 --
 CryptoPkg/CryptRuntimeDxe/CryptRuntimeDxeExtra.uni |  20 -
 CryptoPkg/CryptoPkg.dec|   4 -
 CryptoPkg/CryptoPkg.dsc|  10 +-
 CryptoPkg/Include/Protocol/RuntimeCrypt.h  | 204 --
 CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf|   7 +-
 CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf |   5 +-
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf |   3 -
 .../BaseCryptLibRuntimeCryptProtocol.inf   |  76 
 .../BaseCryptLibRuntimeCryptProtocol.uni   |  29 --
 .../Cipher/CryptAesNull.c  | 165 
 .../Cipher/CryptArc4Null.c | 130 ---
 .../Cipher/CryptTdesNull.c | 166 
 .../Hash/CryptMd4Null.c| 124 --
 .../Hash/CryptMd5Null.c| 125 --
 .../Hash/CryptSha1Null.c   | 125 --
 .../Hmac/CryptHmacMd5Null.c| 127 ---
 .../Hmac/CryptHmacSha1Null.c   | 127 ---
 .../InternalCryptLib.h |  23 --
 .../Pem/CryptPemNull.c |  44 ---
 .../Pk/CryptAuthenticodeNull.c |  51 ---
 .../Pk/CryptDhNull.c   | 156 
 .../Pk/CryptPkcs7SignNull.c|  59 ---
 .../Pk/CryptPkcs7VerifyNull.c  | 163 
 .../Pk/CryptRsaExtNull.c   | 125 --
 .../Pk/CryptX509Null.c | 238 
 .../Rand/CryptRandNull.c   |  63 
 .../RuntimeDxeIpfCryptLib.c| 419 -
 CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf|  15 +-
 CryptoPkg/Library/OpensslLib/OpensslLib.inf|   7 +-
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf  |   7 +-
 CryptoPkg/Library/TlsLib/TlsLib.inf|   4 +-
 35 files changed, 12 insertions(+), 3319 deletions(-)
 delete mode 100644 CryptoPkg/CryptRuntimeDxe/CryptRuntime.c
 delete mode 100644 CryptoPkg/CryptRuntimeDxe/CryptRuntime.h
 delete mode 100644 CryptoPkg/CryptRuntimeDxe/CryptRuntimeDxe.inf
 delete mode 100644 CryptoPkg/CryptRuntimeDxe/CryptRuntimeDxe.uni
 delete mode 100644 CryptoPkg/CryptRuntimeDxe/CryptRuntimeDxeExtra.uni
 delete mode 100644 CryptoPkg/Include/Protocol/RuntimeCrypt.h
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/BaseCryptLibRuntimeCryptProtocol.inf
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/BaseCryptLibRuntimeCryptProtocol.uni
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptAesNull.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptArc4Null.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptTdesNull.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptMd4Null.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptMd5Null.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptSha1Null.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hmac/CryptHmacMd5Null.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hmac/CryptHmacSha1Null.c
 delete mode 100644