[edk2] [PATCH] SecurityPkg DxeTcg2PPLib: Lock Tcg2PhysicalPresenceFlags variable on S4

2016-11-17 Thread Star Zeng
The code updates Tcg2PhysicalPresenceLibProcessRequest() to also lock
Tcg2PhysicalPresenceFlags variable on S4.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 .../DxeTcg2PhysicalPresenceLib.c   | 34 +++---
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git 
a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c 
b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c
index 4cec0f75278b..bfecffa0fed8 100644
--- 
a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c
+++ 
b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c
@@ -794,6 +794,23 @@ Tcg2PhysicalPresenceLibProcessRequest (
   if (EFI_ERROR (Status)) {
 return ;
   }
+
+  //
+  // This flags variable controls whether physical presence is required for 
TPM command. 
+  // It should be protected from malicious software. We set it as read-only 
variable here.
+  //
+  Status = gBS->LocateProtocol (, NULL, (VOID 
**));
+  if (!EFI_ERROR (Status)) {
+Status = VariableLockProtocol->RequestToLock (
+ VariableLockProtocol,
+ TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
+ 
+ );
+if (EFI_ERROR (Status)) {
+  DEBUG ((EFI_D_ERROR, "[TPM2] Error when lock variable %s, Status = 
%r\n", TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status));
+  ASSERT_EFI_ERROR (Status);
+}
+  }
   
   //
   // Check S4 resume
@@ -832,23 +849,6 @@ Tcg2PhysicalPresenceLibProcessRequest (
 }
   }
   DEBUG ((EFI_D_INFO, "[TPM2] PpiFlags = %x\n", PpiFlags.PPFlags));
-
-  //
-  // This flags variable controls whether physical presence is required for 
TPM command. 
-  // It should be protected from malicious software. We set it as read-only 
variable here.
-  //
-  Status = gBS->LocateProtocol (, NULL, (VOID 
**));
-  if (!EFI_ERROR (Status)) {
-Status = VariableLockProtocol->RequestToLock (
- VariableLockProtocol,
- TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
- 
- );
-if (EFI_ERROR (Status)) {
-  DEBUG ((EFI_D_ERROR, "[TPM2] Error when lock variable %s, Status = 
%r\n", TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status));
-  ASSERT_EFI_ERROR (Status);
-}
-  }
   
   //
   // Initialize physical presence variable.
-- 
2.7.0.windows.1

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


Re: [edk2] [PATCH V2 0/4] Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Star Zeng
> Sent: Friday, November 18, 2016 1:58 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star 
> Subject: [edk2] [PATCH V2 0/4] Tcg2Dxe: Filter inactive digest in event2 log
> from PEI HOB
> 
> V2:
> Add PATCH 2/4 and 3/4.
>   Add GetHashMaskFromAlgo() into Tpm2CommandLib.
>   Update desc for param Buffer of GetDigestListSize().
> Check if required digests in event2 log are reported and show error if not.
> PATCH 4/4 will consume GetHashMaskFromAlgo() that's why PATCH 2/4
> added.
> 
> Star Zeng (4):
>   SecurityPkg TPM2: Make IsHashAlgSupportedInHashAlgorithmMask
> external
>   SecurityPkg TPM2: Add GetHashMaskFromAlgo() into Tpm2CommandLib
>   SecurityPkg TPM2: Update desc for param Buffer of GetDigestListSize()
>   SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB
> 
>  SecurityPkg/Include/Library/Tpm2CommandLib.h  | 31 -
>  SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 37 --
>  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 98
> +--
>  3 files changed, 155 insertions(+), 11 deletions(-)
> 
> --
> 2.7.0.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/DxeNetLib: Allow the IPv4/prefix case when AsciiStrToIp4

2016-11-17 Thread Jiaxin Wu
This patch is used to allow the IPv4 with prefix case.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c 
b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 04d8345..0804052 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -2722,13 +2722,21 @@ NetLibAsciiStrToIp4 (
 
   for (Index = 0; Index < 4; Index++) {
 TempStr = Ip4Str;
 
 while ((*Ip4Str != '\0') && (*Ip4Str != '.')) {
-  if (!NET_IS_DIGIT (*Ip4Str)) {
+  if (Index != 3 && !NET_IS_DIGIT (*Ip4Str)) {
 return EFI_INVALID_PARAMETER;
   }
+  
+  //
+  // Allow the IPv4 with prefix case, e.g. 192.168.10.10/24 
+  //
+  if (Index == 3 && !NET_IS_DIGIT (*Ip4Str) && *Ip4Str != '/') {
+return EFI_INVALID_PARAMETER;
+  }
+  
   Ip4Str++;
 }
 
 //
 // The IPv4 address is X.X.X.X
-- 
1.9.5.msysgit.1

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


Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable device protocol

2016-11-17 Thread Ard Biesheuvel
On 18 November 2016 at 06:13, Ni, Ruiyu  wrote:
>
>
> Regards,
> Ray
>
>>-Original Message-
>>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ard 
>>Biesheuvel
>>Sent: Friday, November 18, 2016 12:59 PM
>>To: Ni, Ruiyu 
>>Cc: Kinney, Michael D ; edk2-devel@lists.01.org; 
>>Gao, Liming ;
>>af...@apple.com; Leif Lindholm 
>>Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable 
>>device protocol
>>
>>On 18 November 2016 at 02:11, Ni, Ruiyu  wrote:
>>>
>>>
>>> Regards,
>>> Ray
>>>
-Original Message-
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
Sent: Thursday, November 17, 2016 6:43 PM
To: Ni, Ruiyu 
Cc: Kinney, Michael D ; 
edk2-devel@lists.01.org; Gao, Liming ;
af...@apple.com; Leif Lindholm 
Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable 
device protocol


> On 17 Nov 2016, at 08:52, Ni, Ruiyu  wrote:
>
>
>
> Thanks/Ray
>
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>> Ard Biesheuvel
>> Sent: Thursday, November 17, 2016 2:07 PM
>> To: Ni, Ruiyu 
>> Cc: Kinney, Michael D ; edk2-
>> de...@lists.01.org; Gao, Liming ; af...@apple.com;
>> Leif Lindholm 
>> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-
>> discoverable device protocol
>>
>>
>>
>>> On 17 Nov 2016, at 02:53, Ni, Ruiyu  wrote:
>>>
>>> Ard,
>>> I have two comments in below.
>>>
>>> Thanks/Ray
>>>
 -Original Message-
 From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
 Of Leif Lindholm
 Sent: Thursday, November 17, 2016 1:49 AM
 To: Ard Biesheuvel 
 Cc: Ni, Ruiyu ; edk2-devel@lists.01.org;
 af...@apple.com; Gao, Liming ; Kinney, Michael
 D 
 Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-
 discoverable device protocol

> On Wed, Nov 16, 2016 at 04:59:27PM +, Ard Biesheuvel wrote:
> Introduce a protocol that can be exposed by a platform for devices
> that are not discoverable, usually because they are wired straight
> to the memory bus rather than to an enumerable bus like PCI or USB.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
> MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 90
 
> MdeModulePkg/MdeModulePkg.dec |  3 +
> 2 files changed, 93 insertions(+)
>
> diff --git a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
> b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
> new file mode 100644
> index ..47ed841b407b
> --- /dev/null
> +++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
> @@ -0,0 +1,90 @@
> +/** @file
> +  Protocol to describe devices that are not on a discoverable bus
> +
> +  Copyright (c) 2016, Linaro, Ltd. All rights reserved.
> +
> +  This program and the accompanying materials  are licensed and
> + made available under the terms and conditions of the BSD License
> + which accompanies this distribution.  The full text of the license
> + may be found at  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
>> IS"
> + BASIS,  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
 EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __NON_DISCOVERABLE_DEVICE_H__ #define
> +__NON_DISCOVERABLE_DEVICE_H__
> +
> +#include 
> +
> +#define EDKII_NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \
> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc,
> +0x8d, 0x51, 0x4a } }
>>>
>>> 1. Can you add "PCI" keyword into the protocol name?
>>> e.g.: EDKII_NON_DISCOVERABLE_PCI_DEVICE_PROTOCOL_GUID
>>>
>>
>> No. This protocol does not describe pci devices, and it is a peculiarity 
>> of the
>> edk2 driver stack that some non-pci devices can only be driven by pci 
>> drivers.
>>
>> in other words, pci is part of the /driver/ side, 

Re: [edk2] [PATCH V2 0/4] Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Zhang, Chao B
Serial Reviewed-by : Chao Zhang 





Thanks & Best regards
Chao Zhang


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Star Zeng
Sent: Friday, November 18, 2016 1:58 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star
Subject: [edk2] [PATCH V2 0/4] Tcg2Dxe: Filter inactive digest in event2 log 
from PEI HOB

V2:
Add PATCH 2/4 and 3/4.
  Add GetHashMaskFromAlgo() into Tpm2CommandLib.
  Update desc for param Buffer of GetDigestListSize().
Check if required digests in event2 log are reported and show error if not.
PATCH 4/4 will consume GetHashMaskFromAlgo() that's why PATCH 2/4 added.

Star Zeng (4):
  SecurityPkg TPM2: Make IsHashAlgSupportedInHashAlgorithmMask external
  SecurityPkg TPM2: Add GetHashMaskFromAlgo() into Tpm2CommandLib
  SecurityPkg TPM2: Update desc for param Buffer of GetDigestListSize()
  SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 31 -
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 37 --
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 98 +--
 3 files changed, 155 insertions(+), 11 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [PATCH] MdeModulePkg/PiSmmCore: Cache CommunicationBuffer info before using it

2016-11-17 Thread Jeff Fan
gSmmCorePrivate->CommunicationBuffer and gSmmCorePrivate->BufferSize locate at
runtime memory region. That means they could be modified by non-SMM code during
runtime.

We should cache them into SMM local variables before we verify them. After
verification, we should use the cached ones directly instead of the ones in
gSmmCorePrivate.

Cc: Jiewen Yao 
Cc: Feng Tian 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan 
---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c 
b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index b877a33..de8db65 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -432,6 +432,8 @@ SmmEntryPoint (
   EFI_SMM_COMMUNICATE_HEADER  *CommunicateHeader;
   BOOLEAN InLegacyBoot;
   BOOLEAN IsOverlapped;
+  VOID*CommunicationBuffer;
+  UINTN   BufferSize;
 
   PERF_START (NULL, "SMM", NULL, 0) ;
 
@@ -463,17 +465,19 @@ SmmEntryPoint (
 // Check to see if this is a Synchronous SMI sent through the SMM 
Communication 
 // Protocol or an Asynchronous SMI
 //
-if (gSmmCorePrivate->CommunicationBuffer != NULL) {
+CommunicationBuffer = gSmmCorePrivate->CommunicationBuffer;
+BufferSize  = gSmmCorePrivate->BufferSize;
+if (CommunicationBuffer != NULL) {
   //
   // Synchronous SMI for SMM Core or request from Communicate protocol
   //
   IsOverlapped = InternalIsBufferOverlapped (
-   (UINT8 *) gSmmCorePrivate->CommunicationBuffer,
-   gSmmCorePrivate->BufferSize,
+   (UINT8 *) CommunicationBuffer,
+   BufferSize,
(UINT8 *) gSmmCorePrivate,
sizeof (*gSmmCorePrivate)
);
-  if (!SmmIsBufferOutsideSmmValid 
((UINTN)gSmmCorePrivate->CommunicationBuffer, gSmmCorePrivate->BufferSize) || 
IsOverlapped) {
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommunicationBuffer, BufferSize) 
|| IsOverlapped) {
 //
 // If CommunicationBuffer is not in valid address scope,
 // or there is overlap between gSmmCorePrivate and CommunicationBuffer,
@@ -482,19 +486,19 @@ SmmEntryPoint (
 gSmmCorePrivate->CommunicationBuffer = NULL;
 gSmmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER;
   } else {
-CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER 
*)gSmmCorePrivate->CommunicationBuffer;
-gSmmCorePrivate->BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, 
Data);
+CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)CommunicationBuffer;
+BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
 Status = SmiManage (
>HeaderGuid, 
NULL, 
CommunicateHeader->Data, 
-   >BufferSize
+   
);
 //
 // Update CommunicationBuffer, BufferSize and ReturnStatus
 // Communicate service finished, reset the pointer to CommBuffer to 
NULL
 //
-gSmmCorePrivate->BufferSize += OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, 
Data);
+gSmmCorePrivate->BufferSize = BufferSize + OFFSET_OF 
(EFI_SMM_COMMUNICATE_HEADER, Data);
 gSmmCorePrivate->CommunicationBuffer = NULL;
 gSmmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS 
: EFI_NOT_FOUND;
   }
-- 
2.9.3.windows.2

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


[edk2] [PATCH V2 4/4] SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Star Zeng
Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 98 +--
 1 file changed, 94 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c 
b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
index db8d662f80dc..e6f0f9e57088 100644
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
@@ -898,6 +898,60 @@ GetDigestListBinSize (
 }
 
 /**
+  Copy TPML_DIGEST_VALUES compact binary into a buffer
+
+  @param[in,out]Buffer  Buffer to hold copied 
TPML_DIGEST_VALUES compact binary.
+  @param[in]DigestListBin   TPML_DIGEST_VALUES compact binary 
buffer.
+  @param[in]HashAlgorithmMask   HASH bits corresponding to the 
desired digests to copy.
+  @param[out]   HashAlgorithmMaskCopied Pointer to HASH bits corresponding 
to the digests copied.
+
+  @return The end of buffer to hold TPML_DIGEST_VALUES compact binary.
+**/
+VOID *
+CopyDigestListBinToBuffer (
+  IN OUT VOID   *Buffer,
+  IN VOID   *DigestListBin,
+  IN UINT32 HashAlgorithmMask,
+  OUT UINT32*HashAlgorithmMaskCopied
+  )
+{
+  UINTN Index;
+  UINT16DigestSize;
+  UINT32Count;
+  TPMI_ALG_HASH HashAlg;
+  UINT32DigestListCount;
+  UINT32*DigestListCountPtr;
+
+  DigestListCountPtr = (UINT32 *) Buffer;
+  DigestListCount = 0;
+  (*HashAlgorithmMaskCopied) = 0;
+
+  Count = ReadUnaligned32 (DigestListBin);
+  Buffer = (UINT8 *)Buffer + sizeof(Count);
+  DigestListBin = (UINT8 *)DigestListBin + sizeof(Count);
+  for (Index = 0; Index < Count; Index++) {
+HashAlg = ReadUnaligned16 (DigestListBin);
+DigestListBin = (UINT8 *)DigestListBin + sizeof(HashAlg);
+DigestSize = GetHashSizeFromAlgo (HashAlg);
+
+if (IsHashAlgSupportedInHashAlgorithmMask(HashAlg, HashAlgorithmMask)) {
+  CopyMem (Buffer, , sizeof(HashAlg));
+  Buffer = (UINT8 *)Buffer + sizeof(HashAlg);
+  CopyMem (Buffer, DigestListBin, DigestSize);
+  Buffer = (UINT8 *)Buffer + DigestSize;
+  DigestListCount++;
+  (*HashAlgorithmMaskCopied) |= GetHashMaskFromAlgo (HashAlg);
+} else {
+  DEBUG ((DEBUG_ERROR, "WARNING: CopyDigestListBinToBuffer Event log has 
HashAlg unsupported by PCR bank (0x%x)\n", HashAlg));
+}
+DigestListBin = (UINT8 *)DigestListBin + DigestSize;
+  }
+  WriteUnaligned32 (DigestListCountPtr, DigestListCount);
+
+  return Buffer;
+}
+
+/**
   Add a new entry to the Event Log.
 
   @param[in] DigestListA list of digest.
@@ -1317,8 +1371,13 @@ SetupEventLog (
   EFI_PEI_HOB_POINTERSGuidHob;
   EFI_PHYSICAL_ADDRESSLasa;
   UINTN   Index;
+  VOID*DigestListBin;
+  TPML_DIGEST_VALUES  TempDigestListBin;
   UINT32  DigestListBinSize;
+  UINT8   *Event;
   UINT32  EventSize;
+  UINT32  *EventSizePtr;
+  UINT32  HashAlgorithmMaskCopied;
   TCG_EfiSpecIDEventStruct*TcgEfiSpecIdEventStruct;
   UINT8   TempBuf[sizeof(TCG_EfiSpecIDEventStruct) + 
sizeof(UINT32) + (HASH_COUNT * sizeof(TCG_EfiSpecIdEventAlgorithmSize)) + 
sizeof(UINT8)];
   TCG_PCR_EVENT_HDR   FirstPcrEvent;
@@ -1497,7 +1556,8 @@ SetupEventLog (
   Status = EFI_SUCCESS;
   while (!EFI_ERROR (Status) && 
  (GuidHob.Raw = GetNextGuidHob (mTcg2EventInfo[Index].EventGuid, 
GuidHob.Raw)) != NULL) {
-TcgEvent= GET_GUID_HOB_DATA (GuidHob.Guid);
+TcgEvent= AllocateCopyPool (GET_GUID_HOB_DATA_SIZE (GuidHob.Guid), 
GET_GUID_HOB_DATA (GuidHob.Guid));
+ASSERT (TcgEvent != NULL);
 GuidHob.Raw = GET_NEXT_HOB (GuidHob);
 switch (mTcg2EventInfo[Index].LogFormat) {
 case EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2:
@@ -1510,17 +1570,47 @@ SetupEventLog (
  );
   break;
 case EFI_TCG2_EVENT_LOG_FORMAT_TCG_2:
-  DigestListBinSize = GetDigestListBinSize ((UINT8 *)TcgEvent + 
sizeof(TCG_PCRINDEX) + sizeof(TCG_EVENTTYPE));
-  CopyMem (, (UINT8 *)TcgEvent + sizeof(TCG_PCRINDEX) + 
sizeof(TCG_EVENTTYPE) + DigestListBinSize, sizeof(UINT32));
+  DigestListBin = (UINT8 *)TcgEvent + sizeof(TCG_PCRINDEX) + 
sizeof(TCG_EVENTTYPE);
+  DigestListBinSize = GetDigestListBinSize (DigestListBin);
+  //
+  // Save event size.
+  //
+  CopyMem (, (UINT8 *)DigestListBin + DigestListBinSize, 
sizeof(UINT32));
+  Event = (UINT8 *)DigestListBin + DigestListBinSize + sizeof(UINT32);
+  //
+  // Filter inactive digest in the event2 log from PEI HOB.
+  //
+ 

[edk2] [PATCH V2 1/4] SecurityPkg TPM2: Make IsHashAlgSupportedInHashAlgorithmMask external

2016-11-17 Thread Star Zeng
Current IsHashAlgSupportedInHashAlgorithmMask is only an internal
function, this patch makes it external for coming consumer.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
Reviewed-by: Jiewen Yao 
---
 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 16 
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c |  1 +
 2 files changed, 17 insertions(+)

diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h 
b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index 9a1dd8d8aceb..85a4c65e0263 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -1007,6 +1007,22 @@ GetHashSizeFromAlgo (
   );
 
 /**
+  Return if hash alg is supported in HashAlgorithmMask.
+
+  @param HashAlgHash algorithm to be checked.
+  @param HashAlgorithmMask  Bitfield of allowed hash algorithms.
+
+  @retval TRUE  Hash algorithm is supported.
+  @retval FALSE Hash algorithm is not supported.
+**/
+BOOLEAN
+EFIAPI
+IsHashAlgSupportedInHashAlgorithmMask(
+  IN TPMI_ALG_HASH  HashAlg,
+  IN UINT32 HashAlgorithmMask
+  );
+
+/**
   Copy TPML_DIGEST_VALUES into a buffer
 
   @param[in,out] Buffer Buffer to hold TPML_DIGEST_VALUES.
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index be95fd69b3dd..95d4f7c84ce9 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -175,6 +175,7 @@ CopyAuthSessionResponse (
   @retval FALSE Hash algorithm is not supported.
 **/
 BOOLEAN
+EFIAPI
 IsHashAlgSupportedInHashAlgorithmMask(
   IN TPMI_ALG_HASH  HashAlg,
   IN UINT32 HashAlgorithmMask
-- 
2.7.0.windows.1

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


[edk2] [PATCH V2 2/4] SecurityPkg TPM2: Add GetHashMaskFromAlgo() into Tpm2CommandLib

2016-11-17 Thread Star Zeng
Add GetHashMaskFromAlgo() into Tpm2CommandLib for coming consumer.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 13 ++
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 34 +++
 2 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h 
b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index 85a4c65e0263..699270f127a1 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -1007,6 +1007,19 @@ GetHashSizeFromAlgo (
   );
 
 /**
+  Get hash mask from algorithm.
+
+  @param[in] HashAlgo   Hash algorithm
+
+  @return Hash mask
+**/
+UINT32
+EFIAPI
+GetHashMaskFromAlgo (
+  IN TPMI_ALG_HASH HashAlgo
+  );
+
+/**
   Return if hash alg is supported in HashAlgorithmMask.
 
   @param HashAlgHash algorithm to be checked.
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 95d4f7c84ce9..9aa77af97af1 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -22,14 +22,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 typedef struct {
   TPMI_ALG_HASH  HashAlgo;
   UINT16 HashSize;
+  UINT32 HashMask;
 } INTERNAL_HASH_INFO;
 
 STATIC INTERNAL_HASH_INFO mHashInfo[] = {
-  {TPM_ALG_SHA1,  SHA1_DIGEST_SIZE},
-  {TPM_ALG_SHA256,SHA256_DIGEST_SIZE},
-  {TPM_ALG_SM3_256,   SM3_256_DIGEST_SIZE},
-  {TPM_ALG_SHA384,SHA384_DIGEST_SIZE},
-  {TPM_ALG_SHA512,SHA512_DIGEST_SIZE},
+  {TPM_ALG_SHA1,  SHA1_DIGEST_SIZE, HASH_ALG_SHA1},
+  {TPM_ALG_SHA256,SHA256_DIGEST_SIZE,   HASH_ALG_SHA256},
+  {TPM_ALG_SM3_256,   SM3_256_DIGEST_SIZE,  HASH_ALG_SM3_256},
+  {TPM_ALG_SHA384,SHA384_DIGEST_SIZE,   HASH_ALG_SHA384},
+  {TPM_ALG_SHA512,SHA512_DIGEST_SIZE,   HASH_ALG_SHA512},
 };
 
 /**
@@ -56,6 +57,29 @@ GetHashSizeFromAlgo (
 }
 
 /**
+  Get hash mask from algorithm.
+
+  @param[in] HashAlgo   Hash algorithm
+
+  @return Hash mask
+**/
+UINT32
+EFIAPI
+GetHashMaskFromAlgo (
+  IN TPMI_ALG_HASH HashAlgo
+  )
+{
+  UINTN  Index;
+
+  for (Index = 0; Index < sizeof(mHashInfo)/sizeof(mHashInfo[0]); Index++) {
+if (mHashInfo[Index].HashAlgo == HashAlgo) {
+  return mHashInfo[Index].HashMask;
+}
+  }
+  return 0;
+}
+
+/**
   Copy AuthSessionIn to TPM2 command buffer.
 
   @param [in]  AuthSessionIn   Input AuthSession data
-- 
2.7.0.windows.1

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


[edk2] [PATCH V2 0/4] Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Star Zeng
V2:
Add PATCH 2/4 and 3/4.
  Add GetHashMaskFromAlgo() into Tpm2CommandLib.
  Update desc for param Buffer of GetDigestListSize().
Check if required digests in event2 log are reported and show error if not.
PATCH 4/4 will consume GetHashMaskFromAlgo() that's why PATCH 2/4 added.

Star Zeng (4):
  SecurityPkg TPM2: Make IsHashAlgSupportedInHashAlgorithmMask external
  SecurityPkg TPM2: Add GetHashMaskFromAlgo() into Tpm2CommandLib
  SecurityPkg TPM2: Update desc for param Buffer of GetDigestListSize()
  SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 31 -
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 37 --
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 98 +--
 3 files changed, 155 insertions(+), 11 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [PATCH V2 3/4] SecurityPkg TPM2: Update desc for param Buffer of GetDigestListSize()

2016-11-17 Thread Star Zeng
To make the description more clear, update the description
for parameter Buffer of GetDigestListSize() to
"Buffer to hold copied TPML_DIGEST_VALUES compact binary.".

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 2 +-
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h 
b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index 699270f127a1..f7a04f20929a 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -1038,7 +1038,7 @@ IsHashAlgSupportedInHashAlgorithmMask(
 /**
   Copy TPML_DIGEST_VALUES into a buffer
 
-  @param[in,out] Buffer Buffer to hold TPML_DIGEST_VALUES.
+  @param[in,out] Buffer Buffer to hold copied TPML_DIGEST_VALUES 
compact binary.
   @param[in] DigestList TPML_DIGEST_VALUES to be copied.
   @param[in] HashAlgorithmMask  HASH bits corresponding to the desired 
digests to copy.
 
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 9aa77af97af1..64d3c531ff92 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -239,7 +239,7 @@ IsHashAlgSupportedInHashAlgorithmMask(
 /**
   Copy TPML_DIGEST_VALUES into a buffer
 
-  @param[in,out] Buffer Buffer to hold TPML_DIGEST_VALUES.
+  @param[in,out] Buffer Buffer to hold copied TPML_DIGEST_VALUES 
compact binary.
   @param[in] DigestList TPML_DIGEST_VALUES to be copied.
   @param[in] HashAlgorithmMask  HASH bits corresponding to the desired 
digests to copy.
 
-- 
2.7.0.windows.1

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


Re: [edk2] [PATCH] SecurityPkg Tcg2Pei: Add comments into LogHashEvent()

2016-11-17 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Zeng, Star
> Sent: Friday, November 18, 2016 1:43 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Yao, Jiewen ;
> Zhang, Chao B 
> Subject: [PATCH] SecurityPkg Tcg2Pei: Add comments into LogHashEvent()
> 
> Add comments into LogHashEvent() to describe the usage
> of GetDigestListSize (DigestList).
> 
> Cc: Jiewen Yao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> index 377f8d9fe45b..209d843245e4 100644
> --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> @@ -317,6 +317,10 @@ LogHashEvent (
>  }
>  break;
>case EFI_TCG2_EVENT_LOG_FORMAT_TCG_2:
> +//
> +// Use GetDigestListSize (DigestList) in the GUID HOB DataLength
> calculation
> +// to reserve enough buffer to hold TPML_DIGEST_VALUES
> compact binary.
> +//
>  HobData = BuildGuidHob (
> ,
> sizeof(TcgPcrEvent2->PCRIndex) +
> sizeof(TcgPcrEvent2->EventType) + GetDigestListSize (DigestList) +
> sizeof(TcgPcrEvent2->EventSize) + NewEventHdr->EventSize
> --
> 2.7.0.windows.1

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


[edk2] [PATCH] SecurityPkg Tcg2Pei: Add comments into LogHashEvent()

2016-11-17 Thread Star Zeng
Add comments into LogHashEvent() to describe the usage
of GetDigestListSize (DigestList).

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 377f8d9fe45b..209d843245e4 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -317,6 +317,10 @@ LogHashEvent (
 }
 break;
   case EFI_TCG2_EVENT_LOG_FORMAT_TCG_2:
+//
+// Use GetDigestListSize (DigestList) in the GUID HOB DataLength 
calculation
+// to reserve enough buffer to hold TPML_DIGEST_VALUES compact binary.
+//
 HobData = BuildGuidHob (
,
sizeof(TcgPcrEvent2->PCRIndex) + 
sizeof(TcgPcrEvent2->EventType) + GetDigestListSize (DigestList) + 
sizeof(TcgPcrEvent2->EventSize) + NewEventHdr->EventSize
-- 
2.7.0.windows.1

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


Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable device protocol

2016-11-17 Thread Tian, Feng
Ard,

I have another question.

Is it the only way to specify device type in below enum? Looks like it will be 
changed often. Is it possible to make use of DevicePath node? Of course, I have 
no good idea to handle AMBA controller...

+//
+// Data Types
+//
+typedef enum {
+  NonDiscoverableDeviceTypeAmba,
+  NonDiscoverableDeviceTypeOhci,
+  NonDiscoverableDeviceTypeUhci,
+  NonDiscoverableDeviceTypeEhci,
+  NonDiscoverableDeviceTypeXhci,
+  NonDiscoverableDeviceTypeAhci,
+  NonDiscoverableDeviceTypeSdhci,
+  NonDiscoverableDeviceTypeUfs,
+  NonDiscoverableDeviceTypeNvme,
+  NonDiscoverableDeviceTypeMax,
+} NON_DISCOVERABLE_DEVICE_TYPE;

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ard 
Biesheuvel
Sent: Friday, November 18, 2016 12:59 PM
To: Ni, Ruiyu 
Cc: Kinney, Michael D ; edk2-devel@lists.01.org; 
Gao, Liming ; af...@apple.com; Leif Lindholm 

Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable 
device protocol

On 18 November 2016 at 02:11, Ni, Ruiyu  wrote:
>
>
> Regards,
> Ray
>
>>-Original Message-
>>From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>>Sent: Thursday, November 17, 2016 6:43 PM
>>To: Ni, Ruiyu 
>>Cc: Kinney, Michael D ; 
>>edk2-devel@lists.01.org; Gao, Liming ; 
>>af...@apple.com; Leif Lindholm 
>>Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce 
>>non-discoverable device protocol
>>
>>
>>> On 17 Nov 2016, at 08:52, Ni, Ruiyu  wrote:
>>>
>>>
>>>
>>> Thanks/Ray
>>>
 -Original Message-
 From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf 
 Of Ard Biesheuvel
 Sent: Thursday, November 17, 2016 2:07 PM
 To: Ni, Ruiyu 
 Cc: Kinney, Michael D ; edk2- 
 de...@lists.01.org; Gao, Liming ; 
 af...@apple.com; Leif Lindholm 
 Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non- 
 discoverable device protocol



> On 17 Nov 2016, at 02:53, Ni, Ruiyu  wrote:
>
> Ard,
> I have two comments in below.
>
> Thanks/Ray
>
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On 
>> Behalf Of Leif Lindholm
>> Sent: Thursday, November 17, 2016 1:49 AM
>> To: Ard Biesheuvel 
>> Cc: Ni, Ruiyu ; edk2-devel@lists.01.org; 
>> af...@apple.com; Gao, Liming ; Kinney, 
>> Michael D 
>> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non- 
>> discoverable device protocol
>>
>>> On Wed, Nov 16, 2016 at 04:59:27PM +, Ard Biesheuvel wrote:
>>> Introduce a protocol that can be exposed by a platform for 
>>> devices that are not discoverable, usually because they are 
>>> wired straight to the memory bus rather than to an enumerable bus like 
>>> PCI or USB.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Ard Biesheuvel 
>>> ---
>>> MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 90
>> 
>>> MdeModulePkg/MdeModulePkg.dec |  3 +
>>> 2 files changed, 93 insertions(+)
>>>
>>> diff --git 
>>> a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> new file mode 100644
>>> index ..47ed841b407b
>>> --- /dev/null
>>> +++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> @@ -0,0 +1,90 @@
>>> +/** @file
>>> +  Protocol to describe devices that are not on a discoverable 
>>> +bus
>>> +
>>> +  Copyright (c) 2016, Linaro, Ltd. All rights reserved.
>>> +
>>> +  This program and the accompanying materials  are licensed and 
>>> + made available under the terms and conditions of the BSD 
>>> + License which accompanies this distribution.  The full text of 
>>> + the license may be found at  
>>> + http://opensource.org/licenses/bsd-license.php
>>> +
>>> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
 IS"
>>> + BASIS,  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
>> EITHER EXPRESS OR IMPLIED.
>>> +
>>> +**/
>>> +
>>> +#ifndef __NON_DISCOVERABLE_DEVICE_H__ #define 
>>> +__NON_DISCOVERABLE_DEVICE_H__
>>> +
>>> +#include 
>>> +
>>> +#define EDKII_NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \
>>> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 
>>> +0x8d, 0x51, 0x4a 

[edk2] [PATCH v2] MdePkg IndustryStandard: Add DDR3, DDR4 and LPDDR definition per SPD spec

2016-11-17 Thread Liming Gao
https://bugzilla.tianocore.org/show_bug.cgi?id=201

In V2, separate DDR3, DDR4 and LPDDR definition into the different files;
use the different SPD prefix as structure definitions for each SPD type.

Cc: Giri P Mudusuru 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao 
---
 MdePkg/Include/IndustryStandard/SdramSpd.h  |  31 +-
 MdePkg/Include/IndustryStandard/SdramSpdDdr3.h  | 769 +++
 MdePkg/Include/IndustryStandard/SdramSpdDdr4.h  | 964 
 MdePkg/Include/IndustryStandard/SdramSpdLpDdr.h | 474 
 4 files changed, 2227 insertions(+), 11 deletions(-)
 create mode 100644 MdePkg/Include/IndustryStandard/SdramSpdDdr3.h
 create mode 100644 MdePkg/Include/IndustryStandard/SdramSpdDdr4.h
 create mode 100644 MdePkg/Include/IndustryStandard/SdramSpdLpDdr.h

diff --git a/MdePkg/Include/IndustryStandard/SdramSpd.h 
b/MdePkg/Include/IndustryStandard/SdramSpd.h
index 2b2012b..8296f19 100644
--- a/MdePkg/Include/IndustryStandard/SdramSpd.h
+++ b/MdePkg/Include/IndustryStandard/SdramSpd.h
@@ -1,19 +1,23 @@
 /** @file
   This file contains definitions for the SPD fields on an SDRAM.
-
-  Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
-  This program and the accompanying materials  
-  are licensed and made available under the terms and conditions of the BSD 
License 
-  which accompanies this distribution.  The full text of the license may be 
found at
-  http://opensource.org/licenses/bsd-license.php   
 
 
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED. 
+  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/
 
 #ifndef _SDRAM_SPD_H_
 #define _SDRAM_SPD_H_
 
+#include 
+#include 
+#include 
+
 //
 // SDRAM SPD field definitions
 //
@@ -47,9 +51,14 @@
 //
 // Memory Type Definitions
 //
-#define SPD_VAL_SDR_TYPE  4 ///< SDR SDRAM memory
-#define SPD_VAL_DDR_TYPE  7 ///< DDR SDRAM memory
-#define SPD_VAL_DDR2_TYPE 8 ///< DDR2 SDRAM memory
+#define SPD_VAL_SDR_TYPE  4  ///< SDR SDRAM memory
+#define SPD_VAL_DDR_TYPE  7  ///< DDR SDRAM memory
+#define SPD_VAL_DDR2_TYPE 8  ///< DDR2 SDRAM memory
+#define SPD_VAL_DDR3_TYPE 11 ///< DDR3 SDRAM memory
+#define SPD_VAL_DDR4_TYPE 12 ///< DDR4 SDRAM memory
+#define SPD_VAL_LPDDR3_TYPE 15 ///< LPDDR3 SDRAM memory
+#define SPD_VAL_LPDDR4_TYPE 16 ///< LPDDR4 SDRAM memory
+
 //
 // ECC Type Definitions
 //
diff --git a/MdePkg/Include/IndustryStandard/SdramSpdDdr3.h 
b/MdePkg/Include/IndustryStandard/SdramSpdDdr3.h
new file mode 100644
index 000..ffeab7a
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/SdramSpdDdr3.h
@@ -0,0 +1,769 @@
+/** @file
+  This file contains definitions for SPD DDR3.
+
+  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+- Serial Presence Detect (SPD) for DDR3 SDRAM Modules Document Release 6
+  http://www.jedec.org/sites/default/files/docs/4_01_02_11R21A.pdf
+**/
+
+#ifndef _SDRAM_SPD_DDR3_H_
+#define _SDRAM_SPD_DDR3_H_
+
+#pragma pack (push, 1)
+
+typedef union {
+  struct {
+UINT8  BytesUsed   :  4; ///< Bits 3:0
+UINT8  BytesTotal  :  3; ///< Bits 6:4
+UINT8  CrcCoverage :  1; ///< Bits 7:7
+  } Bits;
+  UINT8  Data;
+} SPD3_DEVICE_DESCRIPTION_STRUCT;
+
+typedef union {
+  struct {
+UINT8  Minor   :  4; ///< Bits 3:0
+UINT8  Major   :  4; ///< Bits 7:4
+  } Bits;
+  UINT8  Data;
+} SPD3_REVISION_STRUCT;
+
+typedef union {
+  struct {
+UINT8  Type:  8; ///< Bits 7:0
+  } Bits;
+  UINT8  Data;
+} SPD3_DRAM_DEVICE_TYPE_STRUCT;
+
+typedef union {
+  struct {
+UINT8  ModuleType  :  4; ///< Bits 3:0
+UINT8  Reserved:  4; ///< Bits 7:4
+  } 

Re: [edk2] [PATCH] BaseTools: Skip module AutoGen by comparing timestamp.

2016-11-17 Thread Zhu, Yonghong
Thanks for your contribution. I will review it and do some verification. May 
give comment later.

Best Regards,
Zhu Yonghong

-Original Message-
From: Derek Lin [mailto:derek.l...@hpe.com] 
Sent: Friday, November 18, 2016 10:30 AM
To: edk2-devel@lists.01.org
Cc: derek.l...@hpe.com; Zhu, Yonghong ; Gao, Liming 

Subject: [PATCH] BaseTools: Skip module AutoGen by comparing timestamp.

[Introduction]

The BaseTool Build.py AutoGen parse INF meta-file and generate 
AutoGen.c/AutoGen.h/makefile. When we only change .c .h code, the AutoGen might 
be not necessary, but Build.py spend a lot of time on it.
There's a -u flag to skip all module's AutoGen. In my environment, it save 
35%~50% of time in rebuild a ROM.
However, if user change one .INF meta-file, then -u flag is not available.

[Idea]

AutoGen can compare meta-file's timestamp and decide if the module's AutoGen 
can be skipped. With this, when a module's INF is changed, we only run this 
module's AutoGen, we don't need to run other module's.

[Implementation]

In the end of a module's AutoGen, we create a AutoGenTimeStamp.
The file save a file list that related to this module's AutoGen.
In other word, the file list in AutoGenTimeStamp is INPUT files of module 
AutoGen, AutoGenTimeStamp file is OUTPUT.
During rebuild, we compare time stamp between INPUT and OUTPUT, and decide if 
we can skip it.

Below is the Input/Output of a module's AutoGen.

[Input]
  1. All the DSC/DEC/FDF used by the platform.
  2. INF file of a module.
  3. Source files of a module, list in [Sources] section of INF.
  4. All the library link by the module.
  5. All the .h files included by the module's sources.
[Output]
  AutoGen.c/AutoGen.h/makefile/AutoGenTimeStamp

[Testing]

This patch save my build time. When I make a change without touching 
DSC/DEC/FDF, it is absolutely much faster than original rebuild, 35%~50% time 
saving in my environment (compare to original tool rebuild time).
If I change any DSC/DEC/FDF, there's no performance improve, because it can't 
skip any module's AutoGen.

Please note that if your environment will generate DSC/FDF during prebuild, it 
will not skip any AutoGen because of DSC timestamp is changed. This will 
require prebuild script not to update meta file when content is not changed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Derek Lin 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 110 +
 BaseTools/Source/Python/AutoGen/GenMake.py |   3 +
 BaseTools/Source/Python/GenFds/FdfParser.py|   4 +
 .../Source/Python/Workspace/MetaFileParser.py  |   4 +
 4 files changed, 121 insertions(+)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index f35ae25..daa5b35 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -42,6 +42,7 @@ from GenPcdDb import CreatePcdDatabaseCode  from 
Workspace.MetaFileCommentParser import UsageList  from Common.MultipleWorkspace 
import MultipleWorkspace as mws  import InfSectionParser
+import datetime
 
 ## Regular expression for splitting Dependency Expression string into tokens  
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)") @@ -640,6 +641,31 @@ 
class WorkspaceAutoGen(AutoGen):
 self._MakeFileDir = None
 self._BuildCommand = None
 
+#
+# Create list of metafiles of the workspace
+#
+AllWorkSpaceMetaFiles = self._CreateMetaFileList()
+  
+#
+# Retrieve latest modified time of all metafiles
+#
+SrcTimeStamp = 0
+for f in AllWorkSpaceMetaFiles:
+if os.stat(f)[8] > SrcTimeStamp:
+SrcTimeStamp = os.stat(f)[8]
+self._SrcTimeStamp = SrcTimeStamp
+
+#
+# Write metafile list to build directory
+#
+AutoGenFilePath = os.path.join(self.BuildDir, 'AutoGen')
+if os.path.exists (AutoGenFilePath):
+os.remove(AutoGenFilePath)
+if not os.path.exists(self.BuildDir):
+os.makedirs(self.BuildDir)
+with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file:
+for f in AllWorkSpaceMetaFiles:
+print >> file, f
 return True
 
 def _BuildOptionPcdValueFormat(self, TokenSpaceGuidCName, TokenCName, 
PcdDatumType, Value):
@@ -668,6 +694,29 @@ class WorkspaceAutoGen(AutoGen):
 Value = '0'
 return  Value
 
+def _CreateMetaFileList(self):
+AllWorkSpaceMetaFiles = []
+#
+# add fdf
+#
+AllWorkSpaceMetaFiles.append (self.FdfFile.Path)
+if self.FdfFile:
+FdfFiles = GlobalData.gFdfParser.GetAllIncludedFile()
+for f in FdfFiles:
+AllWorkSpaceMetaFiles.append (f.FileName)   
+#
+# add dsc & dec
+ 

Re: [edk2] EDK2 master build failure

2016-11-17 Thread Gao, Liming
In Misc.py, it import string class. But, in the same directory, there is source 
file String.py. Seemly, python interpreter wrongly imports String.py and cause 
this issue. This issue may happen on the case insensitive file system. 

We meet with such issue before. We set up virtual machine on windows OS to run 
Linux build, edk2 source code is downloaded in windows OS and shared to virtual 
linux machine, then do linux build will cause such issue. To avoid it, we 
download edk2 source code in Linux machine and build them pass. 

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Bhupesh Sharma
> Sent: Friday, November 18, 2016 4:12 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] EDK2 master build failure
> 
> Hi EDK2 experts,
> 
> I have just rebased my code on the latest EDK2 master branch and now when
> I am trying to compile the same
> I am getting the following errors (for my ARMv8 build):
> 
> # ./build.sh RELEASE clean; ./build.sh RELEASE
> ..
> Welcome to LS1043A UEFI Build environment
> ..
> Cleaning up the build directory '../../../../Build/LS1043aRdb/'..
> ..
> Welcome to LS1043A UEFI Build environment
> ..
> Initializing workspace
> Loading previous configuration from /media/sf_VBox-
> Share/LS1043A/edk2/Conf/BuildEnv.sh
> WORKSPACE: /media/sf_VBox-Share/LS1043A/edk2
> EDK_TOOLS_PATH: /media/sf_VBox-Share/LS1043A/edk2/BaseTools
> CONF_PATH: /media/sf_VBox-Share/LS1043A/edk2/Conf
> Copying $EDK_TOOLS_PATH/Conf/tools_def.template
>  to /media/sf_VBox-Share/LS1043A/edk2/Conf/tools_def.txt
> Build environment: Linux-4.2.0-27-generic-x86_64-with-Ubuntu-14.04-trusty
> Build start time: 01:19:30, Nov.18 2016
> 
> WORKSPACE= /media/sf_VBox-Share/LS1043A/edk2
> ECP_SOURCE   = /media/sf_VBox-
> Share/LS1043A/edk2/EdkCompatibilityPkg
> EDK_SOURCE   = /media/sf_VBox-
> Share/LS1043A/edk2/EdkCompatibilityPkg
> EFI_SOURCE   = /media/sf_VBox-
> Share/LS1043A/edk2/EdkCompatibilityPkg
> EDK_TOOLS_PATH   = /media/sf_VBox-Share/LS1043A/edk2/BaseTools
> CONF_PATH= /media/sf_VBox-Share/LS1043A/edk2/Conf
> 
> 
> Architecture(s)  = AARCH64
> Build target = RELEASE
> Toolchain= GCC49
> 
> Active Platform  = /media/sf_VBox-
> Share/LS1043A/edk2/OpenPlatformPkg/Platforms/Nxp/LS1043aRdb/LS1043a
> RdbPkg.dsc
> Flash Image Definition   = /media/sf_VBox-
> Share/LS1043A/edk2/OpenPlatformPkg/Platforms/Nxp/LS1043aRdb/LS1043a
> RdbPkg.fdf
> 
> Processing meta-data ...
> 
> 
> build.py...
>  : error C0DE: Unknown fatal error when processing [/media/sf_VBox-
> Share/LS1043A/edk2/MdePkg/MdePkg.dec]
> 
> (Please send email to edk2-devel@lists.01.org for help, attaching following
> call stack trace!)
> 
> (Python 2.7.6 on linux2) Traceback (most recent call last):
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python
> /build/build.py", line 2276, in Main
> MyBuild.Launch()
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python
> /build/build.py", line 2028, in Launch
> self._MultiThreadBuildPlatform()
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python
> /build/build.py", line 1823, in _MultiThreadBuildPlatform
> self.Progress
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py", line
> 176, in __new__
> if not AutoGenObject._Init(Workspace, MetaFile, Target, Toolchain, Arch,
> *args, **kwargs):
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py", line
> 464, in _Init
> for key in BuildData.Pcds:
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/WorkspaceData
> base.py", line 2469, in _GetPcds
> self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/WorkspaceData
> base.py", line 2583, in _GetPcd
> if TokenSpaceGuid not in self.Guids:
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/WorkspaceData
> base.py", line 2368, in _GetGuids
> Value = GuidValue(CName, self.Packages, self.MetaFile.Path)
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/Common/Misc.py", line 804,
> in GuidValue
> GuidKeys = P.Guids.keys()
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/WorkspaceData
> base.py", line 1482, in _GetGuid
> RecordList = self._RawData[MODEL_EFI_GUID, self._Arch]
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/MetaFileParser.
> py", line 239, in __getitem__
> self.Start()
>   File "/media/sf_VBox-
> Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/MetaFileParser.
> 

Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable device protocol

2016-11-17 Thread Ard Biesheuvel
On 18 November 2016 at 02:11, Ni, Ruiyu  wrote:
>
>
> Regards,
> Ray
>
>>-Original Message-
>>From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>>Sent: Thursday, November 17, 2016 6:43 PM
>>To: Ni, Ruiyu 
>>Cc: Kinney, Michael D ; edk2-devel@lists.01.org; 
>>Gao, Liming ;
>>af...@apple.com; Leif Lindholm 
>>Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable 
>>device protocol
>>
>>
>>> On 17 Nov 2016, at 08:52, Ni, Ruiyu  wrote:
>>>
>>>
>>>
>>> Thanks/Ray
>>>
 -Original Message-
 From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
 Ard Biesheuvel
 Sent: Thursday, November 17, 2016 2:07 PM
 To: Ni, Ruiyu 
 Cc: Kinney, Michael D ; edk2-
 de...@lists.01.org; Gao, Liming ; af...@apple.com;
 Leif Lindholm 
 Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-
 discoverable device protocol



> On 17 Nov 2016, at 02:53, Ni, Ruiyu  wrote:
>
> Ard,
> I have two comments in below.
>
> Thanks/Ray
>
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
>> Of Leif Lindholm
>> Sent: Thursday, November 17, 2016 1:49 AM
>> To: Ard Biesheuvel 
>> Cc: Ni, Ruiyu ; edk2-devel@lists.01.org;
>> af...@apple.com; Gao, Liming ; Kinney, Michael
>> D 
>> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-
>> discoverable device protocol
>>
>>> On Wed, Nov 16, 2016 at 04:59:27PM +, Ard Biesheuvel wrote:
>>> Introduce a protocol that can be exposed by a platform for devices
>>> that are not discoverable, usually because they are wired straight
>>> to the memory bus rather than to an enumerable bus like PCI or USB.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Ard Biesheuvel 
>>> ---
>>> MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 90
>> 
>>> MdeModulePkg/MdeModulePkg.dec |  3 +
>>> 2 files changed, 93 insertions(+)
>>>
>>> diff --git a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> new file mode 100644
>>> index ..47ed841b407b
>>> --- /dev/null
>>> +++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>>> @@ -0,0 +1,90 @@
>>> +/** @file
>>> +  Protocol to describe devices that are not on a discoverable bus
>>> +
>>> +  Copyright (c) 2016, Linaro, Ltd. All rights reserved.
>>> +
>>> +  This program and the accompanying materials  are licensed and
>>> + made available under the terms and conditions of the BSD License
>>> + which accompanies this distribution.  The full text of the license
>>> + may be found at  http://opensource.org/licenses/bsd-license.php
>>> +
>>> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
 IS"
>>> + BASIS,  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
>> EITHER EXPRESS OR IMPLIED.
>>> +
>>> +**/
>>> +
>>> +#ifndef __NON_DISCOVERABLE_DEVICE_H__ #define
>>> +__NON_DISCOVERABLE_DEVICE_H__
>>> +
>>> +#include 
>>> +
>>> +#define EDKII_NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \
>>> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc,
>>> +0x8d, 0x51, 0x4a } }
>
> 1. Can you add "PCI" keyword into the protocol name?
> e.g.: EDKII_NON_DISCOVERABLE_PCI_DEVICE_PROTOCOL_GUID
>

 No. This protocol does not describe pci devices, and it is a peculiarity 
 of the
 edk2 driver stack that some non-pci devices can only be driven by pci 
 drivers.

 in other words, pci is part of the /driver/ side, and it is perfectly 
 possible for,
 e.g., a non-discoverable ahci device to be driven by a different non-pci 
 driver
 in the future.

>>>
>>> I see. So some types of devices are handled by the current
>>> NonDiscoveablePciDevice driver, and some other types of devices may be
>>> handled by a future NonDiscoverableXXXDevice driver.
>>> Now since the AHCI type is already handled by the NonDiscoverablePciDevice
>>> driver, when there is a new NonDiscoverableXXXDevice driver, how can the two
>>> know whether it should manage the AHCI type device or not?
>>
>>Good question. But how does the UEFI driver model deal with that? What 
>>happens if i have two drivers that both support the
>>Ahci Pci class codes?
> PCI CFG header contains VendorID/DeviceID fields which 

Re: [edk2] [Patch] OvmfPkg AcpiTables: Use PcdDebugIoPort to describe QEMU debug console

2016-11-17 Thread Gao, Liming
Lin:
   Please run . edksetup.sh --reconfig to reset your local configure files. 

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Gary Lin
> Sent: Friday, November 18, 2016 11:43 AM
> To: Gao, Liming ; Laszlo Ersek 
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] [Patch] OvmfPkg AcpiTables: Use PcdDebugIoPort to
> describe QEMU debug console
> 
> On Wed, Nov 16, 2016 at 10:10:07AM +0800, Liming Gao wrote:
> > Cc: Laszlo Ersek 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Liming Gao 
> 
> Hi Liming and Laszlo,
> 
> I failed to compile OVMF after applying this patch:
> 
> "iasl"  -
> p/home/gary/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/OvmfPkg/AcpiTa
> bles/AcpiTables/OUTPUT/./Dsdt.aml
> /home/gary/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/OvmfPkg/AcpiTabl
> es/AcpiTables/OUTPUT/./Dsdt.
> Compiler aborting due to parser-detected syntax error(s)
> /home/gary/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/OvmfPkg/AcpiTabl
> es/AcpiTables/OUTPUT/./Dsdt.375: IO (Decode16, 
> FixedPcdGet16
> (PcdDebugIoPort), FixedPcdGet16 (PcdDebugIoPort), 0x00, 0x01)
> Error6126 -   
>syntax error,
> unexpected PARSEOP_NAMESEG ^
> 
> /home/gary/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/OvmfPkg/AcpiTabl
> es/AcpiTables/OUTPUT/./Dsdt.440:
> Error6126 - syntax error, unexpected '}', expecting $end and premature
> End-Of-File
> 
> The acpica version in my system is 20160422. Did I missing any update in
> acpica?
> 
> Thanks,
> 
> Gary Lin
> 
> > ---
> >  OvmfPkg/AcpiTables/AcpiTables.inf | 4 
> >  OvmfPkg/AcpiTables/Dsdt.asl   | 2 +-
> >  2 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/OvmfPkg/AcpiTables/AcpiTables.inf
> b/OvmfPkg/AcpiTables/AcpiTables.inf
> > index 1187a14..2c604c3 100644
> > --- a/OvmfPkg/AcpiTables/AcpiTables.inf
> > +++ b/OvmfPkg/AcpiTables/AcpiTables.inf
> > @@ -37,4 +37,8 @@
> >
> >  [Packages]
> >MdePkg/MdePkg.dec
> > +  OvmfPkg/OvmfPkg.dec
> > +
> > +[Pcd]
> > +  gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort
> >
> > diff --git a/OvmfPkg/AcpiTables/Dsdt.asl b/OvmfPkg/AcpiTables/Dsdt.asl
> > index 2c3a314..0397722 100644
> > --- a/OvmfPkg/AcpiTables/Dsdt.asl
> > +++ b/OvmfPkg/AcpiTables/Dsdt.asl
> > @@ -581,7 +581,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 1, "INTEL ",
> "OVMF", 4) {
> >  IO (Decode16, 0x278, 0x278, 0x00, 0x08)
> >  IO (Decode16, 0x370, 0x370, 0x00, 0x02)
> >  IO (Decode16, 0x378, 0x378, 0x00, 0x08)
> > -IO (Decode16, 0x402, 0x402, 0x00, 0x01)// QEMU debug 
> > console,
> should use FixedPcdGet16 (PcdDebugIoPort)
> > +IO (Decode16, FixedPcdGet16 (PcdDebugIoPort), FixedPcdGet16
> (PcdDebugIoPort), 0x00, 0x01)
> >  IO (Decode16, 0x440, 0x440, 0x00, 0x10)
> >  IO (Decode16, 0x678, 0x678, 0x00, 0x08)
> >  IO (Decode16, 0x778, 0x778, 0x00, 0x08)
> > --
> > 2.8.0.windows.1
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> >
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] OvmfPkg AcpiTables: Use PcdDebugIoPort to describe QEMU debug console

2016-11-17 Thread Gary Lin
On Wed, Nov 16, 2016 at 10:10:07AM +0800, Liming Gao wrote:
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao 

Hi Liming and Laszlo,

I failed to compile OVMF after applying this patch:

"iasl"  
-p/home/gary/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Dsdt.aml
 
/home/gary/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Dsdt.
Compiler aborting due to parser-detected syntax error(s)
/home/gary/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Dsdt.
375: IO (Decode16, FixedPcdGet16 (PcdDebugIoPort), 
FixedPcdGet16 (PcdDebugIoPort), 0x00, 0x01)
Error6126 - 
 syntax error, unexpected PARSEOP_NAMESEG ^

/home/gary/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/OvmfPkg/AcpiTables/AcpiTables/OUTPUT/./Dsdt.
440:
Error6126 - syntax error, unexpected '}', expecting $end and premature 
End-Of-File

The acpica version in my system is 20160422. Did I missing any update in acpica?

Thanks,

Gary Lin

> ---
>  OvmfPkg/AcpiTables/AcpiTables.inf | 4 
>  OvmfPkg/AcpiTables/Dsdt.asl   | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/OvmfPkg/AcpiTables/AcpiTables.inf 
> b/OvmfPkg/AcpiTables/AcpiTables.inf
> index 1187a14..2c604c3 100644
> --- a/OvmfPkg/AcpiTables/AcpiTables.inf
> +++ b/OvmfPkg/AcpiTables/AcpiTables.inf
> @@ -37,4 +37,8 @@
>  
>  [Packages]
>MdePkg/MdePkg.dec
> +  OvmfPkg/OvmfPkg.dec
> +
> +[Pcd]
> +  gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort
>  
> diff --git a/OvmfPkg/AcpiTables/Dsdt.asl b/OvmfPkg/AcpiTables/Dsdt.asl
> index 2c3a314..0397722 100644
> --- a/OvmfPkg/AcpiTables/Dsdt.asl
> +++ b/OvmfPkg/AcpiTables/Dsdt.asl
> @@ -581,7 +581,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 1, "INTEL ", "OVMF   
>  ", 4) {
>  IO (Decode16, 0x278, 0x278, 0x00, 0x08)
>  IO (Decode16, 0x370, 0x370, 0x00, 0x02)
>  IO (Decode16, 0x378, 0x378, 0x00, 0x08)
> -IO (Decode16, 0x402, 0x402, 0x00, 0x01)// QEMU debug 
> console, should use FixedPcdGet16 (PcdDebugIoPort)
> +IO (Decode16, FixedPcdGet16 (PcdDebugIoPort), FixedPcdGet16 
> (PcdDebugIoPort), 0x00, 0x01)
>  IO (Decode16, 0x440, 0x440, 0x00, 0x10)
>  IO (Decode16, 0x678, 0x678, 0x00, 0x08)
>  IO (Decode16, 0x778, 0x778, 0x00, 0x08)
> -- 
> 2.8.0.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table entry in RSDT/XSDT

2016-11-17 Thread Zeng, Star
I agree to use FADT in commit log.
I got the reason why "Table = 0;" needs.

With that commit log updated, Reviewed-by: Star Zeng 

Thanks,
Star
-Original Message-
From: Ni, Ruiyu 
Sent: Friday, November 18, 2016 9:59 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: sean.bro...@microsoft.com
Subject: RE: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table entry in 
RSDT/XSDT



Regards,
Ray

>-Original Message-
>From: Zeng, Star
>Sent: Thursday, November 17, 2016 6:55 PM
>To: Ni, Ruiyu ; edk2-devel@lists.01.org
>Cc: sean.bro...@microsoft.com; Zeng, Star 
>Subject: RE: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table 
>entry in RSDT/XSDT
>
>Hi Ray,
>
>Add two minor comments inline.
>
>Thanks,
>Star
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf 
>> Of Ruiyu Ni
>> Sent: Monday, November 14, 2016 1:26 PM
>> To: edk2-devel@lists.01.org
>> Subject: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table entry 
>> in RSDT/XSDT
>>
>> The ACPI code may reserve the first entry for a certain table (might 
>> be FACS) to help with OS compatible issues.
>
>FACS is in FADT according to ACPI spec.
>
do you suggest to use FADT in commit message?

>> We need to skip the NULL table entry in RSDT/XSDT.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ruiyu Ni 
>> Cc: Sean Brogan 
>> ---
>>  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 5 +
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
>> b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
>> index 2bb41e7..35e34b7 100644
>> --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
>> +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
>> @@ -1230,6 +1230,11 @@ ScanTableInSDT (
>>  //
>>  Table = 0;
>
>How about to remove this superfluous line " Table = 0;"?
>


  //
  // Find FADT in RSDT
  //
  if (Fadt == NULL && Rsdp->RsdtAddress != 0) {
Fadt = ScanTableInSDT (
 (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress,
 EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
 sizeof (UINT32)
 );
  }
when above code runs in 64bit env, CopyMem only fills the 4-byte in Table 
leaving hi-4-byte un-initialized.
so we need to set Table to 0 to fill hi-4-byte.

>>  CopyMem (, (VOID *) (EntryBase + Index * 
>> TablePointerSize), TablePointerSize);
>> +
>> +if (Table == NULL) {
>> +  continue;
>> +}
>>
>> +
>>  if (Table->Signature == Signature) {
>>return Table;
>>  }
>> --
>> 2.9.0.windows.1
>>
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] BaseTools: Skip module AutoGen by comparing timestamp.

2016-11-17 Thread Derek Lin
[Introduction]

The BaseTool Build.py AutoGen parse INF meta-file and generate
AutoGen.c/AutoGen.h/makefile. When we only change .c .h code, the
AutoGen might be not necessary, but Build.py spend a lot of time on it.
There's a -u flag to skip all module's AutoGen. In my environment, it save
35%~50% of time in rebuild a ROM.
However, if user change one .INF meta-file, then -u flag is not available.

[Idea]

AutoGen can compare meta-file's timestamp and decide if the module's AutoGen
can be skipped. With this, when a module's INF is changed, we only run this
module's AutoGen, we don't need to run other module's.

[Implementation]

In the end of a module's AutoGen, we create a AutoGenTimeStamp.
The file save a file list that related to this module's AutoGen.
In other word, the file list in AutoGenTimeStamp is INPUT files of
module AutoGen, AutoGenTimeStamp file is OUTPUT.
During rebuild, we compare time stamp between INPUT and OUTPUT, and
decide if we can skip it.

Below is the Input/Output of a module's AutoGen.

[Input]
  1. All the DSC/DEC/FDF used by the platform.
  2. INF file of a module.
  3. Source files of a module, list in [Sources] section of INF.
  4. All the library link by the module.
  5. All the .h files included by the module's sources.
[Output]
  AutoGen.c/AutoGen.h/makefile/AutoGenTimeStamp

[Testing]

This patch save my build time. When I make a change without touching
DSC/DEC/FDF, it is absolutely much faster than original rebuild,
35%~50% time saving in my environment
(compare to original tool rebuild time).
If I change any DSC/DEC/FDF, there's no performance improve, because it
can't skip any module's AutoGen.

Please note that if your environment will generate DSC/FDF during prebuild,
it will not skip any AutoGen because of DSC timestamp is changed. This will
require prebuild script not to update meta file when content is not changed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Derek Lin 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 110 +
 BaseTools/Source/Python/AutoGen/GenMake.py |   3 +
 BaseTools/Source/Python/GenFds/FdfParser.py|   4 +
 .../Source/Python/Workspace/MetaFileParser.py  |   4 +
 4 files changed, 121 insertions(+)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index f35ae25..daa5b35 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -42,6 +42,7 @@ from GenPcdDb import CreatePcdDatabaseCode
 from Workspace.MetaFileCommentParser import UsageList
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 import InfSectionParser
+import datetime
 
 ## Regular expression for splitting Dependency Expression string into tokens
 gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
@@ -640,6 +641,31 @@ class WorkspaceAutoGen(AutoGen):
 self._MakeFileDir = None
 self._BuildCommand = None
 
+#
+# Create list of metafiles of the workspace
+#
+AllWorkSpaceMetaFiles = self._CreateMetaFileList()
+  
+#
+# Retrieve latest modified time of all metafiles
+#
+SrcTimeStamp = 0
+for f in AllWorkSpaceMetaFiles:
+if os.stat(f)[8] > SrcTimeStamp:
+SrcTimeStamp = os.stat(f)[8]
+self._SrcTimeStamp = SrcTimeStamp
+
+#
+# Write metafile list to build directory
+#
+AutoGenFilePath = os.path.join(self.BuildDir, 'AutoGen')
+if os.path.exists (AutoGenFilePath):
+os.remove(AutoGenFilePath)
+if not os.path.exists(self.BuildDir):
+os.makedirs(self.BuildDir)
+with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file:
+for f in AllWorkSpaceMetaFiles:
+print >> file, f
 return True
 
 def _BuildOptionPcdValueFormat(self, TokenSpaceGuidCName, TokenCName, 
PcdDatumType, Value):
@@ -668,6 +694,29 @@ class WorkspaceAutoGen(AutoGen):
 Value = '0'
 return  Value
 
+def _CreateMetaFileList(self):
+AllWorkSpaceMetaFiles = []
+#
+# add fdf
+#
+AllWorkSpaceMetaFiles.append (self.FdfFile.Path)
+if self.FdfFile:
+FdfFiles = GlobalData.gFdfParser.GetAllIncludedFile()
+for f in FdfFiles:
+AllWorkSpaceMetaFiles.append (f.FileName)   
+#
+# add dsc & dec
+#
+for BuildData in self.BuildDatabase._CACHE_.values():
+if 'dsc' is BuildData.MetaFile.Ext:
+AllWorkSpaceMetaFiles.append(BuildData.MetaFile.Path)
+for filePath in BuildData._RawData.IncludedFiles:
+AllWorkSpaceMetaFiles.append(filePath.Path)
+if 'dec' is BuildData.MetaFile.Ext:
+AllWorkSpaceMetaFiles.append(BuildData.MetaFile.Path)
+
+

Re: [edk2] [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size

2016-11-17 Thread Yao, Jiewen
Yes, that is correct. I misunderstand the patch.

Reviewed-by: jiewen@intel.com

At same time, I would recommend we update PEI with comment on why we can use 
GetDigestListSize (DigestList) in PEI, but not use GetDigestListSize in DXE, 
because people may compare these 2 version.

Thank you
Yao Jiewen


From: Zeng, Star
Sent: Friday, November 18, 2016 8:51 AM
To: Yao, Jiewen ; edk2-devel@lists.01.org
Cc: Zhang, Chao B 
Subject: Re: [edk2] [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size

On 2016/11/17 20:32, Yao, Jiewen wrote:
> Hi star
> I am sorry that I am confused on this patch.
>
> 1) Below update is not related to the GIT message.
> I think there is nothing wrong with previous code. May I know if you observe 
> something?

The following GetDigestListBinSize (DigestBuffer) needs *DigestBuffer
points to real digest buffer*.

>
>> -DigestBuffer = CopyDigestListToBuffer (DigestBuffer, DigestList,
>> mTcgDxeData.BsCap.ActivePcrBanks);
>> -CopyMem (DigestBuffer, >EventSize,
>> sizeof(NewEventHdr->EventSize));
>> -DigestBuffer = DigestBuffer + sizeof(NewEventHdr->EventSize);
>> +EventSizePtr = CopyDigestListToBuffer (DigestBuffer, DigestList,
>> mTcgDxeData.BsCap.ActivePcrBanks);
>> +CopyMem (EventSizePtr, >EventSize,
>> sizeof(NewEventHdr->EventSize));
>
> 2) I believe "GetDigestListSize (DigestList)" should be same as 
> "GetDigestListBinSize (DigestBuffer)"
> May I know how did you observe such error?

DigestList points to the original full un-compacted digest list,
DigestBuffer points to the copied partial compacted digest list.

Thanks,
Star

>
>
> Thank you
> Yao Jiewen
>
>
>
>> -Original Message-
>> From: Zeng, Star
>> Sent: Thursday, November 17, 2016 5:27 PM
>> To: edk2-devel@lists.01.org
>> Cc: Zeng, Star >; Yao, 
>> Jiewen >;
>> Zhang, Chao B >
>> Subject: [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size
>>
>> Current code uses GetDigestListSize(DigestList) to get
>> digest list size, that is incorrect.
>> The code should get digest list size of digests copied
>> into event2 log, those digests are compacted, so
>> GetDigestListBinSize() should be used.
>>
>> Cc: Jiewen Yao >
>> Cc: Chao Zhang >
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Star Zeng >
>> ---
>>  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 8 
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
>> b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
>> index d5a32307db6e..f4740a3c 100644
>> --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
>> +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
>> @@ -970,6 +970,7 @@ TcgDxeLogHashEvent (
>>EFI_STATUSRetStatus;
>>TCG_PCR_EVENT2TcgPcrEvent2;
>>UINT8 *DigestBuffer;
>> +  UINT32*EventSizePtr;
>>
>>DEBUG ((EFI_D_INFO, "SupportedEventLogs - 0x%08x\n",
>> mTcgDxeData.BsCap.SupportedEventLogs));
>>
>> @@ -1006,9 +1007,8 @@ TcgDxeLogHashEvent (
>>  TcgPcrEvent2.PCRIndex = NewEventHdr->PCRIndex;
>>  TcgPcrEvent2.EventType = NewEventHdr->EventType;
>>  DigestBuffer = (UINT8 *)
>> -DigestBuffer = CopyDigestListToBuffer (DigestBuffer, DigestList,
>> mTcgDxeData.BsCap.ActivePcrBanks);
>> -CopyMem (DigestBuffer, >EventSize,
>> sizeof(NewEventHdr->EventSize));
>> -DigestBuffer = DigestBuffer + sizeof(NewEventHdr->EventSize);
>> +EventSizePtr = CopyDigestListToBuffer (DigestBuffer, DigestList,
>> mTcgDxeData.BsCap.ActivePcrBanks);
>> +CopyMem (EventSizePtr, >EventSize,
>> sizeof(NewEventHdr->EventSize));
>>
>>  //
>>  // Enter critical region
>> @@ -1017,7 +1017,7 @@ TcgDxeLogHashEvent (
>>  Status = TcgDxeLogEvent (
>> mTcg2EventInfo[Index].LogFormat,
>> ,
>> -   sizeof(TcgPcrEvent2.PCRIndex) +
>> sizeof(TcgPcrEvent2.EventType) + GetDigestListSize (DigestList) +
>> sizeof(TcgPcrEvent2.EventSize),
>> +   sizeof(TcgPcrEvent2.PCRIndex) +
>> sizeof(TcgPcrEvent2.EventType) + GetDigestListBinSize (DigestBuffer) +
>> sizeof(TcgPcrEvent2.EventSize),
>> NewEventData,
>> NewEventHdr->EventSize
>> );
>> --
>> 2.7.0.windows.1
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable device protocol

2016-11-17 Thread Ni, Ruiyu


Regards,
Ray

>-Original Message-
>From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>Sent: Thursday, November 17, 2016 6:43 PM
>To: Ni, Ruiyu 
>Cc: Kinney, Michael D ; edk2-devel@lists.01.org; 
>Gao, Liming ;
>af...@apple.com; Leif Lindholm 
>Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable 
>device protocol
>
>
>> On 17 Nov 2016, at 08:52, Ni, Ruiyu  wrote:
>>
>>
>>
>> Thanks/Ray
>>
>>> -Original Message-
>>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>>> Ard Biesheuvel
>>> Sent: Thursday, November 17, 2016 2:07 PM
>>> To: Ni, Ruiyu 
>>> Cc: Kinney, Michael D ; edk2-
>>> de...@lists.01.org; Gao, Liming ; af...@apple.com;
>>> Leif Lindholm 
>>> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-
>>> discoverable device protocol
>>>
>>>
>>>
 On 17 Nov 2016, at 02:53, Ni, Ruiyu  wrote:

 Ard,
 I have two comments in below.

 Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
> Of Leif Lindholm
> Sent: Thursday, November 17, 2016 1:49 AM
> To: Ard Biesheuvel 
> Cc: Ni, Ruiyu ; edk2-devel@lists.01.org;
> af...@apple.com; Gao, Liming ; Kinney, Michael
> D 
> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-
> discoverable device protocol
>
>> On Wed, Nov 16, 2016 at 04:59:27PM +, Ard Biesheuvel wrote:
>> Introduce a protocol that can be exposed by a platform for devices
>> that are not discoverable, usually because they are wired straight
>> to the memory bus rather than to an enumerable bus like PCI or USB.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel 
>> ---
>> MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 90
> 
>> MdeModulePkg/MdeModulePkg.dec |  3 +
>> 2 files changed, 93 insertions(+)
>>
>> diff --git a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>> b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>> new file mode 100644
>> index ..47ed841b407b
>> --- /dev/null
>> +++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
>> @@ -0,0 +1,90 @@
>> +/** @file
>> +  Protocol to describe devices that are not on a discoverable bus
>> +
>> +  Copyright (c) 2016, Linaro, Ltd. All rights reserved.
>> +
>> +  This program and the accompanying materials  are licensed and
>> + made available under the terms and conditions of the BSD License
>> + which accompanies this distribution.  The full text of the license
>> + may be found at  http://opensource.org/licenses/bsd-license.php
>> +
>> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
>>> IS"
>> + BASIS,  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
> EITHER EXPRESS OR IMPLIED.
>> +
>> +**/
>> +
>> +#ifndef __NON_DISCOVERABLE_DEVICE_H__ #define
>> +__NON_DISCOVERABLE_DEVICE_H__
>> +
>> +#include 
>> +
>> +#define EDKII_NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \
>> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc,
>> +0x8d, 0x51, 0x4a } }

 1. Can you add "PCI" keyword into the protocol name?
 e.g.: EDKII_NON_DISCOVERABLE_PCI_DEVICE_PROTOCOL_GUID

>>>
>>> No. This protocol does not describe pci devices, and it is a peculiarity of 
>>> the
>>> edk2 driver stack that some non-pci devices can only be driven by pci 
>>> drivers.
>>>
>>> in other words, pci is part of the /driver/ side, and it is perfectly 
>>> possible for,
>>> e.g., a non-discoverable ahci device to be driven by a different non-pci 
>>> driver
>>> in the future.
>>>
>>
>> I see. So some types of devices are handled by the current
>> NonDiscoveablePciDevice driver, and some other types of devices may be
>> handled by a future NonDiscoverableXXXDevice driver.
>> Now since the AHCI type is already handled by the NonDiscoverablePciDevice
>> driver, when there is a new NonDiscoverableXXXDevice driver, how can the two
>> know whether it should manage the AHCI type device or not?
>
>Good question. But how does the UEFI driver model deal with that? What happens 
>if i have two drivers that both support the
>Ahci Pci class codes?
PCI CFG header contains VendorID/DeviceID fields which can be used to 
distinguish
them.

>
>> Besides since now all the EDKII Host Controller drivers are based on
>> PciIo, it implicitly requires all the low layer needs to produce PciIo 
>> interface

Re: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table entry in RSDT/XSDT

2016-11-17 Thread Ni, Ruiyu


Regards,
Ray

>-Original Message-
>From: Zeng, Star
>Sent: Thursday, November 17, 2016 6:55 PM
>To: Ni, Ruiyu ; edk2-devel@lists.01.org
>Cc: sean.bro...@microsoft.com; Zeng, Star 
>Subject: RE: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table entry in 
>RSDT/XSDT
>
>Hi Ray,
>
>Add two minor comments inline.
>
>Thanks,
>Star
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>> Ruiyu Ni
>> Sent: Monday, November 14, 2016 1:26 PM
>> To: edk2-devel@lists.01.org
>> Subject: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table entry
>> in RSDT/XSDT
>>
>> The ACPI code may reserve the first entry for a certain table (might
>> be FACS) to help with OS compatible issues.
>
>FACS is in FADT according to ACPI spec.
>
do you suggest to use FADT in commit message?

>> We need to skip the NULL table entry in RSDT/XSDT.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ruiyu Ni 
>> Cc: Sean Brogan 
>> ---
>>  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 5 +
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
>> b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
>> index 2bb41e7..35e34b7 100644
>> --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
>> +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
>> @@ -1230,6 +1230,11 @@ ScanTableInSDT (
>>  //
>>  Table = 0;
>
>How about to remove this superfluous line " Table = 0;"?
>


  //
  // Find FADT in RSDT
  //
  if (Fadt == NULL && Rsdp->RsdtAddress != 0) {
Fadt = ScanTableInSDT (
 (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress,
 EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
 sizeof (UINT32)
 );
  }
when above code runs in 64bit env, CopyMem only fills the 4-byte in Table 
leaving
hi-4-byte un-initialized.
so we need to set Table to 0 to fill hi-4-byte.

>>  CopyMem (, (VOID *) (EntryBase + Index * TablePointerSize),
>> TablePointerSize);
>> +
>> +if (Table == NULL) {
>> +  continue;
>> +}
>>
>> +
>>  if (Table->Signature == Signature) {
>>return Table;
>>  }
>> --
>> 2.9.0.windows.1
>>
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 2/2] SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Yao, Jiewen
That's good idea. I like both. :)

From: Zeng, Star
Sent: Friday, November 18, 2016 9:31 AM
To: Yao, Jiewen ; edk2-devel@lists.01.org
Cc: Zhang, Chao B ; Zeng, Star 
Subject: Re: [edk2] [PATCH 2/2] SecurityPkg Tcg2Dxe: Filter inactive digest in 
event2 log from PEI HOB

On 2016/11/17 20:19, Yao, Jiewen wrote:
> Hi Star
> 1) I am a little confused on below description.
> +  @param[in,out] Buffer Buffer to hold TPML_DIGEST_VALUES.
>
> I think the buffer is the *TPML_DIGEST_VALUES compact binary buffer*, instead 
> of *TPML_DIGEST_VALUES*, right?
> I suggest we describe it clearly.

Oh, yes. The description was just copied from CopyDigestListToBuffer ()
of Tpm2CommandLib, do you think we also need to update the description
for CopyDigestListToBuffer ().

>
> 2) I think the FILTER is great to report ERROR if the TCG event hob producer 
> makes mistake.
> Do you think it is worthy to add more stronger check that: All required TCG 
> event log are reported ?

Yes, It can be done by adding a parameter to CopyDigestListBinToBuffer
() and compare if HashAlgorithmMaskCopied equals to HashAlgorithmMask to
know if all required TCG evente log are reported.

VOID *
CopyDigestListBinToBuffer (
   IN OUT VOID   *Buffer,
   IN VOID   *DigestListBin,
   IN UINT32 HashAlgorithmMask,
*  OUT UINT32*HashAlgorithmMaskCopied*
   )

Thanks,
Star

>
>
>
>> -Original Message-
>> From: Zeng, Star
>> Sent: Thursday, November 17, 2016 5:29 PM
>> To: edk2-devel@lists.01.org
>> Cc: Zeng, Star >; Yao, 
>> Jiewen >;
>> Zhang, Chao B >
>> Subject: [PATCH 2/2] SecurityPkg Tcg2Dxe: Filter inactive digest in event2 
>> log
>> from PEI HOB
>>
>> Cc: Jiewen Yao >
>> Cc: Chao Zhang >
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Star Zeng >
>> ---
>>  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 80
>> +--
>>  1 file changed, 76 insertions(+), 4 deletions(-)
>>
>> diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
>> b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
>> index db8d662f80dc..d5a32307db6e 100644
>> --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
>> +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
>> @@ -898,6 +898,56 @@ GetDigestListBinSize (
>>  }
>>
>>  /**
>> +  Copy TPML_DIGEST_VALUES compact binary into a buffer
>> +
>> +  @param[in,out] Buffer Buffer to hold
>> TPML_DIGEST_VALUES.
>> +  @param[in] DigestListBin  TPML_DIGEST_VALUES compact
>> binary buffer.
>> +  @param[in] HashAlgorithmMask  HASH bits corresponding to the
>> desired digests to copy.
>> +
>> +  @return The end of buffer to hold TPML_DIGEST_VALUES.
>> +**/
>> +VOID *
>> +CopyDigestListBinToBuffer (
>> +  IN OUT VOID   *Buffer,
>> +  IN VOID   *DigestListBin,
>> +  IN UINT32 HashAlgorithmMask
>> +  )
>> +{
>> +  UINTN Index;
>> +  UINT16DigestSize;
>> +  UINT32Count;
>> +  TPMI_ALG_HASH HashAlg;
>> +  UINT32DigestListCount;
>> +  UINT32*DigestListCountPtr;
>> +
>> +  DigestListCountPtr = (UINT32 *) Buffer;
>> +  DigestListCount = 0;
>> +
>> +  Count = ReadUnaligned32 (DigestListBin);
>> +  Buffer = (UINT8 *)Buffer + sizeof(Count);
>> +  DigestListBin = (UINT8 *)DigestListBin + sizeof(Count);
>> +  for (Index = 0; Index < Count; Index++) {
>> +HashAlg = ReadUnaligned16 (DigestListBin);
>> +DigestListBin = (UINT8 *)DigestListBin + sizeof(HashAlg);
>> +DigestSize = GetHashSizeFromAlgo (HashAlg);
>> +
>> +if (IsHashAlgSupportedInHashAlgorithmMask(HashAlg,
>> HashAlgorithmMask)) {
>> +  CopyMem (Buffer, , sizeof(HashAlg));
>> +  Buffer = (UINT8 *)Buffer + sizeof(HashAlg);
>> +  CopyMem (Buffer, DigestListBin, DigestSize);
>> +  Buffer = (UINT8 *)Buffer + DigestSize;
>> +  DigestListCount++;
>> +} else {
>> +  DEBUG ((EFI_D_ERROR, "WARNING: CopyDigestListBinToBuffer
>> Event log has HashAlg unsupported by PCR bank (0x%x)\n", HashAlg));
>> +}
>> +DigestListBin = (UINT8 *)DigestListBin + DigestSize;
>> +  }
>> +  WriteUnaligned32 (DigestListCountPtr, DigestListCount);
>> +
>> +  return Buffer;
>> +}
>> +
>> +/**
>>Add a new entry to the Event Log.
>>
>>@param[in] DigestListA list of digest.
>> @@ -1317,8 +1367,12 @@ SetupEventLog (
>>EFI_PEI_HOB_POINTERSGuidHob;
>>EFI_PHYSICAL_ADDRESSLasa;
>>UINTN   Index;
>> +  VOID*DigestListBin;
>> +  TPML_DIGEST_VALUES   

Re: [edk2] [PATCH 2/2] SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Zeng, Star

On 2016/11/17 20:19, Yao, Jiewen wrote:

Hi Star
1) I am a little confused on below description.
+  @param[in,out] Buffer Buffer to hold TPML_DIGEST_VALUES.

I think the buffer is the *TPML_DIGEST_VALUES compact binary buffer*, instead 
of *TPML_DIGEST_VALUES*, right?
I suggest we describe it clearly.


Oh, yes. The description was just copied from CopyDigestListToBuffer () 
of Tpm2CommandLib, do you think we also need to update the description 
for CopyDigestListToBuffer ().




2) I think the FILTER is great to report ERROR if the TCG event hob producer 
makes mistake.
Do you think it is worthy to add more stronger check that: All required TCG 
event log are reported ?


Yes, It can be done by adding a parameter to CopyDigestListBinToBuffer 
() and compare if HashAlgorithmMaskCopied equals to HashAlgorithmMask to 
know if all required TCG evente log are reported.


VOID *
CopyDigestListBinToBuffer (
  IN OUT VOID   *Buffer,
  IN VOID   *DigestListBin,
  IN UINT32 HashAlgorithmMask,
*  OUT UINT32*HashAlgorithmMaskCopied*
  )

Thanks,
Star






-Original Message-
From: Zeng, Star
Sent: Thursday, November 17, 2016 5:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Yao, Jiewen ;
Zhang, Chao B 
Subject: [PATCH 2/2] SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log
from PEI HOB

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 80
+--
 1 file changed, 76 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
index db8d662f80dc..d5a32307db6e 100644
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
@@ -898,6 +898,56 @@ GetDigestListBinSize (
 }

 /**
+  Copy TPML_DIGEST_VALUES compact binary into a buffer
+
+  @param[in,out] Buffer Buffer to hold
TPML_DIGEST_VALUES.
+  @param[in] DigestListBin  TPML_DIGEST_VALUES compact
binary buffer.
+  @param[in] HashAlgorithmMask  HASH bits corresponding to the
desired digests to copy.
+
+  @return The end of buffer to hold TPML_DIGEST_VALUES.
+**/
+VOID *
+CopyDigestListBinToBuffer (
+  IN OUT VOID   *Buffer,
+  IN VOID   *DigestListBin,
+  IN UINT32 HashAlgorithmMask
+  )
+{
+  UINTN Index;
+  UINT16DigestSize;
+  UINT32Count;
+  TPMI_ALG_HASH HashAlg;
+  UINT32DigestListCount;
+  UINT32*DigestListCountPtr;
+
+  DigestListCountPtr = (UINT32 *) Buffer;
+  DigestListCount = 0;
+
+  Count = ReadUnaligned32 (DigestListBin);
+  Buffer = (UINT8 *)Buffer + sizeof(Count);
+  DigestListBin = (UINT8 *)DigestListBin + sizeof(Count);
+  for (Index = 0; Index < Count; Index++) {
+HashAlg = ReadUnaligned16 (DigestListBin);
+DigestListBin = (UINT8 *)DigestListBin + sizeof(HashAlg);
+DigestSize = GetHashSizeFromAlgo (HashAlg);
+
+if (IsHashAlgSupportedInHashAlgorithmMask(HashAlg,
HashAlgorithmMask)) {
+  CopyMem (Buffer, , sizeof(HashAlg));
+  Buffer = (UINT8 *)Buffer + sizeof(HashAlg);
+  CopyMem (Buffer, DigestListBin, DigestSize);
+  Buffer = (UINT8 *)Buffer + DigestSize;
+  DigestListCount++;
+} else {
+  DEBUG ((EFI_D_ERROR, "WARNING: CopyDigestListBinToBuffer
Event log has HashAlg unsupported by PCR bank (0x%x)\n", HashAlg));
+}
+DigestListBin = (UINT8 *)DigestListBin + DigestSize;
+  }
+  WriteUnaligned32 (DigestListCountPtr, DigestListCount);
+
+  return Buffer;
+}
+
+/**
   Add a new entry to the Event Log.

   @param[in] DigestListA list of digest.
@@ -1317,8 +1367,12 @@ SetupEventLog (
   EFI_PEI_HOB_POINTERSGuidHob;
   EFI_PHYSICAL_ADDRESSLasa;
   UINTN   Index;
+  VOID*DigestListBin;
+  TPML_DIGEST_VALUES  TempDigestListBin;
   UINT32  DigestListBinSize;
+  UINT8   *Event;
   UINT32  EventSize;
+  UINT32  *EventSizePtr;
   TCG_EfiSpecIDEventStruct*TcgEfiSpecIdEventStruct;
   UINT8
TempBuf[sizeof(TCG_EfiSpecIDEventStruct) + sizeof(UINT32) +
(HASH_COUNT * sizeof(TCG_EfiSpecIdEventAlgorithmSize)) + sizeof(UINT8)];
   TCG_PCR_EVENT_HDR   FirstPcrEvent;
@@ -1497,7 +1551,8 @@ SetupEventLog (
   Status = EFI_SUCCESS;
   while (!EFI_ERROR (Status) &&
  (GuidHob.Raw = GetNextGuidHob
(mTcg2EventInfo[Index].EventGuid, GuidHob.Raw)) != NULL) {
-TcgEvent= GET_GUID_HOB_DATA (GuidHob.Guid);
+TcgEvent= AllocateCopyPool (GET_GUID_HOB_DATA_SIZE
(GuidHob.Guid), GET_GUID_HOB_DATA 

Re: [edk2] [Patch v2 0/3] MdePkg/BaseSynchronizationLib: Add volatile

2016-11-17 Thread Gao, Liming
Reviewed-by: Liming Gao 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Michael 
Kinney
Sent: Friday, November 18, 2016 3:35 AM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch v2 0/3] MdePkg/BaseSynchronizationLib: Add volatile

Updates for V2
==
* Split out patch that corrects function names in comment blocks
* Change InterlockedCompareExchangePointer() parameter from volatile VOID**
  to VOID * volatile *.
* Remove unnessary typecast in calls to InterlockedCompareExchangePointer()
* Fix missing copyright updates
* Minor formatting changes

Michael Kinney (3):
  MdePkg/Include: Add volatile to SynchronizationLib parameters
  MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs
  MdePkg/BaseSynchronizationLib: Fix function names in function headers

 MdePkg/Include/Library/SynchronizationLib.h  | 14 +++---
 .../Ia32/InterlockedCompareExchange16.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange16.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange16.nasm   |  4 ++--
 .../Ia32/InterlockedCompareExchange32.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange32.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange32.nasm   |  4 ++--
 .../Ia32/InterlockedCompareExchange64.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange64.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange64.nasm   |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedDecrement.asm |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedDecrement.c   |  4 ++--
 .../Ia32/InterlockedDecrement.nasm   |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedIncrement.asm |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedIncrement.c   |  4 ++--
 .../Ia32/InterlockedIncrement.nasm   |  4 ++--
 MdePkg/Library/BaseSynchronizationLib/Synchronization.c  | 16 
 .../Library/BaseSynchronizationLib/SynchronizationGcc.c  | 16 
 .../Library/BaseSynchronizationLib/SynchronizationMsc.c  | 16 
 .../X64/InterlockedCompareExchange16.asm |  6 +++---
 .../X64/InterlockedCompareExchange16.c   |  4 ++--
 .../X64/InterlockedCompareExchange16.nasm|  6 +++---
 .../X64/InterlockedCompareExchange32.asm |  6 +++---
 .../X64/InterlockedCompareExchange32.c   |  4 ++--
 .../X64/InterlockedCompareExchange32.nasm|  6 +++---
 .../X64/InterlockedCompareExchange64.asm |  6 +++---
 .../X64/InterlockedCompareExchange64.c   |  4 ++--
 .../X64/InterlockedCompareExchange64.nasm|  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedDecrement.asm  |  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedDecrement.c|  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedDecrement.nasm |  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedIncrement.asm  |  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedIncrement.c|  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedIncrement.nasm |  6 +++---
 34 files changed, 103 insertions(+), 103 deletions(-)

-- 
2.6.3.windows.1

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


Re: [edk2] [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size

2016-11-17 Thread Zeng, Star

On 2016/11/17 20:32, Yao, Jiewen wrote:

Hi star
I am sorry that I am confused on this patch.

1) Below update is not related to the GIT message.
I think there is nothing wrong with previous code. May I know if you observe 
something?


The following GetDigestListBinSize (DigestBuffer) needs *DigestBuffer 
points to real digest buffer*.





-DigestBuffer = CopyDigestListToBuffer (DigestBuffer, DigestList,
mTcgDxeData.BsCap.ActivePcrBanks);
-CopyMem (DigestBuffer, >EventSize,
sizeof(NewEventHdr->EventSize));
-DigestBuffer = DigestBuffer + sizeof(NewEventHdr->EventSize);
+EventSizePtr = CopyDigestListToBuffer (DigestBuffer, DigestList,
mTcgDxeData.BsCap.ActivePcrBanks);
+CopyMem (EventSizePtr, >EventSize,
sizeof(NewEventHdr->EventSize));


2) I believe "GetDigestListSize (DigestList)" should be same as 
"GetDigestListBinSize (DigestBuffer)"
May I know how did you observe such error?


DigestList points to the original full un-compacted digest list, 
DigestBuffer points to the copied partial compacted digest list.


Thanks,
Star




Thank you
Yao Jiewen




-Original Message-
From: Zeng, Star
Sent: Thursday, November 17, 2016 5:27 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Yao, Jiewen ;
Zhang, Chao B 
Subject: [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size

Current code uses GetDigestListSize(DigestList) to get
digest list size, that is incorrect.
The code should get digest list size of digests copied
into event2 log, those digests are compacted, so
GetDigestListBinSize() should be used.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
index d5a32307db6e..f4740a3c 100644
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
@@ -970,6 +970,7 @@ TcgDxeLogHashEvent (
   EFI_STATUSRetStatus;
   TCG_PCR_EVENT2TcgPcrEvent2;
   UINT8 *DigestBuffer;
+  UINT32*EventSizePtr;

   DEBUG ((EFI_D_INFO, "SupportedEventLogs - 0x%08x\n",
mTcgDxeData.BsCap.SupportedEventLogs));

@@ -1006,9 +1007,8 @@ TcgDxeLogHashEvent (
 TcgPcrEvent2.PCRIndex = NewEventHdr->PCRIndex;
 TcgPcrEvent2.EventType = NewEventHdr->EventType;
 DigestBuffer = (UINT8 *)
-DigestBuffer = CopyDigestListToBuffer (DigestBuffer, DigestList,
mTcgDxeData.BsCap.ActivePcrBanks);
-CopyMem (DigestBuffer, >EventSize,
sizeof(NewEventHdr->EventSize));
-DigestBuffer = DigestBuffer + sizeof(NewEventHdr->EventSize);
+EventSizePtr = CopyDigestListToBuffer (DigestBuffer, DigestList,
mTcgDxeData.BsCap.ActivePcrBanks);
+CopyMem (EventSizePtr, >EventSize,
sizeof(NewEventHdr->EventSize));

 //
 // Enter critical region
@@ -1017,7 +1017,7 @@ TcgDxeLogHashEvent (
 Status = TcgDxeLogEvent (
mTcg2EventInfo[Index].LogFormat,
,
-   sizeof(TcgPcrEvent2.PCRIndex) +
sizeof(TcgPcrEvent2.EventType) + GetDigestListSize (DigestList) +
sizeof(TcgPcrEvent2.EventSize),
+   sizeof(TcgPcrEvent2.PCRIndex) +
sizeof(TcgPcrEvent2.EventType) + GetDigestListBinSize (DigestBuffer) +
sizeof(TcgPcrEvent2.EventSize),
NewEventData,
NewEventHdr->EventSize
);
--
2.7.0.windows.1


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


Re: [edk2] [Patch v2 0/2] Fix ACPI S3 resume failure with GCC 5.4

2016-11-17 Thread Fan, Jeff
Reviewed-by: Jeff Fan 

Thanks!

-Original Message-
From: Kinney, Michael D 
Sent: Friday, November 18, 2016 5:19 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming; Laszlo Ersek; Andrew Fish; Fan, Jeff
Subject: [Patch v2 0/2] Fix ACPI S3 resume failure with GCC 5.4

Add volatile qualifier to mNumberToFinish to prevent GCC 5.4 compiler from 
optimizing away required logic in ACPI S3 resume.

Update TransferApToSafeState() use UINTN params to reduce the number of type 
casts required in these calls and change the NumberToFinish parameter from 
UINT32* to UINTN NumberToFinishAddress to resolve compiler warnings from a 
volatile pointer to a non-volatile pointer conversion.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Andrew Fish 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 

Michael Kinney (2):
  UefiCpuPkg/PiSmmCpuDxeSmm: TransferApToSafeState() use UINTN params
  UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to mNumberToFinish

 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 10 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 18 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h| 12 ++--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  | 18 +-
 4 files changed, 29 insertions(+), 29 deletions(-)

--
2.6.3.windows.1

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


Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.

2016-11-17 Thread Fan, Jeff
Reviewed-by: Jeff Fan 

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Thursday, November 17, 2016 11:58 PM
To: Yao, Jiewen; edk2-de...@ml01.01.org
Cc: Kinney, Michael D; Fan, Jeff
Subject: Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.

On 11/17/16 14:33, Jiewen Yao wrote:
> When XD is not supported, the BIT63 is reserved.
> We should not set BIT63 in the page table.
> 
> Test OVMF IA32/IA32X64 with XD enabled/disabled.
> 
> Analyzed-by: Laszlo Ersek 
> Cc: Laszlo Ersek 
> Cc: Jeff Fan 
> Cc: Michael D Kinney 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> index b4f8861..c85e025 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> @@ -209,10 +209,12 @@ ConvertPageEntryAttribute (
>  }
>}
>if ((Attributes & EFI_MEMORY_XP) != 0) {
> -if (IsSet) {
> -  NewPageEntry |= IA32_PG_NX;
> -} else {
> -  NewPageEntry &= ~IA32_PG_NX;
> +if (mXdSupported) {
> +  if (IsSet) {
> +NewPageEntry |= IA32_PG_NX;
> +  } else {
> +NewPageEntry &= ~IA32_PG_NX;
> +  }
>  }
>}
>*PageEntry = NewPageEntry;
> 

Tested-by: Laszlo Ersek 

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


Re: [edk2] [Patch v2 0/2] Fix ACPI S3 resume failure with GCC 5.4

2016-11-17 Thread Laszlo Ersek
On 11/17/16 22:19, Michael Kinney wrote:
> Add volatile qualifier to mNumberToFinish to prevent GCC 5.4
> compiler from optimizing away required logic in ACPI S3 resume.
> 
> Update TransferApToSafeState() use UINTN params to reduce the
> number of type casts required in these calls and change
> the NumberToFinish parameter from UINT32* to UINTN
> NumberToFinishAddress to resolve compiler warnings from
> a volatile pointer to a non-volatile pointer conversion.
> 
> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> Cc: Andrew Fish 
> Cc: Jeff Fan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney 
> 
> Michael Kinney (2):
>   UefiCpuPkg/PiSmmCpuDxeSmm: TransferApToSafeState() use UINTN params
>   UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to mNumberToFinish
> 
>  UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 10 +-
>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 18 +-
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h| 12 ++--
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  | 18 +-
>  4 files changed, 29 insertions(+), 29 deletions(-)
> 

series
Reviewed-by: Laszlo Ersek 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v2 0/2] Fix ACPI S3 resume failure with GCC 5.4

2016-11-17 Thread Michael Kinney
Add volatile qualifier to mNumberToFinish to prevent GCC 5.4
compiler from optimizing away required logic in ACPI S3 resume.

Update TransferApToSafeState() use UINTN params to reduce the
number of type casts required in these calls and change
the NumberToFinish parameter from UINT32* to UINTN
NumberToFinishAddress to resolve compiler warnings from
a volatile pointer to a non-volatile pointer conversion.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Andrew Fish 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 

Michael Kinney (2):
  UefiCpuPkg/PiSmmCpuDxeSmm: TransferApToSafeState() use UINTN params
  UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to mNumberToFinish

 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 10 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 18 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h| 12 ++--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  | 18 +-
 4 files changed, 29 insertions(+), 29 deletions(-)

-- 
2.6.3.windows.1

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


[edk2] [Patch v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: TransferApToSafeState() use UINTN params

2016-11-17 Thread Michael Kinney
Update TransferApToSafeState() use UINTN params to reduce the
number of type casts required in these calls.  Also change
the NumberToFinish parameter from UINT32* to UINTN
NumberToFinishAddress to resolve issues with conversion from
a volatile pointer to a non-volatile pointer.  The assembly
code that receives the NumberToFinishAddress value must treat
that memory location as a volatile to track the number of APs.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Andrew Fish 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c |  8 
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 18 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h| 12 ++--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  | 18 +-
 4 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 3fb6864..4af86b7 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -385,7 +385,7 @@ MPRendezvousProcedure (
   CPU_REGISTER_TABLE *RegisterTableList;
   UINT32 InitApicId;
   UINTN  Index;
-  UINT32 TopOfStack;
+  UINTN  TopOfStack;
   UINT8  Stack[128];
 
   ProgramVirtualWireMode ();
@@ -403,10 +403,10 @@ MPRendezvousProcedure (
   //
   // Place AP into the safe code, count down the number with lock mechanism in 
the safe code.
   //
-  TopOfStack  = (UINT32) (UINTN) Stack + sizeof (Stack);
-  TopOfStack &= ~(UINT32) (CPU_STACK_ALIGNMENT - 1);
+  TopOfStack  = (UINTN) Stack + sizeof (Stack);
+  TopOfStack &= ~(UINTN) (CPU_STACK_ALIGNMENT - 1);
   CopyMem ((VOID *) (UINTN) mApHltLoopCode, mApHltLoopCodeTemplate, sizeof 
(mApHltLoopCodeTemplate));
-  TransferApToSafeState ((UINT32) (UINTN) mApHltLoopCode, TopOfStack, 
);
+  TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, 
(UINTN));
 }
 
 /**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
index 4281698..f4db6c8 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
@@ -129,23 +129,23 @@ InitGdt (
 /**
   Transfer AP to safe hlt-loop after it finished restore CPU features on S3 
patch.
 
-  @param[in] ApHltLoopCodeThe 32-bit address of the safe hlt-loop function.
-  @param[in] TopOfStack   A pointer to the new stack to use for the 
ApHltLoopCode.
-  @param[in] NumberToFinish   Semaphore of APs finish count.
+  @param[in] ApHltLoopCode  The address of the safe hlt-loop function.
+  @param[in] TopOfStack A pointer to the new stack to use for the 
ApHltLoopCode.
+  @param[in] NumberToFinishAddress  Address of Semaphore of APs finish count.
 
 **/
 VOID
 TransferApToSafeState (
-  IN UINT32 ApHltLoopCode,
-  IN UINT32 TopOfStack,
-  IN UINT32 *NumberToFinish
+  IN UINTN  ApHltLoopCode,
+  IN UINTN  TopOfStack,
+  IN UINTN  NumberToFinishAddress
   )
 {
   SwitchStack (
-(SWITCH_STACK_ENTRY_POINT) (UINTN) ApHltLoopCode,
-NumberToFinish,
+(SWITCH_STACK_ENTRY_POINT)ApHltLoopCode,
+(VOID *)NumberToFinishAddress,
 NULL,
-(VOID *) (UINTN) TopOfStack
+(VOID *)TopOfStack
 );
   //
   // It should never reach here
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index 907526e..abe5cc6 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -974,16 +974,16 @@ GetAcpiS3EnableFlag (
 /**
   Transfer AP to safe hlt-loop after it finished restore CPU features on S3 
patch.
 
-  @param[in] ApHltLoopCodeThe 32-bit address of the safe hlt-loop function.
-  @param[in] TopOfStack   A pointer to the new stack to use for the 
ApHltLoopCode.
-  @param[in] NumberToFinish   Semaphore of APs finish count.
+  @param[in] ApHltLoopCode  The address of the safe hlt-loop function.
+  @param[in] TopOfStack A pointer to the new stack to use for the 
ApHltLoopCode.
+  @param[in] NumberToFinishAddress  Address of Semaphore of APs finish count.
 
 **/
 VOID
 TransferApToSafeState (
-  IN UINT32 ApHltLoopCode,
-  IN UINT32 TopOfStack,
-  IN UINT32 *NumberToFinish
+  IN UINTN  ApHltLoopCode,
+  IN UINTN  TopOfStack,
+  IN UINTN  NumberToFinishAddress
   );
 
 #endif
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
index d6d6a1a..9fc00c1 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
@@ -129,24 +129,24 @@ GetProtectedModeCS (
 /**
   Transfer AP to safe hlt-loop after it finished 

[edk2] [Patch v2 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to mNumberToFinish

2016-11-17 Thread Michael Kinney
Add volatile qualifier to mNumberToFinish to prevent GCC 5.4
compiler from optimizing away required logic in ACPI S3 resume.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Andrew Fish 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 4af86b7..532b7c4 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -55,7 +55,7 @@ AsmGetAddressMap (
 #define LEGACY_REGION_BASE(0xA - LEGACY_REGION_SIZE)
 
 ACPI_CPU_DATAmAcpiCpuData;
-UINT32   mNumberToFinish;
+volatile UINT32  mNumberToFinish;
 MP_CPU_EXCHANGE_INFO *mExchangeInfo;
 BOOLEAN  mRestoreSmmConfigurationInS3 = FALSE;
 VOID *mGdtForAp = NULL;
-- 
2.6.3.windows.1

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


Re: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to mNumberToFinish

2016-11-17 Thread Kinney, Michael D
Laszlo,

I redid some tests using the following as you suggested, and it works.

  TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, 
(UINTN));

So I will use this style in V2.

Mike

> -Original Message-
> From: Kinney, Michael D
> Sent: Thursday, November 17, 2016 8:06 AM
> To: Laszlo Ersek ; edk2-de...@ml01.01.org; Kinney, Michael 
> D
> 
> Cc: Andrew Fish ; Gao, Liming ; Fan, 
> Jeff
> 
> Subject: RE: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to
> mNumberToFinish
> 
> Laszlo,
> 
> Yes. I can split.  I will send V2 with your feedback.
> 
> For the following line, the cast to (VOID *) before cast to (UINTN) was
> required to pass VS build.  Since mNumberToFinish is a volatile pointer,
> it needs to be cast to a non-volatile pointer before the pointer can be
> converted to an unsigned integer value.
> 
> TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)(VOID
> *));
> 
> Mike
> 
> 
> > -Original Message-
> > From: Laszlo Ersek [mailto:ler...@redhat.com]
> > Sent: Thursday, November 17, 2016 2:22 AM
> > To: Kinney, Michael D ; edk2-de...@ml01.01.org
> > Cc: Andrew Fish ; Gao, Liming ; Fan, 
> > Jeff
> > 
> > Subject: Re: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to
> > mNumberToFinish
> >
> > On 11/17/16 06:34, Michael Kinney wrote:
> > > Add volatile qualifier to mNumberToFinish to prevent compiler
> > > optimization.  Also update TransferApToSafeState() to pass in
> > > UINTN values and treat the mNumberToFinish as an address value
> > > that is passed to the assembly code.
> >
> > Is it possible to split these actions into two patches? One for
> > mNumberToFinish, the other patch for UINTN values.
> >
> > > Cc: Liming Gao 
> > > Cc: Laszlo Ersek 
> > > Cc: Andrew Fish 
> > > Cc: Jeff Fan 
> > > Contributed-under: TianoCore Contribution Agreement 1.0
> > > Signed-off-by: Michael Kinney 
> > > ---
> > >  UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 10 +-
> > >  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 18 +-
> > >  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h| 12 ++--
> > >  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  | 18 +-
> > >  4 files changed, 29 insertions(+), 29 deletions(-)
> > >
> > > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > > index 3fb6864..4531298 100644
> > > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > > @@ -55,7 +55,7 @@ AsmGetAddressMap (
> > >  #define LEGACY_REGION_BASE(0xA - LEGACY_REGION_SIZE)
> > >
> > >  ACPI_CPU_DATAmAcpiCpuData;
> > > -UINT32   mNumberToFinish;
> > > +volatile UINT32  mNumberToFinish;
> > >  MP_CPU_EXCHANGE_INFO *mExchangeInfo;
> > >  BOOLEAN  mRestoreSmmConfigurationInS3 = FALSE;
> > >  VOID *mGdtForAp = NULL;
> > > @@ -385,7 +385,7 @@ MPRendezvousProcedure (
> > >CPU_REGISTER_TABLE *RegisterTableList;
> > >UINT32 InitApicId;
> > >UINTN  Index;
> > > -  UINT32 TopOfStack;
> > > +  UINTN  TopOfStack;
> > >UINT8  Stack[128];
> > >
> > >ProgramVirtualWireMode ();
> > > @@ -403,10 +403,10 @@ MPRendezvousProcedure (
> > >//
> > >// Place AP into the safe code, count down the number with lock 
> > > mechanism in
> the
> > safe code.
> > >//
> > > -  TopOfStack  = (UINT32) (UINTN) Stack + sizeof (Stack);
> > > -  TopOfStack &= ~(UINT32) (CPU_STACK_ALIGNMENT - 1);
> > > +  TopOfStack  = (UINTN) Stack + sizeof (Stack);
> >
> > This change looks good.
> >
> > > +  TopOfStack &= ~(CPU_STACK_ALIGNMENT - 1);
> >
> > Please don't drop the UINT32 cast from before the bit-neg altogether,
> > instead please turn it into a UINTN cast.
> >
> > The reason is that CPU_STACK_ALIGNMENT has type "int", so the bit-neg
> > flips the sign bit too. The resultant value is a negative integer.
> >
> > Due to the two's complement representation, the negative value is
> > actually correct, and when it is converted to UINTN, for the sake of the
> > "&" operation that's inherent in "&=", the behavior is correct. But this
> > silently relies on two's complement, which in my personal opinion is a
> > bad thing. I consider the changing of sign bits with direct bit
> > operations a sin :) -- unless mangling the sign bit is our express
> > purpose -- so I request that we please convert the int value first to
> > the unsigned type with correct width (here, UINTN), and then negate the
> > bits.
> >
> > >CopyMem ((VOID *) (UINTN) mApHltLoopCode, 

[edk2] EDK2 master build failure

2016-11-17 Thread Bhupesh Sharma
Hi EDK2 experts,

I have just rebased my code on the latest EDK2 master branch and now when I am 
trying to compile the same
I am getting the following errors (for my ARMv8 build):

# ./build.sh RELEASE clean; ./build.sh RELEASE
..
Welcome to LS1043A UEFI Build environment
..
Cleaning up the build directory '../../../../Build/LS1043aRdb/'..
..
Welcome to LS1043A UEFI Build environment
..
Initializing workspace
Loading previous configuration from 
/media/sf_VBox-Share/LS1043A/edk2/Conf/BuildEnv.sh
WORKSPACE: /media/sf_VBox-Share/LS1043A/edk2
EDK_TOOLS_PATH: /media/sf_VBox-Share/LS1043A/edk2/BaseTools
CONF_PATH: /media/sf_VBox-Share/LS1043A/edk2/Conf
Copying $EDK_TOOLS_PATH/Conf/tools_def.template
 to /media/sf_VBox-Share/LS1043A/edk2/Conf/tools_def.txt
Build environment: Linux-4.2.0-27-generic-x86_64-with-Ubuntu-14.04-trusty
Build start time: 01:19:30, Nov.18 2016

WORKSPACE= /media/sf_VBox-Share/LS1043A/edk2
ECP_SOURCE   = /media/sf_VBox-Share/LS1043A/edk2/EdkCompatibilityPkg
EDK_SOURCE   = /media/sf_VBox-Share/LS1043A/edk2/EdkCompatibilityPkg
EFI_SOURCE   = /media/sf_VBox-Share/LS1043A/edk2/EdkCompatibilityPkg
EDK_TOOLS_PATH   = /media/sf_VBox-Share/LS1043A/edk2/BaseTools
CONF_PATH= /media/sf_VBox-Share/LS1043A/edk2/Conf


Architecture(s)  = AARCH64
Build target = RELEASE
Toolchain= GCC49

Active Platform  = 
/media/sf_VBox-Share/LS1043A/edk2/OpenPlatformPkg/Platforms/Nxp/LS1043aRdb/LS1043aRdbPkg.dsc
Flash Image Definition   = 
/media/sf_VBox-Share/LS1043A/edk2/OpenPlatformPkg/Platforms/Nxp/LS1043aRdb/LS1043aRdbPkg.fdf

Processing meta-data ... 


build.py...
 : error C0DE: Unknown fatal error when processing 
[/media/sf_VBox-Share/LS1043A/edk2/MdePkg/MdePkg.dec]

(Please send email to edk2-devel@lists.01.org for help, attaching following 
call stack trace!)

(Python 2.7.6 on linux2) Traceback (most recent call last):
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py",
 line 2276, in Main
MyBuild.Launch()
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py",
 line 2028, in Launch
self._MultiThreadBuildPlatform()
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py",
 line 1823, in _MultiThreadBuildPlatform
self.Progress
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py", 
line 176, in __new__
if not AutoGenObject._Init(Workspace, MetaFile, Target, Toolchain, Arch, 
*args, **kwargs):
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py", 
line 464, in _Init
for key in BuildData.Pcds:
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
 line 2469, in _GetPcds
self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
 line 2583, in _GetPcd
if TokenSpaceGuid not in self.Guids:
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
 line 2368, in _GetGuids
Value = GuidValue(CName, self.Packages, self.MetaFile.Path)
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Common/Misc.py", 
line 804, in GuidValue
GuidKeys = P.Guids.keys()
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
 line 1482, in _GetGuid
RecordList = self._RawData[MODEL_EFI_GUID, self._Arch]
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/MetaFileParser.py",
 line 239, in __getitem__
self.Start()
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/MetaFileParser.py",
 line 1671, in Start
self._SectionParser[self._SectionType[0]](self)
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/MetaFileParser.py",
 line 43, in MacroParser
Parser(self)
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Workspace/MetaFileParser.py",
 line 1896, in _PcdParser
IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0])
  File 
"/media/sf_VBox-Share/LS1043A/edk2/BaseTools/Source/Python/Common/Misc.py", 
line 1639, in CheckPcdDatum
Printset = set(string.printable)
AttributeError: 'module' object has no attribute 'printable'


- Failed -
Build end time: 01:19:43,

Is this a known issue?

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


Re: [edk2] [Patch v2 0/3] MdePkg/BaseSynchronizationLib: Add volatile

2016-11-17 Thread Laszlo Ersek
On 11/17/16 20:34, Michael Kinney wrote:
> Updates for V2
> ==
> * Split out patch that corrects function names in comment blocks
> * Change InterlockedCompareExchangePointer() parameter from volatile VOID**
>   to VOID * volatile *.
> * Remove unnessary typecast in calls to InterlockedCompareExchangePointer()
> * Fix missing copyright updates
> * Minor formatting changes
> 
> Michael Kinney (3):
>   MdePkg/Include: Add volatile to SynchronizationLib parameters
>   MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs
>   MdePkg/BaseSynchronizationLib: Fix function names in function headers
> 
>  MdePkg/Include/Library/SynchronizationLib.h  | 14 +++---
>  .../Ia32/InterlockedCompareExchange16.asm|  4 ++--
>  .../Ia32/InterlockedCompareExchange16.c  |  4 ++--
>  .../Ia32/InterlockedCompareExchange16.nasm   |  4 ++--
>  .../Ia32/InterlockedCompareExchange32.asm|  4 ++--
>  .../Ia32/InterlockedCompareExchange32.c  |  4 ++--
>  .../Ia32/InterlockedCompareExchange32.nasm   |  4 ++--
>  .../Ia32/InterlockedCompareExchange64.asm|  4 ++--
>  .../Ia32/InterlockedCompareExchange64.c  |  4 ++--
>  .../Ia32/InterlockedCompareExchange64.nasm   |  4 ++--
>  .../BaseSynchronizationLib/Ia32/InterlockedDecrement.asm |  4 ++--
>  .../BaseSynchronizationLib/Ia32/InterlockedDecrement.c   |  4 ++--
>  .../Ia32/InterlockedDecrement.nasm   |  4 ++--
>  .../BaseSynchronizationLib/Ia32/InterlockedIncrement.asm |  4 ++--
>  .../BaseSynchronizationLib/Ia32/InterlockedIncrement.c   |  4 ++--
>  .../Ia32/InterlockedIncrement.nasm   |  4 ++--
>  MdePkg/Library/BaseSynchronizationLib/Synchronization.c  | 16 
> 
>  .../Library/BaseSynchronizationLib/SynchronizationGcc.c  | 16 
> 
>  .../Library/BaseSynchronizationLib/SynchronizationMsc.c  | 16 
> 
>  .../X64/InterlockedCompareExchange16.asm |  6 +++---
>  .../X64/InterlockedCompareExchange16.c   |  4 ++--
>  .../X64/InterlockedCompareExchange16.nasm|  6 +++---
>  .../X64/InterlockedCompareExchange32.asm |  6 +++---
>  .../X64/InterlockedCompareExchange32.c   |  4 ++--
>  .../X64/InterlockedCompareExchange32.nasm|  6 +++---
>  .../X64/InterlockedCompareExchange64.asm |  6 +++---
>  .../X64/InterlockedCompareExchange64.c   |  4 ++--
>  .../X64/InterlockedCompareExchange64.nasm|  6 +++---
>  .../BaseSynchronizationLib/X64/InterlockedDecrement.asm  |  6 +++---
>  .../BaseSynchronizationLib/X64/InterlockedDecrement.c|  6 +++---
>  .../BaseSynchronizationLib/X64/InterlockedDecrement.nasm |  6 +++---
>  .../BaseSynchronizationLib/X64/InterlockedIncrement.asm  |  6 +++---
>  .../BaseSynchronizationLib/X64/InterlockedIncrement.c|  6 +++---
>  .../BaseSynchronizationLib/X64/InterlockedIncrement.nasm |  6 +++---
>  34 files changed, 103 insertions(+), 103 deletions(-)
> 

series
Reviewed-by: Laszlo Ersek 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 2/2] IntelFsp2Pkg: Use FspSiliconInitDone2 API for the Notify Phase Use FspSiliconInitDone2 API (with error status handling) for the Notify Phase

2016-11-17 Thread Mudusuru, Giri P
Correcting the edk2 mailing list.

> -Original Message-
> From: Mudusuru, Giri P
> Sent: Thursday, November 17, 2016 11:33 AM
> To: Thomaiyar, Richard Marian ; ed2-
> de...@lists.01.org
> Cc: Ma, Maurice ; Yao, Jiewen
> 
> Subject: RE: [PATCH 2/2] IntelFsp2Pkg: Use FspSiliconInitDone2 API for the
> Notify Phase Use FspSiliconInitDone2 API (with error status handling) for the
> Notify Phase
> 
> Reviewed-by: Giri P Mudusuru 
> 
> > -Original Message-
> > From: Thomaiyar, Richard Marian
> > Sent: Wednesday, November 16, 2016 12:51 AM
> > To: ed2-de...@lists.01.org
> > Cc: Ma, Maurice ; Yao, Jiewen
> > ; Mudusuru, Giri P ;
> > Richard; Marian; Thomaiyar
> > Subject: [PATCH 2/2] IntelFsp2Pkg: Use FspSiliconInitDone2 API for the
> > Notify Phase Use FspSiliconInitDone2 API (with error status handling) for
> the
> > Notify Phase
> >
> > Cc: Maurice Ma 
> > Cc: Jiewen Yao 
> > Cc: Giri P Mudusuru 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Richard Marian Thomaiyar
> > 
> > ---
> >  IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> > b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> > index 6acdeb3..41131d5 100644
> > --- a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> > +++ b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> > @@ -81,7 +81,7 @@ WaitForNotify (
> >// Give control back to BootLoader after FspSiliconInit
> >//
> >DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP is waiting for NOTIFY\n"));
> > -  FspSiliconInitDone ();
> > +  FspSiliconInitDone2 (EFI_SUCCESS);
> >
> >//
> >// BootLoader called FSP again through NotifyPhase
> > --
> > 2.9.0.windows.1

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


[edk2] [Patch v2 1/3] MdePkg/Include: Add volatile to SynchronizationLib parameters

2016-11-17 Thread Michael Kinney
The SpinLock functions in the SynchronicationLib use volatile
parameters to keep compiler from optimizing these functions
too much.  The volatile keyword is missing from the Interlocked*()
functions in this same library class.  Update the library class
to consistently use volatile on all functions in this class.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Andrew Fish 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 MdePkg/Include/Library/SynchronizationLib.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/MdePkg/Include/Library/SynchronizationLib.h 
b/MdePkg/Include/Library/SynchronizationLib.h
index 7b97683..6cf3d71 100644
--- a/MdePkg/Include/Library/SynchronizationLib.h
+++ b/MdePkg/Include/Library/SynchronizationLib.h
@@ -1,7 +1,7 @@
 /** @file
   Provides synchronization functions.
 
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -157,7 +157,7 @@ ReleaseSpinLock (
 UINT32
 EFIAPI
 InterlockedIncrement (
-  IN  UINT32*Value
+  IN  volatile UINT32   *Value
   );
 
 
@@ -179,7 +179,7 @@ InterlockedIncrement (
 UINT32
 EFIAPI
 InterlockedDecrement (
-  IN  UINT32*Value
+  IN  volatile UINT32   *Value
   );
 
 
@@ -204,7 +204,7 @@ InterlockedDecrement (
 UINT16
 EFIAPI
 InterlockedCompareExchange16 (
-  IN OUT  UINT16*Value,
+  IN OUT  volatile UINT16   *Value,
   IN  UINT16CompareValue,
   IN  UINT16ExchangeValue
   );
@@ -231,7 +231,7 @@ InterlockedCompareExchange16 (
 UINT32
 EFIAPI
 InterlockedCompareExchange32 (
-  IN OUT  UINT32*Value,
+  IN OUT  volatile UINT32   *Value,
   IN  UINT32CompareValue,
   IN  UINT32ExchangeValue
   );
@@ -258,7 +258,7 @@ InterlockedCompareExchange32 (
 UINT64
 EFIAPI
 InterlockedCompareExchange64 (
-  IN OUT  UINT64*Value,
+  IN OUT  volatile UINT64   *Value,
   IN  UINT64CompareValue,
   IN  UINT64ExchangeValue
   );
@@ -285,7 +285,7 @@ InterlockedCompareExchange64 (
 VOID *
 EFIAPI
 InterlockedCompareExchangePointer (
-  IN OUT  VOID  **Value,
+  IN OUT  VOID  * volatile *Value,
   IN  VOID  *CompareValue,
   IN  VOID  *ExchangeValue
   );
-- 
2.6.3.windows.1

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


[edk2] [Patch v2 0/3] MdePkg/BaseSynchronizationLib: Add volatile

2016-11-17 Thread Michael Kinney
Updates for V2
==
* Split out patch that corrects function names in comment blocks
* Change InterlockedCompareExchangePointer() parameter from volatile VOID**
  to VOID * volatile *.
* Remove unnessary typecast in calls to InterlockedCompareExchangePointer()
* Fix missing copyright updates
* Minor formatting changes

Michael Kinney (3):
  MdePkg/Include: Add volatile to SynchronizationLib parameters
  MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs
  MdePkg/BaseSynchronizationLib: Fix function names in function headers

 MdePkg/Include/Library/SynchronizationLib.h  | 14 +++---
 .../Ia32/InterlockedCompareExchange16.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange16.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange16.nasm   |  4 ++--
 .../Ia32/InterlockedCompareExchange32.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange32.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange32.nasm   |  4 ++--
 .../Ia32/InterlockedCompareExchange64.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange64.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange64.nasm   |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedDecrement.asm |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedDecrement.c   |  4 ++--
 .../Ia32/InterlockedDecrement.nasm   |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedIncrement.asm |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedIncrement.c   |  4 ++--
 .../Ia32/InterlockedIncrement.nasm   |  4 ++--
 MdePkg/Library/BaseSynchronizationLib/Synchronization.c  | 16 
 .../Library/BaseSynchronizationLib/SynchronizationGcc.c  | 16 
 .../Library/BaseSynchronizationLib/SynchronizationMsc.c  | 16 
 .../X64/InterlockedCompareExchange16.asm |  6 +++---
 .../X64/InterlockedCompareExchange16.c   |  4 ++--
 .../X64/InterlockedCompareExchange16.nasm|  6 +++---
 .../X64/InterlockedCompareExchange32.asm |  6 +++---
 .../X64/InterlockedCompareExchange32.c   |  4 ++--
 .../X64/InterlockedCompareExchange32.nasm|  6 +++---
 .../X64/InterlockedCompareExchange64.asm |  6 +++---
 .../X64/InterlockedCompareExchange64.c   |  4 ++--
 .../X64/InterlockedCompareExchange64.nasm|  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedDecrement.asm  |  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedDecrement.c|  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedDecrement.nasm |  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedIncrement.asm  |  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedIncrement.c|  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedIncrement.nasm |  6 +++---
 34 files changed, 103 insertions(+), 103 deletions(-)

-- 
2.6.3.windows.1

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


[edk2] [Patch v2 3/3] MdePkg/BaseSynchronizationLib: Fix function names in function headers

2016-11-17 Thread Michael Kinney
Some of the function names in function header comment blocks in
assembly files do not match the symbol name in the assembly sources.
Update function header comment blocks to match symbol name.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Andrew Fish 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 .../Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.asm | 2 +-
 .../BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm| 2 +-
 .../Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm | 2 +-
 .../BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm| 2 +-
 .../Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm | 2 +-
 .../BaseSynchronizationLib/X64/InterlockedCompareExchange64.nasm| 2 +-
 MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.asm  | 2 +-
 MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.nasm | 2 +-
 MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.asm  | 2 +-
 MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.nasm | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git 
a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.asm 
b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.asm
index e891922..262adeb 100644
--- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.asm
+++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.asm
@@ -27,7 +27,7 @@
 ;--
 ; UINT16
 ; EFIAPI
-; InterlockedCompareExchange16 (
+; InternalSyncCompareExchange16 (
 ;   IN  volatile UINT16   *Value,
 ;   IN  UINT16CompareValue,
 ;   IN  UINT16ExchangeValue
diff --git 
a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm 
b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm
index efe3249..eebed5a 100644
--- 
a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm
+++ 
b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm
@@ -28,7 +28,7 @@
 ;--
 ; UINT16
 ; EFIAPI
-; InterlockedCompareExchange16 (
+; InternalSyncCompareExchange16 (
 ;   IN  volatile UINT16   *Value,
 ;   IN  UINT16CompareValue,
 ;   IN  UINT16ExchangeValue
diff --git 
a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm 
b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm
index 269a3c7..711b399 100644
--- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm
+++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm
@@ -26,7 +26,7 @@
 ;--
 ; UINT32
 ; EFIAPI
-; InterlockedCompareExchange32 (
+; InternalSyncCompareExchange32 (
 ;   IN  volatile UINT32   *Value,
 ;   IN  UINT32CompareValue,
 ;   IN  UINT32ExchangeValue
diff --git 
a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm 
b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm
index 31142d0..5ed4ba5 100644
--- 
a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm
+++ 
b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm
@@ -27,7 +27,7 @@
 ;--
 ; UINT32
 ; EFIAPI
-; InterlockedCompareExchange32 (
+; InternalSyncCompareExchange32 (
 ;   IN  volatile UINT32   *Value,
 ;   IN  UINT32CompareValue,
 ;   IN  UINT32ExchangeValue
diff --git 
a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm 
b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm
index 80d03fd..be429d8 100644
--- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm
+++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm
@@ -26,7 +26,7 @@
 ;--
 ; UINT64
 ; EFIAPI
-; InterlockedCompareExchange64 (
+; InternalSyncCompareExchange64 (
 ;   IN  volatile UINT64   *Value,
 ;   IN  UINT64CompareValue,
 ;   IN  UINT64ExchangeValue
diff --git 
a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.nasm 
b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.nasm
index 

[edk2] [Patch v2 2/3] MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs

2016-11-17 Thread Michael Kinney
The SpinLock functions in the SynchronicationLib use volatile
parameters to keep compiler from optimizing these functions
too much.  The volatile keyword is missing from the Interlocked*()
functions in this same library instance.  Update the library instance
to consistently use volatile on all functions in the
SynchronizationLib class.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Cc: Andrew Fish 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 .../Ia32/InterlockedCompareExchange16.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange16.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange16.nasm   |  4 ++--
 .../Ia32/InterlockedCompareExchange32.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange32.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange32.nasm   |  4 ++--
 .../Ia32/InterlockedCompareExchange64.asm|  4 ++--
 .../Ia32/InterlockedCompareExchange64.c  |  4 ++--
 .../Ia32/InterlockedCompareExchange64.nasm   |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedDecrement.asm |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedDecrement.c   |  4 ++--
 .../Ia32/InterlockedDecrement.nasm   |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedIncrement.asm |  4 ++--
 .../BaseSynchronizationLib/Ia32/InterlockedIncrement.c   |  4 ++--
 .../Ia32/InterlockedIncrement.nasm   |  4 ++--
 MdePkg/Library/BaseSynchronizationLib/Synchronization.c  | 16 
 .../Library/BaseSynchronizationLib/SynchronizationGcc.c  | 16 
 .../Library/BaseSynchronizationLib/SynchronizationMsc.c  | 16 
 .../X64/InterlockedCompareExchange16.asm |  4 ++--
 .../X64/InterlockedCompareExchange16.c   |  4 ++--
 .../X64/InterlockedCompareExchange16.nasm|  4 ++--
 .../X64/InterlockedCompareExchange32.asm |  4 ++--
 .../X64/InterlockedCompareExchange32.c   |  4 ++--
 .../X64/InterlockedCompareExchange32.nasm|  4 ++--
 .../X64/InterlockedCompareExchange64.asm |  4 ++--
 .../X64/InterlockedCompareExchange64.c   |  4 ++--
 .../X64/InterlockedCompareExchange64.nasm|  4 ++--
 .../BaseSynchronizationLib/X64/InterlockedDecrement.asm  |  4 ++--
 .../BaseSynchronizationLib/X64/InterlockedDecrement.c|  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedDecrement.nasm |  4 ++--
 .../BaseSynchronizationLib/X64/InterlockedIncrement.asm  |  4 ++--
 .../BaseSynchronizationLib/X64/InterlockedIncrement.c|  6 +++---
 .../BaseSynchronizationLib/X64/InterlockedIncrement.nasm |  4 ++--
 33 files changed, 86 insertions(+), 86 deletions(-)

diff --git 
a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm 
b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
index 92a0f49..7362fe9 100644
--- 
a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
+++ 
b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
@@ -1,6 +1,6 @@
 ;--
 ;
-; Copyright (c) 2006, Intel Corporation. All rights reserved.
+; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
 ; Copyright (c) 2015, Linaro Ltd. All rights reserved.
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD 
License
@@ -30,7 +30,7 @@
 ; UINT16
 ; EFIAPI
 ; InternalSyncCompareExchange16 (
-;   IN  UINT16*Value,
+;   IN  volatile UINT16   *Value,
 ;   IN  UINT16CompareValue,
 ;   IN  UINT16ExchangeValue
 ;   );
diff --git 
a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.c 
b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.c
index 3d52137..0c3a4f6 100644
--- a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.c
+++ b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.c
@@ -1,7 +1,7 @@
 /** @file
   InterlockedCompareExchange16 function
 
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
   Copyright (c) 2015, Linaro Ltd. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -36,7 +36,7 @@
 UINT16
 EFIAPI
 InternalSyncCompareExchange16 (
-  IN  UINT16*Value,
+  IN  volatile UINT16   *Value,
   IN  UINT16CompareValue,
   IN  UINT16 

Re: [edk2] [PATCH] IntelFsp2Pkg: Use FspSiliconInitDone2 API

2016-11-17 Thread Mudusuru, Giri P
Reviewed-by: Giri P Mudusuru  

> -Original Message-
> From: Thomaiyar, Richard Marian
> Sent: Wednesday, November 16, 2016 1:47 AM
> To: edk2-devel@lists.01.org
> Cc: Ma, Maurice ; Yao, Jiewen
> ; Mudusuru, Giri P ;
> Thomaiyar, Richard Marian 
> Subject: [PATCH] IntelFsp2Pkg: Use FspSiliconInitDone2 API
> 
> Use FspSiliconInitDone2 API in Notify Phase
> 
> Cc: Maurice Ma 
> Cc: Jiewen Yao 
> Cc: Giri P Mudusuru 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Richard Thomaiyar 
> ---
>  IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> index 6acdeb3..41131d5 100644
> --- a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> +++ b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> @@ -81,7 +81,7 @@ WaitForNotify (
>// Give control back to BootLoader after FspSiliconInit
>//
>DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP is waiting for NOTIFY\n"));
> -  FspSiliconInitDone ();
> +  FspSiliconInitDone2 (EFI_SUCCESS);
> 
>//
>// BootLoader called FSP again through NotifyPhase
> --
> 2.9.0.windows.1

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


Re: [edk2] [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs

2016-11-17 Thread Kinney, Michael D
Laszlo,

I agree.  I will do a different patch to fix the function names
in comments.

Mike

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Thursday, November 17, 2016 8:02 AM
> To: Kinney, Michael D ; edk2-de...@ml01.01.org
> Cc: Gao, Liming ; Andrew Fish ; Fan, 
> Jeff
> 
> Subject: Re: [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile 
> Interlocked*()
> APIs
> 
> On 11/17/16 16:55, Kinney, Michael D wrote:
> > Laszlo,
> >
> > Thanks for the feedback.  I will update and send V2.
> >
> > I did not change the names of any functions.  The comment
> > blocks had names that did not match the name of the function,
> > so I was only fixing the comment.
> 
> Ah! Thank you. That's a completely valid set of updates then; but I
> think it should be in a different patch.
> 
> Cheers
> Laszlo
> 
> >> -Original Message-
> >> From: Laszlo Ersek [mailto:ler...@redhat.com]
> >> Sent: Thursday, November 17, 2016 1:21 AM
> >> To: Kinney, Michael D ; edk2-de...@ml01.01.org
> >> Cc: Gao, Liming ; Andrew Fish ; 
> >> Fan, Jeff
> >> 
> >> Subject: Re: [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile
> Interlocked*()
> >> APIs
> >>
> >> On 11/17/16 05:53, Michael Kinney wrote:
> >>> The SpinLock functions in the SynchronicationLib use volatile
> >>> parameters to keep compiler from optimizing these functions
> >>> too much.  The volatile keyword is missing from the Interlocked*()
> >>> functions in this same library instance.  Update the library instance
> >>> to consistently use volatile on all functions in the
> >>> SynchronizationLib class.
> >>>
> >>> Cc: Liming Gao 
> >>> Cc: Laszlo Ersek 
> >>> Cc: Andrew Fish 
> >>> Cc: Jeff Fan 
> >>> Contributed-under: TianoCore Contribution Agreement 1.0
> >>> Signed-off-by: Michael Kinney 
> >>> ---
> >>>  .../Ia32/InterlockedCompareExchange16.asm  |  4 ++--
> >>>  .../Ia32/InterlockedCompareExchange16.c|  4 ++--
> >>>  .../Ia32/InterlockedCompareExchange16.nasm |  4 ++--
> >>>  .../Ia32/InterlockedCompareExchange32.asm  |  4 ++--
> >>>  .../Ia32/InterlockedCompareExchange32.c|  4 ++--
> >>>  .../Ia32/InterlockedCompareExchange32.nasm |  4 ++--
> >>>  .../Ia32/InterlockedCompareExchange64.asm  |  4 ++--
> >>>  .../Ia32/InterlockedCompareExchange64.c|  4 ++--
> >>>  .../Ia32/InterlockedCompareExchange64.nasm |  4 ++--
> >>>  .../Ia32/InterlockedDecrement.asm  |  2 +-
> >>>  .../BaseSynchronizationLib/Ia32/InterlockedDecrement.c |  4 ++--
> >>>  .../Ia32/InterlockedDecrement.nasm |  4 ++--
> >>>  .../Ia32/InterlockedIncrement.asm  |  4 ++--
> >>>  .../BaseSynchronizationLib/Ia32/InterlockedIncrement.c |  4 ++--
> >>>  .../Ia32/InterlockedIncrement.nasm |  4 ++--
> >>>  .../Library/BaseSynchronizationLib/Synchronization.c   | 18 
> >>> +-
> >>>  .../BaseSynchronizationLib/SynchronizationGcc.c| 18 
> >>> +-
> >>>  .../BaseSynchronizationLib/SynchronizationMsc.c| 18 
> >>> +-
> >>>  .../X64/InterlockedCompareExchange16.asm   |  6 +++---
> >>>  .../X64/InterlockedCompareExchange16.c |  4 ++--
> >>>  .../X64/InterlockedCompareExchange16.nasm  |  6 +++---
> >>>  .../X64/InterlockedCompareExchange32.asm   |  6 +++---
> >>>  .../X64/InterlockedCompareExchange32.c |  4 ++--
> >>>  .../X64/InterlockedCompareExchange32.nasm  |  6 +++---
> >>>  .../X64/InterlockedCompareExchange64.asm   |  6 +++---
> >>>  .../X64/InterlockedCompareExchange64.c |  4 ++--
> >>>  .../X64/InterlockedCompareExchange64.nasm  |  4 ++--
> >>>  .../X64/InterlockedDecrement.asm   |  6 +++---
> >>>  .../BaseSynchronizationLib/X64/InterlockedDecrement.c  |  6 +++---
> >>>  .../X64/InterlockedDecrement.nasm  |  6 +++---
> >>>  .../X64/InterlockedIncrement.asm   |  6 +++---
> >>>  .../BaseSynchronizationLib/X64/InterlockedIncrement.c  |  6 +++---
> >>>  .../X64/InterlockedIncrement.nasm  |  6 +++---
> >>>  33 files changed, 97 insertions(+), 97 deletions(-)
> >>>
> >>> diff --git
> >> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> >> b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> >>> index 92a0f49..7362fe9 100644
> >>> --- 
> >>> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> >>> +++ 
> >>> 

Re: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to mNumberToFinish

2016-11-17 Thread Kinney, Michael D
Laszlo,

Yes. I can split.  I will send V2 with your feedback.

For the following line, the cast to (VOID *) before cast to (UINTN) was
required to pass VS build.  Since mNumberToFinish is a volatile pointer,
it needs to be cast to a non-volatile pointer before the pointer can be 
converted to an unsigned integer value.

TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)(VOID 
*));

Mike


> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Thursday, November 17, 2016 2:22 AM
> To: Kinney, Michael D ; edk2-de...@ml01.01.org
> Cc: Andrew Fish ; Gao, Liming ; Fan, 
> Jeff
> 
> Subject: Re: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to
> mNumberToFinish
> 
> On 11/17/16 06:34, Michael Kinney wrote:
> > Add volatile qualifier to mNumberToFinish to prevent compiler
> > optimization.  Also update TransferApToSafeState() to pass in
> > UINTN values and treat the mNumberToFinish as an address value
> > that is passed to the assembly code.
> 
> Is it possible to split these actions into two patches? One for
> mNumberToFinish, the other patch for UINTN values.
> 
> > Cc: Liming Gao 
> > Cc: Laszlo Ersek 
> > Cc: Andrew Fish 
> > Cc: Jeff Fan 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Michael Kinney 
> > ---
> >  UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 10 +-
> >  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 18 +-
> >  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h| 12 ++--
> >  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  | 18 +-
> >  4 files changed, 29 insertions(+), 29 deletions(-)
> >
> > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
> > b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > index 3fb6864..4531298 100644
> > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > @@ -55,7 +55,7 @@ AsmGetAddressMap (
> >  #define LEGACY_REGION_BASE(0xA - LEGACY_REGION_SIZE)
> >
> >  ACPI_CPU_DATAmAcpiCpuData;
> > -UINT32   mNumberToFinish;
> > +volatile UINT32  mNumberToFinish;
> >  MP_CPU_EXCHANGE_INFO *mExchangeInfo;
> >  BOOLEAN  mRestoreSmmConfigurationInS3 = FALSE;
> >  VOID *mGdtForAp = NULL;
> > @@ -385,7 +385,7 @@ MPRendezvousProcedure (
> >CPU_REGISTER_TABLE *RegisterTableList;
> >UINT32 InitApicId;
> >UINTN  Index;
> > -  UINT32 TopOfStack;
> > +  UINTN  TopOfStack;
> >UINT8  Stack[128];
> >
> >ProgramVirtualWireMode ();
> > @@ -403,10 +403,10 @@ MPRendezvousProcedure (
> >//
> >// Place AP into the safe code, count down the number with lock 
> > mechanism in the
> safe code.
> >//
> > -  TopOfStack  = (UINT32) (UINTN) Stack + sizeof (Stack);
> > -  TopOfStack &= ~(UINT32) (CPU_STACK_ALIGNMENT - 1);
> > +  TopOfStack  = (UINTN) Stack + sizeof (Stack);
> 
> This change looks good.
> 
> > +  TopOfStack &= ~(CPU_STACK_ALIGNMENT - 1);
> 
> Please don't drop the UINT32 cast from before the bit-neg altogether,
> instead please turn it into a UINTN cast.
> 
> The reason is that CPU_STACK_ALIGNMENT has type "int", so the bit-neg
> flips the sign bit too. The resultant value is a negative integer.
> 
> Due to the two's complement representation, the negative value is
> actually correct, and when it is converted to UINTN, for the sake of the
> "&" operation that's inherent in "&=", the behavior is correct. But this
> silently relies on two's complement, which in my personal opinion is a
> bad thing. I consider the changing of sign bits with direct bit
> operations a sin :) -- unless mangling the sign bit is our express
> purpose -- so I request that we please convert the int value first to
> the unsigned type with correct width (here, UINTN), and then negate the
> bits.
> 
> >CopyMem ((VOID *) (UINTN) mApHltLoopCode, mApHltLoopCodeTemplate, sizeof
> (mApHltLoopCodeTemplate));
> > -  TransferApToSafeState ((UINT32) (UINTN) mApHltLoopCode, TopOfStack,
> );
> > +  TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)(VOID
> *));
> >  }
> >
> >  /**
> 
> The (VOID*) cast is unnecessary here (in the last arg), any pointer can
> be cast to UINTN directly.
> 
> > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> > index 9760373..d57eb33 100644
> > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> > @@ -98,23 +98,23 @@ InitGdt (
> >  /**
> >Transfer AP to safe hlt-loop after it finished restore CPU features on 
> > S3 patch.
> >
> > -  @param[in] ApHltLoopCodeThe 32-bit 

Re: [edk2] [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus semicolon from GUID def

2016-11-17 Thread Laszlo Ersek
On 11/17/16 15:27, Mudusuru, Giri P wrote:
> Thank you for fixing it.
> Reviewed-by: Giri P Mudusuru 

Thanks! I was eager and already committed it with Jiewen's R-b.

Cheers!
Laszlo

>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Thursday, November 17, 2016 2:37 AM
>> To: edk2-devel-01 
>> Cc: Mudusuru, Giri P ; Yao, Jiewen
>> 
>> Subject: [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus semicolon 
>> from
>> GUID def
>>
>> The DEC spec doesn't allow the trailing semicolon:
>>
>>   2.6 [Guids] Usage
>>
>>   GuidCName = {C Format Guid Value} # Comment
>>
>> Cc: Giri P Mudusuru 
>> Cc: Jiewen Yao 
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek 
>> ---
>>  IntelSiliconPkg/IntelSiliconPkg.dec | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/IntelSiliconPkg/IntelSiliconPkg.dec
>> b/IntelSiliconPkg/IntelSiliconPkg.dec
>> index 4a51d0a547da..8819cb8fed6b 100644
>> --- a/IntelSiliconPkg/IntelSiliconPkg.dec
>> +++ b/IntelSiliconPkg/IntelSiliconPkg.dec
>> @@ -26,7 +26,7 @@ [Includes]
>>  [Guids]
>>## GUID for Package token space
>># {A9F8D54E-1107-4F0A-ADD0-4587E7A4A735}
>> -  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a, { 0xad,
>> 0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } };
>> +  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a, { 0xad,
>> 0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } }
>>
>>## HOB GUID to publish SMBIOS data records from PEI phase
>># HOB data format is same as SMBIOS records defined in SMBIOS spec or OEM
>> defined types
>> --
>> 2.9.2
> 

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


Re: [edk2] OVMF: cross-filesystem copy broken? ("The source and destination are the same")

2016-11-17 Thread Laszlo Ersek
On 11/17/16 16:24, Bruce Cran wrote:
> On 11/17/2016 2:35 AM, Laszlo Ersek wrote:
> 
>> There's a patch on the list for said BZ:
>> [edk2] [PATCH v2] API PathRemoveLastItem not handle root paths properly
>>
>> so if the BZ is indeed what you're encountering, then the patch should
>> fix it for you. Can you please test it and report back in that thread?
> 
> Unfortunately the patch doesn't fix the problem I'm seeing.
> 

Thanks for trying it.

Unfortunately, I can't find the time to dig into this now. And, I think
it's likely related to ShellPkg anyway. Can you please help by filing a
BZ for ShellPkg, and/or bisecting the issue (assuming you remember the
same command working at some point)?

... I observe that the least recent commit that affected "Cp.c" with any
potential to break it like this could be

commit fbd2dfadfe6fb16ab7b49fca3764e05e65d97b8a
Author: Qiu Shumin 
Date:   Fri Oct 23 02:03:20 2015 +

ShellPkg: Follow spec to remove the last '\' char in return name of
GetCurDir().

but that commit is more than a year old now... So I'm not sure. Could be
one of the underlying helper functions. Time to pull out GDB and single
step the code? :)

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


Re: [edk2] [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs

2016-11-17 Thread Laszlo Ersek
On 11/17/16 16:55, Kinney, Michael D wrote:
> Laszlo,
> 
> Thanks for the feedback.  I will update and send V2.
> 
> I did not change the names of any functions.  The comment
> blocks had names that did not match the name of the function,
> so I was only fixing the comment. 

Ah! Thank you. That's a completely valid set of updates then; but I
think it should be in a different patch.

Cheers
Laszlo

>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Thursday, November 17, 2016 1:21 AM
>> To: Kinney, Michael D ; edk2-de...@ml01.01.org
>> Cc: Gao, Liming ; Andrew Fish ; Fan, 
>> Jeff
>> 
>> Subject: Re: [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile 
>> Interlocked*()
>> APIs
>>
>> On 11/17/16 05:53, Michael Kinney wrote:
>>> The SpinLock functions in the SynchronicationLib use volatile
>>> parameters to keep compiler from optimizing these functions
>>> too much.  The volatile keyword is missing from the Interlocked*()
>>> functions in this same library instance.  Update the library instance
>>> to consistently use volatile on all functions in the
>>> SynchronizationLib class.
>>>
>>> Cc: Liming Gao 
>>> Cc: Laszlo Ersek 
>>> Cc: Andrew Fish 
>>> Cc: Jeff Fan 
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Michael Kinney 
>>> ---
>>>  .../Ia32/InterlockedCompareExchange16.asm  |  4 ++--
>>>  .../Ia32/InterlockedCompareExchange16.c|  4 ++--
>>>  .../Ia32/InterlockedCompareExchange16.nasm |  4 ++--
>>>  .../Ia32/InterlockedCompareExchange32.asm  |  4 ++--
>>>  .../Ia32/InterlockedCompareExchange32.c|  4 ++--
>>>  .../Ia32/InterlockedCompareExchange32.nasm |  4 ++--
>>>  .../Ia32/InterlockedCompareExchange64.asm  |  4 ++--
>>>  .../Ia32/InterlockedCompareExchange64.c|  4 ++--
>>>  .../Ia32/InterlockedCompareExchange64.nasm |  4 ++--
>>>  .../Ia32/InterlockedDecrement.asm  |  2 +-
>>>  .../BaseSynchronizationLib/Ia32/InterlockedDecrement.c |  4 ++--
>>>  .../Ia32/InterlockedDecrement.nasm |  4 ++--
>>>  .../Ia32/InterlockedIncrement.asm  |  4 ++--
>>>  .../BaseSynchronizationLib/Ia32/InterlockedIncrement.c |  4 ++--
>>>  .../Ia32/InterlockedIncrement.nasm |  4 ++--
>>>  .../Library/BaseSynchronizationLib/Synchronization.c   | 18 
>>> +-
>>>  .../BaseSynchronizationLib/SynchronizationGcc.c| 18 
>>> +-
>>>  .../BaseSynchronizationLib/SynchronizationMsc.c| 18 
>>> +-
>>>  .../X64/InterlockedCompareExchange16.asm   |  6 +++---
>>>  .../X64/InterlockedCompareExchange16.c |  4 ++--
>>>  .../X64/InterlockedCompareExchange16.nasm  |  6 +++---
>>>  .../X64/InterlockedCompareExchange32.asm   |  6 +++---
>>>  .../X64/InterlockedCompareExchange32.c |  4 ++--
>>>  .../X64/InterlockedCompareExchange32.nasm  |  6 +++---
>>>  .../X64/InterlockedCompareExchange64.asm   |  6 +++---
>>>  .../X64/InterlockedCompareExchange64.c |  4 ++--
>>>  .../X64/InterlockedCompareExchange64.nasm  |  4 ++--
>>>  .../X64/InterlockedDecrement.asm   |  6 +++---
>>>  .../BaseSynchronizationLib/X64/InterlockedDecrement.c  |  6 +++---
>>>  .../X64/InterlockedDecrement.nasm  |  6 +++---
>>>  .../X64/InterlockedIncrement.asm   |  6 +++---
>>>  .../BaseSynchronizationLib/X64/InterlockedIncrement.c  |  6 +++---
>>>  .../X64/InterlockedIncrement.nasm  |  6 +++---
>>>  33 files changed, 97 insertions(+), 97 deletions(-)
>>>
>>> diff --git
>> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
>> b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
>>> index 92a0f49..7362fe9 100644
>>> --- 
>>> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
>>> +++ 
>>> b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
>>> @@ -1,6 +1,6 @@
>>>  
>>> ;--
>>>  ;
>>> -; Copyright (c) 2006, Intel Corporation. All rights reserved.
>>> +; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
>>>  ; Copyright (c) 2015, Linaro Ltd. All rights reserved.
>>>  ; This program and the accompanying materials
>>>  ; are licensed and made available under the terms and conditions of the BSD
>> License
>>> @@ -30,7 +30,7 @@
>>>  ; UINT16
>>>  ; EFIAPI
>>>  ; InternalSyncCompareExchange16 (
>>> -;   IN  UINT16*Value,
>>> +;   IN  volatile UINT16   

Re: [edk2] [PATCH V2] Add 4K PE alignment to enable SMM page level protection.

2016-11-17 Thread Laszlo Ersek
On 11/17/16 14:40, Jiewen Yao wrote:
> Tested boot with below configuration:
> IA32
> IA32X64
> X64
> 
> Tested boot with XD enabled/disabled.
> 
> Requested-by: Laszlo Ersek 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 5 +
>  OvmfPkg/OvmfPkgIa32X64.dsc | 5 +
>  OvmfPkg/OvmfPkgX64.dsc | 5 +
>  3 files changed, 15 insertions(+)

I have two requests before you commit the patch:
(1) please prefix the subject line with "OvmfPkg: ",
(2) please commit this patch only after you commit the patch
"UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX."

Please do not forget these requests.

Tested-by: Laszlo Ersek 
Reviewed-by: Laszlo Ersek 

Thank you,
Laszlo


> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 3f4d42d..ed43c45 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -56,6 +56,11 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>  
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level
> +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 5688475..ccd156d 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -61,6 +61,11 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>  
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level
> +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index dcf64b9..012ce85 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -61,6 +61,11 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>  
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level
> +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> 

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


Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.

2016-11-17 Thread Laszlo Ersek
On 11/17/16 14:33, Jiewen Yao wrote:
> When XD is not supported, the BIT63 is reserved.
> We should not set BIT63 in the page table.
> 
> Test OVMF IA32/IA32X64 with XD enabled/disabled.
> 
> Analyzed-by: Laszlo Ersek 
> Cc: Laszlo Ersek 
> Cc: Jeff Fan 
> Cc: Michael D Kinney 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> index b4f8861..c85e025 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> @@ -209,10 +209,12 @@ ConvertPageEntryAttribute (
>  }
>}
>if ((Attributes & EFI_MEMORY_XP) != 0) {
> -if (IsSet) {
> -  NewPageEntry |= IA32_PG_NX;
> -} else {
> -  NewPageEntry &= ~IA32_PG_NX;
> +if (mXdSupported) {
> +  if (IsSet) {
> +NewPageEntry |= IA32_PG_NX;
> +  } else {
> +NewPageEntry &= ~IA32_PG_NX;
> +  }
>  }
>}
>*PageEntry = NewPageEntry;
> 

Tested-by: Laszlo Ersek 

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


Re: [edk2] [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs

2016-11-17 Thread Kinney, Michael D
Laszlo,

Thanks for the feedback.  I will update and send V2.

I did not change the names of any functions.  The comment
blocks had names that did not match the name of the function,
so I was only fixing the comment. 

Mike
 
> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Thursday, November 17, 2016 1:21 AM
> To: Kinney, Michael D ; edk2-de...@ml01.01.org
> Cc: Gao, Liming ; Andrew Fish ; Fan, 
> Jeff
> 
> Subject: Re: [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile 
> Interlocked*()
> APIs
> 
> On 11/17/16 05:53, Michael Kinney wrote:
> > The SpinLock functions in the SynchronicationLib use volatile
> > parameters to keep compiler from optimizing these functions
> > too much.  The volatile keyword is missing from the Interlocked*()
> > functions in this same library instance.  Update the library instance
> > to consistently use volatile on all functions in the
> > SynchronizationLib class.
> >
> > Cc: Liming Gao 
> > Cc: Laszlo Ersek 
> > Cc: Andrew Fish 
> > Cc: Jeff Fan 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Michael Kinney 
> > ---
> >  .../Ia32/InterlockedCompareExchange16.asm  |  4 ++--
> >  .../Ia32/InterlockedCompareExchange16.c|  4 ++--
> >  .../Ia32/InterlockedCompareExchange16.nasm |  4 ++--
> >  .../Ia32/InterlockedCompareExchange32.asm  |  4 ++--
> >  .../Ia32/InterlockedCompareExchange32.c|  4 ++--
> >  .../Ia32/InterlockedCompareExchange32.nasm |  4 ++--
> >  .../Ia32/InterlockedCompareExchange64.asm  |  4 ++--
> >  .../Ia32/InterlockedCompareExchange64.c|  4 ++--
> >  .../Ia32/InterlockedCompareExchange64.nasm |  4 ++--
> >  .../Ia32/InterlockedDecrement.asm  |  2 +-
> >  .../BaseSynchronizationLib/Ia32/InterlockedDecrement.c |  4 ++--
> >  .../Ia32/InterlockedDecrement.nasm |  4 ++--
> >  .../Ia32/InterlockedIncrement.asm  |  4 ++--
> >  .../BaseSynchronizationLib/Ia32/InterlockedIncrement.c |  4 ++--
> >  .../Ia32/InterlockedIncrement.nasm |  4 ++--
> >  .../Library/BaseSynchronizationLib/Synchronization.c   | 18 
> > +-
> >  .../BaseSynchronizationLib/SynchronizationGcc.c| 18 
> > +-
> >  .../BaseSynchronizationLib/SynchronizationMsc.c| 18 
> > +-
> >  .../X64/InterlockedCompareExchange16.asm   |  6 +++---
> >  .../X64/InterlockedCompareExchange16.c |  4 ++--
> >  .../X64/InterlockedCompareExchange16.nasm  |  6 +++---
> >  .../X64/InterlockedCompareExchange32.asm   |  6 +++---
> >  .../X64/InterlockedCompareExchange32.c |  4 ++--
> >  .../X64/InterlockedCompareExchange32.nasm  |  6 +++---
> >  .../X64/InterlockedCompareExchange64.asm   |  6 +++---
> >  .../X64/InterlockedCompareExchange64.c |  4 ++--
> >  .../X64/InterlockedCompareExchange64.nasm  |  4 ++--
> >  .../X64/InterlockedDecrement.asm   |  6 +++---
> >  .../BaseSynchronizationLib/X64/InterlockedDecrement.c  |  6 +++---
> >  .../X64/InterlockedDecrement.nasm  |  6 +++---
> >  .../X64/InterlockedIncrement.asm   |  6 +++---
> >  .../BaseSynchronizationLib/X64/InterlockedIncrement.c  |  6 +++---
> >  .../X64/InterlockedIncrement.nasm  |  6 +++---
> >  33 files changed, 97 insertions(+), 97 deletions(-)
> >
> > diff --git
> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> > index 92a0f49..7362fe9 100644
> > --- 
> > a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> > +++ 
> > b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> > @@ -1,6 +1,6 @@
> >  
> > ;--
> >  ;
> > -; Copyright (c) 2006, Intel Corporation. All rights reserved.
> > +; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
> >  ; Copyright (c) 2015, Linaro Ltd. All rights reserved.
> >  ; This program and the accompanying materials
> >  ; are licensed and made available under the terms and conditions of the BSD
> License
> > @@ -30,7 +30,7 @@
> >  ; UINT16
> >  ; EFIAPI
> >  ; InternalSyncCompareExchange16 (
> > -;   IN  UINT16*Value,
> > +;   IN  volatile UINT16   *Value,
> >  ;   IN  UINT16CompareValue,
> >  ;   IN  UINT16ExchangeValue
> >  ;   );
> > diff --git
> 

Re: [edk2] OVMF: cross-filesystem copy broken? ("The source and destination are the same")

2016-11-17 Thread Bruce Cran

On 11/17/2016 2:35 AM, Laszlo Ersek wrote:


There's a patch on the list for said BZ:
[edk2] [PATCH v2] API PathRemoveLastItem not handle root paths properly

so if the BZ is indeed what you're encountering, then the patch should
fix it for you. Can you please test it and report back in that thread?


Unfortunately the patch doesn't fix the problem I'm seeing.

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


Re: [edk2] [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus semicolon from GUID def

2016-11-17 Thread Mudusuru, Giri P
Thank you for fixing it.
Reviewed-by: Giri P Mudusuru 


> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Thursday, November 17, 2016 2:37 AM
> To: edk2-devel-01 
> Cc: Mudusuru, Giri P ; Yao, Jiewen
> 
> Subject: [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus semicolon 
> from
> GUID def
> 
> The DEC spec doesn't allow the trailing semicolon:
> 
>   2.6 [Guids] Usage
> 
>   GuidCName = {C Format Guid Value} # Comment
> 
> Cc: Giri P Mudusuru 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek 
> ---
>  IntelSiliconPkg/IntelSiliconPkg.dec | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/IntelSiliconPkg/IntelSiliconPkg.dec
> b/IntelSiliconPkg/IntelSiliconPkg.dec
> index 4a51d0a547da..8819cb8fed6b 100644
> --- a/IntelSiliconPkg/IntelSiliconPkg.dec
> +++ b/IntelSiliconPkg/IntelSiliconPkg.dec
> @@ -26,7 +26,7 @@ [Includes]
>  [Guids]
>## GUID for Package token space
># {A9F8D54E-1107-4F0A-ADD0-4587E7A4A735}
> -  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a, { 0xad,
> 0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } };
> +  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a, { 0xad,
> 0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } }
> 
>## HOB GUID to publish SMBIOS data records from PEI phase
># HOB data format is same as SMBIOS records defined in SMBIOS spec or OEM
> defined types
> --
> 2.9.2

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


Re: [edk2] [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus semicolon from GUID def

2016-11-17 Thread Laszlo Ersek
On 11/17/16 13:04, Yao, Jiewen wrote:
> Reviewed-by: jiewen@intel.com

Thanks! Commit 2048ab4b3ec9.

Laszlo

> 
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>> Laszlo Ersek
>> Sent: Thursday, November 17, 2016 6:37 PM
>> To: edk2-devel-01 
>> Cc: Yao, Jiewen 
>> Subject: [edk2] [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus
>> semicolon from GUID def
>>
>> The DEC spec doesn't allow the trailing semicolon:
>>
>>   2.6 [Guids] Usage
>>
>>   GuidCName = {C Format Guid Value} # Comment
>>
>> Cc: Giri P Mudusuru 
>> Cc: Jiewen Yao 
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek 
>> ---
>>  IntelSiliconPkg/IntelSiliconPkg.dec | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/IntelSiliconPkg/IntelSiliconPkg.dec
>> b/IntelSiliconPkg/IntelSiliconPkg.dec
>> index 4a51d0a547da..8819cb8fed6b 100644
>> --- a/IntelSiliconPkg/IntelSiliconPkg.dec
>> +++ b/IntelSiliconPkg/IntelSiliconPkg.dec
>> @@ -26,7 +26,7 @@ [Includes]
>>  [Guids]
>>## GUID for Package token space
>># {A9F8D54E-1107-4F0A-ADD0-4587E7A4A735}
>> -  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a, { 0xad,
>> 0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } };
>> +  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a,
>> { 0xad, 0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } }
>>
>>## HOB GUID to publish SMBIOS data records from PEI phase
>># HOB data format is same as SMBIOS records defined in SMBIOS spec or
>> OEM defined types
>> --
>> 2.9.2
>>
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel

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


Re: [edk2] [PATCH] OvmfPkg/dsc: enable SMM page level protection.

2016-11-17 Thread Yao, Jiewen
Both patches are submitted.

I will discuss with Jeff tomorrow to see how we can improve the debug message.
-- "Stack Overflow" for "XD page fault" is definitely a misreport. :(

Thank you
Yao Jiewen

From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yao, 
Jiewen
Sent: Thursday, November 17, 2016 9:21 PM
To: Laszlo Ersek ; edk2-de...@ml01.01.org
Cc: Justen, Jordan L 
Subject: Re: [edk2] [PATCH] OvmfPkg/dsc: enable SMM page level protection.

Yes, Laszlo.
You are right. Thanks to catch this.

I will 1) Submit a new patch to fix XD issue.
2) Submit V2 patch for OVMF.

From: Laszlo Ersek [mailto:ler...@redhat.com]
Sent: Thursday, November 17, 2016 8:18 PM
To: Yao, Jiewen >; 
edk2-de...@ml01.01.org
Cc: Justen, Jordan L 
>
Subject: Re: [edk2] [PATCH] OvmfPkg/dsc: enable SMM page level protection.

On 11/17/16 09:21, Jiewen Yao wrote:
> Add 4K PE alignment to enable SMM page level protection.
>
> Tested boot with below configuration:
> IA32
> IA32X64
> X64
>
> Requested-by: Laszlo Ersek 
> >>
> Cc: Jordan Justen 
> >>
> Cc: Laszlo Ersek 
> >>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> >>
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 4 
>  OvmfPkg/OvmfPkgIa32X64.dsc | 4 
>  OvmfPkg/OvmfPkgX64.dsc | 4 
>  3 files changed, 12 insertions(+)
>
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 3f4d42d..59c0f09 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -56,6 +56,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 5688475..226842a 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -61,6 +61,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index dcf64b9..ec97ba8 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -61,6 +61,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
>

Thank you for submitting the patch!

(1) Please wrap the new comments in the DSC files at 79 characters, like this:

#
# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
# protection of DXE_SMM_DRIVER/SMM_CORE modules
#

(2) The Ia32 SMM build of OVMF seems to expose a problem in the page level 
protection code. I will paste the full OVMF log below. My analysis is the 
following (in advance):

* The SMRAM regions provided on Q35 are:

SmmAccessPeiEntryPoint: SMRAM map follows, 2 entries
   PhysicalStart(0x) PhysicalSize(0x) CpuStart(0x)  
RegionState(0x)
7F80 1000 7F80  
 1A
7F801000   7FF000 7F801000  
  A

* The first page is used for holding 

[edk2] [PATCH V2] Add 4K PE alignment to enable SMM page level protection.

2016-11-17 Thread Jiewen Yao
Tested boot with below configuration:
IA32
IA32X64
X64

Tested boot with XD enabled/disabled.

Requested-by: Laszlo Ersek 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 OvmfPkg/OvmfPkgIa32.dsc| 5 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 5 +
 OvmfPkg/OvmfPkgX64.dsc | 5 +
 3 files changed, 15 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 3f4d42d..ed43c45 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -56,6 +56,11 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
 
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_SMM_DRIVER/SMM_CORE modules
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 

 #
 # SKU Identification section - list of all SKU IDs supported by this Platform.
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 5688475..ccd156d 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -61,6 +61,11 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
 
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_SMM_DRIVER/SMM_CORE modules
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 

 #
 # SKU Identification section - list of all SKU IDs supported by this Platform.
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index dcf64b9..012ce85 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -61,6 +61,11 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
 
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_SMM_DRIVER/SMM_CORE modules
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 

 #
 # SKU Identification section - list of all SKU IDs supported by this Platform.
-- 
2.7.4.windows.1

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


[edk2] [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX.

2016-11-17 Thread Jiewen Yao
When XD is not supported, the BIT63 is reserved.
We should not set BIT63 in the page table.

Test OVMF IA32/IA32X64 with XD enabled/disabled.

Analyzed-by: Laszlo Ersek 
Cc: Laszlo Ersek 
Cc: Jeff Fan 
Cc: Michael D Kinney 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
index b4f8861..c85e025 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
@@ -209,10 +209,12 @@ ConvertPageEntryAttribute (
 }
   }
   if ((Attributes & EFI_MEMORY_XP) != 0) {
-if (IsSet) {
-  NewPageEntry |= IA32_PG_NX;
-} else {
-  NewPageEntry &= ~IA32_PG_NX;
+if (mXdSupported) {
+  if (IsSet) {
+NewPageEntry |= IA32_PG_NX;
+  } else {
+NewPageEntry &= ~IA32_PG_NX;
+  }
 }
   }
   *PageEntry = NewPageEntry;
-- 
2.7.4.windows.1

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


Re: [edk2] [PATCH] OvmfPkg/dsc: enable SMM page level protection.

2016-11-17 Thread Yao, Jiewen
Yes, Laszlo.
You are right. Thanks to catch this.

I will 1) Submit a new patch to fix XD issue.
2) Submit V2 patch for OVMF.

From: Laszlo Ersek [mailto:ler...@redhat.com]
Sent: Thursday, November 17, 2016 8:18 PM
To: Yao, Jiewen ; edk2-de...@ml01.01.org
Cc: Justen, Jordan L 
Subject: Re: [edk2] [PATCH] OvmfPkg/dsc: enable SMM page level protection.

On 11/17/16 09:21, Jiewen Yao wrote:
> Add 4K PE alignment to enable SMM page level protection.
>
> Tested boot with below configuration:
> IA32
> IA32X64
> X64
>
> Requested-by: Laszlo Ersek >
> Cc: Jordan Justen 
> >
> Cc: Laszlo Ersek >
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao >
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 4 
>  OvmfPkg/OvmfPkgIa32X64.dsc | 4 
>  OvmfPkg/OvmfPkgX64.dsc | 4 
>  3 files changed, 12 insertions(+)
>
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 3f4d42d..59c0f09 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -56,6 +56,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 5688475..226842a 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -61,6 +61,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index dcf64b9..ec97ba8 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -61,6 +61,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
>

Thank you for submitting the patch!

(1) Please wrap the new comments in the DSC files at 79 characters, like this:

#
# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
# protection of DXE_SMM_DRIVER/SMM_CORE modules
#

(2) The Ia32 SMM build of OVMF seems to expose a problem in the page level 
protection code. I will paste the full OVMF log below. My analysis is the 
following (in advance):

* The SMRAM regions provided on Q35 are:

SmmAccessPeiEntryPoint: SMRAM map follows, 2 entries
   PhysicalStart(0x) PhysicalSize(0x) CpuStart(0x)  
RegionState(0x)
7F80 1000 7F80  
 1A
7F801000   7FF000 7F801000  
  A

* The first page is used for holding the SMM_S3_RESUME_STATE object, and it is 
reported as EFI_ALLOCATED up-front. The second region is exposed to the SMM 
stack as usable/free SMRAM.

The SMM core and the SMM drivers are loaded in the second region, from high 
addresses downwards (top-down method). A good chunk of SMRAM (near 0x7F801000) 
remains free, by the time the SMM page level protection kicks in.

* The code starts setting the NX bit on page table entries that map the free 
(unused) SMRAM range. However, at a certain point, it seems to overflow to (or 
validly reach?) page table entries that map the memory attributes table itself. 
The next access to the memory attributes table causes a page fault.

* The page fault is finally mis-reported as an SMM stack overflow, because the 
fault handler simply checks if the fault address falls within SMRAM.

(3) Shouldn't the page 

Re: [edk2] [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size

2016-11-17 Thread Yao, Jiewen
Hi star
I am sorry that I am confused on this patch.

1) Below update is not related to the GIT message.
I think there is nothing wrong with previous code. May I know if you observe 
something?

> -DigestBuffer = CopyDigestListToBuffer (DigestBuffer, DigestList,
> mTcgDxeData.BsCap.ActivePcrBanks);
> -CopyMem (DigestBuffer, >EventSize,
> sizeof(NewEventHdr->EventSize));
> -DigestBuffer = DigestBuffer + sizeof(NewEventHdr->EventSize);
> +EventSizePtr = CopyDigestListToBuffer (DigestBuffer, DigestList,
> mTcgDxeData.BsCap.ActivePcrBanks);
> +CopyMem (EventSizePtr, >EventSize,
> sizeof(NewEventHdr->EventSize));

2) I believe "GetDigestListSize (DigestList)" should be same as 
"GetDigestListBinSize (DigestBuffer)"
May I know how did you observe such error?


Thank you
Yao Jiewen



> -Original Message-
> From: Zeng, Star
> Sent: Thursday, November 17, 2016 5:27 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Yao, Jiewen ;
> Zhang, Chao B 
> Subject: [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size
> 
> Current code uses GetDigestListSize(DigestList) to get
> digest list size, that is incorrect.
> The code should get digest list size of digests copied
> into event2 log, those digests are compacted, so
> GetDigestListBinSize() should be used.
> 
> Cc: Jiewen Yao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> index d5a32307db6e..f4740a3c 100644
> --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> @@ -970,6 +970,7 @@ TcgDxeLogHashEvent (
>EFI_STATUSRetStatus;
>TCG_PCR_EVENT2TcgPcrEvent2;
>UINT8 *DigestBuffer;
> +  UINT32*EventSizePtr;
> 
>DEBUG ((EFI_D_INFO, "SupportedEventLogs - 0x%08x\n",
> mTcgDxeData.BsCap.SupportedEventLogs));
> 
> @@ -1006,9 +1007,8 @@ TcgDxeLogHashEvent (
>  TcgPcrEvent2.PCRIndex = NewEventHdr->PCRIndex;
>  TcgPcrEvent2.EventType = NewEventHdr->EventType;
>  DigestBuffer = (UINT8 *)
> -DigestBuffer = CopyDigestListToBuffer (DigestBuffer, DigestList,
> mTcgDxeData.BsCap.ActivePcrBanks);
> -CopyMem (DigestBuffer, >EventSize,
> sizeof(NewEventHdr->EventSize));
> -DigestBuffer = DigestBuffer + sizeof(NewEventHdr->EventSize);
> +EventSizePtr = CopyDigestListToBuffer (DigestBuffer, DigestList,
> mTcgDxeData.BsCap.ActivePcrBanks);
> +CopyMem (EventSizePtr, >EventSize,
> sizeof(NewEventHdr->EventSize));
> 
>  //
>  // Enter critical region
> @@ -1017,7 +1017,7 @@ TcgDxeLogHashEvent (
>  Status = TcgDxeLogEvent (
> mTcg2EventInfo[Index].LogFormat,
> ,
> -   sizeof(TcgPcrEvent2.PCRIndex) +
> sizeof(TcgPcrEvent2.EventType) + GetDigestListSize (DigestList) +
> sizeof(TcgPcrEvent2.EventSize),
> +   sizeof(TcgPcrEvent2.PCRIndex) +
> sizeof(TcgPcrEvent2.EventType) + GetDigestListBinSize (DigestBuffer) +
> sizeof(TcgPcrEvent2.EventSize),
> NewEventData,
> NewEventHdr->EventSize
> );
> --
> 2.7.0.windows.1

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


Re: [edk2] [PATCH 1/2] SecurityPkg TPM2: Make IsHashAlgSupportedInHashAlgorithmMask external

2016-11-17 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Zeng, Star
> Sent: Thursday, November 17, 2016 5:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Yao, Jiewen ;
> Zhang, Chao B 
> Subject: [PATCH 1/2] SecurityPkg TPM2: Make
> IsHashAlgSupportedInHashAlgorithmMask external
> 
> Current IsHashAlgSupportedInHashAlgorithmMask is only an internal
> function, this patch makes it external for coming consumer.
> 
> Cc: Jiewen Yao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  SecurityPkg/Include/Library/Tpm2CommandLib.h  | 16
> 
>  SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c |  1 +
>  2 files changed, 17 insertions(+)
> 
> diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h
> b/SecurityPkg/Include/Library/Tpm2CommandLib.h
> index 9a1dd8d8aceb..85a4c65e0263 100644
> --- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
> +++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
> @@ -1007,6 +1007,22 @@ GetHashSizeFromAlgo (
>);
> 
>  /**
> +  Return if hash alg is supported in HashAlgorithmMask.
> +
> +  @param HashAlgHash algorithm to be checked.
> +  @param HashAlgorithmMask  Bitfield of allowed hash algorithms.
> +
> +  @retval TRUE  Hash algorithm is supported.
> +  @retval FALSE Hash algorithm is not supported.
> +**/
> +BOOLEAN
> +EFIAPI
> +IsHashAlgSupportedInHashAlgorithmMask(
> +  IN TPMI_ALG_HASH  HashAlg,
> +  IN UINT32 HashAlgorithmMask
> +  );
> +
> +/**
>Copy TPML_DIGEST_VALUES into a buffer
> 
>@param[in,out] Buffer Buffer to hold
> TPML_DIGEST_VALUES.
> diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> index be95fd69b3dd..95d4f7c84ce9 100644
> --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> @@ -175,6 +175,7 @@ CopyAuthSessionResponse (
>@retval FALSE Hash algorithm is not supported.
>  **/
>  BOOLEAN
> +EFIAPI
>  IsHashAlgSupportedInHashAlgorithmMask(
>IN TPMI_ALG_HASH  HashAlg,
>IN UINT32 HashAlgorithmMask
> --
> 2.7.0.windows.1

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


Re: [edk2] [PATCH 2/2] SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Yao, Jiewen
Hi Star
1) I am a little confused on below description.
+  @param[in,out] Buffer Buffer to hold TPML_DIGEST_VALUES.

I think the buffer is the *TPML_DIGEST_VALUES compact binary buffer*, instead 
of *TPML_DIGEST_VALUES*, right?
I suggest we describe it clearly.

2) I think the FILTER is great to report ERROR if the TCG event hob producer 
makes mistake.
Do you think it is worthy to add more stronger check that: All required TCG 
event log are reported ?



> -Original Message-
> From: Zeng, Star
> Sent: Thursday, November 17, 2016 5:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Yao, Jiewen ;
> Zhang, Chao B 
> Subject: [PATCH 2/2] SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log
> from PEI HOB
> 
> Cc: Jiewen Yao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 80
> +--
>  1 file changed, 76 insertions(+), 4 deletions(-)
> 
> diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> index db8d662f80dc..d5a32307db6e 100644
> --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> @@ -898,6 +898,56 @@ GetDigestListBinSize (
>  }
> 
>  /**
> +  Copy TPML_DIGEST_VALUES compact binary into a buffer
> +
> +  @param[in,out] Buffer Buffer to hold
> TPML_DIGEST_VALUES.
> +  @param[in] DigestListBin  TPML_DIGEST_VALUES compact
> binary buffer.
> +  @param[in] HashAlgorithmMask  HASH bits corresponding to the
> desired digests to copy.
> +
> +  @return The end of buffer to hold TPML_DIGEST_VALUES.
> +**/
> +VOID *
> +CopyDigestListBinToBuffer (
> +  IN OUT VOID   *Buffer,
> +  IN VOID   *DigestListBin,
> +  IN UINT32 HashAlgorithmMask
> +  )
> +{
> +  UINTN Index;
> +  UINT16DigestSize;
> +  UINT32Count;
> +  TPMI_ALG_HASH HashAlg;
> +  UINT32DigestListCount;
> +  UINT32*DigestListCountPtr;
> +
> +  DigestListCountPtr = (UINT32 *) Buffer;
> +  DigestListCount = 0;
> +
> +  Count = ReadUnaligned32 (DigestListBin);
> +  Buffer = (UINT8 *)Buffer + sizeof(Count);
> +  DigestListBin = (UINT8 *)DigestListBin + sizeof(Count);
> +  for (Index = 0; Index < Count; Index++) {
> +HashAlg = ReadUnaligned16 (DigestListBin);
> +DigestListBin = (UINT8 *)DigestListBin + sizeof(HashAlg);
> +DigestSize = GetHashSizeFromAlgo (HashAlg);
> +
> +if (IsHashAlgSupportedInHashAlgorithmMask(HashAlg,
> HashAlgorithmMask)) {
> +  CopyMem (Buffer, , sizeof(HashAlg));
> +  Buffer = (UINT8 *)Buffer + sizeof(HashAlg);
> +  CopyMem (Buffer, DigestListBin, DigestSize);
> +  Buffer = (UINT8 *)Buffer + DigestSize;
> +  DigestListCount++;
> +} else {
> +  DEBUG ((EFI_D_ERROR, "WARNING: CopyDigestListBinToBuffer
> Event log has HashAlg unsupported by PCR bank (0x%x)\n", HashAlg));
> +}
> +DigestListBin = (UINT8 *)DigestListBin + DigestSize;
> +  }
> +  WriteUnaligned32 (DigestListCountPtr, DigestListCount);
> +
> +  return Buffer;
> +}
> +
> +/**
>Add a new entry to the Event Log.
> 
>@param[in] DigestListA list of digest.
> @@ -1317,8 +1367,12 @@ SetupEventLog (
>EFI_PEI_HOB_POINTERSGuidHob;
>EFI_PHYSICAL_ADDRESSLasa;
>UINTN   Index;
> +  VOID*DigestListBin;
> +  TPML_DIGEST_VALUES  TempDigestListBin;
>UINT32  DigestListBinSize;
> +  UINT8   *Event;
>UINT32  EventSize;
> +  UINT32  *EventSizePtr;
>TCG_EfiSpecIDEventStruct*TcgEfiSpecIdEventStruct;
>UINT8
> TempBuf[sizeof(TCG_EfiSpecIDEventStruct) + sizeof(UINT32) +
> (HASH_COUNT * sizeof(TCG_EfiSpecIdEventAlgorithmSize)) + sizeof(UINT8)];
>TCG_PCR_EVENT_HDR   FirstPcrEvent;
> @@ -1497,7 +1551,8 @@ SetupEventLog (
>Status = EFI_SUCCESS;
>while (!EFI_ERROR (Status) &&
>   (GuidHob.Raw = GetNextGuidHob
> (mTcg2EventInfo[Index].EventGuid, GuidHob.Raw)) != NULL) {
> -TcgEvent= GET_GUID_HOB_DATA (GuidHob.Guid);
> +TcgEvent= AllocateCopyPool (GET_GUID_HOB_DATA_SIZE
> (GuidHob.Guid), GET_GUID_HOB_DATA (GuidHob.Guid));
> +ASSERT (TcgEvent != NULL);
>  GuidHob.Raw = GET_NEXT_HOB (GuidHob);
>  switch (mTcg2EventInfo[Index].LogFormat) {
>  case EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2:
> @@ -1510,17 +1565,34 @@ SetupEventLog (
>   );
>break;
>  case EFI_TCG2_EVENT_LOG_FORMAT_TCG_2:
> -  DigestListBinSize = GetDigestListBinSize ((UINT8 *)TcgEvent +
> sizeof(TCG_PCRINDEX) + sizeof(TCG_EVENTTYPE));
> - 

Re: [edk2] [PATCH] OvmfPkg/dsc: enable SMM page level protection.

2016-11-17 Thread Laszlo Ersek
On 11/17/16 09:21, Jiewen Yao wrote:
> Add 4K PE alignment to enable SMM page level protection.
> 
> Tested boot with below configuration:
> IA32
> IA32X64
> X64
> 
> Requested-by: Laszlo Ersek 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 4 
>  OvmfPkg/OvmfPkgIa32X64.dsc | 4 
>  OvmfPkg/OvmfPkgX64.dsc | 4 
>  3 files changed, 12 insertions(+)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 3f4d42d..59c0f09 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -56,6 +56,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>  
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 5688475..226842a 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -61,6 +61,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>  
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index dcf64b9..ec97ba8 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -61,6 +61,10 @@
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>  
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page 
> level protection of DXE_SMM_DRIVER/SMM_CORE modules
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER, 
> BuildOptions.common.EDKII.SMM_CORE]
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  
> 
>  #
>  # SKU Identification section - list of all SKU IDs supported by this 
> Platform.
> 

Thank you for submitting the patch!

(1) Please wrap the new comments in the DSC files at 79 characters, like this:

#
# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
# protection of DXE_SMM_DRIVER/SMM_CORE modules
#

(2) The Ia32 SMM build of OVMF seems to expose a problem in the page level 
protection code. I will paste the full OVMF log below. My analysis is the 
following (in advance):

* The SMRAM regions provided on Q35 are:

SmmAccessPeiEntryPoint: SMRAM map follows, 2 entries
   PhysicalStart(0x) PhysicalSize(0x) CpuStart(0x)  
RegionState(0x)
7F80 1000 7F80  
 1A
7F801000   7FF000 7F801000  
  A

* The first page is used for holding the SMM_S3_RESUME_STATE object, and it is 
reported as EFI_ALLOCATED up-front. The second region is exposed to the SMM 
stack as usable/free SMRAM.

The SMM core and the SMM drivers are loaded in the second region, from high 
addresses downwards (top-down method). A good chunk of SMRAM (near 0x7F801000) 
remains free, by the time the SMM page level protection kicks in.

* The code starts setting the NX bit on page table entries that map the free 
(unused) SMRAM range. However, at a certain point, it seems to overflow to (or 
validly reach?) page table entries that map the memory attributes table itself. 
The next access to the memory attributes table causes a page fault.

* The page fault is finally mis-reported as an SMM stack overflow, because the 
fault handler simply checks if the fault address falls within SMRAM.

(3) Shouldn't the page protection code verify that the processor supports NX in 
the first place? In PiSmmCpuDxeSmm, this fact seems to be available in 
"mXdSupported" already.

The Ia32 build of OVMF (with SMM_REQUIRE) requires the user to disable NX on 
the QEMU command line.

(4) The Ia32X64 build works fine (I also tested S3 suspend/resume briefly).


So here's the log for bullet (2), with a few comments inserted in-between:

> SecCoreStartupWithStack(0xFFFCC000, 0x818000)
> SEC: Normal boot
> DecompressMemFvs: 

Re: [edk2] [PATCH V2] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()

2016-11-17 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Zeng, Star
> Sent: Thursday, November 17, 2016 4:06 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Yao, Jiewen ;
> Zhang, Chao B 
> Subject: [PATCH V2] SecurityPkg TPM2: Assign real copied count in
> CopyDigestListToBuffer()
>
> In CopyDigestListToBuffer() of Tpm2CommandLib, the count in returned
> Buffer should be real copied DigestList count.
>
> Cc: Jiewen Yao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> index 43574a246829..be95fd69b3dd 100644
> --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> @@ -230,8 +230,11 @@ CopyDigestListToBuffer (
>  {
>UINTN  Index;
>UINT16 DigestSize;
> +  UINT32 DigestListCount;
> +  UINT32 *DigestListCountPtr;
>
> -  CopyMem (Buffer, >count, sizeof(DigestList->count));
> +  DigestListCountPtr = (UINT32 *) Buffer;
> +  DigestListCount = 0;
>Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
>for (Index = 0; Index < DigestList->count; Index++) {
>  if
> (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashA
> lg, HashAlgorithmMask)) {
> @@ -243,7 +246,9 @@ CopyDigestListToBuffer (
>  DigestSize = GetHashSizeFromAlgo
> (DigestList->digests[Index].hashAlg);
>  CopyMem (Buffer, >digests[Index].digest, DigestSize);
>  Buffer = (UINT8 *)Buffer + DigestSize;
> +DigestListCount++;
>}
> +  WriteUnaligned32 (DigestListCountPtr, DigestListCount);
>
>return Buffer;
>  }
> --
> 2.7.0.windows.1
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus semicolon from GUID def

2016-11-17 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Laszlo Ersek
> Sent: Thursday, November 17, 2016 6:37 PM
> To: edk2-devel-01 
> Cc: Yao, Jiewen 
> Subject: [edk2] [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus
> semicolon from GUID def
> 
> The DEC spec doesn't allow the trailing semicolon:
> 
>   2.6 [Guids] Usage
> 
>   GuidCName = {C Format Guid Value} # Comment
> 
> Cc: Giri P Mudusuru 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek 
> ---
>  IntelSiliconPkg/IntelSiliconPkg.dec | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/IntelSiliconPkg/IntelSiliconPkg.dec
> b/IntelSiliconPkg/IntelSiliconPkg.dec
> index 4a51d0a547da..8819cb8fed6b 100644
> --- a/IntelSiliconPkg/IntelSiliconPkg.dec
> +++ b/IntelSiliconPkg/IntelSiliconPkg.dec
> @@ -26,7 +26,7 @@ [Includes]
>  [Guids]
>## GUID for Package token space
># {A9F8D54E-1107-4F0A-ADD0-4587E7A4A735}
> -  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a, { 0xad,
> 0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } };
> +  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a,
> { 0xad, 0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } }
> 
>## HOB GUID to publish SMBIOS data records from PEI phase
># HOB data format is same as SMBIOS records defined in SMBIOS spec or
> OEM defined types
> --
> 2.9.2
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V3 0/6] Enable SMM page level protection.

2016-11-17 Thread Yao, Jiewen
Oops, my bad.
Thank you for check in that for me.

Thank you
Yao Jiewen

From: Laszlo Ersek [mailto:ler...@redhat.com]
Sent: Thursday, November 17, 2016 5:55 PM
To: Yao, Jiewen ; Kinney, Michael D 
; Fan, Jeff ; 
edk2-devel@lists.01.org 
Cc: Paolo Bonzini ; Tian, Feng ; 
Zeng, Star 
Subject: Re: [edk2] [PATCH V3 0/6] Enable SMM page level protection.

Jiewen,

On 11/17/16 02:36, Yao, Jiewen wrote:
> You are right. That is good suggestion to mention it. I will add.
>
> Thank you
> Yao Jiewen

You forgot to commit patch #1 from the series, and the build is now broken.

... I have now committed patch #1 for you, with the following commit
message modifications (all according to feedback on the list):
- added my T-b
- added Jeff's R-b
- added Mike's R-b
- added Mike's paragraph (visible below) about
  gEdkiiPiSmmMemoryAttributesTableGuid

Commit 97d2760429d6.

Also I see patch #6 (17abe97671ee), for QuarkPlatformPkg, got committed
with my Tested-by. I didn't test that patch, and I even said so -- I
wrote "For patches #1 through #5".

Please be more careful about last minute changes and about applying
feedback tags.

Thanks
Laszlo

> From: Kinney, Michael D
> Sent: Thursday, November 17, 2016 9:31 AM
> To: Fan, Jeff >; Yao, Jiewen 
> >; 
> edk2-devel@lists.01.org; Kinney, Michael D 
> >
> Cc: Tian, Feng >; Zeng, Star 
> >; Laszlo Ersek 
> >; Paolo Bonzini 
> >
> Subject: RE: [PATCH V3 0/6] Enable SMM page level protection.
>
> Jiewen,
>
> The new file MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c and the
> new code in MdeModulePkg/Core/PiSmmCore/Page.c are based on the algorithms
> and implementation from MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
> and MdeModulePkg/Core/Dxe/Mem/Page.c.
>
> Also, the new GUID gEdkiiPiSmmMemoryAttributesTableGuid and its associated
> structure are based on the EFI_MEMORY_ATTRIBUTES_TABLE and GUID from the
> UEFI Specification.
>
> I recommend you update the commit messages to highlight that these new
> components are based on the Memory Attributes Table feature from the UEFI
> Specification and the existing DXE Core implementation that supports that
> feature.
>
> With those commit message updates, Series
>
> Reviewed-by: Michael Kinney 
> >>
>
> Mike
>
>> -Original Message-
>> From: Fan, Jeff
>> Sent: Wednesday, November 16, 2016 4:45 PM
>> To: Yao, Jiewen 
>> >>;
>>  
>> edk2-devel@lists.01.org>
>> Cc: Tian, Feng 
>> >>;
>>  Zeng, Star 
>> >>;
>>  Kinney,
>> Michael D 
>> >>;
>>  Laszlo Ersek 
>> >>;
>>  Paolo
>> Bonzini 
>> >>
>> Subject: RE: [PATCH V3 0/6] Enable SMM page level protection.
>>
>> Reviewed-by: Jeff Fan 
>> >>
>>
>> Thanks!
>>
>> -Original Message-
>> From: Yao, Jiewen
>> Sent: Friday, November 11, 2016 5:01 PM
>> To: 
>> edk2-devel@lists.01.org>
>> Cc: Fan, Jeff; Tian, Feng; Zeng, Star; Kinney, Michael D; Laszlo Ersek; 
>> Paolo Bonzini
>> Subject: [PATCH V3 0/6] Enable SMM page level protection.
>>
>>
>>  below is V3 description 
>> 1) PiSmmCpu: Fix CpuIndex corruption issue due to stack malposition.
>> (Many thanks to Laszlo Ersek 
>> >>
>>  for catching it.)
>> 2) PiSmmCpu: Add ASSERT for CpuIndex check.
>> 3) PiSmmCpu: Use DEBUG_VERBOSE for page table update.
>> 4) PiSmmCpu: Do not report DEBUG message for Ap non present when 
>> 

Re: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table entry in RSDT/XSDT

2016-11-17 Thread Zeng, Star
Hi Ray,

Add two minor comments inline.

Thanks,
Star
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Ruiyu Ni
> Sent: Monday, November 14, 2016 1:26 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH] PcAtChipsetPkg/PcRtc: Handle NULL table entry 
> in RSDT/XSDT
> 
> The ACPI code may reserve the first entry for a certain table (might 
> be FACS) to help with OS compatible issues.

FACS is in FADT according to ACPI spec.

> We need to skip the NULL table entry in RSDT/XSDT.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Sean Brogan 
> ---
>  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> index 2bb41e7..35e34b7 100644
> --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> @@ -1230,6 +1230,11 @@ ScanTableInSDT (
>  //
>  Table = 0;

How about to remove this superfluous line " Table = 0;"?

>  CopyMem (, (VOID *) (EntryBase + Index * TablePointerSize), 
> TablePointerSize);
> +
> +if (Table == NULL) {
> +  continue;
> +}
> 
> +
>  if (Table->Signature == Signature) {
>return Table;
>  }
> --
> 2.9.0.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-discoverable device protocol

2016-11-17 Thread Ard Biesheuvel

> On 17 Nov 2016, at 08:52, Ni, Ruiyu  wrote:
> 
> 
> 
> Thanks/Ray
> 
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>> Ard Biesheuvel
>> Sent: Thursday, November 17, 2016 2:07 PM
>> To: Ni, Ruiyu 
>> Cc: Kinney, Michael D ; edk2-
>> de...@lists.01.org; Gao, Liming ; af...@apple.com;
>> Leif Lindholm 
>> Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-
>> discoverable device protocol
>> 
>> 
>> 
>>> On 17 Nov 2016, at 02:53, Ni, Ruiyu  wrote:
>>> 
>>> Ard,
>>> I have two comments in below.
>>> 
>>> Thanks/Ray
>>> 
 -Original Message-
 From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
 Of Leif Lindholm
 Sent: Thursday, November 17, 2016 1:49 AM
 To: Ard Biesheuvel 
 Cc: Ni, Ruiyu ; edk2-devel@lists.01.org;
 af...@apple.com; Gao, Liming ; Kinney, Michael
 D 
 Subject: Re: [edk2] [PATCH v3 1/5] MdeModulePkg: introduce non-
 discoverable device protocol
 
> On Wed, Nov 16, 2016 at 04:59:27PM +, Ard Biesheuvel wrote:
> Introduce a protocol that can be exposed by a platform for devices
> that are not discoverable, usually because they are wired straight
> to the memory bus rather than to an enumerable bus like PCI or USB.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
> MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 90
 
> MdeModulePkg/MdeModulePkg.dec |  3 +
> 2 files changed, 93 insertions(+)
> 
> diff --git a/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
> b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
> new file mode 100644
> index ..47ed841b407b
> --- /dev/null
> +++ b/MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h
> @@ -0,0 +1,90 @@
> +/** @file
> +  Protocol to describe devices that are not on a discoverable bus
> +
> +  Copyright (c) 2016, Linaro, Ltd. All rights reserved.
> +
> +  This program and the accompanying materials  are licensed and
> + made available under the terms and conditions of the BSD License
> + which accompanies this distribution.  The full text of the license
> + may be found at  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
>> IS"
> + BASIS,  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
 EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __NON_DISCOVERABLE_DEVICE_H__ #define
> +__NON_DISCOVERABLE_DEVICE_H__
> +
> +#include 
> +
> +#define EDKII_NON_DISCOVERABLE_DEVICE_PROTOCOL_GUID \
> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc,
> +0x8d, 0x51, 0x4a } }
>>> 
>>> 1. Can you add "PCI" keyword into the protocol name?
>>> e.g.: EDKII_NON_DISCOVERABLE_PCI_DEVICE_PROTOCOL_GUID
>>> 
>> 
>> No. This protocol does not describe pci devices, and it is a peculiarity of 
>> the
>> edk2 driver stack that some non-pci devices can only be driven by pci 
>> drivers.
>> 
>> in other words, pci is part of the /driver/ side, and it is perfectly 
>> possible for,
>> e.g., a non-discoverable ahci device to be driven by a different non-pci 
>> driver
>> in the future.
>> 
> 
> I see. So some types of devices are handled by the current
> NonDiscoveablePciDevice driver, and some other types of devices may be
> handled by a future NonDiscoverableXXXDevice driver.
> Now since the AHCI type is already handled by the NonDiscoverablePciDevice
> driver, when there is a new NonDiscoverableXXXDevice driver, how can the two
> know whether it should manage the AHCI type device or not?

Good question. But how does the UEFI driver model deal with that? What happens 
if i have two drivers that both support the Ahci Pci class codes?

> Besides since now all the EDKII Host Controller drivers are based on
> PciIo, it implicitly requires all the low layer needs to produce PciIo 
> interface
> in order to re-use the EDKII Host Controller drivers.
> 

Yes, that is the whole point of these patches. My preferred solution would be 
to split the ?hci drivers from pci i/o, by introducing intermediate protocols, 
but we both know that is unlikely to be accepted

> +
> +//
> +// Protocol interface structure
> +//
> +typedef struct _NON_DISCOVERABLE_DEVICE
 NON_DISCOVERABLE_DEVICE;
> +
> +//
> +// Data Types
> +//
> +typedef enum {
> +  NonDiscoverableDeviceTypeAmba,
> +  NonDiscoverableDeviceTypeOhci,
> +  NonDiscoverableDeviceTypeUhci,
> +  

[edk2] [PATCH] IntelSiliconPkg/IntelSiliconPkg.dec: drop bogus semicolon from GUID def

2016-11-17 Thread Laszlo Ersek
The DEC spec doesn't allow the trailing semicolon:

  2.6 [Guids] Usage

  GuidCName = {C Format Guid Value} # Comment

Cc: Giri P Mudusuru 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 IntelSiliconPkg/IntelSiliconPkg.dec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/IntelSiliconPkg/IntelSiliconPkg.dec 
b/IntelSiliconPkg/IntelSiliconPkg.dec
index 4a51d0a547da..8819cb8fed6b 100644
--- a/IntelSiliconPkg/IntelSiliconPkg.dec
+++ b/IntelSiliconPkg/IntelSiliconPkg.dec
@@ -26,7 +26,7 @@ [Includes]
 [Guids]
   ## GUID for Package token space
   # {A9F8D54E-1107-4F0A-ADD0-4587E7A4A735}
-  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a, { 0xad, 
0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } };
+  gIntelSiliconPkgTokenSpaceGuid  = { 0xa9f8d54e, 0x1107, 0x4f0a, { 0xad, 
0xd0, 0x45, 0x87, 0xe7, 0xa4, 0xa7, 0x35 } }
 
   ## HOB GUID to publish SMBIOS data records from PEI phase
   # HOB data format is same as SMBIOS records defined in SMBIOS spec or OEM 
defined types
-- 
2.9.2

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


Re: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to mNumberToFinish

2016-11-17 Thread Laszlo Ersek
On 11/17/16 06:34, Michael Kinney wrote:
> Add volatile qualifier to mNumberToFinish to prevent compiler
> optimization.  Also update TransferApToSafeState() to pass in
> UINTN values and treat the mNumberToFinish as an address value
> that is passed to the assembly code.

Is it possible to split these actions into two patches? One for
mNumberToFinish, the other patch for UINTN values.

> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> Cc: Andrew Fish 
> Cc: Jeff Fan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 10 +-
>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 18 +-
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h| 12 ++--
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  | 18 +-
>  4 files changed, 29 insertions(+), 29 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> index 3fb6864..4531298 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> @@ -55,7 +55,7 @@ AsmGetAddressMap (
>  #define LEGACY_REGION_BASE(0xA - LEGACY_REGION_SIZE)
>  
>  ACPI_CPU_DATAmAcpiCpuData;
> -UINT32   mNumberToFinish;
> +volatile UINT32  mNumberToFinish;
>  MP_CPU_EXCHANGE_INFO *mExchangeInfo;
>  BOOLEAN  mRestoreSmmConfigurationInS3 = FALSE;
>  VOID *mGdtForAp = NULL;
> @@ -385,7 +385,7 @@ MPRendezvousProcedure (
>CPU_REGISTER_TABLE *RegisterTableList;
>UINT32 InitApicId;
>UINTN  Index;
> -  UINT32 TopOfStack;
> +  UINTN  TopOfStack;
>UINT8  Stack[128];
>  
>ProgramVirtualWireMode ();
> @@ -403,10 +403,10 @@ MPRendezvousProcedure (
>//
>// Place AP into the safe code, count down the number with lock mechanism 
> in the safe code.
>//
> -  TopOfStack  = (UINT32) (UINTN) Stack + sizeof (Stack);
> -  TopOfStack &= ~(UINT32) (CPU_STACK_ALIGNMENT - 1);
> +  TopOfStack  = (UINTN) Stack + sizeof (Stack);

This change looks good.

> +  TopOfStack &= ~(CPU_STACK_ALIGNMENT - 1);

Please don't drop the UINT32 cast from before the bit-neg altogether,
instead please turn it into a UINTN cast.

The reason is that CPU_STACK_ALIGNMENT has type "int", so the bit-neg
flips the sign bit too. The resultant value is a negative integer.

Due to the two's complement representation, the negative value is
actually correct, and when it is converted to UINTN, for the sake of the
"&" operation that's inherent in "&=", the behavior is correct. But this
silently relies on two's complement, which in my personal opinion is a
bad thing. I consider the changing of sign bits with direct bit
operations a sin :) -- unless mangling the sign bit is our express
purpose -- so I request that we please convert the int value first to
the unsigned type with correct width (here, UINTN), and then negate the
bits.

>CopyMem ((VOID *) (UINTN) mApHltLoopCode, mApHltLoopCodeTemplate, sizeof 
> (mApHltLoopCodeTemplate));
> -  TransferApToSafeState ((UINT32) (UINTN) mApHltLoopCode, TopOfStack, 
> );
> +  TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)(VOID 
> *));
>  }
>  
>  /**

The (VOID*) cast is unnecessary here (in the last arg), any pointer can
be cast to UINTN directly.

> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> index 9760373..d57eb33 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> @@ -98,23 +98,23 @@ InitGdt (
>  /**
>Transfer AP to safe hlt-loop after it finished restore CPU features on S3 
> patch.
>  
> -  @param[in] ApHltLoopCodeThe 32-bit address of the safe hlt-loop 
> function.
> -  @param[in] TopOfStack   A pointer to the new stack to use for the 
> ApHltLoopCode.
> -  @param[in] NumberToFinish   Semaphore of APs finish count.
> +  @param[in] ApHltLoopCode  The 32-bit address of the safe hlt-loop 
> function.

Should we replace "32-bit" with "natural width"?

> +  @param[in] TopOfStack A pointer to the new stack to use for 
> the ApHltLoopCode.
> +  @param[in] NumberToFinishAddress  Address of Semaphore of APs finish count.
>  
>  **/
>  VOID
>  TransferApToSafeState (
> -  IN UINT32 ApHltLoopCode,
> -  IN UINT32 TopOfStack,
> -  IN UINT32 *NumberToFinish
> +  IN UINTN  ApHltLoopCode,
> +  IN UINTN  TopOfStack,
> +  IN UINTN  NumberToFinishAddress
>)
>  {
>SwitchStack (
> -(SWITCH_STACK_ENTRY_POINT) (UINTN) ApHltLoopCode,
> -NumberToFinish,
> +(SWITCH_STACK_ENTRY_POINT)ApHltLoopCode,
> +(VOID *)NumberToFinishAddress,
>  

Re: [edk2] [PATCH 4/4] UefiCpuPkg/MpInitLib: support 64-bit AP stack addresses

2016-11-17 Thread Laszlo Ersek
On 11/17/16 02:18, Fan, Jeff wrote:
> Laszlo,
> 
> We have two solutions to fix stack > 4G issue.
> 1. Allocate AP stack buffer and all CPU MP data buffer under < 4G at the 
> beginning.
> 2. Support AP stack buffer and all CPU MP data buffer > 4G as showed in your 
> patch.
> 
> For 1), it seems not necessary.
> For 2), besides your patch. We still need to update RelocateApLoop() in 
> DxeMpLib.c to use one separate stack under 4G when paging disabled on long 
> mode DXE.
> (Currently, we still use AP existing stack after paging disabled)
> I prefer the 2), please go ahead to check-in this serial of patch. I will 
> create another patch to fix RelocateApLoop() stack issue.
> 
> Reviewed-by: Jeff Fan 
> 

Thank you, series committed as 97d2760429d6..dd3fa0cd72de.

Cheers
Laszlo

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com] 
> Sent: Thursday, November 17, 2016 8:18 AM
> To: edk2-devel-01
> Cc: Fan, Jeff
> Subject: [PATCH 4/4] UefiCpuPkg/MpInitLib: support 64-bit AP stack addresses
> 
> The cached "CPU_INFO_IN_HOB.ApTopOfStack" field currently has type UINT32.
> This is not ideal because the AP stacks are located within 
> "CpuMpData->Buffer", which is allocated with a plain AllocatePages() call in 
> MpInitLibInitialize():
> 
>   platform  CpuMpPei included  PEI RAM > 4GB  result
>     -  -  --
>   Ia32  *  n/agood
>   Ia32X64   no n/aBAD
>   Ia32X64   yesn/agood
>   X64   no *  BAD
>   X64   yesno good
>   X64   yesyesBAD
> 
> - If we are on an Ia32X64 or X64 platform that does not include CpuMpPei,
>   then CpuDxe cannot reuse the CPU_INFO_IN_HOB structures preallocated by
>   CpuMpPei (through the CpuInitMpLib GUID HOB), and then AllocatePages()
>   -- invoked first in 64-bit DXE -- could return an address outside of
>   32-bit address space.
> 
> - If we are on an X64 platform where the permanent PEI RAM extends above
>   the 32-bit address space, then the same issue can surface even if
>   CpuMpPei is included: even the original allocation of the
>   CPU_INFO_IN_HOB structures, by CpuMpPei, could be satisfied from above
>   4GB.
> 
> The original "AP init" branch in "X64/MpFuncs.nasm" correctly considers a 
> 64-bit stack start: the "MP_CPU_EXCHANGE_INFO.StackStart" field has type 
> UINTN, and the code uses QWORD addition and movement to set RSP from it.
> 
> Adapt the "GetApicId" branch of "X64/MpFuncs.nasm":
> 
> - change the type of "CPU_INFO_IN_HOB.ApTopOfStack" to UINT64,
> 
> - remove the explicit truncation to UINT32 in InitializeApData(),
> 
> - update the "GetNextProcNumber" iteration size to the new size of
>   "CPU_INFO_IN_HOB",
> 
> - set RSP with a QWORD movement from "CPU_INFO_IN_HOB.ApTopOfStack".
> 
> Because the same CPU_INFO_IN_HOB structure is used by "Ia32/MpFuncs.nasm", we 
> have to update the "GetNextProcNumber" iteration size there as well.
> The ESP setting can be preserved as a DWORD movement from the original offset 
> (decimal 12), since our integers are little endian.
> 
> Cc: Jeff Fan 
> Fixes: 845c5be1fd9bf7edfac4a103dfab70829686978f
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek 
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.h   | 4 +++-
>  UefiCpuPkg/Library/MpInitLib/MpLib.c   | 8 
>  UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm | 2 +-  
> UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm  | 5 ++---
>  4 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
> b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> index 0ac777a099b1..f73a469ae84f 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> @@ -126,18 +126,20 @@ typedef struct {
>  //
>  // Basic CPU information saved in Guided HOB.
>  // Because the contents will be shard between PEI and DXE,  // we need to 
> make sure the each fields offset same in different  // architecture.
>  //
> +#pragma pack (1)
>  typedef struct {
>UINT32 InitialApicId;
>UINT32 ApicId;
>UINT32 Health;
> -  UINT32 ApTopOfStack;
> +  UINT64 ApTopOfStack;
>  } CPU_INFO_IN_HOB;
> +#pragma pack ()
>  
>  //
>  // AP reset code information including code address and size,  // this 
> structure will be shared be C code and assembly code.
>  // It is natural aligned by design.
>  //
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 3c2e6d6b89d9..15dbfa1e7d6c 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -430,22 +430,22 @@ CollectProcessorCount ( 

Re: [edk2] [PATCH V3 0/6] Enable SMM page level protection.

2016-11-17 Thread Laszlo Ersek
Jiewen,

On 11/17/16 02:36, Yao, Jiewen wrote:
> You are right. That is good suggestion to mention it. I will add.
> 
> Thank you
> Yao Jiewen

You forgot to commit patch #1 from the series, and the build is now broken.

... I have now committed patch #1 for you, with the following commit
message modifications (all according to feedback on the list):
- added my T-b
- added Jeff's R-b
- added Mike's R-b
- added Mike's paragraph (visible below) about
  gEdkiiPiSmmMemoryAttributesTableGuid

Commit 97d2760429d6.

Also I see patch #6 (17abe97671ee), for QuarkPlatformPkg, got committed
with my Tested-by. I didn't test that patch, and I even said so -- I
wrote "For patches #1 through #5".

Please be more careful about last minute changes and about applying
feedback tags.

Thanks
Laszlo

> From: Kinney, Michael D
> Sent: Thursday, November 17, 2016 9:31 AM
> To: Fan, Jeff ; Yao, Jiewen ; 
> edk2-devel@lists.01.org; Kinney, Michael D 
> Cc: Tian, Feng ; Zeng, Star ; 
> Laszlo Ersek ; Paolo Bonzini 
> Subject: RE: [PATCH V3 0/6] Enable SMM page level protection.
> 
> Jiewen,
> 
> The new file MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c and the
> new code in MdeModulePkg/Core/PiSmmCore/Page.c are based on the algorithms
> and implementation from MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
> and MdeModulePkg/Core/Dxe/Mem/Page.c.
> 
> Also, the new GUID gEdkiiPiSmmMemoryAttributesTableGuid and its associated
> structure are based on the EFI_MEMORY_ATTRIBUTES_TABLE and GUID from the
> UEFI Specification.
> 
> I recommend you update the commit messages to highlight that these new
> components are based on the Memory Attributes Table feature from the UEFI
> Specification and the existing DXE Core implementation that supports that
> feature.
> 
> With those commit message updates, Series
> 
> Reviewed-by: Michael Kinney 
> >
> 
> Mike
> 
>> -Original Message-
>> From: Fan, Jeff
>> Sent: Wednesday, November 16, 2016 4:45 PM
>> To: Yao, Jiewen >; 
>> edk2-devel@lists.01.org
>> Cc: Tian, Feng >; Zeng, Star 
>> >; Kinney,
>> Michael D >; 
>> Laszlo Ersek >; Paolo
>> Bonzini >
>> Subject: RE: [PATCH V3 0/6] Enable SMM page level protection.
>>
>> Reviewed-by: Jeff Fan >
>>
>> Thanks!
>>
>> -Original Message-
>> From: Yao, Jiewen
>> Sent: Friday, November 11, 2016 5:01 PM
>> To: edk2-devel@lists.01.org
>> Cc: Fan, Jeff; Tian, Feng; Zeng, Star; Kinney, Michael D; Laszlo Ersek; 
>> Paolo Bonzini
>> Subject: [PATCH V3 0/6] Enable SMM page level protection.
>>
>>
>>  below is V3 description 
>> 1) PiSmmCpu: Fix CpuIndex corruption issue due to stack malposition.
>> (Many thanks to Laszlo Ersek > 
>> for catching it.)
>> 2) PiSmmCpu: Add ASSERT for CpuIndex check.
>> 3) PiSmmCpu: Use DEBUG_VERBOSE for page table update.
>> 4) PiSmmCpu: Do not report DEBUG message for Ap non present when 
>> PcdCpuSmmSyncMode==1
>> (Relex mode).
>> 5) PiSmmCpu: Do not report DEBUG message for AP removed when
>> PcdCpuHotPlugSupport==TRUE.
>>
>> Tested combination:
>> 1) XD disabled
>> 2) XD enabled in SMM and disabled in non-SMM.
>> 3) XD enabled in SMM and enabled in non-SMM.
>>
>>  below is V2 description 
>> 1) PiSmmCpu: resolve OVMF multiple processors boot hang issue.
>> 2) PiSmmCpu: Add debug info on StartupAp() fails.
>> 3) PiSmmCpu: Add ASSERT for AllocatePages().
>> 4) PiSmmCpu: Add protection detail in commit message.
>> 5) UefiCpuPkg.dsc: Add page table footprint info in commit message.
>>
>>  below is V1 description 
>> This series patch enables SMM page level protection.
>> Features are:
>> 1) PiSmmCore reports SMM PE image code/data information in
>> EdkiiPiSmmMemoryAttributeTable, if the SMM image is page aligned.
>> 2) PiSmmCpu consumes EdkiiPiSmmMemoryAttributeTable and set XD for data page 
>> and RO
>> for code page.
>> 3) PiSmmCpu enables Static Paging for X64 according to 
>> PcdCpuSmmStaticPageTable. If
>> it is true, 1G paging for above 4G is used as long as it is supported.
>> 4) PiSmmCpu sets importance data structure to be read only, such as Gdt, Idt,
>> SmmEntrypoint, and PageTable itself.
>>
>> tested platform:
>> 1) Intel internal platform (X64).
>> 2) EDKII Quark IA32
>> 3) EDKII Vlv2  X64
>> 4) EDKII OVMF IA32 and IA32X64. (with -smp 8)
>>
>> Cc: Jeff Fan >
>> Cc: 

Re: [edk2] OVMF: cross-filesystem copy broken? ("The source and destination are the same")

2016-11-17 Thread Laszlo Ersek
On 11/17/16 04:11, Bruce Cran wrote:
> I don't know if this is a known issue, but it appears that
> cross-filesystem copies no longer work. I'm running OVMF X64 built from
> git commit a0426207c133bdf40c42561f26c20c4b3114d8f9.  I've tried copying
> between filesystems in various ways - with the current directory being
> fs0, fs1, specifying the destination as the current directory, a empty
> directory or a filename. It always results in the same error:
> 
> FS0:\efi\ubuntu\> cp grubx64.efi fs1:\
> 
> cp: The source and destination are the same.
> 
> 
> I built OVMF with: `./OvmfPkg/build.sh -a X64 -t GCC49 -b NOOPT -D
> DEBUG_ON_SERIAL_PORT=TRUE` and am running OVMF with:
> 
> 
> qemu-system-x86_64 -name uefi -M q35 -m size=16G -cpu host -enable-kvm \
>   -drive
> if=pflash,format=raw,file=workspace/edk2/Build/OvmfX64/NOOPT_GCC49/FV/OVMF.fd
> -serial pty \
>   -nodefaults -s -rtc base=utc -monitor stdio --usbdevice tablet \
>   -vga qxl  -sdl   \
>   -device vfio-pci,host=01:00.0,id=iodrive,rombar=0 \
>   -drive file=uefi.img,if=ide,media=disk,id=disk,format=raw \
>   -drive file=uefi_tmp.img,if=ide,media=disk,id=disk1,format=raw
> 
> 

I wonder if you are running into this BZ:

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

There's a patch on the list for said BZ:

[edk2] [PATCH v2] API PathRemoveLastItem not handle root paths properly

so if the BZ is indeed what you're encountering, then the patch should
fix it for you. Can you please test it and report back in that thread?

The error message that you see corresponds to the STR_CP_SD_SAME token.
It is emitted by the ValidateAndCopyFiles() function, in
"ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c".

However, the same function calls PathRemoveLastItem() in a loop first,
so I suspect the patch is related to the symptom you see.

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


[edk2] [PATCH 0/2] Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Star Zeng
Star Zeng (2):
  SecurityPkg TPM2: Make IsHashAlgSupportedInHashAlgorithmMask external
  SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 16 ++
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c |  1 +
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 80 +--
 3 files changed, 93 insertions(+), 4 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [PATCH 1/2] SecurityPkg TPM2: Make IsHashAlgSupportedInHashAlgorithmMask external

2016-11-17 Thread Star Zeng
Current IsHashAlgSupportedInHashAlgorithmMask is only an internal
function, this patch makes it external for coming consumer.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 16 
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c |  1 +
 2 files changed, 17 insertions(+)

diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h 
b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index 9a1dd8d8aceb..85a4c65e0263 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -1007,6 +1007,22 @@ GetHashSizeFromAlgo (
   );
 
 /**
+  Return if hash alg is supported in HashAlgorithmMask.
+
+  @param HashAlgHash algorithm to be checked.
+  @param HashAlgorithmMask  Bitfield of allowed hash algorithms.
+
+  @retval TRUE  Hash algorithm is supported.
+  @retval FALSE Hash algorithm is not supported.
+**/
+BOOLEAN
+EFIAPI
+IsHashAlgSupportedInHashAlgorithmMask(
+  IN TPMI_ALG_HASH  HashAlg,
+  IN UINT32 HashAlgorithmMask
+  );
+
+/**
   Copy TPML_DIGEST_VALUES into a buffer
 
   @param[in,out] Buffer Buffer to hold TPML_DIGEST_VALUES.
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index be95fd69b3dd..95d4f7c84ce9 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -175,6 +175,7 @@ CopyAuthSessionResponse (
   @retval FALSE Hash algorithm is not supported.
 **/
 BOOLEAN
+EFIAPI
 IsHashAlgSupportedInHashAlgorithmMask(
   IN TPMI_ALG_HASH  HashAlg,
   IN UINT32 HashAlgorithmMask
-- 
2.7.0.windows.1

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


[edk2] [PATCH 2/2] SecurityPkg Tcg2Dxe: Filter inactive digest in event2 log from PEI HOB

2016-11-17 Thread Star Zeng
Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 80 +--
 1 file changed, 76 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c 
b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
index db8d662f80dc..d5a32307db6e 100644
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
@@ -898,6 +898,56 @@ GetDigestListBinSize (
 }
 
 /**
+  Copy TPML_DIGEST_VALUES compact binary into a buffer
+
+  @param[in,out] Buffer Buffer to hold TPML_DIGEST_VALUES.
+  @param[in] DigestListBin  TPML_DIGEST_VALUES compact binary buffer.
+  @param[in] HashAlgorithmMask  HASH bits corresponding to the desired 
digests to copy.
+
+  @return The end of buffer to hold TPML_DIGEST_VALUES.
+**/
+VOID *
+CopyDigestListBinToBuffer (
+  IN OUT VOID   *Buffer,
+  IN VOID   *DigestListBin,
+  IN UINT32 HashAlgorithmMask
+  )
+{
+  UINTN Index;
+  UINT16DigestSize;
+  UINT32Count;
+  TPMI_ALG_HASH HashAlg;
+  UINT32DigestListCount;
+  UINT32*DigestListCountPtr;
+
+  DigestListCountPtr = (UINT32 *) Buffer;
+  DigestListCount = 0;
+
+  Count = ReadUnaligned32 (DigestListBin);
+  Buffer = (UINT8 *)Buffer + sizeof(Count);
+  DigestListBin = (UINT8 *)DigestListBin + sizeof(Count);
+  for (Index = 0; Index < Count; Index++) {
+HashAlg = ReadUnaligned16 (DigestListBin);
+DigestListBin = (UINT8 *)DigestListBin + sizeof(HashAlg);
+DigestSize = GetHashSizeFromAlgo (HashAlg);
+
+if (IsHashAlgSupportedInHashAlgorithmMask(HashAlg, HashAlgorithmMask)) {
+  CopyMem (Buffer, , sizeof(HashAlg));
+  Buffer = (UINT8 *)Buffer + sizeof(HashAlg);
+  CopyMem (Buffer, DigestListBin, DigestSize);
+  Buffer = (UINT8 *)Buffer + DigestSize;
+  DigestListCount++;
+} else {
+  DEBUG ((EFI_D_ERROR, "WARNING: CopyDigestListBinToBuffer Event log has 
HashAlg unsupported by PCR bank (0x%x)\n", HashAlg));
+}
+DigestListBin = (UINT8 *)DigestListBin + DigestSize;
+  }
+  WriteUnaligned32 (DigestListCountPtr, DigestListCount);
+
+  return Buffer;
+}
+
+/**
   Add a new entry to the Event Log.
 
   @param[in] DigestListA list of digest.
@@ -1317,8 +1367,12 @@ SetupEventLog (
   EFI_PEI_HOB_POINTERSGuidHob;
   EFI_PHYSICAL_ADDRESSLasa;
   UINTN   Index;
+  VOID*DigestListBin;
+  TPML_DIGEST_VALUES  TempDigestListBin;
   UINT32  DigestListBinSize;
+  UINT8   *Event;
   UINT32  EventSize;
+  UINT32  *EventSizePtr;
   TCG_EfiSpecIDEventStruct*TcgEfiSpecIdEventStruct;
   UINT8   TempBuf[sizeof(TCG_EfiSpecIDEventStruct) + 
sizeof(UINT32) + (HASH_COUNT * sizeof(TCG_EfiSpecIdEventAlgorithmSize)) + 
sizeof(UINT8)];
   TCG_PCR_EVENT_HDR   FirstPcrEvent;
@@ -1497,7 +1551,8 @@ SetupEventLog (
   Status = EFI_SUCCESS;
   while (!EFI_ERROR (Status) && 
  (GuidHob.Raw = GetNextGuidHob (mTcg2EventInfo[Index].EventGuid, 
GuidHob.Raw)) != NULL) {
-TcgEvent= GET_GUID_HOB_DATA (GuidHob.Guid);
+TcgEvent= AllocateCopyPool (GET_GUID_HOB_DATA_SIZE (GuidHob.Guid), 
GET_GUID_HOB_DATA (GuidHob.Guid));
+ASSERT (TcgEvent != NULL);
 GuidHob.Raw = GET_NEXT_HOB (GuidHob);
 switch (mTcg2EventInfo[Index].LogFormat) {
 case EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2:
@@ -1510,17 +1565,34 @@ SetupEventLog (
  );
   break;
 case EFI_TCG2_EVENT_LOG_FORMAT_TCG_2:
-  DigestListBinSize = GetDigestListBinSize ((UINT8 *)TcgEvent + 
sizeof(TCG_PCRINDEX) + sizeof(TCG_EVENTTYPE));
-  CopyMem (, (UINT8 *)TcgEvent + sizeof(TCG_PCRINDEX) + 
sizeof(TCG_EVENTTYPE) + DigestListBinSize, sizeof(UINT32));
+  DigestListBin = (UINT8 *)TcgEvent + sizeof(TCG_PCRINDEX) + 
sizeof(TCG_EVENTTYPE);
+  DigestListBinSize = GetDigestListBinSize (DigestListBin);
+  //
+  // Save event size.
+  //
+  CopyMem (, (UINT8 *)DigestListBin + DigestListBinSize, 
sizeof(UINT32));
+  Event = (UINT8 *)DigestListBin + DigestListBinSize + sizeof(UINT32);
+  //
+  // Filter inactive digest in the event2 log from PEI HOB.
+  //
+  CopyMem (, DigestListBin, GetDigestListBinSize 
(DigestListBin));
+  EventSizePtr = CopyDigestListBinToBuffer (DigestListBin, 
, mTcgDxeData.BsCap.ActivePcrBanks);
+  //
+  // Restore event size.
+  //
+  CopyMem (EventSizePtr, , sizeof(UINT32));
+  DigestListBinSize = GetDigestListBinSize (DigestListBin);
+
   Status = 

[edk2] [PATCH] SecurityPkg Tcg2Dxe: Get correct digest list size

2016-11-17 Thread Star Zeng
Current code uses GetDigestListSize(DigestList) to get
digest list size, that is incorrect.
The code should get digest list size of digests copied
into event2 log, those digests are compacted, so
GetDigestListBinSize() should be used.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c 
b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
index d5a32307db6e..f4740a3c 100644
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
@@ -970,6 +970,7 @@ TcgDxeLogHashEvent (
   EFI_STATUSRetStatus;
   TCG_PCR_EVENT2TcgPcrEvent2;
   UINT8 *DigestBuffer;
+  UINT32*EventSizePtr;
 
   DEBUG ((EFI_D_INFO, "SupportedEventLogs - 0x%08x\n", 
mTcgDxeData.BsCap.SupportedEventLogs));
 
@@ -1006,9 +1007,8 @@ TcgDxeLogHashEvent (
 TcgPcrEvent2.PCRIndex = NewEventHdr->PCRIndex;
 TcgPcrEvent2.EventType = NewEventHdr->EventType;
 DigestBuffer = (UINT8 *)
-DigestBuffer = CopyDigestListToBuffer (DigestBuffer, DigestList, 
mTcgDxeData.BsCap.ActivePcrBanks);
-CopyMem (DigestBuffer, >EventSize, 
sizeof(NewEventHdr->EventSize));
-DigestBuffer = DigestBuffer + sizeof(NewEventHdr->EventSize);
+EventSizePtr = CopyDigestListToBuffer (DigestBuffer, DigestList, 
mTcgDxeData.BsCap.ActivePcrBanks);
+CopyMem (EventSizePtr, >EventSize, 
sizeof(NewEventHdr->EventSize));
 
 //
 // Enter critical region
@@ -1017,7 +1017,7 @@ TcgDxeLogHashEvent (
 Status = TcgDxeLogEvent (
mTcg2EventInfo[Index].LogFormat,
,
-   sizeof(TcgPcrEvent2.PCRIndex) + 
sizeof(TcgPcrEvent2.EventType) + GetDigestListSize (DigestList) + 
sizeof(TcgPcrEvent2.EventSize),
+   sizeof(TcgPcrEvent2.PCRIndex) + 
sizeof(TcgPcrEvent2.EventType) + GetDigestListBinSize (DigestBuffer) + 
sizeof(TcgPcrEvent2.EventSize),
NewEventData,
NewEventHdr->EventSize
);
-- 
2.7.0.windows.1

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


Re: [edk2] [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs

2016-11-17 Thread Laszlo Ersek
On 11/17/16 05:53, Michael Kinney wrote:
> The SpinLock functions in the SynchronicationLib use volatile
> parameters to keep compiler from optimizing these functions
> too much.  The volatile keyword is missing from the Interlocked*()
> functions in this same library instance.  Update the library instance
> to consistently use volatile on all functions in the
> SynchronizationLib class.
> 
> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> Cc: Andrew Fish 
> Cc: Jeff Fan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney 
> ---
>  .../Ia32/InterlockedCompareExchange16.asm  |  4 ++--
>  .../Ia32/InterlockedCompareExchange16.c|  4 ++--
>  .../Ia32/InterlockedCompareExchange16.nasm |  4 ++--
>  .../Ia32/InterlockedCompareExchange32.asm  |  4 ++--
>  .../Ia32/InterlockedCompareExchange32.c|  4 ++--
>  .../Ia32/InterlockedCompareExchange32.nasm |  4 ++--
>  .../Ia32/InterlockedCompareExchange64.asm  |  4 ++--
>  .../Ia32/InterlockedCompareExchange64.c|  4 ++--
>  .../Ia32/InterlockedCompareExchange64.nasm |  4 ++--
>  .../Ia32/InterlockedDecrement.asm  |  2 +-
>  .../BaseSynchronizationLib/Ia32/InterlockedDecrement.c |  4 ++--
>  .../Ia32/InterlockedDecrement.nasm |  4 ++--
>  .../Ia32/InterlockedIncrement.asm  |  4 ++--
>  .../BaseSynchronizationLib/Ia32/InterlockedIncrement.c |  4 ++--
>  .../Ia32/InterlockedIncrement.nasm |  4 ++--
>  .../Library/BaseSynchronizationLib/Synchronization.c   | 18 
> +-
>  .../BaseSynchronizationLib/SynchronizationGcc.c| 18 
> +-
>  .../BaseSynchronizationLib/SynchronizationMsc.c| 18 
> +-
>  .../X64/InterlockedCompareExchange16.asm   |  6 +++---
>  .../X64/InterlockedCompareExchange16.c |  4 ++--
>  .../X64/InterlockedCompareExchange16.nasm  |  6 +++---
>  .../X64/InterlockedCompareExchange32.asm   |  6 +++---
>  .../X64/InterlockedCompareExchange32.c |  4 ++--
>  .../X64/InterlockedCompareExchange32.nasm  |  6 +++---
>  .../X64/InterlockedCompareExchange64.asm   |  6 +++---
>  .../X64/InterlockedCompareExchange64.c |  4 ++--
>  .../X64/InterlockedCompareExchange64.nasm  |  4 ++--
>  .../X64/InterlockedDecrement.asm   |  6 +++---
>  .../BaseSynchronizationLib/X64/InterlockedDecrement.c  |  6 +++---
>  .../X64/InterlockedDecrement.nasm  |  6 +++---
>  .../X64/InterlockedIncrement.asm   |  6 +++---
>  .../BaseSynchronizationLib/X64/InterlockedIncrement.c  |  6 +++---
>  .../X64/InterlockedIncrement.nasm  |  6 +++---
>  33 files changed, 97 insertions(+), 97 deletions(-)
> 
> diff --git 
> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm 
> b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> index 92a0f49..7362fe9 100644
> --- 
> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> +++ 
> b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.asm
> @@ -1,6 +1,6 @@
>  
> ;--
>  ;
> -; Copyright (c) 2006, Intel Corporation. All rights reserved.
> +; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
>  ; Copyright (c) 2015, Linaro Ltd. All rights reserved.
>  ; This program and the accompanying materials
>  ; are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -30,7 +30,7 @@
>  ; UINT16
>  ; EFIAPI
>  ; InternalSyncCompareExchange16 (
> -;   IN  UINT16*Value,
> +;   IN  volatile UINT16   *Value,
>  ;   IN  UINT16CompareValue,
>  ;   IN  UINT16ExchangeValue
>  ;   );
> diff --git 
> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.c 
> b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.c
> index 3d52137..0c3a4f6 100644
> --- 
> a/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.c
> +++ 
> b/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange16.c
> @@ -1,7 +1,7 @@
>  /** @file
>InterlockedCompareExchange16 function
>  
> -  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
> +  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
>Copyright (c) 2015, Linaro Ltd. All rights reserved.
>This program and the accompanying materials
>are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -36,7 +36,7 @@
>  UINT16
>  EFIAPI

Re: [edk2] [Patch 1/2] MdePkg/Include: Add volatile to SynchronizationLib parameters

2016-11-17 Thread Laszlo Ersek
On 11/17/16 05:53, Michael Kinney wrote:
> The SpinLock functions in the SynchronicationLib use volatile
> parameters to keep compiler from optimizing these functions
> too much.  The volatile keyword is missing from the Interlocked*()
> functions in this same library class.  Update the library class
> to consistently use volatile on all functions in this class.
> 
> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> Cc: Andrew Fish 
> Cc: Jeff Fan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney 
> ---
>  MdePkg/Include/Library/SynchronizationLib.h | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/SynchronizationLib.h 
> b/MdePkg/Include/Library/SynchronizationLib.h
> index 7b97683..4f405e2 100644
> --- a/MdePkg/Include/Library/SynchronizationLib.h
> +++ b/MdePkg/Include/Library/SynchronizationLib.h
> @@ -1,7 +1,7 @@
>  /** @file
>Provides synchronization functions.
>  
> -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD 
> License
>  which accompanies this distribution.  The full text of the license may be 
> found at
> @@ -157,7 +157,7 @@ ReleaseSpinLock (
>  UINT32
>  EFIAPI
>  InterlockedIncrement (
> -  IN  UINT32*Value
> +  IN  volatile UINT32*Value
>);
>  
>  
> @@ -179,7 +179,7 @@ InterlockedIncrement (
>  UINT32
>  EFIAPI
>  InterlockedDecrement (
> -  IN  UINT32*Value
> +  IN  volatile UINT32*Value
>);
>  
>  
> @@ -204,7 +204,7 @@ InterlockedDecrement (
>  UINT16
>  EFIAPI
>  InterlockedCompareExchange16 (
> -  IN OUT  UINT16*Value,
> +  IN OUT  volatile UINT16   *Value,
>IN  UINT16CompareValue,
>IN  UINT16ExchangeValue
>);
> @@ -231,7 +231,7 @@ InterlockedCompareExchange16 (
>  UINT32
>  EFIAPI
>  InterlockedCompareExchange32 (
> -  IN OUT  UINT32*Value,
> +  IN OUT  volatile UINT32   *Value,
>IN  UINT32CompareValue,
>IN  UINT32ExchangeValue
>);
> @@ -258,7 +258,7 @@ InterlockedCompareExchange32 (
>  UINT64
>  EFIAPI
>  InterlockedCompareExchange64 (
> -  IN OUT  UINT64*Value,
> +  IN OUT  volatile UINT64   *Value,
>IN  UINT64CompareValue,
>IN  UINT64ExchangeValue
>);
> @@ -285,7 +285,7 @@ InterlockedCompareExchange64 (
>  VOID *
>  EFIAPI
>  InterlockedCompareExchangePointer (
> -  IN OUT  VOID  **Value,
> +  IN OUT  volatile VOID **Value,
>IN  VOID  *CompareValue,
>IN  VOID  *ExchangeValue
>);
> 

In the last prototype, the changed parameter should be:

  IN OUT VOID * volatile * Value

The object that is pointed-to by Value ((which happens to be a pointer)
needs to get the volatile qualification, not the object that the pointer
being exchanged points to.

volatile
+++-+
Value > | *Value | -> |  **Value|
+++-+

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


Re: [edk2] [PATCH] IntelSiliconPkg: Add DxeSmbiosDataHobLib

2016-11-17 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Mudusuru, Giri P
> Sent: Monday, November 14, 2016 3:27 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Zeng, Star ;
> Kinney, Michael D 
> Subject: [edk2][PATCH] IntelSiliconPkg: Add DxeSmbiosDataHobLib
> 
> Added NULL Library constructor DxeSmbiosDataHobLib which adds SMBIOS
> records from gIntelSmbiosDataHobGuid HOB to SMBIOS table using
> SMBIOS protocol.
> 
> Cc: Jiewen Yao 
> Cc: Star Zeng 
> Cc: Michael Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Giri P Mudusuru 
> ---
>  .../DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c  | 193
> +
>  .../DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.inf|  44 +
>  2 files changed, 237 insertions(+)
>  create mode 100644
> IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c
>  create mode 100644
> IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.inf
> 
> diff --git
> a/IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c
> b/IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c
> new file mode 100644
> index 000..8d513e0
> --- /dev/null
> +++
> b/IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c
> @@ -0,0 +1,193 @@
> +/** @file
> +  Library to add SMBIOS data records from HOB to SMBIOS table.
> +
> +  Copyright (c) 2016, Intel Corporation. All rights reserved.
> +
> +  This program and the accompanying materials are licensed and made
> available under
> +  the terms and conditions of the BSD License which accompanies this
> distribution.
> +  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +  @par Specification Reference:
> +  System Management BIOS (SMBIOS) Reference Specification v3.0.0
> +  dated 2015-Feb-12 (DSP0134)
> +
> http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.
> 0.0.pdf
> +
> +**/
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> +
> +  Get the full size of SMBIOS structure including optional strings that
> follow the formatted structure.
> +  @note: This function is copy from SmbiosDxe in MdeModulePkg.
> +
> +  @param[in] This The EFI_SMBIOS_PROTOCOL
> instance.
> +  @param[in] Head Pointer to the beginning of
> SMBIOS structure.
> +  @param[out] SizeThe returned size.
> +  @param[out] NumberOfStrings The returned number of optional
> strings that follow the formatted structure.
> +
> +  @retval EFI_SUCCESS   Size returned in Size.
> +  @retval EFI_INVALID_PARAMETER Input SMBIOS structure mal-formed
> or Size is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +GetSmbiosStructureSize (
> +  IN   CONST EFI_SMBIOS_PROTOCOL*This,
> +  IN   EFI_SMBIOS_TABLE_HEADER  *Head,
> +  OUT  UINTN*Size,
> +  OUT  UINTN*NumberOfStrings
> +  )
> +{
> +  UINTN  FullSize;
> +  UINTN  StrLen;
> +  UINTN  MaxLen;
> +  INT8*  CharInStr;
> +
> +  if (Size == NULL || NumberOfStrings == NULL) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  FullSize = Head->Length;
> +  CharInStr = (INT8*)Head + Head->Length;
> +  *Size = FullSize;
> +  *NumberOfStrings = 0;
> +  StrLen = 0;
> +
> +  //
> +  // look for the two consecutive zeros, check the string limit by the way.
> +  //
> +  while (*CharInStr != 0 || *(CharInStr+1) != 0) {
> +if (*CharInStr == 0) {
> +  *Size += 1;
> +  CharInStr++;
> +}
> +
> +if (This->MajorVersion < 2 || (This->MajorVersion == 2 &&
> This->MinorVersion < 7)) {
> +  MaxLen = SMBIOS_STRING_MAX_LENGTH;
> +} else if (This->MajorVersion < 3) {
> +  //
> +  // Reference SMBIOS 2.7, chapter 6.1.3, it will have no limit on the
> length of each individual text string.
> +  // However, the length of the entire structure table (including all
> strings) must be reported
> +  // in the Structure Table Length field of the SMBIOS Structure Table
> Entry Point,
> +  // which is a WORD field limited to 65,535 bytes.
> +  //
> +  MaxLen = SMBIOS_TABLE_MAX_LENGTH;
> +} else {
> +  //
> +  // SMBIOS 3.0 defines the Structure table maximum size as DWORD
> field limited to 0x bytes.
> +  // Locate the end of string as long as possible.
> +  //
> +  MaxLen = SMBIOS_3_0_TABLE_MAX_LENGTH;
> +}
> +
> +for (StrLen = 0 ; StrLen < MaxLen; StrLen++) {
> +  if (*(CharInStr+StrLen) == 0) {
> +break;
> +  }
> +}
> +
> +if (StrLen == MaxLen) {
> +  

Re: [edk2] [Patch 2/2] SecurityPkg OpalPasswordDxe: Clean PSID buffer.

2016-11-17 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Dong, Eric
> Sent: Wednesday, November 16, 2016 2:16 PM
> To: edk2-devel@lists.01.org
> Cc: Tian, Feng ; Yao, Jiewen 
> Subject: [Patch 2/2] SecurityPkg OpalPasswordDxe: Clean PSID buffer.
> 
> Change callback handler type to avoid saving PSID info in
> browser temp buffer. Also clean the buffer after using it.
> 
> Cc: Feng Tian 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong 
> ---
>  SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c | 23
> +-
>  .../Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h  |  4 +++-
>  2 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> index 5937ce2..7371b7e 100644
> --- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> +++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> @@ -501,14 +501,13 @@ DriverCallback(
> 
>case HII_KEY_ID_ENTER_PASSWORD:
>  return HiiPasswordEntered(Value->string);
> +
> +  case HII_KEY_ID_ENTER_PSID:
> +return HiiPsidRevert(Value->string);
> +
>  }
>} else if (Action == EFI_BROWSER_ACTION_CHANGED) {
>  switch (HiiKeyId) {
> -  case HII_KEY_ID_ENTER_PSID:
> -HiiPsidRevert();
> -*ActionRequest =
> EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
> -return EFI_SUCCESS;
> -
>case HII_KEY_ID_BLOCKSID:
>  switch (Value->u8) {
>case 0:
> @@ -661,12 +660,14 @@ HiiPopulateDiskInfoForm(
>  /**
>Reverts the Opal disk to factory default.
> 
> +  @param   PsidStringId  The string id for the PSID info.
> +
>@retval  EFI_SUCCESS   Do the required action success.
> 
>  **/
>  EFI_STATUS
>  HiiPsidRevert(
> -  VOID
> +  EFI_STRING_ID PsidStringId
>)
>  {
>CHAR8
> Response[DEFAULT_RESPONSE_SIZE];
> @@ -674,15 +675,19 @@ HiiPsidRevert(
>OPAL_DISK *OpalDisk;
>TCG_RESULTRet;
>OPAL_SESSION  Session;
> +  CHAR16*UnicodeStr;
>UINT8
> TmpBuf[PSID_CHARACTER_STRING_END_LENGTH];
> 
>Ret = TcgResultFailure;
> 
> -  OpalHiiGetBrowserData();
> -
> +  UnicodeStr = HiiGetString (gHiiPackageListHandle, PsidStringId, NULL);
>ZeroMem (TmpBuf, sizeof (TmpBuf));
> -  UnicodeStrToAsciiStrS (gHiiConfiguration.Psid, (CHAR8*)TmpBuf,
> PSID_CHARACTER_STRING_END_LENGTH);
> +  UnicodeStrToAsciiStrS (UnicodeStr, (CHAR8*)TmpBuf,
> PSID_CHARACTER_STRING_END_LENGTH);
>CopyMem (Psid.Psid, TmpBuf, PSID_CHARACTER_LENGTH);
> +  HiiSetString (gHiiPackageListHandle, PsidStringId, L"", NULL);
> +  ZeroMem (TmpBuf, sizeof (TmpBuf));
> +  ZeroMem (UnicodeStr, StrSize (UnicodeStr));
> +  FreePool (UnicodeStr);
> 
>OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
>if (OpalDisk != NULL) {
> diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h
> b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h
> index a7709dd..ec5a93c 100644
> --- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h
> +++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiPrivate.h
> @@ -225,12 +225,14 @@ HiiSetBlockSidAction (
>  /**
>Reverts the Opal disk to factory default.
> 
> +  @param   PsidStringId  The string id for the PSID info.
> +
>@retval  EFI_SUCCESS   Do the required action success.
> 
>  **/
>  EFI_STATUS
>  HiiPsidRevert(
> -  VOID
> +  EFI_STRING_ID PsidStringId
>);
> 
>  /**
> --
> 2.6.4.windows.1

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


Re: [edk2] [Patch 1/2] SecurityPkg OpalPasswordDxe: Clean password buffer.

2016-11-17 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Dong, Eric
> Sent: Wednesday, November 16, 2016 2:15 PM
> To: edk2-devel@lists.01.org
> Cc: Tian, Feng ; Yao, Jiewen 
> Subject: [Patch 1/2] SecurityPkg OpalPasswordDxe: Clean password buffer.
> 
> Cc: Feng Tian 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong 
> ---
>  SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c |  1 +
>  SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c| 17
> +
>  2 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
> b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
> index 718d49e..0a32ee2 100644
> --- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
> +++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
> @@ -240,6 +240,7 @@ OpalDriverPopUpHddPassword (
>}
> 
>UnicodeStrToAsciiStrS (Unicode, Ascii, MAX_PASSWORD_SIZE + 1);
> +  ZeroMem (Unicode, sizeof (Unicode));
> 
>return Ascii;
>  }
> diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> index 5e3106a..5937ce2 100644
> --- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> +++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> @@ -694,6 +694,8 @@ HiiPsidRevert(
>  Ret = OpalSupportPsidRevert(, Psid.Psid,
> (UINT32)sizeof(Psid.Psid), OpalDisk->OpalDevicePath);
>}
> 
> +  ZeroMem (Psid.Psid, PSID_CHARACTER_LENGTH);
> +
>if (Ret == TcgResultSuccess) {
>  AsciiSPrint( Response, DEFAULT_RESPONSE_SIZE, "%a", "PSID Revert:
> Success" );
>} else {
> @@ -1099,8 +1101,8 @@ HiiPasswordEntered(
>EFI_STRING_IDStr
>)
>  {
> -  OPAL_DISK*OpalDisk;
> -  CHAR8
> Password[MAX_PASSWORD_CHARACTER_LENGTH + 1];
> +  OPAL_DISK*   OpalDisk;
> +  CHAR8
> Password[MAX_PASSWORD_CHARACTER_LENGTH + 1];
>CHAR16*  UniStr;
>UINT32   PassLength;
>EFI_STATUS   Status;
> @@ -1124,15 +1126,20 @@ HiiPasswordEntered(
>if (UniStr == NULL) {
>  return EFI_NOT_FOUND;
>}
> +
> +  HiiSetString(gHiiPackageListHandle, Str, L"", NULL);
> +
>PassLength = (UINT32) StrLen (UniStr);
>if (PassLength >= sizeof(Password)) {
>  HiiSetFormString(STRING_TOKEN(STR_ACTION_STATUS), "Password
> too long");
> -gBS->FreePool(UniStr);
> +ZeroMem (UniStr, StrSize (UniStr));
> +FreePool(UniStr);
>  return EFI_BUFFER_TOO_SMALL;
>}
> 
>UnicodeStrToAsciiStrS (UniStr, Password, sizeof (Password));
> -  gBS->FreePool(UniStr);
> +  ZeroMem (UniStr, StrSize (UniStr));
> +  FreePool(UniStr);
> 
>if (gHiiConfiguration.SelectedAction == HII_KEY_ID_GOTO_UNLOCK) {
>  Status = HiiUnlock (OpalDisk, Password, PassLength);
> @@ -1154,6 +1161,8 @@ HiiPasswordEntered(
>  Status = HiiSetPassword(OpalDisk, Password, PassLength);
>}
> 
> +  ZeroMem (Password, sizeof (Password));
> +
>OpalHiiSetBrowserData ();
> 
>return Status;
> --
> 2.6.4.windows.1

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


[edk2] [PATCH] OvmfPkg/dsc: enable SMM page level protection.

2016-11-17 Thread Jiewen Yao
Add 4K PE alignment to enable SMM page level protection.

Tested boot with below configuration:
IA32
IA32X64
X64

Requested-by: Laszlo Ersek 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 OvmfPkg/OvmfPkgIa32.dsc| 4 
 OvmfPkg/OvmfPkgIa32X64.dsc | 4 
 OvmfPkg/OvmfPkgX64.dsc | 4 
 3 files changed, 12 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 3f4d42d..59c0f09 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -56,6 +56,10 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
 
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level 
protection of DXE_SMM_DRIVER/SMM_CORE modules
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 

 #
 # SKU Identification section - list of all SKU IDs supported by this Platform.
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 5688475..226842a 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -61,6 +61,10 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
 
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level 
protection of DXE_SMM_DRIVER/SMM_CORE modules
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 

 #
 # SKU Identification section - list of all SKU IDs supported by this Platform.
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index dcf64b9..ec97ba8 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -61,6 +61,10 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
 
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level 
protection of DXE_SMM_DRIVER/SMM_CORE modules
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 

 #
 # SKU Identification section - list of all SKU IDs supported by this Platform.
-- 
2.7.4.windows.1

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


Re: [edk2] [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()

2016-11-17 Thread Zeng, Star
Chao,

Great comments, just sent out V2 patch, please help review it.

Thanks,
Star
-Original Message-
From: Zhang, Chao B 
Sent: Thursday, November 17, 2016 11:19 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Yao, Jiewen 
Subject: RE: [PATCH] SecurityPkg TPM2: Assign real copied count in 
CopyDigestListToBuffer()

Hi Star:
  Please use WtiteUnaligned32 to update hash count. Others are good to me.





Thanks & Best regards
Chao Zhang

-Original Message-
From: Zeng, Star
Sent: Wednesday, November 16, 2016 9:58 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star; Yao, Jiewen; Zhang, Chao B
Subject: [PATCH] SecurityPkg TPM2: Assign real copied count in 
CopyDigestListToBuffer()

In CopyDigestListToBuffer() of Tpm2CommandLib, the count in returned Buffer 
should be real copied DigestList count.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 43574a246829..caa370c94381 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -230,8 +230,10 @@ CopyDigestListToBuffer (  {
   UINTN  Index;
   UINT16 DigestSize;
+  UINT32 *DigestListCount;
 
-  CopyMem (Buffer, >count, sizeof(DigestList->count));
+  DigestListCount = (UINT32 *) Buffer;
+  *DigestListCount = 0;
   Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
   for (Index = 0; Index < DigestList->count; Index++) {
 if 
(!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, 
HashAlgorithmMask)) { @@ -243,6 +245,7 @@ CopyDigestListToBuffer (
 DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
 CopyMem (Buffer, >digests[Index].digest, DigestSize);
 Buffer = (UINT8 *)Buffer + DigestSize;
+(*DigestListCount)++;
   }
 
   return Buffer;
--
2.7.0.windows.1

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


[edk2] [PATCH V2] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()

2016-11-17 Thread Star Zeng
In CopyDigestListToBuffer() of Tpm2CommandLib, the count in returned
Buffer should be real copied DigestList count.

Cc: Jiewen Yao 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng 
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 43574a246829..be95fd69b3dd 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -230,8 +230,11 @@ CopyDigestListToBuffer (
 {
   UINTN  Index;
   UINT16 DigestSize;
+  UINT32 DigestListCount;
+  UINT32 *DigestListCountPtr;
 
-  CopyMem (Buffer, >count, sizeof(DigestList->count));
+  DigestListCountPtr = (UINT32 *) Buffer;
+  DigestListCount = 0;
   Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
   for (Index = 0; Index < DigestList->count; Index++) {
 if 
(!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, 
HashAlgorithmMask)) {
@@ -243,7 +246,9 @@ CopyDigestListToBuffer (
 DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
 CopyMem (Buffer, >digests[Index].digest, DigestSize);
 Buffer = (UINT8 *)Buffer + DigestSize;
+DigestListCount++;
   }
+  WriteUnaligned32 (DigestListCountPtr, DigestListCount);
 
   return Buffer;
 }
-- 
2.7.0.windows.1

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