Re: [edk2] [Patch] ShellPkg: Enhance ping to select the interface automatically

2016-04-28 Thread Wu, Jiaxin
Siyuan,

I'm not prefer to handle the link local src address selecting automatically to 
make things more complexity. 

Just follow the guide that src address is required when pinging a link-local 
address no matter multiple or single interface in platform. But, I will update 
the patch to add a hint info this case. Do you agree?

Thanks for the comments.

Jiaxin





> -Original Message-
> From: Fu, Siyuan
> Sent: Thursday, April 28, 2016 11:03 AM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Cc: David Van Arnem ; Bhupesh Sharma
> ; Carsey, Jaben ; Ye,
> Ting 
> Subject: RE: [Patch] ShellPkg: Enhance ping to select the interface
> automatically
> 
> Hi, Jiaxin
> 
> A interface with only link local address should be allowed as the src if the 
> dest
> is also an link local address, right?
> 
> And the 2 if conditions in line 1052 is better to change to a "if 
> (UnspecifiedSrc)
> else ..." so it's more readable.
> 
> If (UnspecifiedSrc && !NetIp6IsUnspecifiedAddr (Addr)
> && !NetIp6IsLinkLocalAddr (Addr)){
> }
> if (!UnspecifiedSrc && EFI_IP6_EQUAL (&Private->SrcAddress, Addr)) {
> }
> 
> Best Regards
> Siyuan
> 
> > -Original Message-
> > From: Wu, Jiaxin
> > Sent: Tuesday, April 19, 2016 9:52 AM
> > To: edk2-devel@lists.01.org
> > Cc: David Van Arnem ; Bhupesh Sharma
> > ; Carsey, Jaben ;
> Ye,
> > Ting ; Fu, Siyuan 
> > Subject: [Patch] ShellPkg: Enhance ping to select the interface
> > automatically
> >
> > This patch is used to support no source IP specified case while
> > multiple NICs existed in the platform. The command will select the
> > first both connected and configured interface automatically.
> >
> > Cc: David Van Arnem 
> > Cc: Bhupesh Sharma 
> > Cc: Jaben Carsey 
> > Cc: Ye Ting 
> > Cc: Fu Siyuan 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Jiaxin Wu 
> > ---
> >  .../Library/UefiShellNetwork1CommandsLib/Ping.c| 224 -
> -
> > ---
> >  1 file changed, 127 insertions(+), 97 deletions(-)
> >
> > diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> > index 13bcdde..6b05884 100644
> > --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> > +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> > @@ -874,20 +874,24 @@ PingCreateIpInstance (  {
> >EFI_STATUS   Status;
> >UINTNHandleIndex;
> >UINTNHandleNum;
> >EFI_HANDLE   *HandleBuffer;
> > +  BOOLEAN  UnspecifiedSrc;
> > +  BOOLEAN  MediaPresent;
> >EFI_SERVICE_BINDING_PROTOCOL *EfiSb;
> >VOID *IpXCfg;
> >EFI_IP6_CONFIG_DATA  Ip6Config;
> >EFI_IP4_CONFIG_DATA  Ip4Config;
> >VOID *IpXInterfaceInfo;
> >UINTNIfInfoSize;
> >EFI_IPv6_ADDRESS *Addr;
> >UINTNAddrIndex;
> >
> >HandleBuffer  = NULL;
> > +  UnspecifiedSrc= FALSE;
> > +  MediaPresent  = TRUE;
> >EfiSb = NULL;
> >IpXInterfaceInfo  = NULL;
> >IfInfoSize= 0;
> >
> >//
> > @@ -923,139 +927,165 @@ PingCreateIpInstance (
> >ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", mSrcString);
> >Status = EFI_INVALID_PARAMETER;
> >goto ON_ERROR;
> >  }
> >}
> > +
> > +  if (Private->IpChoice == PING_IP_CHOICE_IP6 ?
> > + NetIp6IsUnspecifiedAddr
> > ((EFI_IPv6_ADDRESS*)&Private->SrcAddress) : \
> > +  PingNetIp4IsUnspecifiedAddr ((EFI_IPv4_ADDRESS*)&Private-
> > >SrcAddress)) {
> > +//
> > +// SrcAddress is unspecified. So, both connected and configured
> > + interface
> > will be automatic selected.
> > +//
> > +UnspecifiedSrc = TRUE;
> > +  }
> > +
> >//
> >// For each ip6 protocol, check interface addresses list.
> >//
> >for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
> > -
> >  EfiSb = NULL;
> >  IpXInterfaceInfo  = NULL;
> >  IfInfoSize= 0;
> >
> > +if (UnspecifiedSrc) {
> > +  //
> > +  // Check media.
> > +  //
> > +  NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
> > +  if (!MediaPresent) {
> > +//
> > +// Skip this one.
> > +//
> > +continue;
> > +  }
> > +}
> > +
> >  Status = gBS->HandleProtocol (
> >  HandleBuffer[HandleIndex],
> >  Private->IpChoice ==
> >
> PING_IP_CHOICE_IP6?&gEfiIp6ServiceBindingProtocolGuid:&gEfiIp4ServiceB
> > i
> > ndingProtocolGuid,
> >  (VOID **) &EfiSb
> >  );
> >  if (EFI_ERROR (Status)) {
> >goto ON_ERROR;
> >  }
> >
> > -if (Private->Ip

[edk2] [Patch] BaseTools: fix the bug for FMP to support use Macro as path description

2016-04-28 Thread Yonghong Zhu
Fix the bug for FMP image to support to use Macro as path description,
eg: FILE DATA = $(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/test.efi

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 72fb3dc..39f951a 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -3433,13 +3433,12 @@ class FdfParser:
 
 if not self.__GetNextToken():
 raise Warning("expected File name", self.FileName, 
self.CurrentLineNumber)
 
 AnyFileName = self.__Token
-AnyFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(AnyFileName)
-if not os.path.exists(AnyFileName):
-raise Warning("File %s not exists"%AnyFileName, self.FileName, 
self.CurrentLineNumber)
+self.__VerifyFile(AnyFileName)
+
 return AnyFileName
 
 ## __GetAnyFileStatement() method
 #
 #   Get AnyFile for capsule
-- 
2.6.1.windows.1

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


[edk2] [Patch] BaseTools: Support \x####\ in UNI files to specify non-ascii characters

2016-04-28 Thread Yonghong Zhu
UNI spec updated to allow using \x\ to specify non-ascii characters,
# is a hex digit.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Source/Python/AutoGen/UniClassObject.py | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py 
b/BaseTools/Source/Python/AutoGen/UniClassObject.py
index a01381b..84de53a 100644
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
@@ -2,11 +2,11 @@
 # This file is used to collect all defined strings in multiple uni files
 #
 #
 # Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
 #
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+# 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
 #
@@ -421,10 +421,19 @@ class UniFileClassObject(object):
 
 Line = Line.replace(UNICODE_WIDE_CHAR, WIDE_CHAR)
 Line = Line.replace(UNICODE_NARROW_CHAR, NARROW_CHAR)
 Line = Line.replace(UNICODE_NON_BREAKING_CHAR, NON_BREAKING_CHAR)
 
+StartPos = Line.find(u'\\x')
+while (StartPos != -1):
+EndPos = Line.find(u'\\', StartPos + 1, StartPos + 7)
+if EndPos != -1 and EndPos - StartPos == 6 :
+Str = Line[StartPos : EndPos + 1]
+UniStr = ('\u' + (Line[StartPos + 2 : 
EndPos])).decode('unicode_escape')
+Line = Line[0 : StartPos] + (Line[StartPos : EndPos + 
1]).replace(Str, UniStr) + Line[EndPos + 1 : ]
+StartPos = Line.find(u'\\x', StartPos + 1)
+
 Line = Line.replace(u'\\r\\n', CR + LF)
 Line = Line.replace(u'\\n', CR + LF)
 Line = Line.replace(u'\\r', CR)
 Line = Line.replace(u'\\t', u' ')
 Line = Line.replace(u'\t', u' ')
-- 
2.6.1.windows.1

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


Re: [edk2] [Patch] ShellPkg: Enhance ping to select the interface automatically

2016-04-28 Thread Fu, Siyuan
Jiaxin,

I agree, we'd better to keep the interface auto select in a simple range, for 
the complex case we could ask user to provide a source address for the 
selection.

And to print out a message to user in the case that a source address argument 
is mandatory will be helpful.

Reviewed-by: Fu Siyuan 

Best Regards
Siyuan

From: Wu, Jiaxin
Sent: Thursday, April 28, 2016 3:03 PM
To: Fu, Siyuan ; edk2-devel@lists.01.org
Cc: David Van Arnem ; Bhupesh Sharma 
; Carsey, Jaben ; Ye, Ting 

Subject: RE: [Patch] ShellPkg: Enhance ping to select the interface 
automatically

Siyuan,

I'm not prefer to handle the link local src address selecting automatically to 
make things more complexity.

Just follow the guide that src address is required when pinging a link-local 
address no matter multiple or single interface in platform. But, I will update 
the patch to add a hint info this case. Do you agree?

Thanks for the comments.

Jiaxin





> -Original Message-
> From: Fu, Siyuan
> Sent: Thursday, April 28, 2016 11:03 AM
> To: Wu, Jiaxin mailto:jiaxin...@intel.com>>; 
> edk2-devel@lists.01.org
> Cc: David Van Arnem mailto:dvanar...@cmlab.biz>>; 
> Bhupesh Sharma
> mailto:bhupesh.sha...@nxp.com>>; Carsey, Jaben 
> mailto:jaben.car...@intel.com>>; Ye,
> Ting mailto:ting...@intel.com>>
> Subject: RE: [Patch] ShellPkg: Enhance ping to select the interface
> automatically
>
> Hi, Jiaxin
>
> A interface with only link local address should be allowed as the src if the 
> dest
> is also an link local address, right?
>
> And the 2 if conditions in line 1052 is better to change to a "if 
> (UnspecifiedSrc)
> else ..." so it's more readable.
>
> If (UnspecifiedSrc && !NetIp6IsUnspecifiedAddr (Addr)
> && !NetIp6IsLinkLocalAddr (Addr)){
> }
> if (!UnspecifiedSrc && EFI_IP6_EQUAL (&Private->SrcAddress, Addr)) {
> }
>
> Best Regards
> Siyuan
>
> > -Original Message-
> > From: Wu, Jiaxin
> > Sent: Tuesday, April 19, 2016 9:52 AM
> > To: edk2-devel@lists.01.org
> > Cc: David Van Arnem mailto:dvanar...@cmlab.biz>>; 
> > Bhupesh Sharma
> > mailto:bhupesh.sha...@nxp.com>>; Carsey, Jaben 
> > mailto:jaben.car...@intel.com>>;
> Ye,
> > Ting mailto:ting...@intel.com>>; Fu, Siyuan 
> > mailto:siyuan...@intel.com>>
> > Subject: [Patch] ShellPkg: Enhance ping to select the interface
> > automatically
> >
> > This patch is used to support no source IP specified case while
> > multiple NICs existed in the platform. The command will select the
> > first both connected and configured interface automatically.
> >
> > Cc: David Van Arnem mailto:dvanar...@cmlab.biz>>
> > Cc: Bhupesh Sharma mailto:bhupesh.sha...@nxp.com>>
> > Cc: Jaben Carsey mailto:jaben.car...@intel.com>>
> > Cc: Ye Ting mailto:ting...@intel.com>>
> > Cc: Fu Siyuan mailto:siyuan...@intel.com>>
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Jiaxin Wu mailto:jiaxin...@intel.com>>
> > ---
> >  .../Library/UefiShellNetwork1CommandsLib/Ping.c| 224 -
> -
> > ---
> >  1 file changed, 127 insertions(+), 97 deletions(-)
> >
> > diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> > index 13bcdde..6b05884 100644
> > --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> > +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> > @@ -874,20 +874,24 @@ PingCreateIpInstance (  {
> >EFI_STATUS   Status;
> >UINTNHandleIndex;
> >UINTNHandleNum;
> >EFI_HANDLE   *HandleBuffer;
> > +  BOOLEAN  UnspecifiedSrc;
> > +  BOOLEAN  MediaPresent;
> >EFI_SERVICE_BINDING_PROTOCOL *EfiSb;
> >VOID *IpXCfg;
> >EFI_IP6_CONFIG_DATA  Ip6Config;
> >EFI_IP4_CONFIG_DATA  Ip4Config;
> >VOID *IpXInterfaceInfo;
> >UINTNIfInfoSize;
> >EFI_IPv6_ADDRESS *Addr;
> >UINTNAddrIndex;
> >
> >HandleBuffer  = NULL;
> > +  UnspecifiedSrc= FALSE;
> > +  MediaPresent  = TRUE;
> >EfiSb = NULL;
> >IpXInterfaceInfo  = NULL;
> >IfInfoSize= 0;
> >
> >//
> > @@ -923,139 +927,165 @@ PingCreateIpInstance (
> >ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", mSrcString);
> >Status = EFI_INVALID_PARAMETER;
> >goto ON_ERROR;
> >  }
> >}
> > +
> > +  if (Private->IpChoice == PING_IP_CHOICE_IP6 ?
> > + NetIp6IsUnspecifiedAddr
> > ((EFI_IPv6_ADDRESS*)&Private->SrcAddress) : \
> > +  PingNetIp4IsUnspecifiedAddr ((EFI_IPv4_ADDRESS*)&Private-
> > >SrcAddress)) {
> > +//
> > +// SrcAddress is unspecified. So, both conn

[edk2] [PATCH 4/5] SecurityPkg: AuthVariableLib: Remove Customized SecureBoot Mode transition.

2016-04-28 Thread Zhang, Chao B
  Remove Customized SecureBoot Mode transition logic for Mantis 1263, including 
AuditMode/DeployedMode/PK update management.
  Also remove image verification logic in AuditMode.
The feature has been moved to
  https://github.com/tianocore/edk2-staging/tree/Customized-Secure-Boot
Previous check-in hash is
  SHA-1: 4fc08e8d683522f255727626197d919a40d4836c

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang 
---
 SecurityPkg/Library/AuthVariableLib/AuthService.c  | 1405 +++-
 .../Library/AuthVariableLib/AuthServiceInternal.h  |   92 --
 .../Library/AuthVariableLib/AuthVariableLib.c  |   97 +-
 .../Library/AuthVariableLib/AuthVariableLib.inf|4 -
 .../DxeImageVerificationLib.c  |  621 +
 5 files changed, 295 insertions(+), 1924 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index 4649e50..6e1e284 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -56,54 +56,6 @@ EFI_SIGNATURE_ITEM mSupportSigItem[] = {
   {EFI_CERT_X509_SHA512_GUID, 0,   80   }
 };
 
-//
-// Secure Boot Mode state machine
-//
-SECURE_BOOT_MODE mSecureBootState[SecureBootModeTypeMax] = {
-  // USER MODE
-  {
-  AUDIT_MODE_DISABLE,// AuditMode
-  FALSE, // IsAuditModeRO, AuditMode 
is RW
-  DEPLOYED_MODE_DISABLE, // DeployedMode
-  FALSE, // IsDeployedModeRO, 
DeployedMode is RW
-  SETUP_MODE_DISABLE,// SetupMode
- // SetupMode is always RO
-  SECURE_BOOT_MODE_ENABLE// SecureBoot
-  },
-  // SETUP MODE
-  {
-  AUDIT_MODE_DISABLE,// AuditMode
-  FALSE, // IsAuditModeRO, AuditMode 
is RW
-  DEPLOYED_MODE_DISABLE, // DeployedMode
-  TRUE,  // IsDeployedModeRO, 
DeployedMode is RO
-  SETUP_MODE_ENABLE, // SetupMode
- // SetupMode is always RO
-  SECURE_BOOT_MODE_DISABLE   // SecureBoot
-  },
-  // AUDIT MODE
-  {
-  AUDIT_MODE_ENABLE, // AuditMode
-  TRUE,  // AuditModeValAttr RO, 
AuditMode is RO
-  DEPLOYED_MODE_DISABLE, // DeployedMode
-  TRUE,  // DeployedModeValAttr RO, 
DeployedMode is RO
-  SETUP_MODE_ENABLE, // SetupMode
- // SetupMode is always RO
-  SECURE_BOOT_MODE_DISABLE   // SecureBoot
-  },
-  // DEPLOYED MODE
-  {
-  AUDIT_MODE_DISABLE,// AuditMode, AuditMode is RO
-  TRUE,  // AuditModeValAttr RO
-  DEPLOYED_MODE_ENABLE,  // DeployedMode
-  TRUE,  // DeployedModeValAttr RO, 
DeployedMode is RO
-  SETUP_MODE_DISABLE,// SetupMode
- // SetupMode is always RO
-  SECURE_BOOT_MODE_ENABLE// SecureBoot
-  }
-};
-
-SECURE_BOOT_MODE_TYPE  mSecureBootMode;
-
 /**
   Finds variable in storage blocks of volatile and non-volatile storage areas.
 
@@ -221,976 +173,80 @@ AuthServiceInternalUpdateVariableWithMonotonicCount (
   AuthVariableInfo.PubKeyIndex = KeyIndex;
   AuthVariableInfo.MonotonicCount = MonotonicCount;
 
-  return mAuthVarLibContextIn->UpdateVariable (
-   &AuthVariableInfo
-   );
-}
-
-/**
-  Update the variable region with Variable information.
-
-  @param[in] VariableName   Name of variable.
-  @param[in] VendorGuid Guid of variable.
-  @param[in] Data   Data pointer.
-  @param[in] DataSize   Size of Data.
-  @param[in] Attributes Attribute value of the variable.
-  @param[in] TimeStamp  Value of associated TimeStamp.
-
-  @retval EFI_SUCCESS   The update operation is success.
-  @retval EFI_INVALID_PARAMETER Invalid parameter.
-  @retval EFI_WRITE_PROTECTED   Variable is write-protected.
-  @retval EFI_OUT_OF_RESOURCES  There is not enough resource.
-
-**/
-EFI_STATUS
-AuthServiceInternalUpdateVariableWithTimeStamp (
-  IN CHAR16 *VariableName,
-  IN EFI_GUID   *VendorGuid,
-  IN VOID   *Data,
-  IN UINTN  DataSize,
-  IN UINT32 Attributes,
-  IN EFI_TIME   *TimeStamp
-  )
-{
-  EFI_STATUSFindStatus;
-  VOID  *OrgData;
-  UINTN OrgDataSize;
-  AUTH_V

[edk2] [PATCH 1/5] MdePkg: Revert AuditMode/DeployedMode name definition

2016-04-28 Thread Zhang, Chao B
Revert AuditMode/DeployedMode definition from Customized Secure Boot feature 
defined in UEFI2.5 Mantis 1263.
The feature has been moved to
  https://github.com/tianocore/edk2-staging/tree/Customized-Secure-Boot
Previous check-in hash is
  SHA-1: 79e7b6472797f156d1ff28f3022b25d9c6f250f9

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang 
---
 MdePkg/Include/Guid/GlobalVariable.h  | 16 +---
 MdePkg/Include/Guid/ImageAuthentication.h | 15 ++-
 2 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/MdePkg/Include/Guid/GlobalVariable.h 
b/MdePkg/Include/Guid/GlobalVariable.h
index e58f7a1..0804236 100644
--- a/MdePkg/Include/Guid/GlobalVariable.h
+++ b/MdePkg/Include/Guid/GlobalVariable.h
@@ -1,7 +1,7 @@
 /** @file
   GUID for EFI (NVRAM) Variables.
 
-  Copyright (c) 2006 - 2015, 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
@@ -126,20 +126,6 @@ extern EFI_GUID gEfiGlobalVariableGuid;
 ///
 #define EFI_SETUP_MODE_NAME L"SetupMode"
 ///
-/// Whether the system is operating in audit mode (1) or not (0).
-/// All other values are reserved. Should be treated as read-only except when 
DeployedMode is 0.
-/// Always becomes read-only after ExitBootServices() is called.
-/// Its attribute is BS+RT.
-///
-#define EFI_AUDIT_MODE_NAME L"AuditMode"
-///
-/// Whether the system is operating in deployed mode (1) or not (0).
-/// All other values are reserved. Should be treated as read-only when its 
value is 1.
-/// Always becomes read-only after ExitBootServices() is called.
-/// Its attribute is BS+RT.
-///
-#define EFI_DEPLOYED_MODE_NAME  L"DeployedMode"
-///
 /// The Key Exchange Key Signature Database.
 /// Its attribute is NV+BS+RT+AT.
 ///
diff --git a/MdePkg/Include/Guid/ImageAuthentication.h 
b/MdePkg/Include/Guid/ImageAuthentication.h
index c733643..3b3b7b5 100644
--- a/MdePkg/Include/Guid/ImageAuthentication.h
+++ b/MdePkg/Include/Guid/ImageAuthentication.h
@@ -1,7 +1,7 @@
 /** @file
   Image signature database are defined for the signed image validation.
 
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 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
@@ -43,20 +43,9 @@
 
 #define SECURE_BOOT_MODE_ENABLE   1
 #define SECURE_BOOT_MODE_DISABLE  0
-///
-/// Depricated value definition for SetupMode variable 
-///
+
 #define SETUP_MODE1
 #define USER_MODE 0
-///
-/// Value definition for SetupMode/DeployedMode/AuditMode variable
-///
-#define SETUP_MODE_ENABLE 1
-#define SETUP_MODE_DISABLE0
-#define DEPLOYED_MODE_ENABLE  1
-#define DEPLOYED_MODE_DISABLE 0
-#define AUDIT_MODE_ENABLE 1
-#define AUDIT_MODE_DISABLE0
 
 //***
 // Signature Database
-- 
1.9.5.msysgit.1

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


[edk2] [PATCH 5/5] SecurityPkg: SecureBootConfigDxe: Remove SecureBoot UI change for Customized Secure Boot

2016-04-28 Thread Zhang, Chao B
  Remove SecureBoot UI support for Customized SecureBoot Mode transition 
according to Mantis 1263.
The feature has been moved to
  https://github.com/tianocore/edk2-staging/tree/Customized-Secure-Boot
Previous check-in hash is
  SHA-1: 96832eefea1025c130979dec9b7da069f77bcd96

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang 
---
 .../SecureBootConfigDxe/SecureBootConfig.vfr   |  37 +-
 .../SecureBootConfigDxe/SecureBootConfigImpl.c | 385 ++---
 .../SecureBootConfigDxe/SecureBootConfigNvData.h   |   7 -
 .../SecureBootConfigStrings.uni|  20 +-
 4 files changed, 32 insertions(+), 417 deletions(-)

diff --git 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr 
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
index 484da2c..fefbfbf 100644
--- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
+++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
@@ -33,14 +33,6 @@ formset
 
 subtitle text = STRING_TOKEN(STR_NULL);
 
-//
-// Display current secure boot mode(one of 
SetupMode/AuditMode/UserMode/DeployedMode)
-//
-text
-  help   = STRING_TOKEN(STR_CUR_SECURE_BOOT_MODE_HELP),
-  text   = STRING_TOKEN(STR_CUR_SECURE_BOOT_MODE_PROMPT),
-text   = STRING_TOKEN(STR_CUR_SECURE_BOOT_MODE_CONTENT);
-
 text
   help   = STRING_TOKEN(STR_SECURE_BOOT_STATE_HELP),
   text   = STRING_TOKEN(STR_SECURE_BOOT_STATE_PROMPT),
@@ -71,7 +63,7 @@ formset
 endoneof;
 
 //
-// Display PK include page
+// Display of 'Current Secure Boot Mode'
 //
 suppressif questionref(SecureBootMode) == SECURE_BOOT_MODE_STANDARD;
 grayoutif NOT ideqval SECUREBOOT_CONFIGURATION.PhysicalPresent == 1;
@@ -93,33 +85,6 @@ formset
 
 subtitle text = STRING_TOKEN(STR_NULL);
 
-//
-// Display of SetupMode/UserMode/AuditMode/DeployedMode transition
-//
-oneof name   = TransSecureBootMode,
-questionid = KEY_TRANS_SECURE_BOOT_MODE,
-prompt = STRING_TOKEN(STR_TRANS_SECURE_BOOT_MODE_PROMPT),
-help   = STRING_TOKEN(STR_TRANS_SECURE_BOOT_MODE_HELP),
-flags  = INTERACTIVE | NUMERIC_SIZE_1,
-  suppressif ideqval SECUREBOOT_CONFIGURATION.CurSecureBootMode == 
SECURE_BOOT_MODE_AUDIT_MODE 
-  OR (ideqval SECUREBOOT_CONFIGURATION.CurSecureBootMode == 
SECURE_BOOT_MODE_DEPLOYED_MODE AND
-  ideqval SECUREBOOT_CONFIGURATION.PhysicalPresent == 0);
-option text = STRING_TOKEN(STR_USER_MODE), value = 
SECURE_BOOT_MODE_USER_MODE,   flags = 0;
-  endif
-  suppressif ideqval SECUREBOOT_CONFIGURATION.CurSecureBootMode == 
SECURE_BOOT_MODE_AUDIT_MODE;
-option text = STRING_TOKEN(STR_SETUP_MODE),value = 
SECURE_BOOT_MODE_SETUP_MODE,  flags = 0;
-  endif
-  suppressif ideqval SECUREBOOT_CONFIGURATION.CurSecureBootMode == 
SECURE_BOOT_MODE_DEPLOYED_MODE;
-option text = STRING_TOKEN(STR_AUDIT_MODE),value = 
SECURE_BOOT_MODE_AUDIT_MODE,  flags = 0;
-  endif
-  suppressif ideqval SECUREBOOT_CONFIGURATION.CurSecureBootMode == 
SECURE_BOOT_MODE_SETUP_MODE;
-option text = STRING_TOKEN(STR_DEPLOYED_MODE), value = 
SECURE_BOOT_MODE_DEPLOYED_MODE,  flags = 0;
-  endif
-
-endoneof;
-
-subtitle text = STRING_TOKEN(STR_NULL);
-
 goto FORMID_SECURE_BOOT_PK_OPTION_FORM,
  prompt = STRING_TOKEN(STR_SECURE_BOOT_PK_OPTION),
  help   = STRING_TOKEN(STR_SECURE_BOOT_PK_OPTION_HELP),
diff --git 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c 
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
index c8f4d97..088fa26 100644
--- 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
+++ 
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
@@ -49,8 +49,6 @@ HII_VENDOR_DEVICE_PATH  
mSecureBootHiiVendorDevicePath = {
 
 
 BOOLEAN mIsEnterSecureBootForm = FALSE;
-BOOLEAN mIsSelectedSecureBootModeForm = FALSE;
-BOOLEAN mIsSecureBootModeChanged = FALSE;
 
 //
 // OID ASN.1 Value for Hash Algorithms
@@ -2833,256 +2831,6 @@ ON_EXIT:
 }
 
 /**
-  Perform secure boot mode transition from User Mode by setting AuditMode 
-  or DeployedMode variable.
-
-  @param[in]  NewMode  New secure boot mode.
-
-  @retval   EFI_SUCCESSSecure Boot mode transition is successful.
-**/
-EFI_STATUS
-TransitionFromUserMode(
-  IN  UINT8 NewMode
-  )
-{
-  UINT8  Data;
-  EFI_STATUS Status;
-
-  if (NewMode == SECURE_BOOT_MODE_AUDIT_MODE) {
-Data = 1;
-Status = gRT->SetVariable(
-EFI_AUDIT_MODE_NAME,
-&gEfiGlobalVariableGuid,
-EFI_VARIABLE_BOOTSERVICE_ACCESS | 
EFI_VARIABLE_RUNTIME_ACCESS,
-sizeof(UINT8),
-&Data
-

[edk2] [PATCH 3/5] SecurityPkg: Remove gEdkiiSecureBootModeGuid definition

2016-04-28 Thread Zhang, Chao B
Remove gEdkiiSecureBootModeGuid definition for Customized Secure Boot feature 
defined in
UEFI2.5 Mantis 1263. It is a private variable GUID.
The feature has been moved to
  https://github.com/tianocore/edk2-staging/tree/Customized-Secure-Boot
Previous check-in hash is
  SHA-1: af9af05bec5b1880f8e4f9142ecc0044fd0acb33

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang 
---
 SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h | 3 +--
 SecurityPkg/SecurityPkg.dec| 4 
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h 
b/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
index 7094d52..55fd92a 100644
--- a/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
+++ b/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
@@ -5,7 +5,7 @@
   and variable storage region headers that has been moved to
   VariableFormat.h.
 
-Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 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
@@ -28,7 +28,6 @@ extern EFI_GUID gEfiSecureBootEnableDisableGuid;
 extern EFI_GUID gEfiCertDbGuid;
 extern EFI_GUID gEfiCustomModeEnableGuid;
 extern EFI_GUID gEfiVendorKeysNvGuid;
-extern EFI_GUID gEdkiiSecureBootModeGuid;
 
 ///
 /// "SecureBootEnable" variable for the Secure Boot feature enable/disable.
diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index 99cda26..f4f3174 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -122,10 +122,6 @@
   #  Include/Guid/AuthenticatedVariableFormat.h
   gEfiCertDbGuid = { 0xd9bee56e, 0x75dc, 0x49d9, { 0xb4, 
0xd7, 0xb5, 0x34, 0x21, 0xf, 0x63, 0x7a } }
 
-  ## GUID used to "SecureBootMode" variable to save platform secure boot mode
-  #  Include/Guid/AuthenticatedVariableFormat.h
-  gEdkiiSecureBootModeGuid   = { 0xc573b77, 0xeb93, 0x4d3d, { 0xaf, 
0xfc, 0x5f, 0xeb, 0xca, 0xfb, 0x65, 0xb0 } }
-
   ## Hob GUID used to pass a TCG_PCR_EVENT from a TPM PEIM to a TPM DXE Driver.
   #  Include/Guid/TcgEventHob.h
   gTcgEventEntryHobGuid  = { 0x2b9ffb52, 0x1b13, 0x416f, { 0xa8, 
0x7b, 0xbc, 0x93, 0xd, 0xef, 0x92, 0xa8 }}
-- 
1.9.5.msysgit.1

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


[edk2] [PATCH 2/5] MdeModulePkg: VarCheckUefiLib: Remove DeployedMode/AuditMode var check logic

2016-04-28 Thread Zhang, Chao B
Remove DeployedMode & AuditMode Global variable check for Customized Secure 
Boot feature defined in UEFI2.5 Mantis 1263.
The feature has been moved to
  https://github.com/tianocore/edk2-staging/tree/Customized-Secure-Boot
Previous check-in hash is
  SHA-1: 0f4f6d202a47e3882c6a7fb7ab9e55dda78a8113

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang 
---
 .../VarCheckUefiLib/VarCheckUefiLibNullClass.c | 24 +-
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c 
b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
index 1d0bc2a..8f7126e 100644
--- a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
+++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation functions and structures for var check uefi library.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 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
@@ -426,28 +426,6 @@ UEFI_DEFINED_VARIABLE_ENTRY mGlobalVariableList[] = {
 NULL
   },
   {
-EFI_AUDIT_MODE_NAME,
-{
-  VAR_CHECK_VARIABLE_PROPERTY_REVISION,
-  0,
-  VARIABLE_ATTRIBUTE_BS_RT,
-  sizeof (UINT8),
-  sizeof (UINT8)
-},
-NULL
-  },
-  {
-EFI_DEPLOYED_MODE_NAME,
-{
-  VAR_CHECK_VARIABLE_PROPERTY_REVISION,
-  0,
-  VARIABLE_ATTRIBUTE_BS_RT,
-  sizeof (UINT8),
-  sizeof (UINT8)
-},
-NULL
-  },
-  {
 EFI_KEY_EXCHANGE_KEY_NAME,
 {
   VAR_CHECK_VARIABLE_PROPERTY_REVISION,
-- 
1.9.5.msysgit.1

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


[edk2] [PATCH v2] ShellPkg: Enhance ping6 to select the interface automatically

2016-04-28 Thread Jiaxin Wu
v2:
* Refine the code to make it more readable.

This patch is used to support no source IP specified case while
multiple NICs existed in the platform. The command will select the
first both connected and configured interface automatically.
Note: Source address is always required when pinging a
link-local address.

Cc: Bhupesh Sharma 
Cc: Jaben Carsey 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 .../Library/UefiShellNetwork2CommandsLib/Ping6.c   | 166 -
 1 file changed, 95 insertions(+), 71 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
index af7d08f..e4ae977 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
@@ -661,22 +661,26 @@ Ping6CreateIpInstance (
 {
   EFI_STATUS   Status;
   UINTNHandleIndex;
   UINTNHandleNum;
   EFI_HANDLE   *HandleBuffer;
+  BOOLEAN  UnspecifiedSrc;
+  BOOLEAN  MediaPresent;
   EFI_SERVICE_BINDING_PROTOCOL *Ip6Sb;
   EFI_IP6_CONFIG_PROTOCOL  *Ip6Cfg;
   EFI_IP6_CONFIG_DATA  Ip6Config;
   EFI_IP6_CONFIG_INTERFACE_INFO*IfInfo;
   UINTNIfInfoSize;
   EFI_IPv6_ADDRESS *Addr;
   UINTNAddrIndex;
 
-  HandleBuffer = NULL;
-  Ip6Sb= NULL;
-  IfInfo   = NULL;
-  IfInfoSize   = 0;
+  HandleBuffer  = NULL;
+  UnspecifiedSrc= FALSE;
+  MediaPresent  = TRUE;
+  Ip6Sb = NULL;
+  IfInfo= NULL;
+  IfInfoSize= 0;
 
   //
   // Locate all the handles with ip6 service binding protocol.
   //
   Status = gBS->LocateHandleBuffer (
@@ -687,113 +691,133 @@ Ping6CreateIpInstance (
   &HandleBuffer
   );
   if (EFI_ERROR (Status) || (HandleNum == 0)) {
 return EFI_ABORTED;
   }
+
+  if (NetIp6IsUnspecifiedAddr (&Private->SrcAddress)) {
+//
+// SrcAddress is unspecified. So, both connected and configured interface 
will be automatic selected. 
+//
+UnspecifiedSrc = TRUE;
+  }
+  
   //
-  // Source address is required when pinging a link-local address on multi-
-  // interfaces host.
+  // Source address is required when pinging a link-local address.
   //
-  if (NetIp6IsLinkLocalAddr (&Private->DstAddress) &&
-  NetIp6IsUnspecifiedAddr (&Private->SrcAddress) &&
-  (HandleNum > 1)) {
+  if (NetIp6IsLinkLocalAddr (&Private->DstAddress) && UnspecifiedSrc) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_SOURCE), 
gShellNetwork2HiiHandle);
 Status = EFI_INVALID_PARAMETER;
 goto ON_ERROR;
   }
+  
   //
   // For each ip6 protocol, check interface addresses list.
   //
   for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
 
 Ip6Sb  = NULL;
 IfInfo = NULL;
 IfInfoSize = 0;
 
+if (UnspecifiedSrc) {
+  //
+  // Check media.
+  //
+  NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
+  if (!MediaPresent) {
+//
+// Skip this one.
+//
+continue;
+  }
+}
+
 Status = gBS->HandleProtocol (
 HandleBuffer[HandleIndex],
 &gEfiIp6ServiceBindingProtocolGuid,
 (VOID **) &Ip6Sb
 );
 if (EFI_ERROR (Status)) {
   goto ON_ERROR;
 }
 
-if (NetIp6IsUnspecifiedAddr (&Private->SrcAddress)) {
-  //
-  // No need to match interface address.
-  //
-  break;
-} else {
-  //
-  // Ip6config protocol and ip6 service binding protocol are installed
-  // on the same handle.
-  //
-  Status = gBS->HandleProtocol (
-  HandleBuffer[HandleIndex],
-  &gEfiIp6ConfigProtocolGuid,
-  (VOID **) &Ip6Cfg
-  );
+//
+// Ip6config protocol and ip6 service binding protocol are installed
+// on the same handle.
+//
+Status = gBS->HandleProtocol (
+HandleBuffer[HandleIndex],
+&gEfiIp6ConfigProtocolGuid,
+(VOID **) &Ip6Cfg
+);
 
-  if (EFI_ERROR (Status)) {
-goto ON_ERROR;
-  }
-  //
-  // Get the interface information size.
-  //
-  Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &IfInfoSize,
- NULL
- );
-
-  if (Status != EFI_BUFFER_TOO_SMALL) {
-ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_PING6_IP6CFG_GETDATA), gShellNetwork2HiiHandle, Status);
-goto ON_ERROR;
-  }
+if (EFI_ERROR (Status)) 

[edk2] [PATCH v2] ShellPkg: Enhance ping to select the interface automatically

2016-04-28 Thread Jiaxin Wu
v2:
* A. Refine the code to make it more readable.
* B. Add hint message for link local address case.

This patch is used to support no source IP specified case
while multiple NICs existed in the platform. The command
will select the first both connected and configured interface
automatically.
Note: Source address is always required when pinging a
link-local address.

Cc: David Van Arnem 
Cc: Bhupesh Sharma 
Cc: Jaben Carsey 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 .../Library/UefiShellNetwork1CommandsLib/Ping.c| 229 -
 .../UefiShellNetwork1CommandsLib.uni   |   1 +
 2 files changed, 129 insertions(+), 101 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
index 13bcdde..abd2f6b 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
@@ -874,20 +874,24 @@ PingCreateIpInstance (
 {
   EFI_STATUS   Status;
   UINTNHandleIndex;
   UINTNHandleNum;
   EFI_HANDLE   *HandleBuffer;
+  BOOLEAN  UnspecifiedSrc;
+  BOOLEAN  MediaPresent;
   EFI_SERVICE_BINDING_PROTOCOL *EfiSb;
   VOID *IpXCfg;
   EFI_IP6_CONFIG_DATA  Ip6Config;
   EFI_IP4_CONFIG_DATA  Ip4Config;
   VOID *IpXInterfaceInfo;
   UINTNIfInfoSize;
   EFI_IPv6_ADDRESS *Addr;
   UINTNAddrIndex;
 
   HandleBuffer  = NULL;
+  UnspecifiedSrc= FALSE;
+  MediaPresent  = TRUE;
   EfiSb = NULL;
   IpXInterfaceInfo  = NULL;
   IfInfoSize= 0;
 
   //
@@ -901,160 +905,183 @@ PingCreateIpInstance (
   &HandleBuffer
   );
   if (EFI_ERROR (Status) || (HandleNum == 0) || (HandleBuffer == NULL)) {
 return EFI_ABORTED;
   }
+
+  if (Private->IpChoice == PING_IP_CHOICE_IP6 ? NetIp6IsUnspecifiedAddr 
((EFI_IPv6_ADDRESS*)&Private->SrcAddress) : \
+  PingNetIp4IsUnspecifiedAddr ((EFI_IPv4_ADDRESS*)&Private->SrcAddress)) {
+//
+// SrcAddress is unspecified. So, both connected and configured interface 
will be automatic selected. 
+//
+UnspecifiedSrc = TRUE;
+  }
+  
   //
-  // Source address is required when pinging a link-local address on multi-
-  // interfaces host.
+  // Source address is required when pinging a link-local address.
   //
   if (Private->IpChoice == PING_IP_CHOICE_IP6) {
-if (NetIp6IsLinkLocalAddr ((EFI_IPv6_ADDRESS*)&Private->DstAddress) &&
-NetIp6IsUnspecifiedAddr ((EFI_IPv6_ADDRESS*)&Private->SrcAddress) &&
-(HandleNum > 1)) {
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), 
gShellNetwork1HiiHandle, L"ping", mSrcString);  
+if (NetIp6IsLinkLocalAddr ((EFI_IPv6_ADDRESS*)&Private->DstAddress) && 
UnspecifiedSrc) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_INVALID_SOURCE), 
gShellNetwork1HiiHandle);
   Status = EFI_INVALID_PARAMETER;
   goto ON_ERROR;
 }
   } else {
 ASSERT(Private->IpChoice == PING_IP_CHOICE_IP4);
-if (PingNetIp4IsLinkLocalAddr ((EFI_IPv4_ADDRESS*)&Private->DstAddress) &&
-PingNetIp4IsUnspecifiedAddr ((EFI_IPv4_ADDRESS*)&Private->SrcAddress) 
&&
-(HandleNum > 1)) {
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), 
gShellNetwork1HiiHandle, L"ping", mSrcString);  
+if (PingNetIp4IsLinkLocalAddr ((EFI_IPv4_ADDRESS*)&Private->DstAddress) && 
UnspecifiedSrc) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_INVALID_SOURCE), 
gShellNetwork1HiiHandle); 
   Status = EFI_INVALID_PARAMETER;
   goto ON_ERROR;
 }
   }
+  
   //
   // For each ip6 protocol, check interface addresses list.
   //
   for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
-
 EfiSb = NULL;
 IpXInterfaceInfo  = NULL;
 IfInfoSize= 0;
 
+if (UnspecifiedSrc) {
+  //
+  // Check media.
+  //
+  NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
+  if (!MediaPresent) {
+//
+// Skip this one.
+//
+continue;
+  }
+}
+
 Status = gBS->HandleProtocol (
 HandleBuffer[HandleIndex],
 Private->IpChoice == 
PING_IP_CHOICE_IP6?&gEfiIp6ServiceBindingProtocolGuid:&gEfiIp4ServiceBindingProtocolGuid,
 (VOID **) &EfiSb
 );
 if (EFI_ERROR (Status)) {
   goto ON_ERROR;
 }
 
-if (Private->IpChoice == PING_IP_CHOICE_IP6?NetIp6IsUnspecifiedAddr 
((EFI_IPv6_ADDRESS*)&Private->SrcAddress):PingNetIp4IsUnspecifiedAddr 
((EFI_IPv4_ADDRESS*)&Private->SrcAddress)) {
-  //
-  // No need to match 

[edk2] [PATCH] ShellPkg: Add NULL pointer check.

2016-04-28 Thread Qiu Shumin
Add pointer check to avoid NULL pointer dereferenced.

Cc: Jaben Carsey 
Cc: Tapan Shah 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin 
---
 .../UefiHandleParsingLib/UefiHandleParsingLib.c  | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 58f1814..830ee3b 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -301,14 +301,26 @@ GraphicsOutputProtocolDumpInformation(
 
   SHELL_FREE_NON_NULL (Temp);
   
-  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_MAIN), NULL);
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_MAIN), NULL);
+  if (Temp == NULL) {
+SHELL_FREE_NON_NULL (RetVal);
+goto EXIT;
+  }
 
   TempRetVal = CatSPrint (RetVal, Temp);
-  SHELL_FREE_NON_NULL (RetVal);
+  SHELL_FREE_NON_NULL (RetVal);
+  if (TempRetVal) {
+goto EXIT;
+  }
   RetVal = TempRetVal;
   SHELL_FREE_NON_NULL (Temp);
 
-  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_ENTRY), NULL);
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_ENTRY), NULL);
+  if (Temp == NULL) {
+SHELL_FREE_NON_NULL (RetVal);
+goto EXIT;
+  }
+
 
   for (Mode = 0; Mode < GraphicsOutput->Mode->MaxMode; Mode++) {
 Status = GraphicsOutput->QueryMode (
@@ -334,6 +346,8 @@ GraphicsOutputProtocolDumpInformation(
 RetVal = TempRetVal;
   }
 
+
+EXIT:
   SHELL_FREE_NON_NULL(Temp);
   SHELL_FREE_NON_NULL(Fmt);
 
-- 
2.7.1.windows.2

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


Re: [edk2] [PATCH v2] ShellPkg: Enhance ping to select the interface automatically

2016-04-28 Thread Fu, Siyuan
Reviewed-by: Fu Siyuan 


> -Original Message-
> From: Wu, Jiaxin
> Sent: Thursday, April 28, 2016 4:18 PM
> To: edk2-devel@lists.01.org
> Cc: David Van Arnem ; Bhupesh Sharma
> ; Carsey, Jaben ; Ye,
> Ting ; Fu, Siyuan 
> Subject: [PATCH v2] ShellPkg: Enhance ping to select the interface
> automatically
> 
> v2:
> * A. Refine the code to make it more readable.
> * B. Add hint message for link local address case.
> 
> This patch is used to support no source IP specified case
> while multiple NICs existed in the platform. The command
> will select the first both connected and configured interface
> automatically.
> Note: Source address is always required when pinging a
> link-local address.
> 
> Cc: David Van Arnem 
> Cc: Bhupesh Sharma 
> Cc: Jaben Carsey 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiaxin Wu 
> ---
>  .../Library/UefiShellNetwork1CommandsLib/Ping.c| 229 --
> ---
>  .../UefiShellNetwork1CommandsLib.uni   |   1 +
>  2 files changed, 129 insertions(+), 101 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> index 13bcdde..abd2f6b 100644
> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> @@ -874,20 +874,24 @@ PingCreateIpInstance (
>  {
>EFI_STATUS   Status;
>UINTNHandleIndex;
>UINTNHandleNum;
>EFI_HANDLE   *HandleBuffer;
> +  BOOLEAN  UnspecifiedSrc;
> +  BOOLEAN  MediaPresent;
>EFI_SERVICE_BINDING_PROTOCOL *EfiSb;
>VOID *IpXCfg;
>EFI_IP6_CONFIG_DATA  Ip6Config;
>EFI_IP4_CONFIG_DATA  Ip4Config;
>VOID *IpXInterfaceInfo;
>UINTNIfInfoSize;
>EFI_IPv6_ADDRESS *Addr;
>UINTNAddrIndex;
> 
>HandleBuffer  = NULL;
> +  UnspecifiedSrc= FALSE;
> +  MediaPresent  = TRUE;
>EfiSb = NULL;
>IpXInterfaceInfo  = NULL;
>IfInfoSize= 0;
> 
>//
> @@ -901,160 +905,183 @@ PingCreateIpInstance (
>&HandleBuffer
>);
>if (EFI_ERROR (Status) || (HandleNum == 0) || (HandleBuffer == NULL)) {
>  return EFI_ABORTED;
>}
> +
> +  if (Private->IpChoice == PING_IP_CHOICE_IP6 ? NetIp6IsUnspecifiedAddr
> ((EFI_IPv6_ADDRESS*)&Private->SrcAddress) : \
> +  PingNetIp4IsUnspecifiedAddr ((EFI_IPv4_ADDRESS*)&Private-
> >SrcAddress)) {
> +//
> +// SrcAddress is unspecified. So, both connected and configured interface
> will be automatic selected.
> +//
> +UnspecifiedSrc = TRUE;
> +  }
> +
>//
> -  // Source address is required when pinging a link-local address on multi-
> -  // interfaces host.
> +  // Source address is required when pinging a link-local address.
>//
>if (Private->IpChoice == PING_IP_CHOICE_IP6) {
> -if (NetIp6IsLinkLocalAddr ((EFI_IPv6_ADDRESS*)&Private->DstAddress) &&
> -NetIp6IsUnspecifiedAddr ((EFI_IPv6_ADDRESS*)&Private->SrcAddress)
> &&
> -(HandleNum > 1)) {
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
> gShellNetwork1HiiHandle, L"ping", mSrcString);
> +if (NetIp6IsLinkLocalAddr ((EFI_IPv6_ADDRESS*)&Private->DstAddress) &&
> UnspecifiedSrc) {
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_PING_INVALID_SOURCE), gShellNetwork1HiiHandle);
>Status = EFI_INVALID_PARAMETER;
>goto ON_ERROR;
>  }
>} else {
>  ASSERT(Private->IpChoice == PING_IP_CHOICE_IP4);
> -if (PingNetIp4IsLinkLocalAddr ((EFI_IPv4_ADDRESS*)&Private->DstAddress)
> &&
> -PingNetIp4IsUnspecifiedAddr ((EFI_IPv4_ADDRESS*)&Private-
> >SrcAddress) &&
> -(HandleNum > 1)) {
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
> gShellNetwork1HiiHandle, L"ping", mSrcString);
> +if (PingNetIp4IsLinkLocalAddr ((EFI_IPv4_ADDRESS*)&Private->DstAddress)
> && UnspecifiedSrc) {
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_PING_INVALID_SOURCE), gShellNetwork1HiiHandle);
>Status = EFI_INVALID_PARAMETER;
>goto ON_ERROR;
>  }
>}
> +
>//
>// For each ip6 protocol, check interface addresses list.
>//
>for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
> -
>  EfiSb = NULL;
>  IpXInterfaceInfo  = NULL;
>  IfInfoSize= 0;
> 
> +if (UnspecifiedSrc) {
> +  //
> +  // Check media.
> +  //
> +  NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
> +  if (!MediaPresent) {
> +//
> +// Skip this one.
> +//
> +continue;
> +  }
> +}
> +
>  St

Re: [edk2] [PATCH v2] ShellPkg: Enhance ping6 to select the interface automatically

2016-04-28 Thread Fu, Siyuan
Reviewed-by: Fu Siyuan 

> -Original Message-
> From: Wu, Jiaxin
> Sent: Thursday, April 28, 2016 4:18 PM
> To: edk2-devel@lists.01.org
> Cc: Bhupesh Sharma ; Carsey, Jaben
> ; Ye, Ting ; Fu, Siyuan
> 
> Subject: [PATCH v2] ShellPkg: Enhance ping6 to select the interface
> automatically
> 
> v2:
> * Refine the code to make it more readable.
> 
> This patch is used to support no source IP specified case while
> multiple NICs existed in the platform. The command will select the
> first both connected and configured interface automatically.
> Note: Source address is always required when pinging a
> link-local address.
> 
> Cc: Bhupesh Sharma 
> Cc: Jaben Carsey 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiaxin Wu 
> ---
>  .../Library/UefiShellNetwork2CommandsLib/Ping6.c   | 166 -
> 
>  1 file changed, 95 insertions(+), 71 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
> b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
> index af7d08f..e4ae977 100644
> --- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
> +++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
> @@ -661,22 +661,26 @@ Ping6CreateIpInstance (
>  {
>EFI_STATUS   Status;
>UINTNHandleIndex;
>UINTNHandleNum;
>EFI_HANDLE   *HandleBuffer;
> +  BOOLEAN  UnspecifiedSrc;
> +  BOOLEAN  MediaPresent;
>EFI_SERVICE_BINDING_PROTOCOL *Ip6Sb;
>EFI_IP6_CONFIG_PROTOCOL  *Ip6Cfg;
>EFI_IP6_CONFIG_DATA  Ip6Config;
>EFI_IP6_CONFIG_INTERFACE_INFO*IfInfo;
>UINTNIfInfoSize;
>EFI_IPv6_ADDRESS *Addr;
>UINTNAddrIndex;
> 
> -  HandleBuffer = NULL;
> -  Ip6Sb= NULL;
> -  IfInfo   = NULL;
> -  IfInfoSize   = 0;
> +  HandleBuffer  = NULL;
> +  UnspecifiedSrc= FALSE;
> +  MediaPresent  = TRUE;
> +  Ip6Sb = NULL;
> +  IfInfo= NULL;
> +  IfInfoSize= 0;
> 
>//
>// Locate all the handles with ip6 service binding protocol.
>//
>Status = gBS->LocateHandleBuffer (
> @@ -687,113 +691,133 @@ Ping6CreateIpInstance (
>&HandleBuffer
>);
>if (EFI_ERROR (Status) || (HandleNum == 0)) {
>  return EFI_ABORTED;
>}
> +
> +  if (NetIp6IsUnspecifiedAddr (&Private->SrcAddress)) {
> +//
> +// SrcAddress is unspecified. So, both connected and configured interface
> will be automatic selected.
> +//
> +UnspecifiedSrc = TRUE;
> +  }
> +
>//
> -  // Source address is required when pinging a link-local address on multi-
> -  // interfaces host.
> +  // Source address is required when pinging a link-local address.
>//
> -  if (NetIp6IsLinkLocalAddr (&Private->DstAddress) &&
> -  NetIp6IsUnspecifiedAddr (&Private->SrcAddress) &&
> -  (HandleNum > 1)) {
> +  if (NetIp6IsLinkLocalAddr (&Private->DstAddress) && UnspecifiedSrc) {
>  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_PING6_INVALID_SOURCE), gShellNetwork2HiiHandle);
>  Status = EFI_INVALID_PARAMETER;
>  goto ON_ERROR;
>}
> +
>//
>// For each ip6 protocol, check interface addresses list.
>//
>for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
> 
>  Ip6Sb  = NULL;
>  IfInfo = NULL;
>  IfInfoSize = 0;
> 
> +if (UnspecifiedSrc) {
> +  //
> +  // Check media.
> +  //
> +  NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
> +  if (!MediaPresent) {
> +//
> +// Skip this one.
> +//
> +continue;
> +  }
> +}
> +
>  Status = gBS->HandleProtocol (
>  HandleBuffer[HandleIndex],
>  &gEfiIp6ServiceBindingProtocolGuid,
>  (VOID **) &Ip6Sb
>  );
>  if (EFI_ERROR (Status)) {
>goto ON_ERROR;
>  }
> 
> -if (NetIp6IsUnspecifiedAddr (&Private->SrcAddress)) {
> -  //
> -  // No need to match interface address.
> -  //
> -  break;
> -} else {
> -  //
> -  // Ip6config protocol and ip6 service binding protocol are installed
> -  // on the same handle.
> -  //
> -  Status = gBS->HandleProtocol (
> -  HandleBuffer[HandleIndex],
> -  &gEfiIp6ConfigProtocolGuid,
> -  (VOID **) &Ip6Cfg
> -  );
> +//
> +// Ip6config protocol and ip6 service binding protocol are installed
> +// on the same handle.
> +//
> +Status = gBS->HandleProtocol (
> +HandleBuffer[HandleIndex],
> +&gEfiIp6ConfigProtocolGuid,
> +(VOID **) &Ip6Cfg
> +);
> 
> -  if 

Re: [edk2] OVMF broken under Xen (in PCI initialisation)

2016-04-28 Thread Gary Lin
On Thu, Apr 28, 2016 at 05:08:50AM +, Ni, Ruiyu wrote:
> 
> 
> Regards,
> Ray
> 
> >-Original Message-
> >From: Laszlo Ersek [mailto:ler...@redhat.com]
> >Sent: Wednesday, April 27, 2016 6:44 PM
> >To: Ni, Ruiyu ; Gary Lin 
> >Cc: edk2-devel@lists.01.org ; Xen Devel 
> >; Kinney, Michael D
> >
> >Subject: Re: [edk2] OVMF broken under Xen (in PCI initialisation)
> >
> >On 04/27/16 11:50, Ni, Ruiyu wrote:
> >> Copying Mike.
> >>
> >> Regards,
> >> Ray
> >>
> >>> -Original Message-
> >>> From: Ni, Ruiyu
> >>> Sent: Wednesday, April 27, 2016 5:49 PM
> >>> To: 'Gary Lin' 
> >>> Cc: edk2-devel@lists.01.org; Xen Devel ; Laszlo 
> >>> Ersek 
> >>> Subject: RE: [edk2] OVMF broken under Xen (in PCI initialisation)
> >>>
> >>> Gary,
> >>> Thanks for the try.
> >>>
> >>> I now understand why the issue happens.
> >>> 1. PciEnumeratorLight() depends on the MinBus returned from
> >>> PciRootBridgeIo.Configuration().
> >>> 2. PciRootBridgeIo.Configuration() returns the resource descriptors
> >>> initialized by 
> >>> PciHostBridge.NotifyPhase(EfiPciHostBridgeAllocateResources).
> >>> 3. PciHostBridge.NotifyPhase(EfiPciHostBridgeAllocateResources)
> >>> is not called when PcdPciDisableBusEnumeration is TRUE
> >>>
> >>> I am thinking about let PciRootBridgeIo.Configuration() returns
> >>> the correct resource consumption information even when
> >>> PcdPciDisableBusEnumeration is TRUE.
> >>>
> >>> I can add a new field to PCI_ROOT_BRIDGE structure defined in
> >>> MdeModulePkg/Include/Library/PciHostBridgeLib.h to indicate
> >>> that the resources filled in PCI_ROOT_BRIDGE.Bus/Io/Mem/
> >>> MemAbove4G/PMem/PMemAbove4G are already assigned
> >>> to PCI bus. So that PciRootBridgeIo.Configuration() can return
> >>> these value even when
> >>> PciHostBridge.NotifyPhase(EfiPciHostBridgeAllocateResources)
> >>> is not called due to PcdPciDisableBusEnumeration is TRUE.
> >
> >Can you use PcdPciDisableBusEnumeration directly for this?
> >
> >(If you don't like the idea, we could certainly set the new field in
> >PCI_ROOT_BRIDGE from the PCD too, in OvmfPkg/Library/PciHostBridgeLib.)
> >
> >>> Do you know whether Xen passes the PCI device resource
> >>> information to firmware?
> >
> >I don't think so, no.
> >
> >But, given that the previous PciHostBridgeDxe driver was working on Xen,
> >can we perhaps emulate that behavior in
> >"OvmfPkg/Library/PciHostBridgeLib" somehow?
> 
> Let me explain the reason why previous PciHostBridgeDxe driver was
> working on Xen:
> The PciRootBridgeIo.Configuration() in new driver only create resource
> descriptor when the resource status is allocated:
> 
> if (ResAllocNode->Status != ResAllocated) {
>   continue;
> }
> 
> The same function in old driver doesn't check the Status field so it
> unconditionally returns BUS descriptor with AddrRangeMin and
> AddrRangeMax both equal 0. So that PciEnumeratorLight()
> in PciBus driver can still search the devices from starting bus 0.
> It just happened to work.
> 
> I think the new driver's Configuration() implementation is correct
> while the old driver's one is wrong. So I don't want to change to 
> wrong implementation to fix this issue.
> 
> The issue can be resolved if we have a way to tell PciBus
> PciEnumeratorLight() which bus number to start searching.
> 
> It's almost true that starting bus number for root bridge #0
> is 0. But it might not be true for the rest root bridges.
> 
> OVMF's PciHostBridgeLib currently returns multiple root bridges
> and for root bridge #1, the starting bus number is obviously
> not 0 unless "etc/extra-pci-roots" doesn't exist or is 0 so there is
> only one root bridge.
> 
> My question is in OVMF over Xen, does "etc/extra-pci-roots" exist?
> If it exists, device behind root bridge #1, #2... can *not* be found
> with the current implementation.
> 
>From my OVMF/Xen debug log:
[...]
QemuFwCfg interface not supported.

I guess "etc/extra-pci-roots" won't exist in Xen though I can't
guarantee it due to my limited experience with Xen.

Cheers,

Gary Lin

> 
> >
> >Do you think that step (2) above behaves differently between the old and
> >the new PCI host bridge driver? (Steps (1) and (3) should be identical,
> >they are initiated by the PCI Bus driver.)
> >
> >Thanks
> >Laszlo
> >
> >>>
> >>> Copying Laszlo.
> >>>
> >>> Regards,
> >>> Ray
> >>>
>  -Original Message-
>  From: Gary Lin [mailto:g...@suse.com]
>  Sent: Wednesday, April 27, 2016 4:27 PM
>  To: Ni, Ruiyu 
>  Cc: edk2-devel@lists.01.org; Xen Devel 
>  Subject: Re: [edk2] OVMF broken under Xen (in PCI initialisation)
> 
>  On Wed, Apr 27, 2016 at 07:18:21AM +, Ni, Ruiyu wrote:
> > Gary,
> > In PciEnumeratorLight(), please directly assign 0 to MinBus when
> > Configuration() returns error, instead of calling PciGetBusRange() to
> > extract MinBus from the descriptors returned from Configuration().
> >
>  OK, I ignored PciGetBusRange() and the check of the return status of
>  C

Re: [edk2] OVMF broken under Xen (in PCI initialisation)

2016-04-28 Thread Laszlo Ersek
On 04/28/16 07:08, Ni, Ruiyu wrote:


 Do you know whether Xen passes the PCI device resource
 information to firmware?
>>
>> I don't think so, no.
>>
>> But, given that the previous PciHostBridgeDxe driver was working on Xen,
>> can we perhaps emulate that behavior in
>> "OvmfPkg/Library/PciHostBridgeLib" somehow?
> 
> Let me explain the reason why previous PciHostBridgeDxe driver was
> working on Xen:
> The PciRootBridgeIo.Configuration() in new driver only create resource
> descriptor when the resource status is allocated:
> 
> if (ResAllocNode->Status != ResAllocated) {
>   continue;
> }
> 
> The same function in old driver doesn't check the Status field so it
> unconditionally returns BUS descriptor with AddrRangeMin and
> AddrRangeMax both equal 0. So that PciEnumeratorLight()
> in PciBus driver can still search the devices from starting bus 0.
> It just happened to work.
> 
> I think the new driver's Configuration() implementation is correct
> while the old driver's one is wrong. So I don't want to change to 
> wrong implementation to fix this issue.

Makes sense, thank you for the explanation.

> The issue can be resolved if we have a way to tell PciBus
> PciEnumeratorLight() which bus number to start searching.
> 
> It's almost true that starting bus number for root bridge #0
> is 0. But it might not be true for the rest root bridges.
> 
> OVMF's PciHostBridgeLib currently returns multiple root bridges
> and for root bridge #1, the starting bus number is obviously
> not 0 unless "etc/extra-pci-roots" doesn't exist or is 0 so there is
> only one root bridge.
> 
> My question is in OVMF over Xen, does "etc/extra-pci-roots" exist?
> If it exists, device behind root bridge #1, #2... can *not* be found
> with the current implementation.

"etc/extra-pci-roots" (more precisely, fw_cfg in general) is specific to
QEMU. QemuFwCfgLib runs alright in Xen guests, but whenever you look for
an fw_cfg file, it is not found -- which is good behavior.

So, OVMF's PciHostBridgeLib produces exactly one PCI_ROOT_BRIDGE object
when it runs on Xen. ExtraRootBridges is set to zero, the loop runs zero
times, and the one InitRootBridge() call after the loop produces one
PCI_ROOT_BRIDGE object, with the following parameters:
- Bus.Base = 0
- Bus.Limit = PCI_MAX_BUS

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


Re: [edk2] [PATCH 1/3] MdeModulePkg: PiDxeS3BootScriptLib: honor PcdAcpiS3Enable

2016-04-28 Thread Laszlo Ersek
On 04/28/16 01:19, Carsey, Jaben wrote:
> thanks for the explanation.
> 
> I agree that libraries must be designed for this feature from the
> beginning.  I also know that people use libraries for purposes other
> than their original intent.  I think it would be best to plan for
> this by having properly coded destructors in libraries whenever
> possible.
> 
> I mean it's a lot harder to use a DXE/PEI DRIVER in an application or
> unloadable driver than it is to link to a library.  I just think that
> libraries should inherently be self-contained.

I agree. I'll keep that in mind for any further library instances we
might write.

> That does not mean that you should add one in this case though...  
> 
> Reviewed-by: Jaben Carsey 

Thank you!
Laszlo

>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Wednesday, April 27, 2016 1:12 PM
>> To: Carsey, Jaben ; edk2-devel-01 > de...@ml01.01.org>
>> Cc: Ni, Ruiyu ; Justen, Jordan L
>> ; Tian, Feng ; Yao, Jiewen
>> ; Zeng, Star 
>> Subject: Re: [edk2] [PATCH 1/3] MdeModulePkg: PiDxeS3BootScriptLib:
>> honor PcdAcpiS3Enable
>> Importance: High
>>
>> On 04/27/16 21:45, Carsey, Jaben wrote:
>>> Laszlo,
>>>
>>> Does the library destructor not get called?  Shouldn't that destructor
>> unregister the protocol notify and leave the callback pointer in DXE core
>> correct?
>>
>> PiDxeS3BootScriptLib doesn't have a DESTRUCTOR at the moment.
>>
>> I would prefer not attempting to add a destructor from scratch.
>>
>> The constructor does quite a bit of work that would all have to be
>> undone in the destructor.
>>
>> The commit message here only points out the protocol notify, but in fact
>> S3BootScriptLibInitialize() implements a "shared responsibility memory
>> allocation" as well, through PcdS3BootScriptTablePrivateDataPtr.
>>
>> All modules that are linked against this library instance, and are
>> dispatched through the same boot, are prepared to "be the first" and
>> allocate the region. The guys that come second and later just reuse the
>> area.
>>
>> Undoing this is messy; I think it would require reference counting (in
>> another PCD, or in the data structure pointed-to by the current PCD).
>>
>> The constructor also has some sophisticated logic for determining if it
>> is running as part of a DXE_SMM_DRIVER module, or just as part of a
>> DXE_(RUNTIME_)DRIVER module. Even without my patch, the constructor has
>> five (5) RETURN_SUCCESS exit points. Rolling back all those (valid)
>> library states in a destructor would be a nightmare.
>>
>> I think that DESTRUCTOR is a clever facility of edk2, but similarly to
>> how a DXE_DRIVER must be designed from the ground up for unloading
>> (UNLOAD_IMAGE=... in the INF file), a library instance must also be
>> designed from the ground up if it is to have a DESTRUCTOR. I think that
>> none of BootScriptExecutorDxe, S3SaveStateDxe, SmmS3SaveState, and
>> PiDxeS3BootScriptLib qualify.
>>
>> (I do see that the shell command libraries use DESTRUCTORs. That makes
>> perfect sense: the shell binary that they are linked into with NULL
>> library resolution is a UEFI application (not a driver), which is by
>> definition unload-capable. Hence I even believe that for the shell
>> command libs, DESTRUCTORs are actually unavoidable.)
>>
>> Thanks!
>> Laszlo
>>
 -Original Message-
 From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
 Laszlo Ersek
 Sent: Wednesday, April 27, 2016 12:21 PM
 To: edk2-devel-01 
 Cc: Ni, Ruiyu ; Justen, Jordan L
 ; Tian, Feng ; Yao,
>> Jiewen
 ; Zeng, Star 
 Subject: [edk2] [PATCH 1/3] MdeModulePkg: PiDxeS3BootScriptLib: honor
 PcdAcpiS3Enable

 In the edk2 tree, there are currently four drivers that consume
 PcdAcpiS3Enable:



>> IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.in
 f


>> MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorD
 xe.inf
   MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
   MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.inf

 From these, AcpiS3SaveDxe is the only one that isn't also a client of the
 S3BootScriptLib class; all the others (BootScriptExecutorDxe,
 S3SaveStateDxe, SmmS3SaveState) are clients of the S3BootScriptLib class.

 In turn, the edk2 tree contains only one non-Null instance of the
 S3BootScriptLib class:

   MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf

 Therefore we can safely state that BootScriptExecutorDxe,
>> S3SaveStateDxe,
 and SmmS3SaveState are all linked against PiDxeS3BootScriptLib.

 Now, if PcdAcpiS3Enable is FALSE when either of BootScriptExecutorDxe,
 SmmS3SaveState, or SmmS3SaveState is dispatched, then the following
 happens:

 - The constructor of PiDxeS3BootScriptLib, function
   S3BootScriptLibInitialize(), registers a protocol installation

Re: [edk2] [PATCH v3 2/2] OvmfPkg: Modify fdf files due to RamDiskDxe driver's adding ASL code

2016-04-28 Thread Laszlo Ersek
On 04/28/16 07:08, Hao Wu wrote:
> The RamDiskDxe driver in MdeModulePkg now will sometimes report a NVDIMM
> Root Device using ASL code which is put in a Secondary System Description
> Table (SSDT) according to the ACPI 6.1 spec.
> 
> Locating the SSDT requires modifying the fdf files in OvmfPkg.
> 
> Cc: Laszlo Ersek 
> Cc: Jordan Justen 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu 
> ---
>  OvmfPkg/OvmfPkgIa32.fdf| 2 ++
>  OvmfPkg/OvmfPkgIa32X64.fdf | 2 ++
>  OvmfPkg/OvmfPkgX64.fdf | 2 ++
>  3 files changed, 6 insertions(+)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
> index 93a51a5..287737c 100644
> --- a/OvmfPkg/OvmfPkgIa32.fdf
> +++ b/OvmfPkg/OvmfPkgIa32.fdf
> @@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
>  UI   STRING="$(MODULE_NAME)" Optional
>  VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
> +RAW ACPI  Optional   |.acpi
> +RAW ASL   Optional   |.aml
>}
>  
>  [Rule.Common.DXE_RUNTIME_DRIVER]
> diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
> index aad16a6..cc1587a 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.fdf
> +++ b/OvmfPkg/OvmfPkgIa32X64.fdf
> @@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
>  UI   STRING="$(MODULE_NAME)" Optional
>  VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
> +RAW ACPI  Optional   |.acpi
> +RAW ASL   Optional   |.aml
>}
>  
>  [Rule.Common.DXE_RUNTIME_DRIVER]
> diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
> index 387b808..1b52381 100644
> --- a/OvmfPkg/OvmfPkgX64.fdf
> +++ b/OvmfPkg/OvmfPkgX64.fdf
> @@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
>  UI   STRING="$(MODULE_NAME)" Optional
>  VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
> +RAW ACPI  Optional   |.acpi
> +RAW ASL   Optional   |.aml
>}
>  
>  [Rule.Common.DXE_RUNTIME_DRIVER]
> 

I guess I can ACK this, but what about my other comment, namely setting
PcdInstallAcpiSdtProtocol to TRUE in the OVMF DSC files?

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


Re: [edk2] [Patch v3 02/23] OvmfPkg/PlatformPei: Add memory above 4GB as tested

2016-04-28 Thread Laszlo Ersek
On 04/28/16 03:59, Ni, Ruiyu wrote:
> 
> 
> Regards,
> Ray
> 
>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Tuesday, April 26, 2016 5:27 AM
>> To: Ni, Ruiyu 
>> Cc: edk2-de...@ml01.01.org; Justen, Jordan L 
>> Subject: Re: [edk2] [Patch v3 02/23] OvmfPkg/PlatformPei: Add memory above 
>> 4GB as tested

>> For this patch:
>>
>> Tested-by: Laszlo Ersek 
>> Reviewed-by: Laszlo Ersek 
> 
> You already did the boot test using big RAM size.
> Do you still need I do that as well?

No, you don't need to do it. (Sorry that I wasn't clear about this.)

> 
>>
>> (2) A general question: why has the memory testing (= conversion from
>> untested to tested) been removed from BDS?
> Is your question
> "why has the memory testing been removed from BDS *core*?"

Yes, that's my question.

> The answer is:
> 1. BDS core just follows the UEFI Spec chapter 3 while that chapter doesn't
> say memory testing should be performed in BDS

Ah, very good answer. Thanks!

> 2. Memory test involves user interaction and screen updates (progress bar,
> ESC to skip, test failure...). I don't want BDS core contain these UI. UI is
> the component that everyone has different ideas. I want the BDS core to be
> stable.

Good point as well.

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


Re: [edk2] [Patch v3 04/23] OvmfPkg/QemuNewBootOrderLib: Build with UefiBootManagerLib

2016-04-28 Thread Laszlo Ersek
On 04/28/16 04:16, Ni, Ruiyu wrote:

>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Tuesday, April 26, 2016 11:02 PM
>> To: Ni, Ruiyu ; edk2-de...@ml01.01.org
>> Cc: Justen, Jordan L 
>> Subject: Re: [edk2] [Patch v3 04/23] OvmfPkg/QemuNewBootOrderLib: Build with 
>> UefiBootManagerLib

>> On 04/21/16 08:57, Ruiyu Ni wrote:

>>> +  FileBuffer = EfiBootManagerGetLoadOptionBuffer (
>>> + (EFI_DEVICE_PATH_PROTOCOL *) DevicePath,
>>
>> (6) I think that this cast is only necessary because
>> EfiBootManagerGetLoadOptionBuffer() does not accept a
>> pointer-to-CONST here.
>>
>> What do you think about modifying
>> EfiBootManagerGetLoadOptionBuffer() instead? (It could be done in
>> patch #1.)
>>
>> If it is very messy (= would need a lot of changes), then I agree
>> that this cast is okay. After all, the FilePath param of 
>> EfiBootManagerGetLoadOptionBuffer() is "IN", so we can trust it not
>> to modify FilePath.
> 
> Really messy. I tried that but given up. Many library APIs need to
> add CONST modifier.

Yep, that's what I thought :)

> I admit I didn't do a good job!

I think you did a pretty good job -- after all the UEFI and PI specs
very rarely (if ever?) use CONST in the function prototypes they
declare, as far as I remember. They rather use IN, OUT, OPTIONAL etc,
and I think your boot manager / BDS code is consistent with that style.

> I can try to create a separate patch
> to add the missing CONST modifier if everyone agrees.

It would be a nice bonus, I think, but probably low priority (and
certainly separate from this work).

> For your other comments in this mail, v4 patch will take them.

Thanks!

I'll try to continue the review today.

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


Re: [edk2] [Patch v3 12/23] OvmfPkg/PlatformBds: Do not launch Boot Manager Menu

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> MdeModulePkg/BDS doesn't launch UI (Boot Manager Menu) from platform
> side.
> The change removes the code which launches the UI and but still set
> the boot timeout.

I think the word "and" should be dropped.

Reviewed-by: Laszlo Ersek 

Thanks!
Laszlo


> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c  | 3 +--
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h  | 6 --
>  OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 1 +
>  3 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 7fc2dd5..38e2943 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -114,6 +114,7 @@ Returns:
>DEBUG ((EFI_D_INFO, "PlatformBootManagerBeforeConsole\n"));
>InstallDevicePathCallback ();
>PlatformInitializeConsole (gPlatformConsole);
> +  PcdSet16 (PcdPlatformBootTimeOut, GetFrontPageTimeoutFromQemu ());
>  }
>  
>  
> @@ -1277,8 +1278,6 @@ Routine Description:
>// it.
>//
>BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
> -
> -  PlatformBdsEnterFrontPage (GetFrontPageTimeoutFromQemu(), TRUE);
>  }
>  
>  VOID
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> index fb22790..796b53d 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> @@ -266,12 +266,6 @@ ConvertSystemTable (
>   IN OUT VOID   **Table
>);
>  
> -VOID
> -PlatformBdsEnterFrontPage (
> -  IN UINT16 TimeoutDefault,
> -  IN BOOLEANConnectAllHappened
> -  );
> -
>  /**
>Loads and boots UEFI Linux via the FwCfg interface.
>  
> diff --git 
> a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
> b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> index 00a7583..f9cbe65 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> @@ -59,6 +59,7 @@ [Pcd]
>gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent
>gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
>gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
> +  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
>  
>  [Pcd.IA32, Pcd.X64]
>gEfiMdePkgTokenSpaceGuid.PcdFSBClock
> 

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


[edk2] accessing IP info. set using ifconfig shell command in EFI application.

2016-04-28 Thread devendra rawat
I am setting IP address, netmask and gateway IP for interface eth0 using
Tianocore shell "ifconfig" command. I need to access these IP addresses in
an EFI Application. can someone provide any pointers, or example code for
doing the same.

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


Re: [edk2] [PATCH] ShellPkg: Add NULL pointer check.

2016-04-28 Thread Shah, Tapan
This should be changed:

+  if (TempRetVal) {
+goto EXIT;
+  }

To:

+  if (TempRetVal == NULL) {
+goto EXIT;
+  }

Reviewed-by: Tapan Shah 

-Original Message-
From: Qiu Shumin [mailto:shumin@intel.com] 
Sent: Thursday, April 28, 2016 3:26 AM
To: edk2-devel@lists.01.org
Cc: Qiu Shumin ; Jaben Carsey ; 
Shah, Tapan 
Subject: [PATCH] ShellPkg: Add NULL pointer check.

Add pointer check to avoid NULL pointer dereferenced.

Cc: Jaben Carsey 
Cc: Tapan Shah 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin 
---
 .../UefiHandleParsingLib/UefiHandleParsingLib.c  | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 58f1814..830ee3b 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -301,14 +301,26 @@ GraphicsOutputProtocolDumpInformation(
 
   SHELL_FREE_NON_NULL (Temp);
   
-  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_MAIN), NULL);
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_MAIN), NULL);
+  if (Temp == NULL) {
+SHELL_FREE_NON_NULL (RetVal);
+goto EXIT;
+  }
 
   TempRetVal = CatSPrint (RetVal, Temp);
-  SHELL_FREE_NON_NULL (RetVal);
+  SHELL_FREE_NON_NULL (RetVal);
+  if (TempRetVal) {
+goto EXIT;
+  }
   RetVal = TempRetVal;
   SHELL_FREE_NON_NULL (Temp);
 
-  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_ENTRY), NULL);
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_ENTRY), NULL);
+  if (Temp == NULL) {
+SHELL_FREE_NON_NULL (RetVal);
+goto EXIT;
+  }
+
 
   for (Mode = 0; Mode < GraphicsOutput->Mode->MaxMode; Mode++) {
 Status = GraphicsOutput->QueryMode (
@@ -334,6 +346,8 @@ GraphicsOutputProtocolDumpInformation(
 RetVal = TempRetVal;
   }
 
+
+EXIT:
   SHELL_FREE_NON_NULL(Temp);
   SHELL_FREE_NON_NULL(Fmt);
 
-- 
2.7.1.windows.2

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


Re: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by serial IO mode

2016-04-28 Thread Heyi Guo



On 04/28/2016 11:10 AM, Ni, Ruiyu wrote:

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Heyi Guo
Sent: Saturday, April 23, 2016 4:54 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Heyi Guo ; 
Tian, Feng ;
Zeng, Star 
Subject: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by serial IO 
mode

Calculate serial input polling rate according to parameters from
serial IO mode as below, to fix potential input truncation.

Polling interval (100ns) =
FifoDepth * (StartBit + DataBits + StopBits + ParityBits) * 10,000,000
/ BaudRate
(StopBits is assumed to be 1 and ParityBits is ignored for simplicity.

However, as the event is time sensitive, we need to align the interval
to timer interrupt period to make sure the event will be triggered at
the expected rate. E.g. if the interval is 2.7ms and timer interrupt
period is 1ms, the event will be triggered by time slice sequence as
below:
3ms 3ms 2ms 3ms 3ms 2ms...

In such case we will adjust the polling interval to be 2ms.

Heyi,
I remember we had a discussion about the polling interval calculation
equation a month ago. The equation used in the patch looks good to me.
Because the timer handler is called sometimes every 3ms but not 2.7ms
resulting the key loss?
Just want to confirm with you.
Yes, I think so. And polling rate aligned with timer interrupt period 
(like 2ms) works well on my platform.


Heyi




Regards,
Ray


Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo 
Cc: Feng Tian 
Cc: Star Zeng 
Cc: Michael D Kinney 
---
.../Universal/Console/TerminalDxe/Terminal.c   |  5 +-
.../Universal/Console/TerminalDxe/Terminal.h   | 28 ++-
.../Universal/Console/TerminalDxe/TerminalConIn.c  | 92 ++
.../Universal/Console/TerminalDxe/TerminalDxe.inf  |  1 +
4 files changed, 123 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 6fde3b2..2944707 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -71,6 +71,7 @@ TERMINAL_DEV  mTerminalDevTemplate = {
   },
   NULL, // TerminalConsoleModeData
   0,  // SerialInTimeOut
+  0,  // KeyboardTimerInterval

   NULL, // RawFifo
   NULL, // UnicodeFiFo
@@ -984,10 +985,12 @@ TerminalDriverBindingStart (
 );
 ASSERT_EFI_ERROR (Status);

+TerminalDevice->KeyboardTimerInterval = GetKeyboardTimerInterval (Mode);
+
 Status = gBS->SetTimer (
 TerminalDevice->TimerEvent,
 TimerPeriodic,
-KEYBOARD_TIMER_INTERVAL
+TerminalDevice->KeyboardTimerInterval
 );
 ASSERT_EFI_ERROR (Status);

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index 269d2ae..a1ff595 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
#include 
#include 
#include 
+#include 

#include 
#include 
@@ -68,8 +69,6 @@ typedef struct {
   UINTN   Rows;
} TERMINAL_CONSOLE_MODE_DATA;

-#define KEYBOARD_TIMER_INTERVAL 20  // 0.02s
-
#define TERMINAL_DEV_SIGNATURE  SIGNATURE_32 ('t', 'm', 'n', 'l')

#define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('t', 'm', 'e', 
'n')
@@ -91,6 +90,7 @@ typedef struct {
   EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
   TERMINAL_CONSOLE_MODE_DATA  *TerminalConsoleModeData;
   UINTN   SerialInTimeOut;
+  UINT64  KeyboardTimerInterval;
   RAW_DATA_FIFO   *RawFiFo;
   UNICODE_FIFO*UnicodeFiFo;
   EFI_KEY_FIFO*EfiKeyFiFo;
@@ -1358,4 +1358,28 @@ TerminalConInTimerHandler (
   IN EFI_EVENTEvent,
   IN VOID *Context
   );
+
+/**
+  Calculate input polling timer interval by serial IO mode.
+
+  @param  Mode  Pointer to serial IO mode.
+
+  @retval The required polling timer interval in 100ns.
+
+**/
+UINT64
+GetKeyboardTimerInterval (
+  IN EFI_SERIAL_IO_MODE   *Mode
+  );
+
+/**
+  Update period of polling timer event.
+
+  @param  TerminalDeviceThe terminal device to update.
+**/
+VOID
+UpdatePollingRate (
+  IN TERMINAL_DEV *TerminalDevice
+  );
+
#endif
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 3be877b..e7788a0 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.

#inc

Re: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by serial IO mode

2016-04-28 Thread Heyi Guo



On 04/28/2016 11:17 AM, Andrew Fish wrote:

On Apr 27, 2016, at 8:10 PM, Ni, Ruiyu  wrote:


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Heyi Guo
Sent: Saturday, April 23, 2016 4:54 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Heyi Guo ; 
Tian, Feng ;
Zeng, Star 
Subject: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by serial IO 
mode

Calculate serial input polling rate according to parameters from
serial IO mode as below, to fix potential input truncation.

Polling interval (100ns) =
FifoDepth * (StartBit + DataBits + StopBits + ParityBits) * 10,000,000
/ BaudRate
(StopBits is assumed to be 1 and ParityBits is ignored for simplicity.

However, as the event is time sensitive, we need to align the interval
to timer interrupt period to make sure the event will be triggered at
the expected rate. E.g. if the interval is 2.7ms and timer interrupt
period is 1ms, the event will be triggered by time slice sequence as
below:
3ms 3ms 2ms 3ms 3ms 2ms...

In such case we will adjust the polling interval to be 2ms.

Heyi,
I remember we had a discussion about the polling interval calculation
equation a month ago. The equation used in the patch looks good to me.
Because the timer handler is called sometimes every 3ms but not 2.7ms
resulting the key loss?
Just want to confirm with you.


Is it safe to make assumptions based on an implementation of an AP? Other 
platforms could be using different code?

Thanks,

Andrew Fish
Michael has similar concern and we will try using standard UEFI services 
or protocols to achieve the timer interrupt period.


Thanks.

Heyi



Regards,
Ray


Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo 
Cc: Feng Tian 
Cc: Star Zeng 
Cc: Michael D Kinney 
---
.../Universal/Console/TerminalDxe/Terminal.c   |  5 +-
.../Universal/Console/TerminalDxe/Terminal.h   | 28 ++-
.../Universal/Console/TerminalDxe/TerminalConIn.c  | 92 ++
.../Universal/Console/TerminalDxe/TerminalDxe.inf  |  1 +
4 files changed, 123 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 6fde3b2..2944707 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -71,6 +71,7 @@ TERMINAL_DEV  mTerminalDevTemplate = {
  },
  NULL, // TerminalConsoleModeData
  0,  // SerialInTimeOut
+  0,  // KeyboardTimerInterval

  NULL, // RawFifo
  NULL, // UnicodeFiFo
@@ -984,10 +985,12 @@ TerminalDriverBindingStart (
);
ASSERT_EFI_ERROR (Status);

+TerminalDevice->KeyboardTimerInterval = GetKeyboardTimerInterval (Mode);
+
Status = gBS->SetTimer (
TerminalDevice->TimerEvent,
TimerPeriodic,
-KEYBOARD_TIMER_INTERVAL
+TerminalDevice->KeyboardTimerInterval
);
ASSERT_EFI_ERROR (Status);

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index 269d2ae..a1ff595 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
#include 
#include 
#include 
+#include 

#include 
#include 
@@ -68,8 +69,6 @@ typedef struct {
  UINTN   Rows;
} TERMINAL_CONSOLE_MODE_DATA;

-#define KEYBOARD_TIMER_INTERVAL 20  // 0.02s
-
#define TERMINAL_DEV_SIGNATURE  SIGNATURE_32 ('t', 'm', 'n', 'l')

#define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('t', 'm', 'e', 
'n')
@@ -91,6 +90,7 @@ typedef struct {
  EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
  TERMINAL_CONSOLE_MODE_DATA  *TerminalConsoleModeData;
  UINTN   SerialInTimeOut;
+  UINT64  KeyboardTimerInterval;
  RAW_DATA_FIFO   *RawFiFo;
  UNICODE_FIFO*UnicodeFiFo;
  EFI_KEY_FIFO*EfiKeyFiFo;
@@ -1358,4 +1358,28 @@ TerminalConInTimerHandler (
  IN EFI_EVENTEvent,
  IN VOID *Context
  );
+
+/**
+  Calculate input polling timer interval by serial IO mode.
+
+  @param  Mode  Pointer to serial IO mode.
+
+  @retval The required polling timer interval in 100ns.
+
+**/
+UINT64
+GetKeyboardTimerInterval (
+  IN EFI_SERIAL_IO_MODE   *Mode
+  );
+
+/**
+  Update period of polling timer event.
+
+  @param  TerminalDeviceThe terminal device to update.
+**/
+VOID
+UpdatePollingRate (
+  IN TERMINAL_DEV *TerminalDevice
+  );
+
#endif
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 3be877b..e7788a0 100644
--- a/MdeModulePkg/Universal/Console/T

Re: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by serial IO mode

2016-04-28 Thread Heyi Guo

Thanks, I will try the methods.

Heyi

On 04/27/2016 11:57 PM, Kinney, Michael D wrote:

Heyi,

1) A couple ways to measure.
   a) Loop calling gBS->Stall() and counting number of stall calls between
  2 periodic timer event notifications.  The accuracy of the measurement
  depends on the granularity and accuracy of the Stall service.  For your
  use case, using a Stall() period between 10 uS and 100 uS should work
  well.
   b) Use the EFI_TIMESTAMP_PROTOCOL to get a performance counter value in
  2 successive timer event notifications and use GetProperties() to convert
  performance counter ticks to time.  This protocol should provide more
  accurate information, but it is optional, so the code that detects the
  tick period has to check to see if this protocol is present and can use
  it if it is present, and fall back to Stall() if it is not present.

2) I agree.  Ignore time to first notification.  Measure time between 2nd and
3rd notification.

3,4) I agree that setting TriggerTime to 0 makes the most sense.

Mike



-Original Message-
From: Heyi Guo [mailto:heyi@linaro.org]
Sent: Wednesday, April 27, 2016 8:21 AM
To: Kinney, Michael D ; edk2-devel@lists.01.org
Cc: Tian, Feng ; Zeng, Star 
Subject: Re: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by 
serial IO
mode

Hi Michael,

I still have questions about measuring timer tick by event:

1. How can we measure the time elapsed? TimerLib is not in UEFI spec,
and shall we use gBS->Stall in a loop to measure the time?
2. By using a periodic timer event, I think we need to drop the 1st
trigger as it is random and determined by the time when event is
created, isn't it?
3. For the timer event with period of 1*100ns, I think it might be
triggered twice in one timer tick by below code:
Timer.c, line #143:
Event->Timer.TriggerTime = Event->Timer.TriggerTime +
Event->Timer.Period;

//
// If that's before now, then reset the timer to start from now
//
if (Event->Timer.TriggerTime <= SystemTime) {
  Event->Timer.TriggerTime = SystemTime;
  CoreSignalEvent (mEfiCheckTimerEvent);
}
4. How about setting TriggerTime=0 when calling SetTimer so that the
period of event will be exactly the timer tick, as stated in UEFI spec?

Thanks and regards.

Heyi


On 04/27/2016 12:21 AM, Kinney, Michael D wrote:

Heyi,

I agree the source code required to detect the current tick rate using only UEFI

services

is more complex.

However, a UEFI driver (especially ones on an add-in devices such as a PCI 
adapter)

should not

use a PCD for the system tick rate because the add-in card can be used in 
systems

with different

system tick rates.

If you are concerned about complexity, we could consider adding a new lib 
function to

the

UefiLib that returns the current system tick rate using UEFI services to detect 
it.

This way,

A UEFI driver can be kept simple and we move the complexity into a single new 
lib

function.

Best regards,

Mike


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Heyi Guo
Sent: Tuesday, April 26, 2016 8:14 AM
To: Kinney, Michael D ; edk2-devel@lists.01.org
Cc: Tian, Feng ; Zeng, Star 
Subject: Re: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by 
serial IO
mode

Hi Michael,

It seems we are making the implementation more and more complicated. How
about just creating a PCD for polling rate which can be set freely by
platforms?

Regards.

Heyi

On 04/24/2016 12:11 AM, Kinney, Michael D wrote:

Heyi Guo,

The TerminalDxe driver is intended to be a UEFI Driver.  The Timer Arch 
Protocol is
a PI Protocol that is intended to be used by the PI DXE Core.  In order to

determine

the timer rate in a UEFI way, create a periodic timer event with a period of 1,

100ns

unit, and then measure the time between timer event notification functions.

Mike


-Original Message-
From: Heyi Guo [mailto:heyi@linaro.org]
Sent: Saturday, April 23, 2016 1:54 AM
To: edk2-devel@lists.01.org
Cc: Heyi Guo ; Tian, Feng ; Zeng, Star
; Kinney, Michael D 
Subject: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by serial IO

mode

Calculate serial input polling rate according to parameters from
serial IO mode as below, to fix potential input truncation.

Polling interval (100ns) =
FifoDepth * (StartBit + DataBits + StopBits + ParityBits) * 10,000,000
/ BaudRate
(StopBits is assumed to be 1 and ParityBits is ignored for simplicity.

However, as the event is time sensitive, we need to align the interval
to timer interrupt period to make sure the event will be triggered at
the expected rate. E.g. if the interval is 2.7ms and timer interrupt
period is 1ms, the event will be triggered by time slice sequence as
below:
3ms 3ms 2ms 3ms 3ms 2ms...

In such case we will adjust the polling interval to be 2ms.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Gu

Re: [edk2] [Patch v3 13/23] OvmfPkg/PlatformBds: Register boot options and hot keys.

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> The patch registers "Enter" key as the continue key (hot key to skip
> the boot timeout wait), maps "F2" key to UI, and registers Shell
> boot option.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  .../Library/PlatformBootManagerLib/BdsPlatform.c   | 71 
> ++
>  .../Library/PlatformBootManagerLib/BdsPlatform.h   |  1 +
>  .../PlatformBootManagerLib.inf |  2 +
>  3 files changed, 74 insertions(+)

This patch also looks good, I have just a few requests :)

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 38e2943..d4bdbe5 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -88,6 +88,55 @@ InstallDevicePathCallback (
>VOID
>);
>  
> +VOID
> +PlatformRegisterFvBootOption (
> +  EFI_GUID *FileGuid,
> +  CHAR16   *Description,
> +  UINT32   Attributes
> +  )
> +{
> +  EFI_STATUSStatus;
> +  UINTN OptionIndex;
> +  EFI_BOOT_MANAGER_LOAD_OPTION  NewOption;
> +  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOptions;
> +  UINTN BootOptionCount;
> +  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> +  EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> +  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> +
> +  Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, 
> (VOID **) &LoadedImage);

Please make sure that lines being added in this patch are not longer
than 79 characters.

> +  ASSERT_EFI_ERROR (Status);
> +
> +  EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> +  DevicePath = AppendDevicePathNode (
> + DevicePathFromHandle (LoadedImage->DeviceHandle),
> + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> + );

Would it make sense to call DevicePathFromHandle() separately, and
assert that the retval is not NULL?

Also: AppendDevicePathNode() allocates memory dynamically. Please check
if it succeeds (if it fails, we can trigger an assert, or log an
EFI_D_WARN message, and just return -- up to you).

> +
> +  Status = EfiBootManagerInitializeLoadOption (
> + &NewOption,
> + LoadOptionNumberUnassigned,
> + LoadOptionTypeBoot,
> + Attributes,
> + Description,
> + DevicePath,
> + NULL,
> + 0
> + );

The variable DevicePath should be freed right here; we are currently
leaking it. (EfiBootManagerInitializeLoadOption() creates a deep copy.)

Also, if this call fails, can you please log an EFI_D_WARN message?

> +  if (!EFI_ERROR (Status)) {
> +BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, 
> LoadOptionTypeBoot);
> +
> +OptionIndex = EfiBootManagerFindLoadOption (&NewOption, BootOptions, 
> BootOptionCount);

The type of OptionIndex (declared above) should be INTN then, not UINTN.

> +if (OptionIndex == -1) {
> +  Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1);

For better readability, I propose MAX_UINTN, rather than (UINTN)-1.

> +  ASSERT_EFI_ERROR (Status);
> +}
> +EfiBootManagerFreeLoadOption (&NewOption);
> +EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> +  }
> +}
> +
>  //
>  // BDS Platform Functions
>  //
> @@ -111,10 +160,32 @@ Returns:
>  
>  --*/
>  {
> +  EFI_INPUT_KEYEnter;
> +  EFI_INPUT_KEYF2;
> +  EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> +
>DEBUG ((EFI_D_INFO, "PlatformBootManagerBeforeConsole\n"));
>InstallDevicePathCallback ();
>PlatformInitializeConsole (gPlatformConsole);
>PcdSet16 (PcdPlatformBootTimeOut, GetFrontPageTimeoutFromQemu ());
> +
> +  //
> +  // Register ENTER as CONTINUE key
> +  //
> +  Enter.ScanCode= SCAN_NULL;
> +  Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> +  EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);

Can you please add an EFI_D_WARN or an ASSERT_EFI_ERROR here?

> +  //
> +  // Map F2 to Boot Manager Menu
> +  //
> +  F2.ScanCode= SCAN_F2;
> +  F2.UnicodeChar = CHAR_NULL;
> +  EfiBootManagerGetBootManagerMenu (&BootOption);

Ditto.

> +  EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) 
> BootOption.OptionNumber, 0, &F2, NULL);

Ditto.

Also, can you please register the ESC key as well, in addition to F2, to
enter the Boot Manager Menu?

> +  //
> +  // Register UEFI Shell
> +  //
> +  PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", 
> LOAD_OPTION_ACTIVE);

Can you please extract all these steps into a separate function, called
PlatformRegisterOptionsAndKeys()?

Thanks!
Laszlo

>  }
>  
>  
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/

Re: [edk2] [Patch v3 14/23] OvmfPkg/PlatformBds: Remove unused local functions.

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  .../Library/PlatformBootManagerLib/BdsPlatform.c   | 94 
> --
>  1 file changed, 94 deletions(-)

Reviewed-by: Laszlo Ersek 

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index d4bdbe5..43a859c 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -1351,100 +1351,6 @@ Routine Description:
>BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
>  }
>  
> -VOID
> -EFIAPI
> -PlatformBdsBootSuccess (
> -  IN  BDS_COMMON_OPTION   *Option
> -  )
> -/*++
> -
> -Routine Description:
> -
> -  Hook point after a boot attempt succeeds. We don't expect a boot option to
> -  return, so the EFI 1.0 specification defines that you will default to an
> -  interactive mode and stop processing the BootOrder list in this case. This
> -  is alos a platform implementation and can be customized by IBV/OEM.
> -
> -Arguments:
> -
> -  Option - Pointer to Boot Option that succeeded to boot.
> -
> -Returns:
> -
> -  None.
> -
> ---*/
> -{
> -  CHAR16  *TmpStr;
> -
> -  DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n"));
> -  //
> -  // If Boot returned with EFI_SUCCESS and there is not in the boot device
> -  // select loop then we need to pop up a UI and wait for user input.
> -  //
> -  TmpStr = Option->StatusString;
> -  if (TmpStr != NULL) {
> -BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", 
> NULL);
> -FreePool (TmpStr);
> -  }
> -}
> -
> -VOID
> -EFIAPI
> -PlatformBdsBootFail (
> -  IN  BDS_COMMON_OPTION  *Option,
> -  IN  EFI_STATUS Status,
> -  IN  CHAR16 *ExitData,
> -  IN  UINTN  ExitDataSize
> -  )
> -/*++
> -
> -Routine Description:
> -
> -  Hook point after a boot attempt fails.
> -
> -Arguments:
> -
> -  Option - Pointer to Boot Option that failed to boot.
> -
> -  Status - Status returned from failed boot.
> -
> -  ExitData - Exit data returned from failed boot.
> -
> -  ExitDataSize - Exit data size returned from failed boot.
> -
> -Returns:
> -
> -  None.
> -
> ---*/
> -{
> -  CHAR16  *TmpStr;
> -
> -  DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n"));
> -
> -  //
> -  // If Boot returned with failed status then we need to pop up a UI and wait
> -  // for user input.
> -  //
> -  TmpStr = Option->StatusString;
> -  if (TmpStr != NULL) {
> -BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", 
> NULL);
> -FreePool (TmpStr);
> -  }
> -}
> -
> -VOID
> -EFIAPI
> -PlatformBdsLockNonUpdatableFlash (
> -  VOID
> -  )
> -{
> -  DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n"));
> -  return;
> -}
> -
> -
>  /**
>This notification function is invoked when an instance of the
>EFI_DEVICE_PATH_PROTOCOL is produced.
> 

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


Re: [edk2] [Patch v3 15/23] OvmfPkg/PlatformBds: Change PlatformBdsConnectSequence()

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> The patch changes PlatformBdsConnectSequence() to use library API
> exposed from UefiBootManagerLib and removes the additional
> connect ALL action.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 9 +++--
>  1 file changed, 3 insertions(+), 6 deletions(-)

Please change the subject to:

  OvmfPkg/PlatformBootManagerLib: port PlatformBdsConnectSequence to 
UefiBootManagerLib

(It is 85 characters long, but we can't do anything about it -- the function 
and library names are just long.)

With that:

Reviewed-by: Laszlo Ersek 

Thanks!
Laszlo

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 43a859c..dc6bc7f 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -1075,7 +1075,6 @@ PlatformBdsRestoreNvVarsFromHardDisk (
>  
>  }
>  
> -
>  VOID
>  PlatformBdsConnectSequence (
>VOID
> @@ -1112,14 +,15 @@ Returns:
>  //
>  // Build the platform boot option
>  //
> -BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);
> +EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index], NULL);
>  Index++;
>}
>  
>//
>// Just use the simple policy to connect all devices
>//
> -  BdsLibConnectAll ();
> +  DEBUG ((EFI_D_INFO, "EfiBootManagerConnectAll\n"));
> +  EfiBootManagerConnectAll ();
>  
>PciAcpiInitialization ();
>  
> @@ -1338,9 +1338,6 @@ Routine Description:
>// Process QEMU's -kernel command line option
>//
>TryRunningQemuKernel ();
> -
> -  DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n"));
> -  BdsLibConnectAll ();
>BdsLibEnumerateAllBootOption (BootOptionList);
>  
>SetBootOrderFromQemu (BootOptionList);
> 

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


Re: [edk2] [PATCH] ArmPlatformPkg/PrePi: allow unicore version to be used on MP hardware

2016-04-28 Thread Ard Biesheuvel
On 19 April 2016 at 09:26, Ard Biesheuvel  wrote:
> When combining UEFI firmware built from Tianocore with ARM Trusted
> Firmware running in EL3, it is the responsibility of ATF that only
> a single core enters the UEFI firmware in EL2, and the remaining cores
> are released directly to the OS via PSCI SMC calls.
>
> In this case, we don't need the MpCore flavor of PrePi or PrePeiCore,
> but the UniCore flavor currently checks the CPU identification registers
> directly, and refuses to proceed if the boot CPU is part of a MpCore
> system.
>
> So drop the ASSERT()'s that implement this check.
>

We will need something like this for PrePeiCore so that we can move Husky to it

> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmPlatformPkg/PrePi/MainUniCore.c | 5 -
>  ArmPlatformPkg/PrePi/PrePi.c   | 2 --
>  2 files changed, 7 deletions(-)
>
> diff --git a/ArmPlatformPkg/PrePi/MainUniCore.c 
> b/ArmPlatformPkg/PrePi/MainUniCore.c
> index 49b02338ebc2..11b9f462bb48 100644
> --- a/ArmPlatformPkg/PrePi/MainUniCore.c
> +++ b/ArmPlatformPkg/PrePi/MainUniCore.c
> @@ -21,11 +21,6 @@ PrimaryMain (
>IN  UINT64StartTimeStamp
>)
>  {
> -  DEBUG_CODE_BEGIN();
> -// On MPCore system, PeiMpCore.inf should be used instead of 
> PeiUniCore.inf
> -ASSERT(ArmIsMpCore() == 0);
> -  DEBUG_CODE_END();
> -
>PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
>
>// We must never return
> diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c
> index 8740b2a9e84d..36928c65a73b 100644
> --- a/ArmPlatformPkg/PrePi/PrePi.c
> +++ b/ArmPlatformPkg/PrePi/PrePi.c
> @@ -183,8 +183,6 @@ CEntryPoint (
>  {
>UINT64   StartTimeStamp;
>
> -  ASSERT(!ArmIsMpCore() || (PcdGet32 (PcdCoreCount) > 1));
> -
>// Initialize the platform specific controllers
>ArmPlatformInitialize (MpId);
>
> --
> 2.5.0
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch v3 16/23] OvmfPkg/PlatformBds: Use EfiBootManagerRefreshAllBootOption()

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> The patch uses EfiBootManagerRefreshAllBootOption() to collect
> all boot options and uses SetBootOrderFromQemu exposed by
> QemuNewBootOrderLib to adjust the boot option order.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 11 +++
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h |  1 +
>  2 files changed, 4 insertions(+), 8 deletions(-)

Reviewed-by: Laszlo Ersek 

Thanks!
Laszlo

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index dc6bc7f..0284a9a 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -14,7 +14,6 @@
>  
>  #include "BdsPlatform.h"
>  #include 
> -#include 
>  
>  
>  //
> @@ -1338,14 +1337,10 @@ Routine Description:
>// Process QEMU's -kernel command line option
>//
>TryRunningQemuKernel ();
> -  BdsLibEnumerateAllBootOption (BootOptionList);
>  
> -  SetBootOrderFromQemu (BootOptionList);
> -  //
> -  // The BootOrder variable may have changed, reload the in-memory list with
> -  // it.
> -  //
> -  BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
> +  EfiBootManagerRefreshAllBootOption ();
> +
> +  SetBootOrderFromQemu (NULL);
>  }
>  
>  /**
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> index 2eab29a..ae3c268 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> @@ -47,6 +47,7 @@ Abstract:
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> 

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


Re: [edk2] [Patch v3 17/23] OvmfPkg/PlatformBds: Remove PlatformBdsGetDriverOption()

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  .../Library/PlatformBootManagerLib/BdsPlatform.c   | 30 
> --
>  .../Library/PlatformBootManagerLib/BdsPlatform.h   |  6 -
>  2 files changed, 36 deletions(-)

Reviewed-by: Laszlo Ersek 

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 0284a9a..59ff097 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -1129,31 +1129,6 @@ Returns:
>  }
>  
>  VOID
> -PlatformBdsGetDriverOption (
> -  IN OUT LIST_ENTRY  *BdsDriverLists
> -  )
> -/*++
> -
> -Routine Description:
> -
> -  Load the predefined driver option, OEM/IBV can customize this
> -  to load their own drivers
> -
> -Arguments:
> -
> -  BdsDriverLists  - The header of the driver option link list.
> -
> -Returns:
> -
> -  None.
> -
> ---*/
> -{
> -  DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n"));
> -  return;
> -}
> -
> -VOID
>  PlatformBdsDiagnostics (
>IN EXTENDMEM_COVERAGE_LEVELMemoryTestLevel,
>IN BOOLEAN QuietBoot,
> @@ -1307,11 +1282,6 @@ Routine Description:
>}
>  
>//
> -  // Load the driver option as the driver option list
> -  //
> -  PlatformBdsGetDriverOption (DriverOptionList);
> -
> -  //
>// Get current Boot Mode
>//
>Status = BdsLibGetBootMode (&BootMode);
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> index ae3c268..6e5ca34 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> @@ -210,12 +210,6 @@ extern PLATFORM_CONSOLE_CONNECT_ENTRY  
> gPlatformConsole[];
>  //
>  // Platform BDS Functions
>  //
> -
> -VOID
> -PlatformBdsGetDriverOption (
> -  IN LIST_ENTRY   *BdsDriverLists
> -  );
> -
>  EFI_STATUS
>  BdsMemoryTest (
>EXTENDMEM_COVERAGE_LEVEL Level
> 

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


Re: [edk2] [Patch v3 18/23] OvmfPkg/PlatformBds: Use GetBootModeHob() in HobLib

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Laszlo Ersek 

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 59ff097..6c21407 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -1240,7 +1240,6 @@ Routine Description:
>  
>  --*/
>  {
> -  EFI_STATUS Status;
>EFI_BOOT_MODE  BootMode;
>  
>DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n"));
> @@ -1284,7 +1283,7 @@ Routine Description:
>//
>// Get current Boot Mode
>//
> -  Status = BdsLibGetBootMode (&BootMode);
> +  BootMode = GetBootModeHob ();
>DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));
>  
>//
> 

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


Re: [edk2] [PATCH] ArmPlatformPkg/PrePi: allow unicore version to be used on MP hardware

2016-04-28 Thread Leif Lindholm
On Thu, Apr 28, 2016 at 05:02:19PM +0200, Ard Biesheuvel wrote:
> On 19 April 2016 at 09:26, Ard Biesheuvel  wrote:
> > When combining UEFI firmware built from Tianocore with ARM Trusted
> > Firmware running in EL3, it is the responsibility of ATF that only
> > a single core enters the UEFI firmware in EL2, and the remaining cores
> > are released directly to the OS via PSCI SMC calls.
> >
> > In this case, we don't need the MpCore flavor of PrePi or PrePeiCore,
> > but the UniCore flavor currently checks the CPU identification registers
> > directly, and refuses to proceed if the boot CPU is part of a MpCore
> > system.
> >
> > So drop the ASSERT()'s that implement this check.
> >
> 
> We will need something like this for PrePeiCore so that we can move Husky to 
> it

Yeah, sorry - was getting stuck considering what to do at the MP side,
but that really is a completely separate thing.

Apart from the name no longer making sense:
Reviewed-by: Leif Lindholm 

> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >  ArmPlatformPkg/PrePi/MainUniCore.c | 5 -
> >  ArmPlatformPkg/PrePi/PrePi.c   | 2 --
> >  2 files changed, 7 deletions(-)
> >
> > diff --git a/ArmPlatformPkg/PrePi/MainUniCore.c 
> > b/ArmPlatformPkg/PrePi/MainUniCore.c
> > index 49b02338ebc2..11b9f462bb48 100644
> > --- a/ArmPlatformPkg/PrePi/MainUniCore.c
> > +++ b/ArmPlatformPkg/PrePi/MainUniCore.c
> > @@ -21,11 +21,6 @@ PrimaryMain (
> >IN  UINT64StartTimeStamp
> >)
> >  {
> > -  DEBUG_CODE_BEGIN();
> > -// On MPCore system, PeiMpCore.inf should be used instead of 
> > PeiUniCore.inf
> > -ASSERT(ArmIsMpCore() == 0);
> > -  DEBUG_CODE_END();
> > -
> >PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
> >
> >// We must never return
> > diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c
> > index 8740b2a9e84d..36928c65a73b 100644
> > --- a/ArmPlatformPkg/PrePi/PrePi.c
> > +++ b/ArmPlatformPkg/PrePi/PrePi.c
> > @@ -183,8 +183,6 @@ CEntryPoint (
> >  {
> >UINT64   StartTimeStamp;
> >
> > -  ASSERT(!ArmIsMpCore() || (PcdGet32 (PcdCoreCount) > 1));
> > -
> >// Initialize the platform specific controllers
> >ArmPlatformInitialize (MpId);
> >
> > --
> > 2.5.0
> >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch v3 19/23] OvmfPkg/PlatformBds: Remove unnecessary memory test

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  .../Library/PlatformBootManagerLib/BdsPlatform.c   | 60 
> +-
>  .../Library/PlatformBootManagerLib/BdsPlatform.h   |  5 --
>  2 files changed, 2 insertions(+), 63 deletions(-)

Reviewed-by: Laszlo Ersek 

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 6c21407..e595979 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -1128,62 +1128,6 @@ Returns:
>gST->ConOut->ClearScreen (gST->ConOut);
>  }
>  
> -VOID
> -PlatformBdsDiagnostics (
> -  IN EXTENDMEM_COVERAGE_LEVELMemoryTestLevel,
> -  IN BOOLEAN QuietBoot,
> -  IN BASEM_MEMORY_TEST   BaseMemoryTest
> -  )
> -/*++
> -
> -Routine Description:
> -
> -  Perform the platform diagnostic, such like test memory. OEM/IBV also
> -  can customize this fuction to support specific platform diagnostic.
> -
> -Arguments:
> -
> -  MemoryTestLevel  - The memory test intensive level
> -
> -  QuietBoot- Indicate if need to enable the quiet boot
> -
> -  BaseMemoryTest   - A pointer to BaseMemoryTest()
> -
> -Returns:
> -
> -  None.
> -
> ---*/
> -{
> -  EFI_STATUS  Status;
> -
> -  DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n"));
> -
> -  //
> -  // Here we can decide if we need to show
> -  // the diagnostics screen
> -  // Notes: this quiet boot code should be remove
> -  // from the graphic lib
> -  //
> -  if (QuietBoot) {
> -EnableQuietBoot (PcdGetPtr(PcdLogoFile));
> -//
> -// Perform system diagnostic
> -//
> -Status = BaseMemoryTest (MemoryTestLevel);
> -if (EFI_ERROR (Status)) {
> -  DisableQuietBoot ();
> -}
> -
> -return ;
> -  }
> -  //
> -  // Perform system diagnostic
> -  //
> -  Status = BaseMemoryTest (MemoryTestLevel);
> -}
> -
> -
>  /**
>Save the S3 boot script.
>  
> @@ -1293,9 +1237,9 @@ Routine Description:
>ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
>  
>//
> -  // Memory test and Logo show
> +  // Logo show
>//
> -  PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
> +  EnableQuietBoot (PcdGetPtr (PcdLogoFile));
>  
>//
>// Perform some platform specific connect sequence
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> index 6e5ca34..4bde841 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> @@ -211,11 +211,6 @@ extern PLATFORM_CONSOLE_CONNECT_ENTRY  
> gPlatformConsole[];
>  // Platform BDS Functions
>  //
>  EFI_STATUS
> -BdsMemoryTest (
> -  EXTENDMEM_COVERAGE_LEVEL Level
> -  );
> -
> -EFI_STATUS
>  PlatformBdsShowProgress (
>EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
>EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
> 

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


Re: [edk2] [Patch v3 20/23] OvmfPkg/PlatformBds: Remove unused variables and function prototypes.

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h  | 11 ---
>  OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c | 12 +---
>  2 files changed, 1 insertion(+), 22 deletions(-)

One question:

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> index 4bde841..3d05999 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> @@ -68,7 +68,6 @@ Abstract:
>  #include 
>  
>  extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];
> -extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformDriverOption[];
>  extern ACPI_HID_DEVICE_PATH   gPnpPs2KeyboardDeviceNode;
>  extern ACPI_HID_DEVICE_PATH   gPnp16550ComPortDeviceNode;
>  extern UART_DEVICE_PATH   gUartDeviceNode;
> @@ -221,16 +220,6 @@ PlatformBdsShowProgress (
>);
>  
>  VOID
> -PlatformBdsConnectSequence (
> -  VOID
> -  );

The definition for this function does exist -- why are you removing the
prototype?

Or else, is the idea that the prototype should be removed if there is no
external caller? I can agree with that as well, but in that case, a lot
more could be removed.

So, I'm not saying that this patch is wrong; I just find the selection
arbitrary. I think we should either not remove this prototype, or remove
a lot more (for example, all the Convert*() prototypes). What do you think?

Thanks!
Laszlo

> -
> -EFI_STATUS
> -ProcessCapsules (
> -  EFI_BOOT_MODE BootMode
> -  );
> -
> -VOID
>  PlatformInitializeConsole (
>IN PLATFORM_CONSOLE_CONNECT_ENTRY   *PlatformConsole
>);
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c 
> b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
> index 4f8cdf7..e9737a7 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
> @@ -2,7 +2,7 @@
>Defined the platform specific device path which will be used by
>platform Bbd to perform the platform policy connect.
>  
> -  Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
> +  Copyright (c) 2004 - 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
> @@ -15,11 +15,6 @@
>  
>  #include "BdsPlatform.h"
>  
> -//
> -// Predefined platform default time out value
> -//
> -UINT16  gPlatformBootTimeOutDefault = 5;
> -
>  ACPI_HID_DEVICE_PATH   gPnpPs2KeyboardDeviceNode  = gPnpPs2Keyboard;
>  ACPI_HID_DEVICE_PATH   gPnp16550ComPortDeviceNode = gPnp16550ComPort;
>  UART_DEVICE_PATH   gUartDeviceNode= gUart;
> @@ -40,11 +35,6 @@ PLATFORM_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {
>  };
>  
>  //
> -// Predefined platform specific driver option
> -//
> -EFI_DEVICE_PATH_PROTOCOL*gPlatformDriverOption[] = { NULL };
> -
> -//
>  // Predefined platform connect sequence
>  //
>  EFI_DEVICE_PATH_PROTOCOL*gPlatformConnectSequence[] = { NULL };
> 

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


[edk2] [PATCH] MdeModulePkg/PciBusDxe: don't create bogus descriptor if no resources needed

2016-04-28 Thread Ard Biesheuvel
If the current PCI configuration requires no resources to be allocated at
all (i.e., unpopulated bus), the PCI enumeration code creates a single
ACPI_ADDRESS_SPACE_DESCRIPTOR memory descriptor with all fields cleared.
This is rejected by the SubmitResources() implementation of the generic
PciHostBridgeDxe in the following way:

  PciHostBridge: SubmitResources for PcieRoot(0x0)
   Mem: Granularity/SpecificFlag = 0 / 00
Length/Alignment = 0x0 / 0x0
  PciBus: HostBridge->SubmitResources() - Invalid Parameter

  ASSERT_EFI_ERROR (Status = Invalid Parameter)
  ASSERT [PciBusDxe] .../PciBusDxe/PciLib.c(561): !EFI_ERROR (Status)

So instead, create the empty configuration as a single entry of type
EFI_ACPI_END_TAG_DESCRIPTOR.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
index 597c0834e0f5..469a2ddb8ac0 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
@@ -1307,15 +1307,12 @@ ConstructAcpiResourceRequestor (
 //
 // If there is no resource request
 //
-Configuration = AllocateZeroPool (sizeof 
(EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR));
+Configuration = AllocateZeroPool (sizeof (EFI_ACPI_END_TAG_DESCRIPTOR));
 if (Configuration == NULL) {
   return EFI_OUT_OF_RESOURCES;
 }
 
-Ptr   = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) (Configuration);
-Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
-
-PtrEnd= (EFI_ACPI_END_TAG_DESCRIPTOR *) (Ptr + 1);
+PtrEnd= (EFI_ACPI_END_TAG_DESCRIPTOR *) (Configuration);
 PtrEnd->Desc  = ACPI_END_TAG_DESCRIPTOR;
 PtrEnd->Checksum  = 0;
   }
-- 
2.7.4

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


Re: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by serial IO mode

2016-04-28 Thread Andrew Fish

> On Apr 28, 2016, at 7:19 AM, Heyi Guo  wrote:
> 
> 
> 
> On 04/28/2016 11:17 AM, Andrew Fish wrote:
>>> On Apr 27, 2016, at 8:10 PM, Ni, Ruiyu  wrote:
>>> 
 -Original Message-
 From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
 Heyi Guo
 Sent: Saturday, April 23, 2016 4:54 PM
 To: edk2-devel@lists.01.org
 Cc: Kinney, Michael D ; Heyi Guo 
 ; Tian, Feng ;
 Zeng, Star 
 Subject: [edk2] [PATCH] MdeModulePkg/TerminalDxe: Set polling rate by 
 serial IO mode
 
 Calculate serial input polling rate according to parameters from
 serial IO mode as below, to fix potential input truncation.
 
 Polling interval (100ns) =
 FifoDepth * (StartBit + DataBits + StopBits + ParityBits) * 10,000,000
 / BaudRate
 (StopBits is assumed to be 1 and ParityBits is ignored for simplicity.
 
 However, as the event is time sensitive, we need to align the interval
 to timer interrupt period to make sure the event will be triggered at
 the expected rate. E.g. if the interval is 2.7ms and timer interrupt
 period is 1ms, the event will be triggered by time slice sequence as
 below:
 3ms 3ms 2ms 3ms 3ms 2ms...
 
 In such case we will adjust the polling interval to be 2ms.
>>> Heyi,
>>> I remember we had a discussion about the polling interval calculation
>>> equation a month ago. The equation used in the patch looks good to me.
>>> Because the timer handler is called sometimes every 3ms but not 2.7ms
>>> resulting the key loss?
>>> Just want to confirm with you.
>>> 
>> Is it safe to make assumptions based on an implementation of an AP? Other 
>> platforms could be using different code?
>> 
>> Thanks,
>> 
>> Andrew Fish
> Michael has similar concern and we will try using standard UEFI services or 
> protocols to achieve the timer interrupt period.
> 

I know Kinney mentioned not to use PI APIs, but this sounds like you are making 
assumptions about the implementation. A lot of the EFI APIs are specified as 
will delay at least X 100 ns, and with no quality of service guarantee. So you 
need to code to that assumption, not how a specific timer driver works. 

Thanks,

Andrew Fish

> Thanks.
> 
> Heyi
>> 
>>> Regards,
>>> Ray
>>> 
 Contributed-under: TianoCore Contribution Agreement 1.0
 Signed-off-by: Heyi Guo 
 Cc: Feng Tian 
 Cc: Star Zeng 
 Cc: Michael D Kinney 
 ---
 .../Universal/Console/TerminalDxe/Terminal.c   |  5 +-
 .../Universal/Console/TerminalDxe/Terminal.h   | 28 ++-
 .../Universal/Console/TerminalDxe/TerminalConIn.c  | 92 
 ++
 .../Universal/Console/TerminalDxe/TerminalDxe.inf  |  1 +
 4 files changed, 123 insertions(+), 3 deletions(-)
 
 diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
 b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
 index 6fde3b2..2944707 100644
 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
 +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
 @@ -71,6 +71,7 @@ TERMINAL_DEV  mTerminalDevTemplate = {
  },
  NULL, // TerminalConsoleModeData
  0,  // SerialInTimeOut
 +  0,  // KeyboardTimerInterval
 
  NULL, // RawFifo
  NULL, // UnicodeFiFo
 @@ -984,10 +985,12 @@ TerminalDriverBindingStart (
);
ASSERT_EFI_ERROR (Status);
 
 +TerminalDevice->KeyboardTimerInterval = GetKeyboardTimerInterval 
 (Mode);
 +
Status = gBS->SetTimer (
TerminalDevice->TimerEvent,
TimerPeriodic,
 -KEYBOARD_TIMER_INTERVAL
 +TerminalDevice->KeyboardTimerInterval
);
ASSERT_EFI_ERROR (Status);
 
 diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
 b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
 index 269d2ae..a1ff595 100644
 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
 +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
 @@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, 
 EITHER EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
 +#include 
 
 #include 
 #include 
 @@ -68,8 +69,6 @@ typedef struct {
  UINTN   Rows;
 } TERMINAL_CONSOLE_MODE_DATA;
 
 -#define KEYBOARD_TIMER_INTERVAL 20  // 0.02s
 -
 #define TERMINAL_DEV_SIGNATURE  SIGNATURE_32 ('t', 'm', 'n', 'l')
 
 #define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('t', 'm', 
 'e', 'n')
 @@ -91,6 +90,7 @@ typedef struct {
  EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
  TERMINAL_CONSOLE_MODE_DATA  *TerminalConsoleModeData;
  UINTN   SerialInTimeOut;
 +  UINT64  KeyboardTimerInterval;
  RAW_DAT

Re: [edk2] [Patch v3 21/23] OvmfPkg/PlatformBds: Add EnableQuietBoot and DisableQuietBoot

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> EnableQuietBoot and DisableQuietBoot are copied from
> IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c.
> Because these two functions are not in UefiBootManagerLib.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  .../Library/PlatformBootManagerLib/BdsPlatform.h   |  33 +
>  .../PlatformBootManagerLib.inf |   3 +
>  OvmfPkg/Library/PlatformBootManagerLib/QuietBoot.c | 668 
> +
>  3 files changed, 704 insertions(+)
>  create mode 100644 OvmfPkg/Library/PlatformBootManagerLib/QuietBoot.c

Two remarks:

> +  default:
> +//
> +// Other bit format BMP is not supported.
> +//
> +if (IsAllocated) {
> +  FreePool (*GopBlt);
> +  *GopBlt = NULL;
> +}
> +return EFI_UNSUPPORTED;
> +break;

This break statement is not present in the original (and it is dead code
here).

> +  //
> +  // Get the specified image from FV.
> +  //
> +  Status = GetSectionFromAnyFv (LogoFile, EFI_SECTION_RAW, 0, (VOID **) 
> &ImageData, &ImageSize);
> +  if (EFI_ERROR (Status)) {
> +return EFI_UNSUPPORTED;
> +  }
> +
> +  CoordinateX = 0;
> +  CoordinateY = 0;
> +  Attribute   = EfiBadgingDisplayAttributeCenter;

This again differs from the original, where, dependent on
PcdBootlogoOnlyEnable, we set EfiBadgingDisplayAttributeCustomized instead.

Any reason for this difference?

The patch looks good otherwise (with the issues fixed that Gary brought up).

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


Re: [edk2] [PATCH] MdeModulePkg/PciBusDxe: don't create bogus descriptor if no resources needed

2016-04-28 Thread Laszlo Ersek
On 04/28/16 17:51, Ard Biesheuvel wrote:
> If the current PCI configuration requires no resources to be allocated at
> all (i.e., unpopulated bus), the PCI enumeration code creates a single
> ACPI_ADDRESS_SPACE_DESCRIPTOR memory descriptor with all fields cleared.
> This is rejected by the SubmitResources() implementation of the generic
> PciHostBridgeDxe in the following way:
> 
>   PciHostBridge: SubmitResources for PcieRoot(0x0)
>Mem: Granularity/SpecificFlag = 0 / 00
> Length/Alignment = 0x0 / 0x0
>   PciBus: HostBridge->SubmitResources() - Invalid Parameter
> 
>   ASSERT_EFI_ERROR (Status = Invalid Parameter)
>   ASSERT [PciBusDxe] .../PciBusDxe/PciLib.c(561): !EFI_ERROR (Status)
> 
> So instead, create the empty configuration as a single entry of type
> EFI_ACPI_END_TAG_DESCRIPTOR.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)

Is this error related to the other thread?

http://thread.gmane.org/gmane.comp.bios.edk2.devel/11135

In particular, to PcdPciDisableBusEnumeration?

Thanks
Laszlo

> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c 
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
> index 597c0834e0f5..469a2ddb8ac0 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
> @@ -1307,15 +1307,12 @@ ConstructAcpiResourceRequestor (
>  //
>  // If there is no resource request
>  //
> -Configuration = AllocateZeroPool (sizeof 
> (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR));
> +Configuration = AllocateZeroPool (sizeof (EFI_ACPI_END_TAG_DESCRIPTOR));
>  if (Configuration == NULL) {
>return EFI_OUT_OF_RESOURCES;
>  }
>  
> -Ptr   = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) 
> (Configuration);
> -Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
> -
> -PtrEnd= (EFI_ACPI_END_TAG_DESCRIPTOR *) (Ptr + 1);
> +PtrEnd= (EFI_ACPI_END_TAG_DESCRIPTOR *) (Configuration);
>  PtrEnd->Desc  = ACPI_END_TAG_DESCRIPTOR;
>  PtrEnd->Checksum  = 0;
>}
> 

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


Re: [edk2] [Patch v3 22/23] OvmfPkg/PlatformBds: Remove unused C structures definitions.

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  .../Library/PlatformBootManagerLib/BdsPlatform.h   | 47 
> --
>  1 file changed, 47 deletions(-)

Reviewed-by: Laszlo Ersek 

> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h 
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> index 8c17297..43b487e 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
> @@ -152,56 +152,9 @@ extern VENDOR_DEVICE_PATH 
> gTerminalTypeDeviceNode;
>  #define PCI_SUBCLASS_SERIAL0x00
>  #define PCI_IF_16550   0x02
>  #define IS_PCI_16550SERIAL(_p)   IS_CLASS3 (_p, PCI_CLASS_SCC, 
> PCI_SUBCLASS_SERIAL, PCI_IF_16550)
> -
> -#define EFI_SYSTEM_TABLE_MAX_ADDRESS 0x
> -#define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 )
> -
>  #define IS_PCI_ISA_PDECODE(_p)IS_CLASS3 (_p, PCI_CLASS_BRIDGE, 
> PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
>  
>  typedef struct {
> -  ACPI_HID_DEVICE_PATH  PciRootBridge;
> -  PCI_DEVICE_PATH   IsaBridge;
> -  ACPI_HID_DEVICE_PATH  Keyboard;
> -  EFI_DEVICE_PATH_PROTOCOL  End;
> -} PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH;
> -
> -typedef struct {
> -  ACPI_HID_DEVICE_PATH  PciRootBridge;
> -  PCI_DEVICE_PATH   IsaBridge;
> -  ACPI_HID_DEVICE_PATH  IsaSerial;
> -  UART_DEVICE_PATH  Uart;
> -  VENDOR_DEVICE_PATHTerminalType;
> -  EFI_DEVICE_PATH_PROTOCOL  End;
> -} PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH;
> -
> -typedef struct {
> -  ACPI_HID_DEVICE_PATH  PciRootBridge;
> -  PCI_DEVICE_PATH   VgaDevice;
> -  EFI_DEVICE_PATH_PROTOCOL  End;
> -} PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH;
> -
> -typedef struct {
> -  ACPI_HID_DEVICE_PATH  PciRootBridge;
> -  PCI_DEVICE_PATH   PciBridge;
> -  PCI_DEVICE_PATH   SerialDevice;
> -  UART_DEVICE_PATH  Uart;
> -  VENDOR_DEVICE_PATHTerminalType;
> -  EFI_DEVICE_PATH_PROTOCOL  End;
> -} PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH;
> -
> -//
> -// the short form device path for Usb keyboard
> -//
> -#define CLASS_HID   3
> -#define SUBCLASS_BOOT   1
> -#define PROTOCOL_KEYBOARD   1
> -
> -typedef struct {
> -  USB_CLASS_DEVICE_PATH   UsbClass;
> -  EFI_DEVICE_PATH_PROTOCOLEnd;
> -} USB_CLASS_FORMAT_DEVICE_PATH;  
> -
> -typedef struct {
>EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
>UINTN ConnectType;
>  } PLATFORM_CONSOLE_CONNECT_ENTRY;
> 

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


Re: [edk2] [PATCH] MdeModulePkg/PciBusDxe: don't create bogus descriptor if no resources needed

2016-04-28 Thread Ard Biesheuvel
On 28 April 2016 at 18:06, Laszlo Ersek  wrote:
> On 04/28/16 17:51, Ard Biesheuvel wrote:
>> If the current PCI configuration requires no resources to be allocated at
>> all (i.e., unpopulated bus), the PCI enumeration code creates a single
>> ACPI_ADDRESS_SPACE_DESCRIPTOR memory descriptor with all fields cleared.
>> This is rejected by the SubmitResources() implementation of the generic
>> PciHostBridgeDxe in the following way:
>>
>>   PciHostBridge: SubmitResources for PcieRoot(0x0)
>>Mem: Granularity/SpecificFlag = 0 / 00
>> Length/Alignment = 0x0 / 0x0
>>   PciBus: HostBridge->SubmitResources() - Invalid Parameter
>>
>>   ASSERT_EFI_ERROR (Status = Invalid Parameter)
>>   ASSERT [PciBusDxe] .../PciBusDxe/PciLib.c(561): !EFI_ERROR (Status)
>>
>> So instead, create the empty configuration as a single entry of type
>> EFI_ACPI_END_TAG_DESCRIPTOR.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel 
>> ---
>>  MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 7 ++-
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> Is this error related to the other thread?
>
> http://thread.gmane.org/gmane.comp.bios.edk2.devel/11135
>
> In particular, to PcdPciDisableBusEnumeration?
>

No, it is completely separate, as far as I can tell. It simply creates
an incorrect descriptor list if none of the PCI devices behind a root
bridge require any resources at all, and this is probably a code path
that you are very unlikely to hit on x86.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] accessing IP info. set using ifconfig shell command in EFI application.

2016-04-28 Thread Carsey, Jaben
You could look at the source code for that command since you know that does 
what you want.
It's located here: ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> devendra rawat
> Sent: Thursday, April 28, 2016 5:41 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] accessing IP info. set using ifconfig shell command in EFI
> application.
> Importance: High
> 
> I am setting IP address, netmask and gateway IP for interface eth0 using
> Tianocore shell "ifconfig" command. I need to access these IP addresses in
> an EFI Application. can someone provide any pointers, or example code for
> doing the same.
> 
> Thanks,
> Deven
> ___
> 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] MdeModulePkg/PciBusDxe: don't create bogus descriptor if no resources needed

2016-04-28 Thread Laszlo Ersek
On 04/28/16 18:09, Ard Biesheuvel wrote:
> On 28 April 2016 at 18:06, Laszlo Ersek  wrote:
>> On 04/28/16 17:51, Ard Biesheuvel wrote:
>>> If the current PCI configuration requires no resources to be allocated at
>>> all (i.e., unpopulated bus), the PCI enumeration code creates a single
>>> ACPI_ADDRESS_SPACE_DESCRIPTOR memory descriptor with all fields cleared.
>>> This is rejected by the SubmitResources() implementation of the generic
>>> PciHostBridgeDxe in the following way:
>>>
>>>   PciHostBridge: SubmitResources for PcieRoot(0x0)
>>>Mem: Granularity/SpecificFlag = 0 / 00
>>> Length/Alignment = 0x0 / 0x0
>>>   PciBus: HostBridge->SubmitResources() - Invalid Parameter
>>>
>>>   ASSERT_EFI_ERROR (Status = Invalid Parameter)
>>>   ASSERT [PciBusDxe] .../PciBusDxe/PciLib.c(561): !EFI_ERROR (Status)
>>>
>>> So instead, create the empty configuration as a single entry of type
>>> EFI_ACPI_END_TAG_DESCRIPTOR.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Ard Biesheuvel 
>>> ---
>>>  MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 7 ++-
>>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> Is this error related to the other thread?
>>
>> http://thread.gmane.org/gmane.comp.bios.edk2.devel/11135
>>
>> In particular, to PcdPciDisableBusEnumeration?
>>
> 
> No, it is completely separate, as far as I can tell. It simply creates
> an incorrect descriptor list if none of the PCI devices behind a root
> bridge require any resources at all, and this is probably a code path
> that you are very unlikely to hit on x86.

Ah, very interesting. So only devices with PCI config space, right? How
curious. :)

Thank you for the explanation!
Laszlo

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


Re: [edk2] [Patch v3 23/23] OvmfPkg: Use MdeModulePkg/BDS

2016-04-28 Thread Laszlo Ersek
On 04/21/16 08:58, Ruiyu Ni wrote:
> By default the new MdeModulePkg/BDS is used.
> If USE_OLD_BDS is defined to TRUE, IntelFrameworkModulePkg/BDS
> is used.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 45 ++--
>  OvmfPkg/OvmfPkgIa32.fdf|  5 +
>  OvmfPkg/OvmfPkgIa32X64.dsc | 47 
> +++---
>  OvmfPkg/OvmfPkgIa32X64.fdf |  5 +
>  OvmfPkg/OvmfPkgX64.dsc | 45 ++--
>  OvmfPkg/OvmfPkgX64.fdf |  5 +
>  6 files changed, 133 insertions(+), 19 deletions(-)

This patch looks good. It is complex, but it can be followed.

I'm requesting a few (cosmetic) changes:

> @@ -551,13 +566,32 @@ [Components]
>PcAtChipsetPkg/KbcResetDxe/Reset.inf
>MdeModulePkg/Universal/Metronome/Metronome.inf
>PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
> +!if $(USE_OLD_BDS) == TRUE
>IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
>  
> -!ifdef $(CSM_ENABLE)
> +  !ifdef $(CSM_ENABLE)
>NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf
> -!endif
> +  !endif
>}

Looking at the DSC files, it seems we don't indent nested "!if"
directives at all. For consistency with the rest of the DSC files, can
we please drop the re-indentation? (For all three DSC files.)

> -
> +!else
> +  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
> +
> +  !ifdef $(CSM_ENABLE)

Same here -- please don't indent the !ifdef.

> +  NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf
> +  
> NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf
> +  !endif
> +  }
> +  MdeModulePkg/Application/UiApp/UiApp.inf {
> +
> +  NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
> +  NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
> +  
> NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
> +  !ifdef $(CSM_ENABLE)

Ditto.

> +  
> NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf
> +  
> NULL|IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf
> +  !endif
> +  }
> +!endif
>OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
>OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
>OvmfPkg/Virtio10Dxe/Virtio10.inf

[snip]

For the OvmfPkgIa32X64.dsc file specifically:

> @@ -417,11 +429,11 @@ [PcdsFixedAtBuild]
>gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
>  !endif
>  
> +[PcdsFixedAtBuild.X64]
>  !ifndef $(USE_OLD_SHELL)
>gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 
> 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
>  !endif
>  
> -[PcdsFixedAtBuild.X64]
>  !if $(SMM_REQUIRE) == TRUE
>gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01
>gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|10

I agree that PcdShellFile should be set in the [PcdsFixedAtBuild.X64]
section, and not the [PcdsFixedAtBuild] section.

Can you please factor out this change to a separate patch?


Thanks a lot for this work, Ray; I think it's really good, and I look
forward to using the new BDS driver + UI app.

I think this nice separation of patches will also help us much in
porting ArmVirtPkg too.


As discussed before (under patch v3 11/23), please wait with version 4,
until my short series

  [edk2] [PATCH 0/3] OvmfPkg: tighten the SMM lockdown

is committed; your v4 should be based upon it.

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


Re: [edk2] [PATCH 0/3] OvmfPkg: tighten the SMM lockdown

2016-04-28 Thread Jordan Justen
On 2016-04-27 12:20:46, Laszlo Ersek wrote:
> The first patch (for MdeModulePkg) fixes a bug that is exposed
> (triggered) by the third patch.
> 
> The second and third patches fix a security vulnerability in OVMF that I
> reported to the UEFI SRT more than three weeks ago:
> 
>   To: secur...@uefi.org, secal...@redhat.com [...]
>   From: Laszlo Ersek 
>   Subject: OVMF PlatformBds allows circumvention of SMM
>   Message-ID: <5701256d.8010...@redhat.com>
>   Date: Sun, 3 Apr 2016 16:15:09 +0200
> 
> I have not received any response thus far.
> 
> As can be seen above, I also reported the issue to the Red Hat SRT.
> While I received acknowledgement about my report, there has been no
> technical feedback either.
> 
> Now, this issue has very low impact in my opinion:
> 
> - Configurations (that is, (host kernel, QEMU, OVMF firmware) triplets)
>   on which the issue being fixed is *actually* a vulnerability count as
>   "very recent" and "sporadic" at best. I'm not aware of any deployments
>   where such a configuration is put to use in a production environment.
> 
> - If Secure Boot is enabled, then the attacker's job is much harder: he
>   cannot install just any UEFI driver in DriverOrder (see the second
>   patch for more explanation), he must instead exploit a bug in an
>   already signed UEFI driver, before that driver is blacklisted in DBX.
> 
> Independently, Ray's work for porting OvmfPkg to MdeModulePkg/BDS
> includes a patch, namely
> 
>   [edk2] [Patch v3 11/23] OvmfPkg/PlatformBds: Initialize console
>   variables in *BeforeConsole()
>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/10859/focus=11039
> 
> that needs to connect the PCI root bridges on the call stack of
> PlatformBdsInit(), not the current PlatformBdsPolicyBehavior(). Since
> patch #2 in this series implements a superset of that requirement, and
> given the low impact of the security issue (and the unresponsiveness of
> the USRT), it makes sense for me to post this small series first, and
> for Ray to rebase his work on top second.
> 
> I tested these changes in OVMF, with
> 
>   { S3 enabled, S3 disabled } x { SMM enabled, SMM disabled },
> 
> using Fedora guests.
> 
> Public branch: .
> 
> Cc: Feng Tian 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Ruiyu Ni 
> Cc: Star Zeng 
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (3):
>   MdeModulePkg: PiDxeS3BootScriptLib: honor PcdAcpiS3Enable
>   OvmfPkg: PlatformBdsLib: lock down SMM in PlatformBdsInit()
>   OvmfPkg: PlatformBdsLib: lock down SMM regardless of S3

2 & 3 Reviewed-by: Jordan Justen 

> 
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf |  1 +
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c   |  4 +
>  OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c | 89 
> 
>  3 files changed, 58 insertions(+), 36 deletions(-)
> 
> -- 
> 1.8.3.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 0/3] OvmfPkg: tighten the SMM lockdown

2016-04-28 Thread Laszlo Ersek
On 04/27/16 21:20, Laszlo Ersek wrote:
> The first patch (for MdeModulePkg) fixes a bug that is exposed
> (triggered) by the third patch.
> 
> The second and third patches fix a security vulnerability in OVMF that I
> reported to the UEFI SRT more than three weeks ago:
> 
>   To: secur...@uefi.org, secal...@redhat.com [...]
>   From: Laszlo Ersek 
>   Subject: OVMF PlatformBds allows circumvention of SMM
>   Message-ID: <5701256d.8010...@redhat.com>
>   Date: Sun, 3 Apr 2016 16:15:09 +0200
> 
> I have not received any response thus far.
> 
> As can be seen above, I also reported the issue to the Red Hat SRT.
> While I received acknowledgement about my report, there has been no
> technical feedback either.
> 
> Now, this issue has very low impact in my opinion:
> 
> - Configurations (that is, (host kernel, QEMU, OVMF firmware) triplets)
>   on which the issue being fixed is *actually* a vulnerability count as
>   "very recent" and "sporadic" at best. I'm not aware of any deployments
>   where such a configuration is put to use in a production environment.
> 
> - If Secure Boot is enabled, then the attacker's job is much harder: he
>   cannot install just any UEFI driver in DriverOrder (see the second
>   patch for more explanation), he must instead exploit a bug in an
>   already signed UEFI driver, before that driver is blacklisted in DBX.
> 
> Independently, Ray's work for porting OvmfPkg to MdeModulePkg/BDS
> includes a patch, namely
> 
>   [edk2] [Patch v3 11/23] OvmfPkg/PlatformBds: Initialize console
>   variables in *BeforeConsole()
>   http://thread.gmane.org/gmane.comp.bios.edk2.devel/10859/focus=11039
> 
> that needs to connect the PCI root bridges on the call stack of
> PlatformBdsInit(), not the current PlatformBdsPolicyBehavior(). Since
> patch #2 in this series implements a superset of that requirement, and
> given the low impact of the security issue (and the unresponsiveness of
> the USRT), it makes sense for me to post this small series first, and
> for Ray to rebase his work on top second.
> 
> I tested these changes in OVMF, with
> 
>   { S3 enabled, S3 disabled } x { SMM enabled, SMM disabled },
> 
> using Fedora guests.
> 
> Public branch: .
> 
> Cc: Feng Tian 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Ruiyu Ni 
> Cc: Star Zeng 
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (3):
>   MdeModulePkg: PiDxeS3BootScriptLib: honor PcdAcpiS3Enable
>   OvmfPkg: PlatformBdsLib: lock down SMM in PlatformBdsInit()
>   OvmfPkg: PlatformBdsLib: lock down SMM regardless of S3
> 
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf |  1 +
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c   |  4 +
>  OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c | 89 
> 
>  3 files changed, 58 insertions(+), 36 deletions(-)

Thanks much everyone for the reviews; I've pushed the series:

59844e126614..84d2070aef84

Ray, please feel free to proceed with v4 of "Use MdeModulePkg/BDS in
OVMF platform".

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


[edk2] [staging/HTTPs-TLS] merge from tianocore master

2016-04-28 Thread El-Haj-Mahmoud, Samer
Jiaxin,

Can you please merge this revision into the edk2-staging/HTTPS-TLS branch, 
since it conflicts with the TLS code?

Thanks,
--Samer


Revision: 20667
Author: edk2buildsystem
Date: Thursday, April 28, 2016 4:05:33 AM
Message:
NetworkPkg: Avoid the indefinite wait case in HttpDxe

Need the timer check to avoid the indefinite wait case
in HttpDxe driver
A.HTTP receive Header process in HttpTcpReceiveHeader();
B.HTTP receive Body process in HttpTcpReceiveBody();

Cc: Hegde Nagaraj P 
Cc: El-Haj-Mahmoud Samer 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
Reviewed-by: Hegde Nagaraj P 
Reviewed-by: Fu Siyuan 
(cherry picked from commit b347a22aecbfac9aac47831fee9a30aa810d6d0b)

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


[edk2] [staging/HTTPS-TLS][PATCH] CryptPkg: Cleanup TlsLib X509Store initialization

2016-04-28 Thread Samer El-Haj-Mahmoud
Cleanup TlsLib to create a new X509 store only if needed in TlsNew(),
and set its flags when created, not every time we are adding a
certificate (in TlsSetCaCertificate)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Thomas Palmer 
---
 CryptoPkg/Library/TlsLib/TlsLib.c | 41 ++-
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/CryptoPkg/Library/TlsLib/TlsLib.c 
b/CryptoPkg/Library/TlsLib/TlsLib.c
index 0818653..b91fee7 100644
--- a/CryptoPkg/Library/TlsLib/TlsLib.c
+++ b/CryptoPkg/Library/TlsLib/TlsLib.c
@@ -130,7 +130,7 @@ TlsInitialize (
   // Loads error strings from both crypto and ssl library.
   //
   SSL_load_error_strings ();
-  
+
   /// OpenSSL_add_all_algorithms();
 
   //
@@ -274,6 +274,7 @@ TlsNew (
   )
 {
   TLS_CONNECTION  *TlsConn;
+  X509_STORE  *X509Store;
 
   TlsConn = NULL;
 
@@ -342,6 +343,28 @@ TlsNew (
   //
   SSL_set_bio (TlsConn->Ssl, TlsConn->InBio, TlsConn->OutBio);
 
+
+  //
+  // Create new X509 store if needed
+  //
+  X509Store = SSL_CTX_get_cert_store (TlsConn->Ssl->ctx);
+  if (X509Store == NULL) {
+X509Store = X509_STORE_new ();
+if (X509Store == NULL) {
+  TlsFree ((VOID *) TlsConn);
+  return NULL;
+}
+SSL_CTX_set1_verify_cert_store (TlsConn->Ssl->ctx, X509Store);
+X509_STORE_free (X509Store);
+  }
+
+  //
+  // Set X509_STORE flags used in certificate validation
+  //
+  X509_STORE_set_flags (
+X509Store,
+X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_NO_CHECK_TIME
+);
   return (VOID *) TlsConn;
 }
 
@@ -1473,15 +1496,13 @@ TlsSetCaCertificate (
 
   X509Store = SSL_CTX_get_cert_store(TlsConn->Ssl->ctx);
   if (X509Store == NULL) {
-X509Store = X509_STORE_new();
-if (X509Store == NULL) {
   Status = EFI_ABORTED;
   goto ON_EXIT;
-}
-
-SSL_CTX_set_cert_store(TlsConn->Ssl->ctx, X509Store);
   }
 
+  //
+  // Add certificate to X509 store
+  //
   Ret = X509_STORE_add_cert (X509Store, Cert);
   if (Ret != 1) {
 ErrorCode = ERR_peek_last_error ();
@@ -1493,14 +1514,8 @@ TlsSetCaCertificate (
   Status = EFI_ABORTED;
   goto ON_EXIT;
 }
-
   }
-  
-  X509_STORE_set_flags (
-X509Store, 
-X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_NO_CHECK_TIME
-);
-  
+
 ON_EXIT:
   if (BioCert != NULL) {
 BIO_free (BioCert);
-- 
2.6.3.windows.1

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


[edk2] [PATCH] SecurityPkg: Add DEBUG messages for TPM2Startup

2016-04-28 Thread Samer El-Haj-Mahmoud
Add DEBUG messages for TPM2Startup to distinguish between TPM_RC_SUCCESS
and TPM_RC_INITIALIZE. This helps debugging some hardware problems.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
index f67043b..dc2c562 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
@@ -2,6 +2,7 @@
   Implement TPM2 Startup related command.
 
 Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -75,8 +76,11 @@ Tpm2Startup (
   ResponseCode = SwapBytes32(Res.Header.responseCode);
   switch (ResponseCode)  {
   case TPM_RC_SUCCESS:
+DEBUG ((DEBUG_INFO, "TPM2Startup: TPM_RC_SUCCESS\n"));
+return EFI_SUCCESS;
   case TPM_RC_INITIALIZE:
 // TPM_RC_INITIALIZE can be returned if Tpm2Startup is not required.
+DEBUG ((DEBUG_INFO, "TPM2Startup: TPM_RC_INITIALIZE\n"));
 return EFI_SUCCESS;
   default:
 DEBUG ((EFI_D_ERROR, "Tpm2Startup: Response Code error! 0x%08x\r\n", 
ResponseCode));
-- 
2.6.3.windows.1

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


[edk2] [PATCH] SecurityPkg: Fix TPM 1.2 NV Storage Command Size byte order

2016-04-28 Thread Samer El-Haj-Mahmoud
Fix Tpm12NvWriteValue() command/response length byte order.
Tpm12SubmitCommand() was using the value from Command.Hdr.paramSize
which was swapped to be Big Endian, but the function was
expecting it in UINT32 Little Endian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
index 7baafa8..e176b00 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 NV storage related command.
 
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -199,8 +200,9 @@ Tpm12NvWriteValue (
 {
   EFI_STATUS  Status;
   TPM_CMD_NV_WRITE_VALUE  Command;
+  UINT32  CommandLength;
   TPM_RSP_COMMAND_HDR Response;
-  UINT32  Length;
+  UINT32  ResponseLength;
 
   if (DataSize > sizeof (Command.Data)) {
 return EFI_UNSUPPORTED;
@@ -210,14 +212,15 @@ Tpm12NvWriteValue (
   // send Tpm command TPM_ORD_NV_WriteValue
   //
   Command.Hdr.tag   = SwapBytes16 (TPM_TAG_RQU_COMMAND);
-  Command.Hdr.paramSize = SwapBytes32 (sizeof (Command) - sizeof(Command.Data) 
+ DataSize);
+  CommandLength = sizeof (Command) - sizeof(Command.Data) + DataSize;
+  Command.Hdr.paramSize = SwapBytes32 (CommandLength);
   Command.Hdr.ordinal   = SwapBytes32 (TPM_ORD_NV_WriteValue);
   Command.NvIndex   = SwapBytes32 (NvIndex);
   Command.Offset= SwapBytes32 (Offset);
   Command.DataSize  = SwapBytes32 (DataSize);
   CopyMem (Command.Data, Data, DataSize);
-  Length = sizeof (Response);
-  Status = Tpm12SubmitCommand (Command.Hdr.paramSize, (UINT8 *)&Command, 
&Length, (UINT8 *)&Response);
+  ResponseLength = sizeof (Response);
+  Status = Tpm12SubmitCommand (CommandLength, (UINT8 *)&Command, 
&ResponseLength, (UINT8 *)&Response);
   if (EFI_ERROR (Status)) {
 return Status;
   }
-- 
2.6.3.windows.1

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


[edk2] [PATCH] SecurityPkg: Fix bug in TPM 1.2 SelfTest

2016-04-28 Thread Samer El-Haj-Mahmoud
Fix uninitialized command Length variable in TPM1.2 Self Test command

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
index cd08d19..8e232ee 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 NV Self Test related commands.
 
 Copyright (c) 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -42,5 +43,6 @@ Tpm12ContinueSelfTest (
   Command.tag   = SwapBytes16 (TPM_TAG_RQU_COMMAND);
   Command.paramSize = SwapBytes32 (sizeof (Command));
   Command.ordinal   = SwapBytes32 (TPM_ORD_ContinueSelfTest);
+  Length = sizeof (Response);
   return Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, 
(UINT8 *)&Response);
 }
-- 
2.6.3.windows.1

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


[edk2] [PATCH] SecurityPkg: Add DEBUG messages for TPM12Startup

2016-04-28 Thread Samer El-Haj-Mahmoud
Add DEBUG messages for TPM12Startup to distinguish between TPM_SUCCESS
and
TPM_INVALID_POSTINIT. This helps debugging some hardware problems.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
index bc10e45..098dd28 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 Startup related command.
 
 Copyright (c) 2013, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -16,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 
 
 #pragma pack(1)
 
@@ -59,8 +61,11 @@ Tpm12Startup (
   }
   switch (SwapBytes32(Response.returnCode)) {
   case TPM_SUCCESS:
+DEBUG ((DEBUG_INFO, "TPM12Startup: TPM_SUCCESS\n"));
+return EFI_SUCCESS;
   case TPM_INVALID_POSTINIT:
 // In warm reset, TPM may response TPM_INVALID_POSTINIT
+DEBUG ((DEBUG_INFO, "TPM12Startup: TPM_INVALID_POSTINIT\n"));
 return EFI_SUCCESS;
   default:
 return EFI_DEVICE_ERROR;
-- 
2.6.3.windows.1

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


[edk2] [PATCH] SecurityPkg: Update servers TCG ACPI Table template to TCG 1.2

2016-04-28 Thread Samer El-Haj-Mahmoud
Update the TCG Spec in the the EFI_TCG_SERVER_ACPI_TABLE from TCG 1.0 to
TCG 1.2

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Tcg/TcgDxe/TcgDxe.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/SecurityPkg/Tcg/TcgDxe/TcgDxe.c b/SecurityPkg/Tcg/TcgDxe/TcgDxe.c
index 690f356..0d7e32a 100644
--- a/SecurityPkg/Tcg/TcgDxe/TcgDxe.c
+++ b/SecurityPkg/Tcg/TcgDxe/TcgDxe.c
@@ -9,6 +9,7 @@ buffer overflow, integer overflow.
 TcgDxePassThroughToTpm() will receive untrusted input and do basic validation.
 
 Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials 
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at 
@@ -102,8 +103,8 @@ EFI_TCG_SERVER_ACPI_TABLE   mTcgServerAcpiTemplate 
= {
   0,  // Reserved
   0,  // Log Area Max Length
   (EFI_PHYSICAL_ADDRESS) (SIZE_4GB - 1), // Log Area Start Address
-  0x0100, // TCG Specification revision 1.0
-  2,  // Device Flags
+  0x0120, // TCG Specification revision 1.2
+  0,  // Device Flags
   0,  // Interrupt Flags
   0,  // GPE
   {0},// Reserved 3 bytes
@@ -353,9 +354,9 @@ TcgDxeHashAll (
   }
   *HashedDataLen = sizeof (TPM_DIGEST);
 
- if (*HashedDataResult == NULL) {
-   *HashedDataResult = AllocatePool ((UINTN) *HashedDataLen);
- } 
+  if (*HashedDataResult == NULL) {
+*HashedDataResult = AllocatePool ((UINTN) *HashedDataLen);
+  } 
 
   return TpmCommHashAll (
HashData,
-- 
2.6.3.windows.1

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


[edk2] [PATCH] SecurityPkg: Reduce DEBUG verbosity in Tcg2Dxe

2016-04-28 Thread Samer El-Haj-Mahmoud
Reduce several DEBUG messages verbosity from INFO to VERBOSE to reduce
debug spam when there is no TPM 2.0 part present

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c 
b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
index 07f76af..6555df5 100644
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
@@ -2,6 +2,7 @@
   This module implements Tcg2 Protocol.
   
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials 
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at 
@@ -332,14 +333,14 @@ Tcg2GetCapability (
   IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
   )
 {
-  DEBUG ((EFI_D_INFO, "Tcg2GetCapability ...\n"));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability ...\n"));
 
   if ((This == NULL) || (ProtocolCapability == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
   
-  DEBUG ((EFI_D_INFO, "Size - 0x%x\n", ProtocolCapability->Size));
-  DEBUG ((EFI_D_INFO, " 1.1 - 0x%x, 1.0 - 0x%x\n", 
sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY), 
sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));
+  DEBUG ((DEBUG_VERBOSE, "Size - 0x%x\n", ProtocolCapability->Size));
+  DEBUG ((DEBUG_VERBOSE, " 1.1 - 0x%x, 1.0 - 0x%x\n", 
sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY), 
sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));
 
   if (ProtocolCapability->Size < mTcgDxeData.BsCap.Size) {
 //
@@ -363,7 +364,7 @@ Tcg2GetCapability (
   }
 
   CopyMem (ProtocolCapability, &mTcgDxeData.BsCap, mTcgDxeData.BsCap.Size);
-  DEBUG ((EFI_D_INFO, "Tcg2GetCapability - %r\n", EFI_SUCCESS));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability - %r\n", EFI_SUCCESS));
   return EFI_SUCCESS;
 }
 
@@ -1237,7 +1238,7 @@ Tcg2HashLogExtendEvent (
   TCG_PCR_EVENT_HDR  NewEventHdr;
   TPML_DIGEST_VALUES DigestList;
 
-  DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent ...\n"));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent ...\n"));
 
   if ((This == NULL) || (DataToHash == 0) || (Event == NULL)) {
 return EFI_INVALID_PARAMETER;
@@ -1287,7 +1288,7 @@ Tcg2HashLogExtendEvent (
Event->Event
);
   }
-  DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent - %r\n", Status));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent - %r\n", Status));
   return Status;
 }
 
@@ -2530,10 +2531,10 @@ DriverEntry (
 mTcgDxeData.BsCap.SupportedEventLogs &= ~EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
   }
 
-  DEBUG ((EFI_D_INFO, "Tcg2.SupportedEventLogs - 0x%08x\n", 
mTcgDxeData.BsCap.SupportedEventLogs));
-  DEBUG ((EFI_D_INFO, "Tcg2.HashAlgorithmBitmap - 0x%08x\n", 
mTcgDxeData.BsCap.HashAlgorithmBitmap));
-  DEBUG ((EFI_D_INFO, "Tcg2.NumberOfPCRBanks  - 0x%08x\n", 
mTcgDxeData.BsCap.NumberOfPCRBanks));
-  DEBUG ((EFI_D_INFO, "Tcg2.ActivePcrBanks- 0x%08x\n", 
mTcgDxeData.BsCap.ActivePcrBanks));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2.SupportedEventLogs - 0x%08x\n", 
mTcgDxeData.BsCap.SupportedEventLogs));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2.HashAlgorithmBitmap - 0x%08x\n", 
mTcgDxeData.BsCap.HashAlgorithmBitmap));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2.NumberOfPCRBanks  - 0x%08x\n", 
mTcgDxeData.BsCap.NumberOfPCRBanks));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2.ActivePcrBanks- 0x%08x\n", 
mTcgDxeData.BsCap.ActivePcrBanks));
 
   if (mTcgDxeData.BsCap.TPMPresentFlag) {
 //
-- 
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 1/5] MdePkg: Revert AuditMode/DeployedMode name definition

2016-04-28 Thread El-Haj-Mahmoud, Samer
Series reviewed-by: Samer El-Haj-Mahmoud 


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang, 
Chao B
Sent: Thursday, April 28, 2016 2:46 AM
To: edk2-devel@lists.01.org
Cc: siyuan...@intel.com; Chao Zhang ; 
star.z...@intel.com
Subject: [edk2] [PATCH 1/5] MdePkg: Revert AuditMode/DeployedMode name 
definition

Revert AuditMode/DeployedMode definition from Customized Secure Boot feature 
defined in UEFI2.5 Mantis 1263.
The feature has been moved to
  https://github.com/tianocore/edk2-staging/tree/Customized-Secure-Boot
Previous check-in hash is
  SHA-1: 79e7b6472797f156d1ff28f3022b25d9c6f250f9

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang 
---
 MdePkg/Include/Guid/GlobalVariable.h  | 16 +---
 MdePkg/Include/Guid/ImageAuthentication.h | 15 ++-
 2 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/MdePkg/Include/Guid/GlobalVariable.h 
b/MdePkg/Include/Guid/GlobalVariable.h
index e58f7a1..0804236 100644
--- a/MdePkg/Include/Guid/GlobalVariable.h
+++ b/MdePkg/Include/Guid/GlobalVariable.h
@@ -1,7 +1,7 @@
 /** @file
   GUID for EFI (NVRAM) Variables.
 
-  Copyright (c) 2006 - 2015, 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
@@ -126,20 +126,6 @@ extern EFI_GUID gEfiGlobalVariableGuid;  ///
 #define EFI_SETUP_MODE_NAME L"SetupMode"
 ///
-/// Whether the system is operating in audit mode (1) or not (0).
-/// All other values are reserved. Should be treated as read-only except when 
DeployedMode is 0.
-/// Always becomes read-only after ExitBootServices() is called.
-/// Its attribute is BS+RT.
-///
-#define EFI_AUDIT_MODE_NAME L"AuditMode"
-///
-/// Whether the system is operating in deployed mode (1) or not (0).
-/// All other values are reserved. Should be treated as read-only when its 
value is 1.
-/// Always becomes read-only after ExitBootServices() is called.
-/// Its attribute is BS+RT.
-///
-#define EFI_DEPLOYED_MODE_NAME  L"DeployedMode"
-///
 /// The Key Exchange Key Signature Database.
 /// Its attribute is NV+BS+RT+AT.
 ///
diff --git a/MdePkg/Include/Guid/ImageAuthentication.h 
b/MdePkg/Include/Guid/ImageAuthentication.h
index c733643..3b3b7b5 100644
--- a/MdePkg/Include/Guid/ImageAuthentication.h
+++ b/MdePkg/Include/Guid/ImageAuthentication.h
@@ -1,7 +1,7 @@
 /** @file
   Image signature database are defined for the signed image validation.
 
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 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 @@ -43,20 +43,9 @@
 
 #define SECURE_BOOT_MODE_ENABLE   1
 #define SECURE_BOOT_MODE_DISABLE  0
-///
-/// Depricated value definition for SetupMode variable -///
+
 #define SETUP_MODE1
 #define USER_MODE 0
-///
-/// Value definition for SetupMode/DeployedMode/AuditMode variable -///
-#define SETUP_MODE_ENABLE 1
-#define SETUP_MODE_DISABLE0
-#define DEPLOYED_MODE_ENABLE  1
-#define DEPLOYED_MODE_DISABLE 0
-#define AUDIT_MODE_ENABLE 1
-#define AUDIT_MODE_DISABLE0
 
 //***
 // Signature Database
--
1.9.5.msysgit.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 0/2] Report ACPI NFIT for reserved memory RAM disks

2016-04-28 Thread El-Haj-Mahmoud, Samer
Hao,

One issue with this approach is that BDS may be downloading ISO images (from 
HTTP Boot options) and generating RAMDisks (of type Reserved memory) *AFTER* 
ReadyToBoot is signaled (after first unsuccessful BDS boot attempt). Also, the 
user may do this using Shell tools from the Shell (also after ReadyToBoot).

Is it possible to keep track of Reserved memory RAMDisks that are created using 
the protocol after ReadyToBoot, then add them to the NFIT table? You still need 
this patch for the initial RAMDisk NFIT Table (and ACPI space) creation at 
ReadyToBoot

Thanks,
--Samer

-Original Message-
From: Hao Wu [mailto:hao.a...@intel.com] 
Sent: Thursday, April 28, 2016 12:08 AM
To: edk2-devel@lists.01.org; feng.t...@intel.com; El-Haj-Mahmoud, Samer 
; jiewen@intel.com
Cc: Hao Wu 
Subject: [PATCH v3 0/2] Report ACPI NFIT for reserved memory RAM disks

Changes compared with V2:
1. RamDiskDxe driver now will register an EFI event in the Ready To Boot
   Event Group to a). detect whether EFI_ACPI_TABLE_PROTOCOL and
   EFI_ACPI_SDT_PROTOCOL are both produced; b). publish all the reserved
   memory type RAM disks registered at this point to the NFIT if both
   protocols are produced.

2. The RamDiskUnpublishNfit() now will uninstall NFIT and SSDT that is
   used to report the NVDIMM root device from the ACPI table when there is
   no NFIT structure in NFIT after removing a RAM disk.

3. Instead of adding a new rule in OvmfPkg FDF files, the patch now lists
   the asl and aml options in the main [Rule.Common.DXE_DRIVER] field.


Changes compared with V1:
1. Instead of creating a new NFIT for each registered reserved memory RAM
   disk, new cotent of the NFIT is appended to the existing one.

2. Report an NVDIMM root device in the \SB scope if there is no NFIT in
   the ACPI table.

3. Modify FDF files in OvmfPkg to make sure the report of the NVDIMM root
   device will be done correctly.


Hao Wu (2):
  MdeModulePkg RamDiskDxe: Report ACPI NFIT for reserved memory RAM
disks
  OvmfPkg: Modify fdf files due to RamDiskDxe driver's adding ASL code

 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDisk.asl |  44 ++
 .../Universal/Disk/RamDiskDxe/RamDiskDriver.c  |  80 
 .../Universal/Disk/RamDiskDxe/RamDiskDxe.inf   |  12 +
 .../Universal/Disk/RamDiskDxe/RamDiskImpl.h|  28 ++
 .../Universal/Disk/RamDiskDxe/RamDiskProtocol.c| 494 +
 OvmfPkg/OvmfPkgIa32.fdf|   2 +
 OvmfPkg/OvmfPkgIa32X64.fdf |   2 +
 OvmfPkg/OvmfPkgX64.fdf |   2 +
 8 files changed, 664 insertions(+)
 create mode 100644 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDisk.asl

-- 
1.9.5.msysgit.0

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


[edk2] [PATCH] SecurityPkg: Reduce TPM debug verbosity

2016-04-28 Thread Samer El-Haj-Mahmoud
Reduce several DEBUG messages verbosity in TPM, especially when no TPM
HW is present

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
---
 SecurityPkg/Tcg/TcgPei/TcgPei.c   |  3 ++-
 SecurityPkg/Tcg/TcgSmm/TcgSmm.c   |  3 ++-
 SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c | 43 ---
 SecurityPkg/Tcg/TrEEPei/TrEEPei.c |  5 +++--
 4 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index 25724a6..69eb728 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -2,6 +2,7 @@
   Initialize TPM device and measure FVs before handing off control to DXE.
 
 Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials 
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at 
@@ -753,7 +754,7 @@ PeimEntryMA (
   EFI_BOOT_MODE BootMode;
 
   if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), 
&gEfiTpmDeviceInstanceTpm12Guid)){
-DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n"));
+DEBUG ((EFI_D_INFO, "No TPM12 instance required!\n"));
 return EFI_UNSUPPORTED;
   }
 
diff --git a/SecurityPkg/Tcg/TcgSmm/TcgSmm.c b/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
index 96fb456..981db1c 100644
--- a/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
+++ b/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
@@ -9,6 +9,7 @@
   PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted 
input and do some check.
 
 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials 
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at 
@@ -426,7 +427,7 @@ InitializeTcgSmm (
   EFI_HANDLE SwHandle;
 
   if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), 
&gEfiTpmDeviceInstanceTpm12Guid)){
-DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n"));
+DEBUG ((EFI_D_INFO, "No TPM12 instance required!\n"));
 return EFI_UNSUPPORTED;
   }
 
diff --git a/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c 
b/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c
index dfdee04..f93c6d2 100644
--- a/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c
+++ b/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c
@@ -2,6 +2,7 @@
   This module implements TrEE Protocol.
   
 Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials 
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at 
@@ -212,7 +213,7 @@ InternalDumpData (
 {
   UINTN  Index;
   for (Index = 0; Index < Size; Index++) {
-DEBUG ((EFI_D_INFO, "%02x", (UINTN)Data[Index]));
+DEBUG ((DEBUG_VERBOSE, "%02x", (UINTN)Data[Index]));
   }
 }
 
@@ -239,15 +240,15 @@ InternalDumpHex (
   Count = Size / COLUME_SIZE;
   Left  = Size % COLUME_SIZE;
   for (Index = 0; Index < Count; Index++) {
-DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE));
+DEBUG ((DEBUG_VERBOSE, "%04x: ", Index * COLUME_SIZE));
 InternalDumpData (Data + Index * COLUME_SIZE, COLUME_SIZE);
-DEBUG ((EFI_D_INFO, "\n"));
+DEBUG ((DEBUG_VERBOSE, "\n"));
   }
 
   if (Left != 0) {
-DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE));
+DEBUG ((DEBUG_VERBOSE, "%04x: ", Index * COLUME_SIZE));
 InternalDumpData (Data + Index * COLUME_SIZE, Left);
-DEBUG ((EFI_D_INFO, "\n"));
+DEBUG ((DEBUG_VERBOSE, "\n"));
   }
 }
 
@@ -392,21 +393,21 @@ DumpEventLog (
   TCG_PCR_EVENT_HDR *EventHdr;
   UINTN Index;
 
-  DEBUG ((EFI_D_INFO, "EventLogFormat: (0x%x)\n", EventLogFormat));
+  DEBUG ((DEBUG_VERBOSE, "EventLogFormat: (0x%x)\n", EventLogFormat));
   
   switch (EventLogFormat) {
   case TREE_EVENT_LOG_FORMAT_TCG_1_2:
 EventHdr = (TCG_PCR_EVENT_HDR *)(UINTN)EventLogLocation;
 while ((UINTN)EventHdr <= EventLogLastEntry) {
-  DEBUG ((EFI_D_INFO, "  Event:\n"));
-  DEBUG ((EFI_D_INFO, "PCRIndex  - %d\n", EventHdr->PCRIndex));
-  DEBUG ((EFI_D_INFO, "EventType - 0x%08x\n", EventHdr->EventType));
-  DEBUG ((EFI_D_INFO, "Digest- "));
+  DEBUG ((DEBUG_VERBOSE, "  Event:\n"));
+  DEBUG ((DEBUG_VERBOSE, "PCRIndex  - %d\n", EventHdr->PCRIndex));
+  DEBUG ((DEBUG_VERBOSE, "EventType - 0x%08x\n", EventHdr->EventType));
+  DEBUG ((DEBUG_VERBOSE, "Digest- "));
   for (Index = 0; Index < sizeof(TCG_DIGEST); Index++) {
-DEBUG ((EFI_D_INFO, "%02x ", EventHdr->Digest.digest[Index]));
+DEBUG ((DEBUG_VE

[edk2] Security Issues for Tianocore

2016-04-28 Thread Mangefeste, Tony
I'm working on refining how the community handles security issues found in 
Tianocore.  Expect an update soon(tm), however, in the meantime, please refer 
to the update on our portal at: http://tianocore.org/security.

The TL;DR we're asking all security issues discovered in Tianocore be reported 
to the UEFI USRT as a stop-gap measure.  Issues should not be reported through 
any other unencrypted, insecure mechanism.

I'll be discussing our process with the UEFI USRT next week. 

***do not send further emails on tianocore-secur...@lists.sourceforge.net***

---
Tony Mangefeste
Intel Corporation
STO/SMC
Community Technology Lead
Tianocore Community Manager
g+: https://goo.gl/l5B5JH
t: @tonymangefeste



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


Re: [edk2] [PATCH] SecurityPkg: Add DEBUG messages for TPM2Startup

2016-04-28 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Samer El-Haj-Mahmoud
> Sent: Friday, April 29, 2016 4:04 AM
> To: edk2-devel@lists.01.org
> Cc: Samer El-Haj-Mahmoud ; Zhang, Chao B
> 
> Subject: [edk2] [PATCH] SecurityPkg: Add DEBUG messages for TPM2Startup
> 
> Add DEBUG messages for TPM2Startup to distinguish between
> TPM_RC_SUCCESS
> and TPM_RC_INITIALIZE. This helps debugging some hardware problems.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Samer El-Haj-Mahmoud 
> ---
>  SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
> b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
> index f67043b..dc2c562 100644
> --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
> +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
> @@ -2,6 +2,7 @@
>Implement TPM2 Startup related command.
> 
>  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. 
> +(C) Copyright 2016 Hewlett Packard Enterprise Development LP
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -75,8 +76,11 @@ Tpm2Startup (
>ResponseCode = SwapBytes32(Res.Header.responseCode);
>switch (ResponseCode)  {
>case TPM_RC_SUCCESS:
> +DEBUG ((DEBUG_INFO, "TPM2Startup: TPM_RC_SUCCESS\n"));
> +return EFI_SUCCESS;
>case TPM_RC_INITIALIZE:
>  // TPM_RC_INITIALIZE can be returned if Tpm2Startup is not required.
> +DEBUG ((DEBUG_INFO, "TPM2Startup: TPM_RC_INITIALIZE\n"));
>  return EFI_SUCCESS;
>default:
>  DEBUG ((EFI_D_ERROR, "Tpm2Startup: Response Code error!
> 0x%08x\r\n", ResponseCode));
> --
> 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 v3 0/2] Report ACPI NFIT for reserved memory RAM disks

2016-04-28 Thread Wu, Hao A
Hi Samer,

Sorry for not making it clear in the patch cover letter. For this version
of patch, the RamDiskDxe driver still reports reserved memory type RAM
disks to NFIT after the 'ready to boot' event.

Changes comparing to V2 of the patch is adding a check for whether
EFI_ACPI_TABLE_PROTOCOL and EFI_ACPI_SDT_PROTOCOL are both produced at the
point when the 'ready to boot' event is signaled. By that time, all
protocols that going to be produced should be ready. So if either protocol
is missing, the driver will not try to report RAM disks to NFIT afterwards.

The purpose of this change is to make sure reserved memory type RAM disks
registered before EFI_ACPI_TABLE_PROTOCOL and EFI_ACPI_SDT_PROTOCOL are
ready can be reported to NFIT.

Best Regards,
Hao Wu

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of El-
> Haj-Mahmoud, Samer
> Sent: Friday, April 29, 2016 4:59 AM
> To: Wu, Hao A; edk2-devel@lists.01.org; Tian, Feng; Yao, Jiewen
> Subject: Re: [edk2] [PATCH v3 0/2] Report ACPI NFIT for reserved memory RAM
> disks
> 
> Hao,
> 
> One issue with this approach is that BDS may be downloading ISO images (from
> HTTP Boot options) and generating RAMDisks (of type Reserved memory)
> *AFTER* ReadyToBoot is signaled (after first unsuccessful BDS boot attempt).
> Also, the user may do this using Shell tools from the Shell (also after
> ReadyToBoot).
> 
> Is it possible to keep track of Reserved memory RAMDisks that are created
> using the protocol after ReadyToBoot, then add them to the NFIT table? You
> still need this patch for the initial RAMDisk NFIT Table (and ACPI space)
> creation at ReadyToBoot
> 
> Thanks,
> --Samer
> 
> -Original Message-
> From: Hao Wu [mailto:hao.a...@intel.com]
> Sent: Thursday, April 28, 2016 12:08 AM
> To: edk2-devel@lists.01.org; feng.t...@intel.com; El-Haj-Mahmoud, Samer
> ; jiewen@intel.com
> Cc: Hao Wu 
> Subject: [PATCH v3 0/2] Report ACPI NFIT for reserved memory RAM disks
> 
> Changes compared with V2:
> 1. RamDiskDxe driver now will register an EFI event in the Ready To Boot
>Event Group to a). detect whether EFI_ACPI_TABLE_PROTOCOL and
>EFI_ACPI_SDT_PROTOCOL are both produced; b). publish all the reserved
>memory type RAM disks registered at this point to the NFIT if both
>protocols are produced.
> 
> 2. The RamDiskUnpublishNfit() now will uninstall NFIT and SSDT that is
>used to report the NVDIMM root device from the ACPI table when there is
>no NFIT structure in NFIT after removing a RAM disk.
> 
> 3. Instead of adding a new rule in OvmfPkg FDF files, the patch now lists
>the asl and aml options in the main [Rule.Common.DXE_DRIVER] field.
> 
> 
> Changes compared with V1:
> 1. Instead of creating a new NFIT for each registered reserved memory RAM
>disk, new cotent of the NFIT is appended to the existing one.
> 
> 2. Report an NVDIMM root device in the \SB scope if there is no NFIT in
>the ACPI table.
> 
> 3. Modify FDF files in OvmfPkg to make sure the report of the NVDIMM root
>device will be done correctly.
> 
> 
> Hao Wu (2):
>   MdeModulePkg RamDiskDxe: Report ACPI NFIT for reserved memory RAM
> disks
>   OvmfPkg: Modify fdf files due to RamDiskDxe driver's adding ASL code
> 
>  MdeModulePkg/Universal/Disk/RamDiskDxe/RamDisk.asl |  44 ++
>  .../Universal/Disk/RamDiskDxe/RamDiskDriver.c  |  80 
>  .../Universal/Disk/RamDiskDxe/RamDiskDxe.inf   |  12 +
>  .../Universal/Disk/RamDiskDxe/RamDiskImpl.h|  28 ++
>  .../Universal/Disk/RamDiskDxe/RamDiskProtocol.c| 494
> +
>  OvmfPkg/OvmfPkgIa32.fdf|   2 +
>  OvmfPkg/OvmfPkgIa32X64.fdf |   2 +
>  OvmfPkg/OvmfPkgX64.fdf |   2 +
>  8 files changed, 664 insertions(+)
>  create mode 100644 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDisk.asl
> 
> --
> 1.9.5.msysgit.0
> 
> ___
> 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] [staging/HTTPs-TLS] merge from tianocore master

2016-04-28 Thread Wu, Jiaxin
Yeah, we did some updates for HttpDxe driver in edk2 trunk this day,  which is 
conflicted with current HTTPS implementation.

I'm working on the merging work for this conflicts. But we need to sync 
edk2-staging/master with edk2/master first. 


Thanks.
Jiaxin

> -Original Message-
> From: El-Haj-Mahmoud, Samer [mailto:samer.el-haj-mahm...@hpe.com]
> Sent: Friday, April 29, 2016 2:25 AM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Subject: [staging/HTTPs-TLS] merge from tianocore master
> 
> Jiaxin,
> 
> Can you please merge this revision into the edk2-staging/HTTPS-TLS branch,
> since it conflicts with the TLS code?
> 
> Thanks,
> --Samer
> 
> 
> Revision: 20667
> Author: edk2buildsystem
> Date: Thursday, April 28, 2016 4:05:33 AM
> Message:
> NetworkPkg: Avoid the indefinite wait case in HttpDxe
> 
> Need the timer check to avoid the indefinite wait case in HttpDxe driver
> A.HTTP receive Header process in HttpTcpReceiveHeader(); B.HTTP receive
> Body process in HttpTcpReceiveBody();
> 
> Cc: Hegde Nagaraj P 
> Cc: El-Haj-Mahmoud Samer 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Zhang Lubo 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiaxin Wu 
> Reviewed-by: Hegde Nagaraj P 
> Reviewed-by: Fu Siyuan  (cherry picked from commit
> b347a22aecbfac9aac47831fee9a30aa810d6d0b)
> 

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


[edk2] [RFC] MdeModulePkg, ShellPkg: increase TFTP block size

2016-04-28 Thread Marcin Wojtas
From: Bartosz Szczepanek 

Hi,

When dealing with low network speed during tftp, the analysis showed
two issues - UEFI tftp and network stack spend a lot of time (~3.5ms,
comparing to U-Boot's ~0.6ms) on preparing ACK packet after receiving
data block from host. The network driver itself is using SNP and its
time spent on executing SnpTransmit routine is negligible, so it is
definitely not a problem.

This patch however is only releated to above mentioned problem. It
occurred that despite our MTU is set to 1500, each block of data has
to be split to 512 chunks, so the very long receive/ack sequence was
executed three times more than needed.

Below is an example of a solution of increasing TFTP block size
to maximum allowed by 1500 MTU. The default block size is changed,
as well as this option is negotiatied with host. For sure a situation,
when proposed, increased block size is rejected by host (a default
fall back to 512 should happen) should be handled properly.

Also a dynamic dependency between port's MTU was considered, but there
are two problems - how to pass it to Mtftp4 module and way of negotiating
size with host - option requires string format. Hence IMO it's better
to stick to arbitrary size.

I would be very grateful for any comments and ideas, how to handle
this issue properly.

Best reards,
Marcin

---
 MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h | 2 +-
 ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c   | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h 
b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
index 527fd1d..9a2d409 100644
--- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
+++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
@@ -55,7 +55,7 @@ typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
 #define MTFTP4_DEFAULT_SERVER_PORT  69
 #define MTFTP4_DEFAULT_TIMEOUT  3
 #define MTFTP4_DEFAULT_RETRY5
-#define MTFTP4_DEFAULT_BLKSIZE  512
+#define MTFTP4_DEFAULT_BLKSIZE  1468
 #define MTFTP4_TIME_TO_GETMAP   5
 
 #define MTFTP4_STATE_UNCONFIGED 0
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c 
b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
index 831b9c3..3e06b67 100644
--- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
+++ b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
@@ -894,12 +894,17 @@ DownloadFile (
   TftpContext->DownloadedNbOfBytes   = 0;
   TftpContext->LastReportedNbOfBytes = 0;
 
+  UINT8 name[] = "blksize";
+  UINT8 val[] = "1468";
+  EFI_MTFTP4_OPTION Blksize = { name, val };
   ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN));
   Mtftp4Token.Filename= (UINT8*)AsciiFilePath;
   Mtftp4Token.BufferSize  = FileSize;
   Mtftp4Token.Buffer  = Buffer;
   Mtftp4Token.CheckPacket = CheckPacket;
   Mtftp4Token.Context = (VOID*)TftpContext;
+  Mtftp4Token.OptionCount = 1;
+  Mtftp4Token.OptionList = &Blksize;
 
   ShellPrintHiiEx (
 -1, -1, NULL, STRING_TOKEN (STR_TFTP_DOWNLOADING),
-- 
1.8.3.1

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


Re: [edk2] [PATCH v3 2/2] OvmfPkg: Modify fdf files due to RamDiskDxe driver's adding ASL code

2016-04-28 Thread Wu, Hao A
> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Thursday, April 28, 2016 7:31 PM
> To: Wu, Hao A; edk2-de...@ml01.01.org; Tian, Feng; samer.el-haj-
> mahm...@hpe.com; Yao, Jiewen
> Cc: Justen, Jordan L
> Subject: Re: [PATCH v3 2/2] OvmfPkg: Modify fdf files due to RamDiskDxe
> driver's adding ASL code
> 
> On 04/28/16 07:08, Hao Wu wrote:
> > The RamDiskDxe driver in MdeModulePkg now will sometimes report a
> NVDIMM
> > Root Device using ASL code which is put in a Secondary System Description
> > Table (SSDT) according to the ACPI 6.1 spec.
> >
> > Locating the SSDT requires modifying the fdf files in OvmfPkg.
> >
> > Cc: Laszlo Ersek 
> > Cc: Jordan Justen 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Hao Wu 
> > ---
> >  OvmfPkg/OvmfPkgIa32.fdf| 2 ++
> >  OvmfPkg/OvmfPkgIa32X64.fdf | 2 ++
> >  OvmfPkg/OvmfPkgX64.fdf | 2 ++
> >  3 files changed, 6 insertions(+)
> >
> > diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
> > index 93a51a5..287737c 100644
> > --- a/OvmfPkg/OvmfPkgIa32.fdf
> > +++ b/OvmfPkg/OvmfPkgIa32.fdf
> > @@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-
> E77F1DB2D792 {
> >  PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
> >  UI   STRING="$(MODULE_NAME)" Optional
> >  VERSION  STRING="$(INF_VERSION)" Optional
> BUILD_NUM=$(BUILD_NUMBER)
> > +RAW ACPI  Optional   |.acpi
> > +RAW ASL   Optional   |.aml
> >}
> >
> >  [Rule.Common.DXE_RUNTIME_DRIVER]
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
> > index aad16a6..cc1587a 100644
> > --- a/OvmfPkg/OvmfPkgIa32X64.fdf
> > +++ b/OvmfPkg/OvmfPkgIa32X64.fdf
> > @@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-
> E77F1DB2D792 {
> >  PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
> >  UI   STRING="$(MODULE_NAME)" Optional
> >  VERSION  STRING="$(INF_VERSION)" Optional
> BUILD_NUM=$(BUILD_NUMBER)
> > +RAW ACPI  Optional   |.acpi
> > +RAW ASL   Optional   |.aml
> >}
> >
> >  [Rule.Common.DXE_RUNTIME_DRIVER]
> > diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
> > index 387b808..1b52381 100644
> > --- a/OvmfPkg/OvmfPkgX64.fdf
> > +++ b/OvmfPkg/OvmfPkgX64.fdf
> > @@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-
> E77F1DB2D792 {
> >  PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
> >  UI   STRING="$(MODULE_NAME)" Optional
> >  VERSION  STRING="$(INF_VERSION)" Optional
> BUILD_NUM=$(BUILD_NUMBER)
> > +RAW ACPI  Optional   |.acpi
> > +RAW ASL   Optional   |.aml
> >}
> >
> >  [Rule.Common.DXE_RUNTIME_DRIVER]
> >
> 
> I guess I can ACK this, but what about my other comment, namely setting
> PcdInstallAcpiSdtProtocol to TRUE in the OVMF DSC files?
> 

Sorry for missing the above comment. Yes, I will send out a new version of
patch to set the pcd PcdInstallAcpiSdtProtocol to TRUE in OVMF DSC files.

Best Regards,
Hao Wu

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


[edk2] [staging/HTTPS-TLS][PATCH] CryptoPkg: Fix ssl build error.

2016-04-28 Thread Jiaxin Wu
This patch is used to fix ssl unresolved external build error.

Cc: Samer El-Haj-Mahmoud 
Cc: Thomas Palmer 
Cc: Long Qin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c 
b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
index c0ccc0e..a2386bc 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
@@ -382,10 +382,15 @@ FILE *fopen (const char *c, const char *m)
 size_t fread (void *b, size_t c, size_t i, FILE *f)
 {
   return 0;
 }
 
+int fputs (const char *s, FILE *f)
+{
+  return 0;
+}
+
 int fprintf (FILE *f, const char *s, ...)
 {
   return 0;
 }
 
@@ -446,5 +451,10 @@ void syslog (int a, const char *c, ...)
 
 ssize_t write (int f, const void *b, size_t l)
 {
   return 0;
 }
+
+int printf (char const *fmt, ...)
+{
+  return 0;
+}
-- 
1.9.5.msysgit.1

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


[edk2] [patch] Nt32Pkg: Fix SnpNt32 GetStatus bug

2016-04-28 Thread Zhang Lubo
According to UEFI spec, the Snp.GetStatus should
return the recycled transmit buffer address, while
the NT32 SNP always return value 1 for the Txbuffer.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 Nt32Pkg/SnpNt32Dxe/SnpNt32.c | 42 --
 Nt32Pkg/SnpNt32Dxe/SnpNt32.h | 22 +-
 2 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
index 4dee182..6d22c2f 100644
--- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
+++ b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
@@ -1,8 +1,8 @@
 /** @file
 
-Copyright (c) 2006 - 2013, 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
 http://opensource.org/licenses/bsd-license.php
 
@@ -42,10 +42,13 @@ SNPNT32_GLOBAL_DATA gSnpNt32GlobalData = {
   {
 0,
 0,
 EfiLockUninitialized
   },  //  Lock
+  NULL,   //  RecycledTxBuf
+  0,  //  RecycledTxBufCount
+  32, //  MaxRecycledTxBuf
   //
   //  Private functions
   //
   SnpNt32InitializeGlobalData,//  InitializeGlobalData
   SnpNt32InitializeInstanceData,  //  InitializeInstanceData
@@ -859,13 +862,24 @@ SnpNt32GetStatus (
   IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
   OUT UINT32 *InterruptStatus,
   OUT VOID   **TxBuffer
   )
 {
+  SNPNT32_INSTANCE_DATA *Instance;
+  SNPNT32_GLOBAL_DATA   *GlobalData;
+
+  Instance= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
+
+  GlobalData  = Instance->GlobalData;
 
   if (TxBuffer != NULL) {
-*((UINT8 **) TxBuffer) = (UINT8 *)(UINTN) 1;
+if (GlobalData->RecycledTxBufCount != 0) {
+  GlobalData->RecycledTxBufCount --;
+  *((UINT8 **) TxBuffer)= (UINT8 *) 
(UINTN)GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount];
+} else {
+  *((UINT8 **) TxBuffer)= NULL;
+}
   }
 
   if (InterruptStatus != NULL) {
 *InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
   }
@@ -916,10 +930,11 @@ SnpNt32Transmit (
   )
 {
   SNPNT32_INSTANCE_DATA *Instance;
   SNPNT32_GLOBAL_DATA   *GlobalData;
   INT32 ReturnValue;
+  UINT64*Tmp;
 
   Instance= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
 
   GlobalData  = Instance->GlobalData;
 
@@ -943,10 +958,28 @@ SnpNt32Transmit (
 
   EfiReleaseLock (&GlobalData->Lock);
 
   if (ReturnValue < 0) {
 return EFI_DEVICE_ERROR;
+  } else {
+if ((GlobalData->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT) >= 
SNP_MAX_TX_BUFFER_NUM) {
+  return EFI_NOT_READY;
+}
+
+if (GlobalData->RecycledTxBufCount < GlobalData->MaxRecycledTxBuf) {
+  GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount] = (UINT64) 
Buffer;
+  GlobalData->RecycledTxBufCount ++;
+} else {
+  Tmp = AllocatePool (sizeof (UINT64) * (GlobalData->MaxRecycledTxBuf + 
SNP_TX_BUFFER_INCREASEMENT));
+  if (Tmp == NULL) {
+return EFI_DEVICE_ERROR;
+  }
+  CopyMem (Tmp, GlobalData->RecycledTxBuf, sizeof (UINT64) * 
GlobalData->RecycledTxBufCount);
+  FreePool (GlobalData->RecycledTxBuf);
+  GlobalData->RecycledTxBuf=  Tmp;
+  GlobalData->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT;
+}
   }
 
   return EFI_SUCCESS;
 }
 
@@ -1081,10 +1114,15 @@ SnpNt32InitializeGlobalData (
   InterfaceCount= MAX_INTERFACE_INFO_NUMBER;
 
   InitializeListHead (&This->InstanceList);
   EfiInitializeLock (&This->Lock, TPL_CALLBACK);
 
+  This->RecycledTxBuf = AllocatePool (sizeof (UINT64) * MAX_XMIT_BUFFERS);
+  if (This->RecycledTxBuf == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
   //
   //  Get the WinNT thunk
   //
   Status = gBS->LocateProtocol (&gEfiWinNtThunkProtocolGuid, NULL, (VOID 
**)&This->WinNtThunk);
 
diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.h b/Nt32Pkg/SnpNt32Dxe/SnpNt32.h
index 07f6129..cb95c57 100644
--- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.h
+++ b/Nt32Pkg/SnpNt32Dxe/SnpNt32.h
@@ -1,8 +1,8 @@
 /** @file
 
-Copyright (c) 2006 - 2007, 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
 http://opensource.org/licenses/bsd-license.php
 
@@ -56,10 +56,16 @@ typedef struct _NT_NET_INTERFACE_INFO {
 #define NET_ETHER_HEADER_SIZE 14
 
 #define MAX_INTERFACE_INFO_NUMBER 16
 #define MAX_FILE_NAME_LENGTH  280
 
+#define SNP_MAX_TX_BUFFER_NUM 65536
+#define SNP_TX_B

Re: [edk2] [PATCH] SecurityPkg: Fix TPM 1.2 NV Storage Command Size byte order

2016-04-28 Thread Lin, Derek (HPS UEFI Dev)
This patch has been sent and reviewed month ago, but not committed.

-Original Message-
From: El-Haj-Mahmoud, Samer 
Sent: Friday, April 29, 2016 4:24 AM
To: edk2-devel@lists.01.org
Cc: chao.b.zh...@intel.com; El-Haj-Mahmoud, Samer 
; El-Haj-Mahmoud, Samer 
; Lin, Derek (HPS UEFI Dev) 
Subject: [PATCH] SecurityPkg: Fix TPM 1.2 NV Storage Command Size byte order

Fix Tpm12NvWriteValue() command/response length byte order.
Tpm12SubmitCommand() was using the value from Command.Hdr.paramSize which was 
swapped to be Big Endian, but the function was expecting it in UINT32 Little 
Endian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
index 7baafa8..e176b00 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 NV storage related command.
 
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -199,8 +200,9 @@ 
Tpm12NvWriteValue (  {
   EFI_STATUS  Status;
   TPM_CMD_NV_WRITE_VALUE  Command;
+  UINT32  CommandLength;
   TPM_RSP_COMMAND_HDR Response;
-  UINT32  Length;
+  UINT32  ResponseLength;
 
   if (DataSize > sizeof (Command.Data)) {
 return EFI_UNSUPPORTED;
@@ -210,14 +212,15 @@ Tpm12NvWriteValue (
   // send Tpm command TPM_ORD_NV_WriteValue
   //
   Command.Hdr.tag   = SwapBytes16 (TPM_TAG_RQU_COMMAND);
-  Command.Hdr.paramSize = SwapBytes32 (sizeof (Command) - sizeof(Command.Data) 
+ DataSize);
+  CommandLength = sizeof (Command) - sizeof(Command.Data) + DataSize;  
+ Command.Hdr.paramSize = SwapBytes32 (CommandLength);
   Command.Hdr.ordinal   = SwapBytes32 (TPM_ORD_NV_WriteValue);
   Command.NvIndex   = SwapBytes32 (NvIndex);
   Command.Offset= SwapBytes32 (Offset);
   Command.DataSize  = SwapBytes32 (DataSize);
   CopyMem (Command.Data, Data, DataSize);
-  Length = sizeof (Response);
-  Status = Tpm12SubmitCommand (Command.Hdr.paramSize, (UINT8 *)&Command, 
&Length, (UINT8 *)&Response);
+  ResponseLength = sizeof (Response);
+  Status = Tpm12SubmitCommand (CommandLength, (UINT8 *)&Command, 
+ &ResponseLength, (UINT8 *)&Response);
   if (EFI_ERROR (Status)) {
 return Status;
   }
--
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] SecurityPkg: Fix bug in TPM 1.2 SelfTest

2016-04-28 Thread Lin, Derek (HPS UEFI Dev)

This has been sent and reviewed, but not committed yet.

From: El-Haj-Mahmoud, Samer
Sent: Friday, April 29, 2016 4:29:27 AM
To: edk2-devel@lists.01.org
Cc: chao.b.zh...@intel.com; El-Haj-Mahmoud, Samer; El-Haj-Mahmoud, Samer; Lin, 
Derek (HPS UEFI Dev)
Subject: [PATCH] SecurityPkg: Fix bug in TPM 1.2 SelfTest

Fix uninitialized command Length variable in TPM1.2 Self Test command

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
index cd08d19..8e232ee 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 NV Self Test related commands.

 Copyright (c) 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -42,5 +43,6 @@ Tpm12ContinueSelfTest (
   Command.tag   = SwapBytes16 (TPM_TAG_RQU_COMMAND);
   Command.paramSize = SwapBytes32 (sizeof (Command));
   Command.ordinal   = SwapBytes32 (TPM_ORD_ContinueSelfTest);
+  Length = sizeof (Response);
   return Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, 
(UINT8 *)&Response);
 }
--
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] Nt32Pkg: Fix SnpNt32 GetStatus bug

2016-04-28 Thread Fu, Siyuan
Hi, Lubo

The allocate memory in SnpNt32InitializeGlobalData is better to use 
AllocatePool (sizeof (UINT64) * This->MaxRecycledTxBuf);
to avoid possible macro value update in future.
Other parts are good to me.


Reviewed-by: Fu Siyuan 




> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Zhang Lubo
> Sent: Friday, April 29, 2016 9:50 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Wu,
> Jiaxin 
> Subject: [edk2] [patch] Nt32Pkg: Fix SnpNt32 GetStatus bug
> 
> According to UEFI spec, the Snp.GetStatus should
> return the recycled transmit buffer address, while
> the NT32 SNP always return value 1 for the Txbuffer.
> 
> Cc: Fu Siyuan 
> Cc: Ye Ting 
> Cc: Wu Jiaxin 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo 
> ---
>  Nt32Pkg/SnpNt32Dxe/SnpNt32.c | 42
> --
>  Nt32Pkg/SnpNt32Dxe/SnpNt32.h | 22 +-
>  2 files changed, 61 insertions(+), 3 deletions(-)
> 
> diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
> b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
> index 4dee182..6d22c2f 100644
> --- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
> +++ b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
> @@ -1,8 +1,8 @@
>  /** @file
> 
> -Copyright (c) 2006 - 2013, 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
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -42,10 +42,13 @@ SNPNT32_GLOBAL_DATA gSnpNt32GlobalData = {
>{
>  0,
>  0,
>  EfiLockUninitialized
>},  //  Lock
> +  NULL,   //  RecycledTxBuf
> +  0,  //  RecycledTxBufCount
> +  32, //  MaxRecycledTxBuf
>//
>//  Private functions
>//
>SnpNt32InitializeGlobalData,//  InitializeGlobalData
>SnpNt32InitializeInstanceData,  //  InitializeInstanceData
> @@ -859,13 +862,24 @@ SnpNt32GetStatus (
>IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
>OUT UINT32 *InterruptStatus,
>OUT VOID   **TxBuffer
>)
>  {
> +  SNPNT32_INSTANCE_DATA *Instance;
> +  SNPNT32_GLOBAL_DATA   *GlobalData;
> +
> +  Instance= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
> +
> +  GlobalData  = Instance->GlobalData;
> 
>if (TxBuffer != NULL) {
> -*((UINT8 **) TxBuffer) = (UINT8 *)(UINTN) 1;
> +if (GlobalData->RecycledTxBufCount != 0) {
> +  GlobalData->RecycledTxBufCount --;
> +  *((UINT8 **) TxBuffer)= (UINT8 *) (UINTN)GlobalData-
> >RecycledTxBuf[GlobalData->RecycledTxBufCount];
> +} else {
> +  *((UINT8 **) TxBuffer)= NULL;
> +}
>}
> 
>if (InterruptStatus != NULL) {
>  *InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
>}
> @@ -916,10 +930,11 @@ SnpNt32Transmit (
>)
>  {
>SNPNT32_INSTANCE_DATA *Instance;
>SNPNT32_GLOBAL_DATA   *GlobalData;
>INT32 ReturnValue;
> +  UINT64*Tmp;
> 
>Instance= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
> 
>GlobalData  = Instance->GlobalData;
> 
> @@ -943,10 +958,28 @@ SnpNt32Transmit (
> 
>EfiReleaseLock (&GlobalData->Lock);
> 
>if (ReturnValue < 0) {
>  return EFI_DEVICE_ERROR;
> +  } else {
> +if ((GlobalData->MaxRecycledTxBuf +
> SNP_TX_BUFFER_INCREASEMENT) >= SNP_MAX_TX_BUFFER_NUM) {
> +  return EFI_NOT_READY;
> +}
> +
> +if (GlobalData->RecycledTxBufCount < GlobalData->MaxRecycledTxBuf) {
> +  GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount] = (UINT64)
> Buffer;
> +  GlobalData->RecycledTxBufCount ++;
> +} else {
> +  Tmp = AllocatePool (sizeof (UINT64) * (GlobalData->MaxRecycledTxBuf +
> SNP_TX_BUFFER_INCREASEMENT));
> +  if (Tmp == NULL) {
> +return EFI_DEVICE_ERROR;
> +  }
> +  CopyMem (Tmp, GlobalData->RecycledTxBuf, sizeof (UINT64) *
> GlobalData->RecycledTxBufCount);
> +  FreePool (GlobalData->RecycledTxBuf);
> +  GlobalData->RecycledTxBuf=  Tmp;
> +  GlobalData->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT;
> +}
>}
> 
>return EFI_SUCCESS;
>  }
> 
> @@ -1081,10 +1114,15 @@ SnpNt32InitializeGlobalData (
>InterfaceCount= MAX_INTERFACE_INFO_NUMBER;
> 
>InitializeListHead (&This->InstanceList);
>EfiInitializeLock (&This->Lock, TPL_CALLBACK);
> 
> +  This->RecycledTxBuf = AllocatePool (sizeof (UINT64) *
> MAX_XMIT_BUFFERS);
> +  if (This->RecycledTxBuf == NULL) {
> +return EFI_OUT_OF_RESOURCES;
> +  }
> +
>//
>//  Get the WinNT thunk
>//
>Status = gBS->LocateProtocol (&gEfiWinNtThunkProtocolGuid, NULL, (VOID
> **)&This->WinNtThunk);
> 
> diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.h
> b/Nt

Re: [edk2] [patch] Nt32Pkg: Fix SnpNt32 GetStatus bug

2016-04-28 Thread Zhang, Lubo
A good comment to me, I will change it at the commit time, thanks 

-Original Message-
From: Fu, Siyuan 
Sent: Friday, April 29, 2016 10:04 AM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Ye, Ting ; Wu, Jiaxin 
Subject: RE: [edk2] [patch] Nt32Pkg: Fix SnpNt32 GetStatus bug

Hi, Lubo

The allocate memory in SnpNt32InitializeGlobalData is better to use 
AllocatePool (sizeof (UINT64) * This->MaxRecycledTxBuf); to avoid 
possible macro value update in future.
Other parts are good to me.


Reviewed-by: Fu Siyuan 




> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Zhang Lubo
> Sent: Friday, April 29, 2016 9:50 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; 
> Wu, Jiaxin 
> Subject: [edk2] [patch] Nt32Pkg: Fix SnpNt32 GetStatus bug
> 
> According to UEFI spec, the Snp.GetStatus should return the recycled 
> transmit buffer address, while the NT32 SNP always return value 1 for 
> the Txbuffer.
> 
> Cc: Fu Siyuan 
> Cc: Ye Ting 
> Cc: Wu Jiaxin 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo 
> ---
>  Nt32Pkg/SnpNt32Dxe/SnpNt32.c | 42
> --
>  Nt32Pkg/SnpNt32Dxe/SnpNt32.h | 22 +-
>  2 files changed, 61 insertions(+), 3 deletions(-)
> 
> diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c 
> b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c index 4dee182..6d22c2f 100644
> --- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
> +++ b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
> @@ -1,8 +1,8 @@
>  /** @file
> 
> -Copyright (c) 2006 - 2013, 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  http://opensource.org/licenses/bsd-license.php
> 
> @@ -42,10 +42,13 @@ SNPNT32_GLOBAL_DATA gSnpNt32GlobalData = {
>{
>  0,
>  0,
>  EfiLockUninitialized
>},  //  Lock
> +  NULL,   //  RecycledTxBuf
> +  0,  //  RecycledTxBufCount
> +  32, //  MaxRecycledTxBuf
>//
>//  Private functions
>//
>SnpNt32InitializeGlobalData,//  InitializeGlobalData
>SnpNt32InitializeInstanceData,  //  InitializeInstanceData
> @@ -859,13 +862,24 @@ SnpNt32GetStatus (
>IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
>OUT UINT32 *InterruptStatus,
>OUT VOID   **TxBuffer
>)
>  {
> +  SNPNT32_INSTANCE_DATA *Instance;
> +  SNPNT32_GLOBAL_DATA   *GlobalData;
> +
> +  Instance= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
> +
> +  GlobalData  = Instance->GlobalData;
> 
>if (TxBuffer != NULL) {
> -*((UINT8 **) TxBuffer) = (UINT8 *)(UINTN) 1;
> +if (GlobalData->RecycledTxBufCount != 0) {
> +  GlobalData->RecycledTxBufCount --;
> +  *((UINT8 **) TxBuffer)= (UINT8 *) (UINTN)GlobalData-
> >RecycledTxBuf[GlobalData->RecycledTxBufCount];
> +} else {
> +  *((UINT8 **) TxBuffer)= NULL;
> +}
>}
> 
>if (InterruptStatus != NULL) {
>  *InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
>}
> @@ -916,10 +930,11 @@ SnpNt32Transmit (
>)
>  {
>SNPNT32_INSTANCE_DATA *Instance;
>SNPNT32_GLOBAL_DATA   *GlobalData;
>INT32 ReturnValue;
> +  UINT64*Tmp;
> 
>Instance= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
> 
>GlobalData  = Instance->GlobalData;
> 
> @@ -943,10 +958,28 @@ SnpNt32Transmit (
> 
>EfiReleaseLock (&GlobalData->Lock);
> 
>if (ReturnValue < 0) {
>  return EFI_DEVICE_ERROR;
> +  } else {
> +if ((GlobalData->MaxRecycledTxBuf +
> SNP_TX_BUFFER_INCREASEMENT) >= SNP_MAX_TX_BUFFER_NUM) {
> +  return EFI_NOT_READY;
> +}
> +
> +if (GlobalData->RecycledTxBufCount < GlobalData->MaxRecycledTxBuf) {
> +  GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount] = 
> + (UINT64)
> Buffer;
> +  GlobalData->RecycledTxBufCount ++;
> +} else {
> +  Tmp = AllocatePool (sizeof (UINT64) * 
> + (GlobalData->MaxRecycledTxBuf +
> SNP_TX_BUFFER_INCREASEMENT));
> +  if (Tmp == NULL) {
> +return EFI_DEVICE_ERROR;
> +  }
> +  CopyMem (Tmp, GlobalData->RecycledTxBuf, sizeof (UINT64) *
> GlobalData->RecycledTxBufCount);
> +  FreePool (GlobalData->RecycledTxBuf);
> +  GlobalData->RecycledTxBuf=  Tmp;
> +  GlobalData->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT;
> +}
>}
> 
>return EFI_SUCCESS;
>  }
> 
> @@ -1081,10 +1114,15 @@ SnpNt32InitializeGlobalData (
>InterfaceCount= MAX_INTERFACE_INFO_NUMBER;
> 
>InitializeListHead (&This->InstanceList);
>EfiInitializeLock (&This->Lock, TPL_CALLBACK);
> 
> +  This->RecycledTxBuf = AllocatePool (sizeof (UINT64) *
> M

[edk2] [PATCH v4 0/2] Report ACPI NFIT for reserved memory RAM disks

2016-04-28 Thread Hao Wu
Since the RamDiskDxe part in MdeModulePkg has not been changed, this
series only contains the patch for changes made in OvmfPkg.

Changes compared with V3:
1. Set Pcd 'PcdInstallAcpiSdtProtocol' to TURE in OVMF DSC files.

Changes compared with V2:
1. RamDiskDxe driver now will register an EFI event in the Ready To Boot
   Event Group to a). detect whether EFI_ACPI_TABLE_PROTOCOL and
   EFI_ACPI_SDT_PROTOCOL are both produced; b). publish all the reserved
   memory type RAM disks registered at this point to the NFIT if both
   protocols are produced.

2. The RamDiskUnpublishNfit() now will uninstall NFIT and SSDT that is
   used to report the NVDIMM root device from the ACPI table when there is
   no NFIT structure in NFIT after removing a RAM disk.

3. Instead of adding a new rule in OvmfPkg FDF files, the patch now lists
   the asl and aml options in the main [Rule.Common.DXE_DRIVER] field.


Changes compared with V1:
1. Instead of creating a new NFIT for each registered reserved memory RAM
   disk, new cotent of the NFIT is appended to the existing one.

2. Report an NVDIMM root device in the \SB scope if there is no NFIT in
   the ACPI table.

3. Modify FDF files in OvmfPkg to make sure the report of the NVDIMM root
   device will be done correctly.


Hao Wu (2):
  MdeModulePkg RamDiskDxe: Report ACPI NFIT for reserved memory RAM
disks
  OvmfPkg: Modify FDF/DSC files for RamDiskDxe's adding NFIT report
feature

 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDisk.asl |  44 ++
 .../Universal/Disk/RamDiskDxe/RamDiskDriver.c  |  80 
 .../Universal/Disk/RamDiskDxe/RamDiskDxe.inf   |  12 +
 .../Universal/Disk/RamDiskDxe/RamDiskImpl.h|  28 ++
 .../Universal/Disk/RamDiskDxe/RamDiskProtocol.c| 494 +
 OvmfPkg/OvmfPkgIa32.dsc|   1 +
 OvmfPkg/OvmfPkgIa32.fdf|   2 +
 OvmfPkg/OvmfPkgIa32X64.dsc |   1 +
 OvmfPkg/OvmfPkgIa32X64.fdf |   2 +
 OvmfPkg/OvmfPkgX64.dsc |   1 +
 OvmfPkg/OvmfPkgX64.fdf |   2 +
 11 files changed, 667 insertions(+)
 create mode 100644 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDisk.asl

-- 
1.9.5.msysgit.0

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


[edk2] [PATCH v4 2/2] OvmfPkg: Modify FDF/DSC files for RamDiskDxe's adding NFIT report feature

2016-04-28 Thread Hao Wu
The RamDiskDxe driver in MdeModulePkg now will use EFI_ACPI_TABLE_PROTOCOL
and EFI_ACPI_SDT_PROTOCOL during reporting RAM disks to NVDIMM Firmware
Interface Table (NFIT).

A Pcd 'PcdInstallAcpiSdtProtocol' controls whether the
EFI_ACPI_SDT_PROTOCOL will be produced. Its default value is set to FALSE
in MdeModulePkg. To make the NFIT reporting feature working properly under
OVMF, the patch will set the Pcd to TRUE in OVMF DSC files.

Also, the RamDiskDxe driver will sometimes report a NVDIMM Root Device
using ASL code which is put in a Secondary System Description Table (SSDT)
according to the ACPI 6.1 spec.

Locating the SSDT requires modifying the [Rule.Common.DXE_DRIVER] field in
OVMF FDF files.

Cc: Laszlo Ersek 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32.fdf| 2 ++
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgIa32X64.fdf | 2 ++
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.fdf | 2 ++
 6 files changed, 9 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 0206dda..5dbfe57 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -350,6 +350,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 !if $(SECURE_BOOT_ENABLE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 93a51a5..287737c 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
 PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
 UI   STRING="$(MODULE_NAME)" Optional
 VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+RAW ACPI  Optional   |.acpi
+RAW ASL   Optional   |.aml
   }
 
 [Rule.Common.DXE_RUNTIME_DRIVER]
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 06fe141..896f9c6 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -355,6 +355,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 !if $(SECURE_BOOT_ENABLE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index aad16a6..cc1587a 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
 PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
 UI   STRING="$(MODULE_NAME)" Optional
 VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+RAW ACPI  Optional   |.acpi
+RAW ASL   Optional   |.aml
   }
 
 [Rule.Common.DXE_RUNTIME_DRIVER]
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index e88e70d..cdac4ef 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -355,6 +355,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 !if $(SECURE_BOOT_ENABLE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
 !endif
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 387b808..1b52381 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -444,6 +444,8 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
 PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
 UI   STRING="$(MODULE_NAME)" Optional
 VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+RAW ACPI  Optional   |.acpi
+RAW ASL   Optional   |.aml
   }
 
 [Rule.Common.DXE_RUNTIME_DRIVER]
-- 
1.9.5.msysgit.0

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


Re: [edk2] [PATCH] SecurityPkg: Fix TPM 1.2 NV Storage Command Size byte order

2016-04-28 Thread Zhang, Chao B
Reviewed-by: Chao Zhang 






Thanks & Best regards
Chao Zhang


-Original Message-
From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hpe.com] 
Sent: Friday, April 29, 2016 4:24 AM
To: edk2-devel@lists.01.org
Cc: Zhang, Chao B; Samer El-Haj-Mahmoud; Samer El-Haj-Mahmoud; Derek Lin
Subject: [PATCH] SecurityPkg: Fix TPM 1.2 NV Storage Command Size byte order

Fix Tpm12NvWriteValue() command/response length byte order.
Tpm12SubmitCommand() was using the value from Command.Hdr.paramSize which was 
swapped to be Big Endian, but the function was expecting it in UINT32 Little 
Endian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
index 7baafa8..e176b00 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 NV storage related command.
 
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -199,8 +200,9 @@ 
Tpm12NvWriteValue (  {
   EFI_STATUS  Status;
   TPM_CMD_NV_WRITE_VALUE  Command;
+  UINT32  CommandLength;
   TPM_RSP_COMMAND_HDR Response;
-  UINT32  Length;
+  UINT32  ResponseLength;
 
   if (DataSize > sizeof (Command.Data)) {
 return EFI_UNSUPPORTED;
@@ -210,14 +212,15 @@ Tpm12NvWriteValue (
   // send Tpm command TPM_ORD_NV_WriteValue
   //
   Command.Hdr.tag   = SwapBytes16 (TPM_TAG_RQU_COMMAND);
-  Command.Hdr.paramSize = SwapBytes32 (sizeof (Command) - sizeof(Command.Data) 
+ DataSize);
+  CommandLength = sizeof (Command) - sizeof(Command.Data) + DataSize;  
+ Command.Hdr.paramSize = SwapBytes32 (CommandLength);
   Command.Hdr.ordinal   = SwapBytes32 (TPM_ORD_NV_WriteValue);
   Command.NvIndex   = SwapBytes32 (NvIndex);
   Command.Offset= SwapBytes32 (Offset);
   Command.DataSize  = SwapBytes32 (DataSize);
   CopyMem (Command.Data, Data, DataSize);
-  Length = sizeof (Response);
-  Status = Tpm12SubmitCommand (Command.Hdr.paramSize, (UINT8 *)&Command, 
&Length, (UINT8 *)&Response);
+  ResponseLength = sizeof (Response);
+  Status = Tpm12SubmitCommand (CommandLength, (UINT8 *)&Command, 
+ &ResponseLength, (UINT8 *)&Response);
   if (EFI_ERROR (Status)) {
 return Status;
   }
--
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] SecurityPkg: Add DEBUG messages for TPM2Startup

2016-04-28 Thread Zhang, Chao B
Reviewed-by: Chao Zhang 






Thanks & Best regards
Chao Zhang


-Original Message-
From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hpe.com] 
Sent: Friday, April 29, 2016 4:04 AM
To: edk2-devel@lists.01.org
Cc: Zhang, Chao B; Samer El-Haj-Mahmoud; Samer El-Haj-Mahmoud
Subject: [PATCH] SecurityPkg: Add DEBUG messages for TPM2Startup

Add DEBUG messages for TPM2Startup to distinguish between TPM_RC_SUCCESS and 
TPM_RC_INITIALIZE. This helps debugging some hardware problems.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
index f67043b..dc2c562 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
@@ -2,6 +2,7 @@
   Implement TPM2 Startup related command.
 
 Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -75,8 +76,11 @@ 
Tpm2Startup (
   ResponseCode = SwapBytes32(Res.Header.responseCode);
   switch (ResponseCode)  {
   case TPM_RC_SUCCESS:
+DEBUG ((DEBUG_INFO, "TPM2Startup: TPM_RC_SUCCESS\n"));
+return EFI_SUCCESS;
   case TPM_RC_INITIALIZE:
 // TPM_RC_INITIALIZE can be returned if Tpm2Startup is not required.
+DEBUG ((DEBUG_INFO, "TPM2Startup: TPM_RC_INITIALIZE\n"));
 return EFI_SUCCESS;
   default:
 DEBUG ((EFI_D_ERROR, "Tpm2Startup: Response Code error! 0x%08x\r\n", 
ResponseCode));
--
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] SecurityPkg: Fix bug in TPM 1.2 SelfTest

2016-04-28 Thread Zhang, Chao B
Reviewed-by: Chao Zhang 





Thanks & Best regards
Chao Zhang


-Original Message-
From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hpe.com] 
Sent: Friday, April 29, 2016 4:29 AM
To: edk2-devel@lists.01.org
Cc: Zhang, Chao B; Samer El-Haj-Mahmoud; Samer El-Haj-Mahmoud; Derek Lin
Subject: [PATCH] SecurityPkg: Fix bug in TPM 1.2 SelfTest

Fix uninitialized command Length variable in TPM1.2 Self Test command

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
index cd08d19..8e232ee 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 NV Self Test related commands.
 
 Copyright (c) 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -42,5 +43,6 @@ 
Tpm12ContinueSelfTest (
   Command.tag   = SwapBytes16 (TPM_TAG_RQU_COMMAND);
   Command.paramSize = SwapBytes32 (sizeof (Command));
   Command.ordinal   = SwapBytes32 (TPM_ORD_ContinueSelfTest);
+  Length = sizeof (Response);
   return Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, 
(UINT8 *)&Response);  }
--
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] SecurityPkg: Reduce DEBUG verbosity in Tcg2Dxe

2016-04-28 Thread Zhang, Chao B
Reviewed-by: Chao Zhang 






Thanks & Best regards
Chao Zhang


-Original Message-
From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hpe.com] 
Sent: Friday, April 29, 2016 4:47 AM
To: edk2-devel@lists.01.org
Cc: Zhang, Chao B; Samer El-Haj-Mahmoud; Samer El-Haj-Mahmoud; Derek Lin
Subject: [PATCH] SecurityPkg: Reduce DEBUG verbosity in Tcg2Dxe

Reduce several DEBUG messages verbosity from INFO to VERBOSE to reduce debug 
spam when there is no TPM 2.0 part present

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c 
b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
index 07f76af..6555df5 100644
--- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
@@ -2,6 +2,7 @@
   This module implements Tcg2 Protocol.
   
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -332,14 +333,14 
@@ Tcg2GetCapability (
   IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
   )
 {
-  DEBUG ((EFI_D_INFO, "Tcg2GetCapability ...\n"));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability ...\n"));
 
   if ((This == NULL) || (ProtocolCapability == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
   
-  DEBUG ((EFI_D_INFO, "Size - 0x%x\n", ProtocolCapability->Size));
-  DEBUG ((EFI_D_INFO, " 1.1 - 0x%x, 1.0 - 0x%x\n", 
sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY), 
sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));
+  DEBUG ((DEBUG_VERBOSE, "Size - 0x%x\n", ProtocolCapability->Size));  
+ DEBUG ((DEBUG_VERBOSE, " 1.1 - 0x%x, 1.0 - 0x%x\n", 
+ sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY), 
+ sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));
 
   if (ProtocolCapability->Size < mTcgDxeData.BsCap.Size) {
 //
@@ -363,7 +364,7 @@ Tcg2GetCapability (
   }
 
   CopyMem (ProtocolCapability, &mTcgDxeData.BsCap, mTcgDxeData.BsCap.Size);
-  DEBUG ((EFI_D_INFO, "Tcg2GetCapability - %r\n", EFI_SUCCESS));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability - %r\n", EFI_SUCCESS));
   return EFI_SUCCESS;
 }
 
@@ -1237,7 +1238,7 @@ Tcg2HashLogExtendEvent (
   TCG_PCR_EVENT_HDR  NewEventHdr;
   TPML_DIGEST_VALUES DigestList;
 
-  DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent ...\n"));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent ...\n"));
 
   if ((This == NULL) || (DataToHash == 0) || (Event == NULL)) {
 return EFI_INVALID_PARAMETER;
@@ -1287,7 +1288,7 @@ Tcg2HashLogExtendEvent (
Event->Event
);
   }
-  DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent - %r\n", Status));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent - %r\n", Status));
   return Status;
 }
 
@@ -2530,10 +2531,10 @@ DriverEntry (
 mTcgDxeData.BsCap.SupportedEventLogs &= ~EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
   }
 
-  DEBUG ((EFI_D_INFO, "Tcg2.SupportedEventLogs - 0x%08x\n", 
mTcgDxeData.BsCap.SupportedEventLogs));
-  DEBUG ((EFI_D_INFO, "Tcg2.HashAlgorithmBitmap - 0x%08x\n", 
mTcgDxeData.BsCap.HashAlgorithmBitmap));
-  DEBUG ((EFI_D_INFO, "Tcg2.NumberOfPCRBanks  - 0x%08x\n", 
mTcgDxeData.BsCap.NumberOfPCRBanks));
-  DEBUG ((EFI_D_INFO, "Tcg2.ActivePcrBanks- 0x%08x\n", 
mTcgDxeData.BsCap.ActivePcrBanks));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2.SupportedEventLogs - 0x%08x\n", 
+ mTcgDxeData.BsCap.SupportedEventLogs));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2.HashAlgorithmBitmap - 0x%08x\n", 
mTcgDxeData.BsCap.HashAlgorithmBitmap));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2.NumberOfPCRBanks  - 0x%08x\n", 
mTcgDxeData.BsCap.NumberOfPCRBanks));
+  DEBUG ((DEBUG_VERBOSE, "Tcg2.ActivePcrBanks- 0x%08x\n", 
mTcgDxeData.BsCap.ActivePcrBanks));
 
   if (mTcgDxeData.BsCap.TPMPresentFlag) {
 //
--
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] SecurityPkg: Fix bug in TPM 1.2 SelfTest

2016-04-28 Thread Zhang, Chao B
I will help to check-in these SecurityPkg fixes 





Thanks & Best regards
Chao Zhang


-Original Message-
From: Lin, Derek (HPS UEFI Dev) [mailto:derek.l...@hpe.com] 
Sent: Friday, April 29, 2016 9:59 AM
To: El-Haj-Mahmoud, Samer; edk2-devel@lists.01.org
Cc: Zhang, Chao B
Subject: Re: [PATCH] SecurityPkg: Fix bug in TPM 1.2 SelfTest


This has been sent and reviewed, but not committed yet.

From: El-Haj-Mahmoud, Samer
Sent: Friday, April 29, 2016 4:29:27 AM
To: edk2-devel@lists.01.org
Cc: chao.b.zh...@intel.com; El-Haj-Mahmoud, Samer; El-Haj-Mahmoud, Samer; Lin, 
Derek (HPS UEFI Dev)
Subject: [PATCH] SecurityPkg: Fix bug in TPM 1.2 SelfTest

Fix uninitialized command Length variable in TPM1.2 Self Test command

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
index cd08d19..8e232ee 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 NV Self Test related commands.

 Copyright (c) 2016, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -42,5 +43,6 @@ 
Tpm12ContinueSelfTest (
   Command.tag   = SwapBytes16 (TPM_TAG_RQU_COMMAND);
   Command.paramSize = SwapBytes32 (sizeof (Command));
   Command.ordinal   = SwapBytes32 (TPM_ORD_ContinueSelfTest);
+  Length = sizeof (Response);
   return Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, 
(UINT8 *)&Response);  }
--
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] SecurityPkg: Add DEBUG messages for TPM12Startup

2016-04-28 Thread Zhang, Chao B
Reviewed-by: Chao Zhang 






Thanks & Best regards
Chao Zhang


-Original Message-
From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hpe.com] 
Sent: Friday, April 29, 2016 4:33 AM
To: edk2-devel@lists.01.org
Cc: Zhang, Chao B; Samer El-Haj-Mahmoud; Samer El-Haj-Mahmoud; Derek Lin
Subject: [PATCH] SecurityPkg: Add DEBUG messages for TPM12Startup

Add DEBUG messages for TPM12Startup to distinguish between TPM_SUCCESS and 
TPM_INVALID_POSTINIT. This helps debugging some hardware problems.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud 
Signed-off-by: Derek Lin 
---
 SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c 
b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
index bc10e45..098dd28 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
@@ -2,6 +2,7 @@
   Implement TPM1.2 Startup related command.
 
 Copyright (c) 2013, Intel Corporation. All rights reserved. 
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -16,6 +17,7 @@ 
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 
 
 #pragma pack(1)
 
@@ -59,8 +61,11 @@ Tpm12Startup (
   }
   switch (SwapBytes32(Response.returnCode)) {
   case TPM_SUCCESS:
+DEBUG ((DEBUG_INFO, "TPM12Startup: TPM_SUCCESS\n"));
+return EFI_SUCCESS;
   case TPM_INVALID_POSTINIT:
 // In warm reset, TPM may response TPM_INVALID_POSTINIT
+DEBUG ((DEBUG_INFO, "TPM12Startup: TPM_INVALID_POSTINIT\n"));
 return EFI_SUCCESS;
   default:
 return EFI_DEVICE_ERROR;
--
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] SecurityPkg: Reduce DEBUG verbosity in Tcg2Dxe

2016-04-28 Thread Yao, Jiewen
Hi Samer
I am a little confused on this patch.

If there is no TPM 2.0 part present, this code should not run, by design.

Would you please clarify how you trigger this situation?

Thank you
Yao Jiewen


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Samer El-Haj-Mahmoud
> Sent: Friday, April 29, 2016 4:47 AM
> To: edk2-devel@lists.01.org
> Cc: Samer El-Haj-Mahmoud ; Derek Lin
> ; Zhang, Chao B 
> Subject: [edk2] [PATCH] SecurityPkg: Reduce DEBUG verbosity in Tcg2Dxe
> 
> Reduce several DEBUG messages verbosity from INFO to VERBOSE to reduce
> debug spam when there is no TPM 2.0 part present
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Samer El-Haj-Mahmoud 
> Signed-off-by: Derek Lin 
> ---
>  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 21 +++--
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> index 07f76af..6555df5 100644
> --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> @@ -2,6 +2,7 @@
>This module implements Tcg2 Protocol.
> 
>  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
> +(C) Copyright 2016 Hewlett Packard Enterprise Development LP
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -332,14 +333,14 @@ Tcg2GetCapability (
>IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
>)
>  {
> -  DEBUG ((EFI_D_INFO, "Tcg2GetCapability ...\n"));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability ...\n"));
> 
>if ((This == NULL) || (ProtocolCapability == NULL)) {
>  return EFI_INVALID_PARAMETER;
>}
> 
> -  DEBUG ((EFI_D_INFO, "Size - 0x%x\n", ProtocolCapability->Size));
> -  DEBUG ((EFI_D_INFO, " 1.1 - 0x%x, 1.0 - 0x%x\n",
> sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY),
> sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));
> +  DEBUG ((DEBUG_VERBOSE, "Size - 0x%x\n", ProtocolCapability->Size));
> +  DEBUG ((DEBUG_VERBOSE, " 1.1 - 0x%x, 1.0 - 0x%x\n",
> sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY),
> sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));
> 
>if (ProtocolCapability->Size < mTcgDxeData.BsCap.Size) {
>  //
> @@ -363,7 +364,7 @@ Tcg2GetCapability (
>}
> 
>CopyMem (ProtocolCapability, &mTcgDxeData.BsCap,
> mTcgDxeData.BsCap.Size);
> -  DEBUG ((EFI_D_INFO, "Tcg2GetCapability - %r\n", EFI_SUCCESS));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability - %r\n", EFI_SUCCESS));
>return EFI_SUCCESS;
>  }
> 
> @@ -1237,7 +1238,7 @@ Tcg2HashLogExtendEvent (
>TCG_PCR_EVENT_HDR  NewEventHdr;
>TPML_DIGEST_VALUES DigestList;
> 
> -  DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent ...\n"));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent ...\n"));
> 
>if ((This == NULL) || (DataToHash == 0) || (Event == NULL)) {
>  return EFI_INVALID_PARAMETER;
> @@ -1287,7 +1288,7 @@ Tcg2HashLogExtendEvent (
> Event->Event
> );
>}
> -  DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent - %r\n", Status));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent - %r\n", Status));
>return Status;
>  }
> 
> @@ -2530,10 +2531,10 @@ DriverEntry (
>  mTcgDxeData.BsCap.SupportedEventLogs &=
> ~EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
>}
> 
> -  DEBUG ((EFI_D_INFO, "Tcg2.SupportedEventLogs - 0x%08x\n",
> mTcgDxeData.BsCap.SupportedEventLogs));
> -  DEBUG ((EFI_D_INFO, "Tcg2.HashAlgorithmBitmap - 0x%08x\n",
> mTcgDxeData.BsCap.HashAlgorithmBitmap));
> -  DEBUG ((EFI_D_INFO, "Tcg2.NumberOfPCRBanks  - 0x%08x\n",
> mTcgDxeData.BsCap.NumberOfPCRBanks));
> -  DEBUG ((EFI_D_INFO, "Tcg2.ActivePcrBanks- 0x%08x\n",
> mTcgDxeData.BsCap.ActivePcrBanks));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2.SupportedEventLogs - 0x%08x\n",
> mTcgDxeData.BsCap.SupportedEventLogs));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2.HashAlgorithmBitmap - 0x%08x\n",
> mTcgDxeData.BsCap.HashAlgorithmBitmap));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2.NumberOfPCRBanks  -
> 0x%08x\n", mTcgDxeData.BsCap.NumberOfPCRBanks));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2.ActivePcrBanks- 0x%08x\n",
> mTcgDxeData.BsCap.ActivePcrBanks));
> 
>if (mTcgDxeData.BsCap.TPMPresentFlag) {
>  //
> --
> 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: Reduce DEBUG verbosity in Tcg2Dxe

2016-04-28 Thread Yao, Jiewen
Chao
I have question on this patch. I asked in another mail.

If there is no TPM 2.0 part present, this code should not run, by design.

Would you please clarify how you trigger this situation?

Thank you
Yao Jiewen

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Zhang, Chao B
> Sent: Friday, April 29, 2016 10:31 AM
> To: Samer El-Haj-Mahmoud ;
> edk2-devel@lists.01.org
> Cc: Samer El-Haj-Mahmoud ; Derek Lin
> 
> Subject: Re: [edk2] [PATCH] SecurityPkg: Reduce DEBUG verbosity in Tcg2Dxe
> 
> Reviewed-by: Chao Zhang 
> 
> 
> 
> 
> 
> 
> Thanks & Best regards
> Chao Zhang
> 
> 
> -Original Message-
> From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hpe.com]
> Sent: Friday, April 29, 2016 4:47 AM
> To: edk2-devel@lists.01.org
> Cc: Zhang, Chao B; Samer El-Haj-Mahmoud; Samer El-Haj-Mahmoud; Derek
> Lin
> Subject: [PATCH] SecurityPkg: Reduce DEBUG verbosity in Tcg2Dxe
> 
> Reduce several DEBUG messages verbosity from INFO to VERBOSE to reduce
> debug spam when there is no TPM 2.0 part present
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Samer El-Haj-Mahmoud 
> Signed-off-by: Derek Lin 
> ---
>  SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 21 +++--
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> index 07f76af..6555df5 100644
> --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
> @@ -2,6 +2,7 @@
>This module implements Tcg2 Protocol.
> 
>  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
> +(C) Copyright 2016 Hewlett Packard Enterprise Development LP
>  This program and the accompanying materials  are licensed and made
> available under the terms and conditions of the BSD License  which
> accompanies this distribution.  The full text of the license may be found at
> @@ -332,14 +333,14 @@ Tcg2GetCapability (
>IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
>)
>  {
> -  DEBUG ((EFI_D_INFO, "Tcg2GetCapability ...\n"));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability ...\n"));
> 
>if ((This == NULL) || (ProtocolCapability == NULL)) {
>  return EFI_INVALID_PARAMETER;
>}
> 
> -  DEBUG ((EFI_D_INFO, "Size - 0x%x\n", ProtocolCapability->Size));
> -  DEBUG ((EFI_D_INFO, " 1.1 - 0x%x, 1.0 - 0x%x\n",
> sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY),
> sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));
> +  DEBUG ((DEBUG_VERBOSE, "Size - 0x%x\n", ProtocolCapability->Size));
> + DEBUG ((DEBUG_VERBOSE, " 1.1 - 0x%x, 1.0 - 0x%x\n",
> + sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY),
> + sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));
> 
>if (ProtocolCapability->Size < mTcgDxeData.BsCap.Size) {
>  //
> @@ -363,7 +364,7 @@ Tcg2GetCapability (
>}
> 
>CopyMem (ProtocolCapability, &mTcgDxeData.BsCap,
> mTcgDxeData.BsCap.Size);
> -  DEBUG ((EFI_D_INFO, "Tcg2GetCapability - %r\n", EFI_SUCCESS));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2GetCapability - %r\n", EFI_SUCCESS));
>return EFI_SUCCESS;
>  }
> 
> @@ -1237,7 +1238,7 @@ Tcg2HashLogExtendEvent (
>TCG_PCR_EVENT_HDR  NewEventHdr;
>TPML_DIGEST_VALUES DigestList;
> 
> -  DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent ...\n"));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent ...\n"));
> 
>if ((This == NULL) || (DataToHash == 0) || (Event == NULL)) {
>  return EFI_INVALID_PARAMETER;
> @@ -1287,7 +1288,7 @@ Tcg2HashLogExtendEvent (
> Event->Event
> );
>}
> -  DEBUG ((EFI_D_INFO, "Tcg2HashLogExtendEvent - %r\n", Status));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2HashLogExtendEvent - %r\n", Status));
>return Status;
>  }
> 
> @@ -2530,10 +2531,10 @@ DriverEntry (
>  mTcgDxeData.BsCap.SupportedEventLogs &=
> ~EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
>}
> 
> -  DEBUG ((EFI_D_INFO, "Tcg2.SupportedEventLogs - 0x%08x\n",
> mTcgDxeData.BsCap.SupportedEventLogs));
> -  DEBUG ((EFI_D_INFO, "Tcg2.HashAlgorithmBitmap - 0x%08x\n",
> mTcgDxeData.BsCap.HashAlgorithmBitmap));
> -  DEBUG ((EFI_D_INFO, "Tcg2.NumberOfPCRBanks  - 0x%08x\n",
> mTcgDxeData.BsCap.NumberOfPCRBanks));
> -  DEBUG ((EFI_D_INFO, "Tcg2.ActivePcrBanks- 0x%08x\n",
> mTcgDxeData.BsCap.ActivePcrBanks));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2.SupportedEventLogs - 0x%08x\n",
> + mTcgDxeData.BsCap.SupportedEventLogs));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2.HashAlgorithmBitmap - 0x%08x\n",
> mTcgDxeData.BsCap.HashAlgorithmBitmap));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2.NumberOfPCRBanks  -
> 0x%08x\n", mTcgDxeData.BsCap.NumberOfPCRBanks));
> +  DEBUG ((DEBUG_VERBOSE, "Tcg2.ActivePcrBanks- 0x%08x\n",
> mTcgDxeData.BsCap.ActivePcrBanks));
> 
>if (mTcgDxeData.BsCap.TPMPresentFlag) {
>  //
> --
> 2.6.3.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___

[edk2] [PATCH 1/2] ShellPkg/UefiDpLib: Fix the error message "Timer library instance error!"

2016-04-28 Thread Cinnamon Shia
When executing shell dp command, there is an error message "Timer library
instance error!"

The error message "Timer library instance error!" should be for the case about
duration > EndTimeStamp if CountUp or duration < StartTimeStamp if CountDown.

But if the EndTimeStamp of an entry is not added, it should not the case to 
catch.

This change fixes the error message "Timer library instance error!" from the
"BdsAttempt" entry which is logged when trying to boot a boot option.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia 
---
 ShellPkg/Library/UefiDpLib/DpUtilities.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c 
b/ShellPkg/Library/UefiDpLib/DpUtilities.c
index 032e7b4..fbdd938 100644
--- a/ShellPkg/Library/UefiDpLib/DpUtilities.c
+++ b/ShellPkg/Library/UefiDpLib/DpUtilities.c
@@ -2,7 +2,7 @@
   Utility functions used by the Dp application.
 
   Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+  (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -68,6 +68,10 @@ GetDuration (
   UINT64Duration;
   BOOLEAN   Error;
 
+  if (Measurement->EndTimeStamp == 0) {
+return 0;
+  }
+
   // PERF_START macros are called with a value of 1 to indicate
   // the beginning of time.  So, adjust the start ticker value
   // to the real beginning of time.
-- 
2.8.1.windows.1

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


[edk2] [PATCH 2/2] PerformancePkg/Dp_App: Fix the error message "Timer library instance error!"

2016-04-28 Thread Cinnamon Shia
When executing shell dp command, there is an error message "Timer library
instance error!"

The error message "Timer library instance error!" should be for the case about
duration > EndTimeStamp if CountUp or duration < StartTimeStamp if CountDown.

But if the EndTimeStamp of an entry is not added, it should not the case to 
catch.

This change fixes the error message "Timer library instance error!" from the
"BdsAttempt" entry which is logged when trying to boot a boot option.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia 
---
 PerformancePkg/Dp_App/DpUtilities.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/PerformancePkg/Dp_App/DpUtilities.c 
b/PerformancePkg/Dp_App/DpUtilities.c
index b49844a..f5ef9cf 100644
--- a/PerformancePkg/Dp_App/DpUtilities.c
+++ b/PerformancePkg/Dp_App/DpUtilities.c
@@ -2,6 +2,7 @@
   Utility functions used by the Dp application.
 
   Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -82,6 +83,10 @@ GetDuration (
   UINT64Duration;
   BOOLEAN   Error;
 
+  if (Measurement->EndTimeStamp == 0) {
+return 0;
+  }
+
   // PERF_START macros are called with a value of 1 to indicate
   // the beginning of time.  So, adjust the start ticker value
   // to the real beginning of time.
-- 
2.8.1.windows.1

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


Re: [edk2] [staging/HTTPS-TLS][PATCH] CryptPkg: Cleanup TlsLib X509Store initialization

2016-04-28 Thread Wu, Jiaxin
Reviewed-by: Jiaxin Wu 


> -Original Message-
> From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hpe.com]
> Sent: Friday, April 29, 2016 2:50 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin ; Samer El-Haj-Mahmoud  haj-mahm...@hpe.com>; Samer El-Haj-Mahmoud ;
> Thomas Palmer 
> Subject: [staging/HTTPS-TLS][PATCH] CryptPkg: Cleanup TlsLib X509Store
> initialization
> 
> Cleanup TlsLib to create a new X509 store only if needed in TlsNew(), and set
> its flags when created, not every time we are adding a certificate (in
> TlsSetCaCertificate)
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Samer El-Haj-Mahmoud 
> Signed-off-by: Thomas Palmer 
> ---
>  CryptoPkg/Library/TlsLib/TlsLib.c | 41 ++--
> ---
>  1 file changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/CryptoPkg/Library/TlsLib/TlsLib.c
> b/CryptoPkg/Library/TlsLib/TlsLib.c
> index 0818653..b91fee7 100644
> --- a/CryptoPkg/Library/TlsLib/TlsLib.c
> +++ b/CryptoPkg/Library/TlsLib/TlsLib.c
> @@ -130,7 +130,7 @@ TlsInitialize (
>// Loads error strings from both crypto and ssl library.
>//
>SSL_load_error_strings ();
> -
> +
>/// OpenSSL_add_all_algorithms();
> 
>//
> @@ -274,6 +274,7 @@ TlsNew (
>)
>  {
>TLS_CONNECTION  *TlsConn;
> +  X509_STORE  *X509Store;
> 
>TlsConn = NULL;
> 
> @@ -342,6 +343,28 @@ TlsNew (
>//
>SSL_set_bio (TlsConn->Ssl, TlsConn->InBio, TlsConn->OutBio);
> 
> +
> +  //
> +  // Create new X509 store if needed
> +  //
> +  X509Store = SSL_CTX_get_cert_store (TlsConn->Ssl->ctx);  if
> + (X509Store == NULL) {
> +X509Store = X509_STORE_new ();
> +if (X509Store == NULL) {
> +  TlsFree ((VOID *) TlsConn);
> +  return NULL;
> +}
> +SSL_CTX_set1_verify_cert_store (TlsConn->Ssl->ctx, X509Store);
> +X509_STORE_free (X509Store);
> +  }
> +
> +  //
> +  // Set X509_STORE flags used in certificate validation  //
> + X509_STORE_set_flags (
> +X509Store,
> +X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_NO_CHECK_TIME
> +);
>return (VOID *) TlsConn;
>  }
> 
> @@ -1473,15 +1496,13 @@ TlsSetCaCertificate (
> 
>X509Store = SSL_CTX_get_cert_store(TlsConn->Ssl->ctx);
>if (X509Store == NULL) {
> -X509Store = X509_STORE_new();
> -if (X509Store == NULL) {
>Status = EFI_ABORTED;
>goto ON_EXIT;
> -}
> -
> -SSL_CTX_set_cert_store(TlsConn->Ssl->ctx, X509Store);
>}
> 
> +  //
> +  // Add certificate to X509 store
> +  //
>Ret = X509_STORE_add_cert (X509Store, Cert);
>if (Ret != 1) {
>  ErrorCode = ERR_peek_last_error (); @@ -1493,14 +1514,8 @@
> TlsSetCaCertificate (
>Status = EFI_ABORTED;
>goto ON_EXIT;
>  }
> -
>}
> -
> -  X509_STORE_set_flags (
> -X509Store,
> -X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_NO_CHECK_TIME
> -);
> -
> +
>  ON_EXIT:
>if (BioCert != NULL) {
>  BIO_free (BioCert);
> --
> 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 v4 0/2] Report ACPI NFIT for reserved memory RAM disks

2016-04-28 Thread El-Haj-Mahmoud, Samer
Series Reviewed-By: Samer El-Haj-Mahmoud 



-Original Message-
From: Hao Wu [hao.a...@intel.com]
Received: Thursday, 28 Apr 2016, 9:23PM
To: edk2-devel@lists.01.org [edk2-devel@lists.01.org]; ler...@redhat.com 
[ler...@redhat.com]; jordan.l.jus...@intel.com [jordan.l.jus...@intel.com]
CC: Hao Wu [hao.a...@intel.com]
Subject: [edk2] [PATCH v4 0/2] Report ACPI NFIT for reserved memory RAM disks

Since the RamDiskDxe part in MdeModulePkg has not been changed, this
series only contains the patch for changes made in OvmfPkg.

Changes compared with V3:
1. Set Pcd 'PcdInstallAcpiSdtProtocol' to TURE in OVMF DSC files.

Changes compared with V2:
1. RamDiskDxe driver now will register an EFI event in the Ready To Boot
   Event Group to a). detect whether EFI_ACPI_TABLE_PROTOCOL and
   EFI_ACPI_SDT_PROTOCOL are both produced; b). publish all the reserved
   memory type RAM disks registered at this point to the NFIT if both
   protocols are produced.

2. The RamDiskUnpublishNfit() now will uninstall NFIT and SSDT that is
   used to report the NVDIMM root device from the ACPI table when there is
   no NFIT structure in NFIT after removing a RAM disk.

3. Instead of adding a new rule in OvmfPkg FDF files, the patch now lists
   the asl and aml options in the main [Rule.Common.DXE_DRIVER] field.


Changes compared with V1:
1. Instead of creating a new NFIT for each registered reserved memory RAM
   disk, new cotent of the NFIT is appended to the existing one.

2. Report an NVDIMM root device in the \SB scope if there is no NFIT in
   the ACPI table.

3. Modify FDF files in OvmfPkg to make sure the report of the NVDIMM root
   device will be done correctly.


Hao Wu (2):
  MdeModulePkg RamDiskDxe: Report ACPI NFIT for reserved memory RAM
disks
  OvmfPkg: Modify FDF/DSC files for RamDiskDxe's adding NFIT report
feature

 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDisk.asl |  44 ++
 .../Universal/Disk/RamDiskDxe/RamDiskDriver.c  |  80 
 .../Universal/Disk/RamDiskDxe/RamDiskDxe.inf   |  12 +
 .../Universal/Disk/RamDiskDxe/RamDiskImpl.h|  28 ++
 .../Universal/Disk/RamDiskDxe/RamDiskProtocol.c| 494 +
 OvmfPkg/OvmfPkgIa32.dsc|   1 +
 OvmfPkg/OvmfPkgIa32.fdf|   2 +
 OvmfPkg/OvmfPkgIa32X64.dsc |   1 +
 OvmfPkg/OvmfPkgIa32X64.fdf |   2 +
 OvmfPkg/OvmfPkgX64.dsc |   1 +
 OvmfPkg/OvmfPkgX64.fdf |   2 +
 11 files changed, 667 insertions(+)
 create mode 100644 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDisk.asl

--
1.9.5.msysgit.0

___
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] ShellPkg: Add NULL pointer check.

2016-04-28 Thread Qiu, Shumin
Thanks for the catch.

-Shumin

-Original Message-
From: Shah, Tapan [mailto:tapands...@hpe.com] 
Sent: Thursday, April 28, 2016 9:55 PM
To: Qiu, Shumin; edk2-devel@lists.01.org
Cc: Carsey, Jaben
Subject: RE: [PATCH] ShellPkg: Add NULL pointer check.

This should be changed:

+  if (TempRetVal) {
+goto EXIT;
+  }

To:

+  if (TempRetVal == NULL) {
+goto EXIT;
+  }

Reviewed-by: Tapan Shah 

-Original Message-
From: Qiu Shumin [mailto:shumin@intel.com]
Sent: Thursday, April 28, 2016 3:26 AM
To: edk2-devel@lists.01.org
Cc: Qiu Shumin ; Jaben Carsey ; 
Shah, Tapan 
Subject: [PATCH] ShellPkg: Add NULL pointer check.

Add pointer check to avoid NULL pointer dereferenced.

Cc: Jaben Carsey 
Cc: Tapan Shah 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin 
---
 .../UefiHandleParsingLib/UefiHandleParsingLib.c  | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 58f1814..830ee3b 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -301,14 +301,26 @@ GraphicsOutputProtocolDumpInformation(
 
   SHELL_FREE_NON_NULL (Temp);
   
-  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_MAIN), NULL);
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
+ (STR_GOP_RES_LIST_MAIN), NULL);  if (Temp == NULL) {
+SHELL_FREE_NON_NULL (RetVal);
+goto EXIT;
+  }
 
   TempRetVal = CatSPrint (RetVal, Temp);
-  SHELL_FREE_NON_NULL (RetVal);
+  SHELL_FREE_NON_NULL (RetVal);
+  if (TempRetVal) {
+goto EXIT;
+  }
   RetVal = TempRetVal;
   SHELL_FREE_NON_NULL (Temp);
 
-  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
(STR_GOP_RES_LIST_ENTRY), NULL);
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN 
+ (STR_GOP_RES_LIST_ENTRY), NULL);  if (Temp == NULL) {
+SHELL_FREE_NON_NULL (RetVal);
+goto EXIT;
+  }
+
 
   for (Mode = 0; Mode < GraphicsOutput->Mode->MaxMode; Mode++) {
 Status = GraphicsOutput->QueryMode ( @@ -334,6 +346,8 @@ 
GraphicsOutputProtocolDumpInformation(
 RetVal = TempRetVal;
   }
 
+
+EXIT:
   SHELL_FREE_NON_NULL(Temp);
   SHELL_FREE_NON_NULL(Fmt);
 
--
2.7.1.windows.2


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


Re: [edk2] [PATCH 2/2] PerformancePkg/Dp_App: Fix the error message "Timer library instance error!"

2016-04-28 Thread Zeng, Star

Cinnamon,

On 2016/4/29 10:42, Cinnamon Shia wrote:

When executing shell dp command, there is an error message "Timer library
instance error!"

The error message "Timer library instance error!" should be for the case about
duration > EndTimeStamp if CountUp or duration < StartTimeStamp if CountDown.


The information "duration < StartTimeStamp" should be "duration > 
StartTimeStamp", right?


With this updated, you can have my Reviewed-by: Star Zeng 
.

Same comments to another patch in ShellPkg.

If you agree, you do not need resend the patch, I can help push the patches.

I have other comments are not related to these patches.
Could you help send patch to remove "HP_ISS_EDK2_CONTRIUTION" in 
ShellPkg\Library\UefiDpLib\DpTrace.c comments?
And could you send patch to remove InitCumulativeData() in 
PerformancePkg\Dp_App\Dp.c as the function is not used by Dp in 
PerformancePkg?



Thanks,
Star



But if the EndTimeStamp of an entry is not added, it should not the case to 
catch.

This change fixes the error message "Timer library instance error!" from the
"BdsAttempt" entry which is logged when trying to boot a boot option.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia 
---
  PerformancePkg/Dp_App/DpUtilities.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/PerformancePkg/Dp_App/DpUtilities.c 
b/PerformancePkg/Dp_App/DpUtilities.c
index b49844a..f5ef9cf 100644
--- a/PerformancePkg/Dp_App/DpUtilities.c
+++ b/PerformancePkg/Dp_App/DpUtilities.c
@@ -2,6 +2,7 @@
Utility functions used by the Dp application.

Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD 
License
which accompanies this distribution.  The full text of the license may be 
found at
@@ -82,6 +83,10 @@ GetDuration (
UINT64Duration;
BOOLEAN   Error;

+  if (Measurement->EndTimeStamp == 0) {
+return 0;
+  }
+
// PERF_START macros are called with a value of 1 to indicate
// the beginning of time.  So, adjust the start ticker value
// to the real beginning of time.



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


[edk2] [Patch] SecurityPkg OpalPasswordDxe: Install menu without device dependency.

2016-04-28 Thread Eric Dong
Change design to always install opal menu.
Current implementation only install menu when device connect.

Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c  | 13 +++---
 SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c | 46 --
 .../Tcg/Opal/OpalPasswordDxe/OpalPasswordDxe.inf   |  2 +-
 3 files changed, 6 insertions(+), 55 deletions(-)

diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c 
b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
index e06ce4a..1f70331 100644
--- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
+++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
@@ -732,6 +732,11 @@ EfiDriverEntryPoint(
   &ReadyToBootEvent
   );
 
+  //
+  // Install Hii packages.
+  //
+  HiiInstall();
+
   return Status;
 }
 
@@ -966,14 +971,6 @@ OpalEfiDriverBindingStart(
   AddDeviceToTail(Dev);
 
   //
-  // Install Hii if it hasn't already been installed
-  //
-  if (!gHiiInstalled) {
-HiiInstall();
-gHiiInstalled = TRUE;
-  }
-
-  //
   // check if device is locked and prompt for password
   //
   OpalDriverRequestPassword (Dev);
diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c 
b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
index 75ff9fc..0a4453a 100644
--- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
+++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
@@ -108,43 +108,6 @@ HiiSetCurrentConfiguration(
 }
 
 /**
-  Check that all required protocols for HII are available.
-
-  @retval  EFI_SUCCESSAll required protocols are installed.
-  @retval  EFI_NOT_FOUND  One or more protocol are not installed.
-**/
-EFI_STATUS
-HiiCheckForRequiredProtocols (
-  VOID
-  )
-{
-  VOID*   TempProtocol;
-  EFI_STATUS  Status;
-
-  Status = gBS->LocateProtocol(&gEfiHiiStringProtocolGuid, NULL, 
(VOID**)&TempProtocol );
-  if (EFI_ERROR (Status)) {
-return EFI_NOT_FOUND;
-  }
-
-  Status = gBS->LocateProtocol(&gEfiHiiDatabaseProtocolGuid, NULL, 
(VOID**)&TempProtocol );
-  if (EFI_ERROR (Status)) {
-return EFI_NOT_FOUND;
-  }
-
-  Status = gBS->LocateProtocol(&gEfiHiiConfigRoutingProtocolGuid, NULL, 
(VOID**)&TempProtocol );
-  if (EFI_ERROR (Status)) {
-return EFI_NOT_FOUND;
-  }
-
-  Status = gBS->LocateProtocol(&gEfiFormBrowser2ProtocolGuid, NULL, 
(VOID**)&TempProtocol );
-  if (EFI_ERROR (Status)) {
-return EFI_NOT_FOUND;
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
   Install the HII related resources.
 
   @retval  EFI_SUCCESSInstall all the resources success.
@@ -159,15 +122,6 @@ HiiInstall(
   EFI_HANDLE   DriverHandle;
 
   //
-  // Check that all required protocols are available for HII.
-  // If not, fail the install
-  //
-  Status = HiiCheckForRequiredProtocols();
-  if (EFI_ERROR(Status)) {
-return Status;
-  }
-
-  //
   // Clear the global configuration.
   //
   ZeroMem(&gHiiConfiguration, sizeof(gHiiConfiguration));
diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalPasswordDxe.inf 
b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalPasswordDxe.inf
index bae8885..703c1b6 100644
--- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalPasswordDxe.inf
+++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalPasswordDxe.inf
@@ -78,4 +78,4 @@
   gOpalExtraInfoVariableGuid## PRODUCES ## GUID
 
 [Depex]
-  gEfiSmmCommunicationProtocolGuid
+  gEfiSmmCommunicationProtocolGuid AND gEfiHiiStringProtocolGuid AND 
gEfiHiiDatabaseProtocolGuid
-- 
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] BaseTools: fix the bug for FMP to support use Macro as path description

2016-04-28 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Zhu, Yonghong
> Sent: Thursday, April 28, 2016 3:07 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [Patch] BaseTools: fix the bug for FMP to support use Macro as path
> description
> 
> Fix the bug for FMP image to support to use Macro as path description,
> eg: FILE DATA =
> $(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/test.efi
> 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Yonghong Zhu 
> ---
>  BaseTools/Source/Python/GenFds/FdfParser.py | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py
> b/BaseTools/Source/Python/GenFds/FdfParser.py
> index 72fb3dc..39f951a 100644
> --- a/BaseTools/Source/Python/GenFds/FdfParser.py
> +++ b/BaseTools/Source/Python/GenFds/FdfParser.py
> @@ -3433,13 +3433,12 @@ class FdfParser:
> 
>  if not self.__GetNextToken():
>  raise Warning("expected File name", self.FileName,
> self.CurrentLineNumber)
> 
>  AnyFileName = self.__Token
> -AnyFileName =
> GenFdsGlobalVariable.ReplaceWorkspaceMacro(AnyFileName)
> -if not os.path.exists(AnyFileName):
> -raise Warning("File %s not exists"%AnyFileName, self.FileName,
> self.CurrentLineNumber)
> +self.__VerifyFile(AnyFileName)
> +
>  return AnyFileName
> 
>  ## __GetAnyFileStatement() method
>  #
>  #   Get AnyFile for capsule
> --
> 2.6.1.windows.1

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


Re: [edk2] [PATCH] [BaseTools]/Build: Better DSC arch filtering

2016-04-28 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

I will push this patch to Git Repository.

Best Regards,
Zhu Yonghong


-Original Message-
From: Thomas Palmer [mailto:thomas.pal...@hpe.com] 
Sent: Thursday, April 28, 2016 6:32 AM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong ; Gao, Liming ; 
samer.el-haj-mahm...@hpe.com; Thomas Palmer 
Subject: [PATCH] [BaseTools]/Build: Better DSC arch filtering

Description:
When building for any specific architecture, the build script today is loading 
DSC sections for other architectures not in the build. The build process should 
disregard DSC sections that are not relevant to the build.

My previous patch only fixed issue for one section type (Components). This 
patch will handle all section types by updating the MetaFileParser class, which 
now takes a Arch argument and will filter the DSC table results as they are 
returned from the database.  The database still contains all information from 
DSCs for when builds support multiple arch's

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Thomas Palmer 
---
 .../Source/Python/Workspace/MetaFileParser.py  | 40 ++
 .../Source/Python/Workspace/WorkspaceDatabase.py   |  7 +---
 2 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 2811fd1..209f47c 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -2,7 +2,7 @@
 # This file is used to parse meta files  #  # Copyright (c) 2008 - 2016, Intel 
Corporation. All rights reserved. -# Copyright (c) 2015, Hewlett Packard 
Enterprise Development, L.P.
+# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 # This program and the accompanying materials  # are licensed and made 
available under the terms and conditions of the BSD License  # which 
accompanies this distribution.  The full text of the license may be found at @@ 
-144,14 +144,15 @@ class MetaFileParser(object):
 #
 #   @param  FilePathThe path of platform description file
 #   @param  FileTypeThe raw data of DSC file
+#   @param  ArchDefault Arch value for filtering sections
 #   @param  Table   Database used to retrieve module/package 
information
-#   @param  Macros  Macros used for replacement in file
 #   @param  Owner   Owner ID (for sub-section parsing)
 #   @param  FromID from which the data comes (for !INCLUDE 
directive)
 #
-def __init__(self, FilePath, FileType, Table, Owner= -1, From= -1):
+def __init__(self, FilePath, FileType, Arch, Table, Owner= -1, From= -1):
 self._Table = Table
 self._RawTable = Table
+self._Arch = Arch
 self._FileType = FileType
 self.MetaFile = FilePath
 self._FileDir = self.MetaFile.Dir @@ -211,6 +212,15 @@ class 
MetaFileParser(object):
 def _SetFinished(self, Value):
 self._Finished = Value
 
+## Remove records that do not match given Filter Arch
+def _FilterRecordList(self, RecordList, FilterArch):
+NewRecordList = []
+for Record in RecordList:
+Arch = Record[3]
+if Arch == 'COMMON' or Arch == FilterArch:
+NewRecordList.append(Record)
+return NewRecordList
+
 ## Use [] style to query data in table, just for readability
 #
 #   DataInfo = [data_type, scope1(arch), scope2(platform/moduletype)]
@@ -230,13 +240,13 @@ class MetaFileParser(object):
 
 # No specific ARCH or Platform given, use raw data
 if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] == None):
-return self._RawTable.Query(*DataInfo)
+return 
+ self._FilterRecordList(self._RawTable.Query(*DataInfo), self._Arch)
 
 # Do post-process if necessary
 if not self._PostProcessed:
 self._PostProcess()
 
-return self._Table.Query(*DataInfo)
+return self._FilterRecordList(self._Table.Query(*DataInfo), 
+ DataInfo[1])
 
 ## Data parser for the common format in different type of file
 #
@@ -490,14 +500,14 @@ class InfParser(MetaFileParser):
 #
 #   @param  FilePathThe path of module description file
 #   @param  FileTypeThe raw data of DSC file
+#   @param  ArchDefault Arch value for filtering sections
 #   @param  Table   Database used to retrieve module/package 
information
-#   @param  Macros  Macros used for replacement in file
 #
-def __init__(self, FilePath, FileType, Table):
+def __init__(self, FilePath, FileType, Arch, Table):
 # prevent re-initialization
 if hasattr(self, "_Table"):
 return
-MetaFileParser.__init__(self, FilePath, FileType, Table)
+MetaFileParser.__in

Re: [edk2] [PATCH] [BaseTools]/Build: Better DSC arch filtering

2016-04-28 Thread Palmer, Thomas
Xie xie,
Thomas

-Original Message-
From: Zhu, Yonghong [mailto:yonghong@intel.com] 
Sent: Friday, April 29, 2016 1:30 AM
To: Palmer, Thomas ; edk2-devel@lists.01.org
Cc: Gao, Liming ; El-Haj-Mahmoud, Samer 
; Zhu, Yonghong 
Subject: RE: [PATCH] [BaseTools]/Build: Better DSC arch filtering

Reviewed-by: Yonghong Zhu  

I will push this patch to Git Repository.

Best Regards,
Zhu Yonghong


-Original Message-
From: Thomas Palmer [mailto:thomas.pal...@hpe.com]
Sent: Thursday, April 28, 2016 6:32 AM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong ; Gao, Liming ; 
samer.el-haj-mahm...@hpe.com; Thomas Palmer 
Subject: [PATCH] [BaseTools]/Build: Better DSC arch filtering

Description:
When building for any specific architecture, the build script today is loading 
DSC sections for other architectures not in the build. The build process should 
disregard DSC sections that are not relevant to the build.

My previous patch only fixed issue for one section type (Components). This 
patch will handle all section types by updating the MetaFileParser class, which 
now takes a Arch argument and will filter the DSC table results as they are 
returned from the database.  The database still contains all information from 
DSCs for when builds support multiple arch's

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Thomas Palmer 
---
 .../Source/Python/Workspace/MetaFileParser.py  | 40 ++
 .../Source/Python/Workspace/WorkspaceDatabase.py   |  7 +---
 2 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 2811fd1..209f47c 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -2,7 +2,7 @@
 # This file is used to parse meta files  #  # Copyright (c) 2008 - 2016, Intel 
Corporation. All rights reserved. -# Copyright (c) 2015, Hewlett Packard 
Enterprise Development, L.P.
+# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 # This program and the accompanying materials  # are licensed and made 
available under the terms and conditions of the BSD License  # which 
accompanies this distribution.  The full text of the license may be found at @@ 
-144,14 +144,15 @@ class MetaFileParser(object):
 #
 #   @param  FilePathThe path of platform description file
 #   @param  FileTypeThe raw data of DSC file
+#   @param  ArchDefault Arch value for filtering sections
 #   @param  Table   Database used to retrieve module/package 
information
-#   @param  Macros  Macros used for replacement in file
 #   @param  Owner   Owner ID (for sub-section parsing)
 #   @param  FromID from which the data comes (for !INCLUDE 
directive)
 #
-def __init__(self, FilePath, FileType, Table, Owner= -1, From= -1):
+def __init__(self, FilePath, FileType, Arch, Table, Owner= -1, From= -1):
 self._Table = Table
 self._RawTable = Table
+self._Arch = Arch
 self._FileType = FileType
 self.MetaFile = FilePath
 self._FileDir = self.MetaFile.Dir @@ -211,6 +212,15 @@ class 
MetaFileParser(object):
 def _SetFinished(self, Value):
 self._Finished = Value
 
+## Remove records that do not match given Filter Arch
+def _FilterRecordList(self, RecordList, FilterArch):
+NewRecordList = []
+for Record in RecordList:
+Arch = Record[3]
+if Arch == 'COMMON' or Arch == FilterArch:
+NewRecordList.append(Record)
+return NewRecordList
+
 ## Use [] style to query data in table, just for readability
 #
 #   DataInfo = [data_type, scope1(arch), scope2(platform/moduletype)]
@@ -230,13 +240,13 @@ class MetaFileParser(object):
 
 # No specific ARCH or Platform given, use raw data
 if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] == None):
-return self._RawTable.Query(*DataInfo)
+return
+ self._FilterRecordList(self._RawTable.Query(*DataInfo), self._Arch)
 
 # Do post-process if necessary
 if not self._PostProcessed:
 self._PostProcess()
 
-return self._Table.Query(*DataInfo)
+return self._FilterRecordList(self._Table.Query(*DataInfo),
+ DataInfo[1])
 
 ## Data parser for the common format in different type of file
 #
@@ -490,14 +500,14 @@ class InfParser(MetaFileParser):
 #
 #   @param  FilePathThe path of module description file
 #   @param  FileTypeThe raw data of DSC file
+#   @param  ArchDefault Arch value for filtering sections
 #   @param  Table   Database used to retrieve module/package 
information
-#   @param  Macros  Macros used for replacement in file