Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer arithmetic

2020-07-22 Thread Andrew Fish via groups.io
Bob,

It also looks like clang could use this flag as the default seems to be to 
follow the GCC behavior.

Thanks,

Andrew Fish

> On Jul 22, 2020, at 6:56 PM, Bob Feng  wrote:
> 
> Hi Leif
> 
> I agree to revert that patch for now and I sent a revert patch for review. 
> After resolving the build break issue for ARM/AARCH64 platforms in 
> edk2-platforms, and make sure there is no platform build break with this 
> patch, we will push it again.
> 
> Thanks,
> Bob 
> 
> -Original Message-
> From: devel@edk2.groups.io  
> mailto:devel@edk2.groups.io>> On Behalf Of Leif 
> Lindholm
> Sent: Thursday, July 23, 2020 2:06 AM
> To: devel@edk2.groups.io ; Feng, Bob C 
> mailto:bob.c.f...@intel.com>>
> Cc: PierreGondois mailto:pierre.gond...@arm.com>>; 
> Gao, Liming mailto:liming@intel.com>>; 
> to...@nuviainc.com 
> Subject: Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on 
> void* pointer arithmetic
> 
> Hi Bob,
> 
> This patch also breaks about half of the ARM/AARCH64 platforms in 
> edk2-platforms. I agree it should go in at a later stage, but for now, can we 
> please revert it?
> 
> Regards,
> 
> Leif
> 
> On Mon, Jul 20, 2020 at 04:10:27 +, Bob Feng wrote:
>> Reviewed-by: Bob Feng
>> 
>> 
>> -Original Message-
>> From: PierreGondois 
>> Sent: Tuesday, July 7, 2020 4:35 PM
>> To: devel@edk2.groups.io
>> Cc: Pierre Gondois ; Feng, Bob C 
>> ; Gao, Liming ; 
>> tomas.pi...@arm.com; n...@arm.com
>> Subject: [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* 
>> pointer arithmetic
>> 
>> From: Pierre Gondois 
>> 
>> By default, gcc allows void* pointer arithmetic.
>> This is a GCC extension.
>> However:
>> - the C reference manual states that void*
>>   pointer "cannot be operands of addition
>>   or subtraction operators". Cf s5.3.1
>>   "Generic Pointers";
>> - Visual studio compiler treat such operation as
>>   an error.
>> 
>> To prevent such pointer arithmetic, the "-Wpointer-arith"
>> flag should be set for all GCC versions.
>> 
>> The "-Wpointer-arith"  allows to:
>>  "Warn about anything that depends on the "size of"
>>  a function type or of void. GNU C assigns these
>>  types a size of 1, for convenience in calculations
>>  with void * pointers and pointers to functions."
>> 
>> This flag is available since GCC2.95.3 which came out in 2001.
>> 
>> Signed-off-by: Pierre Gondois 
>> ---
>> 
>> The changes can be seen at: 
>> https://github.com/PierreARM/edk2/commits/831_Add_gcc_flag_warning_v2
>> 
>> Notes:
>>v1:
>> - Add "-Wpointer-arith" gcc flag. [Pierre]
>>v2:
>> - Only add the flag for ARM and AARCH64. [Tomas]
>> 
>> BaseTools/Conf/tools_def.template | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/BaseTools/Conf/tools_def.template 
>> b/BaseTools/Conf/tools_def.template
>> index 
>> 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..397b011ba38f97f81f314f8641ac
>> 8bb95d5a2197 100755
>> --- a/BaseTools/Conf/tools_def.template
>> +++ b/BaseTools/Conf/tools_def.template
>> @@ -1,7 +1,7 @@
>> #
>> #  Copyright (c) 2006 - 2018, Intel Corporation. All rights 
>> reserved.  #  Portions copyright (c) 2008 - 2009, Apple Inc. All 
>> rights reserved. -#  Portions copyright (c) 2011 - 2019, ARM Ltd. 
>> All rights reserved.
>> +#  Portions copyright (c) 2011 - 2020, ARM Ltd. All rights 
>> +reserved.
>> #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.  #  (C) 
>> Copyright 2020, Hewlett Packard Enterprise Development LP  #  Copyright 
>> (c) Microsoft Corporation
>> @@ -1921,9 +1921,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
>> --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N
>> DEFINE GCC_ALL_CC_FLAGS= -g -Os -fshort-wchar -fno-builtin 
>> -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h 
>> -fno-common
>> DEFINE GCC_IA32_CC_FLAGS   = DEF(GCC_ALL_CC_FLAGS) -m32 
>> -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 
>> -mno-stack-arg-probe
>> DEFINE GCC_X64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mno-red-zone 
>> -Wno-address -mno-stack-arg-probe
>> -DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
>> -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections 
>> -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft 
>> -fno-pic -fno-pie
>> +DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
>> -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char 
>> -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address 
>> -mthumb -mfloat-abi=soft -fno-pic -fno-pie
>> DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
>> -DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
>> -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections 
>> -fdata-sections -Wno-address -fno-asynchronous-unwind-tables 
>> -fno-unwind-tables -fno-pic -fno-pie -

Re: [edk2-devel] [PATCH] SecurityPkg: Fix GetSupportedAndActivePcrs counter calculation

2020-07-22 Thread Yao, Jiewen
Reviewed-by: Jiewen Yao 

> -Original Message-
> From: Gonzalez Del Cueto, Rodrigo 
> Sent: Tuesday, July 21, 2020 6:27 AM
> To: devel@edk2.groups.io
> Cc: Gonzalez Del Cueto, Rodrigo ; Yao,
> Jiewen ; Wang, Jian J ; Zhang,
> Qi1 
> Subject: [PATCH] SecurityPkg: Fix GetSupportedAndActivePcrs counter
> calculation
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2855
> The Tpm2GetCapabilitySupportedAndActivePcrs function prints a
> count number that should reflect the *supported and currently
> active* PCR banks, but the implementation in place displays
> instead the count of the *supported PCR banks* retrieved
> directly from the Tpm2GetCapabilityPcrs()
> TPML_PCR_SELECTION output.
> 
> The counter should only take into account those PCRs banks
> which are active.
> 
> Replaced usage of EFI_D_* for DEBUG_* definitions in debug
> messages.
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Qi Zhang 
> Signed-off-by: Rodrigo Gonzalez del Cueto
> 
> ---
>  .../Library/Tpm2CommandLib/Tpm2Capability.c   | 46 ---
>  1 file changed, 29 insertions(+), 17 deletions(-)
> 
> diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c
> b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c
> index 85b11c7715..07cac08c40 100644
> --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c
> +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c
> @@ -110,7 +110,7 @@ Tpm2GetCapability (
>// Fail if command failed
> 
>//
> 
>if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
> 
> -DEBUG ((EFI_D_ERROR, "Tpm2GetCapability: Response Code error!
> 0x%08x\r\n", SwapBytes32(RecvBuffer.Header.responseCode)));
> 
> +DEBUG ((DEBUG_ERROR, "Tpm2GetCapability: Response Code error!
> 0x%08x\r\n", SwapBytes32(RecvBuffer.Header.responseCode)));
> 
>  return EFI_DEVICE_ERROR;
> 
>}
> 
> 
> 
> @@ -522,74 +522,86 @@ Tpm2GetCapabilitySupportedAndActivePcrs (
>EFI_STATUSStatus;
> 
>TPML_PCR_SELECTIONPcrs;
> 
>UINTN Index;
> 
> +  UINT8 ActivePcrBankCount;
> 
> 
> 
>//
> 
> -  // Get supported PCR and current Active PCRs.
> 
> +  // Get supported PCR
> 
>//
> 
>Status = Tpm2GetCapabilityPcrs (&Pcrs);
> 
> -
> 
> +  DEBUG ((DEBUG_INFO, "Supported PCRs - Count = %08x\n", Pcrs.count));
> 
> +  ActivePcrBankCount = 0;
> 
>//
> 
>// If error, assume that we have at least SHA-1 (and return the error.)
> 
>//
> 
>if (EFI_ERROR (Status)) {
> 
> -DEBUG ((EFI_D_ERROR, "GetSupportedAndActivePcrs -
> Tpm2GetCapabilityPcrs fail!\n"));
> 
> +DEBUG ((DEBUG_ERROR, "GetSupportedAndActivePcrs -
> Tpm2GetCapabilityPcrs fail!\n"));
> 
>  *TpmHashAlgorithmBitmap = HASH_ALG_SHA1;
> 
>  *ActivePcrBanks = HASH_ALG_SHA1;
> 
> +ActivePcrBankCount = 1;
> 
>}
> 
>//
> 
>// Otherwise, process the return data to determine what algorithms are
> supported
> 
>// and currently allocated.
> 
>//
> 
>else {
> 
> -DEBUG ((EFI_D_INFO, "GetSupportedAndActivePcrs - Count = %08x\n",
> Pcrs.count));
> 
>  *TpmHashAlgorithmBitmap = 0;
> 
>  *ActivePcrBanks = 0;
> 
>  for (Index = 0; Index < Pcrs.count; Index++) {
> 
>switch (Pcrs.pcrSelections[Index].hash) {
> 
>case TPM_ALG_SHA1:
> 
> -DEBUG ((EFI_D_VERBOSE, "GetSupportedAndActivePcrs - HASH_ALG_SHA1
> present.\n"));
> 
> +DEBUG ((DEBUG_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA1 present.\n"));
> 
>  *TpmHashAlgorithmBitmap |= HASH_ALG_SHA1;
> 
>  if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect,
> Pcrs.pcrSelections[Index].sizeofSelect)) {
> 
> -  DEBUG ((EFI_D_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA1 active.\n"));
> 
> +  DEBUG ((DEBUG_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA1 active.\n"));
> 
>*ActivePcrBanks |= HASH_ALG_SHA1;
> 
> +  ActivePcrBankCount++;
> 
>  }
> 
>  break;
> 
>case TPM_ALG_SHA256:
> 
> -DEBUG ((EFI_D_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA256 present.\n"));
> 
> +DEBUG ((DEBUG_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA256 present.\n"));
> 
>  *TpmHashAlgorithmBitmap |= HASH_ALG_SHA256;
> 
>  if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect,
> Pcrs.pcrSelections[Index].sizeofSelect)) {
> 
> -  DEBUG ((EFI_D_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA256 active.\n"));
> 
> +  DEBUG ((DEBUG_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA256 active.\n"));
> 
>*ActivePcrBanks |= HASH_ALG_SHA256;
> 
> +  ActivePcrBankCount++;
> 
>  }
> 
>  break;
> 
>case TPM_ALG_SHA384:
> 
> -DEBUG ((EFI_D_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA384 present.\n"));
> 
> +DEBUG ((DEBUG_VERBOSE, "GetSupportedAndActivePcrs -
> HASH_ALG_SHA384 present.\n"));
> 
>  *TpmHashAlgorithmB

Re: [edk2-devel] [PATCH] SecurityPkg: Debug code to audit BIOS TPM extend operations.

2020-07-22 Thread Yao, Jiewen
Here is some initial feedback:

1) Please don't change function header Tpm2PcrEvent() and Tpm2PcrRead() in 
Tpm2CommandLib.h

2) Please don't move Tpm2PcrRead() function in Tpm2Integrity.c, so that I can 
know what you have changed.

3) Please add Tpm2ActivePcrRegisterRead() as the last function in 
Tpm2Integrity.c

4) Please use DEBUG_VERBOSE for the new debug log. We got feedback before that 
there are too many debug messages in TPM driver.

5) Below code is weird in Tpm2ActivePcrRegisterRead().
  UINT32PcrIndex; 
  PcrIndex = (UINT8)PcrHandle;

Why you define it as UINT32 and cast it as UINT8?

6) Please use 2 spaces indent for the function header.

EFI_STATUS
EFIAPI
Tpm2ActivePcrRegisterRead (
 IN  TPMI_DH_PCRPcrHandle,
 OUT TPML_DIGEST*HashList
)

7) The name of Tpm2ActivePcrRegisterRead() is confusing. What you try to do is 
to read the PCR for the active bank. Maybe Tpm2PcrReadForActiveBank() ?

Thank you
Yao Jiewen


> -Original Message-
> From: Gonzalez Del Cueto, Rodrigo 
> Sent: Tuesday, July 21, 2020 6:29 AM
> To: devel@edk2.groups.io
> Cc: Gonzalez Del Cueto, Rodrigo ; Yao,
> Jiewen ; Wang, Jian J ; Zhang,
> Qi1 
> Subject: [PATCH] SecurityPkg: Debug code to audit BIOS TPM extend operations.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2858
> 
> Add debug functionality to examine TPM extend operations
> performed by BIOS and inspect the PCR 00 value prior to
> any BIOS measurements.
> 
> Replaced usage of EFI_D_* for DEBUG_* definitions in debug
> messages.
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Qi Zhang 
> Signed-off-by: Rodrigo Gonzalez del Cueto
> 
> ---
>  SecurityPkg/Include/Library/Tpm2CommandLib.h  |  25 +-
>  .../Library/Tpm2CommandLib/Tpm2Integrity.c| 468 --
>  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c |  32 +-
>  3 files changed, 364 insertions(+), 161 deletions(-)
> 
> diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h
> b/SecurityPkg/Include/Library/Tpm2CommandLib.h
> index ce381e786b..bfa5bd82f4 100644
> --- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
> +++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
> @@ -505,7 +505,7 @@ EFIAPI
>  Tpm2PcrEvent (
> 
>IN  TPMI_DH_PCR   PcrHandle,
> 
>IN  TPM2B_EVENT   *EventData,
> 
> - OUT  TPML_DIGEST_VALUES*Digests
> 
> +  OUT  TPML_DIGEST_VALUES*Digests
> 
>);
[Jiewen] Why you need this this?

> 
> 
> 
>  /**
> 
> @@ -523,9 +523,26 @@ EFI_STATUS
>  EFIAPI
> 
>  Tpm2PcrRead (
> 
>IN  TPML_PCR_SELECTION*PcrSelectionIn,
> 
> - OUT  UINT32*PcrUpdateCounter,
> 
> - OUT  TPML_PCR_SELECTION*PcrSelectionOut,
> 
> - OUT  TPML_DIGEST   *PcrValues
> 
> +  OUT  UINT32*PcrUpdateCounter,
> 
> +  OUT  TPML_PCR_SELECTION*PcrSelectionOut,
> 
> +  OUT  TPML_DIGEST   *PcrValues
> 
> +  ); 
> 
> +
> 
> +/**
> 
> +   This function will query the TPM to determine which hashing algorithms and
> 
> +   get the digests of all active and supported PCR banks of a specific PCR
> register.
> 
> +
> 
> +   @param[in] PcrHandle The index of the PCR register to be read.
> 
> +   @param[out]HashList  List of digests from PCR register being read.
> 
> +
> 
> +   @retval EFI_SUCCESS   The Pcr was read successfully.
> 
> +   @retval EFI_DEVICE_ERROR  The command was unsuccessful.
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +Tpm2ActivePcrRegisterRead (
> 
> +  IN  TPMI_DH_PCRPcrHandle,
> 
> +  OUT TPML_DIGEST*HashList
> 
>);
> 
> 
> 
>  /**
> 
> diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c
> b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c
> index ddb15178fb..229fc44139 100644
> --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c
> +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c
> @@ -76,6 +76,297 @@ typedef struct {
> 
> 
>  #pragma pack()
> 
> 
> 
> +/**
> 
> +  This command returns the values of all PCR specified in pcrSelect.
> 
> +
> 
> +  @param[in]  PcrSelectionIn The selection of PCR to read.
> 
> +  @param[out] PcrUpdateCounter   The current value of the PCR update
> counter.
> 
> +  @param[out] PcrSelectionOutThe PCR in the returned list.
> 
> +  @param[out] PcrValues  The contents of the PCR indicated in 
> pcrSelect.
> 
> +
> 
> +  @retval EFI_SUCCESSOperation completed successfully.
> 
> +  @retval EFI_DEVICE_ERROR   The command was unsuccessful.
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +Tpm2PcrRead (
> 
> +  IN  TPML_PCR_SELECTION*PcrSelectionIn,
> 
> + OUT  UINT32*PcrUpdateCounter,
> 
> + OUT  TPML_PCR_SELECTION*PcrSelectionOut,
> 
> + OUT  TPML_DIGEST   *PcrValues
> 
> +  )
> 
> +{
> 
> +  EFI_STATUSStatus;
> 
> +  TPM2_PCR_READ_COMMAND 

Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer arithmetic

2020-07-22 Thread Bob Feng
Hi Leif

I agree to revert that patch for now and I sent a revert patch for review. 
After resolving the build break issue for ARM/AARCH64 platforms in 
edk2-platforms, and make sure there is no platform build break with this patch, 
we will push it again.

Thanks,
Bob 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Leif Lindholm
Sent: Thursday, July 23, 2020 2:06 AM
To: devel@edk2.groups.io; Feng, Bob C 
Cc: PierreGondois ; Gao, Liming ; 
to...@nuviainc.com
Subject: Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on 
void* pointer arithmetic

Hi Bob,

This patch also breaks about half of the ARM/AARCH64 platforms in 
edk2-platforms. I agree it should go in at a later stage, but for now, can we 
please revert it?

Regards,

Leif

On Mon, Jul 20, 2020 at 04:10:27 +, Bob Feng wrote:
> Reviewed-by: Bob Feng
> 
> 
> -Original Message-
> From: PierreGondois 
> Sent: Tuesday, July 7, 2020 4:35 PM
> To: devel@edk2.groups.io
> Cc: Pierre Gondois ; Feng, Bob C 
> ; Gao, Liming ; 
> tomas.pi...@arm.com; n...@arm.com
> Subject: [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* 
> pointer arithmetic
> 
> From: Pierre Gondois 
> 
> By default, gcc allows void* pointer arithmetic.
> This is a GCC extension.
> However:
>  - the C reference manual states that void*
>pointer "cannot be operands of addition
>or subtraction operators". Cf s5.3.1
>"Generic Pointers";
>  - Visual studio compiler treat such operation as
>an error.
> 
> To prevent such pointer arithmetic, the "-Wpointer-arith"
> flag should be set for all GCC versions.
> 
> The "-Wpointer-arith"  allows to:
>   "Warn about anything that depends on the "size of"
>   a function type or of void. GNU C assigns these
>   types a size of 1, for convenience in calculations
>   with void * pointers and pointers to functions."
> 
> This flag is available since GCC2.95.3 which came out in 2001.
> 
> Signed-off-by: Pierre Gondois 
> ---
> 
> The changes can be seen at: 
> https://github.com/PierreARM/edk2/commits/831_Add_gcc_flag_warning_v2
> 
> Notes:
> v1:
>  - Add "-Wpointer-arith" gcc flag. [Pierre]
> v2:
>  - Only add the flag for ARM and AARCH64. [Tomas]
> 
>  BaseTools/Conf/tools_def.template | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index 
> 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..397b011ba38f97f81f314f8641ac
> 8bb95d5a2197 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -1,7 +1,7 @@
>  #
>  #  Copyright (c) 2006 - 2018, Intel Corporation. All rights 
> reserved.  #  Portions copyright (c) 2008 - 2009, Apple Inc. All 
> rights reserved. -#  Portions copyright (c) 2011 - 2019, ARM Ltd. 
> All rights reserved.
> +#  Portions copyright (c) 2011 - 2020, ARM Ltd. All rights 
> +reserved.
>  #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.  #  (C) 
> Copyright 2020, Hewlett Packard Enterprise Development LP  #  Copyright 
> (c) Microsoft Corporation
> @@ -1921,9 +1921,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
> --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N
>  DEFINE GCC_ALL_CC_FLAGS= -g -Os -fshort-wchar -fno-builtin 
> -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h 
> -fno-common
>  DEFINE GCC_IA32_CC_FLAGS   = DEF(GCC_ALL_CC_FLAGS) -m32 
> -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 
> -mno-stack-arg-probe
>  DEFINE GCC_X64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mno-red-zone 
> -Wno-address -mno-stack-arg-probe
> -DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
> -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections 
> -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft 
> -fno-pic -fno-pie
> +DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
> -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char 
> -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb 
> -mfloat-abi=soft -fno-pic -fno-pie
>  DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
> -DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
> -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections 
> -fdata-sections -Wno-address -fno-asynchronous-unwind-tables 
> -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
> +DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
> -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char 
> -ffunction-sections -fdata-sections -Wno-address 
> -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie 
> -ffixed-x18
>  DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
>  DEFINE GCC_DLINK_FLAGS_COMMON  = -nostdlib --pie
>  DEFINE GCC_DLINK2_FLAGS_COMMON = 
> -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
> --
> 'G

Re: [edk2-devel] A problem to build KabyLake

2020-07-22 Thread Canh Kha
Hi Nate,
Yes, I built it successfully with this command
>py -3.8 build_bios.py -p KabylakeRvp3 -r

post_build_ex
Done
Fd file can be found at
C:\minnow\Build\KabylakeOpenBoardPkg\KabylakeRvp3\RELEASE_VS2015\FV\KABYLAKERVP3.fd

>From the build.log, I saw
...
Generating FVMICROCODE FV

Generate Region at Offset 0x59
   Region Size = 0x6
   Region File Name = c:\minnow\FSP\AmberLakeFspBinPkg/Fsp_Rebased_S.fd

Generate Region at Offset 0x5F
   Region Size = 0xBC000
   Region File Name = c:\minnow\FSP\AmberLakeFspBinPkg/Fsp_Rebased_M.fd

Generate Region at Offset 0x6AC000
   Region Size = 0x14000
   Region File Name = c:\minnow\FSP\AmberLakeFspBinPkg/Fsp_Rebased_T.fd

Generate Region at Offset 0x6C
   Region Size = 0x1
   Region Name = FV

Generating FVADVANCEDPREMEMORY FV

Generate Region at Offset 0x6D
   Region Size = 0x13
   Region Name = FV

Generating FVPREMEMORY FV

GUID cross reference file can be found at
c:\minnow\Build\KabylakeOpenBoardPkg\KabylakeRvp3\RELEASE_VS2015\FV\Guid.xref

FV Space Information
FVMICROCODE [59%Full] 655360 total, 387168 used, 268192 free
FVPREMEMORY [6%Full] 1245184 total, 83200 used, 1161984 free
FVPOSTMEMORYUNCOMPACT [52%Full] 65536 total, 34672 used, 30864 free
FVPOSTMEMORY [%Full] 1572864 total, 11240 used, 1561624 free
FVUEFIBOOTUNCOMPACT [98%Full] 2162688 total, 2121744 used, 40944 free
FVUEFIBOOT [31%Full] 1966080 total, 619040 used, 1347040 free
FVOSBOOTUNCOMPACT [83%Full] 393216 total, 329712 used, 63504 free
FVLATESILICON [94%Full] 131072 total, 124336 used, 6736 free
FVOSBOOT [24%Full] 589824 total, 141608 used, 448216 free
FVSECURITYPREMEMORY [12%Full] 65536 total, 8152 used, 57384 free
FVSECURITYPOSTMEMORY [%Full] 65536 total, 120 used, 65416 free
FVSECURITYLATE [61%Full] 65536 total, 39992 used, 25544 free
FVSECURITY [17%Full] 458752 total, 82008 used, 376744 free
FVADVANCEDPREMEMORY [%Full] 65536 total, 120 used, 65416 free
FVADVANCEDUNCOMPACT [100%Full] 120 total, 120 used, 0 free
FVADVANCED [%Full] 327680 total, 272 used, 327408 free
Build report can be found at C:\minnow\BuildReport.log

- Done -
Build end time: 19:06:19, Jul.22 2020
Build total time: 00:02:32

Does that mean this fd file has the Intel Amberlake FSP?
When using Intel FITC to form a full image, I will need to pick this fd
file, right?
Thanks,
Canh


On Wed, Jul 22, 2020 at 6:44 PM Desimone, Nathaniel L <
nathaniel.l.desim...@intel.com> wrote:

> Hi Canh,
>
>
>
> To build KabyLake please use edk2-platforms/Platform/Intel/build_bios.py
>
>
>
> Debug Build: build_bios.py -p KabylakeRvp3 -d
>
> Release Build: build_bios.py -p KabylakeRvp3 -r
>
>
>
> Thanks,
>
> Nate
>
>
>
> *From:* devel@edk2.groups.io  *On Behalf Of *Canh
> Kha
> *Sent:* Wednesday, July 22, 2020 8:32 AM
> *To:* Jiang, Guomin 
> *Cc:* devel@edk2.groups.io
> *Subject:* Re: [edk2-devel] A problem to build KabyLake
>
>
>
> Hi Guomin,
>
>
>
> Yes, I also have the same file as you do
>
> >dir
> C:\minnow\edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include\PreMemory.fdf
>  Volume in drive C is OS
>  Volume Serial Number is CCF3-B399
>
>  Directory of
> C:\minnow\edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include
>
> 07/11/2020  03:26 PM 1,779 PreMemory.fdf
>1 File(s)  1,779 bytes
>
>
>
> But for some reason, the script seems looking for it from
> a different directory.
>
> Thank you,
>
> Canh
>
>
>
> On Wed, Jul 22, 2020 at 5:47 AM Jiang, Guomin 
> wrote:
>
>  It confuse me that near line 60, column 0:   !include
> LogoFeaturePkg/Include/PreMemory.fdf.
>
>
>
> In my local machine, the PreMemory.fdf should be
> AdvancedFeaturePkg/Include/PreMemory.fdf,
>
>
>
> I can also find this file in directory
> edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include.
>
>
>
> Please confirm it.
>
>
>
> Thanks.
>
> Guomin
>
> *From:* devel@edk2.groups.io  *On Behalf Of *Canh
> Kha
> *Sent:* Wednesday, July 22, 2020 1:13 PM
> *To:* devel@edk2.groups.io
> *Subject:* [edk2-devel] A problem to build KabyLake
>
>
>
> Hi,
>
> When I ran this build command
>
> build -a IA32 -a X64 -n 5 -t VS2015x86 -b DEBUG -p
> KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc
>
> I received the following message
>
>
> build.py...
>  : error C0DE: Unknown fatal error when processing
> [c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc]
>
> (Please send email to devel@edk2.groups.io for help, attaching following
> call stack trace!)
>
> (Python 3.8.3 on win32) Traceback (most recent call last):
>   File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2636,
> in Main
> MyBuild.Launch()
>   File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2431,
> in Launch
> self._MultiThreadBuildPlatform()
>   File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2238,
> in _MultiThreadBuildPlatform
> Wa, self.BuildModules = self.PerformAutoGen(BuildTarget,ToolChain)
>   File "C:\minnow\edk2\BaseTools\Source\Python\buil

Re: [edk2-devel] A problem to build KabyLake

2020-07-22 Thread Nate DeSimone
Hi Canh,

Yes, the Intel Amberlake FSP has been automatically included in the FD file. 
The final FD file is found at 
C:\minnow\Build\KabylakeOpenBoardPkg\KabylakeRvp3\RELEASE_VS2015\FV\KABYLAKERVP3.fd

In FITC, you would use KABYLAKERVP3.fd as your BIOS image when stitching the 
full IFWI (Integrated Firmware Image).

Thanks,
Nate

From: Canh Kha 
Date: Wednesday, July 22, 2020 at 5:24 PM
To: "Desimone, Nathaniel L" 
Cc: "devel@edk2.groups.io" , "Jiang, Guomin" 

Subject: Re: [edk2-devel] A problem to build KabyLake

Hi Nate,
Yes, I built it successfully with this command
>py -3.8 build_bios.py -p KabylakeRvp3 -r

post_build_ex
Done
Fd file can be found at 
C:\minnow\Build\KabylakeOpenBoardPkg\KabylakeRvp3\RELEASE_VS2015\FV\KABYLAKERVP3.fd

From the build.log, I saw
...
Generating FVMICROCODE FV

Generate Region at Offset 0x59
   Region Size = 0x6
   Region File Name = c:\minnow\FSP\AmberLakeFspBinPkg/Fsp_Rebased_S.fd

Generate Region at Offset 0x5F
   Region Size = 0xBC000
   Region File Name = c:\minnow\FSP\AmberLakeFspBinPkg/Fsp_Rebased_M.fd

Generate Region at Offset 0x6AC000
   Region Size = 0x14000
   Region File Name = c:\minnow\FSP\AmberLakeFspBinPkg/Fsp_Rebased_T.fd

Generate Region at Offset 0x6C
   Region Size = 0x1
   Region Name = FV

Generating FVADVANCEDPREMEMORY FV

Generate Region at Offset 0x6D
   Region Size = 0x13
   Region Name = FV

Generating FVPREMEMORY FV

GUID cross reference file can be found at 
c:\minnow\Build\KabylakeOpenBoardPkg\KabylakeRvp3\RELEASE_VS2015\FV\Guid.xref

FV Space Information
FVMICROCODE [59%Full] 655360 total, 387168 used, 268192 free
FVPREMEMORY [6%Full] 1245184 total, 83200 used, 1161984 free
FVPOSTMEMORYUNCOMPACT [52%Full] 65536 total, 34672 used, 30864 free
FVPOSTMEMORY [%Full] 1572864 total, 11240 used, 1561624 free
FVUEFIBOOTUNCOMPACT [98%Full] 2162688 total, 2121744 used, 40944 free
FVUEFIBOOT [31%Full] 1966080 total, 619040 used, 1347040 free
FVOSBOOTUNCOMPACT [83%Full] 393216 total, 329712 used, 63504 free
FVLATESILICON [94%Full] 131072 total, 124336 used, 6736 free
FVOSBOOT [24%Full] 589824 total, 141608 used, 448216 free
FVSECURITYPREMEMORY [12%Full] 65536 total, 8152 used, 57384 free
FVSECURITYPOSTMEMORY [%Full] 65536 total, 120 used, 65416 free
FVSECURITYLATE [61%Full] 65536 total, 39992 used, 25544 free
FVSECURITY [17%Full] 458752 total, 82008 used, 376744 free
FVADVANCEDPREMEMORY [%Full] 65536 total, 120 used, 65416 free
FVADVANCEDUNCOMPACT [100%Full] 120 total, 120 used, 0 free
FVADVANCED [%Full] 327680 total, 272 used, 327408 free
Build report can be found at C:\minnow\BuildReport.log

- Done -
Build end time: 19:06:19, Jul.22 2020
Build total time: 00:02:32

Does that mean this fd file has the Intel Amberlake FSP?
When using Intel FITC to form a full image, I will need to pick this fd file, 
right?
Thanks,
Canh


On Wed, Jul 22, 2020 at 6:44 PM Desimone, Nathaniel L 
mailto:nathaniel.l.desim...@intel.com>> wrote:
Hi Canh,

To build KabyLake please use edk2-platforms/Platform/Intel/build_bios.py

Debug Build: build_bios.py -p KabylakeRvp3 -d
Release Build: build_bios.py -p KabylakeRvp3 -r

Thanks,
Nate

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Canh Kha
Sent: Wednesday, July 22, 2020 8:32 AM
To: Jiang, Guomin mailto:guomin.ji...@intel.com>>
Cc: devel@edk2.groups.io
Subject: Re: [edk2-devel] A problem to build KabyLake

Hi Guomin,

Yes, I also have the same file as you do
>dir 
>C:\minnow\edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include\PreMemory.fdf
 Volume in drive C is OS
 Volume Serial Number is CCF3-B399

 Directory of C:\minnow\edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include

07/11/2020  03:26 PM 1,779 PreMemory.fdf
   1 File(s)  1,779 bytes

But for some reason, the script seems looking for it from a different directory.
Thank you,
Canh

On Wed, Jul 22, 2020 at 5:47 AM Jiang, Guomin 
mailto:guomin.ji...@intel.com>> wrote:
 It confuse me that near line 60, column 0:   !include 
LogoFeaturePkg/Include/PreMemory.fdf.

In my local machine, the PreMemory.fdf should be 
AdvancedFeaturePkg/Include/PreMemory.fdf,

I can also find this file in directory 
edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include.

Please confirm it.

Thanks.
Guomin
From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Canh Kha
Sent: Wednesday, July 22, 2020 1:13 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] A problem to build KabyLake

Hi,
When I ran this build command
build -a IA32 -a X64 -n 5 -t VS2015x86 -b DEBUG -p 
KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc
I received the following message

build.py...
 : error C0DE: Unknown fatal error when processing 
[c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc]

(Please send email to devel@edk2.groups.io

Re: [edk2-devel] [PATCH v11 06/46] MdePkg/BaseLib: Add support for the XGETBV instruction

2020-07-22 Thread Liming Gao
Laszlo:

-Original Message-
From: Laszlo Ersek  
Sent: 2020年7月23日 4:28
To: Liu, Zhiguang ; devel@edk2.groups.io; 
thomas.lenda...@amd.com
Cc: Brijesh Singh ; Ard Biesheuvel 
; Dong, Eric ; Justen, Jordan L 
; Gao, Liming ; Kinney, 
Michael D ; Ni, Ray 
Subject: Re: [edk2-devel] [PATCH v11 06/46] MdePkg/BaseLib: Add support for the 
XGETBV instruction

On 07/22/20 02:55, Liu, Zhiguang wrote:
> Hi Tom,
> Nasm is a cross-OS assembly code and can be used in Linux.
> So I think we don't need implement the same function in GccInline.c, we can 
> just use the nasm file in Linux.

I could agree, but this would create an inconsistency with the existent 
functions (where both gcc inline assembly and NASM exists).
[Liming] Yes. This is clean up task to make the existing ones be consistent. 
The new one X86 assembly function (IA32 and X64) should follow nasm style.

For example, consider AsmReadEflags():
- inline assembly for MSFT IA32 ("Ia32/ReadEflags.c")
- NASM for MSFT X64 ("X64/ReadEflags.nasm")
- inline assembly for GCC IA32 ("Ia32/GccInline.c")
- inline assembly for GCC X64 ("X64/GccInline.c")

The source file "X64/ReadEflags.nasm" could be used with GCC X64 too, not just 
with MSFT X64.

So why do we have the gcc inline implementation for AsmReadEflags() in 
"X64/GccInline.c", in the first place?
[Liming] This is the history. Nasm migration replaces .S and .asm. But, the 
remaining one in C source is not replaced. 

Thanks
Liming
The pattern that a contributor is supposed to follow is not clear to me.

Thanks,
Laszlo

>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of 
>> Lendacky, Thomas
>> Sent: Wednesday, July 22, 2020 5:19 AM
>> To: devel@edk2.groups.io
>> Cc: Brijesh Singh ; Ard Biesheuvel 
>> ; Dong, Eric ; Justen, 
>> Jordan L ; Laszlo Ersek 
>> ; Gao, Liming ; Kinney, 
>> Michael D ; Ni, Ray 
>> Subject: [edk2-devel] [PATCH v11 06/46] MdePkg/BaseLib: Add support 
>> for the XGETBV instruction
>>
>> From: Tom Lendacky 
>>
>> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198
>>
>> Under SEV-ES, a CPUID instruction requires the current value of the 
>> XCR0 register. In order to retrieve that value, the XGETBV 
>> instruction needs to be executed.
>>
>> Provide the necessary support to execute the XGETBV instruction.
>>
>> Cc: Michael D Kinney 
>> Cc: Liming Gao 
>> Signed-off-by: Tom Lendacky 
>> ---
>>  MdePkg/Library/BaseLib/BaseLib.inf  |  2 ++
>>  MdePkg/Include/Library/BaseLib.h| 17 +
>>  MdePkg/Library/BaseLib/Ia32/GccInline.c | 28   
>> MdePkg/Library/BaseLib/X64/GccInline.c  | 30 ++  
>> MdePkg/Library/BaseLib/Ia32/XGetBv.nasm | 31
>> ++
>>  MdePkg/Library/BaseLib/X64/XGetBv.nasm  | 34
>> +
>>  6 files changed, 142 insertions(+)
>>  create mode 100644 MdePkg/Library/BaseLib/Ia32/XGetBv.nasm
>>  create mode 100644 MdePkg/Library/BaseLib/X64/XGetBv.nasm
>>
>> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf
>> b/MdePkg/Library/BaseLib/BaseLib.inf
>> index c740a819cacf..e26c0d8cb0ac 100644
>> --- a/MdePkg/Library/BaseLib/BaseLib.inf
>> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
>> @@ -153,6 +153,7 @@ [Sources.Ia32]
>>Ia32/ARShiftU64.c | MSFT
>>Ia32/EnableCache.c | MSFT
>>Ia32/DisableCache.c | MSFT
>> +  Ia32/XGetBv.nasm | MSFT
>>
>>
>>Ia32/GccInline.c | GCC
>> @@ -288,6 +289,7 @@ [Sources.X64]
>>X64/ReadCr2.nasm| MSFT
>>X64/ReadCr0.nasm| MSFT
>>X64/ReadEflags.nasm| MSFT
>> +  X64/XGetBv.nasm | MSFT
>>
>>
>>X64/Non-existing.c
>> diff --git a/MdePkg/Include/Library/BaseLib.h
>> b/MdePkg/Include/Library/BaseLib.h
>> index 8e7b87cbda4e..7edf0051a0a0 100644
>> --- a/MdePkg/Include/Library/BaseLib.h
>> +++ b/MdePkg/Include/Library/BaseLib.h
>> @@ -7831,6 +7831,23 @@ AsmLfence (
>>VOID
>>);
>>
>> +/**
>> +  Executes a XGETBV instruction
>> +
>> +  Executes a XGETBV instruction. This function is only available on 
>> + IA-32 and  x64.
>> +
>> +  @param[in] IndexExtended control register index
>> +
>> +  @return The current value of the extended control register
>> +**/
>> +UINT64
>> +EFIAPI
>> +AsmXGetBv (
>> +  IN UINT32  Index
>> +  );
>> +
>> +
>>  /**
>>Patch the immediate operand of an IA32 or X64 instruction such 
>> that the byte,
>>word, dword or qword operand is encoded at the end of the 
>> instruction's diff --git a/MdePkg/Library/BaseLib/Ia32/GccInline.c
>> b/MdePkg/Library/BaseLib/Ia32/GccInline.c
>> index 6ed938187a08..c2565ab9a183 100644
>> --- a/MdePkg/Library/BaseLib/Ia32/GccInline.c
>> +++ b/MdePkg/Library/BaseLib/Ia32/GccInline.c
>> @@ -584,3 +584,31 @@ AsmReadTsc (
>>
>>return Data;
>>  }
>> +
>> +
>> +/**
>> +  Executes a XGETBV instruction
>> +
>> +  Executes a XGETBV instruction. This function is only available on 
>> + IA-32 and  x64.
>> +
>> +  @param[in] IndexExtended control register index
>> +
>> +  @return The current value of the extended c

Re: [edk2-devel] [PATCH] MdePkg Base.h: Delete prototype for __builtin_return_address

2020-07-22 Thread Liming Gao
Jess:
  In the commit message, below line is too long that can't pass patch check. 
Can you move this line from the commit message to BZ?

[1] 
https://github.com/llvm/llvm-project/commit/41af97137572ad6d4dafc872e7ecf6bbb08d4984

Thanks
Liming
-Original Message-
From: devel@edk2.groups.io  On Behalf Of Liming Gao
Sent: 2020年7月21日 10:30
To: Jessica Clarke 
Cc: devel@edk2.groups.io; l...@nuviainc.com; Kinney, Michael D 

Subject: Re: [edk2-devel] [PATCH] MdePkg Base.h: Delete prototype for 
__builtin_return_address

Jess:
  OK. Seemly, there is no impact with this change. Reviewed-by: Liming Gao 


Thanks
Liming
-Original Message-
From: Jessica Clarke 
Sent: 2020年7月20日 23:06
To: Gao, Liming 
Cc: devel@edk2.groups.io; l...@nuviainc.com; Kinney, Michael D 

Subject: Re: [edk2-devel] [PATCH] MdePkg Base.h: Delete prototype for 
__builtin_return_address

It will always look like void *__builtin_return_address(unsigned) and work like 
that, just that under the hood it's being implemented slightly differently, 
which has the unfortunate side-effect of triggering this bug. We've been 
compiling the embedded EDK2 in our CheriBSD with that line deleted for years 
now with no issue.

Jess

> On 20 Jul 2020, at 15:58, Gao, Liming  wrote:
> 
> Clarke:
>  Do you mean CLANG compiler may have the different prototype for 
> __builtin_return_address()? If so, dose __builtin_return_address (L) always 
> work? 
> 
> Thanks
> Liming
>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of Leif 
>> Lindholm
>> Sent: Monday, July 20, 2020 10:05 PM
>> To: Jessica Clarke 
>> Cc: devel@edk2.groups.io; Kinney, Michael D 
>> ; Gao, Liming 
>> Subject: Re: [edk2-devel] [PATCH] MdePkg Base.h: Delete prototype for 
>> __builtin_return_address
>> 
>> +Mike, Liming
>> 
>> On Mon, Jul 20, 2020 at 14:49:46 +0100, Jessica Clarke wrote:
>>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1004
>>> 
>>> Being a compiler builtin, the type of __builtin_return_address is 
>>> already known to the compiler so no prototype is needed. Clang also 
>>> errors out when redeclaring certain builtins like this[1], though 
>>> currently only for ones with custom type checking. At the moment, 
>>> __builtin_return_address does not use custom type checking and so 
>>> does not trigger this error, however, the CHERI fork of LLVM, which 
>>> will form the basis of the toolchain for Arm's experimental Morello 
>>> platform, does use custom type checking for it, and so gives an 
>>> error. Thus, simply delete the unnecessary line.
>>> 
>>> [1]
>>> https://github.com/llvm/llvm-project/commit/41af97137572ad6d4dafc872
>>> e7ecf6bbb08d4984
>>> 
>>> Cc: Leif Lindholm 
>>> Signed-off-by: Jessica Clarke 
>>> ---
>>> MdePkg/Include/Base.h | 1 -
>>> 1 file changed, 1 deletion(-)
>>> 
>>> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 
>>> 85a091b9d5..8e4271f6ea 100644
>>> --- a/MdePkg/Include/Base.h
>>> +++ b/MdePkg/Include/Base.h
>>> @@ -1273,7 +1273,6 @@ typedef UINTN RETURN_STATUS;
>>>   **/
>>>   #define RETURN_ADDRESS(L) ((L == 0) ? _ReturnAddress() : (VOID *) 0)
>>> #elif defined (__GNUC__) || defined (__clang__)
>>> -  void * __builtin_return_address (unsigned int level);
>> 
>> Agreed this looks somewhat bonkers.
>> And I can't see any ill effects from dropping it, so:
>> Reviewed-by: Leif Lindholm 
>> 
>>>   /**
>>> Get the return address of the calling function.
>>> 
>>> --
>>> 2.20.1
>>> 
>> 
>> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63168): https://edk2.groups.io/g/devel/message/63168
Mute This Topic: https://groups.io/mt/75682100/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 1/1] BaseLib:Fix RISC-V Supervisor mode (S-Mode) trap handler reentry issue.

2020-07-22 Thread Liming Gao
Acked-by: Liming Gao 

-Original Message-
From: Abner Chang  
Sent: 2020年7月22日 16:54
To: devel@edk2.groups.io
Cc: abner.ch...@hpe.com; Daniel Schaefer ; Kinney, 
Michael D ; Gao, Liming ; 
Leif Lindholm 
Subject: [PATCH v2 1/1] BaseLib:Fix RISC-V Supervisor mode (S-Mode) trap 
handler reentry issue.

While RISC-V hart is trapped into S-Mode, the S-Mode interrupt CSR (SIE) is 
disabled by RISC-V hart. However the (SIE) is enabled again by RestoreTPL, this 
causes the second S-Mode trap is triggered by the machine mode (M-Mode)timer 
interrupt redirection. The SRET instruction clear Supervisor Previous Privilege 
(SPP) to zero (User mode) in the second S-Mode interrupt according to the 
RISC-V spec. Above brings hart to the user mode (U-Mode) when execute SRET in 
the nested S-Mode interrupt handler because SPP is set to User Mode in the 
second interrupt. Afterward, system runs in U-Mode and any accesses to S-Mode 
CSR causes the invalid instruction exception.

Signed-off-by: Abner Chang 
Reviewed-by: Daniel Schaefer 

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Daniel Schaefer 
Cc: Leif Lindholm 
---
 .../Library/BaseLib/RiscV64/RiscVInterrupt.S  | 45 ---
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S 
b/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
index 766fcfb9cb..e821124781 100644
--- a/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
+++ b/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
@@ -12,21 +12,52 @@ ASM_GLOBAL ASM_PFX(RiscVDisableSupervisorModeInterrupts)
 ASM_GLOBAL ASM_PFX(RiscVEnableSupervisorModeInterrupt) ASM_GLOBAL 
ASM_PFX(RiscVGetSupervisorModeInterrupts) -# define  MSTATUS_SIE
0x0002-# define  CSR_SSTATUS0x100+#define  SSTATUS_SIE 
0x0002+#define  CSR_SSTATUS 0x100+#define  
SSTATUS_SPP_BIT_POSITION8 +//+// This routine disables supervisor mode 
interrupt+// ASM_PFX(RiscVDisableSupervisorModeInterrupts):-  li   a1, 
MSTATUS_SIE-  csrc CSR_SSTATUS, a1+  add   sp, sp, -(__SIZEOF_POINTER__)+  sd   
 a1, (sp)+  lia1, SSTATUS_SIE+  csrc  CSR_SSTATUS, a1+  lda1, (sp)+  
add   sp, sp, (__SIZEOF_POINTER__)   ret +//+// This routine enables supervisor 
mode interrupt+// ASM_PFX(RiscVEnableSupervisorModeInterrupt):-  li   a1, 
MSTATUS_SIE-  csrs CSR_SSTATUS, a1+  add   sp, sp, -2*(__SIZEOF_POINTER__)+  sd 
   a0, (0*__SIZEOF_POINTER__)(sp)+  sda1, (1*__SIZEOF_POINTER__)(sp)++  
csrr  a0, CSR_SSTATUS+  and   a0, a0, (1 << SSTATUS_SPP_BIT_POSITION)+  bnez  
a0, InTrap  // We are in supervisor mode (SMode)+// 
trap handler.+// Skip enabling SIE becasue SIE+ 
   // is set to disabled by RISC-V hart+// 
when the trap takes hart to SMode.++  lia1, SSTATUS_SIE+  csrs  
CSR_SSTATUS, a1+InTrap:+  lda0, (0*__SIZEOF_POINTER__)(sp)+  lda1, 
(1*__SIZEOF_POINTER__)(sp)+  add   sp, sp, 2*(__SIZEOF_POINTER__)   ret +//+// 
This routine returns supervisor mode interrupt+// status.+// 
ASM_PFX(RiscVGetSupervisorModeInterrupts):   csrr a0, CSR_SSTATUS-  andi a0, 
a0, MSTATUS_SIE+  andi a0, a0, SSTATUS_SIE   ret -- 
2.25.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63167): https://edk2.groups.io/g/devel/message/63167
Mute This Topic: https://groups.io/mt/75721373/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] Maintainers.txt: Add 'Zhiguang Liu' for MdePkg review

2020-07-22 Thread Liming Gao
Sure. https://github.com/tianocore/edk2/pull/818 has been created. 

-Original Message-
From: Laszlo Ersek  
Sent: 2020年7月23日 3:59
To: devel@edk2.groups.io; Gao, Liming ; Liu, Zhiguang 

Cc: Kinney, Michael D 
Subject: Re: [edk2-devel] [PATCH] Maintainers.txt: Add 'Zhiguang Liu' for 
MdePkg review

Hi Liming,

On 07/20/20 16:30, Liming Gao wrote:
> Reviewed-by: Liming Gao 

can you merge the patch, please?

Thanks!
Laszlo

>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of 
>> Zhiguang Liu
>> Sent: Monday, July 20, 2020 4:53 PM
>> To: devel@edk2.groups.io
>> Cc: Kinney, Michael D ; Gao, Liming 
>> 
>> Subject: [edk2-devel] [PATCH] Maintainers.txt: Add 'Zhiguang Liu' for 
>> MdePkg review
>>
>> Add 'Zhiguang Liu' as a reviewer for MdePkg.
>>
>> Cc: Michael D Kinney 
>> Cc: Liming Gao 
>> Signed-off-by: Zhiguang Liu 
>> ---
>>  Maintainers.txt | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/Maintainers.txt b/Maintainers.txt index 
>> 599f94d57a..5504bb3d17 100644
>> --- a/Maintainers.txt
>> +++ b/Maintainers.txt
>> @@ -381,6 +381,7 @@ F: MdePkg/
>>  W: https://github.com/tianocore/tianocore.github.io/wiki/MdePkg
>>
>>  M: Michael D Kinney 
>>
>>  M: Liming Gao 
>>
>> +R: Zhiguang Liu 
>>
>>
>>
>>  NetworkPkg
>>
>>  F: NetworkPkg/
>>
>> --
>> 2.25.1.windows.1
>>
>>
>> -=-=-=-=-=-=
>> Groups.io Links: You receive all messages sent to this group.
>>
>> View/Reply Online (#62823): 
>> https://edk2.groups.io/g/devel/message/62823
>> Mute This Topic: https://groups.io/mt/75678333/1759384
>> Group Owner: devel+ow...@edk2.groups.io
>> Unsubscribe: https://edk2.groups.io/g/devel/unsub  
>> [liming@intel.com] -=-=-=-=-=-=
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63166): https://edk2.groups.io/g/devel/message/63166
Mute This Topic: https://groups.io/mt/75678333/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch] Revert "BaseTools: Add gcc flag to warn on void* pointer arithmetic"

2020-07-22 Thread Bob Feng
This reverts commit dbd546a32d5abe225306e22d43a7d86e3a042eee.

This patch also breaks about half of the ARM/AARCH64 platforms in edk2-platforms

Signed-off-by: Bob Feng 

Cc: Pierre Gondois 
Cc: Leif Lindholm 
Cc: Andrew Fish 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
Cc: Liming Gao 
---
 BaseTools/Conf/tools_def.template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index a1fd27b1ad..933b3160fd 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1,9 +1,9 @@
 #
 #  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
-#  Portions copyright (c) 2011 - 2020, ARM Ltd. All rights reserved.
+#  Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.
 #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
 #  (C) Copyright 2020, Hewlett Packard Enterprise Development LP
 #  Copyright (c) Microsoft Corporation
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -1919,13 +1919,13 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
--add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N
 *_*_*_DTC_PATH = DEF(DTC_BIN)
 
 DEFINE GCC_ALL_CC_FLAGS= -g -Os -fshort-wchar -fno-builtin 
-fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h 
-fno-common
 DEFINE GCC_IA32_CC_FLAGS   = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double 
-freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe
 DEFINE GCC_X64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mno-red-zone 
-Wno-address -mno-stack-arg-probe
-DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
-mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char 
-ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb 
-mfloat-abi=soft -fno-pic -fno-pie
+DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
-mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections 
-fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft 
-fno-pic -fno-pie
 DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
-DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
-mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char 
-ffunction-sections -fdata-sections -Wno-address 
-fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
+DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
-fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections 
-fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables 
-fno-pic -fno-pie -ffixed-x18
 DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
 DEFINE GCC_DLINK_FLAGS_COMMON  = -nostdlib --pie
 DEFINE GCC_DLINK2_FLAGS_COMMON = 
-Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
 DEFINE GCC_IA32_X64_DLINK_COMMON   = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
 DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib 
-Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) 
-Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
-- 
2.20.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63165): https://edk2.groups.io/g/devel/message/63165
Mute This Topic: https://groups.io/mt/75737532/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1] EdkRepo: Continue checkout on submodule deinit errors

2020-07-22 Thread Ashley E Desimone
Reviewed-by: Ashley DeSimone 

-Original Message-
From: Bjorge, Erik C  
Sent: Wednesday, July 22, 2020 11:26 AM
To: devel@edk2.groups.io
Cc: Desimone, Ashley E ; Desimone, Nathaniel L 
; Pandya, Puja ; Bret 
Barkelew ; Agyeman, Prince 

Subject: [edk2-staging/EdkRepo] [PATCH v1] EdkRepo: Continue checkout on 
submodule deinit errors

In some cases submodules may still not be deinitialzied even with the more 
aggressive deinit flags.  In these cases the checkout will report a warning and 
attempt to continue the checkout process.

Cc: Ashley E Desimone 
Cc: Nate DeSimone 
Cc: Puja Pandya 
Cc: Bret Barkelew 
Cc: Prince Agyeman 
Cc: Erik Bjorge 
Signed-off-by: Erik Bjorge 
---
 edkrepo/commands/checkout_pin_command.py | 9 +++--  
edkrepo/common/common_repo_functions.py  | 8 +++-
 edkrepo/common/humble.py | 3 +++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/edkrepo/commands/checkout_pin_command.py 
b/edkrepo/commands/checkout_pin_command.py
index 39c5aeb..1c58113 100644
--- a/edkrepo/commands/checkout_pin_command.py
+++ b/edkrepo/commands/checkout_pin_command.py
@@ -16,7 +16,7 @@ import edkrepo.commands.arguments.checkout_pin_args as 
arguments  import edkrepo.commands.humble.checkout_pin_humble as humble  from 
edkrepo.common.common_repo_functions import sparse_checkout_enabled, 
reset_sparse_checkout, sparse_checkout  from 
edkrepo.common.common_repo_functions import check_dirty_repos, checkout_repos, 
combinations_in_manifest -from edkrepo.common.humble import SPARSE_CHECKOUT, 
SPARSE_RESET
+from edkrepo.common.humble import SPARSE_CHECKOUT, SPARSE_RESET, 
+SUBMODULE_DEINIT_FAILED
 from edkrepo.common.edkrepo_exception import 
EdkrepoInvalidParametersException, EdkrepoProjectMismatchException  from 
edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
list_available_manifest_repos  from 
edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
find_source_manifest_repo @@ -71,7 +71,12 @@ class 
CheckoutPinCommand(EdkrepoCommand):
 print(SPARSE_RESET)
 reset_sparse_checkout(workspace_path, manifest_sources)
 submodule_combo = pin.general_config.current_combo
-deinit_full(workspace_path, manifest, args.verbose)
+try:
+deinit_full(workspace_path, manifest, args.verbose)
+except Exception as e:
+print(SUBMODULE_DEINIT_FAILED)
+if args.verbose:
+print(e)
 pin_repo_sources = 
pin.get_repo_sources(pin.general_config.current_combo)
 try:
 checkout_repos(args.verbose, args.override, pin_repo_sources, 
workspace_path, manifest) diff --git a/edkrepo/common/common_repo_functions.py 
b/edkrepo/common/common_repo_functions.py
index 313a1ca..a6a38cf 100644
--- a/edkrepo/common/common_repo_functions.py
+++ b/edkrepo/common/common_repo_functions.py
@@ -50,6 +50,7 @@ from edkrepo.common.humble import INCLUDED_URL_LINE, 
INCLUDED_INSTEAD_OF_LINE, I  from edkrepo.common.humble import 
ERROR_WRITING_INCLUDE, MULTIPLE_SOURCE_ATTRIBUTES_SPECIFIED
 from edkrepo.common.humble import VERIFY_GLOBAL, VERIFY_ARCHIVED, VERIFY_PROJ, 
VERIFY_PROJ_FAIL  from edkrepo.common.humble import VERIFY_PROJ_NOT_IN_INDEX, 
VERIFY_GLOBAL_FAIL
+from edkrepo.common.humble import SUBMODULE_DEINIT_FAILED
 from edkrepo.common.pathfix import get_actual_path  from project_utils.sparse 
import BuildInfo, process_sparse_checkout  from edkrepo.config.config_factory 
import get_workspace_path @@ -523,7 +524,12 @@ def checkout(combination_or_sha, 
verbose=False, override=False, log=None):
 # Deinit all submodules due to the potential for issues when switching
 # branches.
 if combo_or_sha != manifest.general_config.current_combo:
-deinit_full(workspace_path, manifest, verbose)
+try:
+deinit_full(workspace_path, manifest, verbose)
+except Exception as e:
+print(SUBMODULE_DEINIT_FAILED)
+if verbose:
+print(e)
 
 print(CHECKING_OUT_COMBO.format(combo_or_sha))
 
diff --git a/edkrepo/common/humble.py b/edkrepo/common/humble.py index 
f905357..763b9a6 100644
--- a/edkrepo/common/humble.py
+++ b/edkrepo/common/humble.py
@@ -155,3 +155,6 @@ BRANCH = 'Branch : {0}'
 COMMIT = 'Commit Id: {0}'
 WRITING_PIN_FILE = 'Writing pin file to {0} ...'
 COMMIT_MESSAGE = 'Pin file for project: {0} \nPin Description: {1}'
+
+# Common submodule error messages
+SUBMODULE_DEINIT_FAILED = 'Warning: Unable to remove all submodule content'
--
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63164): https://edk2.groups.io/g/devel/message/63164
Mute This Topic: https://groups.io/mt/75730839/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] A problem to build KabyLake

2020-07-22 Thread Nate DeSimone
Hi Canh,

To build KabyLake please use edk2-platforms/Platform/Intel/build_bios.py

Debug Build: build_bios.py -p KabylakeRvp3 -d
Release Build: build_bios.py -p KabylakeRvp3 -r

Thanks,
Nate

From: devel@edk2.groups.io  On Behalf Of Canh Kha
Sent: Wednesday, July 22, 2020 8:32 AM
To: Jiang, Guomin 
Cc: devel@edk2.groups.io
Subject: Re: [edk2-devel] A problem to build KabyLake

Hi Guomin,

Yes, I also have the same file as you do
>dir 
>C:\minnow\edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include\PreMemory.fdf
 Volume in drive C is OS
 Volume Serial Number is CCF3-B399

 Directory of C:\minnow\edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include

07/11/2020  03:26 PM 1,779 PreMemory.fdf
   1 File(s)  1,779 bytes

But for some reason, the script seems looking for it from a different directory.
Thank you,
Canh

On Wed, Jul 22, 2020 at 5:47 AM Jiang, Guomin 
mailto:guomin.ji...@intel.com>> wrote:
 It confuse me that near line 60, column 0:   !include 
LogoFeaturePkg/Include/PreMemory.fdf.

In my local machine, the PreMemory.fdf should be 
AdvancedFeaturePkg/Include/PreMemory.fdf,

I can also find this file in directory 
edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include.

Please confirm it.

Thanks.
Guomin
From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Canh Kha
Sent: Wednesday, July 22, 2020 1:13 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] A problem to build KabyLake

Hi,
When I ran this build command
build -a IA32 -a X64 -n 5 -t VS2015x86 -b DEBUG -p 
KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc
I received the following message

build.py...
 : error C0DE: Unknown fatal error when processing 
[c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc]

(Please send email to devel@edk2.groups.io for 
help, attaching following call stack trace!)

(Python 3.8.3 on win32) Traceback (most recent call last):
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2636, in 
Main
MyBuild.Launch()
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2431, in 
Launch
self._MultiThreadBuildPlatform()
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2238, in 
_MultiThreadBuildPlatform
Wa, self.BuildModules = self.PerformAutoGen(BuildTarget,ToolChain)
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2088, in 
PerformAutoGen
Wa = WorkspaceAutoGen(
  File "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", 
line 43, in __init__
self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args, 
**kwargs)
  File "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", 
line 112, in _InitWorker
self.ProcessModuleFromPdf()
  File "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", 
line 188, in ProcessModuleFromPdf
if self.FdfProfile:
  File "C:\minnow\edk2\BaseTools\Source\Python\Common\caching.py", line 28, in 
__get__
Value = obj.__dict__[self._function.__name__] = self._function(obj)
  File "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", 
line 164, in FdfProfile
Fdf.ParseFile()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line 1312, 
in ParseFile
self.Preprocess()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line 1291, 
in Preprocess
self.PreprocessIncludeFile()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line 624, 
in PreprocessIncludeFile
raise Warning("The include file does not exist under below directories: 
\n%s\n%s\n%s\n"%(os.path.dirname(self.FileName), PlatformDir, 
GlobalData.gWorkspace),
GenFds.FdfParser.Warning: The include file does not exist under below 
directories:
c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3
c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3
c:\minnow
 near line 60, column 0:   !include LogoFeaturePkg/Include/PreMemory.fdf



- Failed -
Build end time: 00:01:19, Jul.22 2020
Build total time: 00:00:00

This is my PACKAGES_PATH
C:\minnow\edk2;C:\minnow\edk2-platforms\Silicon\Intel;C:\minnow\edk2-platforms\Platform\Intel;;C:\minnow\edk2-platforms\Features\Intel;C:\minnow\edk2-non-osi\Silicon\Intel;C:\minnow\FSP
Could you help to give me some suggestions to try?
Thanks,
Canh


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63163): https://edk2.groups.io/g/devel/message/63163
Mute This Topic: https://groups.io/mt/75721822/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] Intel® FSP External Architecture Specification v2.2 Has Been Released

2020-07-22 Thread Nate DeSimone
Hi Everyone,

We are pleased to announce that the FSP External Architecture Specification 
v2.2 has been posted to https://www.intel.com/fsp! 

Highlights

* Multi-Phase Silicon Initialization – A new optional API has been added to 
FSP-S to address some of the ongoing community feedback surrounding FSP-S. In 
general, the feedback has been that FSP-S is too monolithic. FspSiliconInit() 
does a large amount of initialization in one API call; so much that it has made 
integration difficult in some cases. For example, firmware update/recovery 
flows. To address this, a new FspMultiPhaseSiInit() API has been added which 
splits FSP-S into multiple parts. This allows the bootloader to add board 
specific code throughout the SiliconInit flow as needed. The breakdown of 
silicon initialization steps may vary per product and will be detailed in the 
Integration Guide. FspMultiPhaseSiInit() is only used in API mode. In dispatch 
mode, equivalent functionality can be achieved using PPIs with less complexity.

* FSP Event Handlers – This new feature enables FSP to generate events messages 
to aid in the debugging of firmware issues. This eliminates the need for FSP to 
directly write debug messages to the UART. Instead FSP signals the bootloader 
to inform it of a new debug message. This allows the bootloader to provide 
board specific methods of reporting debug messages beyond the UART. This brings 
feature parity between dispatch mode and API mode as FSP 2.1 defined a similar 
method for dispatch mode.

This change also helps dispatch mode as well. Since it provides a means for 
FSP-T and early PEI to output debug message before the status code services 
PEIMs are initialized.

Roadmap

TigerLakeFspBinPkg provides the first implementation of FSP 2.2. Tiger Lake FSP 
implements 2 phases for FSP-S: FspSiliconInit() will return after TCSS (“Type-C 
Sub System” – Integrated USB-C & Thunderbolt 4) initialization is complete. The 
second phase, invoked by FspMultiPhaseSiInit(), will initialize the graphics 
framebuffer and lock SAI/SPI writes. This allows board specific USB-C 
programming to be done before FSP attempts to start early video, and also 
provides a potentially convenient location for firmware update flows. Looking 
forward, our upcoming Alder Lake platform will also have FSP 2.2 support.

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63162): https://edk2.groups.io/g/devel/message/63162
Mute This Topic: https://groups.io/mt/75736394/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 10/10] MdeModulePkg/Core: Avoid redundant shadow when enable the Migrated PCD (CVE-2019-11098)

2020-07-22 Thread Laszlo Ersek
On 07/22/20 10:36, Guomin Jiang wrote:
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
>
> When PcdMigrateTemporaryRamFirmwareVolumes is TRUE, it will shadow the
> PEIMs, when it is disabled, PEIMs marked REGISTER_FOR_SHADOW will be
> shadowed as well and it is controled by PcdShadowPeimOnBoot and
> PcdShadowPeimOnS3Boot.
>
> To cover the shadow behavior, the change will always shadow PEIMs when
> enable PcdMigrateTemporaryRamFirmwareVolumes.
>
> When PcdMigrateTemporaryRamFirmwareVolumes is true, if enable
> PcdShadowPeimOnBoot or PcdShadowPeimOnS3Boot, it will shadow some PEIMs
> twice and occupy more memory and waste more boot time, it is unnecessary,
> so the only valid choice is to enable PcdMigrateTemporaryRamFirmwareVolumes
> and disable PcdShadowPeimOnBoot and PcdShadowPeimOnS3Boot.
>
> Signed-off-by: Guomin Jiang 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Cc: Dandan Bi 
> Cc: Liming Gao 
> Cc: Debkumar De 
> Cc: Harry Han 
> Cc: Catharine West 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 11 +---
>  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 14 +++---
>  MdeModulePkg/Core/Pei/Image/Image.c   |  6 ++---
>  MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   | 26 +++
>  4 files changed, 42 insertions(+), 15 deletions(-)

(1) This patch should be split, and the parts coming out of it should be
squashed into:

- patch#1 ("MdeModulePkg: Add new PCD to control the evacuate temporary
memory feature"),

- and patch#2 ("MdeModulePkg/PeiCore: Enable T-RAM evacuation in
PeiCore").

It's wrong to introduce a feature with a known bug in one patch of a
series, and then fix it separately in a later patch in the same series.
If the bug is known in the earlier patch, at the time of posting the
series, then the earlier patch should be updated to *not* introduce the
bug in the first place.

Note: when you do the above squashing, you're going to modify both
patches #1 and #2 significantly, so you'll have to drop all feedback
tags from them (received thus far), and reviewers will have to re-check
both of those patches.


>
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index e0ad9373e62f..5220202b233b 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1223,11 +1223,14 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
># @Prompt Shadow Peim and PeiCore on boot
>gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|TRUE|BOOLEAN|0x30001029
>
> -  ## Enable the feature that evacuate temporary memory to permanent memory 
> or not
> +  ## Enable the feature that evacuate temporary memory to permanent memory 
> or not
>#  Set FALSE as default, if the developer need this feature to avoid this 
> vulnerability, please
> -  #  enable it in dsc file.
> -  #  TRUE - Evacuate temporary memory, the actions include copy memory, 
> convert PPI pointers and so on.
> -  #  FALSE - Do nothing, for example, no copy memory, no convert PPI 
> pointers and so on.
> +  #  enable it and disable PcdShadowPeimOnBoot and PcdShadowPeimOnS3Boot in 
> dsc file at the same time.
> +  #  The reason is that PcdMigrateTemporaryRamFirmwareVolumes will make all 
> PEIMs be shadowed and
> +  #  it is unnecessary that shadow PEIMs which is controled by 
> PcdShadowPeimOnBoot and PcdShadowPeimOnS3Boot
> +  #  again, it will occupy more memory and waste more time if you enable 
> it.
> +  #  TRUE - Evacuate temporary memory, the actions include copy memory, 
> convert PPI pointers and so on.
> +  #  FALSE - Do nothing, for example, no copy memory, no convert PPI 
> pointers and so on.
># @Prompt Evacuate temporary memory to permanent memory
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE|BOOLEAN|0x3000102A
>

So yes, this belongs in patch#1.

The rest of the updates should go into patch#2.

> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index 667d9273bb91..11ff5e693304 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -1408,7 +1408,11 @@ PeiDispatcher (
>PeimFileHandle = NULL;
>EntryPoint = 0;
>
> -  if ((Private->PeiMemoryInstalled) && 
> (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME || 
> PcdGetBool (PcdShadowPeimOnS3Boot))) {
> +  if ((Private->PeiMemoryInstalled) &&
> +  (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)
> +   || (Private->HobList.HandoffInformationTable->BootMode != 
> BOOT_ON_S3_RESUME)
> +   || PcdGetBool (PcdShadowPeimOnS3Boot))
> +) {
>  //
>  // Once real memory is available, shadow the RegisterForShadow modules. 
> And meanwhile
>  // update the modules' status from PEIM_STATE_REGISTER_FOR_SHADOW to 
> PEIM_STATE_DONE.

(2) The arrangement of the || operators is not idiomatic.

It should be:

  if (Private->PeiMemoryInstalled &&
  (PcdGetBool (PcdMigrateTemporaryRamFi

Re: [edk2-devel] [PATCH v5 2/9] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098)

2020-07-22 Thread Laszlo Ersek
On 07/13/20 08:38, Wang, Jian J wrote:
>> +VOID
>> +ConvertStatusCodeCallbacks (
>> +  IN  UINTN   OrgFvHandle,
>> +  IN  UINTN   FvHandle,
>> +  IN  UINTN   FvSize
>> +  )
>> +{
>> +  EFI_PEI_HOB_POINTERSHob;
>> +  UINTN   *NumberOfEntries;
>> +  UINTN   *CallbackEntry;
>> +  UINTN   Index;
>> +
>> +  Hob.Raw  = GetFirstGuidHob (&gStatusCodeCallbackGuid);
>> +  while (Hob.Raw != NULL) {
>> +NumberOfEntries = GET_GUID_HOB_DATA (Hob);
>> +CallbackEntry   = NumberOfEntries + 1;
>> +for (Index = 0; Index < *NumberOfEntries; Index++) {
>> +  if (((VOID *) CallbackEntry[Index]) != NULL) {
>> +if ((CallbackEntry[Index] >= OrgFvHandle) && (CallbackEntry[Index] <
>> (OrgFvHandle + FvSize))) {
>> +  DEBUG ((DEBUG_INFO, "Migrating CallbackEntry[%d] from 0x%08X to ",
>> Index, CallbackEntry[Index]));
> CallbackEntry is defined as pointer to UINTN, which is 4-byte with 32-bit PEI.
> Using %08X might be not a good idea. Suggest to use %p instead.
> 

For portability between 32-bit (such as IA32 and ARM) and 64-bit (such
as X64 and AARCH64), UINTN values should be printed as follows:

- cast them to UINT64
- print them with %Lx or %Lu

In the above message, we have two UINTN objects, Index and
CallbackEntry[Index]. Therefore, all of %d, %X, and %p are wrong. The
proper way is this:

  DEBUG ((
DEBUG_INFO,
"Migrating CallbackEntry[%Lu] from 0x%016Lx to ",
(UINT64)Index,
(UINT64)CallbackEntry[Index]
));

If you want to zero-pad to 8 nibbles only (not 16) on ARM and IA32,
that's possible too. Replace the constant field width "16" with "*", and
pass the field width explicitly, as a parameter:

  DEBUG ((
DEBUG_INFO,
"Migrating CallbackEntry[%Lu] from 0x%0*Lx to ",
(UINT64)Index,
(sizeof CallbackEntry[Index]) * 2,
(UINT64)CallbackEntry[Index]
));

The field width specifier "*" takes an extra parameter, which needs to
be of type UINTN in edk2 (see BasePrintLibSPrintMarker()). The sizeof
operator produces an UINTN.

The following example:

  UINTN Foo;

  Foo = 0xABCD;
  DEBUG ((DEBUG_INFO, "Foo=0x%0*Lx\n", (sizeof Foo) * 2, (UINT64)Foo));

produces the following output on IA32:

  Foo=0xABCD

and on X64:

  Foo=0xABCD

Thanks,
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63160): https://edk2.groups.io/g/devel/message/63160
Mute This Topic: https://groups.io/mt/75390174/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 08/10] UefiCpuPkg: Correct some typos.

2020-07-22 Thread Laszlo Ersek
On 07/22/20 10:36, Guomin Jiang wrote:
> Correct some typos.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Rahul Kumar 
> Signed-off-by: Guomin Jiang 
> Reviewed-by: Laszlo Ersek 
> ---
>  UefiCpuPkg/CpuMpPei/CpuMpPei.h| 2 +-
>  .../Library/CpuExceptionHandlerLib/CpuExceptionCommon.h   | 4 ++--
>  UefiCpuPkg/CpuMpPei/CpuPaging.c   | 4 ++--
>  .../CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c| 4 ++--
>  .../Library/CpuExceptionHandlerLib/SecPeiCpuException.c   | 2 +-
>  .../Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c | 4 ++--
>  6 files changed, 10 insertions(+), 10 deletions(-)

Identical to v5, so my R-b stands.

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63159): https://edk2.groups.io/g/devel/message/63159
Mute This Topic: https://groups.io/mt/75720853/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 07/10] UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU (CVE-2019-11098)

2020-07-22 Thread Laszlo Ersek
On 07/22/20 10:36, Guomin Jiang wrote:
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
> 
> To avoid the TOCTOU, enable paging and set Not Present flag so when
> access any code in the flash range, it will trigger #PF exception.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Rahul Kumar 
> Signed-off-by: Guomin Jiang 
> Acked-by: Laszlo Ersek 
> Reviewed-by: Jian J Wang 
> ---
>  UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  3 +++
>  UefiCpuPkg/CpuMpPei/CpuPaging.c  | 32 +++-
>  2 files changed, 30 insertions(+), 5 deletions(-)

Commit message and comment wording fixes, plus updated formatting for
the local variable definitions. (Relative to v5.) My A-b stands.

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63158): https://edk2.groups.io/g/devel/message/63158
Mute This Topic: https://groups.io/mt/75720852/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 05/10] MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-22 Thread Laszlo Ersek
On 07/22/20 10:36, Guomin Jiang wrote:
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
> 
> When we allocate pool to save the rebased PEIMs, the address will change
> randomly, therefore the hash will change and result PCR0 change as well.
> To avoid this, we save the raw PEIMs and use it to calculate hash.
> 
> The MigratedFvInfo HOB will never produce when
> PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD control
> the total feature.
> 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Cc: Dandan Bi 
> Cc: Liming Gao 
> Cc: Debkumar De 
> Cc: Harry Han 
> Cc: Catharine West 
> Signed-off-by: Guomin Jiang 
> Acked-by: Laszlo Ersek 
> Reviewed-by: Jian J Wang 
> ---
>  MdeModulePkg/MdeModulePkg.dec |  3 ++
>  MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
>  MdeModulePkg/Core/Pei/PeiMain.h   |  1 +
>  MdeModulePkg/Include/Guid/MigratedFvInfo.h| 22 +++
>  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 28 +++
>  5 files changed, 55 insertions(+)
>  create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h

Comment fixes only (relative to v5); my A-b stands.

Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63157): https://edk2.groups.io/g/devel/message/63157
Mute This Topic: https://groups.io/mt/75720850/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 04/10] UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

2020-07-22 Thread Laszlo Ersek
On 07/22/20 10:36, Guomin Jiang wrote:
> From: Michael Kubacki 
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
> 
> Adds a PEIM that republishes structures produced in SEC. This
> is done because SEC modules may not be shadowed in some platforms
> due to space constraints or special alignment requirements. The
> SecMigrationPei module locates interfaces that may be published in
> SEC and reinstalls the interface with permanent memory addresses.
> 
> This is important if pre-memory address access is forbidden after
> memory initialization and data such as a PPI descriptor, PPI GUID,
> or PPI inteface reside in pre-memory.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Rahul Kumar 
> Cc: Debkumar De 
> Cc: Harry Han 
> Cc: Catharine West 
> Signed-off-by: Michael Kubacki 
> Acked-by: Laszlo Ersek 
> ---
>  UefiCpuPkg/UefiCpuPkg.dec |   3 +
>  UefiCpuPkg/UefiCpuPkg.dsc |   1 +
>  UefiCpuPkg/SecCore/SecCore.inf|   2 +
>  .../SecMigrationPei/SecMigrationPei.inf   |  67 +++
>  UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
>  UefiCpuPkg/SecCore/SecMain.h  |   1 +
>  UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 158 +++
>  UefiCpuPkg/SecCore/SecMain.c  |  26 +-
>  UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 385 ++
>  .../SecMigrationPei/SecMigrationPei.uni   |  13 +
>  10 files changed, 708 insertions(+), 2 deletions(-)
>  create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
>  create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
>  create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
>  create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
>  create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni
> 
> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
> index 762badf5d239..8b2e03d49d07 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dec
> +++ b/UefiCpuPkg/UefiCpuPkg.dec
> @@ -84,6 +84,9 @@ [Ppis]
>## Include/Ppi/ShadowMicrocode.h
>gEdkiiPeiShadowMicrocodePpiGuid = { 0x430f6965, 0x9a69, 0x41c5, { 0x93, 
> 0xed, 0x8b, 0xf0, 0x64, 0x35, 0xc1, 0xc6 }}
>  
> +  ## Include/Ppi/RepublishSecPpi.h
> +  gRepublishSecPpiPpiGuid   = { 0x27a71b1e, 0x73ee, 0x43d6, { 0xac, 0xe3, 
> 0x52, 0x1a, 0x2d, 0xc5, 0xd0, 0x92 }}
> +
>  [PcdsFeatureFlag]
>## Indicates if SMM Profile will be enabled.
>#  If enabled, instruction executions in and data accesses to memory 
> outside of SMRAM will be logged.
> diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
> index afa304128221..964720048dd7 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dsc
> +++ b/UefiCpuPkg/UefiCpuPkg.dsc
> @@ -146,6 +146,7 @@ [Components.IA32, Components.X64]
>UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
>UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
>UefiCpuPkg/SecCore/SecCore.inf
> +  UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
>UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
>UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
>  
> diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
> index 0562820c95e0..545781d6b4b3 100644
> --- a/UefiCpuPkg/SecCore/SecCore.inf
> +++ b/UefiCpuPkg/SecCore/SecCore.inf
> @@ -68,6 +68,8 @@ [Ppis]
>## SOMETIMES_CONSUMES
>gPeiSecPerformancePpiGuid
>gEfiPeiCoreFvLocationPpiGuid
> +  ## CONSUMES
> +  gRepublishSecPpiPpiGuid
>  
>  [Guids]
>## SOMETIMES_PRODUCES   ## HOB
> diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf 
> b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
> new file mode 100644
> index ..f4c2f6b658fb
> --- /dev/null
> +++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
> @@ -0,0 +1,67 @@
> +## @file
> +#  Migrates SEC structures after permanent memory is installed.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = SecMigrationPei
> +  MODULE_UNI_FILE= SecMigrationPei.uni
> +  FILE_GUID  = 58B35361-8922-41BC-B313-EF7ED9ADFDF7
> +  MODULE_TYPE= PEIM
> +  VERSION_STRING = 1.0
> +  ENTRY_POINT= SecMigrationPeiInitialize
> +
> +#
> +# The following information is for reference only and not required by the 
> build tools.
> +#
> +#  VALID_ARCHITECTURES   = IA32 X64 EBC
> +#
> +
> +[Sources]
> +  SecMigrationPei.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  UefiCpuPkg/UefiCpuPkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  BaseMemoryLib
> +  DebugLib
> +  HobLib
> +  MemoryAllocationLib
> +  PeimEntryPoint
> +  PeiServicesLib
> +  PeiServicesTablePointerLib
> +
> +[Ppis]
> +  ## PRODUCES
> +  gRepublishSecPpiPpiGuid
> +
> +  ## SOMETIMES_PRODUCES
> +  gEfiTemporaryRamDonePpiGui

Re: [edk2-devel] [PATCH v7 03/10] UefiCpuPkg/CpuMpPei: Add GDT migration support (CVE-2019-11098)

2020-07-22 Thread Laszlo Ersek
On 07/22/20 10:36, Guomin Jiang wrote:
> From: Michael Kubacki 
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
> 
> Moves the GDT to permanent memory in a memory discovered
> callback. This is done to ensure the GDT authenticated in
> pre-memory is not fetched from outside a verified location
> after the permanent memory transition.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Rahul Kumar 
> Signed-off-by: Michael Kubacki 
> Reviewed-by: Laszlo Ersek 
> Reviewed-by: Jian J Wang 
> ---
>  UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  1 +
>  UefiCpuPkg/CpuMpPei/CpuMpPei.h   | 12 +++
>  UefiCpuPkg/CpuMpPei/CpuMpPei.c   | 37 
>  UefiCpuPkg/CpuMpPei/CpuPaging.c  | 12 +--
>  4 files changed, 60 insertions(+), 2 deletions(-)

I see that the IDT references have been removed from the subject and the
commit message (relative to v5), so my R-b stands.

Thanks!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63155): https://edk2.groups.io/g/devel/message/63155
Mute This Topic: https://groups.io/mt/75720848/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 01/10] MdeModulePkg: Add new PCD to control the evacuate temporary memory feature (CVE-2019-11098)

2020-07-22 Thread Laszlo Ersek
On 07/22/20 10:36, Guomin Jiang wrote:
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
> 
> The security researcher found that we can get control after NEM disable.
> 
> The reason is that the flash content reside in NEM at startup and the
> code will get the content from flash directly after disable NEM.
> 
> To avoid this vulnerability, the feature will copy the PEIMs from
> temporary memory to permanent memory and only execute the code in
> permanent memory.
> 
> The vulnerability is exist in physical platform and haven't report in
> virtual platform, so the virtual can disable the feature currently.
> 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Signed-off-by: Guomin Jiang 
> Acked-by: Laszlo Ersek 
> Reviewed-by: Jian J Wang 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 8 
>  MdeModulePkg/MdeModulePkg.uni | 6 ++
>  2 files changed, 14 insertions(+)

Comparing this against v5 (which I last checked), my ACK stands.

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63153): https://edk2.groups.io/g/devel/message/63153
Mute This Topic: https://groups.io/mt/75720846/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 02/10] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098)

2020-07-22 Thread Laszlo Ersek
On 07/22/20 10:36, Guomin Jiang wrote:
> From: Michael Kubacki 
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
> 
> Introduces new changes to PeiCore to move the contents of temporary
> RAM visible to the PeiCore to permanent memory. This expands on
> pre-existing shadowing support in the PeiCore to perform the following
> additional actions:
> 
>  1. Migrate pointers in PPIs installed in PeiCore to the permanent
> memory copy of PeiCore.
> 
>  2. Copy all installed firmware volumes to permanent memory.
> 
>  3. Relocate and fix up the PEIMs within the firmware volumes.
> 
>  4. Convert all PPIs into the migrated firmware volume to the corresponding
> PPI address in the permanent memory location.
> 
> This applies to PPIs and PEI notifications.
> 
>  5. Convert all status code callbacks in the migrated firmware volume to
> the corresponding address in the permanent memory location.
> 
>  6. Update the FV HOB to the corresponding firmware volume in permanent
> memory.
> 
>  7. Add PcdMigrateTemporaryRamFirmwareVolumes to control if enable the
> feature or not. when the PCD disable, the EvacuateTempRam() will
> never be called.
> 
> The function control flow as below:
>   PeiCore()
> DumpPpiList()
> EvacuateTempRam()
>   ConvertPeiCorePpiPointers()
> ConvertPpiPointersFv()
>   MigratePeimsInFv()
> MigratePeim()
>   PeiGetPe32Data()
>   LoadAndRelocatePeCoffImageInPlace()
>   MigrateSecModulesInFv()
>   ConvertPpiPointersFv()
>   ConvertStatusCodeCallbacks()
>   ConvertFvHob()
>   RemoveFvHobsInTemporaryMemory()
> DumpPpiList()
> 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Cc: Dandan Bi 
> Cc: Liming Gao 
> Cc: Debkumar De 
> Cc: Harry Han 
> Cc: Catharine West 
> Signed-off-by: Michael Kubacki 
> Acked-by: Laszlo Ersek 
> ---
>  MdeModulePkg/Core/Pei/PeiMain.inf |   2 +
>  MdeModulePkg/Core/Pei/PeiMain.h   | 169 
>  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 392 ++
>  MdeModulePkg/Core/Pei/Image/Image.c   | 116 ++
>  MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
>  MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  24 ++
>  MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 +
>  7 files changed, 1072 insertions(+)

I've reviewed this incrementally against v5, which I had ACKed.

My ACK stands.

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63154): https://edk2.groups.io/g/devel/message/63154
Mute This Topic: https://groups.io/mt/75720847/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer arithmetic

2020-07-22 Thread Andrew Fish via groups.io
Leif,

I also noticed we would need this flag for clang/Xcode too. 

~/work/Compiler>clang -S void.c
~/work/Compiler>clang -S void.c -Wpointer-arith
void.c:4:14: warning: arithmetic on a pointer to void is a GNU extension
  [-Wpointer-arith]
  return Arg + 1;
 ~~~ ^
1 warning generated.
~/work/Compiler>cat void.c
void *
Test (void *Arg)
{
  return Arg + 1;
}

Thanks,

Andrew Fish

> On Jul 22, 2020, at 11:05 AM, Leif Lindholm  wrote:
> 
> Hi Bob,
> 
> This patch also breaks about half of the ARM/AARCH64 platforms in
> edk2-platforms. I agree it should go in at a later stage, but for now,
> can we please revert it?
> 
> Regards,
> 
> Leif
> 
> On Mon, Jul 20, 2020 at 04:10:27 +, Bob Feng wrote:
>> Reviewed-by: Bob Feng
>> 
>> 
>> -Original Message-
>> From: PierreGondois  
>> Sent: Tuesday, July 7, 2020 4:35 PM
>> To: devel@edk2.groups.io
>> Cc: Pierre Gondois ; Feng, Bob C 
>> ; Gao, Liming ; 
>> tomas.pi...@arm.com; n...@arm.com
>> Subject: [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer 
>> arithmetic
>> 
>> From: Pierre Gondois 
>> 
>> By default, gcc allows void* pointer arithmetic.
>> This is a GCC extension.
>> However:
>> - the C reference manual states that void*
>>   pointer "cannot be operands of addition
>>   or subtraction operators". Cf s5.3.1
>>   "Generic Pointers";
>> - Visual studio compiler treat such operation as
>>   an error.
>> 
>> To prevent such pointer arithmetic, the "-Wpointer-arith"
>> flag should be set for all GCC versions.
>> 
>> The "-Wpointer-arith"  allows to:
>>  "Warn about anything that depends on the "size of"
>>  a function type or of void. GNU C assigns these
>>  types a size of 1, for convenience in calculations
>>  with void * pointers and pointers to functions."
>> 
>> This flag is available since GCC2.95.3 which came out in 2001.
>> 
>> Signed-off-by: Pierre Gondois 
>> ---
>> 
>> The changes can be seen at: 
>> https://github.com/PierreARM/edk2/commits/831_Add_gcc_flag_warning_v2
>> 
>> Notes:
>>v1:
>> - Add "-Wpointer-arith" gcc flag. [Pierre]
>>v2:
>> - Only add the flag for ARM and AARCH64. [Tomas]
>> 
>> BaseTools/Conf/tools_def.template | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/BaseTools/Conf/tools_def.template 
>> b/BaseTools/Conf/tools_def.template
>> index 
>> 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..397b011ba38f97f81f314f8641ac8bb95d5a2197
>>  100755
>> --- a/BaseTools/Conf/tools_def.template
>> +++ b/BaseTools/Conf/tools_def.template
>> @@ -1,7 +1,7 @@
>> #
>> #  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.  # 
>>  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. -#  
>> Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.
>> +#  Portions copyright (c) 2011 - 2020, ARM Ltd. All rights 
>> +reserved.
>> #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.  #  (C) 
>> Copyright 2020, Hewlett Packard Enterprise Development LP  #  Copyright 
>> (c) Microsoft Corporation
>> @@ -1921,9 +1921,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
>> --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N
>> DEFINE GCC_ALL_CC_FLAGS= -g -Os -fshort-wchar -fno-builtin 
>> -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h 
>> -fno-common
>> DEFINE GCC_IA32_CC_FLAGS   = DEF(GCC_ALL_CC_FLAGS) -m32 
>> -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 
>> -mno-stack-arg-probe
>> DEFINE GCC_X64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mno-red-zone 
>> -Wno-address -mno-stack-arg-probe
>> -DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
>> -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections 
>> -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft 
>> -fno-pic -fno-pie
>> +DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
>> -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char 
>> -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address 
>> -mthumb -mfloat-abi=soft -fno-pic -fno-pie
>> DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
>> -DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
>> -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections 
>> -fdata-sections -Wno-address -fno-asynchronous-unwind-tables 
>> -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
>> +DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
>> -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char 
>> -ffunction-sections -fdata-sections -Wno-address 
>> -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie 
>> -ffixed-x18
>> DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
>> DEFINE GCC_DLINK_FLAGS_COMMON  = -nostdlib --pie
>> DEFINE GCC_DLINK2_FLAGS_COMMON = 
>> -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
>> --
>> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)

Re: [edk2-devel] [PATCH v1 2/2] EmbeddedPkg: Add cast from (void*) for VS2017 build

2020-07-22 Thread Laszlo Ersek
On 07/22/20 17:35, Leif Lindholm wrote:
> On Tue, Jun 30, 2020 at 11:49:01 +0100, PierreGondois wrote:
>> From: Pierre Gondois 
>>
>> The following build configrations:
>> build -b DEBUG -a AARCH64 -t VS2017 -p edk2\EmbeddedPkg\EmbeddedPkg.dsc
>> build -b NOOPT -a AARCH64 -t VS2017 -p edk2\EmbeddedPkg\EmbeddedPkg.dsc
>> build -b RELEASE -a AARCH64 -t VS2017 -p edk2\EmbeddedPkg\EmbeddedPkg.dsc
>>
>> are generating the following build errors:
>> edk2\EmbeddedPkg\Library\AndroidBootImgLib\AndroidBootImgLib.c(100):
>> error C2036: 'void *': unknown size
>> edk2\EmbeddedPkg\Library\AndroidBootImgLib\AndroidBootImgLib.c(347):
>> error C2036: 'void *': unknown size
>>
>> Since the size of void* depends on the architecture, it can be
>> dangerous to use void* pointer arithmetic. Plus the C99 doesn't state
>> that void* pointer arithmetic is allowed.
>> This patch adds a cast to fix the Visual Studio errors reported.
>>
>> Signed-off-by: Pierre Gondois 
>> ---
>>
>> The changes can be seen at: 
>> https://github.com/PierreARM/edk2/commits/831_Fix_VS2017_build_error_v1
>>
>> Notes:
>> v1:
>>  - Fix VS2017 build errors. [Pierre]
>>
>>  EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c | 13 -
>>  1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
>> b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
>> index 
>> e1036954ee586dfc30266eec2897d71bfc949038..bbe0d41018b3d5665c72ee61efe737ae57b1b2eb
>>  100644
>> --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
>> +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
>> @@ -1,6 +1,6 @@
>>  /** @file
>>
>> -  Copyright (c) 2013-2014, ARM Ltd. All rights reserved.
>> +  Copyright (c) 2013-2020, ARM Ltd. All rights reserved.
>>Copyright (c) 2017, Linaro. All rights reserved.
>>
>>SPDX-License-Identifier: BSD-2-Clause-Patent
>> @@ -97,7 +97,7 @@ AndroidBootImgGetKernelInfo (
>>ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize));
>>
>>*KernelSize = Header->KernelSize;
>> -  *Kernel = BootImg + Header->PageSize;
>> +  *Kernel = (UINT8*)BootImg + Header->PageSize;
>
> The reason I prefer my version, although this one would also solve the
> compilation error, is that I really don't like casts to char * (which
> this effectively is) as a workaround.
>
> The problem I have with it is that a cast is a signal of intent (this
> thing that we have been viewing as an X should now be seen as a Y) -
> and the intent here is simply to get the side effect that a char has a
> known size of 1 (whereas a void doesn't).
> I will admit it is the first time I have seen it used for this purpose
> :)

Personally I'd be OK with either fix (yours or Pierre's); to me both
express the exact same thing -- move Header->PageSize bytes past
BootImg.

Viewed from a portability perspective, Pierre's patch is actually more
portable (per C standard); as UINT8 stands for "unsigned char", and that
is called "object representation" by the C standard:

> 6.2.6 Representations of types
> 6.2.6.1 General
>
> 3 Values stored in unsigned bit-fields and objects of type unsigned
>   char shall be represented using a pure binary notation. (Footnote
>   40.)
>
> 4 Values stored in non-bit-field objects of any other object type
>   consist of n * CHAR_BIT bits, where n is the size of an object of
>   that type, in bytes. The value may be copied into an object of type
>   unsigned char [n] (e.g., by memcpy); the resulting set of bytes is
>   called the object representation of the value.
>
> Footnote 40: [...] A byte contains CHAR_BIT bits, and the values of
>  type unsigned char range from 0 to (2^CHAR_BIT)-1.

Further references:

> 6.2.5 Types
>
> 27 A pointer to void shall have the same representation and alignment
>requirements as a pointer to a character type. Footnote 39 [...]
>
> Footnote 39: The same representation and alignment requirements are
>  meant to imply interchangeability as arguments to
>  functions, return values from functions, and members of
>  unions.

> 6.3.2.3 Pointers
>
> 7 [...] When a pointer to an object is converted to a pointer to a
>   character type, the result points to the lowest addressed byte of
>   the object. Successive increments of the result, up to the size of
>   the object, yield pointers to the remaining bytes of the object.

> 6.5 Expressions
>
> 6 The effective type of an object for an access to its stored value is
>   the declared type of the object, if any. (Footnote 75.) [...] If a
>   value is copied into an object having no declared type using memcpy
>   or memmove, or is copied as an array of character type, then the
>   effective type of the modified object for that access and for
>   subsequent accesses that do not modify the value is the effective
>   type of the object from which the value is copied, if it has one.

> Footnote 75: Allocated objects have no declared

[edk2-devel] [PATCH v2 0/2] Enable HttpDynamicCommand for ArmVirtPkg and OvmfPkg

2020-07-22 Thread Vladimir Olovyannikov via groups.io
Hi,

This patchset enables HttpDynamicCommand (Shell command "http") which can be
used on ArmVirt and Ovmf platforms. HttpDynamicCommand needs to be available
in the tree before this patchset can be applied. The patchset needs to
be tested on both platforms.

PATCH v2 patchset addresses comments from Laszlo:
 - mention BZ id in commit message;
 - remove the extra whitespace in dsc files;
 - add the new module to OvmfPkg/ArmVirPkg fdf files.

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

Thank you,
Vladimir
Vladimir Olovyannikov (2):
  ArmVirtPkg: enable HttpDynamiCommand
  OvmfPkg: enable HttpDynamicCommand

 ArmVirtPkg/ArmVirt.dsc.inc   | 4 
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 +
 ArmVirtPkg/ArmVirtXen.fdf| 1 +
 OvmfPkg/OvmfPkgIa32.dsc  | 4 
 OvmfPkg/OvmfPkgIa32.fdf  | 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc   | 4 
 OvmfPkg/OvmfPkgIa32X64.fdf   | 1 +
 OvmfPkg/OvmfPkgX64.dsc   | 4 
 OvmfPkg/OvmfPkgX64.fdf   | 1 +
 OvmfPkg/OvmfXen.dsc  | 4 
 OvmfPkg/OvmfXen.fdf  | 1 +
 11 files changed, 26 insertions(+)

--
2.26.2.266.ge870325ee8


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63148): https://edk2.groups.io/g/devel/message/63148
Mute This Topic: https://groups.io/mt/75733795/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 2/2] OvmfPkg: enable HttpDynamicCommand

2020-07-22 Thread Vladimir Olovyannikov via groups.io
Enable HttpDynamicCommand (Shell command "http") for OvmfPkg platforms.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2857

Signed-off-by: Vladimir Olovyannikov 
---
 OvmfPkg/OvmfPkgIa32.dsc| 4 
 OvmfPkg/OvmfPkgIa32.fdf| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 4 
 OvmfPkg/OvmfPkgIa32X64.fdf | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 4 
 OvmfPkg/OvmfPkgX64.fdf | 1 +
 OvmfPkg/OvmfXen.dsc| 4 
 OvmfPkg/OvmfXen.fdf| 1 +
 8 files changed, 20 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 9178ffeb71cb..78413e5ecaae 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -883,6 +883,10 @@ [Components]
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
   }
+  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
+
+  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+  }
   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 2b9a6b58015f..c07b775d0a2d 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -293,6 +293,7 @@ [FV.DXEFV]
 
 !if $(TOOL_CHAIN_TAG) != "XCODE5"
 INF  ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
+INF  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
 INF  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
 !endif
 INF  ShellPkg/Application/Shell/Shell.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index a665f78f0dc7..92e08fb8c072 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -897,6 +897,10 @@ [Components.X64]
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
   }
+  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
+
+  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+  }
   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 83ff6aef2e8c..9adf1525c135 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -294,6 +294,7 @@ [FV.DXEFV]
 
 !if $(TOOL_CHAIN_TAG) != "XCODE5"
 INF  ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
+INF  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
 INF  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
 !endif
 INF  ShellPkg/Application/Shell/Shell.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 17f345acf4ee..68ed86ef53ce 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -893,6 +893,10 @@ [Components]
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
   }
+  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
+
+  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+  }
   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 83ff6aef2e8c..9adf1525c135 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -294,6 +294,7 @@ [FV.DXEFV]
 
 !if $(TOOL_CHAIN_TAG) != "XCODE5"
 INF  ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
+INF  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
 INF  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
 !endif
 INF  ShellPkg/Application/Shell/Shell.inf
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 782803cb2787..1ed7176d26c5 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -675,6 +675,10 @@ [Components]
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
   }
+  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
+
+  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+  }
   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
diff --git a/OvmfPkg/OvmfXen.fdf b/OvmfPkg/OvmfXen.fdf
index d9ee14b484a0..c7d4d1853027 100644
--- a/OvmfPkg/OvmfXen.fdf
+++ b/OvmfPkg/OvmfXen.fdf
@@ -363,6 +363,7 @@ [FV.DXEFV]
 
 !if $(TOOL_CHAIN_TAG) != "XCODE5"
 INF  ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
+INF  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
 INF  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
 !endif
 INF  ShellPkg/Application/Shell/Shell.inf
-- 
2.26.2.266.ge870325ee8


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63150): https://edk2.groups.io/g/devel/message/63150
Mute This Topic

[edk2-devel] [PATCH v2 1/2] ArmVirtPkg: enable HttpDynamiCommand

2020-07-22 Thread Vladimir Olovyannikov via groups.io
Enable HttpDynamicCommand (http Shell command)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2857

Signed-off-by: Vladimir Olovyannikov 
---
 ArmVirtPkg/ArmVirt.dsc.inc   | 4 
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 +
 ArmVirtPkg/ArmVirtXen.fdf| 1 +
 3 files changed, 6 insertions(+)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index cf44fc73890b..f39f7e903ff9 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -377,6 +377,10 @@ [Components.common]
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
   }
+  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
+
+  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+  }
   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
 
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc 
b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
index a2f4bd62c846..6eade7e50ff7 100644
--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
+++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
@@ -103,6 +103,7 @@ [FV.FvMain]
   #
   INF ShellPkg/Application/Shell/Shell.inf
   INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
+  INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
   INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
 
   #
diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf
index f708878f4965..8fbbc2313aff 100644
--- a/ArmVirtPkg/ArmVirtXen.fdf
+++ b/ArmVirtPkg/ArmVirtXen.fdf
@@ -182,6 +182,7 @@ [FV.FvMain]
   #
   INF ShellPkg/Application/Shell/Shell.inf
   INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
+  INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
   INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
 
   #
-- 
2.26.2.266.ge870325ee8


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63149): https://edk2.groups.io/g/devel/message/63149
Mute This Topic: https://groups.io/mt/75733798/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v11 06/46] MdePkg/BaseLib: Add support for the XGETBV instruction

2020-07-22 Thread Lendacky, Thomas
On 7/22/20 3:27 PM, Laszlo Ersek wrote:
> On 07/22/20 02:55, Liu, Zhiguang wrote:
>> Hi Tom,
>> Nasm is a cross-OS assembly code and can be used in Linux.
>> So I think we don't need implement the same function in GccInline.c, we can 
>> just use the nasm file in Linux.
> 
> I could agree, but this would create an inconsistency with the existent
> functions (where both gcc inline assembly and NASM exists).
> 
> For example, consider AsmReadEflags():
> - inline assembly for MSFT IA32 ("Ia32/ReadEflags.c")
> - NASM for MSFT X64 ("X64/ReadEflags.nasm")
> - inline assembly for GCC IA32 ("Ia32/GccInline.c")
> - inline assembly for GCC X64 ("X64/GccInline.c")
> 
> The source file "X64/ReadEflags.nasm" could be used with GCC X64 too,
> not just with MSFT X64.
> 
> So why do we have the gcc inline implementation for AsmReadEflags() in
> "X64/GccInline.c", in the first place?
> 
> The pattern that a contributor is supposed to follow is not clear to me.

Thanks for replying Laszlo. For some reason the original email from
Zhiguang has not made it to my inbox. Hopefully it is only delayed vs
going into some bit-bucket in our mail server...

I'll keep an eye out on the edk2.groups.io site to try and not miss anything.

Thanks,
Tom

> 
> Thanks,
> Laszlo
> 
>>> -Original Message-
>>> From: devel@edk2.groups.io  On Behalf Of
>>> Lendacky, Thomas
>>> Sent: Wednesday, July 22, 2020 5:19 AM
>>> To: devel@edk2.groups.io
>>> Cc: Brijesh Singh ; Ard Biesheuvel
>>> ; Dong, Eric ; Justen,
>>> Jordan L ; Laszlo Ersek ;
>>> Gao, Liming ; Kinney, Michael D
>>> ; Ni, Ray 
>>> Subject: [edk2-devel] [PATCH v11 06/46] MdePkg/BaseLib: Add support for
>>> the XGETBV instruction
>>>
>>> From: Tom Lendacky 
>>>
>>> BZ: 
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198&data=02%7C01%7Cthomas.lendacky%40amd.com%7C71ad2ee66be84e95474b08d82e7dbcd7%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637310464865695923&sdata=GRMR9I8VwFIc2NtpOUDBFeoCpy9UgzWidaYEcx1wYfg%3D&reserved=0
>>>
>>> Under SEV-ES, a CPUID instruction requires the current value of the XCR0
>>> register. In order to retrieve that value, the XGETBV instruction needs
>>> to be executed.
>>>
>>> Provide the necessary support to execute the XGETBV instruction.
>>>
>>> Cc: Michael D Kinney 
>>> Cc: Liming Gao 
>>> Signed-off-by: Tom Lendacky 
>>> ---
>>>  MdePkg/Library/BaseLib/BaseLib.inf  |  2 ++
>>>  MdePkg/Include/Library/BaseLib.h| 17 +
>>>  MdePkg/Library/BaseLib/Ia32/GccInline.c | 28 
>>>  MdePkg/Library/BaseLib/X64/GccInline.c  | 30 ++
>>>  MdePkg/Library/BaseLib/Ia32/XGetBv.nasm | 31
>>> ++
>>>  MdePkg/Library/BaseLib/X64/XGetBv.nasm  | 34
>>> +
>>>  6 files changed, 142 insertions(+)
>>>  create mode 100644 MdePkg/Library/BaseLib/Ia32/XGetBv.nasm
>>>  create mode 100644 MdePkg/Library/BaseLib/X64/XGetBv.nasm
>>>
>>> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf
>>> b/MdePkg/Library/BaseLib/BaseLib.inf
>>> index c740a819cacf..e26c0d8cb0ac 100644
>>> --- a/MdePkg/Library/BaseLib/BaseLib.inf
>>> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
>>> @@ -153,6 +153,7 @@ [Sources.Ia32]
>>>Ia32/ARShiftU64.c | MSFT
>>>Ia32/EnableCache.c | MSFT
>>>Ia32/DisableCache.c | MSFT
>>> +  Ia32/XGetBv.nasm | MSFT
>>>
>>>
>>>Ia32/GccInline.c | GCC
>>> @@ -288,6 +289,7 @@ [Sources.X64]
>>>X64/ReadCr2.nasm| MSFT
>>>X64/ReadCr0.nasm| MSFT
>>>X64/ReadEflags.nasm| MSFT
>>> +  X64/XGetBv.nasm | MSFT
>>>
>>>
>>>X64/Non-existing.c
>>> diff --git a/MdePkg/Include/Library/BaseLib.h
>>> b/MdePkg/Include/Library/BaseLib.h
>>> index 8e7b87cbda4e..7edf0051a0a0 100644
>>> --- a/MdePkg/Include/Library/BaseLib.h
>>> +++ b/MdePkg/Include/Library/BaseLib.h
>>> @@ -7831,6 +7831,23 @@ AsmLfence (
>>>VOID
>>>);
>>>
>>> +/**
>>> +  Executes a XGETBV instruction
>>> +
>>> +  Executes a XGETBV instruction. This function is only available on IA-32 
>>> and
>>> +  x64.
>>> +
>>> +  @param[in] IndexExtended control register index
>>> +
>>> +  @return The current value of the extended control 
>>> register
>>> +**/
>>> +UINT64
>>> +EFIAPI
>>> +AsmXGetBv (
>>> +  IN UINT32  Index
>>> +  );
>>> +
>>> +
>>>  /**
>>>Patch the immediate operand of an IA32 or X64 instruction such that the
>>> byte,
>>>word, dword or qword operand is encoded at the end of the instruction's
>>> diff --git a/MdePkg/Library/BaseLib/Ia32/GccInline.c
>>> b/MdePkg/Library/BaseLib/Ia32/GccInline.c
>>> index 6ed938187a08..c2565ab9a183 100644
>>> --- a/MdePkg/Library/BaseLib/Ia32/GccInline.c
>>> +++ b/MdePkg/Library/BaseLib/Ia32/GccInline.c
>>> @@ -584,3 +584,31 @@ AsmReadTsc (
>>>
>>>return Data;
>>>  }
>>> +
>>> +
>>> +/**
>>> +  Executes a XGETBV instruction
>>> +
>>> +  Executes a XGETBV instruction. This function is only available on IA-32 
>>> and
>>> +  x64.
>>> +
>>> +  @param[in] IndexExte

Re: [edk2-devel] [PATCH v11 00/46] SEV-ES guest support

2020-07-22 Thread Lendacky, Thomas
On 7/22/20 3:13 PM, Laszlo Ersek wrote:
> On 07/21/20 23:18, Tom Lendacky wrote:
>> From: Tom Lendacky 
>>
>> This patch series provides support for running EDK2/OVMF under SEV-ES.
>>
>> Secure Encrypted Virtualization - Encrypted State (SEV-ES) expands on the
>> SEV support to protect the guest register state from the hypervisor. See
>> "AMD64 Architecture Programmer's Manual Volume 2: System Programming",
>> section "15.35 Encrypted State (SEV-ES)" [1].
>>
>> In order to allow a hypervisor to perform functions on behalf of a guest,
>> there is architectural support for notifying a guest's operating system
>> when certain types of VMEXITs are about to occur. This allows the guest to
>> selectively share information with the hypervisor to satisfy the requested
>> function. The notification is performed using a new exception, the VMM
>> Communication exception (#VC). The information is shared through the
>> Guest-Hypervisor Communication Block (GHCB) using the VMGEXIT instruction.
>> The GHCB format and the protocol for using it is documented in "SEV-ES
>> Guest-Hypervisor Communication Block Standardization" [2].
>>
>> The main areas of the EDK2 code that are updated to support SEV-ES are
>> around the exception handling support and the AP boot support.
>>
>> Exception support is required starting in Sec, continuing through Pei
>> and into Dxe in order to handle #VC exceptions that are generated.  Each
>> AP requires it's own GHCB page as well as a page to hold values specific
>> to that AP.
>>
>> AP booting poses some interesting challenges. The INIT-SIPI-SIPI sequence
>> is typically used to boot the APs. However, the hypervisor is not allowed
>> to update the guest registers. The GHCB document [2] talks about how SMP
>> booting under SEV-ES is performed.
>>
>> Since the GHCB page must be a shared (unencrypted) page, the processor
>> must be running in long mode in order for the guest and hypervisor to
>> communicate with each other. As a result, SEV-ES is only supported under
>> the X64 architecture.
>>
>> [1] 
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.amd.com%2Fsystem%2Ffiles%2FTechDocs%2F24593.pdf&data=02%7C01%7Cthomas.lendacky%40amd.com%7C55f66571386d4639169308d82e7bb6c1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637310457204828040&sdata=FUhx4fmdzpMota0nG9nudA3aA%2F9Z4Pj2tShJL8UvyhI%3D&reserved=0
>> [2] 
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdeveloper.amd.com%2Fwp-content%2Fresources%2F56421.pdf&data=02%7C01%7Cthomas.lendacky%40amd.com%7C55f66571386d4639169308d82e7bb6c1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637310457204838018&sdata=Krm34z0vbUIvbx3YUNdAFjVJ14hopxmR95tyfpUMquA%3D&reserved=0
>>
>> ---
>>
>> These patches are based on commit:
>> 9132a31b9c83 ("MdeModulePkg/DxeCorePerformanceLib: Switch to 
>> UnicodeStrnToAsciiStrS")
>>
>> A version of the tree can be found at:
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAMDESE%2Fovmf%2Ftree%2Fsev-es-v19&data=02%7C01%7Cthomas.lendacky%40amd.com%7C55f66571386d4639169308d82e7bb6c1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637310457204838018&sdata=IObhTmWtA4zHG1k5rM8lNjaUfOjYR%2BdV2b1pp2G7Lw4%3D&reserved=0
>>
>> Cc: Andrew Fish 
>> Cc: Anthony Perard 
>> Cc: Ard Biesheuvel 
>> Cc: Benjamin You 
>> Cc: Dandan Bi 
>> Cc: Eric Dong 
>> Cc: Guo Dong 
>> Cc: Hao A Wu 
>> Cc: Jian J Wang 
>> Cc: Jordan Justen 
>> Cc: Julien Grall 
>> Cc: Laszlo Ersek 
>> Cc: Leif Lindholm 
>> Cc: Liming Gao 
>> Cc: Maurice Ma 
>> Cc: Michael D Kinney 
>> Cc: Ray Ni 
>>
>> Changes since v10:
>> - Fix conflicts around GccInline.c file after moving to latest commit
>> - Fix conflicts with OVMF PCD values after moving to latest commit
> 
> The updates in patch 29 (OvmfPkg: Create a GHCB page for use during Sec
> phase) look OK; thanks.
> 
> My understanding is that the MdePkg and MdeModulePkg patches remain
> needing approval; is that correct?

Yes, those are the only patches that don't have a Reviewed-by: or Acked-by:.

Thanks,
Tom

> 
> Thanks!
> Laszlo
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63146): https://edk2.groups.io/g/devel/message/63146
Mute This Topic: https://groups.io/mt/75713024/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] EmbeddedPkg: fix gcc build errors in AndroidBootImgLib

2020-07-22 Thread Laszlo Ersek
On 07/21/20 14:50, Leif Lindholm wrote:
> Commit dbd546a32d5a
> ("BaseTools: Add gcc flag to warn on void* pointer arithmetic")
> does its work and triggers build errors in this library.
> Update the affected code to build correctly again.
> 
> Cc: Pierre Gondois 
> Cc: Laszlo Ersek 
> Cc: Bob Feng
> Signed-off-by: Leif Lindholm 
> ---
> 
> Pierre - can you please ensure to CC Arm maintainers when proposing
> changes to Arm build flags? (And build test all the top-level edk2
> packages *cough*.)

or we could perhaps introduce

  EmbeddedPkg/EmbeddedPkg.ci.yaml

> 
> Bob - can you please ensure Arm maintainers have commented on changes to
> global build flags?
> (Would it be possible to break up tools_def.template into separate
> arch-specific include files so we could have GetMaintainer.py be
> more helpful for this?)
> 
> Laszlo - you're not formally an EmbeddedPkg reviewer, but Ard is out for
> another couple of weeks. But since the Linaro CI is currently broken and
> the fix is trivial, could you have a look please?
> 
>  EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
> b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> index e1036954ee58..15b5bf451330 100644
> --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> @@ -97,7 +97,7 @@ AndroidBootImgGetKernelInfo (
>ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize));
>  
>*KernelSize = Header->KernelSize;
> -  *Kernel = BootImg + Header->PageSize;
> +  *Kernel = (VOID *)((UINTN)BootImg + Header->PageSize);
>return EFI_SUCCESS;
>  }
>  

Header->PageSize has type UINT32, so this is OK (the addition is
performed in UINTN, so the conversion back to VOID* is from UINTN).

> @@ -341,7 +341,7 @@ AndroidBootImgUpdateFdt (
>  
>Status = AndroidBootImgSetProperty64 (UpdatedFdtBase, ChosenNode,
>  "linux,initrd-end",
> -(UINTN)(RamdiskData + RamdiskSize));
> +((UINTN)RamdiskData + RamdiskSize));
>if (EFI_ERROR (Status)) {
>  goto Fdt_Exit;
>}
> 

RamdiskSize is a UINTN, so this is OK too.

(You could even strip the outer parentheses:

  (UINTN)RamdiskData + RamdiskSize
)

Reviewed-by: Laszlo Ersek 

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63145): https://edk2.groups.io/g/devel/message/63145
Mute This Topic: https://groups.io/mt/75702678/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v11 06/46] MdePkg/BaseLib: Add support for the XGETBV instruction

2020-07-22 Thread Laszlo Ersek
On 07/22/20 02:55, Liu, Zhiguang wrote:
> Hi Tom,
> Nasm is a cross-OS assembly code and can be used in Linux.
> So I think we don't need implement the same function in GccInline.c, we can 
> just use the nasm file in Linux.

I could agree, but this would create an inconsistency with the existent
functions (where both gcc inline assembly and NASM exists).

For example, consider AsmReadEflags():
- inline assembly for MSFT IA32 ("Ia32/ReadEflags.c")
- NASM for MSFT X64 ("X64/ReadEflags.nasm")
- inline assembly for GCC IA32 ("Ia32/GccInline.c")
- inline assembly for GCC X64 ("X64/GccInline.c")

The source file "X64/ReadEflags.nasm" could be used with GCC X64 too,
not just with MSFT X64.

So why do we have the gcc inline implementation for AsmReadEflags() in
"X64/GccInline.c", in the first place?

The pattern that a contributor is supposed to follow is not clear to me.

Thanks,
Laszlo

>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of
>> Lendacky, Thomas
>> Sent: Wednesday, July 22, 2020 5:19 AM
>> To: devel@edk2.groups.io
>> Cc: Brijesh Singh ; Ard Biesheuvel
>> ; Dong, Eric ; Justen,
>> Jordan L ; Laszlo Ersek ;
>> Gao, Liming ; Kinney, Michael D
>> ; Ni, Ray 
>> Subject: [edk2-devel] [PATCH v11 06/46] MdePkg/BaseLib: Add support for
>> the XGETBV instruction
>>
>> From: Tom Lendacky 
>>
>> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198
>>
>> Under SEV-ES, a CPUID instruction requires the current value of the XCR0
>> register. In order to retrieve that value, the XGETBV instruction needs
>> to be executed.
>>
>> Provide the necessary support to execute the XGETBV instruction.
>>
>> Cc: Michael D Kinney 
>> Cc: Liming Gao 
>> Signed-off-by: Tom Lendacky 
>> ---
>>  MdePkg/Library/BaseLib/BaseLib.inf  |  2 ++
>>  MdePkg/Include/Library/BaseLib.h| 17 +
>>  MdePkg/Library/BaseLib/Ia32/GccInline.c | 28 
>>  MdePkg/Library/BaseLib/X64/GccInline.c  | 30 ++
>>  MdePkg/Library/BaseLib/Ia32/XGetBv.nasm | 31
>> ++
>>  MdePkg/Library/BaseLib/X64/XGetBv.nasm  | 34
>> +
>>  6 files changed, 142 insertions(+)
>>  create mode 100644 MdePkg/Library/BaseLib/Ia32/XGetBv.nasm
>>  create mode 100644 MdePkg/Library/BaseLib/X64/XGetBv.nasm
>>
>> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf
>> b/MdePkg/Library/BaseLib/BaseLib.inf
>> index c740a819cacf..e26c0d8cb0ac 100644
>> --- a/MdePkg/Library/BaseLib/BaseLib.inf
>> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
>> @@ -153,6 +153,7 @@ [Sources.Ia32]
>>Ia32/ARShiftU64.c | MSFT
>>Ia32/EnableCache.c | MSFT
>>Ia32/DisableCache.c | MSFT
>> +  Ia32/XGetBv.nasm | MSFT
>>
>>
>>Ia32/GccInline.c | GCC
>> @@ -288,6 +289,7 @@ [Sources.X64]
>>X64/ReadCr2.nasm| MSFT
>>X64/ReadCr0.nasm| MSFT
>>X64/ReadEflags.nasm| MSFT
>> +  X64/XGetBv.nasm | MSFT
>>
>>
>>X64/Non-existing.c
>> diff --git a/MdePkg/Include/Library/BaseLib.h
>> b/MdePkg/Include/Library/BaseLib.h
>> index 8e7b87cbda4e..7edf0051a0a0 100644
>> --- a/MdePkg/Include/Library/BaseLib.h
>> +++ b/MdePkg/Include/Library/BaseLib.h
>> @@ -7831,6 +7831,23 @@ AsmLfence (
>>VOID
>>);
>>
>> +/**
>> +  Executes a XGETBV instruction
>> +
>> +  Executes a XGETBV instruction. This function is only available on IA-32 
>> and
>> +  x64.
>> +
>> +  @param[in] IndexExtended control register index
>> +
>> +  @return The current value of the extended control register
>> +**/
>> +UINT64
>> +EFIAPI
>> +AsmXGetBv (
>> +  IN UINT32  Index
>> +  );
>> +
>> +
>>  /**
>>Patch the immediate operand of an IA32 or X64 instruction such that the
>> byte,
>>word, dword or qword operand is encoded at the end of the instruction's
>> diff --git a/MdePkg/Library/BaseLib/Ia32/GccInline.c
>> b/MdePkg/Library/BaseLib/Ia32/GccInline.c
>> index 6ed938187a08..c2565ab9a183 100644
>> --- a/MdePkg/Library/BaseLib/Ia32/GccInline.c
>> +++ b/MdePkg/Library/BaseLib/Ia32/GccInline.c
>> @@ -584,3 +584,31 @@ AsmReadTsc (
>>
>>return Data;
>>  }
>> +
>> +
>> +/**
>> +  Executes a XGETBV instruction
>> +
>> +  Executes a XGETBV instruction. This function is only available on IA-32 
>> and
>> +  x64.
>> +
>> +  @param[in] IndexExtended control register index
>> +
>> +  @return The current value of the extended control register
>> +**/
>> +UINT64
>> +EFIAPI
>> +AsmXGetBv (
>> +  IN UINT32 Index
>> +  )
>> +{
>> +  UINT64 Data;
>> +
>> +  __asm__ __volatile__ (
>> +"xgetbv"
>> +: "=A" (Data)
>> +: "c"  (Index)
>> +);
>> +
>> +  return Data;
>> +}
>> diff --git a/MdePkg/Library/BaseLib/X64/GccInline.c
>> b/MdePkg/Library/BaseLib/X64/GccInline.c
>> index 40a208f1985f..65f864e35922 100644
>> --- a/MdePkg/Library/BaseLib/X64/GccInline.c
>> +++ b/MdePkg/Library/BaseLib/X64/GccInline.c
>> @@ -560,3 +560,33 @@ AsmReadTsc (
>>
>>return (((UINT64)HiData) << 32) | LowData;
>>  }
>> +
>> +
>> +/**
>> +  Executes a XGETBV instruction
>> +
>> +  Execute

Re: [edk2-devel] [PATCH v11 00/46] SEV-ES guest support

2020-07-22 Thread Laszlo Ersek
On 07/21/20 23:18, Tom Lendacky wrote:
> From: Tom Lendacky 
> 
> This patch series provides support for running EDK2/OVMF under SEV-ES.
> 
> Secure Encrypted Virtualization - Encrypted State (SEV-ES) expands on the
> SEV support to protect the guest register state from the hypervisor. See
> "AMD64 Architecture Programmer's Manual Volume 2: System Programming",
> section "15.35 Encrypted State (SEV-ES)" [1].
> 
> In order to allow a hypervisor to perform functions on behalf of a guest,
> there is architectural support for notifying a guest's operating system
> when certain types of VMEXITs are about to occur. This allows the guest to
> selectively share information with the hypervisor to satisfy the requested
> function. The notification is performed using a new exception, the VMM
> Communication exception (#VC). The information is shared through the
> Guest-Hypervisor Communication Block (GHCB) using the VMGEXIT instruction.
> The GHCB format and the protocol for using it is documented in "SEV-ES
> Guest-Hypervisor Communication Block Standardization" [2].
> 
> The main areas of the EDK2 code that are updated to support SEV-ES are
> around the exception handling support and the AP boot support.
> 
> Exception support is required starting in Sec, continuing through Pei
> and into Dxe in order to handle #VC exceptions that are generated.  Each
> AP requires it's own GHCB page as well as a page to hold values specific
> to that AP.
> 
> AP booting poses some interesting challenges. The INIT-SIPI-SIPI sequence
> is typically used to boot the APs. However, the hypervisor is not allowed
> to update the guest registers. The GHCB document [2] talks about how SMP
> booting under SEV-ES is performed.
> 
> Since the GHCB page must be a shared (unencrypted) page, the processor
> must be running in long mode in order for the guest and hypervisor to
> communicate with each other. As a result, SEV-ES is only supported under
> the X64 architecture.
> 
> [1] https://www.amd.com/system/files/TechDocs/24593.pdf
> [2] https://developer.amd.com/wp-content/resources/56421.pdf
> 
> ---
> 
> These patches are based on commit:
> 9132a31b9c83 ("MdeModulePkg/DxeCorePerformanceLib: Switch to 
> UnicodeStrnToAsciiStrS")
> 
> A version of the tree can be found at:
> https://github.com/AMDESE/ovmf/tree/sev-es-v19
> 
> Cc: Andrew Fish 
> Cc: Anthony Perard 
> Cc: Ard Biesheuvel 
> Cc: Benjamin You 
> Cc: Dandan Bi 
> Cc: Eric Dong 
> Cc: Guo Dong 
> Cc: Hao A Wu 
> Cc: Jian J Wang 
> Cc: Jordan Justen 
> Cc: Julien Grall 
> Cc: Laszlo Ersek 
> Cc: Leif Lindholm 
> Cc: Liming Gao 
> Cc: Maurice Ma 
> Cc: Michael D Kinney 
> Cc: Ray Ni 
> 
> Changes since v10:
> - Fix conflicts around GccInline.c file after moving to latest commit
> - Fix conflicts with OVMF PCD values after moving to latest commit

The updates in patch 29 (OvmfPkg: Create a GHCB page for use during Sec
phase) look OK; thanks.

My understanding is that the MdePkg and MdeModulePkg patches remain
needing approval; is that correct?

Thanks!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63143): https://edk2.groups.io/g/devel/message/63143
Mute This Topic: https://groups.io/mt/75713024/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 2/2] OvmfPkg: enable HttpDynamicCommand

2020-07-22 Thread Vladimir Olovyannikov via groups.io
Hi Laszlo,

Thank you for reviewing the patchset.

> -Original Message-
> From: Laszlo Ersek 
> Sent: Wednesday, July 22, 2020 12:52 PM
> To: Vladimir Olovyannikov ;
> devel@edk2.groups.io
> Cc: Ard Biesheuvel ; Leif Lindholm
> 
> Subject: Re: [PATCH 2/2] OvmfPkg: enable HttpDynamicCommand
>
> On 07/21/20 19:23, Vladimir Olovyannikov wrote:
> > Enable HttpDynamicCommand (Shell command "http") for OvmfPkg
> platforms
> >
> > Signed-off-by: Vladimir Olovyannikov
> > 
> > ---
> >  OvmfPkg/OvmfPkgIa32.dsc| 6 ++
> >  OvmfPkg/OvmfPkgIa32X64.dsc | 6 ++
> >  OvmfPkg/OvmfPkgX64.dsc | 6 ++
> >  OvmfPkg/OvmfXen.dsc| 6 ++
> >  4 files changed, 24 insertions(+)
> >
> > diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index
> > 9178ffeb71cb..aed3a73c0172 100644
> > --- a/OvmfPkg/OvmfPkgIa32.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32.dsc
> > @@ -883,6 +883,12 @@ [Components]
> >  
> >gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> >}
> > +
> > +
> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand
> .inf {
> > +
> > +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> > +  }
> > +
> >
> OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellComma
> nd.inf {
> >  
> >gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc
> b/OvmfPkg/OvmfPkgIa32X64.dsc
> > index a665f78f0dc7..6c07326cc0fe 100644
> > --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> > @@ -897,6 +897,12 @@ [Components.X64]
> >  
> >gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> >}
> > +
> > +
> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand
> .inf {
> > +
> > +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> > +  }
> > +
> >
> OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellComma
> nd.inf {
> >  
> >gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> > diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index
> > 17f345acf4ee..d5e5bcf8e66c 100644
> > --- a/OvmfPkg/OvmfPkgX64.dsc
> > +++ b/OvmfPkg/OvmfPkgX64.dsc
> > @@ -893,6 +893,12 @@ [Components]
> >  
> >gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> >}
> > +
> > +
> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand
> .inf {
> > +
> > +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> > +  }
> > +
> >
> OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellComma
> nd.inf {
> >  
> >gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> > diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index
> > 782803cb2787..fe549502863a 100644
> > --- a/OvmfPkg/OvmfXen.dsc
> > +++ b/OvmfPkg/OvmfXen.dsc
> > @@ -675,6 +675,12 @@ [Components]
> >  
> >gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> >}
> > +
> > +
> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand
> .inf {
> > +
> > +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> > +  }
> > +
> >
> OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellComma
> nd.inf {
> >  
> >gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> >
>
> Basically same comments as under the ArmVirtPkg patch:
>
> (1) Please mention 
> in the commit message.
OK, will do. For future contributions related to a BZ ticket - does it mean
that mentioning of BZ id in the cover letter is not enough?
>
> (2) Please don't introduce the extra whitespace in the DSC files.
>
> (3) Please also add the new module to the following (FDF) files:
>
> - OvmfPkgIa32.fdf
> - OvmfPkgIa32X64.fdf
> - OvmfPkgX64.fdf
> - OvmfXen.fdf
OK, will do, thanks.
>
> Once you post v2 of this series, with the above points fixed (especially
> the
> FDF files), I'd like to test the new command (with both ArmVirtQemu and
> OVMF).
Sure, that would be great.
>
> Thanks!
> Laszlo

Thank you,
Vladimir

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63142): https://edk2.groups.io/g/devel/message/63142
Mute This Topic: https://groups.io/mt/75708462/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] Maintainers.txt: Add 'Zhiguang Liu' for MdePkg review

2020-07-22 Thread Laszlo Ersek
Hi Liming,

On 07/20/20 16:30, Liming Gao wrote:
> Reviewed-by: Liming Gao 

can you merge the patch, please?

Thanks!
Laszlo

>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of Zhiguang Liu
>> Sent: Monday, July 20, 2020 4:53 PM
>> To: devel@edk2.groups.io
>> Cc: Kinney, Michael D ; Gao, Liming 
>> 
>> Subject: [edk2-devel] [PATCH] Maintainers.txt: Add 'Zhiguang Liu' for MdePkg 
>> review
>>
>> Add 'Zhiguang Liu' as a reviewer for MdePkg.
>>
>> Cc: Michael D Kinney 
>> Cc: Liming Gao 
>> Signed-off-by: Zhiguang Liu 
>> ---
>>  Maintainers.txt | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/Maintainers.txt b/Maintainers.txt
>> index 599f94d57a..5504bb3d17 100644
>> --- a/Maintainers.txt
>> +++ b/Maintainers.txt
>> @@ -381,6 +381,7 @@ F: MdePkg/
>>  W: https://github.com/tianocore/tianocore.github.io/wiki/MdePkg
>>
>>  M: Michael D Kinney 
>>
>>  M: Liming Gao 
>>
>> +R: Zhiguang Liu 
>>
>>
>>
>>  NetworkPkg
>>
>>  F: NetworkPkg/
>>
>> --
>> 2.25.1.windows.1
>>
>>
>> -=-=-=-=-=-=
>> Groups.io Links: You receive all messages sent to this group.
>>
>> View/Reply Online (#62823): https://edk2.groups.io/g/devel/message/62823
>> Mute This Topic: https://groups.io/mt/75678333/1759384
>> Group Owner: devel+ow...@edk2.groups.io
>> Unsubscribe: https://edk2.groups.io/g/devel/unsub  [liming@intel.com]
>> -=-=-=-=-=-=
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63141): https://edk2.groups.io/g/devel/message/63141
Mute This Topic: https://groups.io/mt/75678333/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 2/2] OvmfPkg: enable HttpDynamicCommand

2020-07-22 Thread Laszlo Ersek
On 07/21/20 19:23, Vladimir Olovyannikov wrote:
> Enable HttpDynamicCommand (Shell command "http") for OvmfPkg platforms
> 
> Signed-off-by: Vladimir Olovyannikov 
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 6 ++
>  OvmfPkg/OvmfPkgIa32X64.dsc | 6 ++
>  OvmfPkg/OvmfPkgX64.dsc | 6 ++
>  OvmfPkg/OvmfXen.dsc| 6 ++
>  4 files changed, 24 insertions(+)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 9178ffeb71cb..aed3a73c0172 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -883,6 +883,12 @@ [Components]
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
>}
> +
> +  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
> +
> +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> +  }
> +
>OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index a665f78f0dc7..6c07326cc0fe 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -897,6 +897,12 @@ [Components.X64]
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
>}
> +
> +  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
> +
> +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> +  }
> +
>OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 17f345acf4ee..d5e5bcf8e66c 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -893,6 +893,12 @@ [Components]
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
>}
> +
> +  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
> +
> +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> +  }
> +
>OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
> index 782803cb2787..fe549502863a 100644
> --- a/OvmfPkg/OvmfXen.dsc
> +++ b/OvmfPkg/OvmfXen.dsc
> @@ -675,6 +675,12 @@ [Components]
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
>}
> +
> +  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
> +
> +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> +  }
> +
>OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> 

Basically same comments as under the ArmVirtPkg patch:

(1) Please mention 
in the commit message.

(2) Please don't introduce the extra whitespace in the DSC files.

(3) Please also add the new module to the following (FDF) files:

- OvmfPkgIa32.fdf
- OvmfPkgIa32X64.fdf
- OvmfPkgX64.fdf
- OvmfXen.fdf

Once you post v2 of this series, with the above points fixed (especially
the FDF files), I'd like to test the new command (with both ArmVirtQemu
and OVMF).

Thanks!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63140): https://edk2.groups.io/g/devel/message/63140
Mute This Topic: https://groups.io/mt/75708462/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/2] ArmVirtPkg: enable HttpDynamiCommand

2020-07-22 Thread Laszlo Ersek
Hi Vladimir,

On 07/21/20 19:23, Vladimir Olovyannikov wrote:
> Enable HttpDynamicCommand (http Shell command)
> 
> Signed-off-by: Vladimir Olovyannikov 
> ---
>  ArmVirtPkg/ArmVirt.dsc.inc | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> index cf44fc73890b..c7d52175ee37 100644
> --- a/ArmVirtPkg/ArmVirt.dsc.inc
> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> @@ -377,6 +377,12 @@ [Components.common]
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
>}
> +
> +  ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
> +
> +  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> +  }
> +
>OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
>  
>gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> --
> 2.26.2.266.ge870325ee8
> 

thank you very much for this series. My comments (for this patch):

(1) Please mention 
in the commit message.

(2) The currently enabled dynamic commands "TftpDynamicCommand" and
"LinuxInitrdDynamicShellCommand.inf" do not have any empty lines between
them in the "ArmVirtPkg/ArmVirt.dsc.inc" file. Please insert the new
code block similarly (no leading or trailing empty lines).

(3) Updating the "ArmVirtPkg/ArmVirt.dsc.inc" file makes sure that the
code will be built, but that's not enough for including the module in
the firmware binaries. Please locate "TftpDynamicCommand" in the
following additional files:

- ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
- ArmVirtPkg/ArmVirtXen.fdf

and insert HttpDynamicCommand in those files too, right after
"TftpDynamicCommand".

Thanks!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63139): https://edk2.groups.io/g/devel/message/63139
Mute This Topic: https://groups.io/mt/75708459/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platform][PATCH v1 0/3] Platform/RaspberryPi : SCT EFI_GRAPHICS_OUTPUT_PROTOCOL fixes

2020-07-22 Thread Andrei Warkentin
Tested-by: Andrei Warkentin 

From: Samer El-Haj-Mahmoud 
Sent: Tuesday, July 21, 2020 9:01 PM
To: devel@edk2.groups.io 
Cc: Leif Lindholm ; Pete Batard ; Andrei 
Warkentin ; Ard Biesheuvel 
Subject: [edk2-platform][PATCH v1 0/3] Platform/RaspberryPi : SCT 
EFI_GRAPHICS_OUTPUT_PROTOCOL fixes

This series fixes various failures reported by SCT for
EFI_GRAPHICS_OUTPUT_PROTOCOL 
(https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpftf%2FRPi4%2Fissues%2F73&data=02%7C01%7Cawarkentin%40vmware.com%7C558336c4c06d4bbd608508d82de3175a%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637309800663071295&sdata=aCbQzuQ0S6rWxH8B2ISllUhZL2yNZgDY01wi%2FLd58J0%3D&reserved=0)

Cc: Leif Lindholm 
Cc: Pete Batard 
Cc: Andrei Warkentin 
Cc: Ard Biesheuvel 
Signed-off-by: Samer El-Haj-Mahmoud 
Samer El-Haj-Mahmoud (3):
  Platforms/RaspberryPi: Fix GOP parameter handling
  Platforms/RaspberryPi: Return GOP PixelInformation in QueryMode()
  Platforms/RaspberryPi: Fix GOP FrameBufferSize returned by SetMode()

 .../Drivers/DisplayDxe/DisplayDxe.c   | 22 +++
 1 file changed, 18 insertions(+), 4 deletions(-)

--
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63138): https://edk2.groups.io/g/devel/message/63138
Mute This Topic: https://groups.io/mt/75717277/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 1/1] ShellPkg/DynamicCommand: add HttpDynamicCommand

2020-07-22 Thread Laszlo Ersek
On 07/22/20 21:37, Laszlo Ersek wrote:
> On 07/13/20 20:31, Vladimir Olovyannikov via groups.io wrote:
>> Introduce an http client utilizing EDK2 HTTP protocol, to
>> allow fast image downloading from http/https servers.
>> HTTP download speed is usually faster than tftp.
>> The client is based on the same approach as tftp dynamic command, and
>> uses the same UEFI Shell command line parameters. This makes it easy
>> integrating http into existing UEFI Shell scripts.
>> Note that to enable HTTP download, feature Pcd
>> gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections must
>> be set to TRUE.
>>
>> Signed-off-by: Vladimir Olovyannikov 
>> Tested-By: Samer El-Haj-Mahmoud 
>> Cc: Zhichao Gao 
>> Cc: Maciej Rabeda 
>> Cc: Jiaxin Wu 
>> Cc: Siyuan Fu 
>> Cc: Ray Ni 
>> Cc: Liming Gao 
>> Cc: Nd 
>> ---
>>  .../DynamicCommand/HttpDynamicCommand/Http.c  | 1700 +
>>  .../DynamicCommand/HttpDynamicCommand/Http.h  |   84 +
>>  .../HttpDynamicCommand/Http.uni   |  113 ++
>>  .../HttpDynamicCommand/HttpApp.c  |   53 +
>>  .../HttpDynamicCommand/HttpApp.inf|   58 +
>>  .../HttpDynamicCommand/HttpDynamicCommand.c   |  134 ++
>>  .../HttpDynamicCommand/HttpDynamicCommand.inf |   63 +
>>  ShellPkg/Include/Guid/ShellLibHiiGuid.h   |5 +
>>  ShellPkg/ShellPkg.dec |1 +
>>  ShellPkg/ShellPkg.dsc |5 +
>>  10 files changed, 2216 insertions(+)
>>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c
>>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/Http.h
>>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/Http.uni
>>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.c
>>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.inf
>>  create mode 100644 
>> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.c
>>  create mode 100644 
>> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
> 
> The commit message of this patch should please reference the following
> BZ (which I've just filed):
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=2860
> 
> No need to repost the patch just for this; the commit message can be
> updated upon merge, by the maintainer. (If a v4 becomes necessary,
> please do update the commit message, and also add the v4 link to BZ#2860
> in a new comment).

I've also linked BZ#2860 into the Proposed Features list for the
edk2-stable202008 tag:

https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning#proposed-features

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63137): https://edk2.groups.io/g/devel/message/63137
Mute This Topic: https://groups.io/mt/75483573/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 1/1] ShellPkg/DynamicCommand: add HttpDynamicCommand

2020-07-22 Thread Laszlo Ersek
On 07/13/20 20:31, Vladimir Olovyannikov via groups.io wrote:
> Introduce an http client utilizing EDK2 HTTP protocol, to
> allow fast image downloading from http/https servers.
> HTTP download speed is usually faster than tftp.
> The client is based on the same approach as tftp dynamic command, and
> uses the same UEFI Shell command line parameters. This makes it easy
> integrating http into existing UEFI Shell scripts.
> Note that to enable HTTP download, feature Pcd
> gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections must
> be set to TRUE.
> 
> Signed-off-by: Vladimir Olovyannikov 
> Tested-By: Samer El-Haj-Mahmoud 
> Cc: Zhichao Gao 
> Cc: Maciej Rabeda 
> Cc: Jiaxin Wu 
> Cc: Siyuan Fu 
> Cc: Ray Ni 
> Cc: Liming Gao 
> Cc: Nd 
> ---
>  .../DynamicCommand/HttpDynamicCommand/Http.c  | 1700 +
>  .../DynamicCommand/HttpDynamicCommand/Http.h  |   84 +
>  .../HttpDynamicCommand/Http.uni   |  113 ++
>  .../HttpDynamicCommand/HttpApp.c  |   53 +
>  .../HttpDynamicCommand/HttpApp.inf|   58 +
>  .../HttpDynamicCommand/HttpDynamicCommand.c   |  134 ++
>  .../HttpDynamicCommand/HttpDynamicCommand.inf |   63 +
>  ShellPkg/Include/Guid/ShellLibHiiGuid.h   |5 +
>  ShellPkg/ShellPkg.dec |1 +
>  ShellPkg/ShellPkg.dsc |5 +
>  10 files changed, 2216 insertions(+)
>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c
>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/Http.h
>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/Http.uni
>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.c
>  create mode 100644 ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.inf
>  create mode 100644 
> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.c
>  create mode 100644 
> ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf

The commit message of this patch should please reference the following
BZ (which I've just filed):

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

No need to repost the patch just for this; the commit message can be
updated upon merge, by the maintainer. (If a v4 becomes necessary,
please do update the commit message, and also add the v4 link to BZ#2860
in a new comment).

Thanks!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63136): https://edk2.groups.io/g/devel/message/63136
Mute This Topic: https://groups.io/mt/75483573/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-staging/EdkRepo] [PATCH v1] EdkRepo: Continue checkout on submodule deinit errors

2020-07-22 Thread Bjorge, Erik C
In some cases submodules may still not be deinitialzied even with the
more aggressive deinit flags.  In these cases the checkout will report a
warning and attempt to continue the checkout process.

Cc: Ashley E Desimone 
Cc: Nate DeSimone 
Cc: Puja Pandya 
Cc: Bret Barkelew 
Cc: Prince Agyeman 
Cc: Erik Bjorge 
Signed-off-by: Erik Bjorge 
---
 edkrepo/commands/checkout_pin_command.py | 9 +++--
 edkrepo/common/common_repo_functions.py  | 8 +++-
 edkrepo/common/humble.py | 3 +++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/edkrepo/commands/checkout_pin_command.py 
b/edkrepo/commands/checkout_pin_command.py
index 39c5aeb..1c58113 100644
--- a/edkrepo/commands/checkout_pin_command.py
+++ b/edkrepo/commands/checkout_pin_command.py
@@ -16,7 +16,7 @@ import edkrepo.commands.arguments.checkout_pin_args as 
arguments
 import edkrepo.commands.humble.checkout_pin_humble as humble
 from edkrepo.common.common_repo_functions import sparse_checkout_enabled, 
reset_sparse_checkout, sparse_checkout
 from edkrepo.common.common_repo_functions import check_dirty_repos, 
checkout_repos, combinations_in_manifest
-from edkrepo.common.humble import SPARSE_CHECKOUT, SPARSE_RESET
+from edkrepo.common.humble import SPARSE_CHECKOUT, SPARSE_RESET, 
SUBMODULE_DEINIT_FAILED
 from edkrepo.common.edkrepo_exception import 
EdkrepoInvalidParametersException, EdkrepoProjectMismatchException
 from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
list_available_manifest_repos
 from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
find_source_manifest_repo
@@ -71,7 +71,12 @@ class CheckoutPinCommand(EdkrepoCommand):
 print(SPARSE_RESET)
 reset_sparse_checkout(workspace_path, manifest_sources)
 submodule_combo = pin.general_config.current_combo
-deinit_full(workspace_path, manifest, args.verbose)
+try:
+deinit_full(workspace_path, manifest, args.verbose)
+except Exception as e:
+print(SUBMODULE_DEINIT_FAILED)
+if args.verbose:
+print(e)
 pin_repo_sources = 
pin.get_repo_sources(pin.general_config.current_combo)
 try:
 checkout_repos(args.verbose, args.override, pin_repo_sources, 
workspace_path, manifest)
diff --git a/edkrepo/common/common_repo_functions.py 
b/edkrepo/common/common_repo_functions.py
index 313a1ca..a6a38cf 100644
--- a/edkrepo/common/common_repo_functions.py
+++ b/edkrepo/common/common_repo_functions.py
@@ -50,6 +50,7 @@ from edkrepo.common.humble import INCLUDED_URL_LINE, 
INCLUDED_INSTEAD_OF_LINE, I
 from edkrepo.common.humble import ERROR_WRITING_INCLUDE, 
MULTIPLE_SOURCE_ATTRIBUTES_SPECIFIED
 from edkrepo.common.humble import VERIFY_GLOBAL, VERIFY_ARCHIVED, VERIFY_PROJ, 
VERIFY_PROJ_FAIL
 from edkrepo.common.humble import VERIFY_PROJ_NOT_IN_INDEX, VERIFY_GLOBAL_FAIL
+from edkrepo.common.humble import SUBMODULE_DEINIT_FAILED
 from edkrepo.common.pathfix import get_actual_path
 from project_utils.sparse import BuildInfo, process_sparse_checkout
 from edkrepo.config.config_factory import get_workspace_path
@@ -523,7 +524,12 @@ def checkout(combination_or_sha, verbose=False, 
override=False, log=None):
 # Deinit all submodules due to the potential for issues when switching
 # branches.
 if combo_or_sha != manifest.general_config.current_combo:
-deinit_full(workspace_path, manifest, verbose)
+try:
+deinit_full(workspace_path, manifest, verbose)
+except Exception as e:
+print(SUBMODULE_DEINIT_FAILED)
+if verbose:
+print(e)
 
 print(CHECKING_OUT_COMBO.format(combo_or_sha))
 
diff --git a/edkrepo/common/humble.py b/edkrepo/common/humble.py
index f905357..763b9a6 100644
--- a/edkrepo/common/humble.py
+++ b/edkrepo/common/humble.py
@@ -155,3 +155,6 @@ BRANCH = 'Branch : {0}'
 COMMIT = 'Commit Id: {0}'
 WRITING_PIN_FILE = 'Writing pin file to {0} ...'
 COMMIT_MESSAGE = 'Pin file for project: {0} \nPin Description: {1}'
+
+# Common submodule error messages
+SUBMODULE_DEINIT_FAILED = 'Warning: Unable to remove all submodule content'
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63135): https://edk2.groups.io/g/devel/message/63135
Mute This Topic: https://groups.io/mt/75730839/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms][PATCH v5 0/5] Add initial support for N1SDP board

2020-07-22 Thread Thomas Abraham
On Wed, Jul 22, 2020 at 8:55 PM Pranav Madhu  wrote:
>
> Changes since v4:
> - Updated indents and spacing, functionally same as v4.
>
> Changes since v3:
> - Addressed all the comments from Leif. As part of the clean up that
>   resulted from addressing the comments, some of the comments where not
>   applicable anymore (due to fragments of code that had comments were
>   removed during cleanup).
> - Included detailed description of the workarounds applied to the
>   Neoverse N1 SoC specific PciExpressLib library.
> - Updated Maintainers.txt to add Silicon/ARM/ directory under ARM entry.
> - Picked up Leif's Reviewed-by tag for the 4th patch of this series.
> - Addressed all the comments from Ard.
>
> Changes since v2:
> - Addressed comments from Thomas.
> - Renamed Silicon/ARM/N1SDP to Silicon/ARM/NeoverseN1Soc.
>
> Changes since v1:
> - Addressed comments from Ard.
> - Split the code between Silicon and Platform directories.
>
> Arm's N1SDP is a Arm v8.2-A Neoverse N1 CPU based reference design platform
> primariliy intended for development on Arm64 based platform. This patch series
> adds initial support for Arm's Neoverse N1 SoC and platform support for the
> N1SDP board.
>
> The first patch in this series adds the platform libary implementation. The
> second patch adds a custom implementation of the PciExpressLib due to a PCIe
> integration issue which results in all config space accesses to non-existing
> BDFs resulting in a Serror (bus abort). To avoid this, the N1SDP specific
> PciExpressLib implementation provides a workaround for this issue. The third
> patch in this series adds the platform library for the PciHostBridge. The
> fourth patch adds the initial platform support for the N1SDP platform. The
> fifth patch adds Silicon/ARM/ to ARM entry in maintainers file.
>
> Deepak Pandey (4):
>   Silicon/ARM/N1SoC: Add platform library implementation
>   Silicon/ARM/N1SoC: Implement Neoverse N1 SoC specific PciExpressLib
>   Silicon/ARM/N1SoC: Implement the PciHostBridgeLib library
>   Platform/ARM/N1SDP: Add initial N1SDP platform support
>
> Pranav Madhu (1):
>   Maintainers.txt: Add Silicon/ARM directory

For this series:
Reviewed-by: Thomas Abraham 

>
>  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec  
>   |   46 +
>  Platform/ARM/N1Sdp/N1SdpPlatform.dsc 
>   |  245 +++
>  Platform/ARM/N1Sdp/N1SdpPlatform.fdf 
>   |  294 
>  
> Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf
>  |   56 +
>  Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf  
>   |   49 +
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
>   |   54 +
>  Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
>   |   66 +
>  Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c 
>   | 1589 
>  Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c
>   |  184 +++
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.c  
>   |   67 +
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c   
>   |  151 ++
>  Maintainers.txt  
>   |1 +
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/AArch64/Helper.S   
>   |   84 ++
>  13 files changed, 2886 insertions(+)
>  create mode 100644 Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
>  create mode 100644 Platform/ARM/N1Sdp/N1SdpPlatform.dsc
>  create mode 100644 Platform/ARM/N1Sdp/N1SdpPlatform.fdf
>  create mode 100644 
> Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf
>  create mode 100644 
> Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf
>  create mode 100644 
> Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
>  create mode 100644 Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
>  create mode 100644 
> Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c
>  create mode 100644 
> Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c
>  create mode 100644 
> Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.c
>  create mode 100644 
> Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
>  create mode 100644 
> Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/AArch64/Helper.S
>
> --
> 2.7.4
>
>
> 
> Groups.io Links: You receive all messages sent to this group.
>
> View/Reply Online (#63122): https://edk2.groups.io/g/devel/message/63122
> Mute This Topic: https://groups.io/mt/75726808/1785013
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub  [ta.oma...@gmail.com]
> 
>

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63134): https://edk2.groups.

Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer arithmetic

2020-07-22 Thread Leif Lindholm
Hi Bob,

This patch also breaks about half of the ARM/AARCH64 platforms in
edk2-platforms. I agree it should go in at a later stage, but for now,
can we please revert it?

Regards,

Leif

On Mon, Jul 20, 2020 at 04:10:27 +, Bob Feng wrote:
> Reviewed-by: Bob Feng
> 
> 
> -Original Message-
> From: PierreGondois  
> Sent: Tuesday, July 7, 2020 4:35 PM
> To: devel@edk2.groups.io
> Cc: Pierre Gondois ; Feng, Bob C 
> ; Gao, Liming ; 
> tomas.pi...@arm.com; n...@arm.com
> Subject: [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer 
> arithmetic
> 
> From: Pierre Gondois 
> 
> By default, gcc allows void* pointer arithmetic.
> This is a GCC extension.
> However:
>  - the C reference manual states that void*
>pointer "cannot be operands of addition
>or subtraction operators". Cf s5.3.1
>"Generic Pointers";
>  - Visual studio compiler treat such operation as
>an error.
> 
> To prevent such pointer arithmetic, the "-Wpointer-arith"
> flag should be set for all GCC versions.
> 
> The "-Wpointer-arith"  allows to:
>   "Warn about anything that depends on the "size of"
>   a function type or of void. GNU C assigns these
>   types a size of 1, for convenience in calculations
>   with void * pointers and pointers to functions."
> 
> This flag is available since GCC2.95.3 which came out in 2001.
> 
> Signed-off-by: Pierre Gondois 
> ---
> 
> The changes can be seen at: 
> https://github.com/PierreARM/edk2/commits/831_Add_gcc_flag_warning_v2
> 
> Notes:
> v1:
>  - Add "-Wpointer-arith" gcc flag. [Pierre]
> v2:
>  - Only add the flag for ARM and AARCH64. [Tomas]
> 
>  BaseTools/Conf/tools_def.template | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index 
> 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..397b011ba38f97f81f314f8641ac8bb95d5a2197
>  100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -1,7 +1,7 @@
>  #
>  #  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.  # 
>  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. -#  
> Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.
> +#  Portions copyright (c) 2011 - 2020, ARM Ltd. All rights 
> +reserved.
>  #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.  #  (C) 
> Copyright 2020, Hewlett Packard Enterprise Development LP  #  Copyright 
> (c) Microsoft Corporation
> @@ -1921,9 +1921,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
> --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N
>  DEFINE GCC_ALL_CC_FLAGS= -g -Os -fshort-wchar -fno-builtin 
> -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h 
> -fno-common
>  DEFINE GCC_IA32_CC_FLAGS   = DEF(GCC_ALL_CC_FLAGS) -m32 
> -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 
> -mno-stack-arg-probe
>  DEFINE GCC_X64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mno-red-zone 
> -Wno-address -mno-stack-arg-probe
> -DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
> -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections 
> -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft 
> -fno-pic -fno-pie
> +DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
> -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char 
> -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb 
> -mfloat-abi=soft -fno-pic -fno-pie
>  DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
> -DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-endian 
> -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections 
> -fdata-sections -Wno-address -fno-asynchronous-unwind-tables 
> -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
> +DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith 
> -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char 
> -ffunction-sections -fdata-sections -Wno-address 
> -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie 
> -ffixed-x18
>  DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
>  DEFINE GCC_DLINK_FLAGS_COMMON  = -nostdlib --pie
>  DEFINE GCC_DLINK2_FLAGS_COMMON = 
> -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 
> 
> 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63133): https://edk2.groups.io/g/devel/message/63133
Mute This Topic: https://groups.io/mt/75351535/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 04/10] UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

2020-07-22 Thread Wang, Jian J


Reviewed-by: Jian J Wang 

Regards,
Jian

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guomin
> Jiang
> Sent: Wednesday, July 22, 2020 4:37 PM
> To: devel@edk2.groups.io
> Cc: Michael Kubacki ; Dong, Eric
> ; Ni, Ray ; Laszlo Ersek
> ; Kumar, Rahul1 ; De,
> Debkumar ; Han, Harry ;
> West, Catharine 
> Subject: [edk2-devel] [PATCH v7 04/10] UefiCpuPkg/SecMigrationPei: Add initial
> PEIM (CVE-2019-11098)
> 
> From: Michael Kubacki 
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
> 
> Adds a PEIM that republishes structures produced in SEC. This
> is done because SEC modules may not be shadowed in some platforms
> due to space constraints or special alignment requirements. The
> SecMigrationPei module locates interfaces that may be published in
> SEC and reinstalls the interface with permanent memory addresses.
> 
> This is important if pre-memory address access is forbidden after
> memory initialization and data such as a PPI descriptor, PPI GUID,
> or PPI inteface reside in pre-memory.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Rahul Kumar 
> Cc: Debkumar De 
> Cc: Harry Han 
> Cc: Catharine West 
> Signed-off-by: Michael Kubacki 
> Acked-by: Laszlo Ersek 
> ---
>  UefiCpuPkg/UefiCpuPkg.dec |   3 +
>  UefiCpuPkg/UefiCpuPkg.dsc |   1 +
>  UefiCpuPkg/SecCore/SecCore.inf|   2 +
>  .../SecMigrationPei/SecMigrationPei.inf   |  67 +++
>  UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
>  UefiCpuPkg/SecCore/SecMain.h  |   1 +
>  UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 158 +++
>  UefiCpuPkg/SecCore/SecMain.c  |  26 +-
>  UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 385 ++
>  .../SecMigrationPei/SecMigrationPei.uni   |  13 +
>  10 files changed, 708 insertions(+), 2 deletions(-)
>  create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
>  create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
>  create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
>  create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
>  create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni
> 
> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
> index 762badf5d239..8b2e03d49d07 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dec
> +++ b/UefiCpuPkg/UefiCpuPkg.dec
> @@ -84,6 +84,9 @@ [Ppis]
>## Include/Ppi/ShadowMicrocode.h
>gEdkiiPeiShadowMicrocodePpiGuid = { 0x430f6965, 0x9a69, 0x41c5, { 0x93,
> 0xed, 0x8b, 0xf0, 0x64, 0x35, 0xc1, 0xc6 }}
> 
> +  ## Include/Ppi/RepublishSecPpi.h
> +  gRepublishSecPpiPpiGuid   = { 0x27a71b1e, 0x73ee, 0x43d6, { 0xac, 0xe3, 
> 0x52,
> 0x1a, 0x2d, 0xc5, 0xd0, 0x92 }}
> +
>  [PcdsFeatureFlag]
>## Indicates if SMM Profile will be enabled.
>#  If enabled, instruction executions in and data accesses to memory 
> outside of
> SMRAM will be logged.
> diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
> index afa304128221..964720048dd7 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dsc
> +++ b/UefiCpuPkg/UefiCpuPkg.dsc
> @@ -146,6 +146,7 @@ [Components.IA32, Components.X64]
>UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
>UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
>UefiCpuPkg/SecCore/SecCore.inf
> +  UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
>UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
>UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
>  
> diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
> index 0562820c95e0..545781d6b4b3 100644
> --- a/UefiCpuPkg/SecCore/SecCore.inf
> +++ b/UefiCpuPkg/SecCore/SecCore.inf
> @@ -68,6 +68,8 @@ [Ppis]
>## SOMETIMES_CONSUMES
>gPeiSecPerformancePpiGuid
>gEfiPeiCoreFvLocationPpiGuid
> +  ## CONSUMES
> +  gRepublishSecPpiPpiGuid
> 
>  [Guids]
>## SOMETIMES_PRODUCES   ## HOB
> diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
> b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
> new file mode 100644
> index ..f4c2f6b658fb
> --- /dev/null
> +++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
> @@ -0,0 +1,67 @@
> +## @file
> +#  Migrates SEC structures after permanent memory is installed.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = SecMigrationPei
> +  MODULE_UNI_FILE= SecMigrationPei.uni
> +  FILE_GUID  = 58B35361-8922-41BC-B313-EF7ED9ADFDF7
> +  MODULE_TYPE= PEIM
> +  VERSION_STRING = 1.0
> +  ENTRY_POINT= SecMigrationPeiInitialize
> +
> +#
> +# The following information is for reference only and not required by the 
> build
> tools.
> +#
> +#  VALID_ARCHITECTURES   = IA32 X64 EBC
> +#
> +
> +[Sources]
> +  SecMigrationPei.c
> +
> +

Re: [edk2-devel] [PATCH v7 0/6] Add capability to let PEIM extend TcgEvent

2020-07-22 Thread Wang, Jian J
For this patch series,

Reviewed-by: Jian J Wang 

Regards,
Jian

> -Original Message-
> From: Zhang, Qi1 
> Sent: Wednesday, July 22, 2020 4:21 PM
> To: devel@edk2.groups.io
> Cc: Zhang, Qi1 ; Yao, Jiewen ;
> Wang, Jian J ; Kumar, Rahul1 
> Subject: [PATCH v7 0/6] Add capability to let PEIM extend TcgEvent
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2841
> 
> Currently, we have TCG/TCG2 protocol and DxeTpmMeasurementLib to let DXE
> module extend the TCG event.
> There is more and more use case in PEI phase that a PEIM need extend TCG
> event, such as BootGuard, FSP, Microcode measurement. Currently, we dont
> have API to do that so that each module need create TCG/TCG2 event log,
> which is a burden.
> 
> This bugzilla requests to add PeiTpmMeasurementLib instance.
> 
> The implementation includes:
> 1) A EDKII_TCG_PPI which abstracts the HashLogExtendEvent service.
> 2) A PeiTpmMeasurementLib instance, so that a PEIM can call this API to
>   add TCG event.
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Qi Zhang 
> Cc: Rahul Kumar 
> 
> Jiewen Yao (6):
>   SecurityPkg/TcgPpi: Add TcgPpi header file.
>   SecurityPkg/dec: Add TcgPpi.
>   SecurityPkg/Tcg: Add TcgPpi
>   SecurityPkg/Tcg2: Add TcgPpi
>   SecurityPkg/PeiTpmMeasurementLib: Add PEI instance.
>   SecurityPkg/dsc: Add PeiTpmMeasurementLib.
> 
>  SecurityPkg/Include/Ppi/Tcg.h |  60 ++
>  .../PeiTpmMeasurementLib.c|  74 
>  .../PeiTpmMeasurementLib.inf  |  50 
>  .../PeiTpmMeasurementLib.uni  |  17 +++
>  SecurityPkg/SecurityPkg.dec   |   3 +
>  SecurityPkg/SecurityPkg.dsc   |   4 +-
>  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 110 +-
>  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf   |   3 +-
>  SecurityPkg/Tcg/TcgPei/TcgPei.c   |  61 +-
>  SecurityPkg/Tcg/TcgPei/TcgPei.inf |   3 +-
>  10 files changed, 351 insertions(+), 34 deletions(-)
>  create mode 100644 SecurityPkg/Include/Ppi/Tcg.h
>  create mode 100644
> SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
>  create mode 100644
> SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
>  create mode 100644
> SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni
> 
> --
> 2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63131): https://edk2.groups.io/g/devel/message/63131
Mute This Topic: https://groups.io/mt/75720704/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] A problem to build KabyLake

2020-07-22 Thread Canh Kha
Hi Guomin,

Yes, I also have the same file as you do
>dir
C:\minnow\edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include\PreMemory.fdf
 Volume in drive C is OS
 Volume Serial Number is CCF3-B399

 Directory of
C:\minnow\edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include

07/11/2020  03:26 PM 1,779 PreMemory.fdf
   1 File(s)  1,779 bytes

But for some reason, the script seems looking for it from
a different directory.
Thank you,
Canh

On Wed, Jul 22, 2020 at 5:47 AM Jiang, Guomin 
wrote:

>  It confuse me that near line 60, column 0:   !include
> LogoFeaturePkg/Include/PreMemory.fdf.
>
>
>
> In my local machine, the PreMemory.fdf should be
> AdvancedFeaturePkg/Include/PreMemory.fdf,
>
>
>
> I can also find this file in directory
> edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include.
>
>
>
> Please confirm it.
>
>
>
> Thanks.
>
> Guomin
>
> *From:* devel@edk2.groups.io  * On Behalf Of *Canh
> Kha
> *Sent:* Wednesday, July 22, 2020 1:13 PM
> *To:* devel@edk2.groups.io
> *Subject:* [edk2-devel] A problem to build KabyLake
>
>
>
> Hi,
>
> When I ran this build command
>
> build -a IA32 -a X64 -n 5 -t VS2015x86 -b DEBUG -p
> KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc
>
> I received the following message
>
>
> build.py...
>  : error C0DE: Unknown fatal error when processing
> [c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc]
>
> (Please send email to devel@edk2.groups.io for help, attaching following
> call stack trace!)
>
> (Python 3.8.3 on win32) Traceback (most recent call last):
>   File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2636,
> in Main
> MyBuild.Launch()
>   File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2431,
> in Launch
> self._MultiThreadBuildPlatform()
>   File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2238,
> in _MultiThreadBuildPlatform
> Wa, self.BuildModules = self.PerformAutoGen(BuildTarget,ToolChain)
>   File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2088,
> in PerformAutoGen
> Wa = WorkspaceAutoGen(
>   File
> "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", line
> 43, in __init__
> self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args,
> **kwargs)
>   File
> "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", line
> 112, in _InitWorker
> self.ProcessModuleFromPdf()
>   File
> "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", line
> 188, in ProcessModuleFromPdf
> if self.FdfProfile:
>   File "C:\minnow\edk2\BaseTools\Source\Python\Common\caching.py", line
> 28, in __get__
> Value = obj.__dict__[self._function.__name__] = self._function(obj)
>   File
> "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", line
> 164, in FdfProfile
> Fdf.ParseFile()
>   File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line
> 1312, in ParseFile
> self.Preprocess()
>   File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line
> 1291, in Preprocess
> self.PreprocessIncludeFile()
>   File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line
> 624, in PreprocessIncludeFile
> raise Warning("The include file does not exist under below
> directories: \n%s\n%s\n%s\n"%(os.path.dirname(self.FileName), PlatformDir,
> GlobalData.gWorkspace),
> GenFds.FdfParser.Warning: The include file does not exist under below
> directories:
> c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3
> c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3
> c:\minnow
>  near line 60, column 0:   !include LogoFeaturePkg/Include/PreMemory.fdf
>
>
>
> - Failed -
> Build end time: 00:01:19, Jul.22 2020
> Build total time: 00:00:00
>
>
>
> This is my PACKAGES_PATH
>
>
> C:\minnow\edk2;C:\minnow\edk2-platforms\Silicon\Intel;C:\minnow\edk2-platforms\Platform\Intel;;C:\minnow\edk2-platforms\Features\Intel;C:\minnow\edk2-non-osi\Silicon\Intel;C:\minnow\FSP
>
> Could you help to give me some suggestions to try?
>
> Thanks,
>
> Canh
>
> 
>

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63130): https://edk2.groups.io/g/devel/message/63130
Mute This Topic: https://groups.io/mt/75721822/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v1 1/2] EmbeddedPkg: Fix build error for MmcDxe

2020-07-22 Thread Leif Lindholm
On Tue, Jun 30, 2020 at 11:49:00 +0100, PierreGondois wrote:
> From: Pierre Gondois 
> 
> The following command line:
> build -b NOOPT -a IA32 -t VS2017 -p edk2\EmbeddedPkg\EmbeddedPkg.dsc
> 
> Generates the following error:
> MmcDxe.lib(Diagnostics.obj) : error LNK2001:
> unresolved external symbol __allshl
> MmcDxe.lib(Diagnostics.obj) : error LNK2001:
> unresolved external symbol __aullshr
> MmcDxe.lib(MmcBlockIo.obj) : error LNK2001:
> unresolved external symbol __allmul
> 
> These erros are due to the use of shift/multiply operations
> on UINT64 variable on a IA32 architecture.

Apart from how Ia32 should just bite the bullet and implement a
CompilerIntrinsicsLib for VS so the rest of us can go back to writing
C:

Reviewed-by: Leif Lindholm 

> Signed-off-by: Pierre Gondois 
> ---
> 
> The changes can be seen at: 
> https://github.com/PierreARM/edk2/commits/831_Fix_VS2017_build_error_v1
> 
> Notes:
> v1:
>  - Fix VS2017 build errors. [Pierre]
> 
>  EmbeddedPkg/Universal/MmcDxe/Diagnostics.c | 10 +++---
>  EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c  |  6 +++---
>  2 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c 
> b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
> index 
> 20defeb8745a2eb243f316ba9d4e0d03016e260b..49b069043093544a3cbadc46fda4de483803d638
>  100644
> --- a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
> +++ b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
> @@ -1,7 +1,7 @@
>  /** @file
>Diagnostics Protocol implementation for the MMC DXE driver
>  
> -  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
> +  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
>  
>SPDX-License-Identifier: BSD-2-Clause-Patent
>  
> @@ -56,7 +56,7 @@ GenerateRandomBuffer (
>UINT64* Buffer64 = (UINT64*)Buffer;
>  
>for (i = 0; i < (BufferSize >> 3); i++) {
> -*Buffer64 = i | (~i << 32);
> +*Buffer64 = i | LShiftU64 (~i, 32);
>  Buffer64++;
>}
>  }
> @@ -227,7 +227,11 @@ MmcDriverDiagnosticsRunDiagnostics (
>  
>// LBA=10 Size=BlockSize
>DiagnosticLog (L"MMC Driver Diagnostics - Test: Any Block\n");
> -  Status = MmcReadWriteDataTest (MmcHostInstance, 
> MmcHostInstance->BlockIo.Media->LastBlock >> 1, 
> MmcHostInstance->BlockIo.Media->BlockSize);
> +  Status = MmcReadWriteDataTest (
> + MmcHostInstance,
> + RShiftU64 (MmcHostInstance->BlockIo.Media->LastBlock, 1),
> + MmcHostInstance->BlockIo.Media->BlockSize
> + );
>  
>// LBA=LastBlock Size=BlockSize
>DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n");
> diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c 
> b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> index 
> b508c466d9c5c527855ea32cbd427927e27b..2a5d72d4daf6045e691e51d5b82ed8e6fb721121
>  100644
> --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> @@ -1,6 +1,6 @@
>  /** @file
>  *
> -*  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> +*  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
>  *
>  *  SPDX-License-Identifier: BSD-2-Clause-Patent
>  *
> @@ -149,7 +149,7 @@ MmcTransferBlock (
>  if (MmcHostInstance->CardInfo.OCRData.AccessMode & SD_CARD_CAPACITY) {
>CmdArg = Lba;
>  } else {
> -  CmdArg = Lba * This->Media->BlockSize;
> +  CmdArg = MultU64x32 (Lba, This->Media->BlockSize);
>  }
>} else {
>  //Set command argument based on the card access mode (Byte mode or Block 
> mode)
> @@ -157,7 +157,7 @@ MmcTransferBlock (
>  MMC_OCR_ACCESS_SECTOR) {
>CmdArg = Lba;
>  } else {
> -  CmdArg = Lba * This->Media->BlockSize;
> +  CmdArg = MultU64x32 (Lba, This->Media->BlockSize);
>  }
>}
>  
> -- 
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63129): https://edk2.groups.io/g/devel/message/63129
Mute This Topic: https://groups.io/mt/75211230/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v1 2/2] EmbeddedPkg: Add cast from (void*) for VS2017 build

2020-07-22 Thread Leif Lindholm
On Tue, Jun 30, 2020 at 11:49:01 +0100, PierreGondois wrote:
> From: Pierre Gondois 
> 
> The following build configrations:
> build -b DEBUG -a AARCH64 -t VS2017 -p edk2\EmbeddedPkg\EmbeddedPkg.dsc
> build -b NOOPT -a AARCH64 -t VS2017 -p edk2\EmbeddedPkg\EmbeddedPkg.dsc
> build -b RELEASE -a AARCH64 -t VS2017 -p edk2\EmbeddedPkg\EmbeddedPkg.dsc
> 
> are generating the following build errors:
> edk2\EmbeddedPkg\Library\AndroidBootImgLib\AndroidBootImgLib.c(100):
> error C2036: 'void *': unknown size
> edk2\EmbeddedPkg\Library\AndroidBootImgLib\AndroidBootImgLib.c(347):
> error C2036: 'void *': unknown size
> 
> Since the size of void* depends on the architecture, it can be
> dangerous to use void* pointer arithmetic. Plus the C99 doesn't state
> that void* pointer arithmetic is allowed.
> This patch adds a cast to fix the Visual Studio errors reported.
> 
> Signed-off-by: Pierre Gondois 
> ---
> 
> The changes can be seen at: 
> https://github.com/PierreARM/edk2/commits/831_Fix_VS2017_build_error_v1
> 
> Notes:
> v1:
>  - Fix VS2017 build errors. [Pierre]
> 
>  EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c | 13 -
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
> b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> index 
> e1036954ee586dfc30266eec2897d71bfc949038..bbe0d41018b3d5665c72ee61efe737ae57b1b2eb
>  100644
> --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> @@ -1,6 +1,6 @@
>  /** @file
>  
> -  Copyright (c) 2013-2014, ARM Ltd. All rights reserved.
> +  Copyright (c) 2013-2020, ARM Ltd. All rights reserved.
>Copyright (c) 2017, Linaro. All rights reserved.
>  
>SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -97,7 +97,7 @@ AndroidBootImgGetKernelInfo (
>ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize));
>  
>*KernelSize = Header->KernelSize;
> -  *Kernel = BootImg + Header->PageSize;
> +  *Kernel = (UINT8*)BootImg + Header->PageSize;

The reason I prefer my version, although this one would also solve the
compilation error, is that I really don't like casts to char * (which
this effectively is) as a workaround.

The problem I have with it is that a cast is a signal of intent (this
thing that we have been viewing as an X should now be seen as a Y) -
and the intent here is simply to get the side effect that a char has a
known size of 1 (whereas a void doesn't).
I will admit it is the first time I have seen it used for this purpose
:)

The same problem occure when casting to char * in order to not have to
deal with pointer arithmetic at all or to avoid thinking about
alignment requirements. And both of these are frequently indicators of
buggy code.

/
Leif

>return EFI_SUCCESS;
>  }
>  
> @@ -339,9 +339,12 @@ AndroidBootImgUpdateFdt (
>  goto Fdt_Exit;
>}
>  
> -  Status = AndroidBootImgSetProperty64 (UpdatedFdtBase, ChosenNode,
> -"linux,initrd-end",
> -(UINTN)(RamdiskData + RamdiskSize));
> +  Status = AndroidBootImgSetProperty64 (
> + UpdatedFdtBase,
> + ChosenNode,
> + "linux,initrd-end",
> + (UINTN)((UINT8*)RamdiskData + RamdiskSize)
> + );
>if (EFI_ERROR (Status)) {
>  goto Fdt_Exit;
>}
> -- 
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63128): https://edk2.groups.io/g/devel/message/63128
Mute This Topic: https://groups.io/mt/75211231/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms][PATCH v5 4/5] Platform/ARM/N1SDP: Add initial N1SDP platform support

2020-07-22 Thread Pranav Madhu
From: Deepak Pandey 

Neoverse N1 System Development Platform (N1SDP) is an infrastructure
segment development platform. It includes a Neoverse N1 SoC and an
IOFPGA that provides access to low-bandwidth peripherals. It
also enables development of CCIX-enabled FPGA accelerators.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pranav Madhu 
Reviewed-by: Leif Lindholm 
---
 Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 245 
 Platform/ARM/N1Sdp/N1SdpPlatform.fdf | 294 
 2 files changed, 539 insertions(+)

diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc 
b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
new file mode 100644
index ..92376aab8ffe
--- /dev/null
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
@@ -0,0 +1,245 @@
+#
+#  Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME  = n1sdp
+  PLATFORM_GUID  = 9af67d31-7de8-4a71-a9a8-a597a27659ce
+  PLATFORM_VERSION   = 0.1
+  DSC_SPECIFICATION  = 0x0001001B
+  OUTPUT_DIRECTORY   = Build/$(PLATFORM_NAME)
+  SUPPORTED_ARCHITECTURES= AARCH64
+  BUILD_TARGETS  = NOOPT|DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+  FLASH_DEFINITION   = Platform/ARM/N1Sdp/N1SdpPlatform.fdf
+  BUILD_NUMBER   = 1
+
+!include Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
+
+[LibraryClasses.common]
+  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
+  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+  ArmPlatformLib|Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
+  BasePathLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+
+[LibraryClasses.common.SEC]
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+
+[LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM]
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
+
+[LibraryClasses.common.PEI_CORE]
+  PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
+
+[LibraryClasses.common.PEIM]
+  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
+
+[LibraryClasses.common.DXE_CORE]
+  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
+  
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+
+[LibraryClasses.common.DXE_DRIVER]
+  FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
+  
PciHostBridgeLib|Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+  PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
+  PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
+  
PciExpressLib|Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf
+
+[LibraryClasses.common.DXE_RUNTIME_DRIVER]
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+
+[LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, 
LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.DXE_DRIVER]
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+
+
+#
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform
+#
+
+
+[PcdsFeatureFlag.common]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
+
+[PcdsFixedAtBuild.common]
+  gArmTokenSpaceGuid.PcdVFPEnabled|1
+
+  # Stacks for MPCores in Normal World
+  gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x8000
+  gArmPlatformTo

[edk2-devel] [PATCH V3 1/2] MdePkg/Include/IndustryStandard: CXL 1.1 Registers

2020-07-22 Thread Javeed, Ashraf
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2611

Register definitions from chapter 7 of Compute Express Link
Specification Revision 1.1 are ported into the new Cxl11.h.
The CXL Flex Bus registers are based on the PCIe Extended Capability
DVSEC structure header, led to the inclusion of upgraded Pci.h.

Signed-off-by: Ashraf Javeed 
Cc: Michael D Kinney 
Cc: Liming Gao 
--

V2: Indentation and double declaration fix, copyright date update

V3: Copyright date fix
---
 MdePkg/Include/IndustryStandard/Cxl11.h | 569 
+
 MdePkg/Include/IndustryStandard/Pci.h   |   6 ++
 2 files changed, 571 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/Cxl11.h 
b/MdePkg/Include/IndustryStandard/Cxl11.h
new file mode 100644
index 00..a261bb3fae
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Cxl11.h
@@ -0,0 +1,569 @@
+/** @file
+  CXL 1.1 Register definitions
+
+  This file contains the register definitions based on the Compute Express Link
+  (CXL) Specification Revision 1.1.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _CXL11_H_
+#define _CXL11_H_
+
+#include 
+//
+// DVSEC Vendor ID
+// Compute Express Link Specification Revision: 1.1 - Chapter 7.1.1 - Table 58
+// (subject to change as per CXL assigned Vendor ID)
+//
+#define INTEL_CXL_DVSEC_VENDOR_ID   0x8086
+
+//
+// CXL Flex Bus Device default device and function number
+// Compute Express Link Specification Revision: 1.1 - Chapter 7.1.1
+//
+#define CXL_DEV_DEV 0
+#define CXL_DEV_FUNC0
+
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+
+///
+/// The PCIe DVSEC for Flex Bus Device
+///@{
+typedef union {
+  struct {
+UINT16 CacheCapable : 1; // bit 0
+UINT16 IoCapable: 1; // bit 1
+UINT16 MemCapable   : 1; // bit 2
+UINT16 MemHwInitMode: 1; // bit 3
+UINT16 HdmCount : 2; // bit 
4..5
+UINT16 Reserved1: 8; // bit 
6..13
+UINT16 ViralCapable : 1; // bit 14
+UINT16 Reserved2: 1; // bit 15
+  }Bits;
+  UINT16Uint16;
+} CXL_DVSEC_FLEX_BUS_DEVICE_CAPABILITY;
+
+typedef union {
+  struct {
+UINT16 CacheEnable  : 1; // bit 0
+UINT16 IoEnable : 1; // bit 1
+UINT16 MemEnable: 1; // bit 2
+UINT16 CacheSfCoverage  : 5; // bit 
3..7
+UINT16 CacheSfGranularity   : 3; // bit 
8..10
+UINT16 CacheCleanEviction   : 1; // bit 11
+UINT16 Reserved1: 2; // bit 
12..13
+UINT16 ViralEnable  : 1; // bit 14
+UINT16 Reserved2: 1; // bit 15
+  }Bits;
+  UINT16Uint16;
+} CXL_DVSEC_FLEX_BUS_DEVICE_CONTROL;
+
+typedef union {
+  struct {
+UINT16 Reserved1: 14; // bit 
0..13
+UINT16 ViralStatus  : 1;  // bit 14
+UINT16 Reserved2: 1;  // bit 15
+  }Bits;
+  UINT16Uint16;
+} CXL_DVSEC_FLEX_BUS_DEVICE_STATUS;
+
+typedef union {
+  struct {
+UINT16 Reserved1: 1;  // bit 0
+UINT16 Reserved2: 1;  // bit 1
+UINT16 Reserved3: 1;  // bit 2
+UINT16 Reserved4: 13; // bit 
3..15
+  }Bits;
+  UINT16Uint16;
+} CXL_1_1_DVSEC_FLEX_BUS_DEVICE_CONTROL2;
+
+typedef union {
+  struct {
+U

[edk2-devel] [edk2-platforms][PATCH v5 0/5] Add initial support for N1SDP board

2020-07-22 Thread Pranav Madhu
Changes since v4:
- Updated indents and spacing, functionally same as v4.

Changes since v3:
- Addressed all the comments from Leif. As part of the clean up that
  resulted from addressing the comments, some of the comments where not
  applicable anymore (due to fragments of code that had comments were
  removed during cleanup).
- Included detailed description of the workarounds applied to the
  Neoverse N1 SoC specific PciExpressLib library.
- Updated Maintainers.txt to add Silicon/ARM/ directory under ARM entry.
- Picked up Leif's Reviewed-by tag for the 4th patch of this series.
- Addressed all the comments from Ard.

Changes since v2:
- Addressed comments from Thomas.
- Renamed Silicon/ARM/N1SDP to Silicon/ARM/NeoverseN1Soc.

Changes since v1:
- Addressed comments from Ard.
- Split the code between Silicon and Platform directories.

Arm's N1SDP is a Arm v8.2-A Neoverse N1 CPU based reference design platform
primariliy intended for development on Arm64 based platform. This patch series
adds initial support for Arm's Neoverse N1 SoC and platform support for the
N1SDP board.

The first patch in this series adds the platform libary implementation. The
second patch adds a custom implementation of the PciExpressLib due to a PCIe
integration issue which results in all config space accesses to non-existing
BDFs resulting in a Serror (bus abort). To avoid this, the N1SDP specific
PciExpressLib implementation provides a workaround for this issue. The third
patch in this series adds the platform library for the PciHostBridge. The
fourth patch adds the initial platform support for the N1SDP platform. The
fifth patch adds Silicon/ARM/ to ARM entry in maintainers file.

Deepak Pandey (4):
  Silicon/ARM/N1SoC: Add platform library implementation
  Silicon/ARM/N1SoC: Implement Neoverse N1 SoC specific PciExpressLib
  Silicon/ARM/N1SoC: Implement the PciHostBridgeLib library
  Platform/ARM/N1SDP: Add initial N1SDP platform support

Pranav Madhu (1):
  Maintainers.txt: Add Silicon/ARM directory

 Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
|   46 +
 Platform/ARM/N1Sdp/N1SdpPlatform.dsc   
|  245 +++
 Platform/ARM/N1Sdp/N1SdpPlatform.fdf   
|  294 
 Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf 
|   56 +
 Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf
|   49 +
 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf  
|   54 +
 Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h  
|   66 +
 Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c   
| 1589 
 Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c  
|  184 +++
 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.c
|   67 +
 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c 
|  151 ++
 Maintainers.txt
|1 +
 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/AArch64/Helper.S 
|   84 ++
 13 files changed, 2886 insertions(+)
 create mode 100644 Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
 create mode 100644 Platform/ARM/N1Sdp/N1SdpPlatform.dsc
 create mode 100644 Platform/ARM/N1Sdp/N1SdpPlatform.fdf
 create mode 100644 
Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf
 create mode 100644 
Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf
 create mode 100644 
Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
 create mode 100644 Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
 create mode 100644 
Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c
 create mode 100644 
Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c
 create mode 100644 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.c
 create mode 100644 
Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
 create mode 100644 
Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/AArch64/Helper.S

-- 
2.7.4


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63122): https://edk2.groups.io/g/devel/message/63122
Mute This Topic: https://groups.io/mt/75726808/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms][PATCH v5 2/5] Silicon/ARM/N1SoC: Implement Neoverse N1 SoC specific PciExpressLib

2020-07-22 Thread Pranav Madhu
From: Deepak Pandey 

A slave error is generated when host accesses the config space of
non-available device or unimplemented function on a given bus. So
implement a Neoverse N1 SoC specific PciExpressLib library with a
workaround to return 0x for all such access.

This library is inherited from MdePkg/Library/BasePciExpressLib and
based on commit 9344f0921518 of that library in the tianocore/edk2
project.

In addition to this, the Neoverse N1 SoC has two other limitations which
affect the access to the PCIe root port:
  1. ECAM space is not contiguous, root port ECAM (BDF = 0:0:0) is
 isolated from rest of the downstream hierarchy ECAM space.
  2. Root port ECAM space is not capable of 8bit/16bit writes.
This library includes workaround for these limitations as well.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pranav Madhu 
---
 Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
|4 +
 Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf 
|   56 +
 Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c   
| 1589 
 3 files changed, 1649 insertions(+)

diff --git a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec 
b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
index dba49e6489c0..491806b81be9 100644
--- a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
+++ b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
@@ -25,3 +25,7 @@ [Guids.common]
 [PcdsFixedAtBuild]
   # Secondary DDR memory
   gArmNeoverseN1SocTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x0001
+
+  #PCIe
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseAddress|0x6000|UINT32|0x0002
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseSize|0x1000|UINT32|0x0003
diff --git 
a/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf
 
b/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf
new file mode 100644
index ..acb6fb62197f
--- /dev/null
+++ 
b/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf
@@ -0,0 +1,56 @@
+## @file
+#  Instance of PCI Express Library using the 256 MB PCI Express MMIO window.
+#
+#  PCI Express Library that uses the 256 MB PCI Express MMIO window to perform
+#  PCI Configuration cycles. Layers on top of an I/O Library instance.
+#
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+#
+#  This library is inherited from MdePkg/Library/BasePciExpressLib. On
+#  NeoverseN1 SoC, with the unmodified version of this library, a slave error 
is
+#  generated when host accesses the config space of a non-available device or
+#  unimplemented function on a given bus. In order to resolve this for
+#  NeoverseN1 SoC, a modified version of the MdePkg/Library/BasePciExpressLib
+#  library is used. The modification includes a check to determine whether the
+#  incoming PCI address can be safely accessed.
+#
+#  In addition to this, the NeoverseN1 SoC has two other limitations which
+#  affect the access to the PCIe root port:
+#1. ECAM space is not contiguous, root port ECAM (BDF = 0:0:0) is isolated
+#   from rest of the downstream hierarchy ECAM space.
+#2. Root port ECAM space is not capable of 8bit/16bit writes.
+#  This library includes workaround for these limitations as well.
+#
+#  Copyright (c) 2020, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = BasePciExpressLib
+  FILE_GUID  = b378dd06-de7f-4e8c-8fb0-5126adfb34bf
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = PciExpressLib
+
+[Sources]
+  PciExpressLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
+
+[FixedPcd]
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseAddress
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseSize
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  IoLib
+  PcdLib
+
+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress  ## CONSUMES
diff --git 
a/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c 
b/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c
new file mode 100644
index ..bb0246b4a9e7
--- /dev/null
+++ 
b/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c
@@ -0,0 +1,1589 @@
+/** @file
+  Functions in this library instance make use of MMIO functions in IoLib to
+  access memory mapped PCI configuration space.
+
+  All assertions for I/O operations are handled in MMIO functions in the IoLib
+  Library.
+
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+
+  On the NeoverseN1Soc, a slave error is generated when host accesses the
+  configuration space of non-available device or unimplemented functio

[edk2-devel] [PATCH V3 2/2] MdePkg/Include/IndustryStandard: Main CXL header

2020-07-22 Thread Javeed, Ashraf
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2611

Introducing the Cxl.h as the main header file to support all versions
of Compute Express Link Specification register definitions.

Signed-off-by: Ashraf Javeed 
Cc: Michael D Kinney 
Cc: Liming Gao 
--

V2: Indentation and double declaration fix, copyright date update

V3: Copyright date fix
---
 MdePkg/Include/IndustryStandard/Cxl.h | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/Cxl.h 
b/MdePkg/Include/IndustryStandard/Cxl.h
new file mode 100644
index 00..632aa146d0
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Cxl.h
@@ -0,0 +1,22 @@
+/** @file
+  Support for the latest CXL standard
+
+  The main header to reference all versions of CXL Base specification registers
+  from the MDE
+
+Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _CXL_MAIN_H_
+#define _CXL_MAIN_H_
+
+#include 
+//
+// CXL assigned new Vendor ID
+//
+#define CXL_DVSEC_VENDOR_ID 0x1E98
+
+#endif
+
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63120): https://edk2.groups.io/g/devel/message/63120
Mute This Topic: https://groups.io/mt/75726736/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] EmbeddedPkg: fix gcc build errors in AndroidBootImgLib

2020-07-22 Thread Leif Lindholm
On Tue, Jul 21, 2020 at 13:18:02 +, Pierre Gondois wrote:
> Hello Leif,
> I actually submitted this modification on the build flags because of
> the error that you fixed. I submitted a similar modification here
> https://edk2.groups.io/g/devel/message/61832 .

Right, sorry, I think I had a micommunication with Ard about who was
looking at that. I'll respond to that separately.

Fwiw I prefer my version of the fix, so if Laszlo could review this
one, I would be most grateful.

> I should have waited before modifying the flags, my apologizes.

Ideally, the change would have been part of the same set - then this
sort of mix-up could not have happened.
The real problem was the being merged without Arm maintainer review.

Regards,

Leif

> I tried building edk2 top-level packages and this should be the only impact.
> 
> Regards,
> Pierre
> 
> -Original Message-
> From: Leif Lindholm 
> Sent: 21 July 2020 13:51
> To: devel@edk2.groups.io
> Cc: Pierre Gondois ; Laszlo Ersek 
> ; Bob Feng 
> Subject: [PATCH 1/1] EmbeddedPkg: fix gcc build errors in AndroidBootImgLib
> 
> Commit dbd546a32d5a
> ("BaseTools: Add gcc flag to warn on void* pointer arithmetic") does its work 
> and triggers build errors in this library.
> Update the affected code to build correctly again.
> 
> Cc: Pierre Gondois 
> Cc: Laszlo Ersek 
> Cc: Bob Feng
> Signed-off-by: Leif Lindholm 
> ---
> 
> Pierre - can you please ensure to CC Arm maintainers when proposing changes 
> to Arm build flags? (And build test all the top-level edk2 packages *cough*.)
> 
> Bob - can you please ensure Arm maintainers have commented on changes to 
> global build flags?
> (Would it be possible to break up tools_def.template into separate 
> arch-specific include files so we could have GetMaintainer.py be more helpful 
> for this?)
> 
> Laszlo - you're not formally an EmbeddedPkg reviewer, but Ard is out for 
> another couple of weeks. But since the Linaro CI is currently broken and the 
> fix is trivial, could you have a look please?
> 
>  EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
> b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> index e1036954ee58..15b5bf451330 100644
> --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> @@ -97,7 +97,7 @@ AndroidBootImgGetKernelInfo (
>ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize));
> 
>*KernelSize = Header->KernelSize;
> -  *Kernel = BootImg + Header->PageSize;
> +  *Kernel = (VOID *)((UINTN)BootImg + Header->PageSize);
>return EFI_SUCCESS;
>  }
> 
> @@ -341,7 +341,7 @@ AndroidBootImgUpdateFdt (
> 
>Status = AndroidBootImgSetProperty64 (UpdatedFdtBase, ChosenNode,
>  "linux,initrd-end",
> -(UINTN)(RamdiskData + RamdiskSize));
> +((UINTN)RamdiskData +
> + RamdiskSize));
>if (EFI_ERROR (Status)) {
>  goto Fdt_Exit;
>}
> --
> 2.20.1
> 
> IMPORTANT NOTICE: The contents of this email and any attachments are 
> confidential and may also be privileged. If you are not the intended 
> recipient, please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy the 
> information in any medium. Thank you.

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63121): https://edk2.groups.io/g/devel/message/63121
Mute This Topic: https://groups.io/mt/75702678/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms][PATCH v5 3/5] Silicon/ARM/N1SoC: Implement the PciHostBridgeLib library

2020-07-22 Thread Pranav Madhu
From: Deepak Pandey 

Neoverse N1 SoC includes a PCIe root complex to which a AHCI, GbE and
USB controllers are attached as an endpoint. So implement the
PciHostBridgeLib glue layer and enable support for PCIe controller and
all the devices connected over the PCIe bus.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pranav Madhu 
---
 Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec |  15 
++
 Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf |  49 
++
 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf   |  11 
++
 Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c   | 184 

 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c  |  28 
++-
 5 files changed, 286 insertions(+), 1 deletion(-)

diff --git a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec 
b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
index 491806b81be9..54b793a937ff 100644
--- a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
+++ b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
@@ -29,3 +29,18 @@ [PcdsFixedAtBuild]
   #PCIe
   
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseAddress|0x6000|UINT32|0x0002
   
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseSize|0x1000|UINT32|0x0003
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusCount|18|UINT32|0x0004
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMax|17|UINT32|0x0005
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMin|0|UINT32|0x0006
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoBase|0x0|UINT32|0x0007
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoMaxBase|0x00FF|UINT32|0x0008
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoSize|0x0100|UINT32|0x0009
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoTranslation|0x7520|UINT32|0x000A
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Base|0x7120|UINT32|0x000B
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32MaxBase|0x751F|UINT32|0x000C
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Size|0x0400|UINT32|0x000D
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Translation|0x0|UINT32|0x000E
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Base|0x09|UINT64|0x000F
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64MaxBase|0x28|UINT64|0x0010
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Size|0x20|UINT64|0x0011
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Translation|0x0|UINT64|0x0012
diff --git 
a/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf 
b/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf
new file mode 100644
index ..3ff1c592f2a7
--- /dev/null
+++ b/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.inf
@@ -0,0 +1,49 @@
+## @file
+#  PCI Host Bridge Library instance for ARM Neoverse N1 platform.
+#
+#  Copyright (c) 2019 - 2020, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = PciHostBridgeLib
+  FILE_GUID  = daa340e1-89dd-4bd2-b645-ebe75e541f8b
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = PciHostBridgeLib|DXE_DRIVER
+
+[Sources]
+  PciHostBridgeLib.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  DevicePathLib
+  IoLib
+  MemoryAllocationLib
+  UefiBootServicesTableLib
+
+[FixedPcd]
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMin
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMax
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoBase
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoSize
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Base
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Size
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Base
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Size
+
+[Protocols]
+  gEfiCpuIo2ProtocolGuid
+
+[Depex]
+  gEfiCpuIo2ProtocolGuid
diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf 
b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
index e4d720bd36f5..166c9e044483 100644
--- a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
+++ b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
@@ -29,11 +29,22 @@ [Sources.AARCH64]
   AArch64/Helper.S | GCC
 
 [FixedPcd]
+  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
+
   gArmTokenSpaceGuid.PcdSystemMemoryBase
   gArmTokenSpaceGuid.PcdSystemMemorySize
   gArmTokenSpaceGuid.PcdArmPrimaryCore
   gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
 
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMax
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMin
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Base
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Size

[edk2-devel] [edk2-platforms][PATCH v5 5/5] Maintainers.txt: Add Silicon/ARM directory

2020-07-22 Thread Pranav Madhu
Include Silicon/ARM directory under ARM section entry.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pranav Madhu 
---
 Maintainers.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Maintainers.txt b/Maintainers.txt
index 9fc41187b747..393f592f3c4b 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -93,6 +93,7 @@ M: Leif Lindholm 
 
 ARM
 F: Platform/ARM/
+F: Silicon/ARM/
 R: Ard Biesheuvel 
 R: Thomas Abraham 
 M: Leif Lindholm 
-- 
2.7.4


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63127): https://edk2.groups.io/g/devel/message/63127
Mute This Topic: https://groups.io/mt/75726815/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH V3 0/2] CXL Specification Registers

2020-07-22 Thread Javeed, Ashraf
These 2 patches introduces the Compute Express Link (CXL) Specificition
registers definitions to the MDE.
The Cxl11.h has the actual register definitions of the CXL Specification
Revision 1.1; and the Cxl.h is the main header file to include all
versions of the CXL register definitions.

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

Signed-off-by: Ashraf Javeed 
Cc: Michael D Kinney 
Cc: Liming Gao 
--

Ashraf Javeed (2):
  MdePkg/Include/IndustryStandard: CXL 1.1 Registers
  MdePkg/Include/IndustryStandard: Main CXL header

 MdePkg/Include/IndustryStandard/Cxl.h   |  22 ++
 MdePkg/Include/IndustryStandard/Cxl11.h | 569 
+
 MdePkg/Include/IndustryStandard/Pci.h   |   6 ++
 3 files changed, 593 insertions(+), 4 deletions(-)
 create mode 100644 MdePkg/Include/IndustryStandard/Cxl.h
 create mode 100644 MdePkg/Include/IndustryStandard/Cxl11.h

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63118): https://edk2.groups.io/g/devel/message/63118
Mute This Topic: https://groups.io/mt/75726733/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms][PATCH v5 1/5] Silicon/ARM/N1SoC: Add platform library implementation

2020-07-22 Thread Pranav Madhu
From: Deepak Pandey 

Add the initial Arm's Neoverse N1 System-on-Chip platform library
support. This includes the virtual memory map and helper functions for
platform initialization.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pranav Madhu 
---
 Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec|  27 +
 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf  |  43 +++
 Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h  |  66 
+++
 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.c|  67 
+++
 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c | 125 

 Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/AArch64/Helper.S |  84 
+
 6 files changed, 412 insertions(+)

diff --git a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec 
b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
new file mode 100644
index ..dba49e6489c0
--- /dev/null
+++ b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
@@ -0,0 +1,27 @@
+#
+#  Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+[Defines]
+  DEC_SPECIFICATION  = 0x0001001A
+  PACKAGE_NAME   = NeoverseN1Soc
+  PACKAGE_GUID   = b6d2d197-76d0-401f-a3e0-826a26f350c9
+  PACKAGE_VERSION= 0.1
+
+
+#
+# Include Section - list of Include Paths that are provided by this package.
+#   Comments are used for Keywords and Module Types.
+#
+
+[Includes.common]
+  Include# Root include for the package
+
+[Guids.common]
+  gArmNeoverseN1SocTokenSpaceGuid = { 0xab93eb78, 0x60d7, 0x4099, { 0xac, 
0xeb, 0x6d, 0xb5, 0x02, 0x58, 0x7c, 0x24 } }
+
+[PcdsFixedAtBuild]
+  # Secondary DDR memory
+  gArmNeoverseN1SocTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x0001
diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf 
b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
new file mode 100644
index ..e4d720bd36f5
--- /dev/null
+++ b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
@@ -0,0 +1,43 @@
+## @file
+#
+#  Copyright (c) 2018-2020, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = ArmNeoverseN1SocLib
+  FILE_GUID  = 3d0eafcf-abc1-43d8-9269-709bb24f9d21
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = ArmPlatformLib
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
+
+[Sources.common]
+  PlatformLibMem.c
+  PlatformLib.c
+
+[Sources.AARCH64]
+  AArch64/Helper.S | GCC
+
+[FixedPcd]
+  gArmTokenSpaceGuid.PcdSystemMemoryBase
+  gArmTokenSpaceGuid.PcdSystemMemorySize
+  gArmTokenSpaceGuid.PcdArmPrimaryCore
+  gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
+
+  gArmNeoverseN1SocTokenSpaceGuid.PcdDramBlock2Base
+
+[Guids]
+  gEfiHobListGuid  ## CONSUMES  ## SystemTable
+
+[Ppis]
+  gArmMpCoreInfoPpiGuid
diff --git a/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h 
b/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
new file mode 100644
index ..52e7f92e833a
--- /dev/null
+++ b/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
@@ -0,0 +1,66 @@
+/** @file
+*
+* Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
+*
+* SPDX-License-Identifier: BSD-2-Clause-Patent
+*
+**/
+
+#ifndef NEOVERSEN1SOC_PLATFORM_H_
+#define NEOVERSEN1SOC_PLATFORM_H_
+
+#define NEOVERSEN1SOC_DRAM_BLOCK1_SIZE   SIZE_2GB
+
+//**
+// Platform Memory Map
+//**
+
+// SubSystem Peripherals - UART0
+#define NEOVERSEN1SOC_UART0_BASE 0x2A40
+#define NEOVERSEN1SOC_UART0_SZ   SIZE_64KB
+
+// SubSystem Peripherals - UART1
+#define NEOVERSEN1SOC_UART1_BASE 0x2A41
+#define NEOVERSEN1SOC_UART1_SZ   SIZE_64KB
+
+// SubSystem Peripherals - Generic Watchdog
+#define NEOVERSEN1SOC_GENERIC_WDOG_BASE  0x2A44
+#define NEOVERSEN1SOC_GENERIC_WDOG_SZSIZE_128KB
+
+// SubSystem Peripherals - GIC(600)
+#define NEOVERSEN1SOC_GIC_BASE   0x3000
+#define NEOVERSEN1SOC_GICR_BASE  0x300C
+#define NEOVERSEN1SOC_GIC_SZ SIZE_256KB
+#define NEOVERSEN1SOC_GICR_SZSIZE_1MB
+
+// SubSystem non-secure SRAM
+#define NEOVERSEN1SOC_NON_SECURE_SRA

Re: [edk2-devel] [PATCH v3 1/3] UefiPayloadPkg: Store the size of the MMCONF window

2020-07-22 Thread Ma, Maurice
Reviewed-by: Maurice Ma 

> -Original Message-
> From: Marcello Sylvester Bauer 
> Sent: Wednesday, July 22, 2020 6:16
> To: devel@edk2.groups.io
> Cc: Patrick Rudolph ; Christian Walter
> ; Ma, Maurice ;
> Dong, Guo ; You, Benjamin 
> Subject: [PATCH v3 1/3] UefiPayloadPkg: Store the size of the MMCONF
> window
> 
> From: Patrick Rudolph 
> 
> Store the real size of the Pcie Memory Mapped Address Space.
> This change is necessary to support variable size of MMCONF spaces.
> 
> Signed-off-by: Patrick Rudolph 
> Signed-off-by: Marcello Sylvester Bauer 
> Cc: Patrick Rudolph 
> Cc: Christian Walter 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> ---
>  UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h | 1 +
>  UefiPayloadPkg/BlSupportPei/BlSupportPei.c  | 3 +++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h
> b/UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h
> index fe783fe5e14c..043b748ae4a9 100644
> --- a/UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h
> +++ b/UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h
> @@ -24,6 +24,7 @@ typedef struct {
>UINT64 PmTimerRegBase;
> 
>UINT64 ResetRegAddress;
> 
>UINT64 PcieBaseAddress;
> 
> +  UINT64 PcieBaseSize;
> 
>  } ACPI_BOARD_INFO;
> 
> 
> 
>  #endif
> 
> diff --git a/UefiPayloadPkg/BlSupportPei/BlSupportPei.c
> b/UefiPayloadPkg/BlSupportPei/BlSupportPei.c
> index 22972453117a..a7e99f9ec6de 100644
> --- a/UefiPayloadPkg/BlSupportPei/BlSupportPei.c
> +++ b/UefiPayloadPkg/BlSupportPei/BlSupportPei.c
> @@ -240,8 +240,10 @@ Done:
>if (MmCfgHdr != NULL) {
> 
>  MmCfgBase =
> (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_A
> DDRESS_ALLOCATION_STRUCTURE *)((UINT8*) MmCfgHdr + sizeof
> (*MmCfgHdr));
> 
>  AcpiBoardInfo->PcieBaseAddress = MmCfgBase->BaseAddress;
> 
> +AcpiBoardInfo->PcieBaseSize = (MmCfgBase->EndBusNumber + 1 -
> MmCfgBase->StartBusNumber) * 4096 * 32 * 8;
> 
>} else {
> 
>  AcpiBoardInfo->PcieBaseAddress = 0;
> 
> +AcpiBoardInfo->PcieBaseSize = 0;
> 
>}
> 
>DEBUG ((DEBUG_INFO, "PmCtrl  Reg 0x%lx\n",  AcpiBoardInfo-
> >PmCtrlRegBase));
> 
>DEBUG ((DEBUG_INFO, "PmTimer Reg 0x%lx\n",  AcpiBoardInfo-
> >PmTimerRegBase));
> 
> @@ -250,6 +252,7 @@ Done:
>DEBUG ((DEBUG_INFO, "PmEvt   Reg 0x%lx\n",  AcpiBoardInfo->PmEvtBase));
> 
>DEBUG ((DEBUG_INFO, "PmGpeEn Reg 0x%lx\n",  AcpiBoardInfo-
> >PmGpeEnBase));
> 
>DEBUG ((DEBUG_INFO, "PcieBaseAddr 0x%lx\n", AcpiBoardInfo-
> >PcieBaseAddress));
> 
> +  DEBUG ((DEBUG_INFO, "PcieBaseSize 0x%lx\n", AcpiBoardInfo-
> >PcieBaseSize));
> 
> 
> 
>//
> 
>// Verify values for proper operation
> 
> --
> 2.27.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63117): https://edk2.groups.io/g/devel/message/63117
Mute This Topic: https://groups.io/mt/75724105/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v3 1/3] UefiPayloadPkg: Store the size of the MMCONF window

2020-07-22 Thread Marcello Sylvester Bauer
From: Patrick Rudolph 

Store the real size of the Pcie Memory Mapped Address Space.
This change is necessary to support variable size of MMCONF spaces.

Signed-off-by: Patrick Rudolph 
Signed-off-by: Marcello Sylvester Bauer 
Cc: Patrick Rudolph 
Cc: Christian Walter 
Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
---
 UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h | 1 +
 UefiPayloadPkg/BlSupportPei/BlSupportPei.c  | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h 
b/UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h
index fe783fe5e14c..043b748ae4a9 100644
--- a/UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h
+++ b/UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h
@@ -24,6 +24,7 @@ typedef struct {
   UINT64 PmTimerRegBase;
   UINT64 ResetRegAddress;
   UINT64 PcieBaseAddress;
+  UINT64 PcieBaseSize;
 } ACPI_BOARD_INFO;
 
 #endif
diff --git a/UefiPayloadPkg/BlSupportPei/BlSupportPei.c 
b/UefiPayloadPkg/BlSupportPei/BlSupportPei.c
index 22972453117a..a7e99f9ec6de 100644
--- a/UefiPayloadPkg/BlSupportPei/BlSupportPei.c
+++ b/UefiPayloadPkg/BlSupportPei/BlSupportPei.c
@@ -240,8 +240,10 @@ Done:
   if (MmCfgHdr != NULL) {
 MmCfgBase = 
(EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE
 *)((UINT8*) MmCfgHdr + sizeof (*MmCfgHdr));
 AcpiBoardInfo->PcieBaseAddress = MmCfgBase->BaseAddress;
+AcpiBoardInfo->PcieBaseSize = (MmCfgBase->EndBusNumber + 1 - 
MmCfgBase->StartBusNumber) * 4096 * 32 * 8;
   } else {
 AcpiBoardInfo->PcieBaseAddress = 0;
+AcpiBoardInfo->PcieBaseSize = 0;
   }
   DEBUG ((DEBUG_INFO, "PmCtrl  Reg 0x%lx\n",  AcpiBoardInfo->PmCtrlRegBase));
   DEBUG ((DEBUG_INFO, "PmTimer Reg 0x%lx\n",  AcpiBoardInfo->PmTimerRegBase));
@@ -250,6 +252,7 @@ Done:
   DEBUG ((DEBUG_INFO, "PmEvt   Reg 0x%lx\n",  AcpiBoardInfo->PmEvtBase));
   DEBUG ((DEBUG_INFO, "PmGpeEn Reg 0x%lx\n",  AcpiBoardInfo->PmGpeEnBase));
   DEBUG ((DEBUG_INFO, "PcieBaseAddr 0x%lx\n", AcpiBoardInfo->PcieBaseAddress));
+  DEBUG ((DEBUG_INFO, "PcieBaseSize 0x%lx\n", AcpiBoardInfo->PcieBaseSize));
 
   //
   // Verify values for proper operation
-- 
2.27.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63114): https://edk2.groups.io/g/devel/message/63114
Mute This Topic: https://groups.io/mt/75724105/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v3 3/3] UefiPayloadPkg: Support variable size MMCONF space

2020-07-22 Thread Marcello Sylvester Bauer
The default size is still 256MiB, but will be overwritten by
UefiPayloadPkg with the real MMCONF size.

e.g.: On embedded AMD platforms the MMCONF window size is usually
  only 64MiB.

Fixes crash on platforms not exposing 256 buses.
Tested on:
* AMD Stoney Ridge

Signed-off-by: Patrick Rudolph 
Signed-off-by: Marcello Sylvester Bauer 
Cc: Patrick Rudolph 
Cc: Christian Walter 
Cc: Maurice Ma 
Cc: Nate DeSimone 
Cc: Benjamin You 
---
 UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc | 1 +
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 1 +
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c   | 4 +++-
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc 
b/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc
index a768a8702c66..162cbf47a83f 100644
--- a/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc
@@ -363,6 +363,7 @@ [PcdsDynamicDefault]
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|31
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|100
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0
+  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0
 
 

 #
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf 
b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
index 1371d5eb7952..cebc81135565 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
@@ -54,6 +54,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
+  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize
 
 [Depex]
   TRUE
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c 
b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
index a3974dcc02f8..a746d0581ee3 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -155,13 +155,15 @@ BlDxeEntryPoint (
   }
 
   //
-  // Set PcdPciExpressBaseAddress by HOB info
+  // Set PcdPciExpressBaseAddress and PcdPciExpressBaseSize by HOB info
   //
   GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);
   if (GuidHob != NULL) {
 AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);
 Status = PcdSet64S (PcdPciExpressBaseAddress, 
AcpiBoardInfo->PcieBaseAddress);
 ASSERT_EFI_ERROR (Status);
+Status = PcdSet64S (PcdPciExpressBaseSize, AcpiBoardInfo->PcieBaseSize);
+ASSERT_EFI_ERROR (Status);
   }
 
   return EFI_SUCCESS;
-- 
2.27.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63116): https://edk2.groups.io/g/devel/message/63116
Mute This Topic: https://groups.io/mt/75724111/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v3 2/3] MdePkg/BasePciExpressLib: Support variable size MMCONF

2020-07-22 Thread Marcello Sylvester Bauer
Add support for arbitrary sized MMCONF by introducing a new PCD.

Signed-off-by: Patrick Rudolph 
Signed-off-by: Marcello Sylvester Bauer 
Cc: Patrick Rudolph 
Cc: Christian Walter 
Cc: Michael D Kinney 
Cc: Liming Gao 
---
 MdePkg/MdePkg.dec  |   4 +
 MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf |   6 +-
 MdePkg/Include/Library/PciExpressLib.h |   5 +-
 MdePkg/Library/BasePciExpressLib/PciExpressLib.c   | 216 
+---
 4 files changed, 193 insertions(+), 38 deletions(-)

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 73f6c2407357..02e736a01126 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -2274,6 +2274,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, 
PcdsDynamicEx]
   # @Prompt PCI Express Base Address.
   
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE000|UINT64|0x000a
 
+  ## This value is used to set the size of PCI express hierarchy. The default 
is 256 MB.
+  # @Prompt PCI Express Base Size.
+  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0x0FFF|UINT64|0x000f
+
   ## Default current ISO 639-2 language: English & French.
   # @Prompt Default Value of LangCodes Variable.
   
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangCodes|"engfraengfra"|VOID*|0x001c
diff --git a/MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf 
b/MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
index a7edb74cde71..12734b022ac7 100644
--- a/MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
+++ b/MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
@@ -1,7 +1,7 @@
 ## @file
-#  Instance of PCI Express Library using the 256 MB PCI Express MMIO window.
+#  Instance of PCI Express Library using the variable size PCI Express MMIO 
window.
 #
-#  PCI Express Library that uses the 256 MB PCI Express MMIO window to perform
+#  PCI Express Library that uses the variable size PCI Express MMIO window to 
perform
 #  PCI Configuration cycles. Layers on top of an I/O Library instance.
 #
 #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
@@ -38,4 +38,4 @@ [LibraryClasses]
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress  ## CONSUMES
-
+  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize  ## CONSUMES
diff --git a/MdePkg/Include/Library/PciExpressLib.h 
b/MdePkg/Include/Library/PciExpressLib.h
index 826fdcf7db6c..d78193a0a352 100644
--- a/MdePkg/Include/Library/PciExpressLib.h
+++ b/MdePkg/Include/Library/PciExpressLib.h
@@ -2,8 +2,9 @@
   Provides services to access PCI Configuration Space using the MMIO PCI 
Express window.
 
   This library is identical to the PCI Library, except the access method for 
performing PCI
-  configuration cycles must be through the 256 MB PCI Express MMIO window 
whose base address
-  is defined by PcdPciExpressBaseAddress.
+  configuration cycles must be through the PCI Express MMIO window whose base 
address
+  is defined by PcdPciExpressBaseAddress and size defined by 
PcdPciExpressBaseSize.
+
 
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/MdePkg/Library/BasePciExpressLib/PciExpressLib.c 
b/MdePkg/Library/BasePciExpressLib/PciExpressLib.c
index 99a166c3609b..0311ecb3025f 100644
--- a/MdePkg/Library/BasePciExpressLib/PciExpressLib.c
+++ b/MdePkg/Library/BasePciExpressLib/PciExpressLib.c
@@ -22,7 +22,8 @@
 
 /**
   Assert the validity of a PCI address. A valid PCI address should contain 1's
-  only in the low 28 bits.
+  only in the low 28 bits. PcdPciExpressBaseSize limits the size to the real
+  number of PCI busses in this segment.
 
   @param  A The address to validate.
 
@@ -79,6 +80,24 @@ GetPciExpressBaseAddress (
   return (VOID*)(UINTN) PcdGet64 (PcdPciExpressBaseAddress);
 }
 
+/**
+  Gets the size of PCI Express.
+
+  This internal functions retrieves PCI Express Base Size via a PCD entry
+  PcdPciExpressBaseSize.
+
+  @return The base size of PCI Express.
+
+**/
+STATIC
+UINTN
+PcdPciExpressBaseSize (
+  VOID
+  )
+{
+  return (UINTN) PcdGet64 (PcdPciExpressBaseSize);
+}
+
 /**
   Reads an 8-bit PCI configuration register.
 
@@ -91,7 +110,8 @@ GetPciExpressBaseAddress (
   @param  Address The address that encodes the PCI Bus, Device, Function and
   Register.
 
-  @return The read value from the PCI configuration register.
+  @retval 0xFF  Invalid PCI address.
+  @retval other The read value from the PCI configuration register.
 
 **/
 UINT8
@@ -101,6 +121,9 @@ PciExpressRead8 (
   )
 {
   ASSERT_INVALID_PCI_ADDRESS (Address);
+  if (Address >= PcdPciExpressBaseSize()) {
+return (UINT8) ~0;
+  }
   return MmioRead8 ((UINTN) GetPciExpressBaseAddress () + Address);
 }
 
@@ -117,7 +140,8 @@ PciExpressRead8 (
   Register.
   @param  Value   The value to write.
 
-  @return The value written to the PCI configuration register.
+  @retval 0xFF  Invalid PCI address.
+  @retval other The value written t

[edk2-devel] [PATCH v3 0/3] UefiPayloadPkg: Runtime MMCONF

2020-07-22 Thread Marcello Sylvester Bauer
Support arbitrary platforms with different or even no MMCONF space.
Fixes crash on platforms not exposing 256 buses.

Tested on:
* AMD Stoney Ridge

Branch: https://github.com/9elements/edk2-1/tree/UefiPayloadPkg-MMCONF
PR: https://github.com/tianocore/edk2/pull/817

v3:
* split patch 2 by package
* MdePkg/PciExpress:
  - PciExpressXX add return value specification
  - Undo remove of ASSERT()
  - PcdPciExpressBaseSize() correct function header
  - correct return value types

v2:
* rebased with regards to commit 3900a63e3a1b9ba9a4105bedead7b986188cec2c
* add MdePkg Maintainer

Branch: https://github.com/9elements/edk2-1/tree/UefiPayloadPkg-MMCONF
PR: https://github.com/tianocore/edk2/pull/801

Marcello Sylvester Bauer (2):
  MdePkg/BasePciExpressLib: Support variable size MMCONF
  UefiPayloadPkg: Support variable size MMCONF space

Patrick Rudolph (1):
  UefiPayloadPkg: Store the size of the MMCONF window

 MdePkg/MdePkg.dec  |   4 +
 UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc   |   1 +
 MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf |   6 +-
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf   |   1 +
 MdePkg/Include/Library/PciExpressLib.h |   5 +-
 UefiPayloadPkg/Include/Guid/AcpiBoardInfoGuid.h|   1 +
 MdePkg/Library/BasePciExpressLib/PciExpressLib.c   | 216 
+---
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c |   4 +-
 UefiPayloadPkg/BlSupportPei/BlSupportPei.c |   3 +
 9 files changed, 202 insertions(+), 39 deletions(-)

-- 
2.27.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63113): https://edk2.groups.io/g/devel/message/63113
Mute This Topic: https://groups.io/mt/75724103/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 2/2] MdePkg: Add support for variable size MMCONF space

2020-07-22 Thread Marcello Sylvester Bauer
Hallo,

the second patch will be divided accordingly.

1) act (done for v3)
2) the other libraries are not required for the patch series. I will adapt
the commit message.
3) I will undo this change.
4) act (done for v3)
5) Indeed, my bad.

On Tue, Jul 21, 2020 at 2:49 AM Liming Gao  wrote:

> Marcello:
>   Besides separate the patch for the different packages, I have some
> comments on the change in PciExpressLib.
>
> 1) PciExpressxx() API description should be updated to include the invalid
> return value 0xFF, 0x or 0x in PciExpressLib.h and
> PciExpressLib library implementation.
> 2) There are three PciExprssion library instancs BasePciExpressLib,
> DxeRuntimePciExpressLib and SmmPciExpressLib. They are required to be
> updated.
> 3) For the change in MdePkg\Library\BasePciExpressLib, why remove ASSERT()
> in PciExpressRegisterForRuntimeAccess() function?
> 4) For the change in MdePkg\Library\BasePciExpressLib,
> PcdPciExpressBaseSize() function header return value description is
> incorrect.
> 5) For the change in MdePkg\Library\BasePciExpressLib,
> PciExpressAndThenOr32() function should return UINT32, but the code uses
> return (UINT16) ~0;. There are similar issues in other function
> implementation. Please check them.
>
> Thanks
> Liming
> -Original Message-
> From: Ma, Maurice 
> Sent: 2020年7月20日 23:26
> To: Marcello Sylvester Bauer ;
> devel@edk2.groups.io
> Cc: Patrick Rudolph ; Christian Walter <
> christian.wal...@9elements.com>; Desimone, Nathaniel L <
> nathaniel.l.desim...@intel.com>; Zeng, Star ;
> Kinney, Michael D ; Gao, Liming <
> liming@intel.com>
> Subject: RE: [PATCH v2 2/2] MdePkg: Add support for variable size MMCONF
> space
>
> Hi Marcello,
>
> Since this patch mixes changes for both UefiPayloadPkg  and MdePkg.  I
> think you might want to split this patch into two so that it can be
> reviewed by the proper package maintainers.
>
> Thanks
> Maurice
> > -Original Message-
> > From: Marcello Sylvester Bauer 
> > Sent: Thursday, July 16, 2020 4:48
> > To: devel@edk2.groups.io
> > Cc: Patrick Rudolph ; Christian Walter
> > ; Ma, Maurice ;
> > Desimone, Nathaniel L ; Zeng, Star
> > ; Kinney, Michael D ;
> > Gao, Liming 
> > Subject: [PATCH v2 2/2] MdePkg: Add support for variable size MMCONF
> > space
> >
> > From: Patrick Rudolph 
> >
> > On embedded AMD platforms the MMCONF window is usually only 64MiB.
> >
> > Add support for arbitrary sized MMCONF by introducing a new PCD.
> > The default size is still 256MiB, but will be overwritten by
> > UefiPayloadPkg with the real MMCONF size.
> >
> > Fixes crash on platforms not exposing 256 buses.
> >
> > Tested on:
> > * AMD Stoney Ridge
> >
> > Signed-off-by: Patrick Rudolph 
> > Signed-off-by: Marcello Sylvester Bauer 
> > Cc: Patrick Rudolph 
> > Cc: Christian Walter 
> > Cc: Maurice Ma 
> > Cc: Nate DeSimone 
> > Cc: Star Zeng 
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > ---
> >  MdePkg/MdePkg.dec  |   4 +
> >  UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc   |   1 +
> >  MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf |   6 +-
> >  UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf   |   1 +
> >  MdePkg/Include/Library/PciExpressLib.h |   5 +-
> >  MdePkg/Library/BasePciExpressLib/PciExpressLib.c   | 118
> > +++-
> >  UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c |   4 +-
> >  7 files changed, 131 insertions(+), 8 deletions(-)
> >
> > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index
> > 73f6c2407357..02e736a01126 100644
> > --- a/MdePkg/MdePkg.dec
> > +++ b/MdePkg/MdePkg.dec
> > @@ -2274,6 +2274,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule,
> > PcdsDynamic, PcdsDynamicEx]
> ># @Prompt PCI Express Base Address.
> > gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE000|UINT64|
> > 0x000a +  ## This value is used to set the size of PCI express
> > hierarchy. The default is 256 MB.+  # @Prompt PCI Express Base Size.+
> > gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0x0FFF|UINT64|0x00
> > 0f+   ## Default current ISO 639-2 language: English & French.   #
> > @Prompt Default Value of LangCodes Variable.
> > gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangCodes|"engfraengfra"
> > |VOID*|0x001cdiff --git a/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc
> > b/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc
> > index a768a8702c66..162cbf47a83f 100644
> > --- a/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc
> > +++ b/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc
> > @@ -363,6 +363,7 @@ [PcdsDynamicDefault]
> >gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|31
> > gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|100
> > gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0+
> > gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0
> > #
> > ### #diff --git
> > a/MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
> > b/MdePkg/Li

Re: [edk2-devel] [edk2-platforms][PATCH v4 2/5] Silicon/ARM/N1SoC: Implement Neoverse N1 Soc specific PciExpressLib

2020-07-22 Thread Leif Lindholm
On Tue, Jul 21, 2020 at 23:53:36 +0530, Thomas Abraham wrote:
> Hi Pranav,
> 
> On Sun, Jul 19, 2020 at 2:19 PM Pranav Madhu  wrote:
> >
> > From: Deepak Pandey 
> >
> > A slave error is generated when host accesses the config space of
> > non-available device or unimplemented function on a given bus. So
> > implement a Neoverse N1 SoC specific PciExpressLib library with a
> > workaround to return 0x for all such access.
> >
> > This library is inherited from MdePkg/Library/BasePciExpressLib and
> > based on commit 9344f0921518 of that library in the tianocore/edk2
> > project.
> >
> > In addition to this, the Neoverse N1 SoC has two other limitations which
> > affect the access to the PCIe root port:
> >   1. ECAM space is not contiguous, root port ECAM (BDF = 0:0:0) is
> >  isolated from rest of the downstream hierarchy ECAM space.
> >   2. Root port ECAM space is not capable of 8bit/16bit writes.
> > This library includes workaround for these limitations as well.
> >
> > Cc: Ard Biesheuvel 
> > Cc: Leif Lindholm 
> > Signed-off-by: Pranav Madhu 
> > ---
> >  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
> > |4 +
> >  
> > Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.inf
> >  |   56 +
> >  
> > Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpressLib.c
> >| 1589 
> >  3 files changed, 1649 insertions(+)
> >
> 
> <...>
> 
> > +UINT8
> > +EFIAPI
> > +PciExpressWrite8 (
> > +  IN  UINTN Address,
> > +  IN  UINT8 Value
> > +  )
> > +{
> > +  UINT8 Bus, Device, Function;
> > +  UINT8 Offset;
> > +  UINT32 Data;
> > +
> > +  ASSERT_INVALID_PCI_ADDRESS (Address);
> > +
> > +  Bus = GET_BUS_NUM (Address);
> > +  Device = GET_DEV_NUM (Address);
> > +  Function = GET_FUNC_NUM (Address);
> > +
> > +  //
> > +  // 8-bit and 16-bit writes to root port config space is not supported 
> > due to
> > +  // a hardware limitation. As a workaround, perform a read-update-write
> > +  // sequence on the whole 32-bit word of the root port config register 
> > such
> > +  // that only the specified 8-bits of that word are updated.
> > +  //
> > +  if ((Bus == 0) && (Device == 0) && (Function == 0)) {
> > +Offset = Address & 0x3;
> > +Address &= 0xFFFC;
> > +Data = MmioRead32 ((UINTN)GetPciExpressAddress (Address));
> 
> nit: There should have been a space before the GetPciExpressAddress.
> This is inconsistent with the rest of the file.

Actually, this is the correct way around.
If the rest of the file is different, that is what should change.

Regards,

Leif

> 
> Thanks,
> Thomas.
> 
> <...>

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63111): https://edk2.groups.io/g/devel/message/63111
Mute This Topic: https://groups.io/mt/75658679/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



答复: [edk2-devel] [PATCH edk2 v1 1/1] MdeModulePkg/Variable: Move FindVariable after AutoUpdateLangVariable

2020-07-22 Thread Ming Huang via groups.io
Hi Guomin,

Ok, it will take some time to do this.

Thanks
Ming

-邮件原件-
发件人: Jiang, Guomin [mailto:guomin.ji...@intel.com] 
发送时间: 2020年7月22日 14:49
收件人: Huangming (Mark) ; devel@edk2.groups.io; Wang, 
Jian J ; Wu, Hao A ; Gao, Liming 

抄送: Lidongzhan ; Songdongkuang 
; wanghuiqiang ; qiuliangen 
; Shenlimei ; xiewenyi (A) 
; John Garry 
主题: RE: [edk2-devel] [PATCH edk2 v1 1/1] MdeModulePkg/Variable: Move 
FindVariable after AutoUpdateLangVariable

Hi Ming,

Can you try the newest edk2?

Thanks
Guomin
> -Original Message-
> From: Huangming (Mark) 
> Sent: Wednesday, July 22, 2020 2:44 PM
> To: Jiang, Guomin ; devel@edk2.groups.io; 
> Wang, Jian J ; Wu, Hao A ; 
> Gao, Liming 
> Cc: Lidongzhan ; Songdongkuang 
> ; wanghuiqiang ; 
> qiuliangen ; Shenlimei ; 
> xiewenyi (A) ; John Garry 
> 
> Subject: 答复: [edk2-devel] [PATCH edk2 v1 1/1] MdeModulePkg/Variable:
> Move FindVariable after AutoUpdateLangVariable
> 
> Hi GuoMin,
> 
> I don't think the new change can fix this issue(id=2667). We use older 
> edk2 version which don't have SynchronizeRuntimeVariableCache().
> 
> Thanks
> Ming
> 
> -邮件原件-
> 发件人: Jiang, Guomin [mailto:guomin.ji...@intel.com]
> 发送时间: 2020年7月22日 8:47
> 收件人: Huangming (Mark) ; devel@edk2.groups.io; 
> Wang, Jian J ; Wu, Hao A ; 
> Gao, Liming 
> 抄送: Lidongzhan ; Songdongkuang 
> ; wanghuiqiang ; 
> qiuliangen ; Shenlimei ; 
> xiewenyi (A) ; John Garry 
> 
> 主题: RE: [edk2-devel] [PATCH edk2 v1 1/1] MdeModulePkg/Variable: Move 
> FindVariable after AutoUpdateLangVariable
> 
> Hi Ming,
> 
> The new posted change
> https://edk2.groups.io/g/devel/topic/75412007#62327 may be helpful for 
> this issue.
> 
> Can you add the change in your code and verify it?
> 
> Thanks
> Guomin
> > -Original Message-
> > From: Ming Huang 
> > Sent: Friday, July 3, 2020 8:49 PM
> > To: Jiang, Guomin ; devel@edk2.groups.io; 
> > Wang, Jian J ; Wu, Hao A 
> > ; Gao, Liming 
> > Cc: lidongz...@huawei.com; songdongku...@huawei.com; 
> > wanghuiqi...@huawei.com; qiulian...@huawei.com;
> shenli...@huawei.com;
> > xiewen...@huawei.com; john.ga...@huawei.com
> > Subject: Re: [edk2-devel] [PATCH edk2 v1 1/1] MdeModulePkg/Variable:
> > Move FindVariable after AutoUpdateLangVariable
> >
> >
> >
> > 在 2020/7/1 8:22, Jiang, Guomin 写道:
> > > So I think the key point is why AutoUpdateLangVariable() return 
> > > success
> > rather than fail, if is it reasonable for this case or we need other 
> > error handing?
> >
> > I don't think AutoUpdateLangVariable() should return fail while 
> > occur reclaim internal in AutoUpdateLangVariable () function. The 
> > problem is the
> > Variable(VARIABLE_POINTER_TRACK) get by FindVariable is invald in 
> > this situation and this Variable will be pass to UpdateVariable().
> >
> >   if (mVariableModuleGlobal->VariableGlobal.AuthSupport) {
> > Status = AuthVariableLibProcessVariable (VariableName, 
> > VendorGuid, Data, DataSize, Attributes);
> >   } else {
> > // This Variable is invald while occur reclaim internal in 
> > AutoUpdateLangVariable ()
> > Status = UpdateVariable (VariableName, VendorGuid, Data, 
> > DataSize, Attributes, 0, 0, &Variable, NULL);
> >   }
> >
> > >
> > > I am glad to help you but I can't reproduce it until now, can you 
> > > provide a
> > step to reproduce it in simulation platform.
> >
> > I am not familiar with simulation platform. We reproduct this issue 
> > in our board once.
> > For accelerating reproduction this issue, Add Reclaim() to
> > AutoUpdateLangVariable() for test.
> >
> > Thanks,
> > Ming
> >
> > >
> > > If it is urgent, I suggest that discuss with your internal team 
> > > first and explain
> > that we need consider the risk check it into edk2.
> > >
> > > Best Regards
> > > Guomin
> > >
> > >> -Original Message-
> > >> From: devel@edk2.groups.io  On Behalf Of
> Ming
> > >> Huang via groups.io
> > >> Sent: Tuesday, June 30, 2020 8:26 PM
> > >> To: Jiang, Guomin ; devel@edk2.groups.io; 
> > >> Wang, Jian J ; Wu, Hao A 
> > >> ; Gao, Liming 
> > >> Cc: lidongz...@huawei.com; songdongku...@huawei.com; 
> > >> wanghuiqi...@huawei.com; qiulian...@huawei.com;
> > shenli...@huawei.com;
> > >> xiewen...@huawei.com
> > >> Subject: Re: [edk2-devel] [PATCH edk2 v1 1/1]
> MdeModulePkg/Variable:
> > >> Move FindVariable after AutoUpdateLangVariable
> > >>
> > >>
> > >>
> > >> 在 2020/6/30 8:58, Jiang, Guomin 写道:
> > >>> Hi Huang,
> > >>>
> > >>> >From issue statement, I guess that
> > >>> 1. AutoUpdateLangVariable() invoked, and it will invoke
> > >>> FindVariable() first, at the same time, reclaim occur and 
> > >>> Variable.CurrPtr is invalid, it return
> > >> with success 2. UpdateVariable() is invoked when The old Lang's 
> > >> State is valid and the new Lang's State is also valid.
> > >>> 3. In the situation, FindVariable() checked Lang's State and 
> > >>> only enable one
> > >> Lang's State. But it didn't in fact.
> > >>> 4. BmForEachVariable() deadloop in the situation.
> > >>>
> > >>> Am I right?
> > >>

Re: [edk2-devel] [PATCH V2 2/2] BaseTools: Factorize GCC flags

2020-07-22 Thread Laszlo Ersek
On 07/22/20 13:03, Laszlo Ersek wrote:
> Hi Pierre,
> 
> On 07/07/20 10:35, PierreGondois wrote:
>> From: Pierre Gondois 
>>
>> GCC48_ALL_CC_FLAGS has no dependency on GCC_ALL_CC_FLAGS.
>> By definition, there should be such dependency.
>>
>> The outcomes of this patch is that GCC48_ALL_CC_FLAGS and
>> other dependent configurations will inherit from the
>> additional "-Os" flag.
>> The "-Os" flag optimizes a build in size, not breaking any
>> build. In a gcc command line, the last optimization flag
>> has precedence. This means that this "-Os" flag will be
>> overriden by a more specific optimization configuration,
>> provided that this more specific flag is appended at the
>> end of the CC_FLAGS.
>>
>> Signed-off-by: Pierre Gondois 
>> Suggested-by: Tomas Pilar 
>> ---
>>
>> The changes can be seen at: 
>> https://github.com/PierreARM/edk2/commits/831_Add_gcc_flag_warning_v2
>>
>> Notes:
>> v2:
>>  - Make GCC48_ALL_CC_FLAGS dependent on
>>GCC_ALL_CC_FLAGS. [Tomas]
>>
>>  BaseTools/Conf/tools_def.template | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/BaseTools/Conf/tools_def.template 
>> b/BaseTools/Conf/tools_def.template
>> index 
>> 397b011ba38f97f81f314f8641ac8bb95d5a2197..a1fd27b1adba8769949b7d628d7fbed49fe24267
>>  100755
>> --- a/BaseTools/Conf/tools_def.template
>> +++ b/BaseTools/Conf/tools_def.template
>> @@ -1952,7 +1952,7 @@ DEFINE GCC_RISCV64_RC_FLAGS= -I binary -O 
>> elf64-littleriscv   -B riscv
>>  # GCC Build Flag for included header file list generation
>>  DEFINE GCC_DEPS_FLAGS  = -MMD -MF $@.deps
>>  
>> -DEFINE GCC48_ALL_CC_FLAGS= -g -fshort-wchar -fno-builtin 
>> -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections 
>> -fdata-sections -include AutoGen.h -fno-common 
>> -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
>> +DEFINE GCC48_ALL_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) 
>> -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
>>  DEFINE GCC48_IA32_X64_DLINK_COMMON   = -nostdlib -Wl,-n,-q,--gc-sections -z 
>> common-page-size=0x20
>>  DEFINE GCC48_IA32_CC_FLAGS   = DEF(GCC48_ALL_CC_FLAGS) -m32 
>> -march=i586 -malign-double -fno-stack-protector -D EFI32 
>> -fno-asynchronous-unwind-tables -Wno-address
>>  DEFINE GCC48_X64_CC_FLAGS= DEF(GCC48_ALL_CC_FLAGS) -m64 
>> -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" 
>> -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie 
>> -fno-asynchronous-unwind-tables -Wno-address
>>
> 
> As the commit message states, this change makes GCC48_ALL_CC_FLAGS inherit 
> "-Os".
> 
> It is true that all the NOOPT_GCC flags override "-Os" with "-O0":
> 
> NOOPT_GCC48_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS) -O0
> NOOPT_GCC48_X64_CC_FLAGS   = DEF(GCC48_X64_CC_FLAGS) -O0
> NOOPT_GCC48_ARM_CC_FLAGS   = DEF(GCC48_ARM_CC_FLAGS) -O0
> NOOPT_GCC48_AARCH64_CC_FLAGS   = DEF(GCC48_AARCH64_CC_FLAGS) -O0
> NOOPT_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -O0
> NOOPT_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -O0
> NOOPT_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
> NOOPT_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -O0
> NOOPT_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -O0
> NOOPT_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -O0
> NOOPT_GCC5_ARM_CC_FLAGS= DEF(GCC5_ARM_CC_FLAGS) -O0
> NOOPT_GCC5_AARCH64_CC_FLAGS= DEF(GCC5_AARCH64_CC_FLAGS) -O0
> 
> However, *some* of the DEBUG and RELEASE flags now have two "-Os" flags:
> 
>   DEBUG_GCC48_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS) -Os
> RELEASE_GCC48_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable
>   DEBUG_GCC48_X64_CC_FLAGS   = DEF(GCC48_X64_CC_FLAGS) -Os
> RELEASE_GCC48_X64_CC_FLAGS   = DEF(GCC48_X64_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable
>   DEBUG_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os
> RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>   DEBUG_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os
> RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>   DEBUG_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -flto -Os
> RELEASE_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -flto -Os 
> -Wno-unused-but-set-variable -Wno-unused-const-variable
>   DEBUG_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO 
> -Os
> RELEASE_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO 
> -Os -Wno-unused-but-set-variable -Wno-unused-const-variable
> 
> (The ARM and AARCH64 DEBUG/RELEASE GCC options don't seem to be affected, as 
> they have relied on inherited -- not open-coded -- "-Os" options from much 
> earlier. So now they do not suffer from this duplication.)

We do have some AARCH64 duplication here:

DEFINE GCC49_AARCH64_CC_

Re: [edk2-devel] [PATCH V2 2/2] BaseTools: Factorize GCC flags

2020-07-22 Thread Laszlo Ersek
Hi Pierre,

On 07/07/20 10:35, PierreGondois wrote:
> From: Pierre Gondois 
> 
> GCC48_ALL_CC_FLAGS has no dependency on GCC_ALL_CC_FLAGS.
> By definition, there should be such dependency.
> 
> The outcomes of this patch is that GCC48_ALL_CC_FLAGS and
> other dependent configurations will inherit from the
> additional "-Os" flag.
> The "-Os" flag optimizes a build in size, not breaking any
> build. In a gcc command line, the last optimization flag
> has precedence. This means that this "-Os" flag will be
> overriden by a more specific optimization configuration,
> provided that this more specific flag is appended at the
> end of the CC_FLAGS.
> 
> Signed-off-by: Pierre Gondois 
> Suggested-by: Tomas Pilar 
> ---
> 
> The changes can be seen at: 
> https://github.com/PierreARM/edk2/commits/831_Add_gcc_flag_warning_v2
> 
> Notes:
> v2:
>  - Make GCC48_ALL_CC_FLAGS dependent on
>GCC_ALL_CC_FLAGS. [Tomas]
> 
>  BaseTools/Conf/tools_def.template | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index 
> 397b011ba38f97f81f314f8641ac8bb95d5a2197..a1fd27b1adba8769949b7d628d7fbed49fe24267
>  100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -1952,7 +1952,7 @@ DEFINE GCC_RISCV64_RC_FLAGS= -I binary -O 
> elf64-littleriscv   -B riscv
>  # GCC Build Flag for included header file list generation
>  DEFINE GCC_DEPS_FLAGS  = -MMD -MF $@.deps
>  
> -DEFINE GCC48_ALL_CC_FLAGS= -g -fshort-wchar -fno-builtin 
> -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections 
> -fdata-sections -include AutoGen.h -fno-common 
> -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
> +DEFINE GCC48_ALL_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) 
> -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
>  DEFINE GCC48_IA32_X64_DLINK_COMMON   = -nostdlib -Wl,-n,-q,--gc-sections -z 
> common-page-size=0x20
>  DEFINE GCC48_IA32_CC_FLAGS   = DEF(GCC48_ALL_CC_FLAGS) -m32 
> -march=i586 -malign-double -fno-stack-protector -D EFI32 
> -fno-asynchronous-unwind-tables -Wno-address
>  DEFINE GCC48_X64_CC_FLAGS= DEF(GCC48_ALL_CC_FLAGS) -m64 
> -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" 
> -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie 
> -fno-asynchronous-unwind-tables -Wno-address
> 

As the commit message states, this change makes GCC48_ALL_CC_FLAGS inherit 
"-Os".

It is true that all the NOOPT_GCC flags override "-Os" with "-O0":

NOOPT_GCC48_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS) -O0
NOOPT_GCC48_X64_CC_FLAGS   = DEF(GCC48_X64_CC_FLAGS) -O0
NOOPT_GCC48_ARM_CC_FLAGS   = DEF(GCC48_ARM_CC_FLAGS) -O0
NOOPT_GCC48_AARCH64_CC_FLAGS   = DEF(GCC48_AARCH64_CC_FLAGS) -O0
NOOPT_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -O0
NOOPT_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -O0
NOOPT_GCC49_ARM_CC_FLAGS   = DEF(GCC49_ARM_CC_FLAGS) -O0
NOOPT_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -O0
NOOPT_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -O0
NOOPT_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -O0
NOOPT_GCC5_ARM_CC_FLAGS= DEF(GCC5_ARM_CC_FLAGS) -O0
NOOPT_GCC5_AARCH64_CC_FLAGS= DEF(GCC5_AARCH64_CC_FLAGS) -O0

However, *some* of the DEBUG and RELEASE flags now have two "-Os" flags:

  DEBUG_GCC48_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS) -Os
RELEASE_GCC48_IA32_CC_FLAGS   = DEF(GCC48_IA32_CC_FLAGS) -Os 
-Wno-unused-but-set-variable
  DEBUG_GCC48_X64_CC_FLAGS   = DEF(GCC48_X64_CC_FLAGS) -Os
RELEASE_GCC48_X64_CC_FLAGS   = DEF(GCC48_X64_CC_FLAGS) -Os 
-Wno-unused-but-set-variable
  DEBUG_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os
RELEASE_GCC49_IA32_CC_FLAGS   = DEF(GCC49_IA32_CC_FLAGS) -Os 
-Wno-unused-but-set-variable -Wno-unused-const-variable
  DEBUG_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os
RELEASE_GCC49_X64_CC_FLAGS   = DEF(GCC49_X64_CC_FLAGS) -Os 
-Wno-unused-but-set-variable -Wno-unused-const-variable
  DEBUG_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -flto -Os
RELEASE_GCC5_IA32_CC_FLAGS   = DEF(GCC5_IA32_CC_FLAGS) -flto -Os 
-Wno-unused-but-set-variable -Wno-unused-const-variable
  DEBUG_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO -Os
RELEASE_GCC5_X64_CC_FLAGS= DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO -Os 
-Wno-unused-but-set-variable -Wno-unused-const-variable

(The ARM and AARCH64 DEBUG/RELEASE GCC options don't seem to be affected, as 
they have relied on inherited -- not open-coded -- "-Os" options from much 
earlier. So now they do not suffer from this duplication.)

The point of this patch was a kind of "normalization", so I think the work 
isn't complete until the duplication is undone, i.e., the explicit "-Os" flag 
is removed from the last twelve defines.

Can you submit a follow-up patch please?

Thanks
Laszl

Re: [edk2-devel] A problem to build KabyLake

2020-07-22 Thread Guomin Jiang
 It confuse me that near line 60, column 0:   !include 
LogoFeaturePkg/Include/PreMemory.fdf.

In my local machine, the PreMemory.fdf should be 
AdvancedFeaturePkg/Include/PreMemory.fdf,

I can also find this file in directory 
edk2-platforms\Features\Intel\AdvancedFeaturePkg\Include.

Please confirm it.

Thanks.
Guomin
From: devel@edk2.groups.io  On Behalf Of Canh Kha
Sent: Wednesday, July 22, 2020 1:13 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] A problem to build KabyLake

Hi,
When I ran this build command
build -a IA32 -a X64 -n 5 -t VS2015x86 -b DEBUG -p 
KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc
I received the following message

build.py...
 : error C0DE: Unknown fatal error when processing 
[c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc]

(Please send email to devel@edk2.groups.io for 
help, attaching following call stack trace!)

(Python 3.8.3 on win32) Traceback (most recent call last):
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2636, in 
Main
MyBuild.Launch()
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2431, in 
Launch
self._MultiThreadBuildPlatform()
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2238, in 
_MultiThreadBuildPlatform
Wa, self.BuildModules = self.PerformAutoGen(BuildTarget,ToolChain)
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2088, in 
PerformAutoGen
Wa = WorkspaceAutoGen(
  File "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", 
line 43, in __init__
self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args, 
**kwargs)
  File "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", 
line 112, in _InitWorker
self.ProcessModuleFromPdf()
  File "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", 
line 188, in ProcessModuleFromPdf
if self.FdfProfile:
  File "C:\minnow\edk2\BaseTools\Source\Python\Common\caching.py", line 28, in 
__get__
Value = obj.__dict__[self._function.__name__] = self._function(obj)
  File "C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", 
line 164, in FdfProfile
Fdf.ParseFile()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line 1312, 
in ParseFile
self.Preprocess()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line 1291, 
in Preprocess
self.PreprocessIncludeFile()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line 624, 
in PreprocessIncludeFile
raise Warning("The include file does not exist under below directories: 
\n%s\n%s\n%s\n"%(os.path.dirname(self.FileName), PlatformDir, 
GlobalData.gWorkspace),
GenFds.FdfParser.Warning: The include file does not exist under below 
directories:
c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3
c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3
c:\minnow
 near line 60, column 0:   !include LogoFeaturePkg/Include/PreMemory.fdf



- Failed -
Build end time: 00:01:19, Jul.22 2020
Build total time: 00:00:00

This is my PACKAGES_PATH
C:\minnow\edk2;C:\minnow\edk2-platforms\Silicon\Intel;C:\minnow\edk2-platforms\Platform\Intel;;C:\minnow\edk2-platforms\Features\Intel;C:\minnow\edk2-non-osi\Silicon\Intel;C:\minnow\FSP
Could you help to give me some suggestions to try?
Thanks,
Canh


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63107): https://edk2.groups.io/g/devel/message/63107
Mute This Topic: https://groups.io/mt/75721822/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v3 1/1] BaseTools/Scripts: Ignore the CRLF check when upgrade submodule.

2020-07-22 Thread Guomin Jiang
If the submodule is upgraded, skip the CRLF check as it isn't change for
file.

Signed-off-by: Guomin Jiang 
Cc: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Scripts/PatchCheck.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
index 7db0775d14d1..ca0849b77bbe 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -502,7 +502,7 @@ class GitDiffCheck:
 
 stripped = line.rstrip()
 
-if self.force_crlf and eol != '\r\n':
+if self.force_crlf and eol != '\r\n' and (line.find('Subproject 
commit') == -1):
 self.added_line_error('Line ending (%s) is not CRLF' % repr(eol),
   line)
 if self.force_notabs and '\t' in line:
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63106): https://edk2.groups.io/g/devel/message/63106
Mute This Topic: https://groups.io/mt/75721835/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] A problem to build KabyLake

2020-07-22 Thread Canh Kha
Hi,
When I ran this build command
build -a IA32 -a X64 -n 5 -t VS2015x86 -b DEBUG -p
KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc
I received the following message

build.py...
 : error C0DE: Unknown fatal error when processing
[c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3\OpenBoardPkg.dsc]

(Please send email to devel@edk2.groups.io for help, attaching following
call stack trace!)

(Python 3.8.3 on win32) Traceback (most recent call last):
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2636,
in Main
MyBuild.Launch()
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2431,
in Launch
self._MultiThreadBuildPlatform()
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2238,
in _MultiThreadBuildPlatform
Wa, self.BuildModules = self.PerformAutoGen(BuildTarget,ToolChain)
  File "C:\minnow\edk2\BaseTools\Source\Python\build\build.py", line 2088,
in PerformAutoGen
Wa = WorkspaceAutoGen(
  File
"C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", line
43, in __init__
self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args,
**kwargs)
  File
"C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", line
112, in _InitWorker
self.ProcessModuleFromPdf()
  File
"C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", line
188, in ProcessModuleFromPdf
if self.FdfProfile:
  File "C:\minnow\edk2\BaseTools\Source\Python\Common\caching.py", line 28,
in __get__
Value = obj.__dict__[self._function.__name__] = self._function(obj)
  File
"C:\minnow\edk2\BaseTools\Source\Python\AutoGen\WorkspaceAutoGen.py", line
164, in FdfProfile
Fdf.ParseFile()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line
1312, in ParseFile
self.Preprocess()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line
1291, in Preprocess
self.PreprocessIncludeFile()
  File "C:\minnow\edk2\BaseTools\Source\Python\GenFds\FdfParser.py", line
624, in PreprocessIncludeFile
raise Warning("The include file does not exist under below directories:
\n%s\n%s\n%s\n"%(os.path.dirname(self.FileName), PlatformDir,
GlobalData.gWorkspace),
GenFds.FdfParser.Warning: The include file does not exist under below
directories:
c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3
c:\minnow\edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\KabylakeRvp3
c:\minnow
 near line 60, column 0:   !include LogoFeaturePkg/Include/PreMemory.fdf



- Failed -
Build end time: 00:01:19, Jul.22 2020
Build total time: 00:00:00

This is my PACKAGES_PATH
C:\minnow\edk2;C:\minnow\edk2-platforms\Silicon\Intel;C:\minnow\edk2-platforms\Platform\Intel;;C:\minnow\edk2-platforms\Features\Intel;C:\minnow\edk2-non-osi\Silicon\Intel;C:\minnow\FSP
Could you help to give me some suggestions to try?
Thanks,
Canh

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63105): https://edk2.groups.io/g/devel/message/63105
Mute This Topic: https://groups.io/mt/75721822/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 1/1] BaseLib:Fix RISC-V Supervisor mode (S-Mode) trap handler reentry issue.

2020-07-22 Thread Abner Chang
While RISC-V hart is trapped into S-Mode, the S-Mode interrupt
CSR (SIE) is disabled by RISC-V hart. However the (SIE) is enabled
again by RestoreTPL, this causes the second S-Mode trap is triggered
by the machine mode (M-Mode)timer interrupt redirection. The SRET
instruction clear Supervisor Previous Privilege (SPP) to zero
(User mode) in the second S-Mode interrupt according to the RISC-V
spec. Above brings hart to the user mode (U-Mode) when execute
SRET in the nested S-Mode interrupt handler because SPP is set to
User Mode in the second interrupt. Afterward, system runs in U-Mode
and any accesses to S-Mode CSR causes the invalid instruction exception.

Signed-off-by: Abner Chang 
Reviewed-by: Daniel Schaefer 

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Daniel Schaefer 
Cc: Leif Lindholm 
---
 .../Library/BaseLib/RiscV64/RiscVInterrupt.S  | 45 ---
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S 
b/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
index 766fcfb9cb..e821124781 100644
--- a/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
+++ b/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
@@ -12,21 +12,52 @@ ASM_GLOBAL ASM_PFX(RiscVDisableSupervisorModeInterrupts)
 ASM_GLOBAL ASM_PFX(RiscVEnableSupervisorModeInterrupt)
 ASM_GLOBAL ASM_PFX(RiscVGetSupervisorModeInterrupts)
 
-# define  MSTATUS_SIE0x0002
-# define  CSR_SSTATUS0x100
+#define  SSTATUS_SIE 0x0002
+#define  CSR_SSTATUS 0x100
+#define  SSTATUS_SPP_BIT_POSITION8
 
+//
+// This routine disables supervisor mode interrupt
+//
 ASM_PFX(RiscVDisableSupervisorModeInterrupts):
-  li   a1, MSTATUS_SIE
-  csrc CSR_SSTATUS, a1
+  add   sp, sp, -(__SIZEOF_POINTER__)
+  sda1, (sp)
+  lia1, SSTATUS_SIE
+  csrc  CSR_SSTATUS, a1
+  lda1, (sp)
+  add   sp, sp, (__SIZEOF_POINTER__)
   ret
 
+//
+// This routine enables supervisor mode interrupt
+//
 ASM_PFX(RiscVEnableSupervisorModeInterrupt):
-  li   a1, MSTATUS_SIE
-  csrs CSR_SSTATUS, a1
+  add   sp, sp, -2*(__SIZEOF_POINTER__)
+  sda0, (0*__SIZEOF_POINTER__)(sp)
+  sda1, (1*__SIZEOF_POINTER__)(sp)
+
+  csrr  a0, CSR_SSTATUS
+  and   a0, a0, (1 << SSTATUS_SPP_BIT_POSITION)
+  bnez  a0, InTrap  // We are in supervisor mode (SMode)
+// trap handler.
+// Skip enabling SIE becasue SIE
+// is set to disabled by RISC-V hart
+// when the trap takes hart to SMode.
+
+  lia1, SSTATUS_SIE
+  csrs  CSR_SSTATUS, a1
+InTrap:
+  lda0, (0*__SIZEOF_POINTER__)(sp)
+  lda1, (1*__SIZEOF_POINTER__)(sp)
+  add   sp, sp, 2*(__SIZEOF_POINTER__)
   ret
 
+//
+// This routine returns supervisor mode interrupt
+// status.
+//
 ASM_PFX(RiscVGetSupervisorModeInterrupts):
   csrr a0, CSR_SSTATUS
-  andi a0, a0, MSTATUS_SIE
+  andi a0, a0, SSTATUS_SIE
   ret
 
-- 
2.25.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63104): https://edk2.groups.io/g/devel/message/63104
Mute This Topic: https://groups.io/mt/75721373/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 1/1] BaseTools/Scripts: Ignore the CRLF check when upgrade submodule.

2020-07-22 Thread Guomin Jiang
If the submodule is upgraded, it will not end with the CRLF. it make no
sense that check the submodule upgrade.

Signed-off-by: Guomin Jiang 
Cc: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Scripts/PatchCheck.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
index 7db0775d14d1..ca0849b77bbe 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -502,7 +502,7 @@ class GitDiffCheck:
 
 stripped = line.rstrip()
 
-if self.force_crlf and eol != '\r\n':
+if self.force_crlf and eol != '\r\n' and (line.find('Subproject 
commit') == -1):
 self.added_line_error('Line ending (%s) is not CRLF' % repr(eol),
   line)
 if self.force_notabs and '\t' in line:
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63103): https://edk2.groups.io/g/devel/message/63103
Mute This Topic: https://groups.io/mt/75721109/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 09/10] SecurityPkg/TcgPei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save rebased the PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.
The TcgPei calculate the hash and it use the Migrated FV Info.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Chao Zhang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
Reviewed-by: Jian J Wang 
Reviewed-by: Zhang, Qi1 
---
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |  1 +
 SecurityPkg/Tcg/TcgPei/TcgPei.c   | 29 +++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf 
b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index c0bff6e85e9d..6d1951f8ed65 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -58,6 +58,7 @@ [Guids]
   gTpmErrorHobGuid## 
SOMETIMES_PRODUCES ## HOB
   gMeasuredFvHobGuid  ## 
PRODUCES   ## HOB
   gEfiTpmDeviceInstanceTpm12Guid  ## 
PRODUCES   ## GUID   # TPM device identifier
+  gEdkiiMigratedFvInfoGuid## 
SOMETIMES_CONSUMES ## HOB
 
 [Ppis]
   gPeiLockPhysicalPresencePpiGuid ## 
SOMETIMES_CONSUMES ## NOTIFY
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index a9a808c9ecf3..9701bfe8715b 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -378,6 +379,10 @@ MeasureFvImage (
   EFI_STATUSStatus;
   EFI_PLATFORM_FIRMWARE_BLOBFvBlob;
   TCG_PCR_EVENT_HDR TcgEventHdr;
+  EFI_PHYSICAL_ADDRESS  FvOrgBase;
+  EFI_PHYSICAL_ADDRESS  FvDataBase;
+  EFI_PEI_HOB_POINTERS  Hob;
+  EDKII_MIGRATED_FV_INFO*MigratedFvInfo;
 
   //
   // Check if it is in Excluded FV list
@@ -401,10 +406,30 @@ MeasureFvImage (
 }
   }
 
+  //
+  // Search the matched migration FV info
+  //
+  FvOrgBase  = FvBase;
+  FvDataBase = FvBase;
+  Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+if ((MigratedFvInfo->FvNewBase == (UINT32) FvBase) && 
(MigratedFvInfo->FvLength == (UINT32) FvLength)) {
+  //
+  // Found the migrated FV info
+  //
+  FvOrgBase  = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvOrgBase;
+  FvDataBase = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvDataBase;
+  break;
+}
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+
   //
   // Measure and record the FV to the TPM
   //
-  FvBlob.BlobBase   = FvBase;
+  FvBlob.BlobBase   = FvOrgBase;
   FvBlob.BlobLength = FvLength;
 
   DEBUG ((DEBUG_INFO, "The FV which is measured by TcgPei starts at: 0x%x\n", 
FvBlob.BlobBase));
@@ -416,7 +441,7 @@ MeasureFvImage (
 
   Status = HashLogExtendEvent (
  (EFI_PEI_SERVICES **) GetPeiServicesTablePointer(),
- (UINT8*) (UINTN) FvBlob.BlobBase,
+ (UINT8*) (UINTN) FvDataBase,
  (UINTN) FvBlob.BlobLength,
  &TcgEventHdr,
  (UINT8*) &FvBlob
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63101): https://edk2.groups.io/g/devel/message/63101
Mute This Topic: https://groups.io/mt/75720855/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 08/10] UefiCpuPkg: Correct some typos.

2020-07-22 Thread Guomin Jiang
Correct some typos.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
Reviewed-by: Laszlo Ersek 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.h| 2 +-
 .../Library/CpuExceptionHandlerLib/CpuExceptionCommon.h   | 4 ++--
 UefiCpuPkg/CpuMpPei/CpuPaging.c   | 4 ++--
 .../CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c| 4 ++--
 .../Library/CpuExceptionHandlerLib/SecPeiCpuException.c   | 2 +-
 .../Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c | 4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 309478cbe14c..6a481a84dcc7 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -424,7 +424,7 @@ InitializeCpuMpWorker (
   );
 
 /**
-  Enabl/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
+  Enable/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
 
   Doing this in the memory-discovered callback is to make sure the Stack Guard
   feature to cover as most PEI code as possible.
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index 805dd9cbb4ff..0544d6dba631 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -90,8 +90,8 @@ AsmGetTemplateAddressMap (
 **/
 VOID
 ArchUpdateIdtEntry (
-  IN IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
-  IN UINTN   InterruptHandler
+  OUT IA32_IDT_GATE_DESCRIPTOR   *IdtEntry,
+  IN  UINTN  InterruptHandler
   );
 
 /**
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 8ab7dfcce3a0..50ad4277af79 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -153,7 +153,7 @@ GetPhysicalAddressWidth (
   Get the type of top level page table.
 
   @retval Page512G  PML4 paging.
-  @retval Page1GPAE paing.
+  @retval Page1GPAE paging.
 
 **/
 PAGE_ATTRIBUTE
@@ -583,7 +583,7 @@ SetupStackGuardPage (
 }
 
 /**
-  Enabl/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
+  Enable/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
 
   Doing this in the memory-discovered callback is to make sure the Stack Guard
   feature to cover as most PEI code as possible.
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
index 1aafb7dac139..903449e0daa9 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
@@ -18,8 +18,8 @@
 **/
 VOID
 ArchUpdateIdtEntry (
-  IN IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
-  IN UINTN   InterruptHandler
+  OUT IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
+  IN  UINTN   InterruptHandler
   )
 {
   IdtEntry->Bits.OffsetLow   = (UINT16)(UINTN)InterruptHandler;
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
index 20148db74cf8..d4ae153c5742 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
@@ -87,7 +87,7 @@ InitializeCpuExceptionHandlers (
   IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof 
(IA32_IDT_GATE_DESCRIPTOR);
   if (IdtEntryCount > CPU_EXCEPTION_NUM) {
 //
-// CPU exeption library only setup CPU_EXCEPTION_NUM exception handler at 
most
+// CPU exception library only setup CPU_EXCEPTION_NUM exception handler at 
most
 //
 IdtEntryCount = CPU_EXCEPTION_NUM;
   }
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
index 894c1cfb7533..d3da16e4dfa2 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
@@ -17,8 +17,8 @@
 **/
 VOID
 ArchUpdateIdtEntry (
-  IN IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
-  IN UINTN   InterruptHandler
+  OUT IA32_IDT_GATE_DESCRIPTOR   *IdtEntry,
+  IN  UINTN  InterruptHandler
   )
 {
   IdtEntry->Bits.OffsetLow   = (UINT16)(UINTN)InterruptHandler;
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63100): https://edk2.groups.io/g/devel/message/63100
Mute This Topic: https://groups.io/mt/75720853/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=

[edk2-devel] [PATCH v7 06/10] SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save rebased the PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.
The Tcg2Pei calculate the hash and it use the Migrated FV Info.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Chao Zhang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
Reviewed-by: Jian J Wang 
Reviewed-by: Zhang, Qi1 
---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf |  1 +
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c   | 31 ++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
index 3d361e8859e7..367df21eedaf 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
@@ -63,6 +63,7 @@ [Guids]
   gTcgEvent2EntryHobGuid   ## 
PRODUCES   ## HOB
   gEfiTpmDeviceInstanceNoneGuid## 
SOMETIMES_PRODUCES ## GUID   # TPM device identifier
   gEfiTpmDeviceInstanceTpm12Guid   ## 
SOMETIMES_PRODUCES ## GUID   # TPM device identifier
+  gEdkiiMigratedFvInfoGuid ## 
SOMETIMES_CONSUMES ## HOB
 
 [Ppis]
   gEfiPeiFirmwareVolumeInfoPpiGuid ## 
SOMETIMES_CONSUMES ## NOTIFY
diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 19b8e4b318c5..18569f89b430 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -536,6 +537,10 @@ MeasureFvImage (
   EDKII_PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_PPI   *PrehashedFvPpi;
   HASH_INFO *PreHashInfo;
   UINT32HashAlgoMask;
+  EFI_PHYSICAL_ADDRESS  FvOrgBase;
+  EFI_PHYSICAL_ADDRESS  FvDataBase;
+  EFI_PEI_HOB_POINTERS  Hob;
+  EDKII_MIGRATED_FV_INFO*MigratedFvInfo;
 
   //
   // Check Excluded FV list
@@ -621,6 +626,26 @@ MeasureFvImage (
 Instance++;
   } while (!EFI_ERROR(Status));
 
+  //
+  // Search the matched migration FV info
+  //
+  FvOrgBase  = FvBase;
+  FvDataBase = FvBase;
+  Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+if ((MigratedFvInfo->FvNewBase == (UINT32) FvBase) && 
(MigratedFvInfo->FvLength == (UINT32) FvLength)) {
+  //
+  // Found the migrated FV info
+  //
+  FvOrgBase  = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvOrgBase;
+  FvDataBase = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvDataBase;
+  break;
+}
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+
   //
   // Init the log event for FV measurement
   //
@@ -631,14 +656,14 @@ MeasureFvImage (
 if (FvName != NULL) {
   AsciiSPrint ((CHAR8 *)FvBlob2.BlobDescription, 
sizeof(FvBlob2.BlobDescription), "Fv(%g)", FvName);
 }
-FvBlob2.BlobBase  = FvBase;
+FvBlob2.BlobBase  = FvOrgBase;
 FvBlob2.BlobLength= FvLength;
 TcgEventHdr.PCRIndex  = 0;
 TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB2;
 TcgEventHdr.EventSize = sizeof (FvBlob2);
 EventData = &FvBlob2;
   } else {
-FvBlob.BlobBase   = FvBase;
+FvBlob.BlobBase   = FvOrgBase;
 FvBlob.BlobLength = FvLength;
 TcgEventHdr.PCRIndex  = 0;
 TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB;
@@ -673,7 +698,7 @@ MeasureFvImage (
 //
 Status = HashLogExtendEvent (
0,
-   (UINT8*) (UINTN) FvBase, // HashData
+   (UINT8*) (UINTN) FvDataBase, // HashData
(UINTN) FvLength,// HashDataLen
&TcgEventHdr,// EventHdr
EventData// EventData
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63098): https://edk2.groups.io/g/devel/message/63098
Mute This Topic: https://groups.io/mt/75720851/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 10/10] MdeModulePkg/Core: Avoid redundant shadow when enable the Migrated PCD (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When PcdMigrateTemporaryRamFirmwareVolumes is TRUE, it will shadow the
PEIMs, when it is disabled, PEIMs marked REGISTER_FOR_SHADOW will be
shadowed as well and it is controled by PcdShadowPeimOnBoot and
PcdShadowPeimOnS3Boot.

To cover the shadow behavior, the change will always shadow PEIMs when
enable PcdMigrateTemporaryRamFirmwareVolumes.

When PcdMigrateTemporaryRamFirmwareVolumes is true, if enable
PcdShadowPeimOnBoot or PcdShadowPeimOnS3Boot, it will shadow some PEIMs
twice and occupy more memory and waste more boot time, it is unnecessary,
so the only valid choice is to enable PcdMigrateTemporaryRamFirmwareVolumes
and disable PcdShadowPeimOnBoot and PcdShadowPeimOnS3Boot.

Signed-off-by: Guomin Jiang 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
---
 MdeModulePkg/MdeModulePkg.dec | 11 +---
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 14 +++---
 MdeModulePkg/Core/Pei/Image/Image.c   |  6 ++---
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   | 26 +++
 4 files changed, 42 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index e0ad9373e62f..5220202b233b 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1223,11 +1223,14 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
   # @Prompt Shadow Peim and PeiCore on boot
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|TRUE|BOOLEAN|0x30001029
 
-  ## Enable the feature that evacuate temporary memory to permanent memory or 
not
+  ## Enable the feature that evacuate temporary memory to permanent memory or 
not
   #  Set FALSE as default, if the developer need this feature to avoid this 
vulnerability, please
-  #  enable it in dsc file.
-  #  TRUE - Evacuate temporary memory, the actions include copy memory, 
convert PPI pointers and so on.
-  #  FALSE - Do nothing, for example, no copy memory, no convert PPI pointers 
and so on.
+  #  enable it and disable PcdShadowPeimOnBoot and PcdShadowPeimOnS3Boot in 
dsc file at the same time.
+  #  The reason is that PcdMigrateTemporaryRamFirmwareVolumes will make all 
PEIMs be shadowed and
+  #  it is unnecessary that shadow PEIMs which is controled by 
PcdShadowPeimOnBoot and PcdShadowPeimOnS3Boot
+  #  again, it will occupy more memory and waste more time if you enable 
it.
+  #  TRUE - Evacuate temporary memory, the actions include copy memory, 
convert PPI pointers and so on.
+  #  FALSE - Do nothing, for example, no copy memory, no convert PPI pointers 
and so on.
   # @Prompt Evacuate temporary memory to permanent memory
   
gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE|BOOLEAN|0x3000102A
 
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 667d9273bb91..11ff5e693304 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1408,7 +1408,11 @@ PeiDispatcher (
   PeimFileHandle = NULL;
   EntryPoint = 0;
 
-  if ((Private->PeiMemoryInstalled) && 
(Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME || 
PcdGetBool (PcdShadowPeimOnS3Boot))) {
+  if ((Private->PeiMemoryInstalled) &&
+  (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)
+   || (Private->HobList.HandoffInformationTable->BootMode != 
BOOT_ON_S3_RESUME)
+   || PcdGetBool (PcdShadowPeimOnS3Boot))
+) {
 //
 // Once real memory is available, shadow the RegisterForShadow modules. 
And meanwhile
 // update the modules' status from PEIM_STATE_REGISTER_FOR_SHADOW to 
PEIM_STATE_DONE.
@@ -1607,13 +1611,17 @@ PeiDispatcher (
 PeiCheckAndSwitchStack (SecCoreData, Private);
 
 if ((Private->PeiMemoryInstalled) && 
(Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_REGISTER_FOR_SHADOW) 
&&   \
-(Private->HobList.HandoffInformationTable->BootMode != 
BOOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boot))) {
+(PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)
+ || (Private->HobList.HandoffInformationTable->BootMode != 
BOOT_ON_S3_RESUME)
+ || PcdGetBool (PcdShadowPeimOnS3Boot))
+  ) {
   //
   // If memory is available we shadow images by default for 
performance reasons.
   // We call the entry point a 2nd time so the module knows it's 
shadowed.
   //
   //PERF_START (PeiServices, L"PEIM", PeimFileHandle, 0);
-  if ((Private->HobList.HandoffInformationTable->BootMode != 
BOOT_ON_S3_RESUME) && !PcdGetBool (PcdShadowPeimOnBoot)) {
+  if ((Private->HobList.HandoffInformationTable->BootMode != 
BOOT_ON_S3_RESUME) && !PcdGetBool (PcdShadowPeimOnBoot)
+  && !PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes))

[edk2-devel] [PATCH v7 07/10] UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

To avoid the TOCTOU, enable paging and set Not Present flag so when
access any code in the flash range, it will trigger #PF exception.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
Acked-by: Laszlo Ersek 
Reviewed-by: Jian J Wang 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  3 +++
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 32 +++-
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index f4d11b861f77..7e511325d8b8 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -46,6 +46,9 @@ [LibraryClasses]
   BaseMemoryLib
   CpuLib
 
+[Guids]
+  gEdkiiMigratedFvInfoGuid ## 
SOMETIMES_CONSUMES ## HOB
+
 [Ppis]
   gEfiPeiMpServicesPpiGuid  ## PRODUCES
   gEfiSecPlatformInformationPpiGuid ## SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 3bf0574b34c6..8ab7dfcce3a0 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include "CpuMpPei.h"
 
@@ -602,9 +603,11 @@ MemoryDiscoveredPpiNotifyCallback (
   IN VOID   *Ppi
   )
 {
-  EFI_STATUS  Status;
-  BOOLEAN InitStackGuard;
-  BOOLEAN InterruptState;
+  EFI_STATUS  Status;
+  BOOLEAN InitStackGuard;
+  BOOLEAN InterruptState;
+  EDKII_MIGRATED_FV_INFO  *MigratedFvInfo;
+  EFI_PEI_HOB_POINTERSHob;
 
   if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
 InterruptState = SaveAndDisableInterrupts ();
@@ -619,9 +622,14 @@ MemoryDiscoveredPpiNotifyCallback (
   // the task switch (for the sake of stack switch).
   //
   InitStackGuard = FALSE;
-  if (IsIa32PaeSupported () && PcdGetBool (PcdCpuStackGuard)) {
+  Hob.Raw = NULL;
+  if (IsIa32PaeSupported ()) {
+Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+InitStackGuard = PcdGetBool (PcdCpuStackGuard);
+  }
+
+  if (InitStackGuard || Hob.Raw != NULL) {
 EnablePaging ();
-InitStackGuard = TRUE;
   }
 
   Status = InitializeCpuMpWorker ((CONST EFI_PEI_SERVICES **)PeiServices);
@@ -631,6 +639,20 @@ MemoryDiscoveredPpiNotifyCallback (
 SetupStackGuardPage ();
   }
 
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+
+//
+// Enable #PF exception, so if the code access SPI after disable NEM, it 
will generate
+// the exception to avoid potential vulnerability.
+//
+ConvertMemoryPageAttributes (MigratedFvInfo->FvOrgBase, 
MigratedFvInfo->FvLength, 0);
+
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+  CpuFlushTlb ();
+
   return Status;
 }
 
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63099): https://edk2.groups.io/g/devel/message/63099
Mute This Topic: https://groups.io/mt/75720852/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 05/10] MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save the rebased PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.

The MigratedFvInfo HOB will never produce when
PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD control
the total feature.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Guomin Jiang 
Acked-by: Laszlo Ersek 
Reviewed-by: Jian J Wang 
---
 MdeModulePkg/MdeModulePkg.dec |  3 ++
 MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
 MdeModulePkg/Core/Pei/PeiMain.h   |  1 +
 MdeModulePkg/Include/Guid/MigratedFvInfo.h| 22 +++
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 28 +++
 5 files changed, 55 insertions(+)
 create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index e88f22756d7f..e0ad9373e62f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -389,6 +389,9 @@ [Guids]
   ## GUID indicates the capsule is to store Capsule On Disk file names.
   gEdkiiCapsuleOnDiskNameGuid = { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93, 0x9a, 
0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } }
 
+  ## Include/Guid/MigratedFvInfo.h
+  gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 
0xce, 0xfd, 0x17, 0x98, 0x71 } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 
0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 5b36d516b3fa..0cf357371a16 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -77,6 +77,7 @@ [Guids]
   ## CONSUMES   ## GUID  # Used to compare with FV's file system GUID and 
get the FV's file system format
   gEfiFirmwareFileSystem3Guid
   gStatusCodeCallbackGuid
+  gEdkiiMigratedFvInfoGuid  ## SOMETIMES_PRODUCES ## 
HOB
 
 [Ppis]
   gEfiPeiStatusCodePpiGuid  ## SOMETIMES_CONSUMES # 
PeiReportStatusService is not ready if this PPI doesn't exist
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 6d95a5d32c78..c27e8fc33bc6 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -44,6 +44,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 ///
 /// It is an FFS type extension used for PeiFindFileEx. It indicates current
diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h 
b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
new file mode 100644
index ..061c17ed0e48
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
@@ -0,0 +1,22 @@
+/** @file
+  Migrated FV information
+
+Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
+#define __EDKII_MIGRATED_FV_INFO_GUID_H__
+
+typedef struct {
+  UINT32   FvOrgBase;  // original FV address
+  UINT32   FvNewBase;  // new FV address
+  UINT32   FvDataBase; // original FV data
+  UINT32   FvLength;   // Fv Length
+} EDKII_MIGRATED_FV_INFO;
+
+extern EFI_GUID gEdkiiMigratedFvInfoGuid;
+
+#endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
+
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 6cf32fdeeb14..667d9273bb91 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1223,10 +1223,12 @@ EvacuateTempRam (
   EFI_FIRMWARE_VOLUME_HEADER*FvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*ChildFvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*MigratedFvHeader;
+  EFI_FIRMWARE_VOLUME_HEADER*RawDataFvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*MigratedChildFvHeader;
 
   PEI_CORE_FV_HANDLEPeiCoreFvHandle;
   EFI_PEI_CORE_FV_LOCATION_PPI  *PeiCoreFvLocationPpi;
+  EDKII_MIGRATED_FV_INFOMigratedFvInfo;
 
   ASSERT (Private->PeiMemoryInstalled);
 
@@ -1263,6 +1265,9 @@ EvacuateTempRam (
 (((EFI_PHYSICAL_ADDRESS)(UINTN) FvHeader + (FvHeader->FvLength - 1)) < 
Private->FreePhysicalMemoryTop)
 )
   ) {
+  //
+  // Allocate page to save the rebased PEIMs, the PEIMs will get 
dispatched later.
+  //
   Status =  PeiServicesAllocatePages (
   EfiBootServicesCode,
   EFI_SIZE_TO_PAGES ((UINTN) FvHeader->FvLength),
@@ -1270,6 +1275,17 @@ EvacuateTempRam (
   );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Allocate pool to save the raw PEIMs, which is used to keep consistent 
context across
+  // multiple boot and PCR0 will

[edk2-devel] [PATCH v7 01/10] MdeModulePkg: Add new PCD to control the evacuate temporary memory feature (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

The security researcher found that we can get control after NEM disable.

The reason is that the flash content reside in NEM at startup and the
code will get the content from flash directly after disable NEM.

To avoid this vulnerability, the feature will copy the PEIMs from
temporary memory to permanent memory and only execute the code in
permanent memory.

The vulnerability is exist in physical platform and haven't report in
virtual platform, so the virtual can disable the feature currently.

Cc: Jian J Wang 
Cc: Hao A Wu 
Signed-off-by: Guomin Jiang 
Acked-by: Laszlo Ersek 
Reviewed-by: Jian J Wang 
---
 MdeModulePkg/MdeModulePkg.dec | 8 
 MdeModulePkg/MdeModulePkg.uni | 6 ++
 2 files changed, 14 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 843e963ad34b..e88f22756d7f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1220,6 +1220,14 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
   # @Prompt Shadow Peim and PeiCore on boot
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|TRUE|BOOLEAN|0x30001029
 
+  ## Enable the feature that evacuate temporary memory to permanent memory or 
not
+  #  Set FALSE as default, if the developer need this feature to avoid this 
vulnerability, please
+  #  enable it in dsc file.
+  #  TRUE - Evacuate temporary memory, the actions include copy memory, 
convert PPI pointers and so on.
+  #  FALSE - Do nothing, for example, no copy memory, no convert PPI pointers 
and so on.
+  # @Prompt Evacuate temporary memory to permanent memory
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE|BOOLEAN|0x3000102A
+
   ## The mask is used to control memory profile behavior.
   #  BIT0 - Enable UEFI memory profile.
   #  BIT1 - Enable SMRAM profile.
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 2007e0596c4f..5235dee561ad 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -214,6 +214,12 @@

"TRUE  - Shadow PEIM on S3 boot path after memory is ready.\n"

"FALSE - Not shadow PEIM on S3 boot path after memory is ready."
 
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_HELP 
#language en-US "Enable the feature that evacuate temporary memory to permanent 
memory or not.\n"
+   
   "It will allocate page to save the temporary PEIMs 
resided in NEM(or CAR) to the permanent memory and change all pointers pointed 
to the NEM(or CAR) to permanent memory.\n"
+   
   "After then, there are no pointer pointed to NEM(or CAR) 
and TOCTOU volnerability can be avoid.\n"
+
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_PROMPT 
#language en-US "Enable the feature that evacuate temporary memory to permanent 
memory or not"
+
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_PROMPT  
#language en-US "Default OEM ID for ACPI table creation"
 
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_HELP  #language 
en-US "Default OEM ID for ACPI table creation, its length must be 0x6 bytes to 
follow ACPI specification."
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63093): https://edk2.groups.io/g/devel/message/63093
Mute This Topic: https://groups.io/mt/75720846/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 03/10] UefiCpuPkg/CpuMpPei: Add GDT migration support (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
From: Michael Kubacki 

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

Moves the GDT to permanent memory in a memory discovered
callback. This is done to ensure the GDT authenticated in
pre-memory is not fetched from outside a verified location
after the permanent memory transition.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Michael Kubacki 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Jian J Wang 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.h   | 12 +++
 UefiCpuPkg/CpuMpPei/CpuMpPei.c   | 37 
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 12 +--
 4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index caead3ce34d4..f4d11b861f77 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -63,6 +63,7 @@ [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList  ## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize   ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes  ## 
CONSUMES
 
 [Depex]
   TRUE
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 7d5c527d6006..309478cbe14c 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -397,6 +397,18 @@ SecPlatformInformation2 (
  OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
   );
 
+/**
+  Migrates the Global Descriptor Table (GDT) to permanent memory.
+
+  @retval   EFI_SUCCESS   The GDT was migrated successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The GDT could not be migrated due to lack of 
available memory.
+
+**/
+EFI_STATUS
+MigrateGdt (
+  VOID
+  );
+
 /**
   Initializes MP and exceptions handlers.
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index 07ccbe7c6a91..d07540cf7471 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -429,6 +429,43 @@ GetGdtr (
   AsmReadGdtr ((IA32_DESCRIPTOR *)Buffer);
 }
 
+/**
+  Migrates the Global Descriptor Table (GDT) to permanent memory.
+
+  @retval   EFI_SUCCESS   The GDT was migrated successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The GDT could not be migrated due to lack of 
available memory.
+
+**/
+EFI_STATUS
+MigrateGdt (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINTN   GdtBufferSize;
+  IA32_DESCRIPTOR Gdtr;
+  VOID*GdtBuffer;
+
+  AsmReadGdtr ((IA32_DESCRIPTOR *) &Gdtr);
+  GdtBufferSize = sizeof (IA32_SEGMENT_DESCRIPTOR) -1 + Gdtr.Limit + 1;
+
+  Status =  PeiServicesAllocatePool (
+  GdtBufferSize,
+  &GdtBuffer
+  );
+  ASSERT (GdtBuffer != NULL);
+  if (EFI_ERROR (Status)) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  GdtBuffer = ALIGN_POINTER (GdtBuffer, sizeof (IA32_SEGMENT_DESCRIPTOR));
+  CopyMem (GdtBuffer, (VOID *) Gdtr.Base, Gdtr.Limit + 1);
+  Gdtr.Base = (UINTN) GdtBuffer;
+  AsmWriteGdtr (&Gdtr);
+
+  return EFI_SUCCESS;
+}
+
 /**
   Initializes CPU exceptions handlers for the sake of stack switch requirement.
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index a462e7ee1e38..3bf0574b34c6 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -602,8 +602,16 @@ MemoryDiscoveredPpiNotifyCallback (
   IN VOID   *Ppi
   )
 {
-  EFI_STATUS  Status;
-  BOOLEAN InitStackGuard;
+  EFI_STATUS  Status;
+  BOOLEAN InitStackGuard;
+  BOOLEAN InterruptState;
+
+  if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
+InterruptState = SaveAndDisableInterrupts ();
+Status = MigrateGdt ();
+ASSERT_EFI_ERROR (Status);
+SetInterruptState (InterruptState);
+  }
 
   //
   // Paging must be setup first. Otherwise the exception TSS setup during MP
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63095): https://edk2.groups.io/g/devel/message/63095
Mute This Topic: https://groups.io/mt/75720848/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 00/10] Add new feature that evacuate temporary to permanent memory (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
The TOCTOU vulnerability allow that the physical present person to replace the 
code with the normal BootGuard check and PCR0 value.
The issue occur when BootGuard measure IBB and access flash code after NEM 
disable.
The reason why we access the flash code is that we have some pointer to flash.
To avoid this vulnerability, we need to convert those pointers, the patch 
series do this work and make sure that no code will access flash address.

v2:
Create gEdkiiMigratedFvInfoGuid HOB and add 
PcdMigrateTemporaryRamFirmwareVolumes to control whole feature.

v3:
Remove changes which is not related with the feature and disable the feature in 
virtual platform.

v4:
Disable the feature as default, Copy the Tcg2Pei behavior to TcgPei

v5:
Initialize local variable Shadow and return EFI_ABORTED when RepublishSecPpi 
not installed.

v6:
Avoid redundant shadow PEIM when enable Migrated PCD.

v7:
Change patch 10/10 to enhance the logic.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Anthony Perard 
Cc: Julien Grall 
Cc: Leif Lindholm 
Cc: Rahul Kumar 
Cc: Jiewen Yao 
Cc: Chao Zhang 
Cc: Qi Zhang 

Guomin Jiang (7):
  MdeModulePkg: Add new PCD to control the evacuate temporary memory
feature (CVE-2019-11098)
  MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU
(CVE-2019-11098)
  UefiCpuPkg: Correct some typos.
  SecurityPkg/TcgPei: Use Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  MdeModulePkg/Core: Avoid redundant shadow when enable the Migrated PCD
(CVE-2019-11098)

Michael Kubacki (3):
  MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore
(CVE-2019-11098)
  UefiCpuPkg/CpuMpPei: Add GDT migration support (CVE-2019-11098)
  UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

 MdeModulePkg/MdeModulePkg.dec |  14 +
 UefiCpuPkg/UefiCpuPkg.dec |   3 +
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 MdeModulePkg/Core/Pei/PeiMain.inf |   3 +
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf   |   1 +
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |   1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf  |   4 +
 UefiCpuPkg/SecCore/SecCore.inf|   2 +
 .../SecMigrationPei/SecMigrationPei.inf   |  67 +++
 MdeModulePkg/Core/Pei/PeiMain.h   | 170 +++
 MdeModulePkg/Include/Guid/MigratedFvInfo.h|  22 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.h|  14 +-
 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
 .../CpuExceptionCommon.h  |   4 +-
 UefiCpuPkg/SecCore/SecMain.h  |   1 +
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 158 +++
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 434 +-
 MdeModulePkg/Core/Pei/Image/Image.c   | 122 -
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  42 +-
 MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c |  31 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.c   |  29 +-
 UefiCpuPkg/CpuMpPei/CpuMpPei.c|  37 ++
 UefiCpuPkg/CpuMpPei/CpuPaging.c   |  42 +-
 .../Ia32/ArchExceptionHandler.c   |   4 +-
 .../SecPeiCpuException.c  |   2 +-
 .../X64/ArchExceptionHandler.c|   4 +-
 UefiCpuPkg/SecCore/SecMain.c  |  26 +-
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 385 
 MdeModulePkg/MdeModulePkg.uni |   6 +
 .../SecMigrationPei/SecMigrationPei.uni   |  13 +
 32 files changed, 2037 insertions(+), 28 deletions(-)
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
 create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h
 create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni

-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63092): https://edk2.groups.io/g/devel/message/63092
Mute This Topic: https://groups.io/mt/75720845/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 04/10] UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
From: Michael Kubacki 

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

Adds a PEIM that republishes structures produced in SEC. This
is done because SEC modules may not be shadowed in some platforms
due to space constraints or special alignment requirements. The
SecMigrationPei module locates interfaces that may be published in
SEC and reinstalls the interface with permanent memory addresses.

This is important if pre-memory address access is forbidden after
memory initialization and data such as a PPI descriptor, PPI GUID,
or PPI inteface reside in pre-memory.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Michael Kubacki 
Acked-by: Laszlo Ersek 
---
 UefiCpuPkg/UefiCpuPkg.dec |   3 +
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 UefiCpuPkg/SecCore/SecCore.inf|   2 +
 .../SecMigrationPei/SecMigrationPei.inf   |  67 +++
 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
 UefiCpuPkg/SecCore/SecMain.h  |   1 +
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 158 +++
 UefiCpuPkg/SecCore/SecMain.c  |  26 +-
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 385 ++
 .../SecMigrationPei/SecMigrationPei.uni   |  13 +
 10 files changed, 708 insertions(+), 2 deletions(-)
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
 create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 762badf5d239..8b2e03d49d07 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -84,6 +84,9 @@ [Ppis]
   ## Include/Ppi/ShadowMicrocode.h
   gEdkiiPeiShadowMicrocodePpiGuid = { 0x430f6965, 0x9a69, 0x41c5, { 0x93, 
0xed, 0x8b, 0xf0, 0x64, 0x35, 0xc1, 0xc6 }}
 
+  ## Include/Ppi/RepublishSecPpi.h
+  gRepublishSecPpiPpiGuid   = { 0x27a71b1e, 0x73ee, 0x43d6, { 0xac, 0xe3, 
0x52, 0x1a, 0x2d, 0xc5, 0xd0, 0x92 }}
+
 [PcdsFeatureFlag]
   ## Indicates if SMM Profile will be enabled.
   #  If enabled, instruction executions in and data accesses to memory outside 
of SMRAM will be logged.
diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index afa304128221..964720048dd7 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -146,6 +146,7 @@ [Components.IA32, Components.X64]
   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
   UefiCpuPkg/SecCore/SecCore.inf
+  UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
index 0562820c95e0..545781d6b4b3 100644
--- a/UefiCpuPkg/SecCore/SecCore.inf
+++ b/UefiCpuPkg/SecCore/SecCore.inf
@@ -68,6 +68,8 @@ [Ppis]
   ## SOMETIMES_CONSUMES
   gPeiSecPerformancePpiGuid
   gEfiPeiCoreFvLocationPpiGuid
+  ## CONSUMES
+  gRepublishSecPpiPpiGuid
 
 [Guids]
   ## SOMETIMES_PRODUCES   ## HOB
diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf 
b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
new file mode 100644
index ..f4c2f6b658fb
--- /dev/null
+++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
@@ -0,0 +1,67 @@
+## @file
+#  Migrates SEC structures after permanent memory is installed.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = SecMigrationPei
+  MODULE_UNI_FILE= SecMigrationPei.uni
+  FILE_GUID  = 58B35361-8922-41BC-B313-EF7ED9ADFDF7
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.0
+  ENTRY_POINT= SecMigrationPeiInitialize
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64 EBC
+#
+
+[Sources]
+  SecMigrationPei.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  HobLib
+  MemoryAllocationLib
+  PeimEntryPoint
+  PeiServicesLib
+  PeiServicesTablePointerLib
+
+[Ppis]
+  ## PRODUCES
+  gRepublishSecPpiPpiGuid
+
+  ## SOMETIMES_PRODUCES
+  gEfiTemporaryRamDonePpiGuid
+
+  ## SOMETIME_PRODUCES
+  gEfiTemporaryRamSupportPpiGuid
+
+  ## SOMETIMES_PRODUCES
+  gPeiSecPerformancePpiGuid
+
+  ## SOMETIMES_CONSUMES
+  ## PRODUCES
+  gEfiSecPlatformInformationPpiGuid
+
+  ## SOMETIMES_CONSUMES
+  ## SOMETIMES_PRODUCES
+  gEfiSecPlatformInformation2PpiGuid
+
+[Pcd]
+  gEfiMdeModulePkg

[edk2-devel] [PATCH v7 02/10] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098)

2020-07-22 Thread Guomin Jiang
From: Michael Kubacki 

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

Introduces new changes to PeiCore to move the contents of temporary
RAM visible to the PeiCore to permanent memory. This expands on
pre-existing shadowing support in the PeiCore to perform the following
additional actions:

 1. Migrate pointers in PPIs installed in PeiCore to the permanent
memory copy of PeiCore.

 2. Copy all installed firmware volumes to permanent memory.

 3. Relocate and fix up the PEIMs within the firmware volumes.

 4. Convert all PPIs into the migrated firmware volume to the corresponding
PPI address in the permanent memory location.

This applies to PPIs and PEI notifications.

 5. Convert all status code callbacks in the migrated firmware volume to
the corresponding address in the permanent memory location.

 6. Update the FV HOB to the corresponding firmware volume in permanent
memory.

 7. Add PcdMigrateTemporaryRamFirmwareVolumes to control if enable the
feature or not. when the PCD disable, the EvacuateTempRam() will
never be called.

The function control flow as below:
  PeiCore()
DumpPpiList()
EvacuateTempRam()
  ConvertPeiCorePpiPointers()
ConvertPpiPointersFv()
  MigratePeimsInFv()
MigratePeim()
  PeiGetPe32Data()
  LoadAndRelocatePeCoffImageInPlace()
  MigrateSecModulesInFv()
  ConvertPpiPointersFv()
  ConvertStatusCodeCallbacks()
  ConvertFvHob()
  RemoveFvHobsInTemporaryMemory()
DumpPpiList()

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Michael Kubacki 
Acked-by: Laszlo Ersek 
---
 MdeModulePkg/Core/Pei/PeiMain.inf |   2 +
 MdeModulePkg/Core/Pei/PeiMain.h   | 169 
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 392 ++
 MdeModulePkg/Core/Pei/Image/Image.c   | 116 ++
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  24 ++
 MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 +
 7 files changed, 1072 insertions(+)

diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 6e25cc40232a..5b36d516b3fa 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -76,6 +76,7 @@ [Guids]
   ## CONSUMES   ## UNDEFINED # Locate PPI
   ## CONSUMES   ## GUID  # Used to compare with FV's file system GUID and 
get the FV's file system format
   gEfiFirmwareFileSystem3Guid
+  gStatusCodeCallbackGuid
 
 [Ppis]
   gEfiPeiStatusCodePpiGuid  ## SOMETIMES_CONSUMES # 
PeiReportStatusService is not ready if this PPI doesn't exist
@@ -109,6 +110,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes  ## 
CONSUMES
 
 # [BootMode]
 # S3_RESUME ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 56b3bd85793d..6d95a5d32c78 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -394,6 +394,41 @@ PeimDispatchReadiness (
   IN VOID   *DependencyExpression
   );
 
+/**
+  Migrate a PEIM from temporary RAM to permanent memory.
+
+  @param PeimFileHandle   Pointer to the FFS file header of the image.
+  @param MigratedFileHandle   Pointer to the FFS file header of the migrated 
image.
+
+  @retval EFI_SUCCESS Sucessfully migrated the PEIM to permanent 
memory.
+
+**/
+EFI_STATUS
+EFIAPI
+MigratePeim (
+  IN  EFI_PEI_FILE_HANDLE FileHandle,
+  IN  EFI_PEI_FILE_HANDLE MigratedFileHandle
+  );
+
+/**
+  Migrate FVs out of temporary RAM before the cache is flushed.
+
+  @param Private PeiCore's private data structure
+  @param SecCoreData Points to a data structure containing information 
about the PEI core's operating
+ environment, such as the size and location of 
temporary RAM, the stack location and
+ the BFV location.
+
+  @retval EFI_SUCCESS   Succesfully migrated installed FVs from 
temporary RAM to permanent memory.
+  @retval EFI_OUT_OF_RESOURCES  Insufficient memory exists to allocate needed 
pages.
+
+**/
+EFI_STATUS
+EFIAPI
+EvacuateTempRam (
+  IN PEI_CORE_INSTANCE*Private,
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData
+  );
+
 /**
   Conduct PEIM dispatch.
 
@@ -477,6 +512,50 @@ ConvertPpiPointers (
   IN PEI_CORE_INSTANCE   *PrivateData
   );
 
+/**
+
+  Migrate Notify Pointers inside an FV from temporary memory to permanent 
memory.
+
+  @param PrivateData  Pointer to PeiCore's private data structure.
+ 

[edk2-devel] [PATCH v7 3/6] SecurityPkg/Tcg: Add TcgPpi

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/Tcg/TcgPei/TcgPei.c   | 61 ---
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |  3 +-
 2 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index a9a808c9ec..2533388849 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -1,7 +1,7 @@
 /** @file
   Initialize TPM device and measure FVs before handing off control to DXE.
 
-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -51,6 +52,45 @@ EFI_PEI_PPI_DESCRIPTOR  mTpmInitializationDonePpiList = {
   NULL
 };
 
+/**
+  Do a hash operation on a data buffer, extend a specific TPM PCR with the 
hash result,
+  and build a GUIDed HOB recording the event which will be passed to the DXE 
phase and
+  added into the Event Log.
+
+  @param[in]  This  Indicates the calling context
+  @param[in]  Flags Bitmap providing additional information.
+  @param[in]  HashData  Physical address of the start of the data 
buffer
+to be hashed, extended, and logged.
+  @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
+  @param[in]  NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.
+  @param[in]  NewEventData  Pointer to the new event data.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_OUT_OF_RESOURCES  No enough memory to log the new event.
+  @retval EFI_DEVICE_ERROR  The command was unsuccessful.
+
+**/
+EFI_STATUS
+EFIAPI
+HashLogExtendEvent (
+  IN  EDKII_TCG_PPI *This,
+  IN  UINT64Flags,
+  IN  UINT8 *HashData,
+  IN  UINTN HashDataLen,
+  IN  TCG_PCR_EVENT_HDR *NewEventHdr,
+  IN  UINT8 *NewEventData
+  );
+
+EDKII_TCG_PPI mEdkiiTcgPpi = {
+  HashLogExtendEvent
+};
+
+EFI_PEI_PPI_DESCRIPTOR  mTcgPpiList = {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  &gEdkiiTcgPpiGuid,
+  &mEdkiiTcgPpi
+};
+
 //
 // Number of firmware blobs to grow by each time we run out of room
 //
@@ -243,7 +283,8 @@ TpmCommHashAll (
   and build a GUIDed HOB recording the event which will be passed to the DXE 
phase and
   added into the Event Log.
 
-  @param[in]  PeiServices   Describes the list of possible PEI Services.
+  @param[in]  This  Indicates the calling context.
+  @param[in]  Flags Bitmap providing additional information.
   @param[in]  HashData  Physical address of the start of the data 
buffer
 to be hashed, extended, and logged.
   @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
@@ -256,8 +297,10 @@ TpmCommHashAll (
 
 **/
 EFI_STATUS
+EFIAPI
 HashLogExtendEvent (
-  IN  EFI_PEI_SERVICES  **PeiServices,
+  IN  EDKII_TCG_PPI *This,
+  IN  UINT64Flags,
   IN  UINT8 *HashData,
   IN  UINTN HashDataLen,
   IN  TCG_PCR_EVENT_HDR *NewEventHdr,
@@ -346,7 +389,8 @@ MeasureCRTMVersion (
   TcgEventHdr.EventSize = (UINT32) StrSize((CHAR16*)PcdGetPtr 
(PcdFirmwareVersionString));
 
   return HashLogExtendEvent (
-   PeiServices,
+   &mEdkiiTcgPpi,
+   0,
(UINT8*)PcdGetPtr (PcdFirmwareVersionString),
TcgEventHdr.EventSize,
&TcgEventHdr,
@@ -415,7 +459,8 @@ MeasureFvImage (
   TcgEventHdr.EventSize = sizeof (FvBlob);
 
   Status = HashLogExtendEvent (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer(),
+ &mEdkiiTcgPpi,
+ 0,
  (UINT8*) (UINTN) FvBlob.BlobBase,
  (UINTN) FvBlob.BlobLength,
  &TcgEventHdr,
@@ -744,6 +789,12 @@ PeimEntryMP (
   Status = PeiServicesNotifyPpi (&mNotifyList[0]);
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // install Tcg Services
+  //
+  Status = PeiServicesInstallPpi (&mTcgPpiList);
+  ASSERT_EFI_ERROR (Status);
+
   return Status;
 }
 
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf 
b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index c0bff6e85e..4ab4edd657 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -4,7 +4,7 @@
 #  This module will initialize TPM device, measure reported FVs and BIOS 
version.
 #  This module may also lock TPM physical presence and 
physicalPresenceLifetimeLock.
 #
-# Copyright (c) 2006 

[edk2-devel] [PATCH v7 5/6] SecurityPkg/PeiTpmMeasurementLib: Add PEI instance.

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../PeiTpmMeasurementLib.c| 74 +++
 .../PeiTpmMeasurementLib.inf  | 50 +
 .../PeiTpmMeasurementLib.uni  | 17 +
 3 files changed, 141 insertions(+)
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni

diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c 
b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
new file mode 100644
index 00..200e15a294
--- /dev/null
+++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
@@ -0,0 +1,74 @@
+/** @file
+  This library is used by other modules to measure data to TPM.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved. 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/**
+  Tpm measure and log data, and extend the measurement result into a specific 
PCR.
+
+  @param[in]  PcrIndex PCR Index.
+  @param[in]  EventTypeEvent type.
+  @param[in]  EventLog Measurement event log.
+  @param[in]  LogLen   Event log length in bytes.
+  @param[in]  HashData The start of the data buffer to be hashed, 
extended.
+  @param[in]  HashDataLen  The length, in bytes, of the buffer referenced 
by HashData
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+TpmMeasureAndLogData (
+  IN UINT32 PcrIndex,
+  IN UINT32 EventType,
+  IN VOID   *EventLog,
+  IN UINT32 LogLen,
+  IN VOID   *HashData,
+  IN UINT64 HashDataLen
+  )
+{
+  EFI_STATUSStatus;
+  EDKII_TCG_PPI *TcgPpi;
+  TCG_PCR_EVENT_HDR TcgEventHdr;
+
+  Status = PeiServicesLocatePpi (
+ &gEdkiiTcgPpiGuid,
+ 0,
+ NULL,
+ (VOID**)&TcgPpi
+ );
+  if (EFI_ERROR(Status)) {
+return Status;
+  }
+
+  TcgEventHdr.PCRIndex  = PcrIndex;
+  TcgEventHdr.EventType = EventType;
+  TcgEventHdr.EventSize = LogLen;
+
+  Status = TcgPpi->HashLogExtendEvent (
+ TcgPpi,
+ 0,
+ HashData,
+ (UINTN)HashDataLen,
+ &TcgEventHdr,
+ EventLog
+ );
+  return Status;
+}
diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf 
b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
new file mode 100644
index 00..6625d0fd01
--- /dev/null
+++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
@@ -0,0 +1,50 @@
+## @file
+#  Provides TPM measurement functions for TPM1.2 and TPM 2.0
+#
+#  This library provides TpmMeasureAndLogData() to measure and log data, and
+#  extend the measurement result into a specific PCR.
+#
+# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = PeiTpmMeasurementLib
+  FILE_GUID  = 9A62C49D-C45A-4322-9F3C-45958DF0056B
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = TpmMeasurementLib|PEIM
+  MODULE_UNI_FILE= PeiTpmMeasurementLib.uni
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  PeiTpmMeasurementLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  HobLib
+  DebugLib
+  PcdLib
+  PrintLib
+  PeiServicesLib
+  PeiServicesTablePointerLib
+
+[Ppis]
+  gEdkiiTcgPpiGuid ## 
CONSUMES
+
+[Depex]
+  gEfiPeiMasterBootModePpiGuid AND
+  gEfiTpmDeviceSelectedGuid
diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni 
b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni
new file mode 100644
index 00..7b4341b449
--- /dev/null
+++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni
@@ -0,0 +1,17 @@
+// /** @file
+// Provides TPM measurement functions for TPM1.2 and TPM 2.0
+//
+// This library provides TpmMeasureAndLogData() to to mea

[edk2-devel] [PATCH v7 6/6] SecurityPkg/dsc: Add PeiTpmMeasurementLib.

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/SecurityPkg.dsc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 53fce05353..28effe3eda 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  Security Module Package for All Architectures.
 #
-# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
 # (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -96,6 +96,7 @@
   Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
   Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
   
Tcg2PhysicalPresenceLib|SecurityPkg/Library/PeiTcg2PhysicalPresenceLib/PeiTcg2PhysicalPresenceLib.inf
+  
TpmMeasurementLib|SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
   RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
@@ -234,6 +235,7 @@
   SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf
   
SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.inf
 
+  SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
   SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
   SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
   SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63091): https://edk2.groups.io/g/devel/message/63091
Mute This Topic: https://groups.io/mt/75720711/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 2/6] SecurityPkg/dec: Add TcgPpi.

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/SecurityPkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index 79d46308ad..42fc48cc1f 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -203,6 +203,9 @@
   ## Include/Ppi/FirmwareVolumeInfoStoredHashFv.h
   gEdkiiPeiFirmwareVolumeInfoStoredHashFvPpiGuid = {0x7f5e4e31, 0x81b1, 
0x47e5, { 0x9e, 0x21, 0x1e, 0x4b, 0x5b, 0xc2, 0xf6, 0x1d } }
 
+  ## Include/Ppi/Tcg.h
+  gEdkiiTcgPpiGuid = {0x57a13b87, 0x133d, 0x4bf3, { 0xbf, 0xf1, 0x1b, 0xca, 
0xc7, 0x17, 0x6c, 0xf1 } }
+
 #
 # [Error.gEfiSecurityPkgTokenSpaceGuid]
 #   0x8001 | Invalid value provided.
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63087): https://edk2.groups.io/g/devel/message/63087
Mute This Topic: https://groups.io/mt/75720707/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 4/6] SecurityPkg/Tcg2: Add TcgPpi

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

And do some code clean with updated function

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c   | 110 +---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf |   3 +-
 2 files changed, 86 insertions(+), 27 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 19b8e4b318..71695df3d8 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -1,7 +1,7 @@
 /** @file
   Initialize TPM2 device and measure FVs before handing off control to DXE.
 
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
 Copyright (c) 2017, Microsoft Corporation.  All rights reserved. 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -66,6 +67,48 @@ EFI_PEI_PPI_DESCRIPTOR  mTpmInitializationDonePpiList = {
   NULL
 };
 
+/**
+  Do a hash operation on a data buffer, extend a specific TPM PCR with the 
hash result,
+  and build a GUIDed HOB recording the event which will be passed to the DXE 
phase and
+  added into the Event Log.
+
+  @param[in]  This  Indicates the calling context
+  @param[in]  Flags Bitmap providing additional information.
+  @param[in]  HashData  If BIT0 of Flags is 0, it is physical address 
of the
+start of the data buffer to be hashed, 
extended, and logged.
+If BIT0 of Flags is 1, it is physical address 
of the
+start of the pre-hash data buffter to be 
extended, and logged.
+The pre-hash data format is TPML_DIGEST_VALUES.
+  @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
+  @param[in]  NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.
+  @param[in]  NewEventData  Pointer to the new event data.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_OUT_OF_RESOURCES  No enough memory to log the new event.
+  @retval EFI_DEVICE_ERROR  The command was unsuccessful.
+
+**/
+EFI_STATUS
+EFIAPI
+HashLogExtendEvent (
+  IN  EDKII_TCG_PPI *This,
+  IN  UINT64Flags,
+  IN  UINT8 *HashData,
+  IN  UINTN HashDataLen,
+  IN  TCG_PCR_EVENT_HDR *NewEventHdr,
+  IN  UINT8 *NewEventData
+  );
+
+EDKII_TCG_PPI mEdkiiTcgPpi = {
+  HashLogExtendEvent
+};
+
+EFI_PEI_PPI_DESCRIPTOR  mTcgPpiList = {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  &gEdkiiTcgPpiGuid,
+  &mEdkiiTcgPpi
+};
+
 //
 // Number of firmware blobs to grow by each time we run out of room
 //
@@ -375,9 +418,13 @@ LogHashEvent (
   and build a GUIDed HOB recording the event which will be passed to the DXE 
phase and
   added into the Event Log.
 
+  @param[in]  This  Indicates the calling context
   @param[in]  Flags Bitmap providing additional information.
-  @param[in]  HashData  Physical address of the start of the data 
buffer
-to be hashed, extended, and logged.
+  @param[in]  HashData  If BIT0 of Flags is 0, it is physical address 
of the
+start of the data buffer to be hashed, 
extended, and logged.
+If BIT0 of Flags is 1, it is physical address 
of the
+start of the pre-hash data buffter to be 
extended, and logged.
+The pre-hash data format is TPML_DIGEST_VALUES.
   @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
   @param[in]  NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.
   @param[in]  NewEventData  Pointer to the new event data.
@@ -388,7 +435,9 @@ LogHashEvent (
 
 **/
 EFI_STATUS
+EFIAPI
 HashLogExtendEvent (
+  IN  EDKII_TCG_PPI *This,
   IN  UINT64Flags,
   IN  UINT8 *HashData,
   IN  UINTN HashDataLen,
@@ -403,16 +452,23 @@ HashLogExtendEvent (
 return EFI_DEVICE_ERROR;
   }
 
-  Status = HashAndExtend (
- NewEventHdr->PCRIndex,
- HashData,
- HashDataLen,
+  if(Flags & EDKII_TCG_PRE_HASH) {
+ZeroMem (&DigestList, sizeof(DigestList));
+CopyMem (&DigestList, HashData, sizeof(DigestList));
+Status = Tpm2PcrExtend (
+ 0,
  &DigestList
  );
+  } else {
+Status = HashAndExtend (
+   NewEventHdr->PCRIndex,
+   HashData,
+   

[edk2-devel] [PATCH v7 0/6] Add capability to let PEIM extend TcgEvent

2020-07-22 Thread Qi Zhang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2841

Currently, we have TCG/TCG2 protocol and DxeTpmMeasurementLib to let DXE
module extend the TCG event.
There is more and more use case in PEI phase that a PEIM need extend TCG
event, such as BootGuard, FSP, Microcode measurement. Currently, we dont
have API to do that so that each module need create TCG/TCG2 event log,
which is a burden.

This bugzilla requests to add PeiTpmMeasurementLib instance.

The implementation includes:
1) A EDKII_TCG_PPI which abstracts the HashLogExtendEvent service.
2) A PeiTpmMeasurementLib instance, so that a PEIM can call this API to
  add TCG event.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Cc: Rahul Kumar 

Jiewen Yao (6):
  SecurityPkg/TcgPpi: Add TcgPpi header file.
  SecurityPkg/dec: Add TcgPpi.
  SecurityPkg/Tcg: Add TcgPpi
  SecurityPkg/Tcg2: Add TcgPpi
  SecurityPkg/PeiTpmMeasurementLib: Add PEI instance.
  SecurityPkg/dsc: Add PeiTpmMeasurementLib.

 SecurityPkg/Include/Ppi/Tcg.h |  60 ++
 .../PeiTpmMeasurementLib.c|  74 
 .../PeiTpmMeasurementLib.inf  |  50 
 .../PeiTpmMeasurementLib.uni  |  17 +++
 SecurityPkg/SecurityPkg.dec   |   3 +
 SecurityPkg/SecurityPkg.dsc   |   4 +-
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 110 +-
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf   |   3 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.c   |  61 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |   3 +-
 10 files changed, 351 insertions(+), 34 deletions(-)
 create mode 100644 SecurityPkg/Include/Ppi/Tcg.h
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni

-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63085): https://edk2.groups.io/g/devel/message/63085
Mute This Topic: https://groups.io/mt/75720704/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v7 1/6] SecurityPkg/TcgPpi: Add TcgPpi header file.

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/Include/Ppi/Tcg.h | 60 +++
 1 file changed, 60 insertions(+)
 create mode 100644 SecurityPkg/Include/Ppi/Tcg.h

diff --git a/SecurityPkg/Include/Ppi/Tcg.h b/SecurityPkg/Include/Ppi/Tcg.h
new file mode 100644
index 00..0e943f2465
--- /dev/null
+++ b/SecurityPkg/Include/Ppi/Tcg.h
@@ -0,0 +1,60 @@
+/** @file
+  TCG PPI services.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _TCG_PPI_H_
+#define _TCG_PPI_H_
+
+#include 
+
+typedef struct _EDKII_TCG_PPI EDKII_TCG_PPI;
+
+//
+// This bit is shall be set when HashData is the pre-hash digest.
+//
+#define EDKII_TCG_PRE_HASH  0x0001
+
+/**
+  Tpm measure and log data, and extend the measurement result into a specific 
PCR.
+
+  @param[in]  This  Indicates the calling context
+  @param[in]  Flags Bitmap providing additional information
+  @param[in]  HashData  If BIT0 of Flags is 0, it is physical address 
of the
+start of the data buffer to be hashed, 
extended, and logged.
+If BIT0 of Flags is 1, it is physical address 
of the
+start of the pre-hash data buffter to be 
extended, and logged.
+The pre-hash data format is TPML_DIGEST_VALUES.
+  @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
+  @param[in]  NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.
+  @param[in]  NewEventData  Pointer to the new event data.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_TCG_HASH_LOG_EXTEND_EVENT)(
+  IN  EDKII_TCG_PPI *This,
+  IN  UINT64Flags,
+  IN  UINT8 *HashData,
+  IN  UINTN HashDataLen,
+  IN  TCG_PCR_EVENT_HDR *NewEventHdr,
+  IN  UINT8 *NewEventData
+  );
+
+///
+/// The EFI_TCG Protocol abstracts TCG activity.
+///
+struct _EDKII_TCG_PPI {
+  EDKII_TCG_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+};
+
+extern EFI_GUID gEdkiiTcgPpiGuid;
+
+#endif
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63086): https://edk2.groups.io/g/devel/message/63086
Mute This Topic: https://groups.io/mt/75720705/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] BaseLib:Fix RISC-V Supervisor mode (S-Mode) trap handler reentry issue.

2020-07-22 Thread Daniel Schaefer

On 7/16/20 4:10 PM, Abner Chang wrote:

While RISC-V hart is trapped into S-Mode, the S-Mode interrupt
CSR (SIE) is disabled by RISC-V hart. However the (SIE) is enabled
again by RestoreTPL, this causes the second S-Mode trap is triggered
by the machine mode (M-Mode)timer interrupt redirection. The SRET
instruction clear Supervisor Previous Privilege (SPP) to zero
(User mode) in the second S-Mode interrupt according to the RISC-V
spec. Above brings hart to the user mode (U-Mode) when execute
SRET in the nested S-Mode interrupt handler because SPP is set to
User Mode in the second interrupt. Afterward, system runs in U-Mode
and any accesses to S-Mode CSR causes the invalid instruction exception.

Signed-off-by: Abner Chang 

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Daniel Schaefer 
Cc: Leif Lindholm 
Signed-off-by: Abner Chang 
---
  .../Library/BaseLib/RiscV64/RiscVInterrupt.S  | 45 ---
  1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S 
b/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
index 766fcfb9cb..87b3468fc7 100644
--- a/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
+++ b/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
@@ -12,21 +12,52 @@ ASM_GLOBAL ASM_PFX(RiscVDisableSupervisorModeInterrupts)
  ASM_GLOBAL ASM_PFX(RiscVEnableSupervisorModeInterrupt)
  ASM_GLOBAL ASM_PFX(RiscVGetSupervisorModeInterrupts)
  
-# define  MSTATUS_SIE0x0002

-# define  CSR_SSTATUS0x100
+#define  SSTATUS_SIE 0x0002
+#define  CSR_SSTATUS 0x100
+  #define  SSTATUS_SPP_BIT_POSITION  8


Please start this define at the beginning of the line.

  
+//

+// This routine disables supervisor mode interrupt
+//
  ASM_PFX(RiscVDisableSupervisorModeInterrupts):
-  li   a1, MSTATUS_SIE
-  csrc CSR_SSTATUS, a1
+  add   sp, sp, -(__SIZEOF_POINTER__)
+  sda1, (sp)
+  lia1, SSTATUS_SIE
+  csrc  CSR_SSTATUS, a1
+  lda1, (sp)
+  add   sp, sp, (__SIZEOF_POINTER__)
ret


Good! Let's not lose those register values.


+//
+// This routine enables supervisor mode interrupt
+//
  ASM_PFX(RiscVEnableSupervisorModeInterrupt):
-  li   a1, MSTATUS_SIE
-  csrs CSR_SSTATUS, a1
+  add   sp, sp, -2*(__SIZEOF_POINTER__)
+  sda0, (0*__SIZEOF_POINTER__)(sp)
+  sda1, (1*__SIZEOF_POINTER__)(sp)
+
+  csrr  a0, CSR_SSTATUS
+  and   a0, a0, (1 << SSTATUS_SPP_BIT_POSITION)
+  bnez  a0, InTrap  // We are in supervisor mode (SMode)
+// trap handler.
+// Skip enabling SIE becasue SIE


because


+// is set to disabled by RISC-V hart
+// when the trap takes hart to SMode.
+
+  lia1, SSTATUS_SIE
+  csrs  CSR_SSTATUS, a1
+InTrap:
+  lda0, (0*__SIZEOF_POINTER__)(sp)
+  lda1, (1*__SIZEOF_POINTER__)(sp)
+  add   sp, sp, 2*(__SIZEOF_POINTER__)
ret
  
+//

+// This routine returns supervisor mode interrupt
+// status.
+//
  ASM_PFX(RiscVGetSupervisorModeInterrupts):
csrr a0, CSR_SSTATUS
-  andi a0, a0, MSTATUS_SIE
+  andi a0, a0, SSTATUS_SIE
ret
  



Looks good otherwise :) With the the small changes:
Reviewed-by: Daniel Schaefer 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63084): https://edk2.groups.io/g/devel/message/63084
Mute This Topic: https://groups.io/mt/75543200/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] BaseTools/Scripts: Ignore the CRLF check when upgrade submodule.

2020-07-22 Thread Liming Gao
For submodule, I see the diff content. So, can we use "Subproject commit" as 
key to ignore it?

-Subproject commit c3656cc594daac8167721dde7220f0e59ae146fc
+Subproject commit e2e09d9fba1187f8d6aafaa34d4172f56f1ffb72

Thanks
Liming
-Original Message-
From: Feng, Bob C  
Sent: 2020年7月22日 10:28
To: Jiang, Guomin ; Gao, Liming ; 
devel@edk2.groups.io
Subject: RE: [PATCH 1/1] BaseTools/Scripts: Ignore the CRLF check when upgrade 
submodule.

Here is a case.

diff --git a/BaseTools/BinWrappers/PosixLike/AmlToHex 
b/BaseTools/BinWrappers/PosixLike/AmlToC
similarity index 97%
rename from BaseTools/BinWrappers/PosixLike/AmlToHex
rename to BaseTools/BinWrappers/PosixLike/AmlToC
index 
9fb68299e4c67d1f332cd883fd348a896f1bdc50..1dd28e966288f6ea4fc52d42e2dc7b1f74226c23
 100755

self.line_num+1 looks a hard code based on an assumption. 

Thanks,
Bob

-Original Message-
From: Jiang, Guomin 
Sent: Wednesday, July 22, 2020 10:21 AM
To: Feng, Bob C ; Gao, Liming ; 
devel@edk2.groups.io
Subject: RE: [PATCH 1/1] BaseTools/Scripts: Ignore the CRLF check when upgrade 
submodule.

Hi Bob,

Can you provide a sample that the file attribute is not the next line.

Even if the case you mentioned is present, I seem that have not affect on the 
current behavior, isn't it?

Thanks.
Guomin
> -Original Message-
> From: Feng, Bob C 
> Sent: Wednesday, July 22, 2020 10:08 AM
> To: Jiang, Guomin ; Gao, Liming 
> ; devel@edk2.groups.io
> Subject: RE: [PATCH 1/1] BaseTools/Scripts: Ignore the CRLF check when 
> upgrade submodule.
> 
> Guomin,
> 
> I have two comments.
> 1. Please only descript the patch's function in the commit message.
> 2. The file attribute is not always the next line of the line starts 
> with "diff -- git"
> 
> Thanks,
> Bob
> 
> -Original Message-
> From: Jiang, Guomin 
> Sent: Tuesday, July 21, 2020 6:38 PM
> To: Gao, Liming ; devel@edk2.groups.io
> Cc: Feng, Bob C 
> Subject: RE: [PATCH 1/1] BaseTools/Scripts: Ignore the CRLF check when 
> upgrade submodule.
> 
> It is used to judge if the current change is for submodule.
> 
> The attribute of submodule is 16, just like the file attribute of 
> file is 10644.
> 
> Normally, the changed file will begin with 'diff --git' and the next line 
> like '
> index 954f66c056e..04300e71f38 100644' which end with the attribute, 
> and changed submodule is similar.
> 
> > -Original Message-
> > From: Gao, Liming 
> > Sent: Tuesday, July 21, 2020 1:57 PM
> > To: Jiang, Guomin ; devel@edk2.groups.io
> > Cc: Feng, Bob C 
> > Subject: RE: [PATCH 1/1] BaseTools/Scripts: Ignore the CRLF check 
> > when upgrade submodule.
> >
> > Guomin:
> >   +   self.lines[self.line_num+1].endswith('16\n') or
> >
> >   What means for this line?
> >
> >
> > Thanks
> > Liming
> > -Original Message-
> > From: Jiang, Guomin 
> > Sent: 2020年7月21日 10:59
> > To: devel@edk2.groups.io
> > Cc: Feng, Bob C ; Gao, Liming 
> > 
> > Subject: [PATCH 1/1] BaseTools/Scripts: Ignore the CRLF check when 
> > upgrade submodule.
> >
> > When i upgrade openssl to 1.1.1g, error occurred when run PatchCheck.py.
> > The reason is that the submodule will end with LF, but it will check 
> > based on file rule, it make no sense and need ignore the check.
> >
> > Signed-off-by: Guomin Jiang 
> > Cc: Bob Feng 
> > Cc: Liming Gao 
> > ---
> >  BaseTools/Scripts/PatchCheck.py | 4 
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/BaseTools/Scripts/PatchCheck.py 
> > b/BaseTools/Scripts/PatchCheck.py index 7db0775d14d1..46b9936c6576
> > 100755
> > --- a/BaseTools/Scripts/PatchCheck.py
> > +++ b/BaseTools/Scripts/PatchCheck.py
> > @@ -405,12 +405,16 @@ class GitDiffCheck:
> >  #
> >  self.force_crlf = False
> >  if self.filename == '.gitmodules' or \
> > +   self.lines[self.line_num+1].endswith('16\n')
> > + or \
> > self.filename == 'BaseTools/Conf/diff.order':
> >  #
> >  # .gitmodules and diff orderfiles are used internally 
> > by git
> >  # use tabs and LF line endings.  Do not enforce no 
> > tabs and
> >  # do not enforce CR/LF line endings.
> >  #
> > +# When update submodule, it will encode with LF line 
> > and do
> > +# not enforce CR/LF line endings.
> > +#
> >  self.force_crlf = False
> >  self.force_notabs = False
> >  elif len(line.rstrip()) != 0:
> > --
> > 2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63083): https://edk2.groups.io/g/devel/message/63083
Mute This Topic: https://groups.io/mt/75697127/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v6 6/6] SecurityPkg/dsc: Add PeiTpmMeasurementLib.

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/SecurityPkg.dsc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 53fce05353..28effe3eda 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  Security Module Package for All Architectures.
 #
-# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
 # (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -96,6 +96,7 @@
   Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
   Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
   
Tcg2PhysicalPresenceLib|SecurityPkg/Library/PeiTcg2PhysicalPresenceLib/PeiTcg2PhysicalPresenceLib.inf
+  
TpmMeasurementLib|SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
   RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
@@ -234,6 +235,7 @@
   SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf
   
SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.inf
 
+  SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
   SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
   SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
   SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63082): https://edk2.groups.io/g/devel/message/63082
Mute This Topic: https://groups.io/mt/75720106/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v6 4/6] SecurityPkg/Tcg2: Add TcgPpi

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

And do some code clean with updated function

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c   | 110 +---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf |   3 +-
 2 files changed, 86 insertions(+), 27 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 19b8e4b318..592f760057 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -1,7 +1,7 @@
 /** @file
   Initialize TPM2 device and measure FVs before handing off control to DXE.
 
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
 Copyright (c) 2017, Microsoft Corporation.  All rights reserved. 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -66,6 +67,48 @@ EFI_PEI_PPI_DESCRIPTOR  mTpmInitializationDonePpiList = {
   NULL
 };
 
+/**
+  Do a hash operation on a data buffer, extend a specific TPM PCR with the 
hash result,
+  and build a GUIDed HOB recording the event which will be passed to the DXE 
phase and
+  added into the Event Log.
+
+  @param[in]  This  Indicates the calling context
+  @param[in]  Flags Bitmap providing additional information.
+  @param[in]  HashData  If BIT0 of Flags is 0, it is physical address 
of the
+start of the data buffer to be hashed, 
extended, and logged.
+If BIT0 of Flags is 1, it is physical address 
of the
+start of the pre-hash data buffter to be 
extended, and logged.
+The pre-hash data format is TPML_DIGEST_VALUES.
+  @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
+  @param[in]  NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.
+  @param[in]  NewEventData  Pointer to the new event data.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_OUT_OF_RESOURCES  No enough memory to log the new event.
+  @retval EFI_DEVICE_ERROR  The command was unsuccessful.
+
+**/
+EFI_STATUS
+EFIAPI
+HashLogExtendEvent (
+  IN  EDKII_TCG_PPI *This,
+  IN  UINT64Flags,
+  IN  UINT8 *HashData,
+  IN  UINTN HashDataLen,
+  IN  TCG_PCR_EVENT_HDR *NewEventHdr,
+  IN  UINT8 *NewEventData
+  );
+
+EDKII_TCG_PPI mEdkiiTcgPpi = {
+  HashLogExtendEvent
+};
+
+EFI_PEI_PPI_DESCRIPTOR  mTcgPpiList = {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  &gEdkiiTcgPpiGuid,
+  &mEdkiiTcgPpi
+};
+
 //
 // Number of firmware blobs to grow by each time we run out of room
 //
@@ -375,9 +418,13 @@ LogHashEvent (
   and build a GUIDed HOB recording the event which will be passed to the DXE 
phase and
   added into the Event Log.
 
+  @param[in]  This  Indicates the calling context
   @param[in]  Flags Bitmap providing additional information.
-  @param[in]  HashData  Physical address of the start of the data 
buffer
-to be hashed, extended, and logged.
+  @param[in]  HashData  If BIT0 of Flags is 0, it is physical address 
of the
+start of the data buffer to be hashed, 
extended, and logged.
+If BIT0 of Flags is 1, it is physical address 
of the
+start of the pre-hash data buffter to be 
extended, and logged.
+The pre-hash data format is TPML_DIGEST_VALUES.
   @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
   @param[in]  NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.
   @param[in]  NewEventData  Pointer to the new event data.
@@ -388,7 +435,9 @@ LogHashEvent (
 
 **/
 EFI_STATUS
+EFIAPI
 HashLogExtendEvent (
+  IN  EDKII_TCG_PPI *This,
   IN  UINT64Flags,
   IN  UINT8 *HashData,
   IN  UINTN HashDataLen,
@@ -403,16 +452,23 @@ HashLogExtendEvent (
 return EFI_DEVICE_ERROR;
   }
 
-  Status = HashAndExtend (
- NewEventHdr->PCRIndex,
- HashData,
- HashDataLen,
+  if(Flags & EDKII_TCG_PRE_HASH) {
+ZeroMem (&DigestList, sizeof(DigestList));
+CopyMem(&DigestList, HashData, sizeof(DigestList));
+Status = Tpm2PcrExtend(
+ 0,
  &DigestList
  );
+  } else {
+Status = HashAndExtend (
+   NewEventHdr->PCRIndex,
+   HashData,
+   Ha

[edk2-devel] [PATCH v6 5/6] SecurityPkg/PeiTpmMeasurementLib: Add PEI instance.

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../PeiTpmMeasurementLib.c| 74 +++
 .../PeiTpmMeasurementLib.inf  | 50 +
 .../PeiTpmMeasurementLib.uni  | 17 +
 3 files changed, 141 insertions(+)
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni

diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c 
b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
new file mode 100644
index 00..200e15a294
--- /dev/null
+++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
@@ -0,0 +1,74 @@
+/** @file
+  This library is used by other modules to measure data to TPM.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved. 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/**
+  Tpm measure and log data, and extend the measurement result into a specific 
PCR.
+
+  @param[in]  PcrIndex PCR Index.
+  @param[in]  EventTypeEvent type.
+  @param[in]  EventLog Measurement event log.
+  @param[in]  LogLen   Event log length in bytes.
+  @param[in]  HashData The start of the data buffer to be hashed, 
extended.
+  @param[in]  HashDataLen  The length, in bytes, of the buffer referenced 
by HashData
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+TpmMeasureAndLogData (
+  IN UINT32 PcrIndex,
+  IN UINT32 EventType,
+  IN VOID   *EventLog,
+  IN UINT32 LogLen,
+  IN VOID   *HashData,
+  IN UINT64 HashDataLen
+  )
+{
+  EFI_STATUSStatus;
+  EDKII_TCG_PPI *TcgPpi;
+  TCG_PCR_EVENT_HDR TcgEventHdr;
+
+  Status = PeiServicesLocatePpi (
+ &gEdkiiTcgPpiGuid,
+ 0,
+ NULL,
+ (VOID**)&TcgPpi
+ );
+  if (EFI_ERROR(Status)) {
+return Status;
+  }
+
+  TcgEventHdr.PCRIndex  = PcrIndex;
+  TcgEventHdr.EventType = EventType;
+  TcgEventHdr.EventSize = LogLen;
+
+  Status = TcgPpi->HashLogExtendEvent (
+ TcgPpi,
+ 0,
+ HashData,
+ (UINTN)HashDataLen,
+ &TcgEventHdr,
+ EventLog
+ );
+  return Status;
+}
diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf 
b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
new file mode 100644
index 00..6625d0fd01
--- /dev/null
+++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
@@ -0,0 +1,50 @@
+## @file
+#  Provides TPM measurement functions for TPM1.2 and TPM 2.0
+#
+#  This library provides TpmMeasureAndLogData() to measure and log data, and
+#  extend the measurement result into a specific PCR.
+#
+# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = PeiTpmMeasurementLib
+  FILE_GUID  = 9A62C49D-C45A-4322-9F3C-45958DF0056B
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = TpmMeasurementLib|PEIM
+  MODULE_UNI_FILE= PeiTpmMeasurementLib.uni
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  PeiTpmMeasurementLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  HobLib
+  DebugLib
+  PcdLib
+  PrintLib
+  PeiServicesLib
+  PeiServicesTablePointerLib
+
+[Ppis]
+  gEdkiiTcgPpiGuid ## 
CONSUMES
+
+[Depex]
+  gEfiPeiMasterBootModePpiGuid AND
+  gEfiTpmDeviceSelectedGuid
diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni 
b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni
new file mode 100644
index 00..7b4341b449
--- /dev/null
+++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni
@@ -0,0 +1,17 @@
+// /** @file
+// Provides TPM measurement functions for TPM1.2 and TPM 2.0
+//
+// This library provides TpmMeasureAndLogData() to to mea

[edk2-devel] [PATCH v6 2/6] SecurityPkg/dec: Add TcgPpi.

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/SecurityPkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index 79d46308ad..42fc48cc1f 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -203,6 +203,9 @@
   ## Include/Ppi/FirmwareVolumeInfoStoredHashFv.h
   gEdkiiPeiFirmwareVolumeInfoStoredHashFvPpiGuid = {0x7f5e4e31, 0x81b1, 
0x47e5, { 0x9e, 0x21, 0x1e, 0x4b, 0x5b, 0xc2, 0xf6, 0x1d } }
 
+  ## Include/Ppi/Tcg.h
+  gEdkiiTcgPpiGuid = {0x57a13b87, 0x133d, 0x4bf3, { 0xbf, 0xf1, 0x1b, 0xca, 
0xc7, 0x17, 0x6c, 0xf1 } }
+
 #
 # [Error.gEfiSecurityPkgTokenSpaceGuid]
 #   0x8001 | Invalid value provided.
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63078): https://edk2.groups.io/g/devel/message/63078
Mute This Topic: https://groups.io/mt/75720097/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v6 3/6] SecurityPkg/Tcg: Add TcgPpi

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/Tcg/TcgPei/TcgPei.c   | 61 ---
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |  3 +-
 2 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index a9a808c9ec..2533388849 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -1,7 +1,7 @@
 /** @file
   Initialize TPM device and measure FVs before handing off control to DXE.
 
-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -51,6 +52,45 @@ EFI_PEI_PPI_DESCRIPTOR  mTpmInitializationDonePpiList = {
   NULL
 };
 
+/**
+  Do a hash operation on a data buffer, extend a specific TPM PCR with the 
hash result,
+  and build a GUIDed HOB recording the event which will be passed to the DXE 
phase and
+  added into the Event Log.
+
+  @param[in]  This  Indicates the calling context
+  @param[in]  Flags Bitmap providing additional information.
+  @param[in]  HashData  Physical address of the start of the data 
buffer
+to be hashed, extended, and logged.
+  @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
+  @param[in]  NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.
+  @param[in]  NewEventData  Pointer to the new event data.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_OUT_OF_RESOURCES  No enough memory to log the new event.
+  @retval EFI_DEVICE_ERROR  The command was unsuccessful.
+
+**/
+EFI_STATUS
+EFIAPI
+HashLogExtendEvent (
+  IN  EDKII_TCG_PPI *This,
+  IN  UINT64Flags,
+  IN  UINT8 *HashData,
+  IN  UINTN HashDataLen,
+  IN  TCG_PCR_EVENT_HDR *NewEventHdr,
+  IN  UINT8 *NewEventData
+  );
+
+EDKII_TCG_PPI mEdkiiTcgPpi = {
+  HashLogExtendEvent
+};
+
+EFI_PEI_PPI_DESCRIPTOR  mTcgPpiList = {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  &gEdkiiTcgPpiGuid,
+  &mEdkiiTcgPpi
+};
+
 //
 // Number of firmware blobs to grow by each time we run out of room
 //
@@ -243,7 +283,8 @@ TpmCommHashAll (
   and build a GUIDed HOB recording the event which will be passed to the DXE 
phase and
   added into the Event Log.
 
-  @param[in]  PeiServices   Describes the list of possible PEI Services.
+  @param[in]  This  Indicates the calling context.
+  @param[in]  Flags Bitmap providing additional information.
   @param[in]  HashData  Physical address of the start of the data 
buffer
 to be hashed, extended, and logged.
   @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
@@ -256,8 +297,10 @@ TpmCommHashAll (
 
 **/
 EFI_STATUS
+EFIAPI
 HashLogExtendEvent (
-  IN  EFI_PEI_SERVICES  **PeiServices,
+  IN  EDKII_TCG_PPI *This,
+  IN  UINT64Flags,
   IN  UINT8 *HashData,
   IN  UINTN HashDataLen,
   IN  TCG_PCR_EVENT_HDR *NewEventHdr,
@@ -346,7 +389,8 @@ MeasureCRTMVersion (
   TcgEventHdr.EventSize = (UINT32) StrSize((CHAR16*)PcdGetPtr 
(PcdFirmwareVersionString));
 
   return HashLogExtendEvent (
-   PeiServices,
+   &mEdkiiTcgPpi,
+   0,
(UINT8*)PcdGetPtr (PcdFirmwareVersionString),
TcgEventHdr.EventSize,
&TcgEventHdr,
@@ -415,7 +459,8 @@ MeasureFvImage (
   TcgEventHdr.EventSize = sizeof (FvBlob);
 
   Status = HashLogExtendEvent (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer(),
+ &mEdkiiTcgPpi,
+ 0,
  (UINT8*) (UINTN) FvBlob.BlobBase,
  (UINTN) FvBlob.BlobLength,
  &TcgEventHdr,
@@ -744,6 +789,12 @@ PeimEntryMP (
   Status = PeiServicesNotifyPpi (&mNotifyList[0]);
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // install Tcg Services
+  //
+  Status = PeiServicesInstallPpi (&mTcgPpiList);
+  ASSERT_EFI_ERROR (Status);
+
   return Status;
 }
 
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf 
b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index c0bff6e85e..4ab4edd657 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -4,7 +4,7 @@
 #  This module will initialize TPM device, measure reported FVs and BIOS 
version.
 #  This module may also lock TPM physical presence and 
physicalPresenceLifetimeLock.
 #
-# Copyright (c) 2006 

[edk2-devel] [PATCH v6 0/6] Add capability to let PEIM extend TcgEvent

2020-07-22 Thread Qi Zhang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2841

Currently, we have TCG/TCG2 protocol and DxeTpmMeasurementLib to let DXE
module extend the TCG event.
There is more and more use case in PEI phase that a PEIM need extend TCG
event, such as BootGuard, FSP, Microcode measurement. Currently, we dont
have API to do that so that each module need create TCG/TCG2 event log,
which is a burden.

This bugzilla requests to add PeiTpmMeasurementLib instance.

The implementation includes:
1) A EDKII_TCG_PPI which abstracts the HashLogExtendEvent service.
2) A PeiTpmMeasurementLib instance, so that a PEIM can call this API to
  add TCG event.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Cc: Rahul Kumar 

Jiewen Yao (6):
  SecurityPkg/TcgPpi: Add TcgPpi header file.
  SecurityPkg/dec: Add TcgPpi.
  SecurityPkg/Tcg: Add TcgPpi
  SecurityPkg/Tcg2: Add TcgPpi
  SecurityPkg/PeiTpmMeasurementLib: Add PEI instance.
  SecurityPkg/dsc: Add PeiTpmMeasurementLib.

 SecurityPkg/Include/Ppi/Tcg.h |  60 ++
 .../PeiTpmMeasurementLib.c|  74 
 .../PeiTpmMeasurementLib.inf  |  50 
 .../PeiTpmMeasurementLib.uni  |  17 +++
 SecurityPkg/SecurityPkg.dec   |   3 +
 SecurityPkg/SecurityPkg.dsc   |   4 +-
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 110 +-
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf   |   3 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.c   |  61 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |   3 +-
 10 files changed, 351 insertions(+), 34 deletions(-)
 create mode 100644 SecurityPkg/Include/Ppi/Tcg.h
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
 create mode 100644 
SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni

-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63076): https://edk2.groups.io/g/devel/message/63076
Mute This Topic: https://groups.io/mt/75720095/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v6 1/6] SecurityPkg/TcgPpi: Add TcgPpi header file.

2020-07-22 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 SecurityPkg/Include/Ppi/Tcg.h | 60 +++
 1 file changed, 60 insertions(+)
 create mode 100644 SecurityPkg/Include/Ppi/Tcg.h

diff --git a/SecurityPkg/Include/Ppi/Tcg.h b/SecurityPkg/Include/Ppi/Tcg.h
new file mode 100644
index 00..0e943f2465
--- /dev/null
+++ b/SecurityPkg/Include/Ppi/Tcg.h
@@ -0,0 +1,60 @@
+/** @file
+  TCG PPI services.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _TCG_PPI_H_
+#define _TCG_PPI_H_
+
+#include 
+
+typedef struct _EDKII_TCG_PPI EDKII_TCG_PPI;
+
+//
+// This bit is shall be set when HashData is the pre-hash digest.
+//
+#define EDKII_TCG_PRE_HASH  0x0001
+
+/**
+  Tpm measure and log data, and extend the measurement result into a specific 
PCR.
+
+  @param[in]  This  Indicates the calling context
+  @param[in]  Flags Bitmap providing additional information
+  @param[in]  HashData  If BIT0 of Flags is 0, it is physical address 
of the
+start of the data buffer to be hashed, 
extended, and logged.
+If BIT0 of Flags is 1, it is physical address 
of the
+start of the pre-hash data buffter to be 
extended, and logged.
+The pre-hash data format is TPML_DIGEST_VALUES.
+  @param[in]  HashDataLen   The length, in bytes, of the buffer referenced 
by HashData.
+  @param[in]  NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.
+  @param[in]  NewEventData  Pointer to the new event data.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_TCG_HASH_LOG_EXTEND_EVENT)(
+  IN  EDKII_TCG_PPI *This,
+  IN  UINT64Flags,
+  IN  UINT8 *HashData,
+  IN  UINTN HashDataLen,
+  IN  TCG_PCR_EVENT_HDR *NewEventHdr,
+  IN  UINT8 *NewEventData
+  );
+
+///
+/// The EFI_TCG Protocol abstracts TCG activity.
+///
+struct _EDKII_TCG_PPI {
+  EDKII_TCG_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+};
+
+extern EFI_GUID gEdkiiTcgPpiGuid;
+
+#endif
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63077): https://edk2.groups.io/g/devel/message/63077
Mute This Topic: https://groups.io/mt/75720096/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



  1   2   >