[edk2] [Patch] UefiCpuPkg/Include: Add VMX MSR register structures

2016-11-29 Thread Michael Kinney
Add MSR_IA32_VMX_BASIC_REGISTER and IA32_VMX_MISC_REGISTER
structures with the bit fields for these two MSRs.   Also
add MSEG_HEADER structure whose base address is in the
MsegBase field of MSR_IA32_SMM_MONITOR_CTL_REGISTER.

Cc: Jiewen Yao 
Cc: Jeff Fan 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 UefiCpuPkg/Include/Register/ArchitecturalMsr.h | 224 -
 1 file changed, 219 insertions(+), 5 deletions(-)

diff --git a/UefiCpuPkg/Include/Register/ArchitecturalMsr.h 
b/UefiCpuPkg/Include/Register/ArchitecturalMsr.h
index 7de1c4b..a7a221d 100644
--- a/UefiCpuPkg/Include/Register/ArchitecturalMsr.h
+++ b/UefiCpuPkg/Include/Register/ArchitecturalMsr.h
@@ -19,6 +19,14 @@
   Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3,
   December 2015, Chapter 35 Model-Specific-Registers (MSR), Section 35-1.
 
+  @par Specification Reference:
+  Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3,
+  December 2015, Appendix A VMX Capability Reporting Facility, Section A.1.
+
+  @par Specification Reference:
+  Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3,
+  December 2015, Appendix A VMX Capability Reporting Facility, Section A.6.
+
 **/
 
 #ifndef __ARCHITECTURAL_MSR_H__
@@ -411,7 +419,7 @@ typedef union {
 
 
 /**
-  SMM Monitor Configuration (R/W). If CPUID.01H: ECX[5]=1. CPUID.01H: ECX[6] =
+  SMM Monitor Configuration (R/W). If CPUID.01H: ECX[5]=1 or CPUID.01H: ECX[6] 
=
   1.
 
   @param  ECX  MSR_IA32_SMM_MONITOR_CTL (0x009B)
@@ -471,6 +479,25 @@ typedef union {
   UINT64  Uint64;
 } MSR_IA32_SMM_MONITOR_CTL_REGISTER;
 
+/**
+  MSEG header that is located at the physical address specified by the MsegBase
+  field of #MSR_IA32_SMM_MONITOR_CTL_REGISTER.
+**/
+typedef struct {
+  UINT32  MsegHeaderRevision;
+  UINT32  MonitorFeatures;
+  UINT32  GdtrLimit;
+  UINT32  GdtrBaseOffset;
+  UINT32  CsSelector;
+  UINT32  EipOffset;
+  UINT32  EspOffset;
+  UINT32  Cr3Offset;
+  //
+  // Pad header so total size is 2KB
+  //
+  UINT8   Reserved[SIZE_2KB - 8 * sizeof (UINT32)];
+} MSEG_HEADER;
+
 
 /**
   Base address of the logical processor's SMRAM image (RO, SMM only). If
@@ -3681,14 +3708,119 @@ typedef union {
 
   Example usage
   @code
-  UINT64  Msr;
+  MSR_IA32_VMX_BASIC_REGISTER  Msr;
 
-  Msr = AsmReadMsr64 (MSR_IA32_VMX_BASIC);
+  Msr.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_BASIC);
   @endcode
   @note MSR_IA32_VMX_BASIC is defined as IA32_VMX_BASIC in SDM.
 **/
 #define MSR_IA32_VMX_BASIC   0x0480
 
+/**
+  MSR information returned for MSR index #MSR_IA32_VMX_BASIC
+**/
+typedef union {
+  ///
+  /// Individual bit fields
+  ///
+  struct {
+///
+/// [Bits 30:0] VMCS revision identifier used by the processor.  Processors
+/// that use the same VMCS revision identifier use the same size for VMCS
+/// regions (see subsequent item on bits 44:32).
+///
+/// @note Earlier versions of this manual specified that the VMCS revision
+/// identifier was a 32-bit field in bits 31:0 of this MSR. For all
+/// processors produced prior to this change, bit 31 of this MSR was read
+/// as 0.
+///
+UINT32  VmcsRevisonId:31;
+UINT32  MustBeZero:1;
+///
+/// [Bit 44:32] Reports the number of bytes that software should allocate
+/// for the VMXON region and any VMCS region.  It is a value greater than
+/// 0 and at most 4096(bit 44 is set if and only if bits 43:32 are clear).
+///
+UINT32  VmcsSize:13;
+UINT32  Reserved1:3;
+///
+/// [Bit 48] Indicates the width of the physical addresses that may be used
+/// for the VMXON region, each VMCS, and data structures referenced by
+/// pointers in a VMCS (I/O bitmaps, virtual-APIC page, MSR areas for VMX
+/// transitions).  If the bit is 0, these addresses are limited to the
+/// processor's physical-address width.  If the bit is 1, these addresses
+/// are limited to 32 bits. This bit is always 0 for processors that
+/// support Intel 64 architecture.
+///
+/// @note On processors that support Intel 64 architecture, the pointer
+/// must not set bits beyond the processor's physical address width.
+///
+UINT32  VmcsAddressWidth:1;
+///
+/// [Bit 49] If bit 49 is read as 1, the logical processor supports the
+/// dual-monitor treatment of system-management interrupts and
+/// system-management mode. See Section 34.15 for details of this 
treatment.
+///
+UINT32  DualMonitor:1;
+///
+/// [Bit 53:50] report the memory type that should be used for the VMCS,
+/// for data structures referenced by pointers in the VMCS (I/O bitmaps,
+/// virtual-APIC page, MSR areas for VMX transitions), and for the MSEG
+/// header. If software needs to access these data 

[edk2] [PATCH 3/3] UefiCpuPkg/CpuExceptionHandlerLib: remove un-used mReservedVectors

2016-11-29 Thread Jeff Fan
Cc: Feng Tian 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c | 5 ++---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h | 1 -
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c
index 5d28161..3d85b0c 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c
@@ -1,7 +1,7 @@
 /** @file
   CPU Exception Handler Library common functions.
 
-  Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2012 - 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
@@ -20,8 +20,7 @@
 //
 // 1 means an error code will be pushed, otherwise 0
 //
-CONST UINT32 mErrorCodeFlag = 0x00027d00;
-RESERVED_VECTORS_DATA *mReservedVectors = NULL;
+CONST UINT32 mErrorCodeFlag = 0x00027d00;
 
 //
 // Define the maximum message length
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index f2e4692..4639ed2 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -55,7 +55,6 @@ typedef struct {
 extern CONST UINT32mErrorCodeFlag;
 extern CONST UINTN mImageAlignSize;
 extern CONST UINTN mDoFarReturnFlag;
-extern RESERVED_VECTORS_DATA   *mReservedVectors;
 
 /**
   Return address map of exception handler template so that C code can generate
-- 
2.9.3.windows.2

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


[edk2] [PATCH 0/3] mReservedVectors is not set

2016-11-29 Thread Jeff Fan
mReservedVectors is used by ArchSaveExceptionContext() and 
ArchRestoreExceptionContext() to support HOOK_AFTER capability.
But it is not set to correct pointer. This is one regression issue when
we add PeiExcpetionHandlerLib.inf.

The fix is to add parameter ExceptionHandlerData for thoese 2 APIs and
not to use mReservedVectors.

Jeff Fan (3):
  UefiCpuPkg: Add ExceptionHandlerData for ArchSaveExceptionContext()
  UefiCpuPkg: Add ExceptionHandlerData for ArchRestoreExceptionContext()
  UefiCpuPkg/CpuExceptionHandlerLib: remove un-used mReservedVectors

 .../CpuExceptionHandlerLib/CpuExceptionCommon.c|  5 +-
 .../CpuExceptionHandlerLib/CpuExceptionCommon.h| 23 -
 .../Ia32/ArchExceptionHandler.c| 47 +++
 .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c |  4 +-
 .../X64/ArchExceptionHandler.c | 54 +-
 5 files changed, 76 insertions(+), 57 deletions(-)

-- 
2.9.3.windows.2

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


[edk2] [PATCH 2/3] UefiCpuPkg: Add ExceptionHandlerData for ArchRestoreExceptionContext()

2016-11-29 Thread Jeff Fan
mReservedVectors is not set, we could add parameter ExceptionHandlerData for
ArchRestoreExceptionContext() that could use it instead of mReservedVectors.

Cc: Feng Tian 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan 
---
 .../CpuExceptionHandlerLib/CpuExceptionCommon.h| 11 +-
 .../Ia32/ArchExceptionHandler.c| 21 +++---
 .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c |  2 +-
 .../X64/ArchExceptionHandler.c | 25 +-
 4 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index dc5d941..f2e4692 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -211,14 +211,15 @@ ArchSaveExceptionContext (
 /**
   Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER 
case.
 
-  @param[in] ExceptionType  Exception type.
-  @param[in] SystemContext  Pointer to EFI_SYSTEM_CONTEXT.
-
+  @param[in] ExceptionTypeException type.
+  @param[in] SystemContextPointer to EFI_SYSTEM_CONTEXT.
+  @param[in] ExceptionHandlerData Pointer to exception handler data.
 **/
 VOID
 ArchRestoreExceptionContext (
-  IN UINTNExceptionType,
-  IN EFI_SYSTEM_CONTEXT   SystemContext 
+  IN UINTNExceptionType,
+  IN EFI_SYSTEM_CONTEXT   SystemContext,
+  IN EXCEPTION_HANDLER_DATA   *ExceptionHandlerData
   );
 
 /**
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
index b96636b..7ab2438 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
@@ -87,19 +87,24 @@ ArchSaveExceptionContext (
 /**
   Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER 
case.
 
-  @param ExceptionType  Exception type.
-  @param SystemContext  Pointer to EFI_SYSTEM_CONTEXT.
+  @param[in] ExceptionTypeException type.
+  @param[in] SystemContextPointer to EFI_SYSTEM_CONTEXT.
+  @param[in] ExceptionHandlerData Pointer to exception handler data.
 **/
 VOID
 ArchRestoreExceptionContext (
-  IN UINTNExceptionType,
-  IN EFI_SYSTEM_CONTEXT   SystemContext 
+  IN UINTNExceptionType,
+  IN EFI_SYSTEM_CONTEXT   SystemContext,
+  IN EXCEPTION_HANDLER_DATA   *ExceptionHandlerData
   )
 {
-  SystemContext.SystemContextIa32->Eflags= 
mReservedVectors[ExceptionType].OldFlags;
-  SystemContext.SystemContextIa32->Cs= 
mReservedVectors[ExceptionType].OldCs;
-  SystemContext.SystemContextIa32->Eip   = 
mReservedVectors[ExceptionType].OldIp;
-  SystemContext.SystemContextIa32->ExceptionData = 
mReservedVectors[ExceptionType].ExceptionData;
+  RESERVED_VECTORS_DATA   *ReservedVectors;
+
+  ReservedVectors = ExceptionHandlerData->ReservedVectors;
+  SystemContext.SystemContextIa32->Eflags= 
ReservedVectors[ExceptionType].OldFlags;
+  SystemContext.SystemContextIa32->Cs= 
ReservedVectors[ExceptionType].OldCs;
+  SystemContext.SystemContextIa32->Eip   = 
ReservedVectors[ExceptionType].OldIp;
+  SystemContext.SystemContextIa32->ExceptionData = 
ReservedVectors[ExceptionType].ExceptionData;
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
index 483a417..c0fc9a6 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
@@ -68,7 +68,7 @@ CommonExceptionHandlerWorker (
 // Old IDT handler has been executed, then restore CPU exception 
content to
 // run new exception handler.
 //
-ArchRestoreExceptionContext (ExceptionType, SystemContext);
+ArchRestoreExceptionContext (ExceptionType, SystemContext, 
ExceptionHandlerData);
 //
 // Rlease spin lock for ApicId
 //
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
index f84b1a8..7495b14 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
@@ -90,21 +90,26 @@ ArchSaveExceptionContext (
 /**
   Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER 
case.
 
-  @param ExceptionType  Exception type.
-  @param SystemContext  Pointer to EFI_SYSTEM_CONTEXT.
+  

[edk2] [PATCH 1/3] UefiCpuPkg: Add ExceptionHandlerData for ArchSaveExceptionContext()

2016-11-29 Thread Jeff Fan
mReservedVectors is not set, we could add parameter ExceptionHandlerData for
ArchSaveExceptionContext() that could use it instead of mReservedVectors.

Cc: Feng Tian 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan 
---
 .../CpuExceptionHandlerLib/CpuExceptionCommon.h| 11 
 .../Ia32/ArchExceptionHandler.c| 26 +++
 .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c |  2 +-
 .../X64/ArchExceptionHandler.c | 29 +-
 4 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index 9c88012..dc5d941 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -197,14 +197,15 @@ UpdateIdtTable (
 /**
   Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.
 
-  @param[in] ExceptionType  Exception type.
-  @param[in] SystemContext  Pointer to EFI_SYSTEM_CONTEXT.
-
+  @param[in] ExceptionTypeException type.
+  @param[in] SystemContextPointer to EFI_SYSTEM_CONTEXT.
+  @param[in] ExceptionHandlerData Pointer to exception handler data.
 **/
 VOID
 ArchSaveExceptionContext (
-  IN UINTNExceptionType,
-  IN EFI_SYSTEM_CONTEXT   SystemContext 
+  IN UINTNExceptionType,
+  IN EFI_SYSTEM_CONTEXT   SystemContext,
+  IN EXCEPTION_HANDLER_DATA   *ExceptionHandlerData
   );
 
 /**
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
index 7a183bf..b96636b 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
@@ -1,7 +1,7 @@
 /** @file
   IA32 CPU Exception Handler functons.
 
-  Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2012 - 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
@@ -50,24 +50,28 @@ ArchGetIdtHandler (
 /**
   Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case.
 
-  @param ExceptionType  Exception type.
-  @param SystemContext  Pointer to EFI_SYSTEM_CONTEXT.
-
+  @param[in] ExceptionTypeException type.
+  @param[in] SystemContextPointer to EFI_SYSTEM_CONTEXT.
+  @param[in] ExceptionHandlerData Pointer to exception handler data.
 **/
 VOID
 ArchSaveExceptionContext (
-  IN UINTNExceptionType,
-  IN EFI_SYSTEM_CONTEXT   SystemContext 
+  IN UINTNExceptionType,
+  IN EFI_SYSTEM_CONTEXT   SystemContext,
+  IN EXCEPTION_HANDLER_DATA   *ExceptionHandlerData
   )
 {
   IA32_EFLAGS32   Eflags;
+  RESERVED_VECTORS_DATA   *ReservedVectors;
+
+  ReservedVectors = ExceptionHandlerData->ReservedVectors;
   //
   // Save Exception context in global variable
   //
-  mReservedVectors[ExceptionType].OldFlags  = 
SystemContext.SystemContextIa32->Eflags;
-  mReservedVectors[ExceptionType].OldCs = 
SystemContext.SystemContextIa32->Cs;
-  mReservedVectors[ExceptionType].OldIp = 
SystemContext.SystemContextIa32->Eip;
-  mReservedVectors[ExceptionType].ExceptionData = 
SystemContext.SystemContextIa32->ExceptionData;
+  ReservedVectors[ExceptionType].OldFlags  = 
SystemContext.SystemContextIa32->Eflags;
+  ReservedVectors[ExceptionType].OldCs = 
SystemContext.SystemContextIa32->Cs;
+  ReservedVectors[ExceptionType].OldIp = 
SystemContext.SystemContextIa32->Eip;
+  ReservedVectors[ExceptionType].ExceptionData = 
SystemContext.SystemContextIa32->ExceptionData;
   //
   // Clear IF flag to avoid old IDT handler enable interrupt by IRET
   //
@@ -77,7 +81,7 @@ ArchSaveExceptionContext (
   //
   // Modify the EIP in stack, then old IDT handler will return to the stub code
   //
-  SystemContext.SystemContextIa32->Eip= (UINTN) 
mReservedVectors[ExceptionType].HookAfterStubHeaderCode;
+  SystemContext.SystemContextIa32->Eip= (UINTN) 
ReservedVectors[ExceptionType].HookAfterStubHeaderCode;
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
index e55709c..483a417 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
@@ -55,7 +55,7 @@ CommonExceptionHandlerWorker (
 // Need to 

[edk2] [Patch 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove MTRRs from PSD structure

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=277

All CPUs use the same MTRR settings.  Move MTRR settings
from a field in the PROCESSOR_SMM_DESCRIPTOR structure into
a module global variable.

Cc: Jiewen Yao 
Cc: Jeff Fan 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  | 18 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h |  2 +-
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index cfbf59e..6dc9607 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 //
 // Slots for all MTRR( FIXED MTRR + VARIABLE MTRR + 
MTRR_LIB_IA32_MTRR_DEF_TYPE)
 //
-UINT64  
gSmiMtrrs[MTRR_NUMBER_OF_FIXED_MTRR + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
+MTRR_SETTINGS   gSmiMtrrs;
 UINT64  gPhyMask;
 SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData = NULL;
 UINTN   mSmmMpSyncDataSize;
@@ -283,20 +283,12 @@ ReplaceOSMtrrs (
   IN  UINTN CpuIndex
   )
 {
-  PROCESSOR_SMM_DESCRIPTOR   *Psd;
-  UINT64 *SmiMtrrs;
-  MTRR_SETTINGS  *BiosMtrr;
-
-  Psd = (PROCESSOR_SMM_DESCRIPTOR*)(mCpuHotPlugData.SmBase[CpuIndex] + 
SMM_PSD_OFFSET);
-  SmiMtrrs = (UINT64*)(UINTN)Psd->MtrrBaseMaskPtr;
-
   SmmCpuFeaturesDisableSmrr ();
 
   //
   // Replace all MTRRs registers
   //
-  BiosMtrr  = (MTRR_SETTINGS*)SmiMtrrs;
-  MtrrSetAllMtrrs(BiosMtrr);
+  MtrrSetAllMtrrs ();
 }
 
 /**
@@ -1376,7 +1368,6 @@ InitializeMpServiceData (
 {
   UINT32Cr3;
   UINTN Index;
-  MTRR_SETTINGS *Mtrr;
   PROCESSOR_SMM_DESCRIPTOR  *Psd;
   UINT8 *GdtTssTables;
   UINTN GdtTableStepSize;
@@ -1439,9 +1430,8 @@ InitializeMpServiceData (
   //
   // Record current MTRR settings
   //
-  ZeroMem(gSmiMtrrs, sizeof (gSmiMtrrs));
-  Mtrr =  (MTRR_SETTINGS*)gSmiMtrrs;
-  MtrrGetAllMtrrs (Mtrr);
+  ZeroMem (, sizeof (gSmiMtrrs));
+  MtrrGetAllMtrrs ();
 
   return Cr3;
 }
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index abe5cc6..bd6abf2 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -380,7 +380,7 @@ typedef struct {
   UINT16Reserved11; // Offset 0x50
   UINT16Reserved12; // Offset 0x52
   UINT32Reserved13; // Offset 0x54
-  UINT64MtrrBaseMaskPtr;// Offset 0x58
+  UINT64Reserved14; // Offset 0x58
 } PROCESSOR_SMM_DESCRIPTOR;
 
 
-- 
2.6.3.windows.1

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


[edk2] [Patch 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce use of PSD

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=277

Remove MtrrBaseMaskPtr field from PSD and move MTRR to a
global variable since all CPUs use the same MTRR settings.
Reduce use of PSD to allow alternate SmmCpuFeaturesLib
implementations to use their own PSD layouts.

Cc: Jiewen Yao 
Cc: Jeff Fan 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 

Michael Kinney (2):
  UefiCpuPkg/PiSmmCpuDxeSmm: Remove MTRRs from PSD structure
  UefiCpuPkg/PiSmmCpuDxeSmm: Remove PSD layout assumptions

 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S  |  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm|  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm   |  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  | 33 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 15 
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 26 --
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c |  2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 40 +-
 8 files changed, 64 insertions(+), 61 deletions(-)

-- 
2.6.3.windows.1

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


[edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove PSD layout assumptions

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=277

Remove dependency on layout of PROCESSOR_SMM_DESCRIPTOR
everywhere possible.  The only exception is the standard
SMI entry handler template that is included with the
PiSmmCpuDxeSmm module.  This allows an instance of the
SmmCpuFeaturesLib to provide alternate
PROCESSOR_SMM_DESCRIPTOR structure layouts.

Cc: Jiewen Yao 
Cc: Jeff Fan 
Cc: Feng Tian 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S  |  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm|  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm   |  3 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  | 15 ++--
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 15 
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 26 --
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c |  2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 40 +-
 8 files changed, 60 insertions(+), 47 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
index 0c07558..378e065 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
@@ -31,6 +31,9 @@ ASM_GLOBAL  ASM_PFX(gSmiHandlerIdtr)
 .equMSR_EFER, 0xc080
 .equMSR_EFER_XD, 0x800
 
+#
+# Constants relating to PROCESSOR_SMM_DESCRIPTOR
+#
 .equDSC_OFFSET, 0xfb00
 .equDSC_GDTPTR, 0x30
 .equDSC_GDTSIZ, 0x38
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
index eda1708..a4f4dcb 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
@@ -26,6 +26,9 @@ MSR_IA32_MISC_ENABLE  EQU 1A0h
 MSR_EFER  EQU 0c080h
 MSR_EFER_XD   EQU 0800h
 
+;
+; Constants relating to PROCESSOR_SMM_DESCRIPTOR
+;
 DSC_OFFSETEQU 0fb00h
 DSC_GDTPTREQU 30h
 DSC_GDTSIZEQU 38h
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
index d50a317..4d2383f 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
@@ -22,6 +22,9 @@
 %define MSR_EFER  0xc080
 %define MSR_EFER_XD   0x800
 
+;
+; Constants relating to PROCESSOR_SMM_DESCRIPTOR
+;
 %define DSC_OFFSET 0xfb00
 %define DSC_GDTPTR 0x30
 %define DSC_GDTSIZ 0x38
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 6dc9607..35bd37c 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -1368,7 +1368,6 @@ InitializeMpServiceData (
 {
   UINT32Cr3;
   UINTN Index;
-  PROCESSOR_SMM_DESCRIPTOR  *Psd;
   UINT8 *GdtTssTables;
   UINTN GdtTableStepSize;
 
@@ -1403,24 +1402,16 @@ InitializeMpServiceData (
   GdtTssTables = InitGdt (Cr3, );
 
   //
-  // Initialize PROCESSOR_SMM_DESCRIPTOR for each CPU
+  // Install SMI handler for each CPU
   //
   for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
-Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID 
*)(UINTN)(mCpuHotPlugData.SmBase[Index] + SMM_PSD_OFFSET);
-CopyMem (Psd, , sizeof (gcPsd));
-Psd->SmmGdtPtr = (UINT64)(UINTN)(GdtTssTables + GdtTableStepSize * Index);
-Psd->SmmGdtSize = gcSmiGdtr.Limit + 1;
-
-//
-// Install SMI handler
-//
 InstallSmiHandler (
   Index,
   (UINT32)mCpuHotPlugData.SmBase[Index],
   (VOID*)((UINTN)Stacks + (StackSize * Index)),
   StackSize,
-  (UINTN)Psd->SmmGdtPtr,
-  Psd->SmmGdtSize,
+  (UINTN)(GdtTssTables + GdtTableStepSize * Index),
+  gcSmiGdtr.Limit + 1,
   gcSmiIdtr.Base,
   gcSmiIdtr.Limit + 1,
   Cr3
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index f957de1..4bef60a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -711,22 +711,23 @@ PiCpuSmmEntry (
 
   //
   // Compute tile size of buffer required to hold the CPU SMRAM Save State 
Map, extra CPU
-  // specific context in a PROCESSOR_SMM_DESCRIPTOR, and the SMI entry point.  
This size
-  // is rounded up to nearest power of 2.
+  // specific context start starts at SMBASE + SMM_PSD_OFFSET, and the SMI 
entry point.
+  // This size is rounded up to nearest power of 2.
   //
   TileCodeSize = GetSmiHandlerSize ();
   TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB);
-  TileDataSize = sizeof (SMRAM_SAVE_STATE_MAP) + sizeof 
(PROCESSOR_SMM_DESCRIPTOR);
+  TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - SMM_PSD_OFFSET) + sizeof 
(SMRAM_SAVE_STATE_MAP);
   TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB);
   

Re: [edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6 command.

2016-11-29 Thread Wu, Jiaxin
Reviewed by : Wu Jiaxin 


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Zhang Lubo
> Sent: Tuesday, November 29, 2016 10:58 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Wu,
> Jiaxin 
> Subject: [edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6
> command.
> 
> v2: update the prompt message more readable.
> 
> It should display error prompt message when Ifconfig6 can not configure
> correctly.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Wu Jiaxin 
> ---
>  ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 15
> +++
>  .../UefiShellNetwork2CommandsLib.uni  |  9 +
>  2 files changed, 24 insertions(+)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> index 32dd284..fb308cc 100644
> --- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> +++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> @@ -1315,10 +1315,24 @@ IfConfig6SetInterfaceInfo (
>  goto ON_EXIT;
>}
> 
>VarArg= VarArg->Next;
> 
> +  if (StrCmp (VarArg->Arg, L"host") == 0) {
> +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle,
> Status);
> +ShellStatus = EFI_INVALID_PARAMETER;
> +goto ON_EXIT;
> +  } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
> +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle,
> Status);
> +ShellStatus = EFI_INVALID_PARAMETER;
> +goto ON_EXIT;
> +  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
> +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle,
> Status);
> +ShellStatus = EFI_INVALID_PARAMETER;
> +goto ON_EXIT;
> +  }
> +
>  } else if (StrCmp (VarArg->Arg, L"man") == 0) {
>//
>// Set manual config policy.
>//
>Policy = Ip6ConfigPolicyManual;
> @@ -1509,10 +1523,11 @@ IfConfig6SetInterfaceInfo (
>CfgAddr
>);
> 
>if (EFI_ERROR (Status)) {
>  ShellStatus = SHELL_ACCESS_DENIED;
> +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> + (STR_IFCONFIG6_ERR_MAN_GW), gShellNetwork2HiiHandle, Status);
>  goto ON_EXIT;
>}
> 
>  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
>//
> diff --git
> a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Com
> mandsLib.uni
> b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Com
> mandsLib.uni
> index c3445bb..79af7f9 100644
> ---
> a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Com
> mandsLib.uni
> +++
> b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Com
> +++ mandsLib.uni
> @@ -75,10 +75,19 @@
>  #string STR_IFCONFIG6_ERR_LACK_ARGUMENTS   #language en-US
> "Lack arguments. Bad command %H%s%N is skipped.\r\n"
>"Hint: 
> Please type 'IfConfig6 -?' for help
> info.\r\n"
>  #string STR_IFCONFIG6_ERR_LACK_OPTION  #language en-US"Lack
> options.\r\n"
>"Hint: 
> Please type 'IfConfig6 -?' for help
> info.\r\n"
>  #string STR_IFCONFIG6_ERR_MAN_HOST #language en-US"Manual
> address configuration failed. Please retry.\r\n"
> +
> +#string STR_IFCONFIG6_ERR_MAN_GW   #language en-US"Getway
> address configuration failed. Please check the argument.\r\n"
> +
> +#string STR_IFCONFIG6_ERR_INVALID_IP_CONFIG#language en-US
> "The IP address is not configurable when the policy is
> Ip6ConfigPolicyAutomatic.\r\n"
> +
> +#string STR_IFCONFIG6_ERR_INVALID_GW_CONFIG#language en-US
> "The gateway address is not configurable when the policy is
> Ip6ConfigPolicyAutomatic.\r\n"
> +
> +#string STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG   #language en-US
> "The DNS server address is not configurable when the policy is
> Ip6ConfigPolicyAutomatic.\r\n"
> +
>  #string STR_IFCONFIG6_ERR_DUPLICATE_COMMAND#language en-US
> "Duplicate commands. Bad command %H%s%N is skipped.\r\n"
>"Hint: 
> Please type 'IfConfig6 -?' for help
> info.\r\n"
>  #string STR_IFCONFIG6_ERR_CONFLICT_COMMAND #language en-US
> "Conflict commands. Bad command %H%s%N is skipped.\r\n"
>"Hint: 
> Please type 'IfConfig6 -?' for help
> info.\r\n"
>  

Re: [edk2] [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the unused buf

2016-11-29 Thread Ye, Ting
Reviewed-by: Ye Ting  

-Original Message-
From: Wu, Jiaxin 
Sent: Wednesday, November 30, 2016 10:26 AM
To: edk2-devel@lists.01.org
Cc: Fu, Siyuan ; Ye, Ting ; Zhang, Lubo 

Subject: [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the unused 
buf

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/IpSecDxe/Ikev2/Payload.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/NetworkPkg/IpSecDxe/Ikev2/Payload.c 
b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
index 675ecf6..f32b3a8 100644
--- a/NetworkPkg/IpSecDxe/Ikev2/Payload.c
+++ b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
@@ -655,11 +655,10 @@ Ikev2CertGenerateAuthPayload (
   )
 {
   UINT8  *Digest;
   UINTN  DigestSize;
   PRF_DATA_FRAGMENT  Fragments[3];
-  UINT8  *KeyBuf;
   IKE_PAYLOAD*AuthPayload;
   IKEV2_AUTH *PayloadBuf;
   EFI_STATUS Status;
   UINT8  *Signature;
   UINTN  SigSize;
@@ -680,11 +679,10 @@ Ikev2CertGenerateAuthPayload (
   //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   //
   //
   // Initial point
   //
-  KeyBuf  = NULL;
   AuthPayload = NULL;
   Digest  = NULL;
   Signature   = NULL;
   SigSize = 0;
 
@@ -696,21 +694,10 @@ Ikev2CertGenerateAuthPayload (
   if (Digest == NULL) {
 return NULL;
   }
 
   //
-  // Store the AuthKey into KeyBuf
-  //
-  KeyBuf  = AllocateZeroPool (DigestSize);
-  if (KeyBuf == NULL) {
-Status = EFI_OUT_OF_RESOURCES;
-goto EXIT;
-  }
-  
-  CopyMem (KeyBuf, Digest, DigestSize);
-
-  //
   // Calculate Prf(SK_Pi/r, IDi/r)
   //
   Fragments[0].Data = IdPayload->PayloadBuf + sizeof 
(IKEV2_COMMON_PAYLOAD_HEADER);
   Fragments[0].DataSize = IdPayload->PayloadSize - sizeof 
(IKEV2_COMMON_PAYLOAD_HEADER);
 
@@ -861,13 +848,10 @@ Ikev2CertGenerateAuthPayload (
   //
   AuthPayload->PayloadBuf   = (UINT8 *) PayloadBuf;
   AuthPayload->PayloadType  = IKEV2_PAYLOAD_TYPE_AUTH;
 
 EXIT:
-  if (KeyBuf != NULL) {
-FreePool (KeyBuf);
-  }
   if (Digest != NULL) {
 FreePool (Digest);
   }
   if (Signature != NULL) {
 FreePool (Signature);
@@ -1490,11 +1474,11 @@ Ikev2ParserNotifyCookiePayload (
   @param[in]  CertificateLenThe length of Certificate in byte.
   @param[in]  EncodeTypeSpecified the Certificate Encodeing which is 
defined
 in RFC 4306.
   @param[in]  IsRequest To indicate create Certificate Payload or 
Certificate
 Request Payload. If it is TURE, create 
Certificate
-Payload. Otherwise, create Certificate Request 
Payload.
+Request Payload. Otherwise, create Certificate 
Payload.
 
   @retval  a Pointer to IKE Payload whose payload buffer containing the 
Certificate
payload or Certificated Request payload.
 
 **/
-- 
1.9.5.msysgit.1

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


Re: [edk2] [PATCH] UefiCpuPkg:PiSmmCpu: Set correct attribute on split.

2016-11-29 Thread Yao, Jiewen
How about this:


UefiCpuPkg/PiSmmCpu: relax superpage protection on page split.

PiSmmCpu driver may split page for page attribute request.
Current logic not only propagates the super page attribute to
the leaf page attribut, but also to the directory page attribute.

However, the later might be wrong because we cannot clear protection
without touching directory page attribute.
The effective protection is the strictest combination
across the levels.

We should always clear protection on directory page and set
protection on leaf page for easy clearing later.


Thank you
Yao Jiewen

From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yao, 
Jiewen
Sent: Wednesday, November 30, 2016 9:48 AM
To: Laszlo Ersek ; edk2-de...@ml01.01.org
Cc: Kinney, Michael D ; Fan, Jeff 

Subject: Re: [edk2] [PATCH] UefiCpuPkg:PiSmmCpu: Set correct attribute on split.

Comments below:

From: Laszlo Ersek [mailto:ler...@redhat.com]
Sent: Wednesday, November 30, 2016 5:54 AM
To: Yao, Jiewen >; 
edk2-de...@ml01.01.org
Cc: Kinney, Michael D 
>; Fan, Jeff 
>
Subject: Re: [edk2] [PATCH] UefiCpuPkg:PiSmmCpu: Set correct attribute on split.

On 11/29/16 08:39, Jiewen Yao wrote:
> PiSmmCpu driver may split page for page attribute request.
> Current logic will propagate the super page attribute attribute.
> However, it might be wrong because we cannot clear protection
> without touch super page attribute.
>
> We should always clear protection on super page and set
> protection on end page for easy clear later.
>
> Cc: Jeff Fan 
> >>
> Cc: Michael D Kinney 
> >>
> Cc: Laszlo Ersek 
> >>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> >>
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> index accc11e..d0f41a8 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> @@ -303,7 +303,7 @@ SplitPage (
>for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) {
>  NewPageEntry[Index] = BaseAddress + SIZE_4KB * Index + ((*PageEntry) 
> & PAGE_PROGATE_BITS);
>}
> -  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + ((*PageEntry) & 
> PAGE_PROGATE_BITS);
> +  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + PAGE_ATTRIBUTE_BITS;
>return RETURN_SUCCESS;
>  } else {
>return RETURN_UNSUPPORTED;
> @@ -324,7 +324,7 @@ SplitPage (
>for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) {
>  NewPageEntry[Index] = BaseAddress + SIZE_2MB * Index + IA32_PG_PS + 
> ((*PageEntry) & PAGE_PROGATE_BITS);
>}
> -  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + ((*PageEntry) & 
> PAGE_PROGATE_BITS);
> +  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + PAGE_ATTRIBUTE_BITS;
>return RETURN_SUCCESS;
>  } else {
>return RETURN_UNSUPPORTED;
>

I had to stare a while at this, to get a superficial understanding :)
But, it does seem to make sense (I checked PAGE_ATTRIBUTE_BITS and
PAGE_PROGATE_BITS too, just to be sure). So, this change preserves the
protection inheritance for the leaf pages, but clears NX and sets Dirty
/ Accessed / Writeable / Present on the relevant parent entry. (I see
hat User mode access is enabled as well; I don't know why that is useful
here.)
[Jiewen] Yes. You are right.

Some notes about the commit message:

- we have "attribute attribute". I think we should either drop one of
those words, or say "super page attribute to leaf page attribute".
[Jiewen] Agree. I will update.

- "end page" might be more clearly stated as "leaf page" (just a guess)
[Jiewen] Agree. I will update.

- I think it would be useful to mention, for the uninitiated like me :),
that the effective protection is (apparently) the strictest combination
across the levels.
[Jiewen] Agree. I will update.

- What do you think of the following subject line?
UefiCpuPkg/PiSmmCpuDxeSmm: relax superpage protection on page split
[Jiewen] Agree. I will update.

Anyway, to the extent that I understand this, I agree:

Acked-by: Laszlo Ersek 

Re: [edk2] [patch] MdeModulePkg/Ehci: don't clear port status bits during init

2016-11-29 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Tian, Feng 
Sent: Wednesday, November 30, 2016 1:16 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Mike Turner 
Subject: [patch] MdeModulePkg/Ehci: don't clear port status bits during init

Port status bits are clear in original code, so no enumeration takes place.
Changing this to prevent the status bits from being cleared allows enumeration 
to proceed normally.

Cc: Star Zeng 
Cc: Mike Turner 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Mike Turner 
Signed-off-by: Feng Tian 
---
 MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c | 10 +-  
MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c | 18 +-
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c 
b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
index 88a66ae..3a6ed02 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
@@ -591,6 +591,7 @@ EhcInitHC (
 {
   EFI_STATUS  Status;
   UINT32  Index;
+  UINT32  RegVal;
 
   // This ASSERT crashes the BeagleBoard. There is some issue in the USB stack.
   // This ASSERT needs to be removed so the BeagleBoard will boot. When we fix 
@@ -626,7 +627,14 @@ EhcInitHC (
   //
   if (Ehc->HcStructParams & HCSP_PPC) {
 for (Index = 0; Index < (UINT8) (Ehc->HcStructParams & HCSP_NPORTS); 
Index++) {
-  EhcSetOpRegBit (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * Index)), 
PORTSC_POWER);
+  //
+  // Do not clear port status bits on initialization.  Otherwise devices 
will
+  // not enumerate properly at startup.
+  //
+  RegVal  = EhcReadOpReg(Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * 
Index)));
+  RegVal &= ~PORTSC_CHANGE_MASK;
+  RegVal |= PORTSC_POWER;
+  EhcWriteOpReg (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * 
+ Index)), RegVal);
 }
   }
 
diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c 
b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
index 09769ea..31647ff 100644
--- a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
+++ b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
@@ -2,7 +2,7 @@
 PEIM to produce gPeiUsb2HostControllerPpiGuid based on 
gPeiUsbControllerPpiGuid  which is used to enable recovery function from USB 
Drivers.
 
-Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
   
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions @@ -411,12 +411,20 @@ EhcPowerOnAllPorts (
   IN PEI_USB2_HC_DEV  *Ehc
   )
 {
-  UINT8 PortNumber;
-  UINT8 Index;
-
+  UINT8 PortNumber;
+  UINT8 Index;
+  UINT32RegVal;
+  
   PortNumber = (UINT8)(Ehc->HcStructParams & HCSP_NPORTS);
   for (Index = 0; Index < PortNumber; Index++) {
-EhcSetOpRegBit (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, PORTSC_POWER);
+//
+// Do not clear port status bits on initialization.  Otherwise devices will
+// not enumerate properly at startup.
+//
+RegVal  = EhcReadOpReg(Ehc, EHC_PORT_STAT_OFFSET + 4 * Index);
+RegVal &= ~PORTSC_CHANGE_MASK;
+RegVal |= PORTSC_POWER;
+EhcWriteOpReg (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, RegVal);
   }
 }
 
--
2.7.1.windows.2

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


[edk2] [patch] MdeModulePkg/Ehci: don't clear port status bits during init

2016-11-29 Thread Feng Tian
Port status bits are clear in original code, so no enumeration
takes place.
Changing this to prevent the status bits from being cleared
allows enumeration to proceed normally.

Cc: Star Zeng 
Cc: Mike Turner 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Mike Turner 
Signed-off-by: Feng Tian 
---
 MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c | 10 +-
 MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c | 18 +-
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c 
b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
index 88a66ae..3a6ed02 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
@@ -591,6 +591,7 @@ EhcInitHC (
 {
   EFI_STATUS  Status;
   UINT32  Index;
+  UINT32  RegVal;
 
   // This ASSERT crashes the BeagleBoard. There is some issue in the USB stack.
   // This ASSERT needs to be removed so the BeagleBoard will boot. When we fix
@@ -626,7 +627,14 @@ EhcInitHC (
   //
   if (Ehc->HcStructParams & HCSP_PPC) {
 for (Index = 0; Index < (UINT8) (Ehc->HcStructParams & HCSP_NPORTS); 
Index++) {
-  EhcSetOpRegBit (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * Index)), 
PORTSC_POWER);
+  //
+  // Do not clear port status bits on initialization.  Otherwise devices 
will
+  // not enumerate properly at startup.
+  //
+  RegVal  = EhcReadOpReg(Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * 
Index)));
+  RegVal &= ~PORTSC_CHANGE_MASK;
+  RegVal |= PORTSC_POWER;
+  EhcWriteOpReg (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * Index)), 
RegVal);
 }
   }
 
diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c 
b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
index 09769ea..31647ff 100644
--- a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
+++ b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
@@ -2,7 +2,7 @@
 PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid
 which is used to enable recovery function from USB Drivers.
 
-Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
   
 This program and the accompanying materials
 are licensed and made available under the terms and conditions
@@ -411,12 +411,20 @@ EhcPowerOnAllPorts (
   IN PEI_USB2_HC_DEV  *Ehc
   )
 {
-  UINT8 PortNumber;
-  UINT8 Index;
-
+  UINT8 PortNumber;
+  UINT8 Index;
+  UINT32RegVal;
+  
   PortNumber = (UINT8)(Ehc->HcStructParams & HCSP_NPORTS);
   for (Index = 0; Index < PortNumber; Index++) {
-EhcSetOpRegBit (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, PORTSC_POWER);
+//
+// Do not clear port status bits on initialization.  Otherwise devices will
+// not enumerate properly at startup.
+//
+RegVal  = EhcReadOpReg(Ehc, EHC_PORT_STAT_OFFSET + 4 * Index);
+RegVal &= ~PORTSC_CHANGE_MASK;
+RegVal |= PORTSC_POWER;
+EhcWriteOpReg (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, RegVal);
   }
 }
 
-- 
2.7.1.windows.2

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


[edk2] [Patch 2/4] Vlv2TbltDevicePkg: Fix SOURCE_DEBUG_ENABLE feature

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=276

Fix library mapping and PCD settings required to use
the SOURCE_DEBUG_ENABLE feature in PEI, DXE, and SMM.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 13 ++---
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc  | 22 --
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 3a5776a..4093797 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -338,8 +338,7 @@
 
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf
   
HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
-  
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
-  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
 
  !if $(MINNOW2_FSP_BUILD) == TRUE
  PlatformFspLib|Vlv2TbltDevicePkg/Library/PlatformFspLib/PlatformFspLib.inf
@@ -439,11 +438,6 @@
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !endif
 
-!if $(SOURCE_DEBUG_ENABLE) == TRUE
-  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
-  
TimerLib|$(PLATFORM_PACKAGE)/Library/IntelPchAcpiTimerLib/IntelPchAcpiTimerLib.inf
-!endif
-
 [LibraryClasses.IA32.DXE_RUNTIME_DRIVER]
   
ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf
 !if $(SECURE_BOOT_ENABLE) == TRUE
@@ -616,6 +610,10 @@
 
   gEfiCpuTokenSpaceGuid.PcdCpuSmmBlockStartupThisAp|TRUE
 
+!if $(SOURCE_DEBUG_ENABLE)
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmDebug|TRUE
+!endif
+
 [PcdsFixedAtBuild.common]
 !if $(MINNOW2_FSP_BUILD) == TRUE
 # $(FLASH_REGION_VLVMICROCODE_BASE)
@@ -694,6 +692,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl|FALSE
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|2
 !endif
 
 [PcdsFixedAtBuild.IA32.PEIM, PcdsFixedAtBuild.IA32.PEI_CORE, 
PcdsFixedAtBuild.IA32.SEC]
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index f2f594c..c91ff9f 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -338,8 +338,7 @@
 
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf
   
HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
-  
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
-  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
 
  !if $(MINNOW2_FSP_BUILD) == TRUE
  PlatformFspLib|Vlv2TbltDevicePkg/Library/PlatformFspLib/PlatformFspLib.inf
@@ -439,11 +438,6 @@
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !endif
 
-!if $(SOURCE_DEBUG_ENABLE) == TRUE
-  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
-  
TimerLib|$(PLATFORM_PACKAGE)/Library/IntelPchAcpiTimerLib/IntelPchAcpiTimerLib.inf
-!endif
-
 [LibraryClasses.X64.DXE_RUNTIME_DRIVER]
   
ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf
 !if $(SECURE_BOOT_ENABLE) == TRUE
@@ -616,6 +610,10 @@
 
   gEfiCpuTokenSpaceGuid.PcdCpuSmmBlockStartupThisAp|TRUE
 
+!if $(SOURCE_DEBUG_ENABLE)
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmDebug|TRUE
+!endif
+
 [PcdsFixedAtBuild.common]
 !if $(MINNOW2_FSP_BUILD) == TRUE
 # $(FLASH_REGION_VLVMICROCODE_BASE)
@@ -694,6 +692,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl|FALSE
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|2
 !endif
 
 [PcdsFixedAtBuild.IA32.PEIM, PcdsFixedAtBuild.IA32.PEI_CORE, 
PcdsFixedAtBuild.IA32.SEC]
@@ -1152,9 +1151,12 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
 !if $(CAPSULE_ENABLE) == TRUE
   MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf {
 
-PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
-
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+!if 

[edk2] [Patch 3/4] Vlv2TbltDevicePkg/PlatformBdsLib: Add DebugAgent Console

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=276

Add the UART console produced by the DebugAgent when
SOURCE_DEBUG_ENABLE is TRUE.  Without this change, the
debugger connects but the Boot Manager and the UEFI
Shell do not have an active console because the Boot
Manager does not know about the DebugAgent UART
Console device path and the Debug Agent is using the
UART device.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 .../Library/PlatformBdsLib/BdsPlatform.h   | 13 +-
 .../Library/PlatformBdsLib/PlatformBdsLib.inf  |  1 +
 .../Library/PlatformBdsLib/PlatformData.c  | 48 +-
 3 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.h 
b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.h
index d757243..807094f 100644
--- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.h
+++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.h
@@ -1,6 +1,6 @@
 /*++
 
-  Copyright (c) 2004  - 2014, 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 that accompanies this 
distribution.  

@@ -46,6 +46,7 @@ Abstract:
 #include 
 #include 
 #include 
+#include 
 
 
 #include 
@@ -281,6 +282,16 @@ typedef struct {
 } PLATFORM_USB_DEVICE_PATH;
 
 //
+// Debug Agent UART Console device path definition
+//
+typedef struct {
+  VENDOR_DEVICE_PATHVendorHardware;
+  UART_DEVICE_PATH  Uart;
+  VENDOR_DEVICE_PATHTerminalType;
+  EFI_DEVICE_PATH_PROTOCOL  End;
+} VENDOR_UART_DEVICE_PATH;
+
+//
 // Below is the platform PCI device path
 //
 typedef struct {
diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf 
b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf
index 3e45a31..7512556 100644
--- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf
+++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf
@@ -50,6 +50,7 @@
   CryptoPkg/CryptoPkg.dec
   SecurityPkg/SecurityPkg.dec
   SignedCapsulePkg/SignedCapsulePkg.dec
+  SourceLevelDebugPkg/SourceLevelDebugPkg.dec
 
 [LibraryClasses]
   DxeServicesTableLib
diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformData.c 
b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformData.c
index 64e68d3..45bd32d 100644
--- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformData.c
+++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformData.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2004  - 2014, 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 that accompanies this 
distribution.  

@@ -119,12 +119,57 @@ USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath 
= {
 };
 
 //
+// Debug Agent UART Console device path 
+//
+VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
+  {
+{
+  HARDWARE_DEVICE_PATH,
+  HW_VENDOR_DP,
+  {
+(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
+(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+  }
+},
+EFI_DEBUG_AGENT_GUID,
+  },
+  {
+{
+  MESSAGING_DEVICE_PATH,
+  MSG_UART_DP,
+  {
+(UINT8) (sizeof (UART_DEVICE_PATH)),
+(UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+  }
+},
+0,  // Reserved
+0,  // BaudRate - Default
+0,  // DataBits - Default
+0,  // Parity   - Default
+0,  // StopBits - Default
+  },
+  {
+{
+  MESSAGING_DEVICE_PATH,
+  MSG_VENDOR_DP,
+  {
+(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+  }
+},
+DEVICE_PATH_MESSAGING_PC_ANSI
+  },
+  gEndEntire
+};
+
+//
 // Predefined platform default console device path
 //
 BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole [] = {
   {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_ALL},
   {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_IN},
   {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_IN},
+  {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_ALL},
   {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_IN},
   {NULL, 0}
 };
@@ -242,6 +287,7 @@ BDS_CONSOLE_CONNECT_ENTRY gPlatformSimpleConsole [] = {
   {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_OUT},
   {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_ALL},
   {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_IN},
+  {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_ALL},
   {(EFI_DEVICE_PATH_PROTOCOL*), CONSOLE_IN},
   {NULL, 0}
 };
-- 
2.6.3.windows.1


[edk2] [Patch 4/4] Vlv2TbltDevicePkg: Update PlatformPkgGccX64.dsc

2016-11-29 Thread Michael Kinney
Update PlatformPkgGccX64.dsc to align with PlatformPkgX64.dsc
on library mappings and PCD settings.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 73 +++--
 1 file changed, 33 insertions(+), 40 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index 808facf..1c7a71b 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -227,8 +227,8 @@
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
 !else
-  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
-  SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  SerialPortLib|$(PLATFORM_PACKAGE)/Library/SerialPortLib/SerialPortLib.inf
 !endif
 
   
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
@@ -332,14 +332,13 @@
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
 !else
-  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
-  SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
+  
DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+  SerialPortLib|$(PLATFORM_PACKAGE)/Library/SerialPortLib/SerialPortLib.inf
 !endif
 
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf
   
HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
-  
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
-  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
 
  !if $(MINNOW2_FSP_BUILD) == TRUE
  PlatformFspLib|Vlv2TbltDevicePkg/Library/PlatformFspLib/PlatformFspLib.inf
@@ -413,7 +412,7 @@
 
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
   !if $(TARGET) != RELEASE
-  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
   !endif
 
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
@@ -436,12 +435,7 @@
   
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
 
 !if $(TARGET) != RELEASE
-  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
-!endif
-
-!if $(SOURCE_DEBUG_ENABLE) == TRUE
-  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
-  
TimerLib|$(PLATFORM_PACKAGE)/Library/IntelPchAcpiTimerLib/IntelPchAcpiTimerLib.inf
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !endif
 
 [LibraryClasses.X64.DXE_RUNTIME_DRIVER]
@@ -616,6 +610,10 @@
 
   gEfiCpuTokenSpaceGuid.PcdCpuSmmBlockStartupThisAp|TRUE
 
+!if $(SOURCE_DEBUG_ENABLE)
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmDebug|TRUE
+!endif
+
 [PcdsFixedAtBuild.common]
 !if $(MINNOW2_FSP_BUILD) == TRUE
 # $(FLASH_REGION_VLVMICROCODE_BASE)
@@ -694,6 +692,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl|FALSE
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|2
 !endif
 
 [PcdsFixedAtBuild.IA32.PEIM, PcdsFixedAtBuild.IA32.PEI_CORE, 
PcdsFixedAtBuild.IA32.SEC]
@@ -848,16 +847,15 @@
   !if $(TPM_ENABLED) == TRUE
 gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x7b, 0x3a, 0xcd, 0x72, 
0xA5, 0xFE, 0x5e, 0x4f, 0x91, 0x65, 0x4d, 0xd1, 0x21, 0x87, 0xbb, 0x13}
   !endif
-  !if $(FTPM_ENABLE) == TRUE
-gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x7b, 0x3a, 0xcd, 0x72, 
0xA5, 0xFE, 0x5e, 0x4f, 0x91, 0x65, 0x4d, 0xd1, 0x21, 0x87, 0xbb, 0x13}
-  !endif
 
   ## This PCD defines the video horizontal resolution.
   #  This PCD could be set to 0 then video resolution could be at highest 
resolution.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0
+  #gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
   ## This PCD defines the video vertical resolution.
   #  This PCD could be set to 0 then video resolution could be at highest 
resolution.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0
+  #gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600
 
   ## This PCD defines the Console output column and the default value is 25 
according to UEFI spec.
   #  This PCD could be 

[edk2] [Patch 1/4] Vlv2TbltDevicePkg: Make !if statement usage consistent

2016-11-29 Thread Michael Kinney
Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 +-
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index c3dc25f..808facf 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -457,7 +457,7 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
 
-!if $(CAPSULE_ENABLE)
+!if $(CAPSULE_ENABLE) == TRUE
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
 !endif
 
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 83cbb0a..f2f594c 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -457,7 +457,7 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
 
-!if $(CAPSULE_ENABLE)
+!if $(CAPSULE_ENABLE) == TRUE
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
 !endif
 
-- 
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 v2] ShellPkg: Add error prompt message in Ifconfig6 command.

2016-11-29 Thread Ye, Ting
Looks good to me with the typo fixed.

Reviewed-by: Ye Ting  

-Original Message-
From: Zhang, Lubo 
Sent: Tuesday, November 29, 2016 12:03 PM
To: Hegde, Nagaraj P ; edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: RE: [edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6 
command.

Thank you for reminding.

Lubo

-Original Message-
From: Hegde, Nagaraj P [mailto:nagaraj-p.he...@hpe.com]
Sent: Tuesday, November 29, 2016 11:59 AM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: RE: [edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6 
command.

Spelling correction in the uni file for STR_IFCONFIG6_ERR_MAN_GW. Should be 
"Gateway" instead of "Getway".
Reviewed-by: Hegde, Nagaraj P 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang 
Lubo
Sent: Tuesday, November 29, 2016 8:28 AM
To: edk2-devel@lists.01.org
Cc: Ye Ting ; Fu Siyuan ; Wu Jiaxin 

Subject: [edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6 
command.

v2: update the prompt message more readable.

It should display error prompt message when Ifconfig6 can not configure 
correctly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 15 +++
 .../UefiShellNetwork2CommandsLib.uni  |  9 +
 2 files changed, 24 insertions(+)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
index 32dd284..fb308cc 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
@@ -1315,10 +1315,24 @@ IfConfig6SetInterfaceInfo (
 goto ON_EXIT;
   }
 
   VarArg= VarArg->Next;
 
+  if (StrCmp (VarArg->Arg, L"host") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  }
+
 } else if (StrCmp (VarArg->Arg, L"man") == 0) {
   //
   // Set manual config policy.
   //
   Policy = Ip6ConfigPolicyManual;
@@ -1509,10 +1523,11 @@ IfConfig6SetInterfaceInfo (
   CfgAddr
   );
 
   if (EFI_ERROR (Status)) {
 ShellStatus = SHELL_ACCESS_DENIED;
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
+ (STR_IFCONFIG6_ERR_MAN_GW), gShellNetwork2HiiHandle, Status);
 goto ON_EXIT;
   }
 
 } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
   //
diff --git 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
index c3445bb..79af7f9 100644
--- 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Com
+++ mandsLib.uni
@@ -75,10 +75,19 @@
 #string STR_IFCONFIG6_ERR_LACK_ARGUMENTS   #language en-US"Lack 
arguments. Bad command %H%s%N is skipped.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_LACK_OPTION  #language en-US"Lack 
options.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_MAN_HOST #language en-US"Manual 
address configuration failed. Please retry.\r\n"
+
+#string STR_IFCONFIG6_ERR_MAN_GW   #language en-US"Getway 
address configuration failed. Please check the argument.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_IP_CONFIG#language en-US"The IP 
address is not configurable when the policy is Ip6ConfigPolicyAutomatic.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_GW_CONFIG#language en-US"The 

Re: [edk2] [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the unused buf

2016-11-29 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Wu, Jiaxin 
Sent: Wednesday, November 30, 2016 10:26 AM
To: edk2-devel@lists.01.org
Cc: Fu, Siyuan ; Ye, Ting ; Zhang, Lubo 

Subject: [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the unused 
buf

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/IpSecDxe/Ikev2/Payload.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/NetworkPkg/IpSecDxe/Ikev2/Payload.c 
b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
index 675ecf6..f32b3a8 100644
--- a/NetworkPkg/IpSecDxe/Ikev2/Payload.c
+++ b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
@@ -655,11 +655,10 @@ Ikev2CertGenerateAuthPayload (
   )
 {
   UINT8  *Digest;
   UINTN  DigestSize;
   PRF_DATA_FRAGMENT  Fragments[3];
-  UINT8  *KeyBuf;
   IKE_PAYLOAD*AuthPayload;
   IKEV2_AUTH *PayloadBuf;
   EFI_STATUS Status;
   UINT8  *Signature;
   UINTN  SigSize;
@@ -680,11 +679,10 @@ Ikev2CertGenerateAuthPayload (
   //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   //
   //
   // Initial point
   //
-  KeyBuf  = NULL;
   AuthPayload = NULL;
   Digest  = NULL;
   Signature   = NULL;
   SigSize = 0;
 
@@ -696,21 +694,10 @@ Ikev2CertGenerateAuthPayload (
   if (Digest == NULL) {
 return NULL;
   }
 
   //
-  // Store the AuthKey into KeyBuf
-  //
-  KeyBuf  = AllocateZeroPool (DigestSize);
-  if (KeyBuf == NULL) {
-Status = EFI_OUT_OF_RESOURCES;
-goto EXIT;
-  }
-  
-  CopyMem (KeyBuf, Digest, DigestSize);
-
-  //
   // Calculate Prf(SK_Pi/r, IDi/r)
   //
   Fragments[0].Data = IdPayload->PayloadBuf + sizeof 
(IKEV2_COMMON_PAYLOAD_HEADER);
   Fragments[0].DataSize = IdPayload->PayloadSize - sizeof 
(IKEV2_COMMON_PAYLOAD_HEADER);
 
@@ -861,13 +848,10 @@ Ikev2CertGenerateAuthPayload (
   //
   AuthPayload->PayloadBuf   = (UINT8 *) PayloadBuf;
   AuthPayload->PayloadType  = IKEV2_PAYLOAD_TYPE_AUTH;
 
 EXIT:
-  if (KeyBuf != NULL) {
-FreePool (KeyBuf);
-  }
   if (Digest != NULL) {
 FreePool (Digest);
   }
   if (Signature != NULL) {
 FreePool (Signature);
@@ -1490,11 +1474,11 @@ Ikev2ParserNotifyCookiePayload (
   @param[in]  CertificateLenThe length of Certificate in byte.
   @param[in]  EncodeTypeSpecified the Certificate Encodeing which is 
defined
 in RFC 4306.
   @param[in]  IsRequest To indicate create Certificate Payload or 
Certificate
 Request Payload. If it is TURE, create 
Certificate
-Payload. Otherwise, create Certificate Request 
Payload.
+Request Payload. Otherwise, create Certificate 
Payload.
 
   @retval  a Pointer to IKE Payload whose payload buffer containing the 
Certificate
payload or Certificated Request payload.
 
 **/
-- 
1.9.5.msysgit.1

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


Re: [edk2] [PATCH] SourceLevelDebugPkg: Avoid to re-init IDT table again at SMI entry

2016-11-29 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: Fan, Jeff
> Sent: Tuesday, November 29, 2016 3:17 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Yao, Jiewen ;
> Kinney, Michael D 
> Subject: [PATCH] SourceLevelDebugPkg: Avoid to re-init IDT table again at
> SMI entry
> 
> Current SmmDebugAgentLib will initialize IDT table to support source
> debugging at each time SMI entry on SMM BSP. Actually, we only need to
> initialize IDT table at first time SMI entry.
> 
> Add one flag to avoid re-initializing IDT table.
> 
> Cc: Ruiyu Ni 
> Cc: Jiewen Yao 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Fan 
> ---
>  .../Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c| 10
> +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git
> a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebug
> AgentLib.c
> b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebu
> gAgentLib.c
> index 701c4be..6216142 100644
> ---
> a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebug
> AgentLib.c
> +++
> b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebu
> gAgent
> +++ Lib.c
> @@ -19,6 +19,7 @@ DEBUG_AGENT_MAILBOX mLocalMailbox;
>  UINTN   mSavedDebugRegisters[6];
>  IA32_IDT_GATE_DESCRIPTORmIdtEntryTable[33];
>  BOOLEAN mSkipBreakpoint = FALSE;
> +BOOLEAN mSmmDebugIdtInitFlag = FALSE;
> 
>  CHAR8 mWarningMsgIgnoreSmmEntryBreak[] = "Ignore smmentrybreak
> setting for SMI issued during DXE debugging!\r\n";
> 
> @@ -276,7 +277,14 @@ InitializeDebugAgent (
> 
>case DEBUG_AGENT_INIT_ENTER_SMI:
>  SaveDebugRegister ();
> -InitializeDebugIdt ();
> +if (!mSmmDebugIdtInitFlag) {
> +  //
> +  // We only need to initialize Debug IDT table at first SMI entry
> +  // after SMM relocation.
> +  //
> +  InitializeDebugIdt ();
> +  mSmmDebugIdtInitFlag = TRUE;
> +}
>  //
>  // Check if CPU APIC Timer is working, otherwise initialize it.
>  //
> --
> 2.9.3.windows.2

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


Re: [edk2] [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the unused buf

2016-11-29 Thread Fu, Siyuan
Reviewed-by: Fu Siyuan 

> -Original Message-
> From: Wu, Jiaxin
> Sent: Wednesday, November 30, 2016 10:26 AM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan ; Ye, Ting ; Zhang,
> Lubo 
> Subject: [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the
> unused buf
> 
> Cc: Fu Siyuan 
> Cc: Ye Ting 
> Cc: Zhang Lubo 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiaxin Wu 
> ---
>  NetworkPkg/IpSecDxe/Ikev2/Payload.c | 18 +-
>  1 file changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/NetworkPkg/IpSecDxe/Ikev2/Payload.c
> b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
> index 675ecf6..f32b3a8 100644
> --- a/NetworkPkg/IpSecDxe/Ikev2/Payload.c
> +++ b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
> @@ -655,11 +655,10 @@ Ikev2CertGenerateAuthPayload (
>)
>  {
>UINT8  *Digest;
>UINTN  DigestSize;
>PRF_DATA_FRAGMENT  Fragments[3];
> -  UINT8  *KeyBuf;
>IKE_PAYLOAD*AuthPayload;
>IKEV2_AUTH *PayloadBuf;
>EFI_STATUS Status;
>UINT8  *Signature;
>UINTN  SigSize;
> @@ -680,11 +679,10 @@ Ikev2CertGenerateAuthPayload (
>//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>//
>//
>// Initial point
>//
> -  KeyBuf  = NULL;
>AuthPayload = NULL;
>Digest  = NULL;
>Signature   = NULL;
>SigSize = 0;
> 
> @@ -696,21 +694,10 @@ Ikev2CertGenerateAuthPayload (
>if (Digest == NULL) {
>  return NULL;
>}
> 
>//
> -  // Store the AuthKey into KeyBuf
> -  //
> -  KeyBuf  = AllocateZeroPool (DigestSize);
> -  if (KeyBuf == NULL) {
> -Status = EFI_OUT_OF_RESOURCES;
> -goto EXIT;
> -  }
> -
> -  CopyMem (KeyBuf, Digest, DigestSize);
> -
> -  //
>// Calculate Prf(SK_Pi/r, IDi/r)
>//
>Fragments[0].Data = IdPayload->PayloadBuf + sizeof
> (IKEV2_COMMON_PAYLOAD_HEADER);
>Fragments[0].DataSize = IdPayload->PayloadSize - sizeof
> (IKEV2_COMMON_PAYLOAD_HEADER);
> 
> @@ -861,13 +848,10 @@ Ikev2CertGenerateAuthPayload (
>//
>AuthPayload->PayloadBuf   = (UINT8 *) PayloadBuf;
>AuthPayload->PayloadType  = IKEV2_PAYLOAD_TYPE_AUTH;
> 
>  EXIT:
> -  if (KeyBuf != NULL) {
> -FreePool (KeyBuf);
> -  }
>if (Digest != NULL) {
>  FreePool (Digest);
>}
>if (Signature != NULL) {
>  FreePool (Signature);
> @@ -1490,11 +1474,11 @@ Ikev2ParserNotifyCookiePayload (
>@param[in]  CertificateLenThe length of Certificate in byte.
>@param[in]  EncodeTypeSpecified the Certificate Encodeing which
> is defined
>  in RFC 4306.
>@param[in]  IsRequest To indicate create Certificate Payload or
> Certificate
>  Request Payload. If it is TURE, create
> Certificate
> -Payload. Otherwise, create Certificate
> Request Payload.
> +Request Payload. Otherwise, create
> Certificate Payload.
> 
>@retval  a Pointer to IKE Payload whose payload buffer containing the
> Certificate
> payload or Certificated Request payload.
> 
>  **/
> --
> 1.9.5.msysgit.1

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


[edk2] [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the unused buf

2016-11-29 Thread Jiaxin Wu
Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/IpSecDxe/Ikev2/Payload.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/NetworkPkg/IpSecDxe/Ikev2/Payload.c 
b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
index 675ecf6..f32b3a8 100644
--- a/NetworkPkg/IpSecDxe/Ikev2/Payload.c
+++ b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
@@ -655,11 +655,10 @@ Ikev2CertGenerateAuthPayload (
   )
 {
   UINT8  *Digest;
   UINTN  DigestSize;
   PRF_DATA_FRAGMENT  Fragments[3];
-  UINT8  *KeyBuf;
   IKE_PAYLOAD*AuthPayload;
   IKEV2_AUTH *PayloadBuf;
   EFI_STATUS Status;
   UINT8  *Signature;
   UINTN  SigSize;
@@ -680,11 +679,10 @@ Ikev2CertGenerateAuthPayload (
   //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   //
   //
   // Initial point
   //
-  KeyBuf  = NULL;
   AuthPayload = NULL;
   Digest  = NULL;
   Signature   = NULL;
   SigSize = 0;
 
@@ -696,21 +694,10 @@ Ikev2CertGenerateAuthPayload (
   if (Digest == NULL) {
 return NULL;
   }
 
   //
-  // Store the AuthKey into KeyBuf
-  //
-  KeyBuf  = AllocateZeroPool (DigestSize);
-  if (KeyBuf == NULL) {
-Status = EFI_OUT_OF_RESOURCES;
-goto EXIT;
-  }
-  
-  CopyMem (KeyBuf, Digest, DigestSize);
-
-  //
   // Calculate Prf(SK_Pi/r, IDi/r)
   //
   Fragments[0].Data = IdPayload->PayloadBuf + sizeof 
(IKEV2_COMMON_PAYLOAD_HEADER);
   Fragments[0].DataSize = IdPayload->PayloadSize - sizeof 
(IKEV2_COMMON_PAYLOAD_HEADER);
 
@@ -861,13 +848,10 @@ Ikev2CertGenerateAuthPayload (
   //
   AuthPayload->PayloadBuf   = (UINT8 *) PayloadBuf;
   AuthPayload->PayloadType  = IKEV2_PAYLOAD_TYPE_AUTH;
 
 EXIT:
-  if (KeyBuf != NULL) {
-FreePool (KeyBuf);
-  }
   if (Digest != NULL) {
 FreePool (Digest);
   }
   if (Signature != NULL) {
 FreePool (Signature);
@@ -1490,11 +1474,11 @@ Ikev2ParserNotifyCookiePayload (
   @param[in]  CertificateLenThe length of Certificate in byte.
   @param[in]  EncodeTypeSpecified the Certificate Encodeing which is 
defined
 in RFC 4306.
   @param[in]  IsRequest To indicate create Certificate Payload or 
Certificate
 Request Payload. If it is TURE, create 
Certificate
-Payload. Otherwise, create Certificate Request 
Payload.
+Request Payload. Otherwise, create Certificate 
Payload.
 
   @retval  a Pointer to IKE Payload whose payload buffer containing the 
Certificate
payload or Certificated Request payload.
 
 **/
-- 
1.9.5.msysgit.1

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


Re: [edk2] [Patch] Vlv2TbltDevicePkg: Use 4K aligned PE/COFF sections

2016-11-29 Thread Kinney, Michael D
Jiewen,

I agree.  I have entered an additional Bugzilla issue to get the binaries fixed.

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

Best regards,

Mike

> -Original Message-
> From: Yao, Jiewen
> Sent: Tuesday, November 29, 2016 5:48 PM
> To: Kinney, Michael D ; edk2-devel@lists.01.org
> Cc: Wei, David ; Guo, Mang 
> Subject: RE: [Patch] Vlv2TbltDevicePkg: Use 4K aligned PE/COFF sections
> 
> HI Mike
> I agree on this change.
> But I would like to mention that the protection does not takes effect, until 
> all
> VLV2 binary uses this build option, too.
> 
> We should feedback to VLV2 binary provider as well.
> 
> Reviewed-by: jiewen@intel.com
> 
> Thank you
> Yao Jiewen
> 
> > -Original Message-
> > From: Kinney, Michael D
> > Sent: Wednesday, November 30, 2016 3:22 AM
> > To: edk2-devel@lists.01.org
> > Cc: Yao, Jiewen ; Wei, David
> > ; Guo, Mang 
> > Subject: [Patch] Vlv2TbltDevicePkg: Use 4K aligned PE/COFF sections
> >
> > Update [BuildOptions] to use of 4K aligned PE/COFF
> > image sections to support page level protection of
> > DXE_RUNTIME_DRIVER, SMM_CORE, and DXE_SMM_DRIVER
> > modules.
> >
> > Cc: Jiewen Yao 
> > Cc: David Wei 
> > Cc: Mang Guo 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Michael Kinney 
> > ---
> >  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 16 
> >  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 16 
> >  Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 16 
> >  3 files changed, 48 insertions(+)
> >
> > diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > index c3dc25f..6da2a8a 100644
> > --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > @@ -1676,6 +1676,22 @@
> > $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fT
> > PMInitPeim.inf
> >INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
> >  !endif
> >
> > +#
> > +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> > level
> > +# protection of DXE_RUNTIME_DRIVER modules
> > +#
> > +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> > +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> > +
> > +#
> > +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> > level
> > +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> > +#
> > +[BuildOptions.common.EDKII.DXE_SMM_DRIVER,
> > BuildOptions.common.EDKII.SMM_CORE]
> > +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> > +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> > +
> >  [BuildOptions.Common.EDK]
> >
> >  #
> > diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > index 3a5776a..5b5523f 100644
> > --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > @@ -1659,6 +1659,22 @@
> > $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fT
> > PMInitPeim.inf
> >
> >  !endif
> >
> > +#
> > +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> > level
> > +# protection of DXE_RUNTIME_DRIVER modules
> > +#
> > +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> > +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> > +
> > +#
> > +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> > level
> > +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> > +#
> > +[BuildOptions.common.EDKII.DXE_SMM_DRIVER,
> > BuildOptions.common.EDKII.SMM_CORE]
> > +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> > +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> > +
> >  [BuildOptions.Common.EDK]
> >
> >  #
> > diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > index 83cbb0a..54d2b81 100644
> > --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > @@ -1668,6 +1668,22 @@
> > $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fT
> > PMInitPeim.inf
> >
> >  !endif
> >
> > +#
> > +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> > level
> > +# protection of DXE_RUNTIME_DRIVER modules
> > +#
> > +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> > +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> > +
> > +#
> > +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> > level
> > +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> > +#
> > +[BuildOptions.common.EDKII.DXE_SMM_DRIVER,
> > BuildOptions.common.EDKII.SMM_CORE]
> > +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> > +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> > +
> 

Re: [edk2] [Patch] Vlv2TbltDevicePkg: Use 4K aligned PE/COFF sections

2016-11-29 Thread Yao, Jiewen
HI Mike
I agree on this change.
But I would like to mention that the protection does not takes effect, until 
all VLV2 binary uses this build option, too.

We should feedback to VLV2 binary provider as well.

Reviewed-by: jiewen@intel.com

Thank you
Yao Jiewen

> -Original Message-
> From: Kinney, Michael D
> Sent: Wednesday, November 30, 2016 3:22 AM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Wei, David
> ; Guo, Mang 
> Subject: [Patch] Vlv2TbltDevicePkg: Use 4K aligned PE/COFF sections
> 
> Update [BuildOptions] to use of 4K aligned PE/COFF
> image sections to support page level protection of
> DXE_RUNTIME_DRIVER, SMM_CORE, and DXE_SMM_DRIVER
> modules.
> 
> Cc: Jiewen Yao 
> Cc: David Wei 
> Cc: Mang Guo 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney 
> ---
>  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 16 
>  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 16 
>  Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 16 
>  3 files changed, 48 insertions(+)
> 
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> index c3dc25f..6da2a8a 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> @@ -1676,6 +1676,22 @@
> $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fT
> PMInitPeim.inf
>INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
>  !endif
> 
> +#
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> level
> +# protection of DXE_RUNTIME_DRIVER modules
> +#
> +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
> +#
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> level
> +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> +#
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER,
> BuildOptions.common.EDKII.SMM_CORE]
> +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  [BuildOptions.Common.EDK]
> 
>  #
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> index 3a5776a..5b5523f 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> @@ -1659,6 +1659,22 @@
> $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fT
> PMInitPeim.inf
> 
>  !endif
> 
> +#
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> level
> +# protection of DXE_RUNTIME_DRIVER modules
> +#
> +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
> +#
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> level
> +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> +#
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER,
> BuildOptions.common.EDKII.SMM_CORE]
> +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  [BuildOptions.Common.EDK]
> 
>  #
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> index 83cbb0a..54d2b81 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> @@ -1668,6 +1668,22 @@
> $(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fT
> PMInitPeim.inf
> 
>  !endif
> 
> +#
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> level
> +# protection of DXE_RUNTIME_DRIVER modules
> +#
> +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
> +#
> +# Force PE/COFF sections to be aligned at 4KB boundaries to support page
> level
> +# protection of DXE_SMM_DRIVER/SMM_CORE modules
> +#
> +[BuildOptions.common.EDKII.DXE_SMM_DRIVER,
> BuildOptions.common.EDKII.SMM_CORE]
> +  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
> +  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +
>  [BuildOptions.Common.EDK]
> 
>  #
> --
> 2.6.3.windows.1

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


Re: [edk2] [PATCH] UefiCpuPkg:PiSmmCpu: Set correct attribute on split.

2016-11-29 Thread Yao, Jiewen
Comments below:

From: Laszlo Ersek [mailto:ler...@redhat.com]
Sent: Wednesday, November 30, 2016 5:54 AM
To: Yao, Jiewen ; edk2-de...@ml01.01.org
Cc: Kinney, Michael D ; Fan, Jeff 

Subject: Re: [edk2] [PATCH] UefiCpuPkg:PiSmmCpu: Set correct attribute on split.

On 11/29/16 08:39, Jiewen Yao wrote:
> PiSmmCpu driver may split page for page attribute request.
> Current logic will propagate the super page attribute attribute.
> However, it might be wrong because we cannot clear protection
> without touch super page attribute.
>
> We should always clear protection on super page and set
> protection on end page for easy clear later.
>
> Cc: Jeff Fan >
> Cc: Michael D Kinney 
> >
> Cc: Laszlo Ersek >
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao >
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> index accc11e..d0f41a8 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> @@ -303,7 +303,7 @@ SplitPage (
>for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) {
>  NewPageEntry[Index] = BaseAddress + SIZE_4KB * Index + ((*PageEntry) 
> & PAGE_PROGATE_BITS);
>}
> -  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + ((*PageEntry) & 
> PAGE_PROGATE_BITS);
> +  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + PAGE_ATTRIBUTE_BITS;
>return RETURN_SUCCESS;
>  } else {
>return RETURN_UNSUPPORTED;
> @@ -324,7 +324,7 @@ SplitPage (
>for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) {
>  NewPageEntry[Index] = BaseAddress + SIZE_2MB * Index + IA32_PG_PS + 
> ((*PageEntry) & PAGE_PROGATE_BITS);
>}
> -  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + ((*PageEntry) & 
> PAGE_PROGATE_BITS);
> +  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + PAGE_ATTRIBUTE_BITS;
>return RETURN_SUCCESS;
>  } else {
>return RETURN_UNSUPPORTED;
>

I had to stare a while at this, to get a superficial understanding :)
But, it does seem to make sense (I checked PAGE_ATTRIBUTE_BITS and
PAGE_PROGATE_BITS too, just to be sure). So, this change preserves the
protection inheritance for the leaf pages, but clears NX and sets Dirty
/ Accessed / Writeable / Present on the relevant parent entry. (I see
hat User mode access is enabled as well; I don't know why that is useful
here.)
[Jiewen] Yes. You are right.

Some notes about the commit message:

- we have "attribute attribute". I think we should either drop one of
those words, or say "super page attribute to leaf page attribute".
[Jiewen] Agree. I will update.

- "end page" might be more clearly stated as "leaf page" (just a guess)
[Jiewen] Agree. I will update.

- I think it would be useful to mention, for the uninitiated like me :),
that the effective protection is (apparently) the strictest combination
across the levels.
[Jiewen] Agree. I will update.

- What do you think of the following subject line?
UefiCpuPkg/PiSmmCpuDxeSmm: relax superpage protection on page split
[Jiewen] Agree. I will update.

Anyway, to the extent that I understand this, I agree:

Acked-by: Laszlo Ersek >

I gave the patch a bit of testing in my usual environment; it seems to
cause no problems.
[Jiewen] Thank you.

Tested-by: Laszlo Ersek >

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


Re: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Replace deprecated debug level macros

2016-11-29 Thread Tian, Feng
Reviewed-by: Feng Tian 

I will help push it into EDKII trunk.

Thanks
Feng

-Original Message-
From: Marcin Wojtas [mailto:m...@semihalf.com] 
Sent: Tuesday, November 29, 2016 9:52 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng ; Kinney, Michael D 
; Gao, Liming ; 
leif.lindh...@linaro.org; ard.biesheu...@linaro.org; m...@semihalf.com; 
j...@semihalf.com
Subject: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Replace deprecated debug level 
macros

From: Jan Dąbroś 

EFI_D_INFO, EFI_D_VERBOSE, EFI_D_WARN and EFI_D_ERROR are replaced with 
currently recommended values.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jan Dabros 
Signed-off-by: Marcin Wojtas 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c| 36 +-
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c  | 40 +--
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 22 +++---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c   | 78 +++---
 4 files changed, 88 insertions(+), 88 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
index 61d3517..3f73194 100755
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
@@ -533,7 +533,7 @@ EmmcTuningClkForHs200 (
   do {
 Status = EmmcSendTuningBlk (PassThru, Slot, BusWidth);
 if (EFI_ERROR (Status)) {
-  DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails 
with %r\n", Status));
+  DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block 
+ fails with %r\n", Status));
   return Status;
 }
 
@@ -551,7 +551,7 @@ EmmcTuningClkForHs200 (
 }
   } while (++Retry < 40);
 
-  DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails at %d 
times with HostCtrl2 %02x\n", Retry, HostCtrl2));
+  DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails 
+ at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));
   //
   // Abort the tuning procedure and reset the tuning circuit.
   //
@@ -618,20 +618,20 @@ EmmcSwitchBusWidth (
   CmdSet = 0;
   Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d fails 
with %r\n", BusWidth, Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d 
+ fails with %r\n", BusWidth, Status));
 return Status;
   }
 
   Status = EmmcSendStatus (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: Send status fails with %r\n", 
Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Send status fails with 
+ %r\n", Status));
 return Status;
   }
   //
   // Check the switch operation is really successful or not.
   //
   if ((DevStatus & BIT7) != 0) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: The switch operation fails as 
DevStatus is 0x%08x\n", DevStatus));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: The switch operation 
+ fails as DevStatus is 0x%08x\n", DevStatus));
 return EFI_DEVICE_ERROR;
   }
 
@@ -686,20 +686,20 @@ EmmcSwitchClockFreq (
 
   Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d fails 
with %r\n", HsTiming, Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d 
+ fails with %r\n", HsTiming, Status));
 return Status;
   }
 
   Status = EmmcSendStatus (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: Send status fails with %r\n", 
Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails with 
+ %r\n", Status));
 return Status;
   }
   //
   // Check the switch operation is really successful or not.
   //
   if ((DevStatus & BIT7) != 0) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: The switch operation fails as 
DevStatus is 0x%08x\n", DevStatus));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: The switch operation 
+ fails as DevStatus is 0x%08x\n", DevStatus));
 return EFI_DEVICE_ERROR;
   }
   //
@@ -995,13 +995,13 @@ EmmcSetBusMode (
 
   Status = EmmcGetCsd (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", Status));
+DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", 
+ Status));
 return Status;
   }
 
   Status = EmmcSelect (PassThru, Slot, Rca);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: Select fails with %r\n", Status));
+DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: Select fails with %r\n", 
+ Status));
 return Status;
   }
 
@@ -1019,7 +1019,7 @@ EmmcSetBusMode (
   //
   Status = EmmcGetExtCsd (PassThru, Slot, );
   

Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some semaphores on S3 boot path

2016-11-29 Thread Fan, Jeff
Laszlo,

Thanks your comments. I added my comments as below in [Jeff]

Thanks!
Jeff

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Wednesday, November 30, 2016 4:49 AM
To: Fan, Jeff; edk2-de...@ml01.01.org
Cc: Kinney, Michael D; Yao, Jiewen; Tian, Feng
Subject: Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some semaphores on 
S3 boot path

On 11/29/16 08:51, Jeff Fan wrote:
> Some semaphores are not cleared on S3 boot path. For example,
> mSmmMpSyncData->CpuData[CpuIndex].Present. It may still keeps the 
> mSmmMpSyncData->value set at
> SMM runtime during S3 resume. It may causes BSP have the wrong 
> judgement on SMM AP's present state.
> 
> We have one related fix at e78a2a49ee6b0c0d7c6997c87ace31d7761cf636. 
> But that is not completed.
> 
> This fix is to clear Busy/Run/Present semaphores in InitializeMpSyncData().
> 
> Cc: Laszlo Ersek 
> Cc: Feng Tian 
> Cc: Jiewen Yao 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Fan 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index cfbf59e..a873b68 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1357,6 +1357,9 @@ InitializeMpSyncData (
>  (UINT32 *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Run + 
> mSemaphoreSize * CpuIndex);
>mSmmMpSyncData->CpuData[CpuIndex].Present =
>  (BOOLEAN *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Present + 
> mSemaphoreSize * CpuIndex);
> +  *(mSmmMpSyncData->CpuData[CpuIndex].Busy)= 0;
> +  *(mSmmMpSyncData->CpuData[CpuIndex].Run) = 0;
> +  *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE;
>  }
>}
>  }
> 

Even after this patch, the values pointed-to by the following fields of 
SemaphoreGlobal are not cleared: PFLock, CodeAccessCheckLock, MemoryMappedLock. 
Is that okay?

The values pointed-to by the following fields of SemaphoreMsr are not cleared 
either: Msr, AvailableCounter. Is that okay?

[Jeff] We need to clear the data in 
SMM_CPU_DATA_BLOCK/SMM_DISPATCHER_MP_SYNC_DATA and semaphores pointed by the 
field in those 2 structures.  However, the other spinlock located in 
SemaphoreBlock needn't to be cleared.

Can we imitate e78a2a49ee6b0c0d7c6997c87ace31d7761cf636 here; namely, can we 
save "SemaphoreBlock" and "TotalSize" from
InitializeSmmCpuSemaphores() in global variables (in SMRAM), and then just do 
another ZeroMem() here? That would cover the currently listed objects 
(*Counter, *InsideSmm, *AllCpusInSync), and everything else too, in a 
future-proof way.

[Jeff] This issue is that ZeroMem only clear all the fields in structure and 
needn't o clear the buffer pointed by these fields.

In fact, I wonder if the ZeroMem() could be moved into
InitializeMpSyncData() from InitializeSmmCpuSemaphores().

 [Jeff] If we cleared all semaphores(including Spinlock), we need to 
re-initialize them again. I do not think there is some reasonable usage case to 
let spinlock keep the garbage value.

Of course, if some pointed-to objects must not be cleared, then the
ZeroMem() is not appropriate.

[Jeff]  Agree.

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


Re: [edk2] [Patch] BaseTools: fix the bug to add PaletteSize info into AutoGen

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

> -Original Message-
> From: Zhu, Yonghong
> Sent: Tuesday, November 29, 2016 7:41 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [Patch] BaseTools: fix the bug to add PaletteSize info into AutoGen
> 
> Fix the bug to add PaletteSize info into AutoGen.c when the flag
> UEFI_HII_RESOURCE_SECTION is set to FALSE.
> 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Yonghong Zhu 
> ---
>  BaseTools/Source/Python/AutoGen/GenC.py | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/GenC.py
> b/BaseTools/Source/Python/AutoGen/GenC.py
> index de6eb0e..63cfe04 100644
> --- a/BaseTools/Source/Python/AutoGen/GenC.py
> +++ b/BaseTools/Source/Python/AutoGen/GenC.py
> @@ -1693,14 +1693,15 @@ def CreateIdfFileCode(Info, AutoGenC, StringH,
> IdfGenCFlag, IdfGenBinBuffer):
>  TempBuffer += Buffer
>  elif File.Ext.upper() == '.BMP':
>  TempBuffer, TempPalette = 
> BmpImageDecoder(File, Buffer,
> PaletteIndex, FileObj.TransParent)
>  if len(TempPalette) > 1:
>  PaletteIndex += 1
> -PaletteBuffer += pack('H', 
> len(TempPalette))
> -PaletteBuffer += TempPalette
> +NewPalette = pack('H', len(TempPalette))
> +NewPalette += TempPalette
> +PaletteBuffer += NewPalette
>  PaletteStr = WriteLine(PaletteStr, '// 
> %s: %s: %s' %
> (DecToHexStr(PaletteIndex - 1, 4), ID, DecToHexStr(PaletteIndex - 1, 4)))
> -TempPaletteList = 
> AscToHexList(TempPalette)
> +TempPaletteList = 
> AscToHexList(NewPalette)
>  PaletteStr = WriteLine(PaletteStr,
> CreateArrayItem(TempPaletteList, 16) + '\n')
>  ImageBuffer += TempBuffer
>  BufferStr = WriteLine(BufferStr, '// %s: %s: %s' 
> %
> (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4)))
>  TempBufferList = AscToHexList(TempBuffer)
>  BufferStr = WriteLine(BufferStr,
> CreateArrayItem(TempBufferList, 16) + '\n')
> --
> 2.6.1.windows.1

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


[edk2] [Patch 3/3] Vlv2TbltDevicePkg: Add /m flag for multi-processor build

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=274

Add support for multi-processor builds using a /m flag.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/Build_IFWI.bat | 5 +
 Vlv2TbltDevicePkg/bld_vlv.bat| 8 
 2 files changed, 13 insertions(+)

diff --git a/Vlv2TbltDevicePkg/Build_IFWI.bat b/Vlv2TbltDevicePkg/Build_IFWI.bat
index d33f73e..ac22a76 100644
--- a/Vlv2TbltDevicePkg/Build_IFWI.bat
+++ b/Vlv2TbltDevicePkg/Build_IFWI.bat
@@ -45,6 +45,11 @@ if /i "%~1"=="/y" (
 shift
 goto OptLoop
 )
+if /i "%~1"=="/m" (
+set Build_Flags=%Build_Flags% /m
+shift
+goto OptLoop
+)
 if /i "%~1" == "/c" (
 set Build_Flags=%Build_Flags% /c
 shift
diff --git a/Vlv2TbltDevicePkg/bld_vlv.bat b/Vlv2TbltDevicePkg/bld_vlv.bat
index e6e0bd0..0193d4c 100644
--- a/Vlv2TbltDevicePkg/bld_vlv.bat
+++ b/Vlv2TbltDevicePkg/bld_vlv.bat
@@ -71,6 +71,13 @@ if /i "%~1"=="/y" (
 shift
 goto OptLoop
 )
+if /i "%~1"=="/m" (
+if defined NUMBER_OF_PROCESSORS (
+set /a build_threads=%NUMBER_OF_PROCESSORS%+1
+)
+shift
+goto OptLoop
+)
 if /i "%~1" == "/c" (
 echo Removing previous build files ...
 if exist build (
@@ -266,6 +273,7 @@ echo.
 echo/cCleanAll before building
 echo/lGenerate build log file 
 echo/yGenerate build report file 
+echo/mEnable multi-processor build
 echo/IA32 Set Arch to IA32 (default: X64)
 echo/X64  Set Arch to X64 (default: X64)
 echo.
-- 
2.6.3.windows.1

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


[edk2] [Patch 0/3] Vlv2TbltDevicePkg: Update build scripts

2016-11-29 Thread Michael Kinney
Clean up MinnowMax build scripts removing extra null output
file and adding flags to enable multi-processor builds and 
report file generation.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 

Michael Kinney (3):
  Vlv2TbltDevicePkg: Fix typo in name of nul output file
  Vlv2TbltDevicePkg: Add /y flag to generate report files
  Vlv2TbltDevicePkg: Add /m flag for multi-processor build

 Vlv2TbltDevicePkg/Build_IFWI.bat | 10 ++
 Vlv2TbltDevicePkg/bld_vlv.bat| 24 
 2 files changed, 30 insertions(+), 4 deletions(-)

-- 
2.6.3.windows.1

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


[edk2] [Patch 1/3] Vlv2TbltDevicePkg: Fix typo in name of nul output file

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=272

Fix typo in script file.  To prevent output from being
shown, then output file should be 'nul', not 'null'.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/bld_vlv.bat | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Vlv2TbltDevicePkg/bld_vlv.bat b/Vlv2TbltDevicePkg/bld_vlv.bat
index 6c53917..e21a6cf 100644
--- a/Vlv2TbltDevicePkg/bld_vlv.bat
+++ b/Vlv2TbltDevicePkg/bld_vlv.bat
@@ -68,11 +68,11 @@ if /i "%~1"=="/l" (
 if /i "%~1" == "/c" (
 echo Removing previous build files ...
 if exist build (
-del /f/s/q build > null
+del /f/s/q build > nul
 rmdir /s/q build
 )
 if exist conf\.cache (
-del /f/s/q conf\.cache > null
+del /f/s/q conf\.cache > nul
 rmdir /s/q conf\.cache
 )
 echo.
-- 
2.6.3.windows.1

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


[edk2] [Patch 2/3] Vlv2TbltDevicePkg: Add /y flag to generate report files

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=273

Update build script to generate a report file and put
both the report file and the log file in the directory
Vlv2TbltDevicePkg with an EDK2_Vlv2TbltDevicePkg prefix.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/Build_IFWI.bat |  5 +
 Vlv2TbltDevicePkg/bld_vlv.bat| 12 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Vlv2TbltDevicePkg/Build_IFWI.bat b/Vlv2TbltDevicePkg/Build_IFWI.bat
index 0b50b79..d33f73e 100644
--- a/Vlv2TbltDevicePkg/Build_IFWI.bat
+++ b/Vlv2TbltDevicePkg/Build_IFWI.bat
@@ -40,6 +40,11 @@ if /i "%~1"=="/l" (
 shift
 goto OptLoop
 )
+if /i "%~1"=="/y" (
+set Build_Flags=%Build_Flags% /y
+shift
+goto OptLoop
+)
 if /i "%~1" == "/c" (
 set Build_Flags=%Build_Flags% /c
 shift
diff --git a/Vlv2TbltDevicePkg/bld_vlv.bat b/Vlv2TbltDevicePkg/bld_vlv.bat
index e21a6cf..e6e0bd0 100644
--- a/Vlv2TbltDevicePkg/bld_vlv.bat
+++ b/Vlv2TbltDevicePkg/bld_vlv.bat
@@ -29,7 +29,8 @@ set Arch=X64
 set Source=0
 
 :: Clean up previous build files.
-if exist %WORKSPACE%\edk2.log del %WORKSPACE%\edk2.log
+if exist %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log del 
%WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log
+if exist %WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report del 
%WORKSPACE%\%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report
 if exist %WORKSPACE%\unitool.log del %WORKSPACE%\unitool.log
 if exist %WORKSPACE%\Conf\target.txt del %WORKSPACE%\Conf\target.txt
 if exist %WORKSPACE%\Conf\tools_def.txt del %WORKSPACE%\Conf\tools_def.txt
@@ -61,7 +62,12 @@ copy /y nul %auto_config_inc% >nul
 if /i "%~1"=="/?" goto Usage
 
 if /i "%~1"=="/l" (
-set Build_Flags=%Build_Flags% -j EDK2.log
+set Build_Flags=%Build_Flags% -j 
%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.log
+shift
+goto OptLoop
+)
+if /i "%~1"=="/y" (
+set Build_Flags=%Build_Flags% -y 
%PLATFORM_PACKAGE%\EDK2_%PLATFORM_PACKAGE%.report
 shift
 goto OptLoop
 )
@@ -258,6 +264,8 @@ echo.
 echo Usage: bld_vlv.bat [options] PlatformType [Build Target]
 echo.
 echo/cCleanAll before building
+echo/lGenerate build log file 
+echo/yGenerate build report file 
 echo/IA32 Set Arch to IA32 (default: X64)
 echo/X64  Set Arch to X64 (default: X64)
 echo.
-- 
2.6.3.windows.1

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


Re: [edk2] [PATCH] UefiCpuPkg:PiSmmCpu: Set correct attribute on split.

2016-11-29 Thread Laszlo Ersek
On 11/29/16 08:39, Jiewen Yao wrote:
> PiSmmCpu driver may split page for page attribute request.
> Current logic will propagate the super page attribute attribute.
> However, it might be wrong because we cannot clear protection
> without touch super page attribute.
> 
> We should always clear protection on super page and set
> protection on end page for easy clear later.
> 
> Cc: Jeff Fan 
> Cc: Michael D Kinney 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> index accc11e..d0f41a8 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> @@ -303,7 +303,7 @@ SplitPage (
>for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) {
>  NewPageEntry[Index] = BaseAddress + SIZE_4KB * Index + ((*PageEntry) 
> & PAGE_PROGATE_BITS);
>}
> -  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + ((*PageEntry) & 
> PAGE_PROGATE_BITS);
> +  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + PAGE_ATTRIBUTE_BITS;
>return RETURN_SUCCESS;
>  } else {
>return RETURN_UNSUPPORTED;
> @@ -324,7 +324,7 @@ SplitPage (
>for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) {
>  NewPageEntry[Index] = BaseAddress + SIZE_2MB * Index + IA32_PG_PS + 
> ((*PageEntry) & PAGE_PROGATE_BITS);
>}
> -  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + ((*PageEntry) & 
> PAGE_PROGATE_BITS);
> +  (*PageEntry) = (UINT64)(UINTN)NewPageEntry + PAGE_ATTRIBUTE_BITS;
>return RETURN_SUCCESS;
>  } else {
>return RETURN_UNSUPPORTED;
> 

I had to stare a while at this, to get a superficial understanding :)
But, it does seem to make sense (I checked PAGE_ATTRIBUTE_BITS and
PAGE_PROGATE_BITS too, just to be sure). So, this change preserves the
protection inheritance for the leaf pages, but clears NX and sets Dirty
/ Accessed / Writeable / Present on the relevant parent entry. (I see
hat User mode access is enabled as well; I don't know why that is useful
here.)

Some notes about the commit message:

- we have "attribute attribute". I think we should either drop one of
those words, or say "super page attribute to leaf page attribute".

- "end page" might be more clearly stated as "leaf page" (just a guess)

- I think it would be useful to mention, for the uninitiated like me :),
that the effective protection is (apparently) the strictest combination
across the levels.

- What do you think of the following subject line?

UefiCpuPkg/PiSmmCpuDxeSmm: relax superpage protection on page split


Anyway, to the extent that I understand this, I agree:

Acked-by: Laszlo Ersek 

I gave the patch a bit of testing in my usual environment; it seems to
cause no problems.

Tested-by: Laszlo Ersek 

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


Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some semaphores on S3 boot path

2016-11-29 Thread Laszlo Ersek
On 11/29/16 08:51, Jeff Fan wrote:
> Some semaphores are not cleared on S3 boot path. For example,
> mSmmMpSyncData->CpuData[CpuIndex].Present. It may still keeps the value set at
> SMM runtime during S3 resume. It may causes BSP have the wrong judgement on 
> SMM
> AP's present state.
> 
> We have one related fix at e78a2a49ee6b0c0d7c6997c87ace31d7761cf636. But that 
> is
> not completed.
> 
> This fix is to clear Busy/Run/Present semaphores in InitializeMpSyncData().
> 
> Cc: Laszlo Ersek 
> Cc: Feng Tian 
> Cc: Jiewen Yao 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Fan 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index cfbf59e..a873b68 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1357,6 +1357,9 @@ InitializeMpSyncData (
>  (UINT32 *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Run + 
> mSemaphoreSize * CpuIndex);
>mSmmMpSyncData->CpuData[CpuIndex].Present =
>  (BOOLEAN *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Present + 
> mSemaphoreSize * CpuIndex);
> +  *(mSmmMpSyncData->CpuData[CpuIndex].Busy)= 0;
> +  *(mSmmMpSyncData->CpuData[CpuIndex].Run) = 0;
> +  *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE;
>  }
>}
>  }
> 

Even after this patch, the values pointed-to by the following fields of
SemaphoreGlobal are not cleared: PFLock, CodeAccessCheckLock,
MemoryMappedLock. Is that okay?

The values pointed-to by the following fields of SemaphoreMsr are not
cleared either: Msr, AvailableCounter. Is that okay?

Can we imitate e78a2a49ee6b0c0d7c6997c87ace31d7761cf636 here; namely,
can we save "SemaphoreBlock" and "TotalSize" from
InitializeSmmCpuSemaphores() in global variables (in SMRAM), and then
just do another ZeroMem() here? That would cover the currently listed
objects (*Counter, *InsideSmm, *AllCpusInSync), and everything else too,
in a future-proof way.

In fact, I wonder if the ZeroMem() could be moved into
InitializeMpSyncData() from InitializeSmmCpuSemaphores().

Of course, if some pointed-to objects must not be cleared, then the
ZeroMem() is not appropriate.

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


[edk2] [Patch] Vlv2TbltDevicePkg: Use 4K aligned PE/COFF sections

2016-11-29 Thread Michael Kinney
Update [BuildOptions] to use of 4K aligned PE/COFF
image sections to support page level protection of
DXE_RUNTIME_DRIVER, SMM_CORE, and DXE_SMM_DRIVER
modules.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 16 
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 16 
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 16 
 3 files changed, 48 insertions(+)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index c3dc25f..6da2a8a 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -1676,6 +1676,22 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
   INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
 !endif
 
+#
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_RUNTIME_DRIVER modules
+#
+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
+  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
+#
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_SMM_DRIVER/SMM_CORE modules
+#
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 [BuildOptions.Common.EDK]
 
 #
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 3a5776a..5b5523f 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -1659,6 +1659,22 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
 
 !endif
 
+#
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_RUNTIME_DRIVER modules
+#
+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
+  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
+#
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_SMM_DRIVER/SMM_CORE modules
+#
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 [BuildOptions.Common.EDK]
 
 #
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 83cbb0a..54d2b81 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -1668,6 +1668,22 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
 
 !endif
 
+#
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_RUNTIME_DRIVER modules
+#
+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
+  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
+#
+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level
+# protection of DXE_SMM_DRIVER/SMM_CORE modules
+#
+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
+  MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+
 [BuildOptions.Common.EDK]
 
 #
-- 
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] IntelFsp2Pkg: Add PACKAGES_PATH support

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


> -Original Message-
> From: Thomaiyar, Richard Marian
> Sent: Friday, November 25, 2016 1:21 AM
> To: edk2-devel@lists.01.org
> Cc: Ma, Maurice ; Yao, Jiewen
> ; Mudusuru, Giri P ;
> Thomaiyar, Richard Marian 
> Subject: [PATCH] IntelFsp2Pkg: Add PACKAGES_PATH support
> 
> Add PACKAGES_PATH support in GenCfgOpt.py
> 
> Cc: Maurice Ma 
> Cc: Jiewen Yao 
> Cc: Giri P Mudusuru 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Richard Thomaiyar 
> ---
>  IntelFsp2Pkg/Tools/GenCfgOpt.py | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> index 654cdfc..0675b55 100644
> --- a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> +++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> @@ -523,9 +523,13 @@ EndList
>  if Match:
>  IncludeFilePath = Match.group(1)
>  IncludeFilePath = 
> self.ExpandMacros(IncludeFilePath)
> -try:
> -IncludeDsc  = 
> open(IncludeFilePath, "r")
> -except:
> +PackagesPath = 
> os.getenv("PACKAGES_PATH")
> +for PackagePath in 
> PackagesPath.split(os.pathsep):
> +IncludeFilePathAbs =
> os.path.join(os.path.normpath(PackagePath),
> os.path.normpath(IncludeFilePath))
> +if 
> os.path.exists(IncludeFilePathAbs):
> +IncludeDsc  = 
> open(IncludeFilePathAbs, "r")
> +break
> +if IncludeDsc == None:
>  print("ERROR: Cannot open file 
> '%s'" % IncludeFilePath)
>  raise SystemExit
>  NewDscLines = IncludeDsc.readlines()
> --
> 2.9.0.windows.1

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


Re: [edk2] [PATCH] IntelFsp2Pkg: Add PACKAGES_PATH support

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

> -Original Message-
> From: Thomaiyar, Richard Marian
> Sent: Friday, November 25, 2016 5:21 PM
> To: edk2-devel@lists.01.org
> Cc: Ma, Maurice ; Yao, Jiewen
> ; Mudusuru, Giri P ;
> Thomaiyar, Richard Marian 
> Subject: [PATCH] IntelFsp2Pkg: Add PACKAGES_PATH support
> 
> Add PACKAGES_PATH support in GenCfgOpt.py
> 
> Cc: Maurice Ma 
> Cc: Jiewen Yao 
> Cc: Giri P Mudusuru 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Richard Thomaiyar 
> ---
>  IntelFsp2Pkg/Tools/GenCfgOpt.py | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> index 654cdfc..0675b55 100644
> --- a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> +++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> @@ -523,9 +523,13 @@ EndList
>  if Match:
>  IncludeFilePath =
> Match.group(1)
>  IncludeFilePath =
> self.ExpandMacros(IncludeFilePath)
> -try:
> -IncludeDsc  =
> open(IncludeFilePath, "r")
> -except:
> +PackagesPath =
> os.getenv("PACKAGES_PATH")
> +for PackagePath in
> PackagesPath.split(os.pathsep):
> +IncludeFilePathAbs =
> os.path.join(os.path.normpath(PackagePath),
> os.path.normpath(IncludeFilePath))
> +if
> os.path.exists(IncludeFilePathAbs):
> +IncludeDsc  =
> open(IncludeFilePathAbs, "r")
> +break
> +if IncludeDsc == None:
>  print("ERROR:
> Cannot open file '%s'" % IncludeFilePath)
>  raise SystemExit
>  NewDscLines =
> IncludeDsc.readlines()
> --
> 2.9.0.windows.1

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


[edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Replace deprecated debug level macros

2016-11-29 Thread Marcin Wojtas
From: Jan Dąbroś 

EFI_D_INFO, EFI_D_VERBOSE, EFI_D_WARN and EFI_D_ERROR are replaced
with currently recommended values.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jan Dabros 
Signed-off-by: Marcin Wojtas 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c| 36 +-
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c  | 40 +--
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 22 +++---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c   | 78 +++---
 4 files changed, 88 insertions(+), 88 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
index 61d3517..3f73194 100755
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
@@ -533,7 +533,7 @@ EmmcTuningClkForHs200 (
   do {
 Status = EmmcSendTuningBlk (PassThru, Slot, BusWidth);
 if (EFI_ERROR (Status)) {
-  DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails 
with %r\n", Status));
+  DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails 
with %r\n", Status));
   return Status;
 }
 
@@ -551,7 +551,7 @@ EmmcTuningClkForHs200 (
 }
   } while (++Retry < 40);
 
-  DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails at %d 
times with HostCtrl2 %02x\n", Retry, HostCtrl2));
+  DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails at %d 
times with HostCtrl2 %02x\n", Retry, HostCtrl2));
   //
   // Abort the tuning procedure and reset the tuning circuit.
   //
@@ -618,20 +618,20 @@ EmmcSwitchBusWidth (
   CmdSet = 0;
   Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d fails 
with %r\n", BusWidth, Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d fails 
with %r\n", BusWidth, Status));
 return Status;
   }
 
   Status = EmmcSendStatus (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: Send status fails with %r\n", 
Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Send status fails with %r\n", 
Status));
 return Status;
   }
   //
   // Check the switch operation is really successful or not.
   //
   if ((DevStatus & BIT7) != 0) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: The switch operation fails as 
DevStatus is 0x%08x\n", DevStatus));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: The switch operation fails as 
DevStatus is 0x%08x\n", DevStatus));
 return EFI_DEVICE_ERROR;
   }
 
@@ -686,20 +686,20 @@ EmmcSwitchClockFreq (
 
   Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d fails 
with %r\n", HsTiming, Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d fails 
with %r\n", HsTiming, Status));
 return Status;
   }
 
   Status = EmmcSendStatus (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: Send status fails with %r\n", 
Status));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails with %r\n", 
Status));
 return Status;
   }
   //
   // Check the switch operation is really successful or not.
   //
   if ((DevStatus & BIT7) != 0) {
-DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: The switch operation fails as 
DevStatus is 0x%08x\n", DevStatus));
+DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: The switch operation fails as 
DevStatus is 0x%08x\n", DevStatus));
 return EFI_DEVICE_ERROR;
   }
   //
@@ -995,13 +995,13 @@ EmmcSetBusMode (
 
   Status = EmmcGetCsd (PassThru, Slot, Rca, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", Status));
+DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", Status));
 return Status;
   }
 
   Status = EmmcSelect (PassThru, Slot, Rca);
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: Select fails with %r\n", Status));
+DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: Select fails with %r\n", Status));
 return Status;
   }
 
@@ -1019,7 +1019,7 @@ EmmcSetBusMode (
   //
   Status = EmmcGetExtCsd (PassThru, Slot, );
   if (EFI_ERROR (Status)) {
-DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: GetExtCsd fails with %r\n", Status));
+DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetExtCsd fails with %r\n", Status));
 return Status;
   }
   //
@@ -1065,7 +1065,7 @@ EmmcSetBusMode (
 return EFI_SUCCESS;
   }
 
-  DEBUG ((EFI_D_INFO, "EmmcSetBusMode: HsTiming %d ClockFreq %d BusWidth %d 
Ddr %a\n", HsTiming, ClockFreq, BusWidth, IsDdr ? "TRUE":"FALSE"));
+  DEBUG ((DEBUG_INFO, "EmmcSetBusMode: HsTiming %d ClockFreq %d BusWidth %d 
Ddr %a\n", HsTiming, ClockFreq, BusWidth, IsDdr ? 

[edk2] [PATCH] MdeModulePkg/CapsuleApp: Add Fmp->GetImage() support.

2016-11-29 Thread Jiewen Yao
We add Fmp->GetImage() support in CapsuleApp. So that user may call
Fmp->GetImage() in UEFI shell environment.
This is useful to do unit test for FMP which supports GetImage(),
or user wants to get current image, such as Microcode.

Cc: Eric Dong 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 MdeModulePkg/Application/CapsuleApp/AppSupport.c  | 141 +
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.c  |  57 +-
 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c | 214 
 3 files changed, 411 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Application/CapsuleApp/AppSupport.c 
b/MdeModulePkg/Application/CapsuleApp/AppSupport.c
index 0a1224d..6aea76a 100644
--- a/MdeModulePkg/Application/CapsuleApp/AppSupport.c
+++ b/MdeModulePkg/Application/CapsuleApp/AppSupport.c
@@ -27,6 +27,9 @@
 #include 
 #include 
 
+#define IS_HYPHEN(a)   ((a) == L'-')
+#define IS_NULL(a) ((a) == L'\0')
+
 #define MAX_ARG_NUM 11
 
 UINTN  Argc;
@@ -61,6 +64,144 @@ GetArg (
 }
 
 /**
+  Converts a list of string to a specified buffer.
+
+  @param[out] Buf The output buffer that contains the string.
+  @param[in]  BufferLengthThe length of the buffer
+  @param[in]  Str The input string that contains the hex number
+
+  @retval EFI_SUCCESSThe string was successfully converted to the buffer.
+
+**/
+EFI_STATUS
+StrToBuf (
+  OUT UINT8*Buf,
+  IN  UINTNBufferLength,
+  IN  CHAR16   *Str
+  )
+{
+  UINTN   Index;
+  UINTN   StrLength;
+  UINT8   Digit;
+  UINT8   Byte;
+
+  Digit = 0;
+
+  //
+  // Two hex char make up one byte
+  //
+  StrLength = BufferLength * sizeof (CHAR16);
+
+  for(Index = 0; Index < StrLength; Index++, Str++) {
+
+if ((*Str >= L'a') && (*Str <= L'f')) {
+  Digit = (UINT8) (*Str - L'a' + 0x0A);
+} else if ((*Str >= L'A') && (*Str <= L'F')) {
+  Digit = (UINT8) (*Str - L'A' + 0x0A);
+} else if ((*Str >= L'0') && (*Str <= L'9')) {
+  Digit = (UINT8) (*Str - L'0');
+} else {
+  return EFI_INVALID_PARAMETER;
+}
+
+//
+// For odd characters, write the upper nibble for each buffer byte,
+// and for even characters, the lower nibble.
+//
+if ((Index & 1) == 0) {
+  Byte = (UINT8) (Digit << 4);
+} else {
+  Byte = Buf[Index / 2];
+  Byte &= 0xF0;
+  Byte = (UINT8) (Byte | Digit);
+}
+
+Buf[Index / 2] = Byte;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Converts a string to GUID value.
+  Guid Format is ----
+
+  @param[in]  Str  The registry format GUID string that contains 
the GUID value.
+  @param[out] Guid A pointer to the converted GUID value.
+
+  @retval EFI_SUCCESS The GUID string was successfully converted to the 
GUID value.
+  @retval EFI_UNSUPPORTED The input string is not in registry format.
+  @return others  Some error occurred when converting part of GUID 
value.
+
+**/
+EFI_STATUS
+StrToGuid (
+  IN  CHAR16   *Str,
+  OUT EFI_GUID *Guid
+  )
+{
+  //
+  // Get the first UINT32 data
+  //
+  Guid->Data1 = (UINT32) StrHexToUint64  (Str);
+  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {
+Str ++;
+  }
+
+  if (IS_HYPHEN (*Str)) {
+Str++;
+  } else {
+return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Get the second UINT16 data
+  //
+  Guid->Data2 = (UINT16) StrHexToUint64  (Str);
+  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {
+Str ++;
+  }
+
+  if (IS_HYPHEN (*Str)) {
+Str++;
+  } else {
+return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Get the third UINT16 data
+  //
+  Guid->Data3 = (UINT16) StrHexToUint64  (Str);
+  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {
+Str ++;
+  }
+
+  if (IS_HYPHEN (*Str)) {
+Str++;
+  } else {
+return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Get the following 8 bytes data
+  //
+  StrToBuf (>Data4[0], 2, Str);
+  //
+  // Skip 2 byte hex chars
+  //
+  Str += 2 * 2;
+
+  if (IS_HYPHEN (*Str)) {
+Str++;
+  } else {
+return EFI_UNSUPPORTED;
+  }
+  StrToBuf (>Data4[2], 6, Str);
+
+  return EFI_SUCCESS;
+}
+
+/**
   Return File System Volume containing this shell application.
 
   @return File System Volume containing this shell application.
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
index 23672ae..5137259 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
@@ -86,6 +86,22 @@ DumpFmpData (
   );
 
 /**
+  Dump FMP image data.
+
+  @param[in]  ImageTypeId   The ImageTypeId of the FMP image.
+It is used to identify the FMP protocol.
+  @param[in]  ImageIndexThe ImageIndex of the FMP image.
+It is the input parameter for FMP->GetImage().
+  @param[in]  ImageName The 

[edk2] [PATCH] UefiCpuPkg/MicrocodeUpdate: Fix GetImage API

2016-11-29 Thread Jiewen Yao
Current GetImage API forgets to return data to caller.

Add code to fix it.

Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 .../Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c   | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c 
b/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c
index 2b2d3ac..2eb4ae4 100644
--- a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c
+++ b/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c
@@ -255,6 +255,16 @@ MicrocodeRead (
 TotalSize = MicrocodeEntryPoint->TotalSize;
   }
 
+  if (ImageIndex == Count + 1) {
+if (*ImageSize < TotalSize) {
+  *ImageSize = TotalSize;
+  return EFI_BUFFER_TOO_SMALL;
+}
+*ImageSize = TotalSize;
+CopyMem (Image, MicrocodeEntryPoint, TotalSize);
+return EFI_SUCCESS;
+  }
+
 } else {
   //
   // It is the padding data between the microcode patches for microcode 
patches alignment.
-- 
2.7.4.windows.1

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


Re: [edk2] Which revision of PXE spec does EDK2 code conform to?

2016-11-29 Thread Zimmer, Vincent
Yes.  For IPV4 TFTP-based PXE the wire protocol adheres to the PXE 2.1 
specification with some errata that supercedes that frozen document found under 
section "E.4.20 PXE 2.1 specification wire protocol clarifications" of the UEFI 
2.6 specification.   For IPV6 PXE-style TFTP boot the wire protocol is found 
wholly in the UEFI 2.6 specification.

Vincent

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Heyi Guo
Sent: Tuesday, November 29, 2016 3:38 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng ; Wu, Jiaxin ; Fu, 
Siyuan ; Zeng, Star 
Subject: [edk2] Which revision of PXE spec does EDK2 code conform to?

Hi folks,

Which revision of PXE spec does EDK2 code conform to? Is it PXE v2.1? Do PXE 
implementations in MdeModulePkg and NetworkPkg comform to the same revision?

Thanks and regards,

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


[edk2] [Patch] BaseTools: fix the bug to add PaletteSize info into AutoGen

2016-11-29 Thread Yonghong Zhu
Fix the bug to add PaletteSize info into AutoGen.c when the flag
UEFI_HII_RESOURCE_SECTION is set to FALSE.

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

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index de6eb0e..63cfe04 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1693,14 +1693,15 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, 
IdfGenCFlag, IdfGenBinBuffer):
 TempBuffer += Buffer
 elif File.Ext.upper() == '.BMP':
 TempBuffer, TempPalette = 
BmpImageDecoder(File, Buffer, PaletteIndex, FileObj.TransParent)
 if len(TempPalette) > 1:
 PaletteIndex += 1
-PaletteBuffer += pack('H', 
len(TempPalette))
-PaletteBuffer += TempPalette
+NewPalette = pack('H', len(TempPalette))
+NewPalette += TempPalette
+PaletteBuffer += NewPalette
 PaletteStr = WriteLine(PaletteStr, '// %s: 
%s: %s' % (DecToHexStr(PaletteIndex - 1, 4), ID, DecToHexStr(PaletteIndex - 1, 
4)))
-TempPaletteList = AscToHexList(TempPalette)
+TempPaletteList = AscToHexList(NewPalette)
 PaletteStr = WriteLine(PaletteStr, 
CreateArrayItem(TempPaletteList, 16) + '\n')
 ImageBuffer += TempBuffer
 BufferStr = WriteLine(BufferStr, '// %s: %s: %s' % 
(DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4)))
 TempBufferList = AscToHexList(TempBuffer)
 BufferStr = WriteLine(BufferStr, 
CreateArrayItem(TempBufferList, 16) + '\n')
-- 
2.6.1.windows.1

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


[edk2] Which revision of PXE spec does EDK2 code conform to?

2016-11-29 Thread Heyi Guo

Hi folks,

Which revision of PXE spec does EDK2 code conform to? Is it PXE v2.1? Do 
PXE implementations in MdeModulePkg and NetworkPkg comform to the same 
revision?


Thanks and regards,

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


Re: [edk2] [Patch 0/6] Fix MinnowMax build and boot issues

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

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, November 29, 2016 6:12 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Wei, David
> ; Guo, Mang 
> Subject: [Patch 0/6] Fix MinnowMax build and boot issues
> 
> This patch series fixes a number of minor issues that prevent
> MinnowMax from building and booting using latest verison of
> edk2/master.  With these updates, MinnowMax for both IA32 and
> X64 can boot to the UEFI Shell.
> 
> A few of these changes are workarounds for issues in the
> binary support modules for MinnowMax.  These workarounds will
> be removed in the future once the issues are addressed.
> 
> Cc: Jiewen Yao 
> Cc: David Wei 
> Cc: Mang Guo 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney 
> 
> Michael Kinney (6):
>   Vlv2TbltDevicePkg: Allow BaseTools to run from sources
>   Vlv2TbltDevicePkg: Set CAPSULE_ENABLE to TRUE
>   Vlv2TbltDevicePkg/PlatformInitPei: Workaround unaligned SMRAM size
>   Vlv2TbltDevicePkg: Remove SMM binary modules from FDF
>   Vlv2TbltDevicePkg/PlatformFlashAccessLib: Fix IA32 build issues
>   Vlv2TbltDevicePkg: Fix IA32 boot timeouts
> 
>  .../PlatformFlashAccessLib/PlatformFlashAccessLib.c   | 12
> ++--
>  Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c | 15
> ++-
>  Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h |  3 ++-
>  Vlv2TbltDevicePkg/PlatformInitPei/PlatformInitPei.inf |  3 ++-
>  Vlv2TbltDevicePkg/PlatformPkg.fdf |  9
> +++--
>  Vlv2TbltDevicePkg/PlatformPkgConfig.dsc   |  2 +-
>  Vlv2TbltDevicePkg/PlatformPkgGcc.fdf  |  9
> +++--
>  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc |  9
> +++--
>  Vlv2TbltDevicePkg/bld_vlv.bat |  2 +-
>  9 files changed, 43 insertions(+), 21 deletions(-)
> 
> --
> 2.6.3.windows.1

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


[edk2] [Patch 4/6] Vlv2TbltDevicePkg: Remove SMM binary modules from FDF

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=261
https://bugzilla.tianocore.org/show_bug.cgi?id=262

Remove the PowerManagement2 binary SMM module that generates an
ASSERT() and the DigitalThermalSensor binary SMM module that
causes an AP to be stuck in the busy state.

This is a workaround until these two SMM binary modules can be
updated.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/PlatformPkg.fdf| 9 +++--
 Vlv2TbltDevicePkg/PlatformPkgGcc.fdf | 9 +++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkg.fdf 
b/Vlv2TbltDevicePkg/PlatformPkg.fdf
index 907c6bd..cb5b6b7 100644
--- a/Vlv2TbltDevicePkg/PlatformPkg.fdf
+++ b/Vlv2TbltDevicePkg/PlatformPkg.fdf
@@ -593,8 +593,13 @@ INF UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
 INF UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
 INF 
$(PLATFORM_PACKAGE)/SmmSwDispatch2OnSmmSwDispatchThunk/SmmSwDispatch2OnSmmSwDispatchThunk.inf
-INF RuleOverride = BINARY 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/PowerManagement2.inf
-INF RuleOverride = BINARY 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/DigitalThermalSensor.inf
+
+#
+# Remove the following two SMM binary modules that prevent platform from 
booting to UEFI Shell
+#
+#INF RuleOverride = BINARY 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/PowerManagement2.inf
+#INF RuleOverride = BINARY 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/DigitalThermalSensor.inf
+
   #
   # ACPI
   #
diff --git a/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf 
b/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
index dccb2c9..4243b07 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
+++ b/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
@@ -550,8 +550,13 @@ INF UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
 INF UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
 INF 
$(PLATFORM_PACKAGE)/SmmSwDispatch2OnSmmSwDispatchThunk/SmmSwDispatch2OnSmmSwDispatchThunk.inf
-INF RuleOverride = BINARY 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/PowerManagement2.inf
-INF RuleOverride = BINARY 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/DigitalThermalSensor.inf
+
+#
+# Remove the following two SMM binary modules that prevent platform from 
booting to UEFI Shell
+#
+#INF RuleOverride = BINARY 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/PowerManagement2.inf
+#INF RuleOverride = BINARY 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/$(DXE_ARCHITECTURE)/DigitalThermalSensor.inf
+
   #
   # ACPI
   #
-- 
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/6] Vlv2TbltDevicePkg: Allow BaseTools to run from sources

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=258

Update bld_vlv.bat to run BaseTools build command with a call
statement to support running the build command from python
sources.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/bld_vlv.bat | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/bld_vlv.bat b/Vlv2TbltDevicePkg/bld_vlv.bat
index e02a605..6c53917 100644
--- a/Vlv2TbltDevicePkg/bld_vlv.bat
+++ b/Vlv2TbltDevicePkg/bld_vlv.bat
@@ -205,7 +205,7 @@ if %ERRORLEVEL% NEQ 0 goto BldFail
 
 echo.
 echo Invoking EDK2 build...
-build %Build_Flags%
+call build %Build_Flags%
 
 if %ERRORLEVEL% NEQ 0 goto BldFail
 
-- 
2.6.3.windows.1

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


[edk2] [Patch 6/6] Vlv2TbltDevicePkg: Fix IA32 boot timeouts

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=264

The IA32 build gets timeouts booting to the UEFI Shell.
Update the IA32 DSC file to match the X64 DSC file
disabling the fTPM feature.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 6d88154..3a5776a 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -77,9 +77,9 @@
 
   DEFINE   PLATFORM_PCIEXPRESS_BASE   = 0E000
 
-  DEFINE SEC_ENABLE = TRUE
-  DEFINE SEC_DEBUG_INFO_ENABLE = TRUE
-  DEFINE FTPM_ENABLE = TRUE
+  DEFINE SEC_ENABLE = FALSE
+  DEFINE SEC_DEBUG_INFO_ENABLE = FALSE
+  DEFINE FTPM_ENABLE = FALSE
 
 

 #
@@ -848,9 +848,6 @@
   !if $(TPM_ENABLED) == TRUE
 gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x7b, 0x3a, 0xcd, 0x72, 
0xA5, 0xFE, 0x5e, 0x4f, 0x91, 0x65, 0x4d, 0xd1, 0x21, 0x87, 0xbb, 0x13}
   !endif
-  !if $(FTPM_ENABLE) == TRUE
-gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x7b, 0x3a, 0xcd, 0x72, 
0xA5, 0xFE, 0x5e, 0x4f, 0x91, 0x65, 0x4d, 0xd1, 0x21, 0x87, 0xbb, 0x13}
-  !endif
 
   ## This PCD defines the video horizontal resolution.
   #  This PCD could be set to 0 then video resolution could be at highest 
resolution.
-- 
2.6.3.windows.1

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


[edk2] [Patch 5/6] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Fix IA32 build issues

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=263

Fix IA32 build issues in the PlatformFlashAccessLib.  Some of the
UINT64 FLASH addresses values need to be typecast to UINTN.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 .../Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c  | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
 
b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
index efa1dca..f3cb31d 100644
--- 
a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
+++ 
b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
@@ -59,7 +59,7 @@ PerformFlashWrite (
   }
 
   DEBUG((DEBUG_INFO, "  - 0x%x(%x) - 0x%x\n", 
(UINTN)FlashAddress, (UINTN)FlashAddressType, Length));
-  LibFvbFlashDeviceBlockLock(FlashAddress, Length, FALSE);
+  LibFvbFlashDeviceBlockLock((UINTN)FlashAddress, Length, FALSE);
 
   //
   // Erase & Write
@@ -67,7 +67,7 @@ PerformFlashWrite (
   Status = LibFvbFlashDeviceBlockErase((UINTN)FlashAddress, Length);
   ASSERT_EFI_ERROR(Status);
   if (EFI_ERROR(Status)) {
-LibFvbFlashDeviceBlockLock(FlashAddress, Length, TRUE);
+LibFvbFlashDeviceBlockLock((UINTN)FlashAddress, Length, TRUE);
 DEBUG((DEBUG_ERROR, "Flash Erase error\n"));
 return Status;
   }
@@ -75,12 +75,12 @@ PerformFlashWrite (
   Status = LibFvbFlashDeviceWrite((UINTN)FlashAddress, , Buffer);
   ASSERT_EFI_ERROR(Status);
   if (EFI_ERROR(Status)) {
-LibFvbFlashDeviceBlockLock(FlashAddress, Length, TRUE);
+LibFvbFlashDeviceBlockLock((UINTN)FlashAddress, Length, TRUE);
 DEBUG((DEBUG_ERROR, "Flash write error\n"));
 return Status;
   }
 
-  LibFvbFlashDeviceBlockLock(FlashAddress, Length, TRUE);
+  LibFvbFlashDeviceBlockLock((UINTN)FlashAddress, Length, TRUE);
 
   return EFI_SUCCESS;
 }
@@ -146,10 +146,10 @@ MicrocodeFlashWrite (
 // Save original buffer
 //
 if (OffsetHead != 0) {
-  CopyMem((UINT8 *)AlignedBuffer, (VOID *)AlignedFlashAddress, OffsetHead);
+  CopyMem((UINT8 *)AlignedBuffer, (VOID *)(UINTN)AlignedFlashAddress, 
OffsetHead);
 }
 if (OffsetTail != 0) {
-  CopyMem((UINT8 *)AlignedBuffer + OffsetHead + Length, (VOID 
*)(AlignedFlashAddress + OffsetHead + Length), OffsetTail);
+  CopyMem((UINT8 *)AlignedBuffer + OffsetHead + Length, (VOID 
*)(UINTN)(AlignedFlashAddress + OffsetHead + Length), OffsetTail);
 }
 //
 // Override new buffer
-- 
2.6.3.windows.1

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


[edk2] [Patch 2/6] Vlv2TbltDevicePkg: Set CAPSULE_ENABLE to TRUE

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=259

Set CAPSULE_ENABLE to TRUE so the standard Vlv2TbltDevicePkg
platform builds can complete.  Build_IFWI.bat assumes this
flag is TRUE.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/PlatformPkgConfig.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgConfig.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgConfig.dsc
index 0932add..c93ca8a 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgConfig.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgConfig.dsc
@@ -63,7 +63,7 @@ DEFINE SECURE_BOOT_ENABLE = TRUE
 DEFINE USER_IDENTIFICATION_ENABLE = FALSE
 DEFINE VARIABLE_INFO_ENABLE = FALSE
 DEFINE S3_ENABLE = TRUE
-DEFINE CAPSULE_ENABLE = FALSE
+DEFINE CAPSULE_ENABLE = TRUE
 DEFINE CAPSULE_RESET_ENABLE = TRUE
 DEFINE RECOVERY_ENABLE = FALSE
 DEFINE MICOCODE_CAPSULE_ENABLE = FALSE
-- 
2.6.3.windows.1

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


[edk2] [Patch 3/6] Vlv2TbltDevicePkg/PlatformInitPei: Workaround unaligned SMRAM size

2016-11-29 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=260

The PiSmmCPuDxeSmm module requires the SMRR base address and length
to be aligned.  The memory initialization for Vlv2TbltDevicePkg
produces an SMRAM base address that is on a 16MB boundary and an
SMRAM length of 12MB.  The SMRAM length is rounded up to 16MB.

This is a workaround until the binary module that produces the
gEfiSmmPeiSmramMemoryReserveGuid HOB is updated

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c | 15 ++-
 Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h |  3 ++-
 Vlv2TbltDevicePkg/PlatformInitPei/PlatformInitPei.inf |  3 ++-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c 
b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
index cbfe78d..f8ea09a 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2004  - 2014, 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 that accompanies this 
distribution.  

@@ -820,6 +820,19 @@ PlatformEarlyInitEntry (
   EFI_PLATFORM_INFO_HOB   *PlatformInfo;
   EFI_PEI_HOB_POINTERSHob;
   EFI_PLATFORM_CPU_INFO   PlatformCpuInfo;
+  EFI_SMRAM_HOB_DESCRIPTOR_BLOCK  *DescriptorBlock;
+  UINT64  Size;
+
+  //
+  // Make sure last SMRAM region is aligned
+  //
+  Hob.Raw = GetFirstGuidHob ();
+  if (Hob.Raw != NULL) {
+DescriptorBlock = GET_GUID_HOB_DATA (Hob.Raw);
+Size = 
DescriptorBlock->Descriptor[DescriptorBlock->NumberOfSmmReservedRegions - 
1].PhysicalSize;
+Size = LShiftU64 (1, HighBitSet64 (Size - 1) + 1);
+DescriptorBlock->Descriptor[DescriptorBlock->NumberOfSmmReservedRegions - 
1].PhysicalSize = Size;
+  }
 
   //
   // Initialize SmbusPolicy PPI
diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h 
b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
index c2cdfa3..c280fb8 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
@@ -1,6 +1,6 @@
 /*++
 
-  Copyright (c) 2004  - 2014, 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 that accompanies this 
distribution.  

@@ -83,6 +83,7 @@ Abstract:
 #include 
 #include 
 #include 
+#include 
 
 #define SMC_LAN_ON   0x46
 #define SMC_LAN_OFF0x47
diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformInitPei.inf 
b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformInitPei.inf
index fc517ef..309487d 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformInitPei.inf
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformInitPei.inf
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c)  1999  - 2014, Intel Corporation. All rights reserved
+# Copyright (c)  1999  - 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 that accompanies this 
distribution.  

@@ -102,6 +102,7 @@ ENTRY_POINT= 
PlatformEarlyInitEntry
   gEfiNormalSetupGuid
   gEfiMemoryTypeInformationGuid
   gOsSelectionVariableGuid
+  gEfiSmmPeiSmramMemoryReserveGuid
 
 [Pcd.common]
   gPlatformModuleTokenSpaceGuid.PcdFlashFvMainBase
-- 
2.6.3.windows.1

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


[edk2] [Patch 0/6] Fix MinnowMax build and boot issues

2016-11-29 Thread Michael Kinney
This patch series fixes a number of minor issues that prevent
MinnowMax from building and booting using latest verison of
edk2/master.  With these updates, MinnowMax for both IA32 and
X64 can boot to the UEFI Shell.

A few of these changes are workarounds for issues in the 
binary support modules for MinnowMax.  These workarounds will
be removed in the future once the issues are addressed.

Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 

Michael Kinney (6):
  Vlv2TbltDevicePkg: Allow BaseTools to run from sources
  Vlv2TbltDevicePkg: Set CAPSULE_ENABLE to TRUE
  Vlv2TbltDevicePkg/PlatformInitPei: Workaround unaligned SMRAM size
  Vlv2TbltDevicePkg: Remove SMM binary modules from FDF
  Vlv2TbltDevicePkg/PlatformFlashAccessLib: Fix IA32 build issues
  Vlv2TbltDevicePkg: Fix IA32 boot timeouts

 .../PlatformFlashAccessLib/PlatformFlashAccessLib.c   | 12 ++--
 Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c | 15 ++-
 Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h |  3 ++-
 Vlv2TbltDevicePkg/PlatformInitPei/PlatformInitPei.inf |  3 ++-
 Vlv2TbltDevicePkg/PlatformPkg.fdf |  9 +++--
 Vlv2TbltDevicePkg/PlatformPkgConfig.dsc   |  2 +-
 Vlv2TbltDevicePkg/PlatformPkgGcc.fdf  |  9 +++--
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc |  9 +++--
 Vlv2TbltDevicePkg/bld_vlv.bat |  2 +-
 9 files changed, 43 insertions(+), 21 deletions(-)

-- 
2.6.3.windows.1

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


Re: [edk2] [PATCH v3 0/2] UefiCpuPkg, OvmfPkg: set maximum (V)CPU count dynamically

2016-11-29 Thread Laszlo Ersek
On 11/28/16 14:08, Laszlo Ersek wrote:
> This is the v3 update on
> .
> 
> Changes in this version [Jeff]:
> - preserve original behavior for PcdCpuApInitTimeOutInMicroSeconds==0
> - use MAX_UINT32 (~71 minutes) as "infinite wait"
> 
> Repo:   https://github.com/lersek/edk2/
> Branch: mpinit_v3
> 
> Cc: Igor Mammedov 
> Cc: Jeff Fan 
> Cc: Jordan Justen 
> Cc: Michael Kinney 
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (2):
>   UefiCpuPkg/MpInitLib: wait no longer than necessary for initial AP
> startup
>   OvmfPkg/PlatformPei: take VCPU count from QEMU and configure MpInitLib
> 
>  OvmfPkg/OvmfPkgIa32.dsc  |  4 ++
>  OvmfPkg/OvmfPkgIa32X64.dsc   |  4 ++
>  OvmfPkg/OvmfPkgX64.dsc   |  4 ++
>  OvmfPkg/PlatformPei/PlatformPei.inf  |  1 +
>  OvmfPkg/PlatformPei/Platform.h   |  2 +
>  OvmfPkg/PlatformPei/MemDetect.c  |  2 +-
>  OvmfPkg/PlatformPei/Platform.c   | 43 
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 73 +++-
>  8 files changed, 131 insertions(+), 2 deletions(-)
> 

Thanks all for the reviews, series pushed as 2b2efe33eace..45a70db3c3a5.

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