Re: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-08-24 Thread Matteo Carlini
+Achin

SPD (for OP-TEE and other Trusted-OSes payloads running at S-EL1) and SPM (for 
Secure Partitions at S-EL0) are currently mutually exclusive into Trusted 
Firmware-A codebase.

In other words, you cannot turn them on in parallel and execute both a S-EL1 
Trusted OS AND (one or many) S-EL0 Secure Partitions in the Secure World with 
the current Software Architecture.

Achin and other Arm architects are trying to figure out a way for solving this 
problem without the need for a v8.4 Secure-EL2 Hypervisor, obviously without 
leveraging the isolation benefits of it (see also [1]).

But Ard is right: there could be use-cases to ship UEFI systems with OP-TEE and 
TAs on top...and this should still be currently possible using the SPD 
dispatcher into TF-A. I've not looked deeply into this patch, but it doesn’t 
seem to contradict the above Sw architecture.

The question would be: would you foresee the need for running one (or many) 
other (UEFI/EDK2-based) Secure Services in the Secure World into a Secure 
Partition (using the StandaloneMmPkg) *together* with OP-TEE?

Thanks
Matteo

[1]: 
https://community.arm.com/processors/b/blog/posts/architecting-more-secure-world-with-isolation-and-virtualization

> -Original Message-
> From: Udit Kumar 
> Sent: 24 August 2018 18:46
> To: Ard Biesheuvel ; Matteo Carlini
> 
> Cc: Sumit Garg ; edk2-devel@lists.01.org; tee-
> d...@lists.linaro.org; daniel.thomp...@linaro.org; jens.wiklan...@linaro.org;
> Rod Dorris 
> Subject: RE: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate
> with OP-TEE
>
> Hi Ard
>
> > If MM mode is fundamentally incompatible with OP-TEE, then you cannot
> > run both at the same time,
>
> Both cannot coexist unless you have v8.4 CPU
>
> Regards
> Udit
>
> >
> >
> > >> -Original Message-
> > >> From: edk2-devel  On Behalf Of
> > >> Sumit Garg
> > >> Sent: Friday, August 24, 2018 2:51 PM
> > >> To: edk2-devel@lists.01.org
> > >> Cc: daniel.thomp...@linaro.org; tee-...@lists.linaro.org;
> > >> jens.wiklan...@linaro.org
> > >> Subject: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to
> > >> communicate with OP-TEE
> > >>
> > >> Add following APIs to communicate with OP-TEE static TA:
> > >> 1. OpteeInit
> > >> 2. OpteeOpenSession
> > >> 3. OpteeCloseSession
> > >> 4. OpteeInvokeFunc
> > >>
> > >> Cc: Ard Biesheuvel 
> > >> Cc: Leif Lindholm 
> > >> Contributed-under: TianoCore Contribution Agreement 1.1
> > >> Signed-off-by: Sumit Garg 
> > >> ---
> > >>  ArmPkg/Include/Library/OpteeLib.h  | 102 ++
> > >>  ArmPkg/Library/OpteeLib/Optee.c| 358
> > >> +
> > >>  ArmPkg/Library/OpteeLib/OpteeLib.inf   |   2 +
> > >>  ArmPkg/Library/OpteeLib/OpteeSmc.h |  43 +++
> > >>  .../Include/IndustryStandard/GlobalPlatform.h  |  60 ++--
> > >>  5 files changed, 531 insertions(+), 34 deletions(-)  create mode
> > >> 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h
> > >>  copy ArmPkg/Include/Library/OpteeLib.h =>
> > >> MdePkg/Include/IndustryStandard/GlobalPlatform.h (53%)
> > >>
> > >> diff --git a/ArmPkg/Include/Library/OpteeLib.h
> > >> b/ArmPkg/Include/Library/OpteeLib.h
> > >> index f65d8674d9b8..c323f49072f8 100644
> > >> --- a/ArmPkg/Include/Library/OpteeLib.h
> > >> +++ b/ArmPkg/Include/Library/OpteeLib.h
> > >> @@ -25,10 +25,112 @@
> > >>  #define OPTEE_OS_UID2  0xaf630002
> > >>  #define OPTEE_OS_UID3  0xa5d5c51b
> > >>
> > >> +#define OPTEE_MSG_ATTR_TYPE_NONE0x0
> > >> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INPUT 0x1
> > >> +#define OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT0x2
> > >> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INOUT 0x3
> > >> +#define OPTEE_MSG_ATTR_TYPE_MEM_INPUT   0x9
> > >> +#define OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT  0xa
> > >> +#define OPTEE_MSG_ATTR_TYPE_MEM_INOUT   0xb
> > >> +
> > >> +#define OPTEE_MSG_ATTR_TYPE_MASK0xff
> > >> +
> > >> +typedef struct {
> > >> +  UINT64BufPtr;
> > >> +  UINT64Size;
> > >> +  UINT64ShmRef;
> > >> +} OPTEE_MSG_PARAM_MEM;
> > >> +
> > >> +typedef struct {
> > >> +  UINT64A;
> > >> +  UINT64B;
> > >> +  UINT64C;
> > >> +} OPTEE_MSG_PARAM_VALUE;
> > >> +
> > >> +typedef struct {
> > >> +  UINT64 Attr;
> > >> +  union {
> > >> +OPTEE_MSG_PARAM_MEM  Mem;
> > >> +OPTEE_MSG_PARAM_VALUEValue;
> > >> +  } U;
> > >> +} OPTEE_MSG_PARAM;
> > >> +
> > >> +#define MAX_PARAMS   4
> > >> +
> > >> +typedef struct {
> > >> +UINT32 Cmd;
> > >> +UINT32 Func;
> > >> +UINT32 Session;
> > >> +UINT32 CancelId;
> > >> +UINT32 Pad;
> > >> +UINT32 Ret;
> > >> +UINT32 RetOrigin;
> > >> +UINT32 NumParams;
> > >> +
> > >> +// NumParams tells the actual number of element in Params
> > >> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
> 

Re: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-08-24 Thread Udit Kumar
Hi Ard 
 
> If MM mode is fundamentally incompatible with OP-TEE, then you cannot
> run both at the same time,

Both cannot coexist unless you have v8.4 CPU

Regards
Udit
 
> 
> 
> >> -Original Message-
> >> From: edk2-devel  On Behalf Of Sumit
> >> Garg
> >> Sent: Friday, August 24, 2018 2:51 PM
> >> To: edk2-devel@lists.01.org
> >> Cc: daniel.thomp...@linaro.org; tee-...@lists.linaro.org;
> >> jens.wiklan...@linaro.org
> >> Subject: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate
> >> with OP-TEE
> >>
> >> Add following APIs to communicate with OP-TEE static TA:
> >> 1. OpteeInit
> >> 2. OpteeOpenSession
> >> 3. OpteeCloseSession
> >> 4. OpteeInvokeFunc
> >>
> >> Cc: Ard Biesheuvel 
> >> Cc: Leif Lindholm 
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Sumit Garg 
> >> ---
> >>  ArmPkg/Include/Library/OpteeLib.h  | 102 ++
> >>  ArmPkg/Library/OpteeLib/Optee.c| 358
> >> +
> >>  ArmPkg/Library/OpteeLib/OpteeLib.inf   |   2 +
> >>  ArmPkg/Library/OpteeLib/OpteeSmc.h |  43 +++
> >>  .../Include/IndustryStandard/GlobalPlatform.h  |  60 ++--
> >>  5 files changed, 531 insertions(+), 34 deletions(-)  create mode
> >> 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h
> >>  copy ArmPkg/Include/Library/OpteeLib.h =>
> >> MdePkg/Include/IndustryStandard/GlobalPlatform.h (53%)
> >>
> >> diff --git a/ArmPkg/Include/Library/OpteeLib.h
> >> b/ArmPkg/Include/Library/OpteeLib.h
> >> index f65d8674d9b8..c323f49072f8 100644
> >> --- a/ArmPkg/Include/Library/OpteeLib.h
> >> +++ b/ArmPkg/Include/Library/OpteeLib.h
> >> @@ -25,10 +25,112 @@
> >>  #define OPTEE_OS_UID2  0xaf630002
> >>  #define OPTEE_OS_UID3  0xa5d5c51b
> >>
> >> +#define OPTEE_MSG_ATTR_TYPE_NONE0x0
> >> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INPUT 0x1
> >> +#define OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT0x2
> >> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INOUT 0x3
> >> +#define OPTEE_MSG_ATTR_TYPE_MEM_INPUT   0x9
> >> +#define OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT  0xa
> >> +#define OPTEE_MSG_ATTR_TYPE_MEM_INOUT   0xb
> >> +
> >> +#define OPTEE_MSG_ATTR_TYPE_MASK0xff
> >> +
> >> +typedef struct {
> >> +  UINT64BufPtr;
> >> +  UINT64Size;
> >> +  UINT64ShmRef;
> >> +} OPTEE_MSG_PARAM_MEM;
> >> +
> >> +typedef struct {
> >> +  UINT64A;
> >> +  UINT64B;
> >> +  UINT64C;
> >> +} OPTEE_MSG_PARAM_VALUE;
> >> +
> >> +typedef struct {
> >> +  UINT64 Attr;
> >> +  union {
> >> +OPTEE_MSG_PARAM_MEM  Mem;
> >> +OPTEE_MSG_PARAM_VALUEValue;
> >> +  } U;
> >> +} OPTEE_MSG_PARAM;
> >> +
> >> +#define MAX_PARAMS   4
> >> +
> >> +typedef struct {
> >> +UINT32 Cmd;
> >> +UINT32 Func;
> >> +UINT32 Session;
> >> +UINT32 CancelId;
> >> +UINT32 Pad;
> >> +UINT32 Ret;
> >> +UINT32 RetOrigin;
> >> +UINT32 NumParams;
> >> +
> >> +// NumParams tells the actual number of element in Params
> >> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
> >> +} OPTEE_MSG_ARG;
> >> +
> >> +#define OPTEE_UUID_LEN   16
> >> +
> >> +//
> >> +// struct OPTEE_OPEN_SESSION_ARG - Open session argument
> >> +// @Uuid:   [in] UUID of the Trusted Application
> >> +// @Session:[out] Session id
> >> +// @Ret:[out] Return value
> >> +// @RetOrigin   [out] Origin of the return value
> >> +//
> >> +typedef struct {
> >> +UINT8 Uuid[OPTEE_UUID_LEN];
> >> +UINT32Session;
> >> +UINT32Ret;
> >> +UINT32RetOrigin;
> >> +} OPTEE_OPEN_SESSION_ARG;
> >> +
> >> +//
> >> +// struct OPTEE_INVOKE_FUNC_ARG - Invoke function argument
> >> +// @Func:   [in] Trusted Application function, specific to the TA
> >> +// @Session:[in] Session id
> >> +// @Ret:[out] Return value
> >> +// @RetOrigin   [out] Origin of the return value
> >> +// @Params  [inout] Parameters for function to be invoked
> >> +//
> >> +typedef struct {
> >> +UINT32 Func;
> >> +UINT32 Session;
> >> +UINT32 Ret;
> >> +UINT32 RetOrigin;
> >> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
> >> +} OPTEE_INVOKE_FUNC_ARG;
> >> +
> >>  BOOLEAN
> >>  EFIAPI
> >>  IsOpteePresent (
> >>VOID
> >>);
> >>
> >> +EFI_STATUS
> >> +EFIAPI
> >> +OpteeInit (
> >> +  VOID
> >> +  );
> >> +
> >> +EFI_STATUS
> >> +EFIAPI
> >> +OpteeOpenSession (
> >> +  IN OUT OPTEE_OPEN_SESSION_ARG  *OpenSessionArg
> >> +  );
> >> +
> >> +EFI_STATUS
> >> +EFIAPI
> >> +OpteeCloseSession (
> >> +  IN UINT32  Session
> >> +  );
> >> +
> >> +EFI_STATUS
> >> +EFIAPI
> >> +OpteeInvokeFunc (
> >> +  IN OUT OPTEE_INVOKE_FUNC_ARG   *InvokeFuncArg
> >> +  );
> >> +
> >>  #endif
> >> diff --git 

Re: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-08-24 Thread Ard Biesheuvel
(+ Matteo)

On 24 August 2018 at 17:20, Udit Kumar  wrote:
> Hi Sumit
> What use case you have in mind, to interface op-tee with UEFI.
>
> What ARM proposed (Matteo in cc), to run MM mode in Secure side of machine 
> with SPM.
> Moreover SPD (OP-TEE) and SPM(MM mode) cannot co-exists on current arm 
> devices.
> Then how do you see MM mode working.
>

If MM mode is fundamentally incompatible with OP-TEE, then you cannot
run both at the same time. But that doesn't mean there are no use
cases for shipping a UEFI system with OP-TEE.

I will let Sumit elaborate on the details if you're interested, but he
has working code to use the thermal sensors on SynQuacer (which are
secure world only) to gather entropy and expose it to the OS via the
EFI_RNG_PROTOCOL, which is implemented on top of this OP-TEE client
library.



>> -Original Message-
>> From: edk2-devel  On Behalf Of Sumit
>> Garg
>> Sent: Friday, August 24, 2018 2:51 PM
>> To: edk2-devel@lists.01.org
>> Cc: daniel.thomp...@linaro.org; tee-...@lists.linaro.org;
>> jens.wiklan...@linaro.org
>> Subject: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate
>> with OP-TEE
>>
>> Add following APIs to communicate with OP-TEE static TA:
>> 1. OpteeInit
>> 2. OpteeOpenSession
>> 3. OpteeCloseSession
>> 4. OpteeInvokeFunc
>>
>> Cc: Ard Biesheuvel 
>> Cc: Leif Lindholm 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Sumit Garg 
>> ---
>>  ArmPkg/Include/Library/OpteeLib.h  | 102 ++
>>  ArmPkg/Library/OpteeLib/Optee.c| 358
>> +
>>  ArmPkg/Library/OpteeLib/OpteeLib.inf   |   2 +
>>  ArmPkg/Library/OpteeLib/OpteeSmc.h |  43 +++
>>  .../Include/IndustryStandard/GlobalPlatform.h  |  60 ++--
>>  5 files changed, 531 insertions(+), 34 deletions(-)  create mode 100644
>> ArmPkg/Library/OpteeLib/OpteeSmc.h
>>  copy ArmPkg/Include/Library/OpteeLib.h =>
>> MdePkg/Include/IndustryStandard/GlobalPlatform.h (53%)
>>
>> diff --git a/ArmPkg/Include/Library/OpteeLib.h
>> b/ArmPkg/Include/Library/OpteeLib.h
>> index f65d8674d9b8..c323f49072f8 100644
>> --- a/ArmPkg/Include/Library/OpteeLib.h
>> +++ b/ArmPkg/Include/Library/OpteeLib.h
>> @@ -25,10 +25,112 @@
>>  #define OPTEE_OS_UID2  0xaf630002
>>  #define OPTEE_OS_UID3  0xa5d5c51b
>>
>> +#define OPTEE_MSG_ATTR_TYPE_NONE0x0
>> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INPUT 0x1
>> +#define OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT0x2
>> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INOUT 0x3
>> +#define OPTEE_MSG_ATTR_TYPE_MEM_INPUT   0x9
>> +#define OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT  0xa
>> +#define OPTEE_MSG_ATTR_TYPE_MEM_INOUT   0xb
>> +
>> +#define OPTEE_MSG_ATTR_TYPE_MASK0xff
>> +
>> +typedef struct {
>> +  UINT64BufPtr;
>> +  UINT64Size;
>> +  UINT64ShmRef;
>> +} OPTEE_MSG_PARAM_MEM;
>> +
>> +typedef struct {
>> +  UINT64A;
>> +  UINT64B;
>> +  UINT64C;
>> +} OPTEE_MSG_PARAM_VALUE;
>> +
>> +typedef struct {
>> +  UINT64 Attr;
>> +  union {
>> +OPTEE_MSG_PARAM_MEM  Mem;
>> +OPTEE_MSG_PARAM_VALUEValue;
>> +  } U;
>> +} OPTEE_MSG_PARAM;
>> +
>> +#define MAX_PARAMS   4
>> +
>> +typedef struct {
>> +UINT32 Cmd;
>> +UINT32 Func;
>> +UINT32 Session;
>> +UINT32 CancelId;
>> +UINT32 Pad;
>> +UINT32 Ret;
>> +UINT32 RetOrigin;
>> +UINT32 NumParams;
>> +
>> +// NumParams tells the actual number of element in Params
>> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
>> +} OPTEE_MSG_ARG;
>> +
>> +#define OPTEE_UUID_LEN   16
>> +
>> +//
>> +// struct OPTEE_OPEN_SESSION_ARG - Open session argument
>> +// @Uuid:   [in] UUID of the Trusted Application
>> +// @Session:[out] Session id
>> +// @Ret:[out] Return value
>> +// @RetOrigin   [out] Origin of the return value
>> +//
>> +typedef struct {
>> +UINT8 Uuid[OPTEE_UUID_LEN];
>> +UINT32Session;
>> +UINT32Ret;
>> +UINT32RetOrigin;
>> +} OPTEE_OPEN_SESSION_ARG;
>> +
>> +//
>> +// struct OPTEE_INVOKE_FUNC_ARG - Invoke function argument
>> +// @Func:   [in] Trusted Application function, specific to the TA
>> +// @Session:[in] Session id
>> +// @Ret:[out] Return value
>> +// @RetOrigin   [out] Origin of the return value
>> +// @Params  [inout] Parameters for function to be invoked
>> +//
>> +typedef struct {
>> +UINT32 Func;
>> +UINT32 Session;
>> +UINT32 Ret;
>> +UINT32 RetOrigin;
>> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
>> +} OPTEE_INVOKE_FUNC_ARG;
>> +
>>  BOOLEAN
>>  EFIAPI
>>  IsOpteePresent (
>>VOID
>>);
>>
>> +EFI_STATUS
>> +EFIAPI
>> +OpteeInit (
>> +  VOID
>> +  );
>> +
>> +EFI_STATUS
>> +EFIAPI

[edk2] [PATCH v1 1/1] BaseTools: Create and use a shared value for 'MSFT' from DataType

2018-08-24 Thread Jaben Carsey
I see lots of 'MSFT' throughout code and this can reduce them.

Cc: Bob Feng 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py  |  8 
 BaseTools/Source/Python/AutoGen/BuildEngine.py  |  8 
 BaseTools/Source/Python/AutoGen/GenMake.py  |  3 ++-
 BaseTools/Source/Python/Common/DataType.py  |  2 ++
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py |  2 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py  |  4 ++--
 BaseTools/Source/Python/Workspace/DscBuildData.py   |  4 ++--
 BaseTools/Source/Python/Workspace/InfBuildData.py   | 14 
+++---
 BaseTools/Source/Python/build/build.py  |  2 +-
 9 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index eb1b28388967..cb302189d2a3 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -80,7 +80,7 @@ gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")
 gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
 
 ## Mapping Makefile type
-gMakeTypeMap = {"MSFT":"nmake", "GCC":"gmake"}
+gMakeTypeMap = {TAB_COMPILER_MSFT:"nmake", "GCC":"gmake"}
 
 
 ## Build rule configuration file
@@ -1843,7 +1843,7 @@ class PlatformAutoGen(AutoGen):
or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChain]:
 EdkLogger.verbose("No tool chain family found in configuration 
for %s. Default to MSFT." \
% self.ToolChain)
-self._ToolChainFamily = "MSFT"
+self._ToolChainFamily = TAB_COMPILER_MSFT
 else:
 self._ToolChainFamily = 
ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChain]
 return self._ToolChainFamily
@@ -1856,7 +1856,7 @@ class PlatformAutoGen(AutoGen):
or not 
ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]:
 EdkLogger.verbose("No tool chain family found in configuration 
for %s. Default to MSFT." \
% self.ToolChain)
-self._BuildRuleFamily = "MSFT"
+self._BuildRuleFamily = TAB_COMPILER_MSFT
 else:
 self._BuildRuleFamily = 
ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]
 return self._BuildRuleFamily
@@ -2978,7 +2978,7 @@ class ModuleAutoGen(AutoGen):
 # Regular expression for finding Include Directories, the difference 
between MSFT and INTEL/GCC/RVCT
 # is the former use /I , the Latter used -I to specify include 
directories
 #
-if self.PlatformInfo.ToolChainFamily in ('MSFT'):
+if self.PlatformInfo.ToolChainFamily in (TAB_COMPILER_MSFT):
 BuildOptIncludeRegEx = gBuildOptIncludePatternMsft
 elif self.PlatformInfo.ToolChainFamily in ('INTEL', 'GCC', 'RVCT'):
 BuildOptIncludeRegEx = gBuildOptIncludePatternOther
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py 
b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index 4291da9001b8..ac7a6687552c 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -318,7 +318,7 @@ class BuildRule:
 #   @param  LineIndex   The line number from which the parsing 
will begin
 #   @param  SupportedFamily The list of supported tool chain families
 #
-def __init__(self, File=None, Content=None, LineIndex=0, 
SupportedFamily=["MSFT", "INTEL", "GCC", "RVCT"]):
+def __init__(self, File=None, Content=None, LineIndex=0, 
SupportedFamily=[TAB_COMPILER_MSFT, "INTEL", "GCC", "RVCT"]):
 self.RuleFile = File
 # Read build rules from file if it's not none
 if File is not None:
@@ -596,17 +596,17 @@ if __name__ == '__main__':
 EdkLogger.Initialize()
 if len(sys.argv) > 1:
 Br = BuildRule(sys.argv[1])
-print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1]))
+print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", 
TAB_COMPILER_MSFT][1]))
 print()
 print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1]))
 print()
 print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1]))
 print()
-print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))
+print(str(Br[".ac", "ACPI_TABLE", "IA32", TAB_COMPILER_MSFT][1]))
 print()
 print(str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1]))
 print()
-print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))
+print(str(Br[".ac", "ACPI_TABLE", "IA32", TAB_COMPILER_MSFT][1]))
 print()
 print(str(Br[".s", SUP_MODULE_SEC, "IPF", 

Re: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-08-24 Thread Udit Kumar
Hi Sumit 
What use case you have in mind, to interface op-tee with UEFI. 

What ARM proposed (Matteo in cc), to run MM mode in Secure side of machine with 
SPM. 
Moreover SPD (OP-TEE) and SPM(MM mode) cannot co-exists on current arm devices. 
Then how do you see MM mode working.

Regards
Udit


> -Original Message-
> From: edk2-devel  On Behalf Of Sumit
> Garg
> Sent: Friday, August 24, 2018 2:51 PM
> To: edk2-devel@lists.01.org
> Cc: daniel.thomp...@linaro.org; tee-...@lists.linaro.org;
> jens.wiklan...@linaro.org
> Subject: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate
> with OP-TEE
> 
> Add following APIs to communicate with OP-TEE static TA:
> 1. OpteeInit
> 2. OpteeOpenSession
> 3. OpteeCloseSession
> 4. OpteeInvokeFunc
> 
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sumit Garg 
> ---
>  ArmPkg/Include/Library/OpteeLib.h  | 102 ++
>  ArmPkg/Library/OpteeLib/Optee.c| 358
> +
>  ArmPkg/Library/OpteeLib/OpteeLib.inf   |   2 +
>  ArmPkg/Library/OpteeLib/OpteeSmc.h |  43 +++
>  .../Include/IndustryStandard/GlobalPlatform.h  |  60 ++--
>  5 files changed, 531 insertions(+), 34 deletions(-)  create mode 100644
> ArmPkg/Library/OpteeLib/OpteeSmc.h
>  copy ArmPkg/Include/Library/OpteeLib.h =>
> MdePkg/Include/IndustryStandard/GlobalPlatform.h (53%)
> 
> diff --git a/ArmPkg/Include/Library/OpteeLib.h
> b/ArmPkg/Include/Library/OpteeLib.h
> index f65d8674d9b8..c323f49072f8 100644
> --- a/ArmPkg/Include/Library/OpteeLib.h
> +++ b/ArmPkg/Include/Library/OpteeLib.h
> @@ -25,10 +25,112 @@
>  #define OPTEE_OS_UID2  0xaf630002
>  #define OPTEE_OS_UID3  0xa5d5c51b
> 
> +#define OPTEE_MSG_ATTR_TYPE_NONE0x0
> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INPUT 0x1
> +#define OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT0x2
> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INOUT 0x3
> +#define OPTEE_MSG_ATTR_TYPE_MEM_INPUT   0x9
> +#define OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT  0xa
> +#define OPTEE_MSG_ATTR_TYPE_MEM_INOUT   0xb
> +
> +#define OPTEE_MSG_ATTR_TYPE_MASK0xff
> +
> +typedef struct {
> +  UINT64BufPtr;
> +  UINT64Size;
> +  UINT64ShmRef;
> +} OPTEE_MSG_PARAM_MEM;
> +
> +typedef struct {
> +  UINT64A;
> +  UINT64B;
> +  UINT64C;
> +} OPTEE_MSG_PARAM_VALUE;
> +
> +typedef struct {
> +  UINT64 Attr;
> +  union {
> +OPTEE_MSG_PARAM_MEM  Mem;
> +OPTEE_MSG_PARAM_VALUEValue;
> +  } U;
> +} OPTEE_MSG_PARAM;
> +
> +#define MAX_PARAMS   4
> +
> +typedef struct {
> +UINT32 Cmd;
> +UINT32 Func;
> +UINT32 Session;
> +UINT32 CancelId;
> +UINT32 Pad;
> +UINT32 Ret;
> +UINT32 RetOrigin;
> +UINT32 NumParams;
> +
> +// NumParams tells the actual number of element in Params
> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
> +} OPTEE_MSG_ARG;
> +
> +#define OPTEE_UUID_LEN   16
> +
> +//
> +// struct OPTEE_OPEN_SESSION_ARG - Open session argument
> +// @Uuid:   [in] UUID of the Trusted Application
> +// @Session:[out] Session id
> +// @Ret:[out] Return value
> +// @RetOrigin   [out] Origin of the return value
> +//
> +typedef struct {
> +UINT8 Uuid[OPTEE_UUID_LEN];
> +UINT32Session;
> +UINT32Ret;
> +UINT32RetOrigin;
> +} OPTEE_OPEN_SESSION_ARG;
> +
> +//
> +// struct OPTEE_INVOKE_FUNC_ARG - Invoke function argument
> +// @Func:   [in] Trusted Application function, specific to the TA
> +// @Session:[in] Session id
> +// @Ret:[out] Return value
> +// @RetOrigin   [out] Origin of the return value
> +// @Params  [inout] Parameters for function to be invoked
> +//
> +typedef struct {
> +UINT32 Func;
> +UINT32 Session;
> +UINT32 Ret;
> +UINT32 RetOrigin;
> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
> +} OPTEE_INVOKE_FUNC_ARG;
> +
>  BOOLEAN
>  EFIAPI
>  IsOpteePresent (
>VOID
>);
> 
> +EFI_STATUS
> +EFIAPI
> +OpteeInit (
> +  VOID
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +OpteeOpenSession (
> +  IN OUT OPTEE_OPEN_SESSION_ARG  *OpenSessionArg
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +OpteeCloseSession (
> +  IN UINT32  Session
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +OpteeInvokeFunc (
> +  IN OUT OPTEE_INVOKE_FUNC_ARG   *InvokeFuncArg
> +  );
> +
>  #endif
> diff --git a/ArmPkg/Library/OpteeLib/Optee.c
> b/ArmPkg/Library/OpteeLib/Optee.c index 574527f8b5ea..2111022d3662
> 100644
> --- a/ArmPkg/Library/OpteeLib/Optee.c
> +++ b/ArmPkg/Library/OpteeLib/Optee.c
> @@ -14,11 +14,19 @@
> 
>  **/
> 
> +#include 
>  #include 
> +#include 
>  #include 
> +#include 
>  #include 
> 
>  #include 
> 

Re: [edk2] [PATCH v2 7/7] ArmPkg: Extra action to update permissions for S-ELO MM Image

2018-08-24 Thread Ard Biesheuvel
On 21 August 2018 at 07:50, Sughosh Ganu  wrote:
> hi Ard,
>
> On Tue July 23, 2018 at 11:03PM +0530, Supreeth Venkatesh wrote:
>>
>> On Sat, 2018-07-21 at 20:06 +0900, Ard Biesheuvel wrote:
>> > On 20 July 2018 at 21:38, Sughosh Ganu  wrote:
>> > >
>> > > From: Achin Gupta 
>> > >
>> > > The Standalone MM drivers runs in S-EL0 in AArch64 on ARM Standard
>> > > Platforms and is deployed during SEC phase. The memory allocated to
>> > > the Standalone MM drivers should be marked as RO+X.
>> > >
>> > > During PE/COFF Image section parsing, this patch implements extra
>> > > action "UpdatePeCoffPermissions" to request the privileged firmware
>> > > in
>> > > EL3 to update the permissions.
>> > >
>> > > Contributed-under: TianoCore Contribution Agreement 1.1
>> > > Signed-off-by: Sughosh Ganu 
>> > Apologies for bringing this up only now, but I don't think I was ever
>> > cc'ed on these patches.
>> >
>> Apologies if you have missed it. But I am pretty sure it was part of
>> earlier large patch-set on which you and leif were copied, as it was
>> part of ArmPkg.
>> >
>> > We are relying on a debug hook in the PE/COFF loader to ensure that
>> > we
>> > don't end up with memory that is both writable and executable in the
>> > secure world. Do we really think that is a good idea?
>> >
>> > (I know this code was derived from a proof of concept that I did
>> > years
>> > ago, but that was just a PoC)
>> I think we need a little bit more details on what is your suggestion?
>>
>> A little bit background here: This code runs in S-EL0 and Request gets
>> sent to secure world SPM to ensure that the region permissions are
>> updated correctly via the "ArmMmuStandaloneMmCoreLib" SVC -
>> ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64.
>>
>> DebugPeCoffExtraActionLib is just used to extract image region
>> information, but the region permission
>> update request is sent to secure world for validation.
>>
>> With the above explanation, can you provide an insight into what was
>> your thinking?
>> Do you want us to create a separate library and call it
>> as PeCoffExtraActionLib to avoid the "Debug" word though it is a hook
>> to PeCoffExtraActionLib in MdePkg or do we want to create this library
>> in a separate package (may be in MdePkg?) or something totally
>> different.
>
> Supreeth had replied to your comments on the patch. Can you please
> check this. If you feel that this needs to be implemented differently,
> can you please suggest it to us. Thanks.
>

My point is that such a fundamental action that needs to occur while
loading the PE/COFF image should not be hooked into the loader this
way.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1 1/1] EmbeddedPkg/AndroidFastbootApp: only use ENTER or SPACE to exit

2018-08-24 Thread Ard Biesheuvel
On 23 August 2018 at 07:14, Haojian Zhuang  wrote:
> Since hotkey 'f' is used to start AndroidFastbootApp. If user
> press 'f' key too long, it may be recognized pressing 'f' key
> multiple times. Then AndroidFastbootApp exists since it delcares
> any key press could make it exit.
>
> So only use ENTER or SPACE key to exit AndroidFastbootApp.
>
> Cc: Leif Lindholm 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Haojian Zhuang 

Reviewed-by: Ard Biesheuvel 

Pushed as 6861765935d5b69803321ba6e43240845c7ab0e5

Thanks

> ---
>  EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c | 14 
> --
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c 
> b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
> index c5e8a7e34af2..c1ed94f92b6f 100644
> --- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
> +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
> @@ -426,6 +426,7 @@ FastbootAppEntryPoint (
>EFI_EVENT   WaitEventArray[2];
>UINTN   EventIndex;
>EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
> +  EFI_INPUT_KEY   Key;
>
>mDataBuffer = NULL;
>
> @@ -508,12 +509,21 @@ FastbootAppEntryPoint (
>
>// Talk to the user
>mTextOut->OutputString (mTextOut,
> -  L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press 
> any key to quit.\r\n");
> +  L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press 
> RETURN or SPACE key to quit.\r\n");
>
>// Quit when the user presses any key, or mFinishedEvent is signalled
>WaitEventArray[0] = mFinishedEvent;
>WaitEventArray[1] = TextIn->WaitForKey;
> -  gBS->WaitForEvent (2, WaitEventArray, );
> +  while (1) {
> +gBS->WaitForEvent (2, WaitEventArray, );
> +Status = TextIn->ReadKeyStroke (gST->ConIn, );
> +if (Key.ScanCode == SCAN_NULL) {
> +  if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) ||
> +  (Key.UnicodeChar == L' ')) {
> +break;
> +  }
> +}
> +  }
>
>mTransport->Stop ();
>if (EFI_ERROR (Status)) {
> --
> 2.7.4
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v2 36/43] Platform/Hisilicon/D06: Add capsule upgrade support

2018-08-24 Thread Ard Biesheuvel
On 22 August 2018 at 19:42, Leif Lindholm  wrote:
> On Tue, Aug 14, 2018 at 04:08:56PM +0800, Ming Huang wrote:
>> This module support updating the boot CPU firmware only.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ming Huang 
>
> As I said on v1, I have no further comments on this.
> Reviewed-by: Leif Lindholm 
>
> Ard may have something to add.
>

Reviewed-by: Ard BIesheuvel 

>> ---
>>  Platform/Hisilicon/D06/D06.dsc  
>>  | 14 
>>  Platform/Hisilicon/D06/D06.fdf  
>>  | 72 -
>>  
>> Platform/Hisilicon/D06/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
>>  | 50 
>>  
>> Platform/Hisilicon/D06/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c
>> | 70 +
>>  
>> Platform/Hisilicon/D06/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
>>  | 46 +++
>>  
>> Platform/Hisilicon/D06/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc
>> | 81 
>>  6 files changed, 332 insertions(+), 1 deletion(-)
>>
>> diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc
>> index 9550e0d497..fad6fcc747 100644
>> --- a/Platform/Hisilicon/D06/D06.dsc
>> +++ b/Platform/Hisilicon/D06/D06.dsc
>> @@ -121,6 +121,11 @@
>>gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE
>>gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE
>>gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
>> +[PcdsDynamicExDefault.common.DEFAULT]
>> +  
>> gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100
>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 
>> 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 
>> 0xc5, 0x04, 0x89}
>> +  gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 
>> 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 
>> 0xc5, 0x7b, 0x55}
>> +
>>
>>  [PcdsFixedAtBuild.common]
>>gArmPlatformTokenSpaceGuid.PcdCoreCount|48
>> @@ -266,6 +271,7 @@
>>Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.inf
>>Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf
>>
>> +  
>> Platform/Hisilicon/D06/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
>>MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {
>>  
>>
>> NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
>> @@ -386,6 +392,8 @@
>>MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
>>MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
>>MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
>> +  
>> SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf
>> +  MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
>>#
>># FAT filesystem + GPT/MBR partitioning
>>#
>> @@ -434,6 +442,12 @@
>>MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
>>MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
>>MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
>> +  
>> SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf {
>> +
>> +  
>> FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf
>> +  }
>> +
>> +  MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf
>>
>>#
>># UEFI application (Shell Embedded Boot Loader)
>> diff --git a/Platform/Hisilicon/D06/D06.fdf b/Platform/Hisilicon/D06/D06.fdf
>> index 90379b8558..8c3f4f9932 100644
>> --- a/Platform/Hisilicon/D06/D06.fdf
>> +++ b/Platform/Hisilicon/D06/D06.fdf
>> @@ -308,7 +308,9 @@ READ_LOCK_STATUS   = TRUE
>>INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
>>
>>INF 
>> Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.inf
>> -  INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
>> +  INF 
>> SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf
>> +  INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
>> +
>>#
>># Build Shell from latest source code instead of prebuilt binary
>>#
>> @@ -364,11 +366,79 @@ READ_LOCK_STATUS   = TRUE
>>
>>INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
>>
>> +  INF RuleOverride = FMP_IMAGE_DESC 
>> Platform/Hisilicon/D06/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
>>FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>>  SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED 
>> = TRUE {
>>SECTION FV_IMAGE = FVMAIN
>>  }
>>}
>> +[FV.CapsuleDispatchFv]
>> +FvAlignment= 16
>> +ERASE_POLARITY = 1
>> +MEMORY_MAPPED  = TRUE
>> +STICKY_WRITE   = TRUE
>> +LOCK_CAP   = TRUE
>> +LOCK_STATUS= TRUE
>> +WRITE_DISABLED_CAP = TRUE
>> +WRITE_ENABLED_CAP  = TRUE
>> +WRITE_STATUS   = TRUE
>> +WRITE_LOCK_CAP = 

Re: [edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-08-24 Thread Ard Biesheuvel
Hi Sumit,

On 24 August 2018 at 10:21, Sumit Garg  wrote:
> Add following APIs to communicate with OP-TEE static TA:
> 1. OpteeInit
> 2. OpteeOpenSession
> 3. OpteeCloseSession
> 4. OpteeInvokeFunc
>
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sumit Garg 
> ---
>  ArmPkg/Include/Library/OpteeLib.h  | 102 ++
>  ArmPkg/Library/OpteeLib/Optee.c| 358 
> +
>  ArmPkg/Library/OpteeLib/OpteeLib.inf   |   2 +
>  ArmPkg/Library/OpteeLib/OpteeSmc.h |  43 +++
>  .../Include/IndustryStandard/GlobalPlatform.h  |  60 ++--
>  5 files changed, 531 insertions(+), 34 deletions(-)
>  create mode 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h
>  copy ArmPkg/Include/Library/OpteeLib.h => 
> MdePkg/Include/IndustryStandard/GlobalPlatform.h (53%)
>
> diff --git a/ArmPkg/Include/Library/OpteeLib.h 
> b/ArmPkg/Include/Library/OpteeLib.h
> index f65d8674d9b8..c323f49072f8 100644
> --- a/ArmPkg/Include/Library/OpteeLib.h
> +++ b/ArmPkg/Include/Library/OpteeLib.h
> @@ -25,10 +25,112 @@
>  #define OPTEE_OS_UID2  0xaf630002
>  #define OPTEE_OS_UID3  0xa5d5c51b
>
> +#define OPTEE_MSG_ATTR_TYPE_NONE0x0
> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INPUT 0x1
> +#define OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT0x2
> +#define OPTEE_MSG_ATTR_TYPE_VALUE_INOUT 0x3
> +#define OPTEE_MSG_ATTR_TYPE_MEM_INPUT   0x9
> +#define OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT  0xa
> +#define OPTEE_MSG_ATTR_TYPE_MEM_INOUT   0xb
> +
> +#define OPTEE_MSG_ATTR_TYPE_MASK0xff
> +
> +typedef struct {
> +  UINT64BufPtr;
> +  UINT64Size;
> +  UINT64ShmRef;
> +} OPTEE_MSG_PARAM_MEM;
> +
> +typedef struct {
> +  UINT64A;
> +  UINT64B;
> +  UINT64C;
> +} OPTEE_MSG_PARAM_VALUE;
> +
> +typedef struct {
> +  UINT64 Attr;
> +  union {
> +OPTEE_MSG_PARAM_MEM  Mem;
> +OPTEE_MSG_PARAM_VALUEValue;
> +  } U;
> +} OPTEE_MSG_PARAM;
> +
> +#define MAX_PARAMS   4
> +
> +typedef struct {
> +UINT32 Cmd;
> +UINT32 Func;
> +UINT32 Session;
> +UINT32 CancelId;
> +UINT32 Pad;
> +UINT32 Ret;
> +UINT32 RetOrigin;
> +UINT32 NumParams;
> +
> +// NumParams tells the actual number of element in Params
> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
> +} OPTEE_MSG_ARG;
> +
> +#define OPTEE_UUID_LEN   16
> +
> +//
> +// struct OPTEE_OPEN_SESSION_ARG - Open session argument
> +// @Uuid:   [in] UUID of the Trusted Application
> +// @Session:[out] Session id
> +// @Ret:[out] Return value
> +// @RetOrigin   [out] Origin of the return value
> +//
> +typedef struct {
> +UINT8 Uuid[OPTEE_UUID_LEN];
> +UINT32Session;
> +UINT32Ret;
> +UINT32RetOrigin;
> +} OPTEE_OPEN_SESSION_ARG;
> +

What I meant before was

typedef struct {
UINT8 Uuid[OPTEE_UUID_LEN]; // [in] UUID of the Trusted Application
UINT32Session;  // [out] Session id
UINT32Ret;  // [out] Return value
UINT32RetOrigin;// [out] Origin of the return value
} OPTEE_OPEN_SESSION_ARG;





> +//
> +// struct OPTEE_INVOKE_FUNC_ARG - Invoke function argument
> +// @Func:   [in] Trusted Application function, specific to the TA
> +// @Session:[in] Session id
> +// @Ret:[out] Return value
> +// @RetOrigin   [out] Origin of the return value
> +// @Params  [inout] Parameters for function to be invoked
> +//
> +typedef struct {
> +UINT32 Func;
> +UINT32 Session;
> +UINT32 Ret;
> +UINT32 RetOrigin;
> +OPTEE_MSG_PARAMParams[MAX_PARAMS];
> +} OPTEE_INVOKE_FUNC_ARG;
> +
>  BOOLEAN
>  EFIAPI
>  IsOpteePresent (
>VOID
>);
>
> +EFI_STATUS
> +EFIAPI
> +OpteeInit (
> +  VOID
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +OpteeOpenSession (
> +  IN OUT OPTEE_OPEN_SESSION_ARG  *OpenSessionArg
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +OpteeCloseSession (
> +  IN UINT32  Session
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +OpteeInvokeFunc (
> +  IN OUT OPTEE_INVOKE_FUNC_ARG   *InvokeFuncArg
> +  );
> +
>  #endif
> diff --git a/ArmPkg/Library/OpteeLib/Optee.c b/ArmPkg/Library/OpteeLib/Optee.c
> index 574527f8b5ea..2111022d3662 100644
> --- a/ArmPkg/Library/OpteeLib/Optee.c
> +++ b/ArmPkg/Library/OpteeLib/Optee.c
> @@ -14,11 +14,19 @@
>
>  **/
>
> +#include 
>  #include 
> +#include 
>  #include 
> +#include 
>  #include 
>
>  #include 
> +#include 
> +#include 
> +#include 
> +
> +STATIC OPTEE_SHARED_MEMORY_INFO OpteeShmInfo = { 0 };
>
>  /**
>Check for OP-TEE presence.
> @@ -31,6 +39,7 @@ IsOpteePresent (
>  {
>ARM_SMC_ARGS ArmSmcArgs;
>
> +  

Re: [edk2] [Tee-dev] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-08-24 Thread Sumit Garg
On Fri, 24 Aug 2018 at 17:48, Jerome Forissier
 wrote:
>
>
>
> On 08/24/2018 02:09 PM, Sumit Garg wrote:
> > On Fri, 24 Aug 2018 at 15:57, Jerome Forissier
> >  wrote:
> >>
> >>
> >>
> >> On 08/24/2018 11:21 AM, Sumit Garg wrote:
> >>> Add following APIs to communicate with OP-TEE static TA:
> >>
> >> "static TAs" are now preferably called "pseudo TAs" [1],
> >
> > Sure will use "pseudo TAs" instead.
> >
> >> but it seems this API could be used to invoke "early TAs" as well.>
> > Agree this API could work with "early TAs" as well.
>
> SO the exact, precise description is "pseudo/early TAs" ;-)
>

Ok I will use this in v2.

> >
> >> Or any kind of
> >> Trusted Application as long as the non-secure infrastructure is
> >> available (OP-TEE kernel driver and tee-supplicant daemon).
> >>
> >
> > Current patch for UEFI doesn't provide non-secure infrastructure like
> > support for RPC load TA command. I am not sure about usefulness of
> > such infrastructure during boot.
>
> OK that's the info I was missing, if it's for boot time only then
> "regular" TAs are out-of-scope clearly.
>
> > Anyhow this driver could be extended
> > to provide non-secure infrastructure as well.
> >
> > -Sumit
> >
> >> [1]
> >> https://github.com/OP-TEE/optee_os/blob/3.2.0/documentation/optee_design.md#12-trusted-applications
> >>
> >>> 1. OpteeInit
> >>> 2. OpteeOpenSession
> >>> 3. OpteeCloseSession
> >>> 4. OpteeInvokeFunc
> >>>
> >>> Cc: Ard Biesheuvel 
> >>> Cc: Leif Lindholm 
> >>> Contributed-under: TianoCore Contribution Agreement 1.1
> >>> Signed-off-by: Sumit Garg 
> >>> ---
> >>>  ArmPkg/Include/Library/OpteeLib.h  | 102 ++
> >>>  ArmPkg/Library/OpteeLib/Optee.c| 358 
> >>> +
> >>>  ArmPkg/Library/OpteeLib/OpteeLib.inf   |   2 +
> >>>  ArmPkg/Library/OpteeLib/OpteeSmc.h |  43 +++
> >>>  .../Include/IndustryStandard/GlobalPlatform.h  |  60 ++--
> >>>  5 files changed, 531 insertions(+), 34 deletions(-)
> >>>  create mode 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h
> >>>  copy ArmPkg/Include/Library/OpteeLib.h => 
> >>> MdePkg/Include/IndustryStandard/GlobalPlatform.h (53%)
> >> [...]
> >>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Tee-dev] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-08-24 Thread Sumit Garg
On Fri, 24 Aug 2018 at 15:57, Jerome Forissier
 wrote:
>
>
>
> On 08/24/2018 11:21 AM, Sumit Garg wrote:
> > Add following APIs to communicate with OP-TEE static TA:
>
> "static TAs" are now preferably called "pseudo TAs" [1],

Sure will use "pseudo TAs" instead.

> but it seems this API could be used to invoke "early TAs" as well.

Agree this API could work with "early TAs" as well.

> Or any kind of
> Trusted Application as long as the non-secure infrastructure is
> available (OP-TEE kernel driver and tee-supplicant daemon).
>

Current patch for UEFI doesn't provide non-secure infrastructure like
support for RPC load TA command. I am not sure about usefulness of
such infrastructure during boot. Anyhow this driver could be extended
to provide non-secure infrastructure as well.

-Sumit

> [1]
> https://github.com/OP-TEE/optee_os/blob/3.2.0/documentation/optee_design.md#12-trusted-applications
>
> > 1. OpteeInit
> > 2. OpteeOpenSession
> > 3. OpteeCloseSession
> > 4. OpteeInvokeFunc
> >
> > Cc: Ard Biesheuvel 
> > Cc: Leif Lindholm 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Sumit Garg 
> > ---
> >  ArmPkg/Include/Library/OpteeLib.h  | 102 ++
> >  ArmPkg/Library/OpteeLib/Optee.c| 358 
> > +
> >  ArmPkg/Library/OpteeLib/OpteeLib.inf   |   2 +
> >  ArmPkg/Library/OpteeLib/OpteeSmc.h |  43 +++
> >  .../Include/IndustryStandard/GlobalPlatform.h  |  60 ++--
> >  5 files changed, 531 insertions(+), 34 deletions(-)
> >  create mode 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h
> >  copy ArmPkg/Include/Library/OpteeLib.h => 
> > MdePkg/Include/IndustryStandard/GlobalPlatform.h (53%)
> [...]
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 1/1] ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE

2018-08-24 Thread Sumit Garg
Add following APIs to communicate with OP-TEE static TA:
1. OpteeInit
2. OpteeOpenSession
3. OpteeCloseSession
4. OpteeInvokeFunc

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sumit Garg 
---
 ArmPkg/Include/Library/OpteeLib.h  | 102 ++
 ArmPkg/Library/OpteeLib/Optee.c| 358 +
 ArmPkg/Library/OpteeLib/OpteeLib.inf   |   2 +
 ArmPkg/Library/OpteeLib/OpteeSmc.h |  43 +++
 .../Include/IndustryStandard/GlobalPlatform.h  |  60 ++--
 5 files changed, 531 insertions(+), 34 deletions(-)
 create mode 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h
 copy ArmPkg/Include/Library/OpteeLib.h => 
MdePkg/Include/IndustryStandard/GlobalPlatform.h (53%)

diff --git a/ArmPkg/Include/Library/OpteeLib.h 
b/ArmPkg/Include/Library/OpteeLib.h
index f65d8674d9b8..c323f49072f8 100644
--- a/ArmPkg/Include/Library/OpteeLib.h
+++ b/ArmPkg/Include/Library/OpteeLib.h
@@ -25,10 +25,112 @@
 #define OPTEE_OS_UID2  0xaf630002
 #define OPTEE_OS_UID3  0xa5d5c51b
 
+#define OPTEE_MSG_ATTR_TYPE_NONE0x0
+#define OPTEE_MSG_ATTR_TYPE_VALUE_INPUT 0x1
+#define OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT0x2
+#define OPTEE_MSG_ATTR_TYPE_VALUE_INOUT 0x3
+#define OPTEE_MSG_ATTR_TYPE_MEM_INPUT   0x9
+#define OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT  0xa
+#define OPTEE_MSG_ATTR_TYPE_MEM_INOUT   0xb
+
+#define OPTEE_MSG_ATTR_TYPE_MASK0xff
+
+typedef struct {
+  UINT64BufPtr;
+  UINT64Size;
+  UINT64ShmRef;
+} OPTEE_MSG_PARAM_MEM;
+
+typedef struct {
+  UINT64A;
+  UINT64B;
+  UINT64C;
+} OPTEE_MSG_PARAM_VALUE;
+
+typedef struct {
+  UINT64 Attr;
+  union {
+OPTEE_MSG_PARAM_MEM  Mem;
+OPTEE_MSG_PARAM_VALUEValue;
+  } U;
+} OPTEE_MSG_PARAM;
+
+#define MAX_PARAMS   4
+
+typedef struct {
+UINT32 Cmd;
+UINT32 Func;
+UINT32 Session;
+UINT32 CancelId;
+UINT32 Pad;
+UINT32 Ret;
+UINT32 RetOrigin;
+UINT32 NumParams;
+
+// NumParams tells the actual number of element in Params
+OPTEE_MSG_PARAMParams[MAX_PARAMS];
+} OPTEE_MSG_ARG;
+
+#define OPTEE_UUID_LEN   16
+
+//
+// struct OPTEE_OPEN_SESSION_ARG - Open session argument
+// @Uuid:   [in] UUID of the Trusted Application
+// @Session:[out] Session id
+// @Ret:[out] Return value
+// @RetOrigin   [out] Origin of the return value
+//
+typedef struct {
+UINT8 Uuid[OPTEE_UUID_LEN];
+UINT32Session;
+UINT32Ret;
+UINT32RetOrigin;
+} OPTEE_OPEN_SESSION_ARG;
+
+//
+// struct OPTEE_INVOKE_FUNC_ARG - Invoke function argument
+// @Func:   [in] Trusted Application function, specific to the TA
+// @Session:[in] Session id
+// @Ret:[out] Return value
+// @RetOrigin   [out] Origin of the return value
+// @Params  [inout] Parameters for function to be invoked
+//
+typedef struct {
+UINT32 Func;
+UINT32 Session;
+UINT32 Ret;
+UINT32 RetOrigin;
+OPTEE_MSG_PARAMParams[MAX_PARAMS];
+} OPTEE_INVOKE_FUNC_ARG;
+
 BOOLEAN
 EFIAPI
 IsOpteePresent (
   VOID
   );
 
+EFI_STATUS
+EFIAPI
+OpteeInit (
+  VOID
+  );
+
+EFI_STATUS
+EFIAPI
+OpteeOpenSession (
+  IN OUT OPTEE_OPEN_SESSION_ARG  *OpenSessionArg
+  );
+
+EFI_STATUS
+EFIAPI
+OpteeCloseSession (
+  IN UINT32  Session
+  );
+
+EFI_STATUS
+EFIAPI
+OpteeInvokeFunc (
+  IN OUT OPTEE_INVOKE_FUNC_ARG   *InvokeFuncArg
+  );
+
 #endif
diff --git a/ArmPkg/Library/OpteeLib/Optee.c b/ArmPkg/Library/OpteeLib/Optee.c
index 574527f8b5ea..2111022d3662 100644
--- a/ArmPkg/Library/OpteeLib/Optee.c
+++ b/ArmPkg/Library/OpteeLib/Optee.c
@@ -14,11 +14,19 @@
 
 **/
 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
+#include 
+#include 
+#include 
+
+STATIC OPTEE_SHARED_MEMORY_INFO OpteeShmInfo = { 0 };
 
 /**
   Check for OP-TEE presence.
@@ -31,6 +39,7 @@ IsOpteePresent (
 {
   ARM_SMC_ARGS ArmSmcArgs;
 
+  ZeroMem (, sizeof (ARM_SMC_ARGS));
   // Send a Trusted OS Calls UID command
   ArmSmcArgs.Arg0 = ARM_SMC_ID_TOS_UID;
   ArmCallSmc ();
@@ -44,3 +53,352 @@ IsOpteePresent (
 return FALSE;
   }
 }
+
+STATIC
+EFI_STATUS
+OpteeShmMemRemap (
+  VOID
+  )
+{
+  ARM_SMC_ARGS ArmSmcArgs;
+  EFI_PHYSICAL_ADDRESS Paddr;
+  EFI_PHYSICAL_ADDRESS Start;
+  EFI_PHYSICAL_ADDRESS End;
+  EFI_STATUS   Status;
+  UINTNSize;
+
+  ZeroMem (, sizeof (ARM_SMC_ARGS));
+  ArmSmcArgs.Arg0 = OPTEE_SMC_GET_SHM_CONFIG;
+
+  ArmCallSmc ();
+  if (ArmSmcArgs.Arg0 != OPTEE_SMC_RETURN_OK) {
+DEBUG ((DEBUG_WARN, "OP-TEE shared memory not supported\n"));
+return 

Re: [edk2] [edk2-wiki PATCH] release planning: Add "SMBIOS 3.2.0 support" in Proposed Features

2018-08-24 Thread Zeng, Star
Thanks. Agree and I will follow your preference to push it next week if no 
concern from others. :)

Star
-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Friday, August 24, 2018 3:10 PM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Andrew Fish 
; Leif Lindholm ; Bi, Dandan 

Subject: Re: [edk2-wiki PATCH] release planning: Add "SMBIOS 3.2.0 support" in 
Proposed Features

On 08/24/18 03:18, Zeng, Star wrote:
> I tried both at 
> https://github.com/lzeng14/tianocore/wiki/EDK-II-Release-Planning.

Thanks!

> In fact, I am ok with either one. :)

I like the version more where the URL is not human-readable (in the rendered 
article). If we introduce, say, 5 features until the next stable tag, those 
URLs will get pretty tiresome to look at.

For the version that's currently visible in your clone:

Acked-by: Laszlo Ersek 

Thanks!
Laszlo

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Thursday, August 23, 2018 7:20 PM
> To: Zeng, Star ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Andrew Fish 
> ; Leif Lindholm ; Bi, 
> Dandan 
> Subject: Re: [edk2-wiki PATCH] release planning: Add "SMBIOS 3.2.0 
> support" in Proposed Features
> 
> On 08/23/18 08:40, Star Zeng wrote:
>> Cc: Michael D Kinney 
>> Cc: Laszlo Ersek 
>> Cc: Andrew Fish 
>> Cc: Leif Lindholm 
>> Cc: Dandan Bi 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Star Zeng 
>> ---
>>  EDK-II-Release-Planning.md | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/EDK-II-Release-Planning.md b/EDK-II-Release-Planning.md 
>> index 744770521cca..f2afde72796f 100644
>> --- a/EDK-II-Release-Planning.md
>> +++ b/EDK-II-Release-Planning.md
>> @@ -11,6 +11,8 @@
>>  
>>  ## Proposed Features
>>  
>> +* SMBIOS 3.2.0 support: 
>> +https://bugzilla.tianocore.org/show_bug.cgi?id=1099
>> +
>>  TBD Bugzilla List
>>  
>>  ---
>>
> 
> If you insert
> 
>   [SMBIOS 3.2.0 
> support](https://bugzilla.tianocore.org/show_bug.cgi?id=1099)
> 
> instead, do you like the rendered view better?
> 
> (If you don't, then I'm fine with this patch too, of course.)
> 
> Thanks!
> Laszlo
> 

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


[edk2] [Patch][edk2-platforms/devel-IntelAtomProcessorE3900] UP2 GCC build enabling

2018-08-24 Thread Guo, Mang
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Guo Mang 
---
 Platform/BroxtonPlatformPkg/BuildBxtBios.sh | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Platform/BroxtonPlatformPkg/BuildBxtBios.sh 
b/Platform/BroxtonPlatformPkg/BuildBxtBios.sh
index c8060f8..f6ad400 100644
--- a/Platform/BroxtonPlatformPkg/BuildBxtBios.sh
+++ b/Platform/BroxtonPlatformPkg/BuildBxtBios.sh
@@ -439,10 +439,10 @@ fi
 
 if [ $BoardId == "UP" ]; then
   if [ $FabId == "A" ]; then
-cp -f 
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Board/LeafHill/IFWI/FAB_A/SpiChunk1.bin
  $PLATFORM_PATH/Platform/BroxtonPlatformPkg/Common/Tools/Stitch
-cp -f 
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Board/LeafHill/IFWI/FAB_A/SpiChunk2.bin
  $PLATFORM_PATH/Platform/BroxtonPlatformPkg/Common/Tools/Stitch
-cp -f 
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Board/LeafHill/IFWI/FAB_A/SpiChunk3.bin
  $PLATFORM_PATH/Platform/BroxtonPlatformPkg/Common/Tools/Stitch
-cp -f 
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Board/LeafHill/IFWI/FAB_A/SpiChunk1SpiAccessControl.bin
  $PLATFORM_PATH/Platform/BroxtonPlatformPkg/Common/Tools/Stitch
+cp -f 
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Board/UP2/IFWI/FAB_A/SpiChunk1.bin  
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Common/Tools/Stitch
+cp -f 
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Board/UP2/IFWI/FAB_A/SpiChunk2.bin  
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Common/Tools/Stitch
+cp -f 
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Board/UP2/IFWI/FAB_A/SpiChunk3.bin  
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Common/Tools/Stitch
+cp -f 
$PLATFORM_PATH/Platform/BroxtonPlatformPkg/Board/UP2/IFWI/FAB_A/SpiChunk1SpiAccessControl.bin
  $PLATFORM_PATH/Platform/BroxtonPlatformPkg/Common/Tools/Stitch
   fi
 fi
 #
-- 
2.10.1.windows.1

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


Re: [edk2] [PATCH 2/2] MdeModulePkg/PciBus: Restrict one VGA per HostBridge not Segment

2018-08-24 Thread Zeng, Star

On 2018/8/23 10:53, Ruiyu Ni wrote:

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

Today's restriction of VGA device is to have only one VGA device
enabled per PCI segment. It's not correct because several segments
may share one IO / MMIO address space.
We should restrict to have one VGA per Host Bridge because each
Host Bridge has its only IO / MMIO address space.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Star Zeng 
---
  MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 22 +++---
  MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h | 10 +-
  MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c|  4 ++--
  3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index fdec0bcd53..fbcc53e41a 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -979,33 +979,33 @@ PciDeviceExisted (
  }
  
  /**

-  Get the active VGA device on the same segment.
+  Get the active VGA device on the specified Host Bridge.
  
-  @param VgaDevicePCI IO instance for the VGA device.

+  @param HostBridgeHandleHost Bridge handle.
  
-  @return The active VGA device on the same segment.

+  @return The active VGA device on the specified Host Bridge.
  
  **/

  PCI_IO_DEVICE *
-ActiveVGADeviceOnTheSameSegment (
-  IN PCI_IO_DEVICE*VgaDevice
+LocateVgaDeviceOnHostBridge (
+  IN EFI_HANDLE   HostBridgeHandle
)
  {
LIST_ENTRY  *CurrentLink;
-  PCI_IO_DEVICE   *Temp;
+  PCI_IO_DEVICE   *PciIo;


How about using PciIoDev as the local variable name? PciIo makes me 
regard it for PciIo protocol at the first glance. :)


There are still two minor comments for the code pieces below.

  
CurrentLink = mPciDevicePool.ForwardLink;
  
while (CurrentLink != NULL && CurrentLink != ) {
  
-Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);

+PciIo = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
  
-if (Temp->PciRootBridgeIo->SegmentNumber == VgaDevice->PciRootBridgeIo->SegmentNumber) {

+if (PciIo->PciRootBridgeIo->ParentHandle== HostBridgeHandle) {
  
-  Temp = LocateVgaDevice (Temp);

+  PciIo = LocateVgaDevice (PciIo);
  
-  if (Temp != NULL) {

-return Temp;
+  if (PciIo != NULL) {
+return PciIo;
}
  }
  
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h

index 1ec2178a21..b45d2a5d77 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
@@ -230,16 +230,16 @@ PciDeviceExisted (
);
  
  /**

-  Get the active VGA device on the same segment.
+  Get the active VGA device on the specified Host Bridge.
  
-  @param VgaDevicePCI IO instance for the VGA device.

+  @param HostBridgeHandleHost Bridge handle.
  
-  @return The active VGA device on the same segment.

+  @return The active VGA device on the specified Host Bridge.
  
  **/

  PCI_IO_DEVICE *
-ActiveVGADeviceOnTheSameSegment (
-  IN PCI_IO_DEVICE*VgaDevice
+LocateVgaDeviceOnHostBridge (
+  IN EFI_HANDLE   HostBridgeHandle
);
  
  /**

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
index 291578c63c..333b875ff0 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
@@ -1415,7 +1415,7 @@ SupportPaletteSnoopAttributes (
//
// Get the boot VGA on the same segement


Please also update this code comment.


//
-  Temp = ActiveVGADeviceOnTheSameSegment (PciIoDevice);
+  Temp = LocateVgaDeviceOnHostBridge 
(PciIoDevice->PciRootBridgeIo->ParentHandle);
  
if (Temp == NULL) {

  //
@@ -1670,7 +1670,7 @@ PciIoAttributes (
  //
  // Check if there have been an active VGA device on the same segment


Please also update this code comment.

With the new name and code comments updated,
Reviewed-by: Star Zeng 

Thanks,
Star


  //
-Temp = ActiveVGADeviceOnTheSameSegment (PciIoDevice);
+Temp = LocateVgaDeviceOnHostBridge 
(PciIoDevice->PciRootBridgeIo->ParentHandle);
  if (Temp != NULL && Temp != PciIoDevice) {
//
// An active VGA has been detected, so can not enable another



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


Re: [edk2] [PATCH 1/2] MdeModulePkg/PciBus: Refine ActiveVGADeviceOnTheRootBridge

2018-08-24 Thread Zeng, Star

On 2018/8/23 10:53, Ruiyu Ni wrote:

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1109
The patch doesn't change any behavior of this function.
It just renames the function to LocateVgaDevice() and renames
some parameters and local variables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Star Zeng 
---
  MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 35 +++
  MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h | 10 +++
  2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index f7039da992..fdec0bcd53 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -1002,7 +1002,7 @@ ActiveVGADeviceOnTheSameSegment (
  
  if (Temp->PciRootBridgeIo->SegmentNumber == VgaDevice->PciRootBridgeIo->SegmentNumber) {
  
-  Temp = ActiveVGADeviceOnTheRootBridge (Temp);

+  Temp = LocateVgaDevice (Temp);
  
if (Temp != NULL) {

  return Temp;
@@ -1016,41 +1016,41 @@ ActiveVGADeviceOnTheSameSegment (
  }
  
  /**

-  Get the active VGA device on the root bridge.
+  Locate the active VGA device under the bridge.
  
-  @param RootBridge  PCI IO instance for the root bridge.

+  @param Bridge  PCI IO instance for the bridge.
  
@return The active VGA device.
  
  **/

  PCI_IO_DEVICE *
-ActiveVGADeviceOnTheRootBridge (
-  IN PCI_IO_DEVICE*RootBridge
+LocateVgaDevice (
+  IN PCI_IO_DEVICE*Bridge
)
  {
LIST_ENTRY  *CurrentLink;
-  PCI_IO_DEVICE   *Temp;
+  PCI_IO_DEVICE   *PciIo;


How about using PciIoDev as the local variable name? PciIo makes me 
regard it for PciIo protocol at the first glance. :)


With the new name,
Reviewed-by: Star Zeng 

Thanks,
Star

  
-  CurrentLink = RootBridge->ChildList.ForwardLink;

+  CurrentLink = Bridge->ChildList.ForwardLink;
  
-  while (CurrentLink != NULL && CurrentLink != >ChildList) {

+  while (CurrentLink != NULL && CurrentLink != >ChildList) {
  
-Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);

+PciIo = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
  
-if (IS_PCI_VGA(>Pci) &&

-(Temp->Attributes &
+if (IS_PCI_VGA(>Pci) &&
+(PciIo->Attributes &
   (EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY |
EFI_PCI_IO_ATTRIBUTE_VGA_IO |
EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) != 0) {
-  return Temp;
+  return PciIo;
  }
  
-if (IS_PCI_BRIDGE (>Pci)) {

+if (IS_PCI_BRIDGE (>Pci)) {
  
-  Temp = ActiveVGADeviceOnTheRootBridge (Temp);

+  PciIo = LocateVgaDevice (PciIo);
  
-  if (Temp != NULL) {

-return Temp;
+  if (PciIo != NULL) {
+return PciIo;
}
  }
  
@@ -1060,6 +1060,3 @@ ActiveVGADeviceOnTheRootBridge (

return NULL;
  }
  
-

-
-
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
index c282381f85..1ec2178a21 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
@@ -1,7 +1,7 @@
  /** @file
Supporting functions declaration for PCI devices management.
  
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.

+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD 
License
  which accompanies this distribution.  The full text of the license may be 
found at
@@ -243,16 +243,16 @@ ActiveVGADeviceOnTheSameSegment (
);
  
  /**

-  Get the active VGA device on the root bridge.
+  Locate the active VGA device under the bridge.
  
-  @param RootBridge  PCI IO instance for the root bridge.

+  @param Bridge  PCI IO instance for the bridge.
  
@return The active VGA device.
  
  **/

  PCI_IO_DEVICE *
-ActiveVGADeviceOnTheRootBridge (
-  IN PCI_IO_DEVICE*RootBridge
+LocateVgaDevice (
+  IN PCI_IO_DEVICE*Bridge
);
  
  



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


Re: [edk2] [edk2-wiki PATCH] release planning: Add "SMBIOS 3.2.0 support" in Proposed Features

2018-08-24 Thread Laszlo Ersek
On 08/24/18 03:18, Zeng, Star wrote:
> I tried both at 
> https://github.com/lzeng14/tianocore/wiki/EDK-II-Release-Planning.

Thanks!

> In fact, I am ok with either one. :)

I like the version more where the URL is not human-readable (in the
rendered article). If we introduce, say, 5 features until the next
stable tag, those URLs will get pretty tiresome to look at.

For the version that's currently visible in your clone:

Acked-by: Laszlo Ersek 

Thanks!
Laszlo

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com] 
> Sent: Thursday, August 23, 2018 7:20 PM
> To: Zeng, Star ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Andrew Fish 
> ; Leif Lindholm ; Bi, Dandan 
> 
> Subject: Re: [edk2-wiki PATCH] release planning: Add "SMBIOS 3.2.0 support" 
> in Proposed Features
> 
> On 08/23/18 08:40, Star Zeng wrote:
>> Cc: Michael D Kinney 
>> Cc: Laszlo Ersek 
>> Cc: Andrew Fish 
>> Cc: Leif Lindholm 
>> Cc: Dandan Bi 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Star Zeng 
>> ---
>>  EDK-II-Release-Planning.md | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/EDK-II-Release-Planning.md b/EDK-II-Release-Planning.md 
>> index 744770521cca..f2afde72796f 100644
>> --- a/EDK-II-Release-Planning.md
>> +++ b/EDK-II-Release-Planning.md
>> @@ -11,6 +11,8 @@
>>  
>>  ## Proposed Features
>>  
>> +* SMBIOS 3.2.0 support: 
>> +https://bugzilla.tianocore.org/show_bug.cgi?id=1099
>> +
>>  TBD Bugzilla List
>>  
>>  ---
>>
> 
> If you insert
> 
>   [SMBIOS 3.2.0 support](https://bugzilla.tianocore.org/show_bug.cgi?id=1099)
> 
> instead, do you like the rendered view better?
> 
> (If you don't, then I'm fine with this patch too, of course.)
> 
> Thanks!
> Laszlo
> 

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