[edk2] [Patch v2] Vlv2TbltDevicePkg: Remove reference deprecated macro.

2017-08-03 Thread Eric Dong
v2 changes include:
1. Use MSR data structure instead of redefin local macro.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Cc: David Wei 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c | 29 ++
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c 
b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
index 5a18a3f..6f37e3b 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
@@ -196,16 +196,22 @@ SetPeiCacheMode (
   // Cache the flash area to improve the boot performance in PEI phase
   //
   Index = 0;
-  MtrrSetting.Variables.Mtrr[0].Base = (FixedPcdGet32 
(PcdFlashAreaBaseAddress) | CacheWriteProtected);
-  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 
(PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+  ((MSR_IA32_MTRR_PHYSBASE_REGISTER *) 
[0].Base)->Uint64 = FixedPcdGet32 
(PcdFlashAreaBaseAddress);
+  ((MSR_IA32_MTRR_PHYSBASE_REGISTER *) 
[0].Base)->Bits.Type = CacheWriteProtected;
+  ((MSR_IA32_MTRR_PHYSMASK_REGISTER *) 
[0].Mask)->Uint64 = (~((UINT64)(FixedPcdGet32 
(PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask;
+  ((MSR_IA32_MTRR_PHYSMASK_REGISTER *) 
[0].Mask)->Bits.V = 1;
+
   Index ++;
 
   MemOverflow =0;
   while (MaxMemoryLength > MemOverflow){
-MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & 
ValidMtrrAddressMask) | CacheWriteBack;
 MemoryLength = MaxMemoryLength - MemOverflow;
 MemoryLength = GetPowerOfTwo64 (MemoryLength);
-MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+
+((MSR_IA32_MTRR_PHYSBASE_REGISTER *) 
[Index].Base)->Uint64 = MemOverflow & 
ValidMtrrAddressMask;
+((MSR_IA32_MTRR_PHYSBASE_REGISTER *) 
[Index].Base)->Bits.Type = CacheWriteBack;
+((MSR_IA32_MTRR_PHYSMASK_REGISTER *) 
[Index].Mask)->Uint64 = (~(MemoryLength - 1)) & 
ValidMtrrAddressMask;
+((MSR_IA32_MTRR_PHYSMASK_REGISTER *) 
[Index].Mask)->Bits.V = 1;
 
 MemOverflow += MemoryLength;
 Index++;
@@ -216,23 +222,28 @@ SetPeiCacheMode (
   while (MaxMemoryLength != MemoryLength) {
 MemoryLengthUc = GetPowerOfTwo64 (MaxMemoryLength - MemoryLength);
 
-MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength - 
MemoryLengthUc) & ValidMtrrAddressMask) | CacheUncacheable;
-MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+((MSR_IA32_MTRR_PHYSBASE_REGISTER *) 
[Index].Base)->Uint64 = (MaxMemoryLength - 
MemoryLengthUc) & ValidMtrrAddressMask;
+((MSR_IA32_MTRR_PHYSBASE_REGISTER *) 
[Index].Base)->Bits.Type = CacheUncacheable;
+((MSR_IA32_MTRR_PHYSMASK_REGISTER *) 
[Index].Mask)->Uint64 = (~(MemoryLengthUc   - 1)) & 
ValidMtrrAddressMask;
+((MSR_IA32_MTRR_PHYSMASK_REGISTER *) 
[Index].Mask)->Bits.V = 1;
+
 MaxMemoryLength -= MemoryLengthUc;
 Index++;
   }
 
   MemOverflow =0x1;
   while (HighMemoryLength > 0) {
-MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & 
ValidMtrrAddressMask) | CacheWriteBack;
+
 MemoryLength = HighMemoryLength;
 MemoryLength = GetPowerOfTwo64 (MemoryLength);
-
 if (MemoryLength > MemOverflow){
   MemoryLength = MemOverflow;
 }
 
-MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+((MSR_IA32_MTRR_PHYSBASE_REGISTER *) 
[Index].Base)->Uint64 = MemOverflow & 
ValidMtrrAddressMask;
+((MSR_IA32_MTRR_PHYSBASE_REGISTER *) 
[Index].Base)->Bits.Type = CacheWriteBack;
+((MSR_IA32_MTRR_PHYSMASK_REGISTER *) 
[Index].Mask)->Uint64 = (~(MemoryLength - 1)) & 
ValidMtrrAddressMask;
+((MSR_IA32_MTRR_PHYSMASK_REGISTER *) 
[Index].Mask)->Bits.V = 1;
 
 MemOverflow += MemoryLength;
 HighMemoryLength -= MemoryLength;
-- 
2.7.0.windows.1

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


[edk2] [Patch] Edk2: Update UefiCpuPkg owner.

2017-08-03 Thread Eric Dong
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 Maintainers.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Maintainers.txt b/Maintainers.txt
index 39b5b67..9d1b9fb 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -231,7 +231,7 @@ M: Jaben Carsey 
 
 UefiCpuPkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/UefiCpuPkg
-M: Jeff Fan 
+M: Eric Dong 
 
 UnixPkg
 W: https://github.com/tianocore/tianocore.github.io/wiki/UnixPkg
-- 
2.7.0.windows.1

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


Re: [edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.

2017-08-03 Thread Dong, Eric
Ray,

I check the spec, found the Quark definition has some small difference with 
normal MSR. So I prefer not do this change for Quark.

Thanks,
Eric
-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, August 3, 2017 6:22 PM
To: Dong, Eric ; edk2-devel@lists.01.org
Cc: Fan, Jeff ; Kinney, Michael D 

Subject: RE: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.

Eric,
Please refer to the below code sample to avoid defining local macros.

 MSR_IA32_MTRR_DEF_TYPE_REGISTER  DefType;
  //
  // Enable Cache MTRR
  //
  DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE);
  DefType.Bits.E = 1;
  DefType.Bits.FE = 1;
  AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64);

Thanks/Ray

> -Original Message-
> From: Dong, Eric
> Sent: Thursday, August 3, 2017 5:32 PM
> To: edk2-devel@lists.01.org
> Cc: Fan, Jeff ; Ni, Ruiyu ; 
> Kinney, Michael D 
> Subject: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated 
> macro.
> 
> Cc: Jeff Fan 
> Cc: Ruiyu Ni 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong 
> ---
>  .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c| 26 +--
> ---
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> index 2760427..fe00b37 100644
> --- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> +++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> @@ -23,6 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, 
> EITHER EXPRESS OR IMPLIED.
> 
>  #define QUARK_SOC_CPUID_FAMILY_MODEL_STEPPING 0x590
> 
> +#define CACHE_MTRR_ENABLED0x800
> +#define CACHE_FIXED_MTRR_ENABLED  0x400
> +#define IA32_MTRR_CAP_VCNT_MASK   0xFF
> +
>  //
>  // Context to save and restore when MTRRs are programmed  // @@ 
> -121,7
> +125,7 @@ GetVariableMtrrCountWorker (  {
>UINT32  VariableMtrrCount;
> 
> -  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) & 
> MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
> +  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> + (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> IA32_MTRR_CAP_VCNT_MASK);
>ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
>return VariableMtrrCount;
>  }
> @@ -558,7 +562,7 @@ MtrrGetMemoryAttributeInVariableMtrrWorker (
> 
>ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) * 
> MTRR_NUMBER_OF_VARIABLE_MTRR);
>for (Index = 0, UsedMtrr = 0; Index < FirmwareVariableMtrrCount; 
> Index++) {
> -if ((VariableSettings->Mtrr[Index].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) != 0) {
> +if ((VariableSettings->Mtrr[Index].Mask & CACHE_MTRR_ENABLED) != 
> + 0) {
>VariableMtrr[Index].Msr = (UINT32)Index;
>VariableMtrr[Index].BaseAddress = 
> (VariableSettings->Mtrr[Index].Base
> & MtrrValidAddressMask);
>VariableMtrr[Index].Length  = 
> ((~(VariableSettings->Mtrr[Index].Mask
> & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1; @@ -969,7 +973,7 @@ 
> ProgramVariableMtrr (
>// MTRR Physical Mask
>//
>TempQword = ~(Length - 1);
> -  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> MtrrValidAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
> +  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> + MtrrValidAddressMask) | CACHE_MTRR_ENABLED;
>  }
> 
> 
> @@ -1157,7 +1161,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>}
>MtrrType = MTRR_CACHE_INVALID_TYPE;
> 
> -  if ((TempQword & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +  if ((TempQword & CACHE_MTRR_ENABLED) == 0) {
>  return CacheUncacheable;
>}
> 
> @@ -1165,7 +1169,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>// If address is less than 1M, then try to go through the fixed MTRR
>//
>if (Address < BASE_1MB) {
> -if ((TempQword & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED) != 0) {
> +if ((TempQword & CACHE_FIXED_MTRR_ENABLED) != 0) {
>//
>// Go through the fixed MTRR
>//
> @@ -1539,7 +1543,7 @@ MtrrSetMemoryAttributeWorker (
>}
>if (MtrrSetting != NULL) {
>  MtrrSetting->Fixed.Mtrr[MsrNum] = 
> (MtrrSetting->Fixed.Mtrr[MsrNum] & ~ClearMask) | OrMask;
> -MtrrSetting->MtrrDefType |=
> MTRR_LIB_CACHE_FIXED_MTRR_ENABLED;
> +MtrrSetting->MtrrDefType |= CACHE_FIXED_MTRR_ENABLED;
>} else {
>  if (!FixedSettingsValid[MsrNum]) {
>WorkingFixedSettings.Mtrr[MsrNum] = MtrrRegisterRead 
> (mMtrrLibFixedMtrrTable[MsrNum].Msr);
> @@ -1654,7 +1658,7 @@ MtrrSetMemoryAttributeWorker (
>// Find first unused MTRR
>//
>for (MsrNum = 0; MsrNum < 

Re: [edk2] Issue of step by step debugging of OVMF SEC code in QEMU

2017-08-03 Thread Andrew Fish
It is generally hard to debug across x86 processor mode transitions, and to 
debug 16-bit real mode code with modern tools. There are a few places in the 
x86 that still require 16-bit real mode for handoffs (like the reset vector) so 
you tend to hit this issue more in debugging firmware.

Thanks,

Andrew Fish


> On Aug 3, 2017, at 8:41 PM, wang xiaofeng  wrote:
> 
> Hi  Andrew,
> THe problem is solved, after the SEC code switch to protected mode, gdb 
> can work well now
> 
> 
> 
> 
> 
> 
> At 2017-08-04 11:26:16, "wang xiaofeng"  wrote:
> HI Andrew,
>  How can I adjust the debugger to correct mode? Or I have to enable the 
> debug after swtich to protected mode?
> 
> 
> 
> 
> 
> 
> At 2017-08-04 10:57:16, "Andrew Fish"  > wrote:
> >The reset vector is 16-bit real mode, so you have the debugger in the wrong 
> >mode. The code should transition to 32 bit protected early in the flow.
> >
> >Sent from my iPhone
> >
> >> On Aug 3, 2017, at 7:47 PM, wang xiaofeng  >> > wrote:
> >> 
> >> Hello,
> >>   I am tring to add my own SEC code base on OVMF and run on QEMU. 
> >> Since the code cannot run I need to step to step trace the assembly code .
> >>  The hang point is very early before I can use either UDK or debug 
> >> serial output. I tried to use gdb to connect to QEMU.I start gdb in 
> >> another terminal, and issue the following commands:
> >>  (gdb) set architecture i386:x86-64:intel
> >>  (gdb) target remote localhost:1234
> >>   It really stops at the bios first instruction at 0XFFF0. But gdb 
> >> shows eip= 0xFFF0 and CS=0xF000(why it not be 0xfff0). After I trigger the 
> >> command "display /i $pc"
> >>   It shows the assembly code in 0xFFF0 instead of0XFFF0, so the 
> >> information is incorrect.
> >>   Anyone knows how to corrently debug the SEC code ? Other debug tool is 
> >> also ok.
> >>   Thanks in advance!
> >> 
> >> 
> >> 
> >> ___
> >> 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
> 
> 
>  
> 
> 
> 【网易自营|30天无忧退货】不到同款1折价!Tory Burch制造商美式休闲人字拖限时仅29.9元>> 
> 

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


[edk2] [PATCH V3] MdeModulePkg/DisplayEngine: Fix incorrect display issue

2017-08-03 Thread Dandan Bi
In a form, some new menus may be dynamically inserted between highlight
menu and previous top of screen menu when some question are refreshed.
So the highlight menu and previous top of screen menu perhaps can't be
shown in one page. Existing codes miss to handle this case then will
cause incorrect display.This patch is to fix this display issue.

Cc: Eric Dong 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 .../Universal/DisplayEngineDxe/FormDisplay.c   | 62 ++
 1 file changed, 52 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c 
b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
index dc4ae4b..bbb2675 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
@@ -1716,27 +1716,60 @@ IsTopOfScreeMenuOption (
 
   return FALSE;
 }
 
 /**
-  Find the Top of screen menu.
+  Calculate the distance between two menus and include the skip value of 
StartMenu.
 
-  If the input is NULL, base on the record highlight info in
-  gHighligthMenuInfo to find the last highlight menu.
+  @param  StartMenu The link_entry pointer to start menu.
+  @param  EndMenu   The link_entry pointer to end menu.
 
-  @param  HighLightedStatement  The input highlight statement.
+**/
+UINTN
+GetDistanceBetweenMenus(
+  IN LIST_ENTRY  *StartMenu,
+  IN LIST_ENTRY  *EndMenu
+)
+{
+  LIST_ENTRY *Link;
+  UI_MENU_OPTION *MenuOption;
+  UINTN  Distance;
 
-  @retval  The highlight menu index.
+  Distance = 0;
+
+  Link = StartMenu;
+  while (Link != EndMenu) {
+MenuOption = MENU_OPTION_FROM_LINK (Link);
+if (MenuOption->Row == 0) {
+  UpdateOptionSkipLines (MenuOption);
+}
+Distance += MenuOption->Skip;
+Link = Link->BackLink;
+  }
+  return Distance;
+}
+
+/**
+  Find the top of screen menu base on the previous record menu info.
+
+  @param  HighLightMenu  The link_entry pointer to highlight menu.
+
+  @retval  Return the the link_entry pointer top of screen menu.
 
 **/
 LIST_ENTRY *
 FindTopOfScreenMenuOption (
- VOID
- )
+  IN LIST_ENTRY   *HighLightMenu
+  )
 {
   LIST_ENTRY  *NewPos;
   UI_MENU_OPTION  *MenuOption;
+  UINTN   TopRow;
+  UINTN   BottomRow;
+
+  TopRow= gStatementDimensions.TopRow+ SCROLL_ARROW_HEIGHT;
+  BottomRow = gStatementDimensions.BottomRow - SCROLL_ARROW_HEIGHT;
 
   NewPos = gMenuOption.ForwardLink;
   MenuOption = MENU_OPTION_FROM_LINK (NewPos);
 
   while (!IsTopOfScreeMenuOption(MenuOption)) {
@@ -1752,11 +1785,20 @@ FindTopOfScreenMenuOption (
 
   //
   // Last time top of screen menu has disappeared.
   //
   if (NewPos == ) {
-NewPos = NULL;
+return NULL;
+  }
+  //
+  // Check whether highlight menu and top of screen menu can be shown within 
one page,
+  // if can't, return NULL to re-calcaulate the top of scrren menu. Because 
some new menus
+  // may be dynamically inserted between highlightmenu and previous top of 
screen menu,
+  // So previous record top of screen menu is not appropriate for current 
display.
+  //
+  if (GetDistanceBetweenMenus (HighLightMenu, NewPos) + 1 > BottomRow - 
TopRow) {
+return NULL;
   }
 
   return NewPos;
 }
 
@@ -1803,11 +1845,11 @@ FindTopMenu (
   UpdateOptionSkipLines (MenuOption);
 
   //
   // Found the last time highlight menu.
   //
-  *TopOfScreen = FindTopOfScreenMenuOption();
+  *TopOfScreen = FindTopOfScreenMenuOption(*HighlightMenu);
   if (*TopOfScreen != NULL) {
 //
 // Found the last time selectable top of screen menu.
 //
 AdjustDateAndTimePosition(TRUE, TopOfScreen);
@@ -1856,11 +1898,11 @@ FindTopMenu (
   // Update skip info for this highlight menu.
   //
   MenuOption = MENU_OPTION_FROM_LINK (*HighlightMenu);
   UpdateOptionSkipLines (MenuOption);
   
-  *TopOfScreen = FindTopOfScreenMenuOption();
+  *TopOfScreen = FindTopOfScreenMenuOption(*HighlightMenu);
   if (*TopOfScreen == NULL) {
 //
 // Not found last time top of screen menu, so base on current 
highlight menu
 // to find the new top of screen menu.
 // Make the current highlight menu at the bottom of the form to 
calculate the
-- 
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 v4 2/3] UefiCpuPkg: Add Processor Trace feature definition.

2017-08-03 Thread Fan, Jeff
Reviewed-by: Jeff Fan 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Dong
Sent: Friday, August 04, 2017 11:37 AM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu; Fan, Jeff
Subject: [edk2] [Patch v4 2/3] UefiCpuPkg: Add Processor Trace feature 
definition.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h 
b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
index 54153f4..9331e49 100644
--- a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
+++ b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
@@ -71,6 +71,7 @@
 #define CPU_FEATURE_APIC_TPR_UPDATE_MESSAGE (32+9)
 #define CPU_FEATURE_ENERGY_PERFORMANCE_BIAS (32+10)
 #define CPU_FEATURE_PPIN(32+11)
+#define CPU_FEATURE_PROC_TRACE  (32+12)
 
 #define CPU_FEATURE_BEFORE_ALL  BIT27
 #define CPU_FEATURE_AFTER_ALL   BIT28
-- 
2.7.0.windows.1

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


Re: [edk2] [Patch v4 1/3] UefiCpuPkg: Add Pcds used by processor trace feature.

2017-08-03 Thread Fan, Jeff
Reviewed-by: Jeff Fan 

-Original Message-
From: Dong, Eric 
Sent: Friday, August 04, 2017 11:37 AM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff; Ni, Ruiyu
Subject: [Patch v4 1/3] UefiCpuPkg: Add Pcds used by processor trace feature.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/UefiCpuPkg.dec | 8 
 1 file changed, 8 insertions(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 
e5b0334..2ddeab4 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -285,5 +285,13 @@
   # @ValidList   0x8001 | 0
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting|{0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00}|VOID*|0x0019
 
+  ## Contains the size of memory required when CPU processor trace is enabled.
+  # @Prompt The memory size used for processor trace.
+  
+ gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceMemSize|0x10|UINT32|0x601
+ 2
+
+  ## Contains the processor trace output scheme when CPU processor trace is 
enabled.
+  # @Prompt The processor trace output scheme.
+  
+ gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceOutputScheme|0x2|UINT8|0x6000
+ 0015
+
 [UserExtensions.TianoCore."ExtraFiles"]
   UefiCpuPkgExtra.uni
--
2.7.0.windows.1

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


Re: [edk2] Issue of step by step debugging of OVMF SEC code in QEMU

2017-08-03 Thread wang xiaofeng
Hi  Andrew,
THe problem is solved, after the SEC code switch to protected mode, gdb can 
work well now








At 2017-08-04 11:26:16, "wang xiaofeng"  wrote:

HI Andrew,
 How can I adjust the debugger to correct mode? Or I have to enable the 
debug after swtich to protected mode?








At 2017-08-04 10:57:16, "Andrew Fish"  wrote:
>The reset vector is 16-bit real mode, so you have the debugger in the wrong 
>mode. The code should transition to 32 bit protected early in the flow.
>
>Sent from my iPhone
>
>> On Aug 3, 2017, at 7:47 PM, wang xiaofeng  wrote:
>> 
>> Hello,
>>   I am tring to add my own SEC code base on OVMF and run on QEMU. Since 
>> the code cannot run I need to step to step trace the assembly code .
>>  The hang point is very early before I can use either UDK or debug 
>> serial output. I tried to use gdb to connect to QEMU.I start gdb in another 
>> terminal, and issue the following commands:
>>  (gdb) set architecture i386:x86-64:intel
>>  (gdb) target remote localhost:1234
>>   It really stops at the bios first instruction at 0XFFF0. But gdb shows 
>> eip= 0xFFF0 and CS=0xF000(why it not be 0xfff0). After I trigger the command 
>> "display /i $pc"
>>   It shows the assembly code in 0xFFF0 instead of0XFFF0, so the 
>> information is incorrect.
>>   Anyone knows how to corrently debug the SEC code ? Other debug tool is 
>> also ok.
>>   Thanks in advance!
>> 
>> 
>> 
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
>___
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel





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


[edk2] [Patch v4 3/3] UefiCpuPkg: Enable Processor Trace feature.

2017-08-03 Thread Eric Dong
Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 .../CpuCommonFeaturesLib/CpuCommonFeatures.h   |  66 +++
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c|  11 +
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf  |   4 +-
 .../Library/CpuCommonFeaturesLib/ProcTrace.c   | 463 +
 4 files changed, 543 insertions(+), 1 deletion(-)
 create mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
index b8269b0..d04e214 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
@@ -961,4 +961,70 @@ LmceInitialize (
   IN BOOLEAN   State
   );
 
+/**
+  Prepares for the data used by CPU feature detection and initialization.
+
+  @param[in]  NumberOfProcessors  The number of CPUs in the platform.
+
+  @return  Pointer to a buffer of CPU related configuration data.
+
+  @note This service could be called by BSP only.
+**/
+VOID *
+EFIAPI
+ProcTraceGetConfigData (
+  IN UINTN  NumberOfProcessors
+  );
+
+/**
+  Detects if Intel Processor Trace feature supported on current processor.
+
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.
+  @param[in]  CpuInfo  A pointer to the 
REGISTER_CPU_FEATURE_INFORMATION
+   structure for the CPU executing this function.
+  @param[in]  ConfigData   A pointer to the configuration buffer returned
+   by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
+   CPU_FEATURE_GET_CONFIG_DATA was not provided in
+   RegisterCpuFeature().
+
+  @retval TRUE Processor Trace feature is supported.
+  @retval FALSEProcessor Trace feature is not supported.
+
+  @note This service could be called by BSP/APs.
+**/
+BOOLEAN
+EFIAPI
+ProcTraceSupport (
+  IN UINTN ProcessorNumber,
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
+  IN VOID  *ConfigData  OPTIONAL
+  );
+
+/**
+  Initializes Intel Processor Trace feature to specific state.
+
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.
+  @param[in]  CpuInfo  A pointer to the 
REGISTER_CPU_FEATURE_INFORMATION
+   structure for the CPU executing this function.
+  @param[in]  ConfigData   A pointer to the configuration buffer returned
+   by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
+   CPU_FEATURE_GET_CONFIG_DATA was not provided in
+   RegisterCpuFeature().
+  @param[in]  StateIf TRUE, then the Processor Trace feature must 
be
+   enabled.
+   If FALSE, then the Processor Trace feature must 
be
+   disabled.
+
+  @retval RETURN_SUCCESS   Intel Processor Trace feature is initialized.
+
+**/
+RETURN_STATUS
+EFIAPI
+ProcTraceInitialize (
+  IN UINTN ProcessorNumber,
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
+  IN VOID  *ConfigData,  OPTIONAL
+  IN BOOLEAN   State
+  );
+
 #endif
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
index 4c78209..bbaffc5 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
@@ -229,6 +229,17 @@ CpuCommonFeaturesLibConstructor (
);
 ASSERT_EFI_ERROR (Status);
   }
+  if (IsCpuFeatureSupported (CPU_FEATURE_PROC_TRACE)) {
+Status = RegisterCpuFeature (
+   "Proc Trace",
+   ProcTraceGetConfigData,
+   ProcTraceSupport,
+   ProcTraceInitialize,
+   CPU_FEATURE_PROC_TRACE,
+   CPU_FEATURE_END
+   );
+ASSERT_EFI_ERROR (Status);
+  }
 
   return RETURN_SUCCESS;
 }
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
index 2cca58e..9fc3a9c 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
@@ -49,6 +49,7 @@
   X2Apic.c
   Ppin.c
   Lmce.c
+  ProcTrace.c
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -67,4 +68,5 @@
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport## CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle   ## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset

[edk2] [Patch v4 0/3] Enable Processor Trace feature

2017-08-03 Thread Eric Dong
Enable processor trace feature.
V2 update:
1. Add device capability check logic in Support function.
2. Correct the function comments.

V3 update:
1. Get device capability in Suport function instead of 
   GetConfigData function.

V4 update:
1. Base on the global point to allocate buffer instead
of input processor number.

Eric Dong (3):
  UefiCpuPkg: Add Pcds used by processor trace feature.
  UefiCpuPkg: Add Processor Trace feature definition.
  UefiCpuPkg: Enable Processor Trace feature.

 .../Include/Library/RegisterCpuFeaturesLib.h   |   1 +
 .../CpuCommonFeaturesLib/CpuCommonFeatures.h   |  66 +++
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c|  11 +
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf  |   4 +-
 .../Library/CpuCommonFeaturesLib/ProcTrace.c   | 463 +
 UefiCpuPkg/UefiCpuPkg.dec  |   8 +
 6 files changed, 552 insertions(+), 1 deletion(-)
 create mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c

-- 
2.7.0.windows.1

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


[edk2] [Patch v4 1/3] UefiCpuPkg: Add Pcds used by processor trace feature.

2017-08-03 Thread Eric Dong
Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/UefiCpuPkg.dec | 8 
 1 file changed, 8 insertions(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index e5b0334..2ddeab4 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -285,5 +285,13 @@
   # @ValidList   0x8001 | 0
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting|{0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00}|VOID*|0x0019
 
+  ## Contains the size of memory required when CPU processor trace is enabled.
+  # @Prompt The memory size used for processor trace.
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceMemSize|0x10|UINT32|0x6012
+
+  ## Contains the processor trace output scheme when CPU processor trace is 
enabled.
+  # @Prompt The processor trace output scheme.
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceOutputScheme|0x2|UINT8|0x6015
+
 [UserExtensions.TianoCore."ExtraFiles"]
   UefiCpuPkgExtra.uni
-- 
2.7.0.windows.1

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


[edk2] [Patch v4 2/3] UefiCpuPkg: Add Processor Trace feature definition.

2017-08-03 Thread Eric Dong
Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h 
b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
index 54153f4..9331e49 100644
--- a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
+++ b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
@@ -71,6 +71,7 @@
 #define CPU_FEATURE_APIC_TPR_UPDATE_MESSAGE (32+9)
 #define CPU_FEATURE_ENERGY_PERFORMANCE_BIAS (32+10)
 #define CPU_FEATURE_PPIN(32+11)
+#define CPU_FEATURE_PROC_TRACE  (32+12)
 
 #define CPU_FEATURE_BEFORE_ALL  BIT27
 #define CPU_FEATURE_AFTER_ALL   BIT28
-- 
2.7.0.windows.1

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


Re: [edk2] Issue of step by step debugging of OVMF SEC code in QEMU

2017-08-03 Thread wang xiaofeng
HI Andrew,
 How can I adjust the debugger to correct mode? Or I have to enable the 
debug after swtich to protected mode?








At 2017-08-04 10:57:16, "Andrew Fish"  wrote:
>The reset vector is 16-bit real mode, so you have the debugger in the wrong 
>mode. The code should transition to 32 bit protected early in the flow.
>
>Sent from my iPhone
>
>> On Aug 3, 2017, at 7:47 PM, wang xiaofeng  wrote:
>> 
>> Hello,
>>   I am tring to add my own SEC code base on OVMF and run on QEMU. Since 
>> the code cannot run I need to step to step trace the assembly code .
>>  The hang point is very early before I can use either UDK or debug 
>> serial output. I tried to use gdb to connect to QEMU.I start gdb in another 
>> terminal, and issue the following commands:
>>  (gdb) set architecture i386:x86-64:intel
>>  (gdb) target remote localhost:1234
>>   It really stops at the bios first instruction at 0XFFF0. But gdb shows 
>> eip= 0xFFF0 and CS=0xF000(why it not be 0xfff0). After I trigger the command 
>> "display /i $pc"
>>   It shows the assembly code in 0xFFF0 instead of0XFFF0, so the 
>> information is incorrect.
>>   Anyone knows how to corrently debug the SEC code ? Other debug tool is 
>> also ok.
>>   Thanks in advance!
>> 
>> 
>> 
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
>___
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Issue of step by step debugging of OVMF SEC code in QEMU

2017-08-03 Thread Andrew Fish
The reset vector is 16-bit real mode, so you have the debugger in the wrong 
mode. The code should transition to 32 bit protected early in the flow.

Sent from my iPhone

> On Aug 3, 2017, at 7:47 PM, wang xiaofeng  wrote:
> 
> Hello,
>   I am tring to add my own SEC code base on OVMF and run on QEMU. Since 
> the code cannot run I need to step to step trace the assembly code .
>  The hang point is very early before I can use either UDK or debug serial 
> output. I tried to use gdb to connect to QEMU.I start gdb in another 
> terminal, and issue the following commands:
>  (gdb) set architecture i386:x86-64:intel
>  (gdb) target remote localhost:1234
>   It really stops at the bios first instruction at 0XFFF0. But gdb shows 
> eip= 0xFFF0 and CS=0xF000(why it not be 0xfff0). After I trigger the command 
> "display /i $pc"
>   It shows the assembly code in 0xFFF0 instead of0XFFF0, so the 
> information is incorrect.
>   Anyone knows how to corrently debug the SEC code ? Other debug tool is also 
> ok.
>   Thanks in advance!
> 
> 
> 
> ___
> 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] Issue of step by step debugging of OVMF SEC code in QEMU

2017-08-03 Thread wang xiaofeng
Hello,
   I am tring to add my own SEC code base on OVMF and run on QEMU. Since 
the code cannot run I need to step to step trace the assembly code .
  The hang point is very early before I can use either UDK or debug serial 
output. I tried to use gdb to connect to QEMU.I start gdb in another terminal, 
and issue the following commands:
  (gdb) set architecture i386:x86-64:intel
  (gdb) target remote localhost:1234
   It really stops at the bios first instruction at 0XFFF0. But gdb shows 
eip= 0xFFF0 and CS=0xF000(why it not be 0xfff0). After I trigger the command 
"display /i $pc"
   It shows the assembly code in 0xFFF0 instead of0XFFF0, so the 
information is incorrect.
   Anyone knows how to corrently debug the SEC code ? Other debug tool is also 
ok.
   Thanks in advance!


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


Re: [edk2] [Patch V2 2/4] DuetPkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined

2017-08-03 Thread Wu, Hao A
Reviewed-by: Hao Wu 


Best Regards,
Hao Wu


> -Original Message-
> From: Zhu, Yonghong
> Sent: Thursday, August 03, 2017 5:00 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu; Wu, Hao A; Andrew Fish
> Subject: [Patch V2 2/4] DuetPkg: Fix Xcode 9 Beta treating 32-bit left shift 
> as
> undefined
> 
> Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635
> 
> Cc: Ruiyu Ni 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Andrew Fish 
> ---
>  DuetPkg/EfiLdr/TianoDecompress.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/DuetPkg/EfiLdr/TianoDecompress.c
> b/DuetPkg/EfiLdr/TianoDecompress.c
> index b504e8e..695f516 100644
> --- a/DuetPkg/EfiLdr/TianoDecompress.c
> +++ b/DuetPkg/EfiLdr/TianoDecompress.c
> @@ -91,15 +91,15 @@ Arguments:
> 
>  Returns: (VOID)
> 
>  --*/
>  {
> -  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
> +  Sd->mBitBuf = (UINT32) LShiftU64 (((UINT64)Sd->mBitBuf), NumOfBits);
> 
>while (NumOfBits > Sd->mBitCount) {
> -
> -Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16)
> (NumOfBits - Sd->mBitCount)));
> +NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount);
> +Sd->mBitBuf |= (UINT32) LShiftU64 (((UINT64)Sd->mSubBitBuf), NumOfBits);
> 
>  if (Sd->mCompSize > 0) {
>//
>// Get 1 byte into SubBitBuf
>//
> --
> 2.6.1.windows.1

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


[edk2] [PATCH v3 0/1] Use BusMasterCommonBuffer to map FW_CFG_DMA_ACCESS

2017-08-03 Thread Brijesh Singh
The patch applies on top of Laszlo's IoMmuDxe cleanup series [1].

Commit is also available at https://github.com/codomania/edk2/tree/qemufwcfg-sev

[1] https://lists.01.org/pipermail/edk2-devel/2017-August/012808.html

Changes since v2:
* Changes to address v2 feedbacks.

Changes since v1:
* Drop Patch 1 through 3, they are covered by Laszlo's cleanup series
* Rebase to the latest

Brijesh Singh (1):
  OvmfPkg/QemuFwCfgLib: Use BusMasterCommonBuffer to map
FW_CFG_DMA_ACCESS

 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h |  42 +--
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c | 330 
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 130 
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c |  99 +++---
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c |  58 +---
 5 files changed, 367 insertions(+), 292 deletions(-)

-- 
2.7.4

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


[edk2] [PATCH v3 1/1] OvmfPkg/QemuFwCfgLib: Use BusMasterCommonBuffer to map FW_CFG_DMA_ACCESS

2017-08-03 Thread Brijesh Singh
Commit 09719a01b11b (OvmfPkg/QemuFwCfgLib: Implement SEV internal function
for Dxe phase) uses IOMMU protocol to allocate and free FW_CFG_DMA_ACCESS
buffer when SEV is active. During initial commits we made assumption that
IOMMU.AllocateBuffer() will provide PlainTextAddress (i.e C-bit cleared).
This assumption was wrong, the AllocateBuffer() protocol member is not
expected to produce a buffer that is immediatly usable, and client is
required to call Map() uncondtionally with BusMasterCommonBuffer[64] to
get a mapping which is accessable by both host and device.

The patch refactors code a bit and add the support to Map()
FW_CFG_DMA_ACCESS buffer using BusMasterCommonBuffer operation after
allocation and Unamp() before free.

The complete discussion about this and recommendation from Laszlo can be
found here [1]

[1] https://lists.01.org/pipermail/edk2-devel/2017-July/012652.html

Suggested-by: Laszlo Ersek 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brijesh Singh 
---
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h |  42 +--
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c | 330 
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 130 
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c |  99 +++---
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c |  58 +---
 5 files changed, 367 insertions(+), 292 deletions(-)

diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
index 8cfa7913ffae..327f1d37e17d 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
@@ -45,39 +45,25 @@ InternalQemuFwCfgDmaIsAvailable (
   );
 
 /**
- Returns a boolean indicating whether SEV support is enabled
+  Transfer an array of bytes, or skip a number of bytes, using the DMA
+  interface.
 
- @retvalTRUESEV is enabled
- @retvalFALSE   SEV is disabled
-**/
-BOOLEAN
-InternalQemuFwCfgSevIsEnabled (
-  VOID
-  );
+  @param[in] Size Size in bytes to transfer or skip.
 
-/**
- Allocate a bounce buffer for SEV DMA.
-
-  @param[out]Buffer   Allocated DMA Buffer pointer
-  @param[in] NumPage  Number of pages.
+  @param[in,out] Buffer   Buffer to read data into or write data from. Ignored,
+  and may be NULL, if Size is zero, or Control is
+  FW_CFG_DMA_CTL_SKIP.
 
+  @param[in] Control  One of the following:
+  FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.
+  FW_CFG_DMA_CTL_READ  - read from fw_cfg into Buffer.
+  FW_CFG_DMA_CTL_SKIP  - skip bytes in fw_cfg.
 **/
 VOID
-InternalQemuFwCfgSevDmaAllocateBuffer (
-  OUTVOID **Buffer,
-  IN UINT32   NumPages
+InternalQemuFwCfgDmaBytes (
+  IN UINT32   Size,
+  IN OUT VOID *Buffer OPTIONAL,
+  IN UINT32   Control
   );
 
-/**
- Free the DMA buffer allocated using InternalQemuFwCfgSevDmaAllocateBuffer
-
-  @param[in] NumPage  Number of pages.
-  @param[in] Buffer   DMA Buffer pointer
-
-**/
-VOID
-InternalQemuFwCfgSevDmaFreeBuffer (
-  IN VOID *Buffer,
-  IN UINT32   NumPages
-  );
 #endif
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
index f8eb03bc3a9a..576941749cf2 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
@@ -20,6 +20,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -31,20 +32,6 @@ STATIC BOOLEAN mQemuFwCfgSupported = FALSE;
 STATIC BOOLEAN mQemuFwCfgDmaSupported;
 
 STATIC EDKII_IOMMU_PROTOCOL*mIoMmuProtocol;
-/**
-
- Returns a boolean indicating whether SEV is enabled
-
- @retvalTRUESEV is enabled
- @retvalFALSE   SEV is disabled
-**/
-BOOLEAN
-InternalQemuFwCfgSevIsEnabled (
-  VOID
-  )
-{
-  return MemEncryptSevIsEnabled ();
-}
 
 /**
   Returns a boolean indicating if the firmware configuration interface
@@ -110,7 +97,8 @@ QemuFwCfgInitialize (
 // IoMmuDxe driver must have installed the IOMMU protocol. If we are not
 // able to locate the protocol then something must have gone wrong.
 //
-Status = gBS->LocateProtocol (, NULL, (VOID 
**));
+Status = gBS->LocateProtocol (, NULL,
+(VOID **));
 if (EFI_ERROR (Status)) {
   DEBUG ((DEBUG_ERROR,
 "QemuFwCfgSevDma %a:%a Failed to locate IOMMU protocol.\n",
@@ -157,74 +145,308 @@ InternalQemuFwCfgDmaIsAvailable (
 }
 
 /**
- Allocate a bounce buffer for SEV DMA.
-
-  @param[in] NumPage  Number of pages.
-  @param[out]Buffer   Allocated DMA Buffer pointer
+  Function is used for allocating a bi-directional FW_CFG_DMA_ACCESS used
+  between Host and device to exchange the information. The 

Re: [edk2] [PATCH v2 1/1] OvmfPkg : QemuFwCfgLib: Use BusMasterCommandBuffer to map FW_CFG_DMA_ACCESS

2017-08-03 Thread Laszlo Ersek
On 08/04/17 00:07, Brijesh Singh wrote:
> Hi Laszlo,
> 
> Thanks for the detail review, I will soon send v3 with all your feedback
> addressed. I must admit that I have constant struggle with formating issues
> in EDKII contributions. While browsing the code, several packages have
> code and comment exceeding 79 char. But looking at your previous feedbacks
> somehow I was under assumption that comments should be <= 79 chars but code
> can exceed 79 char limit. I think my understanding was wrong. I will update
> my vi setting to warn me when I exceed 79 char limit.

In the coding style, you will find:

https://edk2-docs.gitbooks.io/edk-ii-c-coding-standards-specification/content/5_source_files/#51-general-rules

--
5 Source Files
5.1 General Rules
5.1.1 Lines shall be 120 columns, or less

Preferably, limit line lengths to 80 columns or less. When this doesn't
leave sufficient space for a good postfix style comment, extend the line
to a total of 120 columns. Having some level of uniformity in the
expected width of the source is useful for viewing and printing the code.
--

I stick with 79 chars because they don't wrap in any kind of window
sized to 80 columns. (Some terminal emulators / pager programs insert
blank lines or wrap unexpectedly when a line is exactly 80 columns.)
And, I like to size my windows to 80 columns because I use only one
monitor (I dislike using more than one) and with 80 cols/window I can
fit two windows side by side conveniently.

You will find that users of Windows IDEs / multi-monitor setups totally
ignore the 80 columns recommendation, and only stay even within the 120
columns limit as long as it's convenient for them (regardless of
"postfix style comments"). For this reason, reading MdePkg /
MdeModulePkg source code is a constant struggle for me. And, I tend to
rewrap code that's imported to OvmfPkg from those places.

Unfortunately, the very long variable names encouraged in edk2, combined
with the requirement to break every argument of a multi-line function
call to a separate line, provides a really strong incentive to exceed 80
characters. Say you have a protocol member func call with 5 arguments,
and when written on a single line, it ends at column 105. Will you stick
with that -- and drive me nuts, when I have to read it --, or will you
break it into *seven* lines (function name, plus 5 args, plus closing
paren)? Most people will opt to drive me nuts.

Of course the sensible pattern would be to fill lines up to 79 chars as
much as possible, and break the line only when you have to (honoring
this limit), but that style has not been accepted, and I've had to
abandon it.

> Sorry about all those formating errors, and thanks for being so patience.

No problem.

Thanks,
Laszlo

> 
> -Brijesh
> 
> On 08/03/2017 03:51 PM, Laszlo Ersek wrote:
>> On 08/03/17 18:10, Brijesh Singh wrote:
>>> Commit 09719a01b11b (OvmfPkg/QemuFwCfgLib: Implement SEV internal
>>> function for Dxe phase)
>>> uses IOMMU protocol to allocate and free FW_CFG_DMA_ACCESS buffer
>>> when SEV is active. During initial commits we made assumption that
>>> IOMMU.AllocateBuffer() will provide PlainTextAddress (i.e C-bit
>>> cleared). This assumption was wrong, the AllocateBuffer() protocol
>>> member is not expected to produce a buffer that is immediatly usable,
>>> and client is required to call Map() uncondtionally with
>>> BusMasterCommonBuffer[64]
>>> to get a mapping which is accessable by both host and device.
>>>
>>> The patch refactors code a bit and add the support to Map()
>>> FW_CFG_DMA_ACCESS buffer using BusMasterCommonBuffer operation
>>> after allocation and Unamp() before free.
>>>
>>> The complete discussion about this and recommendation from Laszlo
>>> can be found here [1]
>>>
>>> [1] https://lists.01.org/pipermail/edk2-devel/2017-July/012652.html
>>>
>>> Suggested-by: Laszlo Ersek 
>>> Cc: Jordan Justen 
>>> Cc: Laszlo Ersek 
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Brijesh Singh 
>>> ---
>>>   OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h |  42 ++--
>>>   OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c | 247
>>> 
>>>   OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 130 ---
>>>   OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 101 +---
>>>   OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c |  56 ++---
>>>   5 files changed, 292 insertions(+), 284 deletions(-)
>>
>> (1) please remove the space characters in front of the colons (":") in
>> the subject.
>>
>> (2) Still for the subject, it is "CommonBuffer", not "CommandBuffer".
>>
>> So the subject should be
>>
>> OvmfPkg: QemuFwCfgLib: Use BusMasterCommonBuffer to map FW_CFG_DMA_ACCESS
>>
>> (3) Please rewrap the commit message to 74 characters.
>>
>>>
>>> diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
>>> 

Re: [edk2] [PATCH v2 1/1] OvmfPkg : QemuFwCfgLib: Use BusMasterCommandBuffer to map FW_CFG_DMA_ACCESS

2017-08-03 Thread Brijesh Singh

Hi Laszlo,

Thanks for the detail review, I will soon send v3 with all your feedback
addressed. I must admit that I have constant struggle with formating issues
in EDKII contributions. While browsing the code, several packages have
code and comment exceeding 79 char. But looking at your previous feedbacks
somehow I was under assumption that comments should be <= 79 chars but code
can exceed 79 char limit. I think my understanding was wrong. I will update
my vi setting to warn me when I exceed 79 char limit.

Sorry about all those formating errors, and thanks for being so patience.

-Brijesh

On 08/03/2017 03:51 PM, Laszlo Ersek wrote:

On 08/03/17 18:10, Brijesh Singh wrote:

Commit 09719a01b11b (OvmfPkg/QemuFwCfgLib: Implement SEV internal function for 
Dxe phase)
uses IOMMU protocol to allocate and free FW_CFG_DMA_ACCESS buffer
when SEV is active. During initial commits we made assumption that
IOMMU.AllocateBuffer() will provide PlainTextAddress (i.e C-bit
cleared). This assumption was wrong, the AllocateBuffer() protocol
member is not expected to produce a buffer that is immediatly usable,
and client is required to call Map() uncondtionally with 
BusMasterCommonBuffer[64]
to get a mapping which is accessable by both host and device.

The patch refactors code a bit and add the support to Map()
FW_CFG_DMA_ACCESS buffer using BusMasterCommonBuffer operation
after allocation and Unamp() before free.

The complete discussion about this and recommendation from Laszlo
can be found here [1]

[1] https://lists.01.org/pipermail/edk2-devel/2017-July/012652.html

Suggested-by: Laszlo Ersek 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brijesh Singh 
---
  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h |  42 ++--
  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c | 247 
  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 130 ---
  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 101 +---
  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c |  56 ++---
  5 files changed, 292 insertions(+), 284 deletions(-)


(1) please remove the space characters in front of the colons (":") in
the subject.

(2) Still for the subject, it is "CommonBuffer", not "CommandBuffer".

So the subject should be

OvmfPkg: QemuFwCfgLib: Use BusMasterCommonBuffer to map FW_CFG_DMA_ACCESS

(3) Please rewrap the commit message to 74 characters.



diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
index 8cfa7913ffae..327f1d37e17d 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
@@ -45,39 +45,25 @@ InternalQemuFwCfgDmaIsAvailable (
);
  
  /**

- Returns a boolean indicating whether SEV support is enabled
+  Transfer an array of bytes, or skip a number of bytes, using the DMA
+  interface.
  
- @retvalTRUESEV is enabled

- @retvalFALSE   SEV is disabled
-**/
-BOOLEAN
-InternalQemuFwCfgSevIsEnabled (
-  VOID
-  );
+  @param[in] Size Size in bytes to transfer or skip.
  
-/**

- Allocate a bounce buffer for SEV DMA.
-
-  @param[out]Buffer   Allocated DMA Buffer pointer
-  @param[in] NumPage  Number of pages.
+  @param[in,out] Buffer   Buffer to read data into or write data from. Ignored,
+  and may be NULL, if Size is zero, or Control is
+  FW_CFG_DMA_CTL_SKIP.
  
+  @param[in] Control  One of the following:

+  FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.
+  FW_CFG_DMA_CTL_READ  - read from fw_cfg into Buffer.
+  FW_CFG_DMA_CTL_SKIP  - skip bytes in fw_cfg.
  **/
  VOID
-InternalQemuFwCfgSevDmaAllocateBuffer (
-  OUTVOID **Buffer,
-  IN UINT32   NumPages
+InternalQemuFwCfgDmaBytes (
+  IN UINT32   Size,
+  IN OUT VOID *Buffer OPTIONAL,
+  IN UINT32   Control
);
  
-/**

- Free the DMA buffer allocated using InternalQemuFwCfgSevDmaAllocateBuffer
-
-  @param[in] NumPage  Number of pages.
-  @param[in] Buffer   DMA Buffer pointer
-
-**/
-VOID
-InternalQemuFwCfgSevDmaFreeBuffer (
-  IN VOID *Buffer,
-  IN UINT32   NumPages
-  );
  #endif
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c


(4) You forgot to remove the InternalQemuFwCfgSevIsEnabled() function
from this file.


index f8eb03bc3a9a..e03647bae3bd 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
@@ -20,6 +20,7 @@
  #include 
  
  #include 

+#include 
  #include 
  #include 
  #include 
@@ -157,74 +158,228 @@ InternalQemuFwCfgDmaIsAvailable (
  }
  
  /**

- Allocate a bounce buffer for SEV DMA.
-
-  @param[in] NumPage  Number of 

Re: [edk2] Announcing the edk2-platforms master branch

2017-08-03 Thread Kinney, Michael D
Leif,

Thanks for all the work on this!

I have updated the default branch on edk2-platforms to 
be the master branch.

Mike

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On
> Behalf Of Leif Lindholm
> Sent: Thursday, August 3, 2017 7:09 AM
> To: edk2-devel@lists.01.org; linaro-u...@lists.linaro.org
> Subject: [edk2] Announcing the edk2-platforms master branch
> 
> Hi all,
> 
> A little over two years ago, I set up OpenPlatformPkg [1] as a
> way to
> prototype a single source tree for multiple platforms, built
> against
> edk2.
> 
> Last year, we finalised the rules for how such a tree could be
> integrated into the edk2-platforms [2] repository, and I have
> now
> completed the migration. edk2-platforms master branch is now
> live
> (although there will be some lag before it becomes the _default_
> branch of the repository).
> 
> Binary-only components have moved to edk2-non-osi [3]. At the
> same
> time edk2-non-osi has been updated with a directory structure
> aligned
> with edk2-platforms master - as well as had explicit
> documentation
> added regarding how licenses work in that tree.
> 
> As of this moment, OpenPlatformPkg becomes a read-only
> historical
> document.
> 
> Mike has agreed to share overall maintainership of edk2-
> platforms with
> me, at least until we start breaking down responsibility a bit
> more.
> 
> Happy hacking!
> 
> /
> Leif
> 
> [1] https://git.linaro.org/uefi/OpenPlatformPkg.git
> [2] https://github.com/tianocore/edk2-platforms.git
> [3] https://github.com/tianocore/edk2-non-osi.git
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 1/1] OvmfPkg : QemuFwCfgLib: Use BusMasterCommandBuffer to map FW_CFG_DMA_ACCESS

2017-08-03 Thread Laszlo Ersek
On 08/03/17 18:10, Brijesh Singh wrote:
> Commit 09719a01b11b (OvmfPkg/QemuFwCfgLib: Implement SEV internal function 
> for Dxe phase)
> uses IOMMU protocol to allocate and free FW_CFG_DMA_ACCESS buffer
> when SEV is active. During initial commits we made assumption that
> IOMMU.AllocateBuffer() will provide PlainTextAddress (i.e C-bit
> cleared). This assumption was wrong, the AllocateBuffer() protocol
> member is not expected to produce a buffer that is immediatly usable,
> and client is required to call Map() uncondtionally with 
> BusMasterCommonBuffer[64]
> to get a mapping which is accessable by both host and device.
> 
> The patch refactors code a bit and add the support to Map()
> FW_CFG_DMA_ACCESS buffer using BusMasterCommonBuffer operation
> after allocation and Unamp() before free.
> 
> The complete discussion about this and recommendation from Laszlo
> can be found here [1]
> 
> [1] https://lists.01.org/pipermail/edk2-devel/2017-July/012652.html
> 
> Suggested-by: Laszlo Ersek 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Brijesh Singh 
> ---
>  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h |  42 ++--
>  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c | 247 
> 
>  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 130 ---
>  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 101 +---
>  OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c |  56 ++---
>  5 files changed, 292 insertions(+), 284 deletions(-)

(1) please remove the space characters in front of the colons (":") in
the subject.

(2) Still for the subject, it is "CommonBuffer", not "CommandBuffer".

So the subject should be

OvmfPkg: QemuFwCfgLib: Use BusMasterCommonBuffer to map FW_CFG_DMA_ACCESS

(3) Please rewrap the commit message to 74 characters.

> 
> diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h 
> b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
> index 8cfa7913ffae..327f1d37e17d 100644
> --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
> +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
> @@ -45,39 +45,25 @@ InternalQemuFwCfgDmaIsAvailable (
>);
>  
>  /**
> - Returns a boolean indicating whether SEV support is enabled
> +  Transfer an array of bytes, or skip a number of bytes, using the DMA
> +  interface.
>  
> - @retvalTRUESEV is enabled
> - @retvalFALSE   SEV is disabled
> -**/
> -BOOLEAN
> -InternalQemuFwCfgSevIsEnabled (
> -  VOID
> -  );
> +  @param[in] Size Size in bytes to transfer or skip.
>  
> -/**
> - Allocate a bounce buffer for SEV DMA.
> -
> -  @param[out]Buffer   Allocated DMA Buffer pointer
> -  @param[in] NumPage  Number of pages.
> +  @param[in,out] Buffer   Buffer to read data into or write data from. 
> Ignored,
> +  and may be NULL, if Size is zero, or Control is
> +  FW_CFG_DMA_CTL_SKIP.
>  
> +  @param[in] Control  One of the following:
> +  FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.
> +  FW_CFG_DMA_CTL_READ  - read from fw_cfg into 
> Buffer.
> +  FW_CFG_DMA_CTL_SKIP  - skip bytes in fw_cfg.
>  **/
>  VOID
> -InternalQemuFwCfgSevDmaAllocateBuffer (
> -  OUTVOID **Buffer,
> -  IN UINT32   NumPages
> +InternalQemuFwCfgDmaBytes (
> +  IN UINT32   Size,
> +  IN OUT VOID *Buffer OPTIONAL,
> +  IN UINT32   Control
>);
>  
> -/**
> - Free the DMA buffer allocated using InternalQemuFwCfgSevDmaAllocateBuffer
> -
> -  @param[in] NumPage  Number of pages.
> -  @param[in] Buffer   DMA Buffer pointer
> -
> -**/
> -VOID
> -InternalQemuFwCfgSevDmaFreeBuffer (
> -  IN VOID *Buffer,
> -  IN UINT32   NumPages
> -  );
>  #endif
> diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c 
> b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c

(4) You forgot to remove the InternalQemuFwCfgSevIsEnabled() function
from this file.

> index f8eb03bc3a9a..e03647bae3bd 100644
> --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
> +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
> @@ -20,6 +20,7 @@
>  #include 
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -157,74 +158,228 @@ InternalQemuFwCfgDmaIsAvailable (
>  }
>  
>  /**
> - Allocate a bounce buffer for SEV DMA.
> -
> -  @param[in] NumPage  Number of pages.
> -  @param[out]Buffer   Allocated DMA Buffer pointer
> +  Function is used for allocating a bi-directional FW_CFG_DMA_ACCESS used
> +  between Host and device to exchange the information. The buffer must be 
> free'd
> +  using FreeFwCfgDmaAccessBuffer ().
>  
>  **/
> -VOID
> -InternalQemuFwCfgSevDmaAllocateBuffer (
> -  OUTVOID **Buffer,
> -  IN UINT32   NumPages
> +STATIC
> +EFI_STATUS
> +AllocFwCfgDmaAccessBuffer (
> +  

Re: [edk2] Building UDK2017 with VS2015 fails - please help

2017-08-03 Thread Kinney, Michael D
Tahnia,

My guess is that you are not using NASM.

It appears that InternalMemIsZeroBuffer is only implemented for NASM and not 
ASM.
Which is a bug since building with ASM results in a missing function.

Your tools_def.txt file is missing this statement.  Please make sure this 
statement
is present in yours and install NASM and try again.

#
# Build rule order
#
*_*_*_*_BUILDRULEORDER = nasm asm Asm ASM S s

Thanks,

Mike

From: Tahnia Lichtenstein [mailto:unl...@gmail.com]
Sent: Thursday, August 3, 2017 9:27 AM
To: edk2-devel@lists.01.org
Subject: Building UDK2017 with VS2015 fails - please help

Hi,

I am new to Tianocore and EDK II. Not sure if this is the right place to ask my 
question, please advise if there is a more suitable forum.

I am trying to build the UDK2017 on Windows 10 x64, using Visual Studio 2015 
(configured for AMD64 compiler).

I followed the procedure documented in UDK2017 
How-to-Build.
 I copied the source .zip and cloned Basetools, checking out the specified 
version. I have not changed any source files, but added the VS2015x86 toolchain 
to tools_def.txt (attached), and also modified targets.txt with the following:

TOOL_CHAIN_TAG   = VS2015x86
ACTIVE_PLATFORM = MdeModulePkg/MdeModulePkg.dsc

When I open the VS2015 command prompt, and run:
edksetup --nt32
build -t VS2015x86

It builds MdeModulePkg successfully (build log attached).

But when I run:
edksetup --nt32
edk2setup --nt32
build -p Nt32Pkg\Nt32Pkg.dsc

I get the following error (build log attached):

Creating library 
c:\projects\edk\udk2017\Build\NT32IA32\DEBUG_VS2015x86\IA32\MdeModulePkg\Application\UiApp\UiApp\DEBUG\UiApp.lib
 and object 
c:\projects\edk\udk2017\Build\NT32IA32\DEBUG_VS2015x86\IA32\MdeModulePkg\Application\UiApp\UiApp\DEBUG\UiApp.exp
BaseMemoryLibOptDxe.lib(IsZeroBufferWrapper.obj) : error LNK2001: unresolved 
external symbol _InternalMemIsZeroBuffer
c:\projects\edk\udk2017\Build\NT32IA32\DEBUG_VS2015x86\IA32\MdeModulePkg\Application\UiApp\UiApp\DEBUG\UiApp.dll
 : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 
14.0\VC\bin\link.exe"' : return code '0x460'
Stop.
build...
 : error 7000: Failed to execute command
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe 
/nologo tbuild 
[c:\projects\edk\udk2017\Build\NT32IA32\DEBUG_VS2015x86\IA32\MdeModulePkg\Application\UiApp\UiApp]
build...
 : error F002: Failed to build module
c:\projects\edk\udk2017\MdeModulePkg\Application\UiApp\UiApp.inf [IA32, 
VS2015x86, DEBUG]


Also when I run:
edksetup --nt32
build -a IA32 -a X64 -p CorebootPayloadPkg\CorebootPayloadPkgIa32X64.dsc -b 
DEBUG

I get a different error (build log attached):
Building ... c:\projects\edk\udk2017\CorebootModulePkg\SecCore\SecCore.inf 
[IA32]
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe" 
/OUT:c:\projects\edk\udk2017\Build\CorebootPayloadPkgX64\DEBUG_VS2015x86\IA32\CorebootModulePkg\SecCore\SecCore\DEBUG\SecCore.dll
 /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 
/SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL 
/ENTRY:_ModuleEntryPoint /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 
/DRIVER /DEBUG  
@c:\projects\edk\udk2017\Build\CorebootPayloadPkgX64\DEBUG_VS2015x86\IA32\CorebootModulePkg\SecCore\SecCore\OUTPUT\static_library_files.lst
LINK : error LNK2001: unresolved external symbol __ModuleEntryPoint
c:\projects\edk\udk2017\Build\CorebootPayloadPkgX64\DEBUG_VS2015x86\IA32\CorebootModulePkg\SecCore\SecCore\DEBUG\SecCore.dll
 : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 
14.0\VC\bin\link.exe"' : return code '0x460'
Stop.
build...
 : error 7000: Failed to execute command
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe 
/nologo tbuild 
[c:\projects\edk\udk2017\Build\CorebootPayloadPkgX64\DEBUG_VS2015x86\IA32\CorebootModulePkg\SecCore\SecCore]
build...
 : error F002: Failed to build module
c:\projects\edk\udk2017\CorebootModulePkg\SecCore\SecCore.inf [IA32, 
VS2015x86, DEBUG]


Please can you help me to get Nt32Pkg and CorebootPayloadPkg to build? Is there 
any additional changes I need to make to my build environment, other than 
listed in UDK2017 
How-to-Build?
 Or is my tools_def.txt wrong? Or do I need to dig a bit in the UDK2017 source 
to fix the errors I am getting?

Best regards,

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


[edk2] [PATCH v3 1/2] MdePkg/BaseLib: Add IsNodeInList() function.

2017-08-03 Thread Marvin Häuser
This patch adds IsNodeInList() to BaseLib, which verifies the given
Node is part of the doubly-linked List provided.

V2:
  - Rename "List" to "FirstEntry" and "Node" to "SecondEntry" to clarify that
"FirstEntry" does not need to be the doubly-linked list's head node.

V3:
  - Remove ASSERTs from IsNodeInList() which are present in
InternalBaseLibIsListValid().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser 
---
 MdePkg/Library/BaseLib/LinkedList.c   | 66 +++-
 MdePkg/Include/Library/BaseLib.h  | 27 
 MdePkg/Library/BaseLib/BaseLibInternals.h | 28 -
 3 files changed, 92 insertions(+), 29 deletions(-)

diff --git a/MdePkg/Library/BaseLib/LinkedList.c 
b/MdePkg/Library/BaseLib/LinkedList.c
index ba373f4b7be3..af27b0dd9a5c 100644
--- a/MdePkg/Library/BaseLib/LinkedList.c
+++ b/MdePkg/Library/BaseLib/LinkedList.c
@@ -1,7 +1,7 @@
 /** @file
   Linked List Library Functions.
 
-  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2017, 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
@@ -113,6 +113,70 @@ InternalBaseLibIsNodeInList (
 }
 
 /**
+  Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
+  list.
+
+  If FirstEntry is NULL, then ASSERT().
+  If FirstEntry->ForwardLink is NULL, then ASSERT().
+  If FirstEntry->BackLink is NULL, then ASSERT().
+  If SecondEntry is NULL, then ASSERT();
+  If PcdMaximumLinkedListLength is not zero, and List contains more than
+  PcdMaximumLinkedListLength nodes, then ASSERT().
+
+  @param  FirstEntry   A pointer to a node in a linked list.
+  @param  SecondEntry  A pointer to the node to locate.
+
+  @retval TRUE   SecondEntry is in the same doubly-linked list as FirstEntry.
+  @retval FALSE  SecondEntry isn't in the same doubly-linked list as 
FirstEntry,
+ or FirstEntry is invalid.
+
+**/
+BOOLEAN
+EFIAPI
+IsNodeInList (
+  IN  CONST LIST_ENTRY  *FirstEntry,
+  IN  CONST LIST_ENTRY  *SecondEntry
+  )
+{
+  UINTN Count;
+  CONST LIST_ENTRY  *Ptr;
+
+  //
+  // ASSERT List not too long
+  //
+  ASSERT (InternalBaseLibIsListValid (FirstEntry));
+
+  ASSERT (SecondEntry != NULL);
+
+  Count = 0;
+  Ptr   = FirstEntry;
+
+  //
+  // Check to see if SecondEntry is a member of FirstEntry.  
+  // Exit early if the number of nodes in List >= PcdMaximumLinkedListLength
+  //
+  do {
+Ptr = Ptr->ForwardLink;
+if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {
+  Count++;
+
+  //
+  // Return if the linked list is too long
+  //
+  if (Count == PcdGet32 (PcdMaximumLinkedListLength)) {
+return (BOOLEAN)(Ptr == SecondEntry);
+  }
+}
+
+if (Ptr == SecondEntry) {
+  return TRUE;
+}
+  } while (Ptr != FirstEntry);
+
+  return FALSE;
+}
+
+/**
   Initializes the head node of a doubly-linked list, and returns the pointer to
   the head node of the doubly-linked list.
 
diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index 791849b80406..40b96b761a85 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -2869,6 +2869,33 @@ PathCleanUpDirectories(
 
 
 /**
+  Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
+  list.
+
+  If FirstEntry is NULL, then ASSERT().
+  If FirstEntry->ForwardLink is NULL, then ASSERT().
+  If FirstEntry->BackLink is NULL, then ASSERT().
+  If SecondEntry is NULL, then ASSERT();
+  If PcdMaximumLinkedListLength is not zero, and List contains more than
+  PcdMaximumLinkedListLength nodes, then ASSERT().
+
+  @param  FirstEntry   A pointer to a node in a linked list.
+  @param  SecondEntry  A pointer to the node to locate.
+
+  @retval TRUE   SecondEntry is in the same doubly-linked list as FirstEntry.
+  @retval FALSE  SecondEntry isn't in the same doubly-linked list as 
FirstEntry,
+ or FirstEntry is invalid.
+
+**/
+BOOLEAN
+EFIAPI
+IsNodeInList (
+  IN  CONST LIST_ENTRY  *FirstEntry,
+  IN  CONST LIST_ENTRY  *SecondEntry
+  );
+
+
+/**
   Initializes the head node of a doubly linked list, and returns the pointer to
   the head node of the doubly linked list.
 
diff --git a/MdePkg/Library/BaseLib/BaseLibInternals.h 
b/MdePkg/Library/BaseLib/BaseLibInternals.h
index ea387ce37d27..9dca97a0dcc9 100644
--- a/MdePkg/Library/BaseLib/BaseLibInternals.h
+++ b/MdePkg/Library/BaseLib/BaseLibInternals.h
@@ -340,34 +340,6 @@ InternalSwitchStack (
 
 
 /**
-  Worker function that locates the Node in the List.
-
-  By searching the List, finds the location of the Node in List. At the same 
time,
-  verifies the validity of this list.
-
-  If List is NULL, then ASSERT().

[edk2] [PATCH v3 2/2] MdePkg/BaseLib: Update internal LinkedList verifications.

2017-08-03 Thread Marvin Häuser
1) Replace InternalBaseLibIsNodeInList() with
   InternalBaseLibIsListValid().
   - The verification whether Node is within the doubly-linked List
 is now done by IsNodeInList().
   - Whether the list is valid is returned.

2) The comments within InsertHeadList() and InsertTailList() stated
   that it is checked whether Entry is not part of the doubly-linked
   list. This was not done as argument 3 of
   InternalBaseLibIsNodeInList() indicated whether the check is done,
   not whether to check if the node is or is not in the list. This
   has been fixed by using IsNodeInList() for the ASSERTs.

V2:
  - Fix IsListEmpty() to ASSERT when the passed list is invalid.
  - Introduce the VERIFY_IS_NODE_IN_LIST() macro to only verify whether the
passed node is part of the list when PcdVerifyNodeInList is TRUE.

V3:
  - Introduce the ASSERT_VERIFY_NODE_IN_VALID_LIST() macro which,
depending on the value of PcdVerifyNodeInList, verifies whether
SecondEntry is or is not part of the same doubly-linked list as
FirstEntry and unconditionally verifies whether the doubly-linked
list FirstEntry is part of is valid. This prevents
InternalBaseLibIsListValid() from being called twice when a
function ASSERTs via the result of IsNodeInList(), as it calls
InternalBaseLibIsListValid() already.
  - Remove the VERIFY_IS_NODE_IN_LIST() macro in favor of
ASSERT_VERIFY_NODE_IN_VALID_LIST().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser 
---
 MdePkg/Library/BaseLib/LinkedList.c | 107 +---
 1 file changed, 49 insertions(+), 58 deletions(-)

diff --git a/MdePkg/Library/BaseLib/LinkedList.c 
b/MdePkg/Library/BaseLib/LinkedList.c
index af27b0dd9a5c..30fd7009e007 100644
--- a/MdePkg/Library/BaseLib/LinkedList.c
+++ b/MdePkg/Library/BaseLib/LinkedList.c
@@ -15,25 +15,47 @@
 #include "BaseLibInternals.h"
 
 /**
-  Worker function that locates the Node in the List.
+  If PcdVerifyNodeInList is TRUE, ASSERTs when SecondEntry is or is not part of
+  the same doubly-linked list as FirstEntry depending on the value of InList.
+  Independent of PcdVerifyNodeInList, ASSERTs when FirstEntry is not part of a
+  valid list.
 
-  By searching the List, finds the location of the Node in List. At the same 
time,
-  verifies the validity of this list.
+  If FirstEntry is NULL, then ASSERT().
+  If FirstEntry->ForwardLink is NULL, then ASSERT().
+  If FirstEntry->BackLink is NULL, then ASSERT().
+  If PcdMaximumLinkedListLength is not zero, and List contains more than
+  PcdMaximumLinkedListLength nodes, then ASSERT().
+  If PcdVerifyNodeInList is TRUE and SecondEntry is NULL, then ASSERT().
+
+  @param  FirstEntry   A pointer to a node in a linked list.
+  @param  SecondEntry  A pointer to the node to locate.
+  @param  InList   Defines whether to check if SecondEntry is or is not 
part
+   of the same doubly-linked list as FirstEntry.
+
+**/
+#if !defined (MDEPKG_NDEBUG)
+  #define ASSERT_VERIFY_NODE_IN_VALID_LIST(FirstEntry, SecondEntry, InList)  \
+do { \
+  if (FeaturePcdGet (PcdVerifyNodeInList)) { \
+ASSERT (InList == IsNodeInList ((FirstEntry), (SecondEntry)));   \
+  } else {   \
+ASSERT (InternalBaseLibIsListValid (FirstEntry));\
+  }  \
+} while (FALSE)
+#else
+  #define ASSERT_VERIFY_NODE_IN_VALID_LIST(FirstEntry, SecondEntry, InList)
+#endif
+
+/**
+  Worker function that verifies the validity of this list.
 
   If List is NULL, then ASSERT().
   If List->ForwardLink is NULL, then ASSERT().
-  If List->backLink is NULL, then ASSERT().
-  If Node is NULL, then ASSERT().
-  If PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE and Node 
-  is in not a member of List, then return FALSE
+  If List->BackLink is NULL, then ASSERT().
   If PcdMaximumLinkedListLength is not zero, and List contains more than
   PcdMaximumLinkedListLength nodes, then ASSERT().
 
   @param  List  A pointer to a node in a linked list.
-  @param  Node  A pointer to a node in a linked list.
-  @param  VerifyNodeInList  TRUE if a check should be made to see if Node is a 
-member of List.  FALSE if no membership test 
should 
-be performed.
 
   @retval   TRUE if PcdVerifyNodeInList is FALSE
   @retval   TRUE if DoMembershipCheck is FALSE
@@ -45,10 +67,8 @@
 **/
 BOOLEAN
 EFIAPI
-InternalBaseLibIsNodeInList (
-  IN CONST LIST_ENTRY  *List,
-  IN CONST LIST_ENTRY  *Node,
-  IN BOOLEAN   VerifyNodeInList
+InternalBaseLibIsListValid (
+  IN CONST LIST_ENTRY  *List
   )
 {
   UINTN Count;
@@ -60,40 +80,11 @@ InternalBaseLibIsNodeInList (
   ASSERT 

Re: [edk2] [PATCH 05/11] ShellPkg/UefiShellLevel2CommandsLib: Remove unnecessary EFIAPI

2017-08-03 Thread Palmer, Thomas
Ruiyu,
Sorry for replying to old patch, I was cleaning out some old sandboxes 
when I stumbled onto this issue.  

Why is EFIAPI removed from InternalCharToUpper in 
UefiShellLevel2CommandsLib.c?  It is present in both BaseLibInternals.h and 
String.c.   Without EFIAPI, GCC builds of this function can fail


Regards,

Thomas Palmer

"I have only made this letter longer because I have not had the time to make it 
shorter" - Blaise Pascal


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Friday, September 30, 2016 3:18 AM
To: edk2-devel@lists.01.org
Cc: Ruiyu Ni ; Jaben Carsey ; Chen 
A Chen 
Subject: [edk2] [PATCH 05/11] ShellPkg/UefiShellLevel2CommandsLib: Remove 
unnecessary EFIAPI

From: Ruiyu Ni 

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen A Chen 
Cc: Jaben Carsey 
Cc: Ruiyu Ni 
---
 ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c |  4 
 ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c   |  2 --
 ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c |  5 -
 ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c| 12 
 ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c |  7 ---
 ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c  |  3 ---
 ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c |  3 ---
 ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c|  1 -
 ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c   |  4 
 .../UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c  |  5 -  
.../UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h  |  6 --
 ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c|  1 -
 12 files changed, 53 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c 
b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
index eb1f3b6..b8f6d31 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
@@ -35,7 +35,6 @@
   @retval SHELL_OUT_OF_RESOURCESa memory allocation failed
 **/
 SHELL_STATUS
-EFIAPI
 ValidateAndCopyFiles(
   IN CONST EFI_SHELL_FILE_INFO  *FileList,
   IN CONST CHAR16   *DestDir,
@@ -58,7 +57,6 @@ ValidateAndCopyFiles(
   @retval SHELL_SUCCESS   The source file was copied to the destination
 **/
 SHELL_STATUS
-EFIAPI
 CopySingleFile(
   IN CONST CHAR16 *Source,
   IN CONST CHAR16 *Dest,
@@ -291,7 +289,6 @@ CopySingleFile(
   @retval SHELL_OUT_OF_RESOURCESa memory allocation failed
 **/
 SHELL_STATUS
-EFIAPI
 ValidateAndCopyFiles(
   IN CONST EFI_SHELL_FILE_INFO  *FileList,
   IN CONST CHAR16   *DestDir,
@@ -576,7 +573,6 @@ ValidateAndCopyFiles(
   @retval SHELL_SUCCESS The operation was successful.
 **/
 SHELL_STATUS
-EFIAPI
 ProcessValidateAndCopyFiles(
   IN   EFI_SHELL_FILE_INFO  *FileList,
   IN CONST CHAR16   *DestDir,
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c 
b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
index ff7c818..322d510 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
@@ -28,7 +28,6 @@
 
 **/
 EFI_STATUS
-EFIAPI
 ConnectAllEfi (
   VOID
   )
@@ -74,7 +73,6 @@ ConnectAllEfi (
   @retval EFI_OUT_OF_RESOURCES  there was insufficient memory  **/  EFI_STATUS 
-EFIAPI  LoadDriver(
   IN CONST CHAR16   *FileName,
   IN CONST BOOLEAN  Connect
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c 
b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
index 9b4c452..52ae18f 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
@@ -22,7 +22,6 @@
   @param[in] TheList   a list of files from the volume.
 **/
 EFI_STATUS
-EFIAPI
 PrintSfoVolumeInfoTableEntry(
   IN CONST EFI_SHELL_FILE_INFO *TheList
   )
@@ -152,7 +151,6 @@ PrintSfoVolumeInfoTableEntry(
 
 **/
 VOID
-EFIAPI
 PrintFileInformation(
   IN CONST BOOLEAN  Sfo, 
   IN CONST EFI_SHELL_FILE_INFO  *TheNode, @@ -263,7 +261,6 @@ 
PrintFileInformation(
   @param[in] Path   String with starting path.
 **/
 VOID
-EFIAPI
 PrintNonSfoHeader(
   IN CONST CHAR16 *Path
   )
@@ -300,7 +297,6 @@ PrintNonSfoHeader(
   @param[in] Dirs The number of directories.
 **/
 VOID
-EFIAPI
 PrintNonSfoFooter(
   IN UINT64 Files, 
   IN UINT64 Size, 
@@ -339,7 +335,6 @@ PrintNonSfoFooter(
   @retval SHELL_SUCCESS the printing was sucessful.
 **/
 SHELL_STATUS
-EFIAPI
 PrintLsOutput(
   IN CONST BOOLEAN Rec,
   IN CONST UINT64  Attribs,
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c 
b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
index 

[edk2] [RFC Patch 2/3] BaseTools/Scripts: Add python script to run a makefile

2017-08-03 Thread Michael D Kinney
Add the python script RunMakefile.py that can be used
in a PREBUILD/POSTBUIILD action to invoke a makefile
passing in context as makefile defines.  The command
line arguments passed into RunMakefile.py are converted
to the following set of defines.

* ACTIVE_PLATFORM
* TARGET_ARCH
* TOOL_CHAIN_TAG
* CONF_DIRECTORY
* TARGET
* EXTRA_FLAGS

In addition, a makefile can access the system environment
variables including WORKSPACE and PACKAGES_PATH.

The makefile target from the following set is also passed
into the makefile.  If no target is passed into build, then
the 'all' target is used.

[all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]

A platform DSC file can use a statements in the [Defines]
section of the following form to use this script.  MAKEFILE
is a WORKSPACE or PACKAGES_PATH relative path to the makefile
to run.

[Defines]
  PREBUILD  = python BaseTools/Script/RunMakefile.py --makefile MAKEFILE
  POSTBUILD = python BaseTools/Script/RunMakefile.py --makefile MAKEFILE

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 BaseTools/Scripts/RunMakefile.py | 178 +++
 1 file changed, 178 insertions(+)
 create mode 100644 BaseTools/Scripts/RunMakefile.py

diff --git a/BaseTools/Scripts/RunMakefile.py b/BaseTools/Scripts/RunMakefile.py
new file mode 100644
index 00..48bc198c76
--- /dev/null
+++ b/BaseTools/Scripts/RunMakefile.py
@@ -0,0 +1,178 @@
+## @file
+# Run a makefile as part of a PREBUILD or POSTBUILD action.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD 
License
+# which accompanies this distribution.  The full text of the license may be 
found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+'''
+RunMakefile.py
+'''
+
+import os
+import sys
+import argparse
+import subprocess
+
+#
+# Globals for help information
+#
+__prog__= 'RunMakefile'
+__version__ = '%s Version %s' % (__prog__, '1.0')
+__copyright__   = 'Copyright (c) 2017, Intel Corporation. All rights reserved.'
+__description__ = 'Run a makefile as part of a PREBUILD or POSTBUILD action.\n'
+
+#
+# Globals
+#
+gArgs = None
+
+def Log(Message):
+  if not gArgs.Verbose:
+return
+  sys.stdout.write (__prog__ + ': ' + Message + '\n')
+
+def Error(Message, ExitValue=1):
+  sys.stderr.write (__prog__ + ': ERROR: ' + Message + '\n')
+  sys.exit (ExitValue)
+
+def RelativePath(target):
+  return os.path.relpath (target, gWorkspace)
+
+def NormalizePath(target):
+  if isinstance(target, tuple):
+return os.path.normpath (os.path.join (*target))
+  else:
+return os.path.normpath (target)
+
+if __name__ == '__main__':
+  #
+  # Create command line argument parser object
+  #
+  parser = argparse.ArgumentParser (
+  prog = __prog__,
+  version = __version__,
+  description = __description__ + __copyright__,
+  conflict_handler = 'resolve'
+  )
+  parser.add_argument (
+   '-a', '--arch', dest = 'Arch', nargs = '+', action = 'append',
+   required = True,
+   help = '''ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC,
+ which overrides target.txt's TARGET_ARCH definition. To
+ specify more archs, please repeat this option.'''
+   )
+  parser.add_argument (
+   '-t', '--tagname', dest = 'ToolChain', required = True,
+   help = '''Using the Tool Chain Tagname to build the platform,
+ overriding target.txt's TOOL_CHAIN_TAG definition.'''
+   )
+  parser.add_argument (
+   '-p', '--platform', dest = 'PlatformFile', required = True,
+   help = '''Build the platform specified by the DSC file name 
argument,
+ overriding target.txt's ACTIVE_PLATFORM definition.'''
+   )
+  parser.add_argument (
+   '-b', '--buildtarget', dest = 'BuildTarget', required = True,
+   help = '''Using the TARGET to build the platform, overriding
+ target.txt's TARGET definition.'''
+   )
+  parser.add_argument (
+   '--conf=', dest = 'ConfDirectory', required = True,
+   help = '''Specify the customized Conf directory.'''
+   )
+  parser.add_argument (
+   '-D', '--define', dest = 'Define', nargs='*', action = 'append',
+   help = '''Macro: "Name [= Value]".'''
+   )
+  parser.add_argument (
+   '--makefile', dest = 'Makefile', required = True,
+   help = '''Makefile to run 

[edk2] [RFC Patch 1/3] BaseTools/build: Expand PREBUILD/POSTBUILD DSC actions

2017-08-03 Thread Michael D Kinney
* Extend PREBUILD/POSTBUILD define values to support more than
  one argument.
* Delay normalization of PREBUILD/POSTBUILD define values
  until all arguments in the define values can be processed.
* Convert PREBUILD/POSTBUILD build define value arguments
  that are WORKSPACE or PACKAGES_PATH relative paths to
  absolute paths.
* Append -p PlatformFile, --conf=ConfDirectory, and build target
  flags to command line used to execute PREBUILD/POSTBUILD
  actions.
* Remove PrebuildScript and PostbuildScript fields from the
  Build class and use Prebuild and Postbuild fields instead.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 .../Source/Python/Workspace/WorkspaceDatabase.py   |   4 +-
 BaseTools/Source/Python/build/build.py | 108 +++--
 2 files changed, 82 insertions(+), 30 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py 
b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index 73b3fe7134..fe2c7c17c4 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -237,7 +237,7 @@ class DscBuildData(PlatformBuildClassObject):
 EdkLogger.error('build', FORMAT_INVALID, 'Missing 
double quotes in the end of %s statement.' % TAB_DSC_PREBUILD,
 File=self.MetaFile, Line=Record[-1])
 PrebuildValue = Record[2][1:-1]
-self._Prebuild = PathClass(NormPath(PrebuildValue, 
self._Macros), GlobalData.gWorkspace)
+self._Prebuild = PrebuildValue
 elif Name == TAB_DSC_POSTBUILD:
 PostbuildValue = Record[2]
 if Record[2][0] == '"':
@@ -245,7 +245,7 @@ class DscBuildData(PlatformBuildClassObject):
 EdkLogger.error('build', FORMAT_INVALID, 'Missing 
double quotes in the end of %s statement.' % TAB_DSC_POSTBUILD,
 File=self.MetaFile, Line=Record[-1])
 PostbuildValue = Record[2][1:-1]
-self._Postbuild = PathClass(NormPath(PostbuildValue, 
self._Macros), GlobalData.gWorkspace)
+self._Postbuild = PostbuildValue
 elif Name == TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES:
 self._SupArchList = GetSplitValueList(Record[2], 
TAB_VALUE_SPLIT)
 elif Name == TAB_DSC_DEFINES_BUILD_TARGETS:
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 4d05ee2761..7436453582 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -796,8 +796,6 @@ class Build():
 self.BuildModules = []
 self.Db_Flag = False
 self.LaunchPrebuildFlag = False
-self.PrebuildScript = ''
-self.PostbuildScript = ''
 self.PlatformBuildPath = 
os.path.join(GlobalData.gConfDirectory,'.cache', '.PlatformBuild')
 if BuildOptions.CommandLength:
 GlobalData.gCommandMaxLength = BuildOptions.CommandLength
@@ -819,11 +817,11 @@ class Build():
 EdkLogger.quiet("%-16s = %s" % ("CONF_PATH", 
GlobalData.gConfDirectory))
 self.InitPreBuild()
 self.InitPostBuild()
-if self.PrebuildScript:
-EdkLogger.quiet("%-16s = %s" % ("PREBUILD", self.PrebuildScript))
-if self.PostbuildScript:
-EdkLogger.quiet("%-16s = %s" % ("POSTBUILD", self.PostbuildScript))
-if self.PrebuildScript:
+if self.Prebuild:
+EdkLogger.quiet("%-16s = %s" % ("PREBUILD", self.Prebuild))
+if self.Postbuild:
+EdkLogger.quiet("%-16s = %s" % ("POSTBUILD", self.Postbuild))
+if self.Prebuild:
 self.LaunchPrebuild()
 self.TargetTxt = TargetTxtClassObject()
 self.ToolDef   = ToolDefClassObject()
@@ -964,16 +962,37 @@ class Build():
 Platform = self.Db._MapPlatform(str(self.PlatformFile))
 self.Prebuild = str(Platform.Prebuild)
 if self.Prebuild:
-PrebuildList = self.Prebuild.split()
-if not os.path.isabs(PrebuildList[0]):
-PrebuildList[0] = mws.join(self.WorkspaceDir, PrebuildList[0])
-if os.path.isfile(PrebuildList[0]):
-self.PrebuildScript = PrebuildList[0]
-self.Prebuild = ' '.join(PrebuildList)
-self.Prebuild += self.PassCommandOption(self.BuildTargetList, 
self.ArchList, self.ToolChainList)
-#self.LaunchPrebuild()
-else:
-EdkLogger.error("Prebuild", PREBUILD_ERROR, "the prebuild 
script %s is not exist.\n If you'd like to disable the Prebuild process, please 
use the format: -D PREBUILD=\"\" " %(PrebuildList[0]))
+PrebuildList = []
+#
+ 

[edk2] [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for use with RunMakefile.py

2017-08-03 Thread Michael D Kinney
Add sample makefile that can be used to test RunMakefile.py
script and can also be used as a template to start a new
PREBUILD/POSTBUILD makefile.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
---
 BaseTools/Scripts/RunMakefileSample.mak | 43 +
 1 file changed, 43 insertions(+)
 create mode 100644 BaseTools/Scripts/RunMakefileSample.mak

diff --git a/BaseTools/Scripts/RunMakefileSample.mak 
b/BaseTools/Scripts/RunMakefileSample.mak
new file mode 100644
index 00..b0947b7644
--- /dev/null
+++ b/BaseTools/Scripts/RunMakefileSample.mak
@@ -0,0 +1,43 @@
+## @file
+# Sample makefile for PREBUILD or POSTBUILD action.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD 
License
+# which accompanies this distribution. The full text of the license may be 
found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+all: show
+   @echo $@
+genc: show
+   @echo $@
+genmake: show
+   @echo $@
+modules: show
+   @echo $@
+libraries: show
+   @echo $@
+fds: show
+   @echo $@
+clean: show
+   @echo $@
+cleanall: show
+   @echo $@
+cleanlib: show
+   @echo $@
+run: show
+   @echo $@
+
+show:
+   @echo WORKSPACE $(WORKSPACE)
+   @echo PACKAGES_PATH $(PACKAGES_PATH)
+   @echo ACTIVE_PLATFORM.. $(ACTIVE_PLATFORM)
+   @echo TARGET_ARCH.. $(TARGET_ARCH)
+   @echo TOOL_CHAIN_TAG... $(TOOL_CHAIN_TAG)
+   @echo CONF_DIRECTORY... $(CONF_DIRECTORY)
+   @echo TARGET... $(TARGET)
+   @echo EXTRA_FLAGS.. $(EXTRA_FLAGS)
-- 
2.13.1.windows.2

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


[edk2] [RFC Patch 0/3] Expand PREBUILD/POSTBUILD actions

2017-08-03 Thread Michael D Kinney
A platform DSC file can provide PREBUILD and POSTBUILD actions in the 
[Defines] section of the DSC file.  The EDK II DSC specification only allows
a single argument for these two defines, which means the PREBUILD and 
POSTBUILD actions are limited to simple batch files, shell scripts, or
applications with no additional arguments.  This also means that a platform
DSC file that uses the PREBUILD/POSTBUILD feature is typically limited to single
OS development environment.

This RFC and associated patch series expands the PREBUILD and POSTBUILD 
define syntax to support multiple arguments.  All arguments are scanned.
Arguments that are WORKSPACE or PACKAGES_PATH relative file paths are converted
to absolute paths.  Supporting multiple arguments allows PREBUILD and POSTBUILD
actions to be implemented in OS independent scripts such as Python. The 
following is an example of a PREBUILD action that runs the python interpreter
on a python script provided in a platform package:

[Defines]
  PREBUILD = python MyPlatformPackage/MyPreBuildScript.py

Supporting multiple arguments also allows additional platform arguments to be
passed into the script:

[Defines]
  PREBUILD = python MyPlatformPackage/MyPreBuildScript.py --FlashSize 4MB

In addition, the EDK II Build Specification states that TARGET, ARCH, and
TOOL_CHAIN_TAG are passed to the PREBUILD and POSTBUILD commands.  The path
to the platform DSC file being build, the path to the Conf directory, and the 
build target form the following set are not provided:

  [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]
  
It is important for the PREBUILD and POSTBUILD actions to receive the same 
context that is provided to the build command. 

This RFC and associated patch series expands the context passed into the
PREBUILD and POSTBUILD actions to include the -p ,
--conf=, and build target arguments.

I have also seen requests to support makefiles in the PREBUILD and POSTBUILD
actions.  Makefiles receive context from system environment and define values
passed in on the command line.  In order to support makefiles, a generic python
script called /BaseTools/Scripts/RunMakefile.py is also included in this patch
series.  This python script converts command line arguments to makefile defines
and runs a makefile specified with the --makefile flag. A sample makefile that
echos the relevant system environment variables and defines is provided in
BaseTools/Scripts/RunMakefileSample.mak.  An example PREBUIILD action that runs
a makefile is as follows:

[Defines]
  PREBUILD = python BaseTools/Script/RunMakefile.py --makefile 
BaseTools/Scripts/RunMakefileSample.mak

The example above contains 4 arguments.  2 of these arguments are WORKSPACE or
PACKAGES_PATH relative paths that must be converted to absolute paths.  This
is a use case that justifies expanding the PREBUILD and POSTBUILD define
statements to support multiple arguments.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 

Michael D Kinney (3):
  BaseTools/build: Expand PREBUILD/POSTBUILD DSC actions
  BaseTools/Scripts: Add python script to run a makefile
  BaseTools/Scripts: Add sample makefile for use with RunMakefile.py

 BaseTools/Scripts/RunMakefile.py   | 178 +
 BaseTools/Scripts/RunMakefileSample.mak|  43 +
 .../Source/Python/Workspace/WorkspaceDatabase.py   |   4 +-
 BaseTools/Source/Python/build/build.py | 108 +
 4 files changed, 303 insertions(+), 30 deletions(-)
 create mode 100644 BaseTools/Scripts/RunMakefile.py
 create mode 100644 BaseTools/Scripts/RunMakefileSample.mak

-- 
2.13.1.windows.2

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


Re: [edk2] [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList verifications.

2017-08-03 Thread Gao, Liming
I have no preference. Please go ahead. 

> -Original Message-
> From: Marvin H?user [mailto:marvin.haeu...@outlook.com]
> Sent: Thursday, August 3, 2017 11:43 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming ; Kinney, Michael D 
> 
> Subject: RE: [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList 
> verifications.
> 
> Hey Liming,
> 
> I noticed that and assumed that a second call is not going to hurt much (only 
> used in DEBUG afterall).
> To work around that, the macro could be modified to either call 
> IsNodeInList() or InternalBaseLibIsListValid() based on the PCD value,
> though one would have to know/check the PCD's value to know what actually 
> triggered the ASSERT(), so I opted to separate the
> ASSERTs (this also looks cleaner in my opinion).
> The macro could also be modified to carry two separate ASSERT calls, which 
> would solve the issue above,
> though I would need to think of a proper name for a macro that checks list 
> membership *and* whether the list is valid.
> If you have a preference, please let me know, otherwise I'll come up with a 
> V3 soon.
> 
> Thanks and regards,
> Marvin.
> 
> > -Original Message-
> > From: Gao, Liming [mailto:liming@intel.com]
> > Sent: Thursday, August 3, 2017 5:28 PM
> > To: marvin.haeu...@outlook.com; edk2-devel@lists.01.org
> > Cc: Kinney, Michael D 
> > Subject: RE: [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList
> > verifications.
> >
> > Marvin:
> >   If PcdVerifyNodeInList is set TRUE, InternalBaseLibIsListValid() will be
> > checked twice in two ASSERT(). In the original logic, 
> > InternalBaseLibIsListValid
> > only runs once. Could we work out the same check logic?
> >
> > Thanks
> > Liming
> > > -Original Message-
> > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > > Marvin H?user
> > > Sent: Wednesday, August 2, 2017 9:12 PM
> > > To: edk2-devel@lists.01.org
> > > Cc: Kinney, Michael D ; Gao, Liming
> > > 
> > > Subject: [edk2] [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList
> > verifications.
> > >
> > > 1) Replace InternalBaseLibIsNodeInList() with
> > >InternalBaseLibIsListValid().
> > >- The verification whether Node is within the doubly-linked List
> > >  is now done by IsNodeInList().
> > >- Whether the list is valid is returned.
> > >
> > > 2) The comments within InsertHeadList() and InsertTailList() stated
> > >that it is checked whether Entry is not part of the doubly-linked
> > >list. This was not done as argument 3 of
> > >InternalBaseLibIsNodeInList() indicated whether the check is done,
> > >not whether to check if the node is or is not in the list. This
> > >has been fixed by using IsNodeInList() for the ASSERTs.
> > >
> > > V2:
> > >   - Fix IsListEmpty() to ASSERT when the passed list is invalid.
> > >   - Introduce the VERIFY_IS_NODE_IN_LIST() macro to only verify whether
> > the
> > > passed node is part of the list when PcdVerifyNodeInList is TRUE.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Marvin Haeuser 
> > > ---
> > >  MdePkg/Library/BaseLib/LinkedList.c | 105 +---
> > >  1 file changed, 47 insertions(+), 58 deletions(-)
> > >
> > > diff --git a/MdePkg/Library/BaseLib/LinkedList.c
> > > b/MdePkg/Library/BaseLib/LinkedList.c
> > > index 484ee836b8c2..6864fae7d939 100644
> > > --- a/MdePkg/Library/BaseLib/LinkedList.c
> > > +++ b/MdePkg/Library/BaseLib/LinkedList.c
> > > @@ -15,25 +15,38 @@
> > >  #include "BaseLibInternals.h"
> > >
> > >  /**
> > > -  Worker function that locates the Node in the List.
> > > +  If PcdVerifyNodeInList is TRUE, checks whether FirstNode and
> > > + SecondNode are  part of the same doubly-linked list.
> > >
> > > -  By searching the List, finds the location of the Node in List. At
> > > the same time,
> > > -  verifies the validity of this list.
> > > +  If FirstEntry is NULL, then ASSERT().
> > > +  If FirstEntry->ForwardLink is NULL, then ASSERT().
> > > +  If FirstEntry->BackLink is NULL, then ASSERT().
> > > +  If SecondEntry is NULL, then ASSERT();  If
> > > + PcdMaximumLinkedListLength is not zero, and List contains more than
> > > + PcdMaximumLinkedListLength nodes, then ASSERT().
> > > +
> > > +  @param  FirstEntry   A pointer to a node in a linked list.
> > > +  @param  SecondEntry  A pointer to the node to locate.
> > > +
> > > +  @retval TRUE   SecondEntry is in the same doubly-linked list as 
> > > FirstEntry
> > > + or PcdVerifyNodeInList is FALSE.
> > > +  @retval FALSE  SecondEntry isn't in the same doubly-linked list as
> > FirstEntry,
> > > + or FirstEntry is invalid.
> > > +
> > > +**/
> > > +#define VERIFY_IS_NODE_IN_LIST(FirstEntry, SecondEntry)  \
> > > +  (!FeaturePcdGet (PcdVerifyNodeInList) || 

[edk2] [PATCH v2 1/1] OvmfPkg : QemuFwCfgLib: Use BusMasterCommandBuffer to map FW_CFG_DMA_ACCESS

2017-08-03 Thread Brijesh Singh
Commit 09719a01b11b (OvmfPkg/QemuFwCfgLib: Implement SEV internal function for 
Dxe phase)
uses IOMMU protocol to allocate and free FW_CFG_DMA_ACCESS buffer
when SEV is active. During initial commits we made assumption that
IOMMU.AllocateBuffer() will provide PlainTextAddress (i.e C-bit
cleared). This assumption was wrong, the AllocateBuffer() protocol
member is not expected to produce a buffer that is immediatly usable,
and client is required to call Map() uncondtionally with 
BusMasterCommonBuffer[64]
to get a mapping which is accessable by both host and device.

The patch refactors code a bit and add the support to Map()
FW_CFG_DMA_ACCESS buffer using BusMasterCommonBuffer operation
after allocation and Unamp() before free.

The complete discussion about this and recommendation from Laszlo
can be found here [1]

[1] https://lists.01.org/pipermail/edk2-devel/2017-July/012652.html

Suggested-by: Laszlo Ersek 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brijesh Singh 
---
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h |  42 ++--
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c | 247 
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 130 ---
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 101 +---
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c |  56 ++---
 5 files changed, 292 insertions(+), 284 deletions(-)

diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
index 8cfa7913ffae..327f1d37e17d 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
@@ -45,39 +45,25 @@ InternalQemuFwCfgDmaIsAvailable (
   );
 
 /**
- Returns a boolean indicating whether SEV support is enabled
+  Transfer an array of bytes, or skip a number of bytes, using the DMA
+  interface.
 
- @retvalTRUESEV is enabled
- @retvalFALSE   SEV is disabled
-**/
-BOOLEAN
-InternalQemuFwCfgSevIsEnabled (
-  VOID
-  );
+  @param[in] Size Size in bytes to transfer or skip.
 
-/**
- Allocate a bounce buffer for SEV DMA.
-
-  @param[out]Buffer   Allocated DMA Buffer pointer
-  @param[in] NumPage  Number of pages.
+  @param[in,out] Buffer   Buffer to read data into or write data from. Ignored,
+  and may be NULL, if Size is zero, or Control is
+  FW_CFG_DMA_CTL_SKIP.
 
+  @param[in] Control  One of the following:
+  FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer.
+  FW_CFG_DMA_CTL_READ  - read from fw_cfg into Buffer.
+  FW_CFG_DMA_CTL_SKIP  - skip bytes in fw_cfg.
 **/
 VOID
-InternalQemuFwCfgSevDmaAllocateBuffer (
-  OUTVOID **Buffer,
-  IN UINT32   NumPages
+InternalQemuFwCfgDmaBytes (
+  IN UINT32   Size,
+  IN OUT VOID *Buffer OPTIONAL,
+  IN UINT32   Control
   );
 
-/**
- Free the DMA buffer allocated using InternalQemuFwCfgSevDmaAllocateBuffer
-
-  @param[in] NumPage  Number of pages.
-  @param[in] Buffer   DMA Buffer pointer
-
-**/
-VOID
-InternalQemuFwCfgSevDmaFreeBuffer (
-  IN VOID *Buffer,
-  IN UINT32   NumPages
-  );
 #endif
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
index f8eb03bc3a9a..e03647bae3bd 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
@@ -20,6 +20,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -157,74 +158,228 @@ InternalQemuFwCfgDmaIsAvailable (
 }
 
 /**
- Allocate a bounce buffer for SEV DMA.
-
-  @param[in] NumPage  Number of pages.
-  @param[out]Buffer   Allocated DMA Buffer pointer
+  Function is used for allocating a bi-directional FW_CFG_DMA_ACCESS used
+  between Host and device to exchange the information. The buffer must be 
free'd
+  using FreeFwCfgDmaAccessBuffer ().
 
 **/
-VOID
-InternalQemuFwCfgSevDmaAllocateBuffer (
-  OUTVOID **Buffer,
-  IN UINT32   NumPages
+STATIC
+EFI_STATUS
+AllocFwCfgDmaAccessBuffer (
+  OUT   VOID **Access,
+  OUT   VOID **Mapping
   )
 {
-  EFI_STATUSStatus;
+  UINTN Size;
+  UINTN NumPages;
+  EFI_STATUSStatus;
+  VOID  *HostAddress;
+  EFI_PHYSICAL_ADDRESS  DmaAddress;
 
-  ASSERT (mIoMmuProtocol != NULL);
+  Size = sizeof (FW_CFG_DMA_ACCESS);
+  NumPages = EFI_SIZE_TO_PAGES (Size);
 
+  //
+  // As per UEFI spec,  in order to map a host address with 
BusMasterCommomBuffer64,
+  // the buffer must be allocated using the IOMMU AllocateBuffer()
+  //
   Status = mIoMmuProtocol->AllocateBuffer (
-mIoMmuProtocol,
-0,
-

[edk2] [PATCH v2 0/1] OvmfPkg/QemuFwCfgLib: Use BusMasterCommandBuffer to map FW_CFG_DMA_ACCESS

2017-08-03 Thread Brijesh Singh
The patch applies on top of Laszlo's IoMmuDxe cleanup series [1].

Commit is also available at https://github.com/codomania/edk2/tree/qemufwcfg-sev

[1] https://lists.01.org/pipermail/edk2-devel/2017-August/012808.html

Changes since v1:
* Drop Patch 1 through 3, they are covered by Laszlo's cleanup series
* Rebase to the latest

Brijesh Singh (1):
  OvmfPkg : QemuFwCfgLib: Use BusMasterCommandBuffer to map
FW_CFG_DMA_ACCESS

 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h |  42 ++--
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c | 247 
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 130 ---
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 101 +---
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c |  56 ++---
 5 files changed, 292 insertions(+), 284 deletions(-)

-- 
2.7.4

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


Re: [edk2] [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList verifications.

2017-08-03 Thread Marvin H?user
Hey Liming,

I noticed that and assumed that a second call is not going to hurt much (only 
used in DEBUG afterall).
To work around that, the macro could be modified to either call IsNodeInList() 
or InternalBaseLibIsListValid() based on the PCD value,
though one would have to know/check the PCD's value to know what actually 
triggered the ASSERT(), so I opted to separate the ASSERTs (this also looks 
cleaner in my opinion).
The macro could also be modified to carry two separate ASSERT calls, which 
would solve the issue above,
though I would need to think of a proper name for a macro that checks list 
membership *and* whether the list is valid.
If you have a preference, please let me know, otherwise I'll come up with a V3 
soon.

Thanks and regards,
Marvin.

> -Original Message-
> From: Gao, Liming [mailto:liming@intel.com]
> Sent: Thursday, August 3, 2017 5:28 PM
> To: marvin.haeu...@outlook.com; edk2-devel@lists.01.org
> Cc: Kinney, Michael D 
> Subject: RE: [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList
> verifications.
> 
> Marvin:
>   If PcdVerifyNodeInList is set TRUE, InternalBaseLibIsListValid() will be
> checked twice in two ASSERT(). In the original logic, 
> InternalBaseLibIsListValid
> only runs once. Could we work out the same check logic?
> 
> Thanks
> Liming
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Marvin H?user
> > Sent: Wednesday, August 2, 2017 9:12 PM
> > To: edk2-devel@lists.01.org
> > Cc: Kinney, Michael D ; Gao, Liming
> > 
> > Subject: [edk2] [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList
> verifications.
> >
> > 1) Replace InternalBaseLibIsNodeInList() with
> >InternalBaseLibIsListValid().
> >- The verification whether Node is within the doubly-linked List
> >  is now done by IsNodeInList().
> >- Whether the list is valid is returned.
> >
> > 2) The comments within InsertHeadList() and InsertTailList() stated
> >that it is checked whether Entry is not part of the doubly-linked
> >list. This was not done as argument 3 of
> >InternalBaseLibIsNodeInList() indicated whether the check is done,
> >not whether to check if the node is or is not in the list. This
> >has been fixed by using IsNodeInList() for the ASSERTs.
> >
> > V2:
> >   - Fix IsListEmpty() to ASSERT when the passed list is invalid.
> >   - Introduce the VERIFY_IS_NODE_IN_LIST() macro to only verify whether
> the
> > passed node is part of the list when PcdVerifyNodeInList is TRUE.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Marvin Haeuser 
> > ---
> >  MdePkg/Library/BaseLib/LinkedList.c | 105 +---
> >  1 file changed, 47 insertions(+), 58 deletions(-)
> >
> > diff --git a/MdePkg/Library/BaseLib/LinkedList.c
> > b/MdePkg/Library/BaseLib/LinkedList.c
> > index 484ee836b8c2..6864fae7d939 100644
> > --- a/MdePkg/Library/BaseLib/LinkedList.c
> > +++ b/MdePkg/Library/BaseLib/LinkedList.c
> > @@ -15,25 +15,38 @@
> >  #include "BaseLibInternals.h"
> >
> >  /**
> > -  Worker function that locates the Node in the List.
> > +  If PcdVerifyNodeInList is TRUE, checks whether FirstNode and
> > + SecondNode are  part of the same doubly-linked list.
> >
> > -  By searching the List, finds the location of the Node in List. At
> > the same time,
> > -  verifies the validity of this list.
> > +  If FirstEntry is NULL, then ASSERT().
> > +  If FirstEntry->ForwardLink is NULL, then ASSERT().
> > +  If FirstEntry->BackLink is NULL, then ASSERT().
> > +  If SecondEntry is NULL, then ASSERT();  If
> > + PcdMaximumLinkedListLength is not zero, and List contains more than
> > + PcdMaximumLinkedListLength nodes, then ASSERT().
> > +
> > +  @param  FirstEntry   A pointer to a node in a linked list.
> > +  @param  SecondEntry  A pointer to the node to locate.
> > +
> > +  @retval TRUE   SecondEntry is in the same doubly-linked list as 
> > FirstEntry
> > + or PcdVerifyNodeInList is FALSE.
> > +  @retval FALSE  SecondEntry isn't in the same doubly-linked list as
> FirstEntry,
> > + or FirstEntry is invalid.
> > +
> > +**/
> > +#define VERIFY_IS_NODE_IN_LIST(FirstEntry, SecondEntry)  \
> > +  (!FeaturePcdGet (PcdVerifyNodeInList) || IsNodeInList
> > +((FirstEntry), (SecondEntry)))
> > +
> > +/**
> > +  Worker function that verifies the validity of this list.
> >
> >If List is NULL, then ASSERT().
> >If List->ForwardLink is NULL, then ASSERT().
> > -  If List->backLink is NULL, then ASSERT().
> > -  If Node is NULL, then ASSERT().
> > -  If PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE and
> > Node
> > -  is in not a member of List, then return FALSE
> > +  If List->BackLink is NULL, then ASSERT().
> >If PcdMaximumLinkedListLength is not zero, and List contains more than
> >

[edk2] [PATCH] BaseTools/edksetup.sh: fix invalid test for current working directory

2017-08-03 Thread Chris Ruffin
edksetup.sh implements a test that requires the current working
directory to contain the edksetup.sh script.  This test has the side
effect of requiring the WORKSPACE to be set to the same directory as
the edksetup.sh.  In a multiple workspace configuration, it is
required to be able to have a WORKSPACE that is different from the
directory that contains edksetup.sh.  This changeset skips this test
if PACKAGE_PATH is set.

Change-Id: Ie6f16a08c012baf4e650c48cc8e91cdc466d05f2
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Ruffin 
---
 edksetup.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/edksetup.sh b/edksetup.sh
index ec54f9ea40..93d6525758 100755
--- a/edksetup.sh
+++ b/edksetup.sh
@@ -54,7 +54,7 @@ function SetWorkspace()
 return 0
   fi
 
-  if [ ! ${BASH_SOURCE[0]} -ef ./edksetup.sh ]
+  if [ ! ${BASH_SOURCE[0]} -ef ./edksetup.sh ] && [ -z "$PACKAGES_PATH" ]
   then
 echo Run this script from the base of your tree.  For example:
 echo "  cd /Path/To/Edk/Root"
-- 
2.13.3.windows.1

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


Re: [edk2] [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList verifications.

2017-08-03 Thread Gao, Liming
Marvin:
  If PcdVerifyNodeInList is set TRUE, InternalBaseLibIsListValid() will be 
checked twice in two ASSERT(). In the original logic, 
InternalBaseLibIsListValid only runs once. Could we work out the same check 
logic?

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Marvin 
> H?user
> Sent: Wednesday, August 2, 2017 9:12 PM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Gao, Liming 
> 
> Subject: [edk2] [PATCH v2 2/2] MdePkg/BaseLib: Update internal LinkedList 
> verifications.
> 
> 1) Replace InternalBaseLibIsNodeInList() with
>InternalBaseLibIsListValid().
>- The verification whether Node is within the doubly-linked List
>  is now done by IsNodeInList().
>- Whether the list is valid is returned.
> 
> 2) The comments within InsertHeadList() and InsertTailList() stated
>that it is checked whether Entry is not part of the doubly-linked
>list. This was not done as argument 3 of
>InternalBaseLibIsNodeInList() indicated whether the check is done,
>not whether to check if the node is or is not in the list. This
>has been fixed by using IsNodeInList() for the ASSERTs.
> 
> V2:
>   - Fix IsListEmpty() to ASSERT when the passed list is invalid.
>   - Introduce the VERIFY_IS_NODE_IN_LIST() macro to only verify whether the
> passed node is part of the list when PcdVerifyNodeInList is TRUE.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marvin Haeuser 
> ---
>  MdePkg/Library/BaseLib/LinkedList.c | 105 +---
>  1 file changed, 47 insertions(+), 58 deletions(-)
> 
> diff --git a/MdePkg/Library/BaseLib/LinkedList.c 
> b/MdePkg/Library/BaseLib/LinkedList.c
> index 484ee836b8c2..6864fae7d939 100644
> --- a/MdePkg/Library/BaseLib/LinkedList.c
> +++ b/MdePkg/Library/BaseLib/LinkedList.c
> @@ -15,25 +15,38 @@
>  #include "BaseLibInternals.h"
> 
>  /**
> -  Worker function that locates the Node in the List.
> +  If PcdVerifyNodeInList is TRUE, checks whether FirstNode and SecondNode are
> +  part of the same doubly-linked list.
> 
> -  By searching the List, finds the location of the Node in List. At the same 
> time,
> -  verifies the validity of this list.
> +  If FirstEntry is NULL, then ASSERT().
> +  If FirstEntry->ForwardLink is NULL, then ASSERT().
> +  If FirstEntry->BackLink is NULL, then ASSERT().
> +  If SecondEntry is NULL, then ASSERT();
> +  If PcdMaximumLinkedListLength is not zero, and List contains more than
> +  PcdMaximumLinkedListLength nodes, then ASSERT().
> +
> +  @param  FirstEntry   A pointer to a node in a linked list.
> +  @param  SecondEntry  A pointer to the node to locate.
> +
> +  @retval TRUE   SecondEntry is in the same doubly-linked list as FirstEntry
> + or PcdVerifyNodeInList is FALSE.
> +  @retval FALSE  SecondEntry isn't in the same doubly-linked list as 
> FirstEntry,
> + or FirstEntry is invalid.
> +
> +**/
> +#define VERIFY_IS_NODE_IN_LIST(FirstEntry, SecondEntry)  \
> +  (!FeaturePcdGet (PcdVerifyNodeInList) || IsNodeInList ((FirstEntry), 
> (SecondEntry)))
> +
> +/**
> +  Worker function that verifies the validity of this list.
> 
>If List is NULL, then ASSERT().
>If List->ForwardLink is NULL, then ASSERT().
> -  If List->backLink is NULL, then ASSERT().
> -  If Node is NULL, then ASSERT().
> -  If PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE and Node
> -  is in not a member of List, then return FALSE
> +  If List->BackLink is NULL, then ASSERT().
>If PcdMaximumLinkedListLength is not zero, and List contains more than
>PcdMaximumLinkedListLength nodes, then ASSERT().
> 
>@param  List  A pointer to a node in a linked list.
> -  @param  Node  A pointer to a node in a linked list.
> -  @param  VerifyNodeInList  TRUE if a check should be made to see if Node is 
> a
> -member of List.  FALSE if no membership test 
> should
> -be performed.
> 
>@retval   TRUE if PcdVerifyNodeInList is FALSE
>@retval   TRUE if DoMembershipCheck is FALSE
> @@ -45,10 +58,8 @@
>  **/
>  BOOLEAN
>  EFIAPI
> -InternalBaseLibIsNodeInList (
> -  IN CONST LIST_ENTRY  *List,
> -  IN CONST LIST_ENTRY  *Node,
> -  IN BOOLEAN   VerifyNodeInList
> +InternalBaseLibIsListValid (
> +  IN CONST LIST_ENTRY  *List
>)
>  {
>UINTN Count;
> @@ -60,40 +71,11 @@ InternalBaseLibIsNodeInList (
>ASSERT (List != NULL);
>ASSERT (List->ForwardLink != NULL);
>ASSERT (List->BackLink != NULL);
> -  ASSERT (Node != NULL);
> -
> -  Count = 0;
> -  Ptr   = List;
> -
> -  if (FeaturePcdGet (PcdVerifyNodeInList) && VerifyNodeInList) {
> -//
> -// Check to see if Node is a member of List.
> -// Exit early if the number of nodes in List >= 
> PcdMaximumLinkedListLength
> -//
> -do {
> -  

Re: [edk2] [PATCH 1/2] MdePkg: Add definition for SecHobData PPI

2017-08-03 Thread Gao, Liming
Reviewed-by: Liming Gao  for this serials.

> -Original Message-
> From: Zeng, Star
> Sent: Wednesday, August 2, 2017 6:37 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Gao, Liming 
> Subject: [PATCH 1/2] MdePkg: Add definition for SecHobData PPI
> 
> This PPI is introduced in PI Version 1.5.
> 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> ---
>  MdePkg/Include/Ppi/SecHobData.h | 65 
> +
>  MdePkg/MdePkg.dec   |  7 +
>  2 files changed, 72 insertions(+)
>  create mode 100644 MdePkg/Include/Ppi/SecHobData.h
> 
> diff --git a/MdePkg/Include/Ppi/SecHobData.h b/MdePkg/Include/Ppi/SecHobData.h
> new file mode 100644
> index ..0efe1a2d0b77
> --- /dev/null
> +++ b/MdePkg/Include/Ppi/SecHobData.h
> @@ -0,0 +1,65 @@
> +/** @file
> +  This file declares Sec Hob Data PPI.
> +
> +  This PPI provides a way for the SEC code to pass zero or more HOBs in a 
> HOB list.
> +
> +Copyright (c) 2017, 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.
> +The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php.
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +  @par Revision Reference:
> +  This PPI is introduced in PI Version 1.5.
> +
> +**/
> +
> +#ifndef __SEC_HOB_DATA_PPI_H__
> +#define __SEC_HOB_DATA_PPI_H__
> +
> +#include 
> +
> +#define EFI_SEC_HOB_DATA_PPI_GUID \
> +  { \
> +0x3ebdaf20, 0x6667, 0x40d8, {0xb4, 0xee, 0xf5, 0x99, 0x9a, 0xc1, 0xb7, 
> 0x1f } \
> +  }
> +
> +typedef struct _EFI_SEC_HOB_DATA_PPI EFI_SEC_HOB_DATA_PPI;
> +
> +/**
> +  Return a pointer to a buffer containing zero or more HOBs that
> +  will be installed into the PEI HOB List.
> +
> +  This function returns a pointer to a pointer to zero or more HOBs,
> +  terminated with a HOB of type EFI_HOB_TYPE_END_OF_HOB_LIST.
> +  Note: The HobList must not contain a EFI_HOB_HANDOFF_INFO_TABLE HOB (PHIT) 
> HOB.
> +
> +  @param[in]  This  Pointer to this PPI structure.
> +  @param[out] HobList   A pointer to a returned pointer to zero or more 
> HOBs.
> +If no HOBs are to be returned, then the returned 
> pointer
> +is a pointer to a HOB of type 
> EFI_HOB_TYPE_END_OF_HOB_LIST.
> +
> +  @retval EFI_SUCCESS   This function completed successfully.
> +  @retval EFI_NOT_FOUND No HOBS are available.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *EFI_SEC_HOB_DATA_GET) (
> +  IN CONST EFI_SEC_HOB_DATA_PPI *This,
> +  OUT EFI_HOB_GENERIC_HEADER**HobList
> +);
> +
> +///
> +/// This PPI provides a way for the SEC code to pass zero or more HOBs in a 
> HOB list.
> +///
> +struct _EFI_SEC_HOB_DATA_PPI {
> +  EFI_SEC_HOB_DATA_GET  GetHobs;
> +};
> +
> +extern EFI_GUID gEfiSecHobDataPpiGuid;
> +
> +#endif
> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> index d6928b3f97bf..f54b056563b4 100644
> --- a/MdePkg/MdePkg.dec
> +++ b/MdePkg/MdePkg.dec
> @@ -909,6 +909,13 @@ [Ppis]
>## Include/Ppi/SecPlatformInformation.h
>gEfiSecPlatformInformation2PpiGuid = { 0x9e9f374b, 0x8f16, 0x4230, {0x98, 
> 0x24, 0x58, 0x46, 0xee, 0x76, 0x6a, 0x97 } }
> 
> +  #
> +  # PPIs defined in PI 1.5.
> +  #
> +
> +  ## Include/Ppi/SecHobData.h
> +  gEfiSecHobDataPpiGuid = { 0x3ebdaf20, 0x6667, 0x40d8, {0xb4, 0xee, 0xf5, 
> 0x99, 0x9a, 0xc1, 0xb7, 0x1f } }
> +
>  [Protocols]
>## Include/Protocol/Pcd.h
>gPcdProtocolGuid   = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 
> 0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}
> --
> 2.7.0.windows.1

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


Re: [edk2] [PATCH] BaseTools/Conf: apply nasmb, asm16 build rule order

2017-08-03 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chris 
> Ruffin
> Sent: Thursday, August 3, 2017 4:30 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH] BaseTools/Conf: apply nasmb, asm16 build rule order
> 
> Prioritize nasmb rule over asm16 where both source types are specified.
> 
> Change-Id: I33ec348dab66b313ddb05cb15f2d8407a648c320
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Chris Ruffin 
> ---
>  BaseTools/Conf/tools_def.template | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index 4b1b7b548c..689b6ec501 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -7756,4 +7756,4 @@ RELEASE_RVCTCYGWIN_ARM_CC_FLAGS  = "$(CCPATH_FLAG)" 
> $(ARCHCC_FLAGS) $(PLATFORM_F
>  #
>  # Build rule order
>  #
> -*_*_*_*_BUILDRULEORDER = nasm asm Asm ASM S s
> +*_*_*_*_BUILDRULEORDER = nasm asm Asm ASM S s nasmb asm16
> --
> 2.13.3.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] IntelFsp2Pkg: Delete useless external TempRamInitApi API

2017-08-03 Thread Gao, Liming
Jiewen:
  The change is in SecFspSecPlatformLibNull. This library instance provides the 
dummy function. It should not be used by any real FSP. We meet with the build 
issue with /WHOLEARCHIVE option. Because this library depends on the external 
TempRamInitApi(), but FspSecCoreS and FspSecCoreT don't provide 
TempRamInitApi(). Then, FspSecCoreS and FspSecCoreT will build failure. To fix 
this build failure, we choose to remove this unnecessary dependency. 

> >  global ASM_PFX(ProtectedModeEntryPoint)
> >  ASM_PFX(ProtectedModeEntryPoint):
> > -  ;
> > -  ; Dummy function. Consume 2 API to make sure they can be linked.
> > -  ;

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yao, 
> Jiewen
> Sent: Thursday, August 3, 2017 9:03 PM
> To: Song, BinX ; edk2-devel@lists.01.org
> Cc: Giri P Mudusuru 
> Subject: Re: [edk2] [PATCH] IntelFsp2Pkg: Delete useless external 
> TempRamInitApi API
> 
> Hi
> May I know what test you have done to remove this?
> 
> Have you built a real FSP and boot it with FSP Wrapper?
> 
> Thank you
> Yao Jiewen
> 
> > -Original Message-
> > From: Song, BinX
> > Sent: Thursday, August 3, 2017 1:47 PM
> > To: edk2-devel@lists.01.org
> > Cc: Yao, Jiewen ; Giri P Mudusuru
> > 
> > Subject: [PATCH] IntelFsp2Pkg: Delete useless external TempRamInitApi API
> >
> > - Delete useless external TempRamInitApi API to fix /WHOLEARCHIVE build
> >   error with VS2015 tool chain
> >
> > Cc: Jiewen Yao 
> > Cc: Giri P Mudusuru 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Bell Song 
> > ---
> >  IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm | 7 ---
> >  1 file changed, 7 deletions(-)
> >
> > diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm
> > b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm
> > index 122eb9e..ee78312 100644
> > --- a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm
> > +++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm
> > @@ -16,8 +16,6 @@
> >  ; Define assembler characteristics
> >  ;
> >
> > -extern   ASM_PFX(TempRamInitApi)
> > -
> >  SECTION .text
> >
> >  %macro RET_ESI  0
> > @@ -66,11 +64,6 @@ ASM_PFX(SecPlatformInit):
> >  
> > ;
> >  global ASM_PFX(ProtectedModeEntryPoint)
> >  ASM_PFX(ProtectedModeEntryPoint):
> > -  ;
> > -  ; Dummy function. Consume 2 API to make sure they can be linked.
> > -  ;
> > -  mov  eax, ASM_PFX(TempRamInitApi)
> > -
> >; Should never return
> >jmp  $
> >
> > --
> > 2.10.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 10/12] OvmfPkg/IoMmuDxe: implement in-place decryption/encryption for Map/Unmap

2017-08-03 Thread Laszlo Ersek
On 08/03/17 16:35, Brijesh Singh wrote:
> Laszlo,
> 
> One minor issue, I got compilation error with GCC48.
> 
> /home/brijesh/codomania/edk2-new/edk2/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c: In
> function ‘IoMmuUnmap’:
> /home/brijesh/codomania/edk2-new/edk2/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c:408:25:
> error: ‘CommonBufferHeader’ may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
>CommonBufferHeader->StashBuffer,
> 
> Looks like we need to initialize CommonBufferHeader = NULL to keep GCC48
> happy.

Interesting, I use GCC48 all the time (as part of RHEL7 on my laptop),
and I didn't get this warning. I'll suppress it.

Thank you for the report!
Laszlo

> 
> thanks
> 
> On 08/02/2017 08:09 PM, Brijesh Singh wrote:
>>
>>
>> On 8/2/17 7:13 PM, Laszlo Ersek wrote:
>>> (CC Andrew)
>>>
>>> On 08/03/17 01:01, Brijesh Singh wrote:

 On 8/2/17 4:24 PM, Laszlo Ersek wrote:

 [Snip]
> At the moment, we have the foll+// The buffer at
> MapInfo->CryptedAddress comes from AllocateBuffer().
>   //
>   MapInfo->PlainTextAddress = MapInfo->CryptedAddress;
> -
>   //
> -// Therefore no mapping is necessary.
> +// Stash the crypted data.
>   //
> -*DeviceAddress = MapInfo->PlainTextAddress;
> -*Mapping   = NO_MAPPING;
> -FreePool (MapInfo);
> -return EFI_SUCCESS;
> +CommonBufferHeader = (COMMON_BUFFER_HEADER *)(
> +   (UINTN)MapInfo->CryptedAddress -
> EFI_PAGE_SIZE
> +   );
 One question, per spec, is it legal for client to call Map() at some
 offset within allocated buffer ?

 e.g something like this:

 * AllocateBuffer (, 1, );
 * MapBuffer = Buffer + 10;
 * Map (, BusMasterCommonBuffer, MappedBuffer, 10, ..) // Bascially Map
 10 bytes from offset 10
>>> The input/output parameter names seem to counter-indicate such use.
>>> Namely, AllocateBuffer() outputs a "HostAddress" param, and Map() takes
>>> a "HostAddress" param. Plus we have sentences like this:
>>>
>>> Under PciIo.Map():
>>>
 ... only memory allocated via the AllocateBuffer() interface can be
 mapped for this type of operation ...
>>> Under PciIo.AllocateBuffer():
>>>
 The AllocateBuffer() function allocates pages that are suitable for an
 EfiPciOperationBusMasterCommonBuffer or
 EfiPciOperationBusMasterCommonBuffer64 mapping. This means that the
 buffer allocated by this function must support simultaneous access by
 both the processor and a PCI Bus Master. The device address that the
 PCI Bus Master uses to access *the* buffer can be retrieved with a
 call to Map().
>>> This second passage says *the* buffer. (Emphasis mine above.)
>>>
 If this is legal then we may need to build MapInfo during
 AllocateBuffer() to locate the "StashBuffer".
>>> Right, in that case we'd have to build a list of allocated ranges (an
>>> interval tree of sorts) in AllocateBuffer, and convert any
>>> CommonBuffer[64] Map() call to its containing allocation with a search.
>>>
>>> It would be worse than that, actually... The pattern you have raised
>>> could be taken one step further: do one AllocateBuffer(), and several
>>> CommonBuffer[64] Map()s into it :) What should happen if those maps are
>>> distinct? What should happen if they overlap? :) I can't even imagine
>>> what this would mean for SEV.
>>>
>>> ... There are guide-like sections in the generic description of
>>> EFI_PCI_IO_PROTOCOL; Andrew quoted them earlier:
>>>
>>>   
>>> A29CDE8F-C82A-4C92-ABF8-008A9BF8F230@apple.com">http://mid.mail-archive.com/A29CDE8F-C82A-4C92-ABF8-008A9BF8F230@apple.com
>>>
>>>
 DMA Bus Master Common Buffer Operation
 ==
 * Call AllocateBuffer() to allocate a common buffer.
 * Call Map() for EfiPciIoOperationBusMasterCommonBuffer.
 * Program the DMA Bus Master with the DeviceAddress returned by Map().
 * The common buffer can now be accessed equally by the processor and
the DMA bus master.
 * Call Unmap().
 * Call FreeBuffer().
>>> Look at page 854 (printed page number: 784) in UEFI 2.7.
>>>
>>> Thus, I don't think the usage you raise is permitted.
>>
>> Sounds good. I did a quick test on SEV hardware, everything seems to be
>> working well. I have started my stresstest and report the result
>> tomorrow.
>>
>> -Brijesh
>>

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


Re: [edk2] [PATCH 10/12] OvmfPkg/IoMmuDxe: implement in-place decryption/encryption for Map/Unmap

2017-08-03 Thread Brijesh Singh

Laszlo,

One minor issue, I got compilation error with GCC48.

/home/brijesh/codomania/edk2-new/edk2/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c: In 
function ‘IoMmuUnmap’:
/home/brijesh/codomania/edk2-new/edk2/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c:408:25: 
error: ‘CommonBufferHeader’ may be used uninitialized in this function 
[-Werror=maybe-uninitialized]
   CommonBufferHeader->StashBuffer,

Looks like we need to initialize CommonBufferHeader = NULL to keep GCC48 happy.

thanks

On 08/02/2017 08:09 PM, Brijesh Singh wrote:



On 8/2/17 7:13 PM, Laszlo Ersek wrote:

(CC Andrew)

On 08/03/17 01:01, Brijesh Singh wrote:


On 8/2/17 4:24 PM, Laszlo Ersek wrote:

[Snip]

At the moment, we have the foll+// The buffer at MapInfo->CryptedAddress 
comes from AllocateBuffer().
  //
  MapInfo->PlainTextAddress = MapInfo->CryptedAddress;
-
  //
-// Therefore no mapping is necessary.
+// Stash the crypted data.
  //
-*DeviceAddress = MapInfo->PlainTextAddress;
-*Mapping   = NO_MAPPING;
-FreePool (MapInfo);
-return EFI_SUCCESS;
+CommonBufferHeader = (COMMON_BUFFER_HEADER *)(
+   (UINTN)MapInfo->CryptedAddress - EFI_PAGE_SIZE
+   );

One question, per spec, is it legal for client to call Map() at some
offset within allocated buffer ?

e.g something like this:

* AllocateBuffer (, 1, );
* MapBuffer = Buffer + 10;
* Map (, BusMasterCommonBuffer, MappedBuffer, 10, ..) // Bascially Map
10 bytes from offset 10

The input/output parameter names seem to counter-indicate such use.
Namely, AllocateBuffer() outputs a "HostAddress" param, and Map() takes
a "HostAddress" param. Plus we have sentences like this:

Under PciIo.Map():


... only memory allocated via the AllocateBuffer() interface can be
mapped for this type of operation ...

Under PciIo.AllocateBuffer():


The AllocateBuffer() function allocates pages that are suitable for an
EfiPciOperationBusMasterCommonBuffer or
EfiPciOperationBusMasterCommonBuffer64 mapping. This means that the
buffer allocated by this function must support simultaneous access by
both the processor and a PCI Bus Master. The device address that the
PCI Bus Master uses to access *the* buffer can be retrieved with a
call to Map().

This second passage says *the* buffer. (Emphasis mine above.)


If this is legal then we may need to build MapInfo during
AllocateBuffer() to locate the "StashBuffer".

Right, in that case we'd have to build a list of allocated ranges (an
interval tree of sorts) in AllocateBuffer, and convert any
CommonBuffer[64] Map() call to its containing allocation with a search.

It would be worse than that, actually... The pattern you have raised
could be taken one step further: do one AllocateBuffer(), and several
CommonBuffer[64] Map()s into it :) What should happen if those maps are
distinct? What should happen if they overlap? :) I can't even imagine
what this would mean for SEV.

... There are guide-like sections in the generic description of
EFI_PCI_IO_PROTOCOL; Andrew quoted them earlier:

   A29CDE8F-C82A-4C92-ABF8-008A9BF8F230@apple.com">http://mid.mail-archive.com/A29CDE8F-C82A-4C92-ABF8-008A9BF8F230@apple.com


DMA Bus Master Common Buffer Operation
==
* Call AllocateBuffer() to allocate a common buffer.
* Call Map() for EfiPciIoOperationBusMasterCommonBuffer.
* Program the DMA Bus Master with the DeviceAddress returned by Map().
* The common buffer can now be accessed equally by the processor and
   the DMA bus master.
* Call Unmap().
* Call FreeBuffer().

Look at page 854 (printed page number: 784) in UEFI 2.7.

Thus, I don't think the usage you raise is permitted.


Sounds good. I did a quick test on SEV hardware, everything seems to be
working well. I have started my stresstest and report the result tomorrow.

-Brijesh


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


Re: [edk2] [PATCH 00/12] OvmfPkg/IoMmuDxe: cleanups and fixes

2017-08-03 Thread Laszlo Ersek
On 08/03/17 16:10, Brijesh Singh wrote:
> Hi Laszlo,
> 
> On 08/02/2017 04:24 PM, Laszlo Ersek wrote:
>> This series is proposed as a replacement (or a replacement "basis") for
>> patches #1 through #3 of Brijesh's series
>>
>>[PATCH v1 0/4] OvmfPkg : IoMmuDxe: BusMasterCommonBuffer support when
>>   SEV is active
>>   
>> 1501529474-20550-1-git-send-email-brijesh.singh@amd.com">http://mid.mail-archive.com/1501529474-20550-1-git-send-email-brijesh.singh@amd.com
>>
>>
>> Patch #4 of the same series ("OvmfPkg : QemuFwCfgLib: Map DMA buffer
>> with CommonBuffer when SEV is enable") is required on top of this
>> series; otherwise QemuFwCfgLib will break on SEV.
>>
>>
>> In the present series, patches #1 through #7 are lightweight
>> improvements for OvmfPkg/IoMmuDxe, concerning line width, MAP_INFO field
>> names, conversion specifiers for DEBUG(), coding style, error
>> propagation, and library class listings.
>>
>> Patch #8 ("zero out pages before releasing them") fixes the "information
>> leak" issue pointed out in:
>>
>>   
>> e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com">http://mid.mail-archive.com/e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com
>>
>>
>> Patch #9 ('rework setup of "MapInfo->PlainTextAddress" in Map()') fixes
>> as-yet undiscussed issues, and lays the groundwork for patch #10, by
>> reworking the calculation of the plaintext buffer address.
>>
>> Patch #10 ("implement in-place decryption/encryption for Map/Unmap")
>> fixes the issues around BusMasterCommonBuffer[64] operations that were
>> discussed in the following messages:
>>
>>   
>> 4071596d-32c9-e6d9-8c93-0d43d28e9b5a@redhat.com">http://mid.mail-archive.com/4071596d-32c9-e6d9-8c93-0d43d28e9b5a@redhat.com
>>
>>   
>> e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com">http://mid.mail-archive.com/e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com
>>
>>   
>> 84c3c5db-623e-181b-c472-7fd7ae1c1670@amd.com">http://mid.mail-archive.com/84c3c5db-623e-181b-c472-7fd7ae1c1670@amd.com
>>   
>> 89e1553a-1630-87a5-cffd-99174a380d41@redhat.com">http://mid.mail-archive.com/89e1553a-1630-87a5-cffd-99174a380d41@redhat.com
>>
>>
>> Patch #11 ("abort harder on memory encryption mask failures") settles
>> the error handling for MemEncryptSevClearPageEncMask() and
>> MemEncryptSevSetPageEncMask(), discussed in:
>>
>>   
>> 89e1553a-1630-87a5-cffd-99174a380d41@redhat.com">http://mid.mail-archive.com/89e1553a-1630-87a5-cffd-99174a380d41@redhat.com
>>
>>
>> Patch #12 ("Unmap(): recycle MAP_INFO after BusMasterCommonBuffer[64]")
>> implements the "free list" proposed in:
>>
>>   
>> e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com">http://mid.mail-archive.com/e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com
>>
>>
>> The series has been formatted with "--function-context", for easier
>> review.
>>
>> Repo:   https://github.com/lersek/edk2.git
>> Branch: amdsev_iommu_cleanups_fixes
>>
>> Cc: Ard Biesheuvel 
>> Cc: Brijesh Singh 
>> Cc: Jordan Justen 
>> Cc: Tom Lendacky 
>>
> 
> Appreciate your help, the series looks good. I have ran some overnight
> tests
> and so far things are looking positive. As you pointed out in blurb that we
> still need Patch #4 from my series. I will soon send updated version.
> 
> Tested-By: Brijesh Singh 
> Reviewed-by: Brijesh Singh 
> 

Thank you!

I'll try to review your patch #4 soon after it hits the list. (Please
also consider pushing it to your public repo.)

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


Re: [edk2] [Patch v3 3/3] UefiCpuPkg: Enable Processor Trace feature.

2017-08-03 Thread Fan, Jeff
Eric,

Typo: " Protected Processor Inventory Number" should be " Intel Processor Trace 
" 
+  @param[in]  StateIf TRUE, then the Protected Processor Inventory 
+   Number feature must be enabled.
+   If FALSE, then the Protected Processor 
Inventory 
+   Number feature must be disabled.
+
+  @retval RETURN_SUCCESS   Intel Processor Trace feature is initialized.
Jeff

-Original Message-
From: Fan, Jeff 
Sent: Thursday, August 03, 2017 10:04 PM
To: Dong, Eric; edk2-devel@lists.01.org
Cc: Ni, Ruiyu
Subject: RE: [Patch v3 3/3] UefiCpuPkg: Enable Processor Trace feature.

Eric,

In ProcTraceInitialize(), we cannot assume ProcessorNumber 0 is always BSP.

+  if (ProcessorNumber == 0) {
+IsBsp = TRUE;

The recommended method is to allocate memory in ProcTraceGetConfigData().

Or add one buffer point in ConfigData structure. 
If buffer point is NULL, allocate buffer, for ProcTraceInitialize() is invoked 
by BSP only.

Jeff

-Original Message-
From: Dong, Eric
Sent: Tuesday, August 01, 2017 3:41 PM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff; Ni, Ruiyu
Subject: [Patch v3 3/3] UefiCpuPkg: Enable Processor Trace feature.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 .../CpuCommonFeaturesLib/CpuCommonFeatures.h   |  66 +++
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c|  11 +
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf  |   4 +-
 .../Library/CpuCommonFeaturesLib/ProcTrace.c   | 465 +
 4 files changed, 545 insertions(+), 1 deletion(-)  create mode 100644 
UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
index c03e5ab..b4a351c 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
@@ -909,4 +909,70 @@ PpinInitialize (
   IN BOOLEAN   State
   );
 
+/**
+  Prepares for the data used by CPU feature detection and initialization.
+
+  @param[in]  NumberOfProcessors  The number of CPUs in the platform.
+
+  @return  Pointer to a buffer of CPU related configuration data.
+
+  @note This service could be called by BSP only.
+**/
+VOID *
+EFIAPI
+ProcTraceGetConfigData (
+  IN UINTN  NumberOfProcessors
+  );
+
+/**
+  Detects if Intel Processor Trace feature supported on current processor.
+
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.
+  @param[in]  CpuInfo  A pointer to the 
REGISTER_CPU_FEATURE_INFORMATION
+   structure for the CPU executing this function.
+  @param[in]  ConfigData   A pointer to the configuration buffer returned
+   by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
+   CPU_FEATURE_GET_CONFIG_DATA was not provided in
+   RegisterCpuFeature().
+
+  @retval TRUE Processor Trace feature is supported.
+  @retval FALSEProcessor Trace feature is not supported.
+
+  @note This service could be called by BSP/APs.
+**/
+BOOLEAN
+EFIAPI
+ProcTraceSupport (
+  IN UINTN ProcessorNumber,
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
+  IN VOID  *ConfigData  OPTIONAL
+  );
+
+/**
+  Initializes Intel Processor Trace feature to specific state.
+
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.
+  @param[in]  CpuInfo  A pointer to the 
REGISTER_CPU_FEATURE_INFORMATION
+   structure for the CPU executing this function.
+  @param[in]  ConfigData   A pointer to the configuration buffer returned
+   by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
+   CPU_FEATURE_GET_CONFIG_DATA was not provided in
+   RegisterCpuFeature().
+  @param[in]  StateIf TRUE, then the Protected Processor Inventory 
+   Number feature must be enabled.
+   If FALSE, then the Protected Processor 
Inventory 
+   Number feature must be disabled.
+
+  @retval RETURN_SUCCESS   Intel Processor Trace feature is initialized.
+
+**/
+RETURN_STATUS
+EFIAPI
+ProcTraceInitialize (
+  IN UINTN ProcessorNumber,
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
+  IN VOID  *ConfigData,  OPTIONAL
+  IN BOOLEAN   State
+  );
+
 #endif
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
index b88b7d1..a4cb260 100644
--- 

Re: [edk2] [Patch 1/3] UefiCpuPkg: Add definition for LMCE feature.

2017-08-03 Thread Fan, Jeff
Reviewed-by: Jeff Fan 

-Original Message-
From: Dong, Eric 
Sent: Tuesday, August 01, 2017 3:51 PM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff; Ni, Ruiyu
Subject: [Patch 1/3] UefiCpuPkg: Add definition for LMCE feature.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h 
b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
index 8ea0609..54153f4 100644
--- a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
+++ b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
@@ -35,6 +35,7 @@
 #define CPU_FEATURE_FASTSTRINGS 6
 #define CPU_FEATURE_VMX 7
 #define CPU_FEATURE_SMX 8
+#define CPU_FEATURE_LMCE9
 #define CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER   10
 #define CPU_FEATURE_LIMIT_CPUID_MAX_VAL 11
 #define CPU_FEATURE_MCE 12
-- 
2.7.0.windows.1

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


Re: [edk2] [Patch 3/3] UefiCpuPkg PiSmmCpuDxeSmm: Check LMCE capability when wait for AP.

2017-08-03 Thread Fan, Jeff
Reviewed-by: Jeff Fan 

-Original Message-
From: Dong, Eric 
Sent: Tuesday, August 01, 2017 3:51 PM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff; Ni, Ruiyu
Subject: [Patch 3/3] UefiCpuPkg PiSmmCpuDxeSmm: Check LMCE capability when wait 
for AP.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 57 ++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 4ac5e8e..6b66c49 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -196,6 +196,56 @@ AllCpusInSmmWithExceptions (
   return TRUE;
 }
 
+/**
+  Has OS enabled Lmce in the MSR_IA32_MCG_EXT_CTL
+  
+  @retval TRUE Os enable lmce.
+  @retval FALSEOs not enable lmce.
+
+**/
+BOOLEAN
+IsLmceOsEnabled (
+  VOID
+  )
+{
+  MSR_IA32_MCG_CAP_REGISTER  McgCap;
+  MSR_IA32_FEATURE_CONTROL_REGISTER  FeatureCtrl;
+  MSR_IA32_MCG_EXT_CTL_REGISTER  McgExtCtrl;
+
+  McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);  if 
+ (McgCap.Bits.MCG_LMCE_P == 0) {
+return FALSE;
+  }
+
+  FeatureCtrl.Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);  if 
+ (FeatureCtrl.Bits.LmceOn == 0) {
+return FALSE;
+  }
+
+  McgExtCtrl.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_EXT_CTL);
+  return (BOOLEAN) (McgExtCtrl.Bits.LMCE_EN == 1); }
+
+/**
+  Return if Local machine check exception signaled. 
+
+  Indicates (when set) that a local machine check exception was 
+ generated. This indicates that the current machine-check event was  delivered 
to only the logical processor.
+
+  @retval TRUELMCE was signaled.
+  @retval FALSE   LMCE was not signaled.
+
+**/
+BOOLEAN
+IsLmceSignaled (
+  VOID
+  )
+{
+  MSR_IA32_MCG_STATUS_REGISTER McgStatus;
+
+  McgStatus.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_STATUS);
+  return (BOOLEAN) (McgStatus.Bits.LMCE_S == 1); }
 
 /**
   Given timeout constraint, wait for all APs to arrive, and insure when this 
function returns, no AP will execute normal mode code before @@ -209,9 +259,14 
@@ SmmWaitForApArrival (  {
   UINT64Timer;
   UINTN Index;
+  BOOLEAN   LmceEn;
+  BOOLEAN   LmceSignal;
 
   ASSERT (*mSmmMpSyncData->Counter <= mNumberOfCpus);
 
+  LmceEn = IsLmceOsEnabled ();
+  LmceSignal = IsLmceSignaled();
+
   //
   // Platform implementor should choose a timeout value appropriately:
   // - The timeout value should balance the SMM time constrains and the 
likelihood that delayed CPUs are excluded in the SMM run. Note @@ -227,7 +282,7 
@@ SmmWaitForApArrival (
   // Sync with APs 1st timeout
   //
   for (Timer = StartSyncTimer ();
-   !IsSyncTimerTimeout (Timer) &&
+   !IsSyncTimerTimeout (Timer) && !(LmceEn && LmceSignal) &&
!AllCpusInSmmWithExceptions (ARRIVAL_EXCEPTION_BLOCKED | 
ARRIVAL_EXCEPTION_SMI_DISABLED );
) {
 CpuPause ();
--
2.7.0.windows.1

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


Re: [edk2] [PATCH 00/12] OvmfPkg/IoMmuDxe: cleanups and fixes

2017-08-03 Thread Brijesh Singh

Hi Laszlo,

On 08/02/2017 04:24 PM, Laszlo Ersek wrote:

This series is proposed as a replacement (or a replacement "basis") for
patches #1 through #3 of Brijesh's series

   [PATCH v1 0/4] OvmfPkg : IoMmuDxe: BusMasterCommonBuffer support when
  SEV is active
   
1501529474-20550-1-git-send-email-brijesh.singh@amd.com">http://mid.mail-archive.com/1501529474-20550-1-git-send-email-brijesh.singh@amd.com

Patch #4 of the same series ("OvmfPkg : QemuFwCfgLib: Map DMA buffer
with CommonBuffer when SEV is enable") is required on top of this
series; otherwise QemuFwCfgLib will break on SEV.


In the present series, patches #1 through #7 are lightweight
improvements for OvmfPkg/IoMmuDxe, concerning line width, MAP_INFO field
names, conversion specifiers for DEBUG(), coding style, error
propagation, and library class listings.

Patch #8 ("zero out pages before releasing them") fixes the "information
leak" issue pointed out in:

   e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com">http://mid.mail-archive.com/e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com

Patch #9 ('rework setup of "MapInfo->PlainTextAddress" in Map()') fixes
as-yet undiscussed issues, and lays the groundwork for patch #10, by
reworking the calculation of the plaintext buffer address.

Patch #10 ("implement in-place decryption/encryption for Map/Unmap")
fixes the issues around BusMasterCommonBuffer[64] operations that were
discussed in the following messages:

   4071596d-32c9-e6d9-8c93-0d43d28e9b5a@redhat.com">http://mid.mail-archive.com/4071596d-32c9-e6d9-8c93-0d43d28e9b5a@redhat.com
   e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com">http://mid.mail-archive.com/e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com
   84c3c5db-623e-181b-c472-7fd7ae1c1670@amd.com">http://mid.mail-archive.com/84c3c5db-623e-181b-c472-7fd7ae1c1670@amd.com
   89e1553a-1630-87a5-cffd-99174a380d41@redhat.com">http://mid.mail-archive.com/89e1553a-1630-87a5-cffd-99174a380d41@redhat.com

Patch #11 ("abort harder on memory encryption mask failures") settles
the error handling for MemEncryptSevClearPageEncMask() and
MemEncryptSevSetPageEncMask(), discussed in:

   89e1553a-1630-87a5-cffd-99174a380d41@redhat.com">http://mid.mail-archive.com/89e1553a-1630-87a5-cffd-99174a380d41@redhat.com

Patch #12 ("Unmap(): recycle MAP_INFO after BusMasterCommonBuffer[64]")
implements the "free list" proposed in:

   e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com">http://mid.mail-archive.com/e1137140-f5d5-7eb8-0162-952694b24f96@redhat.com

The series has been formatted with "--function-context", for easier
review.

Repo:   https://github.com/lersek/edk2.git
Branch: amdsev_iommu_cleanups_fixes

Cc: Ard Biesheuvel 
Cc: Brijesh Singh 
Cc: Jordan Justen 
Cc: Tom Lendacky 



Appreciate your help, the series looks good. I have ran some overnight tests
and so far things are looking positive. As you pointed out in blurb that we
still need Patch #4 from my series. I will soon send updated version.

Tested-By: Brijesh Singh 
Reviewed-by: Brijesh Singh 

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


Re: [edk2] [Patch 2/3] UefiCpuPkg CpuCommonFeaturesLib: Enable LMCE feature.

2017-08-03 Thread Fan, Jeff
Eric,

Typo: " Protected Processor Inventory Number" should be " Local machine check 
exception " 
+  @param[in]  StateIf TRUE, then the Protected Processor Inventory 
+   Number feature must be enabled.
+   If FALSE, then the Protected Processor 
Inventory 
+   Number feature must be disabled.
+
+  @retval RETURN_SUCCESS   Local machine check exception feature is 
initialized.

Jeff

-Original Message-
From: Dong, Eric 
Sent: Tuesday, August 01, 2017 3:51 PM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff; Ni, Ruiyu
Subject: [Patch 2/3] UefiCpuPkg CpuCommonFeaturesLib: Enable LMCE feature.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 .../CpuCommonFeaturesLib/CpuCommonFeatures.h   | 56 +-
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c| 12 +++
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf  |  1 +
 UefiCpuPkg/Library/CpuCommonFeaturesLib/Lmce.c | 90 ++
 4 files changed, 157 insertions(+), 2 deletions(-)  create mode 100644 
UefiCpuPkg/Library/CpuCommonFeaturesLib/Lmce.c

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
index c03e5ab..67a44c6 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
@@ -866,8 +866,8 @@ FeatureControlGetConfigData (
CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature().
 
-  @retval TRUE Enhanced Intel SpeedStep feature is supported.
-  @retval FALSEEnhanced Intel SpeedStep feature is not supported.
+  @retval TRUE Protected Processor Inventory Number feature is supported.
+  @retval FALSEProtected Processor Inventory Number feature is not 
supported.
 
   @note This service could be called by BSP/APs.
 **/
@@ -909,4 +909,56 @@ PpinInitialize (
   IN BOOLEAN   State
   );
 
+/**
+  Detects if Local machine check exception feature supported on current
+  processor.
+
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.
+  @param[in]  CpuInfo  A pointer to the 
REGISTER_CPU_FEATURE_INFORMATION
+   structure for the CPU executing this function.
+  @param[in]  ConfigData   A pointer to the configuration buffer returned
+   by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
+   CPU_FEATURE_GET_CONFIG_DATA was not provided in
+   RegisterCpuFeature().
+
+  @retval TRUE Local machine check exception feature is supported.
+  @retval FALSELocal machine check exception feature is not supported.
+
+  @note This service could be called by BSP/APs.
+**/
+BOOLEAN
+EFIAPI
+LmceSupport (
+  IN UINTN ProcessorNumber,
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
+  IN VOID  *ConfigData  OPTIONAL
+  );
+
+/**
+  Initializes Local machine check exception feature to specific state.
+
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.
+  @param[in]  CpuInfo  A pointer to the 
REGISTER_CPU_FEATURE_INFORMATION
+   structure for the CPU executing this function.
+  @param[in]  ConfigData   A pointer to the configuration buffer returned
+   by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
+   CPU_FEATURE_GET_CONFIG_DATA was not provided in
+   RegisterCpuFeature().
+  @param[in]  StateIf TRUE, then the Protected Processor Inventory 
+   Number feature must be enabled.
+   If FALSE, then the Protected Processor 
Inventory 
+   Number feature must be disabled.
+
+  @retval RETURN_SUCCESS   Local machine check exception feature is 
initialized.
+
+**/
+RETURN_STATUS
+EFIAPI
+LmceInitialize (
+  IN UINTN ProcessorNumber,
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
+  IN VOID  *ConfigData,  OPTIONAL
+  IN BOOLEAN   State
+  );
+
 #endif
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
index b88b7d1..4c78209 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
@@ -217,6 +217,18 @@ CpuCommonFeaturesLibConstructor (
);
 ASSERT_EFI_ERROR (Status);
   }
+  if (IsCpuFeatureSupported (CPU_FEATURE_LMCE)) {
+Status = 

[edk2] Announcing the edk2-platforms master branch

2017-08-03 Thread Leif Lindholm
Hi all,

A little over two years ago, I set up OpenPlatformPkg [1] as a way to
prototype a single source tree for multiple platforms, built against
edk2.

Last year, we finalised the rules for how such a tree could be
integrated into the edk2-platforms [2] repository, and I have now
completed the migration. edk2-platforms master branch is now live
(although there will be some lag before it becomes the _default_
branch of the repository).

Binary-only components have moved to edk2-non-osi [3]. At the same
time edk2-non-osi has been updated with a directory structure aligned
with edk2-platforms master - as well as had explicit documentation
added regarding how licenses work in that tree.

As of this moment, OpenPlatformPkg becomes a read-only historical
document.

Mike has agreed to share overall maintainership of edk2-platforms with
me, at least until we start breaking down responsibility a bit more.

Happy hacking!

/
Leif

[1] https://git.linaro.org/uefi/OpenPlatformPkg.git
[2] https://github.com/tianocore/edk2-platforms.git
[3] https://github.com/tianocore/edk2-non-osi.git
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch v3 3/3] UefiCpuPkg: Enable Processor Trace feature.

2017-08-03 Thread Fan, Jeff
Eric,

In ProcTraceInitialize(), we cannot assume ProcessorNumber 0 is always BSP.

+  if (ProcessorNumber == 0) {
+IsBsp = TRUE;

The recommended method is to allocate memory in ProcTraceGetConfigData().

Or add one buffer point in ConfigData structure. 
If buffer point is NULL, allocate buffer, for ProcTraceInitialize() is invoked 
by BSP only.

Jeff

-Original Message-
From: Dong, Eric 
Sent: Tuesday, August 01, 2017 3:41 PM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff; Ni, Ruiyu
Subject: [Patch v3 3/3] UefiCpuPkg: Enable Processor Trace feature.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 .../CpuCommonFeaturesLib/CpuCommonFeatures.h   |  66 +++
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c|  11 +
 .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf  |   4 +-
 .../Library/CpuCommonFeaturesLib/ProcTrace.c   | 465 +
 4 files changed, 545 insertions(+), 1 deletion(-)  create mode 100644 
UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
index c03e5ab..b4a351c 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
@@ -909,4 +909,70 @@ PpinInitialize (
   IN BOOLEAN   State
   );
 
+/**
+  Prepares for the data used by CPU feature detection and initialization.
+
+  @param[in]  NumberOfProcessors  The number of CPUs in the platform.
+
+  @return  Pointer to a buffer of CPU related configuration data.
+
+  @note This service could be called by BSP only.
+**/
+VOID *
+EFIAPI
+ProcTraceGetConfigData (
+  IN UINTN  NumberOfProcessors
+  );
+
+/**
+  Detects if Intel Processor Trace feature supported on current processor.
+
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.
+  @param[in]  CpuInfo  A pointer to the 
REGISTER_CPU_FEATURE_INFORMATION
+   structure for the CPU executing this function.
+  @param[in]  ConfigData   A pointer to the configuration buffer returned
+   by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
+   CPU_FEATURE_GET_CONFIG_DATA was not provided in
+   RegisterCpuFeature().
+
+  @retval TRUE Processor Trace feature is supported.
+  @retval FALSEProcessor Trace feature is not supported.
+
+  @note This service could be called by BSP/APs.
+**/
+BOOLEAN
+EFIAPI
+ProcTraceSupport (
+  IN UINTN ProcessorNumber,
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
+  IN VOID  *ConfigData  OPTIONAL
+  );
+
+/**
+  Initializes Intel Processor Trace feature to specific state.
+
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.
+  @param[in]  CpuInfo  A pointer to the 
REGISTER_CPU_FEATURE_INFORMATION
+   structure for the CPU executing this function.
+  @param[in]  ConfigData   A pointer to the configuration buffer returned
+   by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
+   CPU_FEATURE_GET_CONFIG_DATA was not provided in
+   RegisterCpuFeature().
+  @param[in]  StateIf TRUE, then the Protected Processor Inventory 
+   Number feature must be enabled.
+   If FALSE, then the Protected Processor 
Inventory 
+   Number feature must be disabled.
+
+  @retval RETURN_SUCCESS   Intel Processor Trace feature is initialized.
+
+**/
+RETURN_STATUS
+EFIAPI
+ProcTraceInitialize (
+  IN UINTN ProcessorNumber,
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
+  IN VOID  *ConfigData,  OPTIONAL
+  IN BOOLEAN   State
+  );
+
 #endif
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
index b88b7d1..a4cb260 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
@@ -217,6 +217,17 @@ CpuCommonFeaturesLibConstructor (
);
 ASSERT_EFI_ERROR (Status);
   }
+  if (IsCpuFeatureSupported (CPU_FEATURE_PROC_TRACE)) {
+Status = RegisterCpuFeature (
+   "Proc Trace",
+   ProcTraceGetConfigData,
+   ProcTraceSupport,
+   ProcTraceInitialize,
+   CPU_FEATURE_PROC_TRACE,
+   CPU_FEATURE_END
+   );
+ASSERT_EFI_ERROR (Status);
+  }
 
   return RETURN_SUCCESS;
 }
diff --git 

Re: [edk2] [PATCH] UefiCpuPkg/Msr: Add a missing IvyBridge processor signature

2017-08-03 Thread Dong, Eric
Reviewed-by: Eric Dong 

-Original Message-
From: Wu, Hao A 
Sent: Wednesday, August 2, 2017 4:30 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Dong, Eric ; Fan, Jeff 

Subject: [PATCH] UefiCpuPkg/Msr: Add a missing IvyBridge processor signature

This commit modifies the CPUID signature check MACRO for IvyBridge processor by 
adding a missing DisplayModel 0x3E. The missing one appears at Section 35.10.1 
to Section 35.10.3 of the Intel(R) 64 and IA-32 Architectures Software 
Developer's Manual, Volume 3, September 2016.

Cc: Eric Dong 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h 
b/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h
index 9eb07994ec..39b0d1af12 100644
--- a/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h
+++ b/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h
@@ -38,7 +38,8 @@
 #define IS_IVY_BRIDGE_PROCESSOR(DisplayFamily, DisplayModel) \
   (DisplayFamily == 0x06 && \
(\
-DisplayModel == 0x3A\
+DisplayModel == 0x3A || \
+DisplayModel == 0x3E\
 )   \
)
 
--
2.12.0.windows.1

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


Re: [edk2] [PATCH] IntelFsp2Pkg: Delete useless external TempRamInitApi API

2017-08-03 Thread Yao, Jiewen
Hi
May I know what test you have done to remove this?

Have you built a real FSP and boot it with FSP Wrapper?

Thank you
Yao Jiewen

> -Original Message-
> From: Song, BinX
> Sent: Thursday, August 3, 2017 1:47 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Giri P Mudusuru
> 
> Subject: [PATCH] IntelFsp2Pkg: Delete useless external TempRamInitApi API
> 
> - Delete useless external TempRamInitApi API to fix /WHOLEARCHIVE build
>   error with VS2015 tool chain
> 
> Cc: Jiewen Yao 
> Cc: Giri P Mudusuru 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Bell Song 
> ---
>  IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm | 7 ---
>  1 file changed, 7 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm
> b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm
> index 122eb9e..ee78312 100644
> --- a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm
> +++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm
> @@ -16,8 +16,6 @@
>  ; Define assembler characteristics
>  ;
> 
> -extern   ASM_PFX(TempRamInitApi)
> -
>  SECTION .text
> 
>  %macro RET_ESI  0
> @@ -66,11 +64,6 @@ ASM_PFX(SecPlatformInit):
>  ;
>  global ASM_PFX(ProtectedModeEntryPoint)
>  ASM_PFX(ProtectedModeEntryPoint):
> -  ;
> -  ; Dummy function. Consume 2 API to make sure they can be linked.
> -  ;
> -  mov  eax, ASM_PFX(TempRamInitApi)
> -
>; Should never return
>jmp  $
> 
> --
> 2.10.2.windows.1

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


Re: [edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.

2017-08-03 Thread Ni, Ruiyu
Eric,
Please refer to the below code sample to avoid defining local macros.

 MSR_IA32_MTRR_DEF_TYPE_REGISTER  DefType;
  //
  // Enable Cache MTRR
  //
  DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE);
  DefType.Bits.E = 1;
  DefType.Bits.FE = 1;
  AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64);

Thanks/Ray

> -Original Message-
> From: Dong, Eric
> Sent: Thursday, August 3, 2017 5:32 PM
> To: edk2-devel@lists.01.org
> Cc: Fan, Jeff ; Ni, Ruiyu ; Kinney,
> Michael D 
> Subject: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated
> macro.
> 
> Cc: Jeff Fan 
> Cc: Ruiyu Ni 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong 
> ---
>  .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c| 26 +--
> ---
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> index 2760427..fe00b37 100644
> --- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> +++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> @@ -23,6 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> 
>  #define QUARK_SOC_CPUID_FAMILY_MODEL_STEPPING 0x590
> 
> +#define CACHE_MTRR_ENABLED0x800
> +#define CACHE_FIXED_MTRR_ENABLED  0x400
> +#define IA32_MTRR_CAP_VCNT_MASK   0xFF
> +
>  //
>  // Context to save and restore when MTRRs are programmed  // @@ -121,7
> +125,7 @@ GetVariableMtrrCountWorker (  {
>UINT32  VariableMtrrCount;
> 
> -  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
> +  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> + (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> IA32_MTRR_CAP_VCNT_MASK);
>ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
>return VariableMtrrCount;
>  }
> @@ -558,7 +562,7 @@ MtrrGetMemoryAttributeInVariableMtrrWorker (
> 
>ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) *
> MTRR_NUMBER_OF_VARIABLE_MTRR);
>for (Index = 0, UsedMtrr = 0; Index < FirmwareVariableMtrrCount; Index++)
> {
> -if ((VariableSettings->Mtrr[Index].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) != 0) {
> +if ((VariableSettings->Mtrr[Index].Mask & CACHE_MTRR_ENABLED) != 0)
> + {
>VariableMtrr[Index].Msr = (UINT32)Index;
>VariableMtrr[Index].BaseAddress = (VariableSettings->Mtrr[Index].Base
> & MtrrValidAddressMask);
>VariableMtrr[Index].Length  = 
> ((~(VariableSettings->Mtrr[Index].Mask
> & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1;
> @@ -969,7 +973,7 @@ ProgramVariableMtrr (
>// MTRR Physical Mask
>//
>TempQword = ~(Length - 1);
> -  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> MtrrValidAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
> +  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> + MtrrValidAddressMask) | CACHE_MTRR_ENABLED;
>  }
> 
> 
> @@ -1157,7 +1161,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>}
>MtrrType = MTRR_CACHE_INVALID_TYPE;
> 
> -  if ((TempQword & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +  if ((TempQword & CACHE_MTRR_ENABLED) == 0) {
>  return CacheUncacheable;
>}
> 
> @@ -1165,7 +1169,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>// If address is less than 1M, then try to go through the fixed MTRR
>//
>if (Address < BASE_1MB) {
> -if ((TempQword & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED) != 0) {
> +if ((TempQword & CACHE_FIXED_MTRR_ENABLED) != 0) {
>//
>// Go through the fixed MTRR
>//
> @@ -1539,7 +1543,7 @@ MtrrSetMemoryAttributeWorker (
>}
>if (MtrrSetting != NULL) {
>  MtrrSetting->Fixed.Mtrr[MsrNum] = (MtrrSetting->Fixed.Mtrr[MsrNum]
> & ~ClearMask) | OrMask;
> -MtrrSetting->MtrrDefType |=
> MTRR_LIB_CACHE_FIXED_MTRR_ENABLED;
> +MtrrSetting->MtrrDefType |= CACHE_FIXED_MTRR_ENABLED;
>} else {
>  if (!FixedSettingsValid[MsrNum]) {
>WorkingFixedSettings.Mtrr[MsrNum] = MtrrRegisterRead
> (mMtrrLibFixedMtrrTable[MsrNum].Msr);
> @@ -1654,7 +1658,7 @@ MtrrSetMemoryAttributeWorker (
>// Find first unused MTRR
>//
>for (MsrNum = 0; MsrNum < VariableMtrrCount; MsrNum++) {
> -if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>break;
>  }
>}
> @@ -1674,7 +1678,7 @@ MtrrSetMemoryAttributeWorker (
>// Find unused MTRR
>//
>for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {

[edk2] [Patch 0/7] Remove deprecated macro.

2017-08-03 Thread Eric Dong
Remove the deprecated macro and change code which use the macro.

Eric Dong (7):
  QuarkSocPkg MtrrLib: Enhance get mtrr mask logic.
  Vlv2TbltDevicePkg: Enhance get mtrr mask logic.
  UefiCpuPkg CpuDxe: Enhance get mtrr mask logic.
  QuarkSocPkg MtrrLib: Remove reference deprecated macro.
  Vlv2TbltDevicePkg: Remove reference deprecated macro.
  UefiCpuPkg CpuDxe: Remove reference deprecated macro.
  UefiCpuPkg MtrrLib: Remove deprecated micro.

 .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c| 35 
 UefiCpuPkg/CpuDxe/CpuDxe.c | 35 
 UefiCpuPkg/CpuDxe/CpuDxe.h |  1 +
 UefiCpuPkg/Include/Library/MtrrLib.h   | 27 -
 Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c | 47 ++
 5 files changed, 77 insertions(+), 68 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro.

2017-08-03 Thread Eric Dong
Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/Include/Library/MtrrLib.h | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/UefiCpuPkg/Include/Library/MtrrLib.h 
b/UefiCpuPkg/Include/Library/MtrrLib.h
index a63da4d..6120526 100644
--- a/UefiCpuPkg/Include/Library/MtrrLib.h
+++ b/UefiCpuPkg/Include/Library/MtrrLib.h
@@ -31,33 +31,6 @@
 #define  RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER  2
 
 #define  MTRR_NUMBER_OF_FIXED_MTRR  11
-//
-// Below macro is deprecated, and should not be used.
-//
-#define  FIRMWARE_VARIABLE_MTRR_NUMBER  6
-#define  MTRR_LIB_IA32_MTRR_CAP  0x0FE
-#define  MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK0x0FF
-#define  MTRR_LIB_IA32_MTRR_FIX64K_0 0x250
-#define  MTRR_LIB_IA32_MTRR_FIX16K_8 0x258
-#define  MTRR_LIB_IA32_MTRR_FIX16K_A 0x259
-#define  MTRR_LIB_IA32_MTRR_FIX4K_C  0x268
-#define  MTRR_LIB_IA32_MTRR_FIX4K_C8000  0x269
-#define  MTRR_LIB_IA32_MTRR_FIX4K_D  0x26A
-#define  MTRR_LIB_IA32_MTRR_FIX4K_D8000  0x26B
-#define  MTRR_LIB_IA32_MTRR_FIX4K_E  0x26C
-#define  MTRR_LIB_IA32_MTRR_FIX4K_E8000  0x26D
-#define  MTRR_LIB_IA32_MTRR_FIX4K_F  0x26E
-#define  MTRR_LIB_IA32_MTRR_FIX4K_F8000  0x26F
-#define  MTRR_LIB_IA32_VARIABLE_MTRR_BASE0x200
-//
-// Below macro is deprecated, and should not be used.
-//
-#define  MTRR_LIB_IA32_VARIABLE_MTRR_END 0x20F
-#define  MTRR_LIB_IA32_MTRR_DEF_TYPE 0x2FF
-#define  MTRR_LIB_MSR_VALID_MASK 0xFULL
-#define  MTRR_LIB_CACHE_VALID_ADDRESS0xFF000ULL
-#define  MTRR_LIB_CACHE_MTRR_ENABLED 0x800
-#define  MTRR_LIB_CACHE_FIXED_MTRR_ENABLED   0x400
 
 //
 // Structure to describe a fixed MTRR
-- 
2.7.0.windows.1

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


[edk2] [Patch 2/7] Vlv2TbltDevicePkg: Enhance get mtrr mask logic.

2017-08-03 Thread Eric Dong
In order to not use the deprecated macro, refine
get mtrr mask value logic.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Cc: David Wei 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c | 45 ++
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c 
b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
index 99bdeb1..5a18a3f 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
@@ -70,6 +70,34 @@ GetMemorySize (
   );
 
 
+/**
+  Initializes the valid address mask for MTRRs.
+
+  This function initializes the valid bits mask and valid address mask for 
MTRRs.
+
+**/
+UINT64
+InitializeAddressMtrrMask (
+  VOID
+  )
+{
+  UINT32RegEax;
+  UINT8 PhysicalAddressBits; 
+  UINT64ValidMtrrBitsMask;
+
+  AsmCpuid (0x8000, , NULL, NULL, NULL);
+
+  if (RegEax >= 0x8008) {
+AsmCpuid (0x8008, , NULL, NULL, NULL);
+
+PhysicalAddressBits = (UINT8) RegEax;
+  } else {
+PhysicalAddressBits = 36;
+  }
+
+  ValidMtrrBitsMask= LShiftU64 (1, PhysicalAddressBits) - 1;
+  return (ValidMtrrBitsMask & 0xf000ULL);
+}
 
 EFI_STATUS
 EFIAPI
@@ -89,6 +117,7 @@ SetPeiCacheMode (
   UINT64  HighMemoryLength;
   UINT8   Index;
   MTRR_SETTINGS   MtrrSetting;
+  UINT64  ValidMtrrAddressMask;
 
   //
   // Load Cache PPI
@@ -124,6 +153,8 @@ SetPeiCacheMode (
  
  );
 
+  ValidMtrrAddressMask = InitializeAddressMtrrMask ();
+
   //
   // Determine memory usage
   //
@@ -166,15 +197,15 @@ SetPeiCacheMode (
   //
   Index = 0;
   MtrrSetting.Variables.Mtrr[0].Base = (FixedPcdGet32 
(PcdFlashAreaBaseAddress) | CacheWriteProtected);
-  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 
(PcdFlashAreaSize) - 1))) & MTRR_LIB_CACHE_VALID_ADDRESS) | 
MTRR_LIB_CACHE_MTRR_ENABLED;
+  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 
(PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
   Index ++;
 
   MemOverflow =0;
   while (MaxMemoryLength > MemOverflow){
-MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & 
MTRR_LIB_CACHE_VALID_ADDRESS) | CacheWriteBack;
+MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & 
ValidMtrrAddressMask) | CacheWriteBack;
 MemoryLength = MaxMemoryLength - MemOverflow;
 MemoryLength = GetPowerOfTwo64 (MemoryLength);
-MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
+MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
 
 MemOverflow += MemoryLength;
 Index++;
@@ -185,15 +216,15 @@ SetPeiCacheMode (
   while (MaxMemoryLength != MemoryLength) {
 MemoryLengthUc = GetPowerOfTwo64 (MaxMemoryLength - MemoryLength);
 
-MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength - 
MemoryLengthUc) & MTRR_LIB_CACHE_VALID_ADDRESS) | CacheUncacheable;
-MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & 
MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
+MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength - 
MemoryLengthUc) & ValidMtrrAddressMask) | CacheUncacheable;
+MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
 MaxMemoryLength -= MemoryLengthUc;
 Index++;
   }
 
   MemOverflow =0x1;
   while (HighMemoryLength > 0) {
-MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & 
MTRR_LIB_CACHE_VALID_ADDRESS) | CacheWriteBack;
+MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & 
ValidMtrrAddressMask) | CacheWriteBack;
 MemoryLength = HighMemoryLength;
 MemoryLength = GetPowerOfTwo64 (MemoryLength);
 
@@ -201,7 +232,7 @@ SetPeiCacheMode (
   MemoryLength = MemOverflow;
 }
 
-MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
+MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
 
 MemOverflow += MemoryLength;
 HighMemoryLength -= MemoryLength;
-- 
2.7.0.windows.1

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


[edk2] [Patch 5/7] Vlv2TbltDevicePkg: Remove reference deprecated macro.

2017-08-03 Thread Eric Dong
Cc: Jeff Fan 
Cc: Ruiyu Ni 
Cc: David Wei 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c 
b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
index 5a18a3f..53d5802 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
@@ -31,6 +31,8 @@ Abstract:
 #define  PEI_MIN_MEMORY_SIZE   (6 * 0x80)
 #define  PEI_RECOVERY_MIN_MEMORY_SIZE  (6 * 0x80)
 
+#define  CACHE_MTRR_ENABLED 0x800
+
 //
 // This is the memory needed for PEI to start up DXE.
 //
@@ -197,7 +199,7 @@ SetPeiCacheMode (
   //
   Index = 0;
   MtrrSetting.Variables.Mtrr[0].Base = (FixedPcdGet32 
(PcdFlashAreaBaseAddress) | CacheWriteProtected);
-  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 
(PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 
(PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask) | CACHE_MTRR_ENABLED;
   Index ++;
 
   MemOverflow =0;
@@ -205,7 +207,7 @@ SetPeiCacheMode (
 MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & 
ValidMtrrAddressMask) | CacheWriteBack;
 MemoryLength = MaxMemoryLength - MemOverflow;
 MemoryLength = GetPowerOfTwo64 (MemoryLength);
-MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
ValidMtrrAddressMask) | CACHE_MTRR_ENABLED;
 
 MemOverflow += MemoryLength;
 Index++;
@@ -217,7 +219,7 @@ SetPeiCacheMode (
 MemoryLengthUc = GetPowerOfTwo64 (MaxMemoryLength - MemoryLength);
 
 MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength - 
MemoryLengthUc) & ValidMtrrAddressMask) | CacheUncacheable;
-MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & 
ValidMtrrAddressMask) | CACHE_MTRR_ENABLED;
 MaxMemoryLength -= MemoryLengthUc;
 Index++;
   }
@@ -232,7 +234,7 @@ SetPeiCacheMode (
   MemoryLength = MemOverflow;
 }
 
-MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & 
ValidMtrrAddressMask) | CACHE_MTRR_ENABLED;
 
 MemOverflow += MemoryLength;
 HighMemoryLength -= MemoryLength;
-- 
2.7.0.windows.1

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


[edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.

2017-08-03 Thread Eric Dong
Cc: Jeff Fan 
Cc: Ruiyu Ni 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c| 26 +-
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c 
b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
index 2760427..fe00b37 100644
--- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
+++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
@@ -23,6 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #define QUARK_SOC_CPUID_FAMILY_MODEL_STEPPING 0x590
 
+#define CACHE_MTRR_ENABLED0x800
+#define CACHE_FIXED_MTRR_ENABLED  0x400
+#define IA32_MTRR_CAP_VCNT_MASK   0xFF
+
 //
 // Context to save and restore when MTRRs are programmed
 //
@@ -121,7 +125,7 @@ GetVariableMtrrCountWorker (
 {
   UINT32  VariableMtrrCount;
 
-  VariableMtrrCount = (UINT32)(MtrrRegisterRead 
(QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) & MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
+  VariableMtrrCount = (UINT32)(MtrrRegisterRead 
(QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) & IA32_MTRR_CAP_VCNT_MASK);
   ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
   return VariableMtrrCount;
 }
@@ -558,7 +562,7 @@ MtrrGetMemoryAttributeInVariableMtrrWorker (
 
   ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) * 
MTRR_NUMBER_OF_VARIABLE_MTRR);
   for (Index = 0, UsedMtrr = 0; Index < FirmwareVariableMtrrCount; Index++) {
-if ((VariableSettings->Mtrr[Index].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) != 
0) {
+if ((VariableSettings->Mtrr[Index].Mask & CACHE_MTRR_ENABLED) != 0) {
   VariableMtrr[Index].Msr = (UINT32)Index;
   VariableMtrr[Index].BaseAddress = (VariableSettings->Mtrr[Index].Base & 
MtrrValidAddressMask);
   VariableMtrr[Index].Length  = ((~(VariableSettings->Mtrr[Index].Mask 
& MtrrValidAddressMask)) & MtrrValidBitsMask) + 1;
@@ -969,7 +973,7 @@ ProgramVariableMtrr (
   // MTRR Physical Mask
   //
   TempQword = ~(Length - 1);
-  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword & MtrrValidAddressMask) 
| MTRR_LIB_CACHE_MTRR_ENABLED;
+  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword & MtrrValidAddressMask) 
| CACHE_MTRR_ENABLED;
 }
 
 
@@ -1157,7 +1161,7 @@ MtrrGetMemoryAttributeByAddressWorker (
   }
   MtrrType = MTRR_CACHE_INVALID_TYPE;
 
-  if ((TempQword & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
+  if ((TempQword & CACHE_MTRR_ENABLED) == 0) {
 return CacheUncacheable;
   }
 
@@ -1165,7 +1169,7 @@ MtrrGetMemoryAttributeByAddressWorker (
   // If address is less than 1M, then try to go through the fixed MTRR
   //
   if (Address < BASE_1MB) {
-if ((TempQword & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED) != 0) {
+if ((TempQword & CACHE_FIXED_MTRR_ENABLED) != 0) {
   //
   // Go through the fixed MTRR
   //
@@ -1539,7 +1543,7 @@ MtrrSetMemoryAttributeWorker (
   }
   if (MtrrSetting != NULL) {
 MtrrSetting->Fixed.Mtrr[MsrNum] = (MtrrSetting->Fixed.Mtrr[MsrNum] & 
~ClearMask) | OrMask;
-MtrrSetting->MtrrDefType |= MTRR_LIB_CACHE_FIXED_MTRR_ENABLED;
+MtrrSetting->MtrrDefType |= CACHE_FIXED_MTRR_ENABLED;
   } else {
 if (!FixedSettingsValid[MsrNum]) {
   WorkingFixedSettings.Mtrr[MsrNum] = MtrrRegisterRead 
(mMtrrLibFixedMtrrTable[MsrNum].Msr);
@@ -1654,7 +1658,7 @@ MtrrSetMemoryAttributeWorker (
   // Find first unused MTRR
   //
   for (MsrNum = 0; MsrNum < VariableMtrrCount; MsrNum++) {
-if ((VariableSettings->Mtrr[MsrNum].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) == 
0) {
+if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED) == 0) {
   break;
 }
   }
@@ -1674,7 +1678,7 @@ MtrrSetMemoryAttributeWorker (
   // Find unused MTRR
   //
   for (; MsrNum < VariableMtrrCount; MsrNum++) {
-if ((VariableSettings->Mtrr[MsrNum].Mask & 
MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
+if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED) == 0) {
   break;
 }
   }
@@ -1705,7 +1709,7 @@ MtrrSetMemoryAttributeWorker (
 // Find unused MTRR
 //
 for (; MsrNum < VariableMtrrCount; MsrNum++) {
-  if ((VariableSettings->Mtrr[MsrNum].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) 
== 0) {
+  if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED) == 0) {
 break;
   }
 }
@@ -1728,7 +1732,7 @@ MtrrSetMemoryAttributeWorker (
 // Find unused MTRR
 //
 for (; MsrNum < VariableMtrrCount; MsrNum++) {
-  if ((VariableSettings->Mtrr[MsrNum].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) 
== 0) {
+  if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED) == 0) {
 break;
   }
 }
@@ -1801,7 +1805,7 @@ Done:
   DEBUG((DEBUG_CACHE, "  Status = %r\n", 

[edk2] [Patch 3/7] UefiCpuPkg CpuDxe: Enhance get mtrr mask logic.

2017-08-03 Thread Eric Dong
In order to not use the deprecated macro, refine
get mtrr mask value logic.

Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/CpuDxe/CpuDxe.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index 8680656..6218670 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -25,8 +25,8 @@
 BOOLEAN   InterruptState = FALSE;
 EFI_HANDLEmCpuHandle = NULL;
 BOOLEAN   mIsFlushingGCD;
-UINT64mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
-UINT64mValidMtrrBitsMask= MTRR_LIB_MSR_VALID_MASK;
+UINT64mValidMtrrAddressMask;
+UINT64mValidMtrrBitsMask;
 UINT64mTimerPeriod = 0;
 
 FIXED_MTRRmFixedMtrrTable[] = {
@@ -510,13 +510,12 @@ InitializeMtrrMask (
 AsmCpuid (0x8008, , NULL, NULL, NULL);
 
 PhysicalAddressBits = (UINT8) RegEax;
-
-mValidMtrrBitsMask= LShiftU64 (1, PhysicalAddressBits) - 1;
-mValidMtrrAddressMask = mValidMtrrBitsMask & 0xf000ULL;
   } else {
-mValidMtrrBitsMask= MTRR_LIB_MSR_VALID_MASK;
-mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
+PhysicalAddressBits = 36;
   }
+
+  mValidMtrrBitsMask= LShiftU64 (1, PhysicalAddressBits) - 1;
+  mValidMtrrAddressMask = mValidMtrrBitsMask & 0xf000ULL;
 }
 
 /**
-- 
2.7.0.windows.1

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


[edk2] [Patch 6/7] UefiCpuPkg CpuDxe: Remove reference deprecated macro.

2017-08-03 Thread Eric Dong
Cc: Jeff Fan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/CpuDxe/CpuDxe.c | 22 +++---
 UefiCpuPkg/CpuDxe/CpuDxe.h |  1 +
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index 6218670..b386f3b 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -31,57 +31,57 @@ UINT64mTimerPeriod = 0;
 
 FIXED_MTRRmFixedMtrrTable[] = {
   {
-MTRR_LIB_IA32_MTRR_FIX64K_0,
+MSR_IA32_MTRR_FIX64K_0,
 0,
 0x1
   },
   {
-MTRR_LIB_IA32_MTRR_FIX16K_8,
+MSR_IA32_MTRR_FIX16K_8,
 0x8,
 0x4000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX16K_A,
+MSR_IA32_MTRR_FIX16K_A,
 0xA,
 0x4000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX4K_C,
+MSR_IA32_MTRR_FIX4K_C,
 0xC,
 0x1000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX4K_C8000,
+MSR_IA32_MTRR_FIX4K_C8000,
 0xC8000,
 0x1000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX4K_D,
+MSR_IA32_MTRR_FIX4K_D,
 0xD,
 0x1000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX4K_D8000,
+MSR_IA32_MTRR_FIX4K_D8000,
 0xD8000,
 0x1000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX4K_E,
+MSR_IA32_MTRR_FIX4K_E,
 0xE,
 0x1000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX4K_E8000,
+MSR_IA32_MTRR_FIX4K_E8000,
 0xE8000,
 0x1000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX4K_F,
+MSR_IA32_MTRR_FIX4K_F,
 0xF,
 0x1000
   },
   {
-MTRR_LIB_IA32_MTRR_FIX4K_F8000,
+MSR_IA32_MTRR_FIX4K_F8000,
 0xF8000,
 0x1000
   },
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h
index 27ad45b..4861abe 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.h
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
-- 
2.7.0.windows.1

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


[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] Enable source level debug.

2017-08-03 Thread zwei4
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: zwei4 
---
 Platform/BroxtonPlatformPkg/BuildBios.bat |  2 +-
 .../PlatformDsc/Components.IA32.dsc   |  3 +++
 .../BroxtonPlatformPkg/PlatformDsc/Components.dsc |  4 
 Platform/BroxtonPlatformPkg/PlatformDsc/Defines.dsc   |  5 +
 .../PlatformDsc/LibraryClasses.DxeCore.dsc|  6 ++
 .../PlatformDsc/LibraryClasses.DxeRuntimeDriver.dsc   |  6 ++
 .../PlatformDsc/LibraryClasses.DxeSmmDriver.dsc   |  2 ++
 .../PlatformDsc/LibraryClasses.IA32.PEI.dsc   |  6 +-
 .../PlatformDsc/LibraryClasses.SmmCore.dsc|  5 +
 .../BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc | 19 ++-
 .../PlatformDsc/PcdsFixedAtBuild.dsc  |  8 +++-
 Platform/BroxtonPlatformPkg/PlatformPkg.fdf   |  8 
 Platform/BroxtonPlatformPkg/PlatformPkgIA32.dsc   |  6 ++
 Platform/BroxtonPlatformPkg/PlatformPkgX64.dsc|  6 ++
 Platform/BroxtonPlatformPkg/PlatformPkgX64Gcc.dsc |  6 ++
 .../BroxtonSoC/BroxtonSiPkg/Library/GpioLib/GpioLib.c |  4 ++--
 .../BroxtonSiPkg/Txe/Library/HeciMsgLib/HeciMsgLib.c  |  4 ++--
 17 files changed, 80 insertions(+), 20 deletions(-)

diff --git a/Platform/BroxtonPlatformPkg/BuildBios.bat 
b/Platform/BroxtonPlatformPkg/BuildBios.bat
index 2ecc28d6b..7aca17650 100644
--- a/Platform/BroxtonPlatformPkg/BuildBios.bat
+++ b/Platform/BroxtonPlatformPkg/BuildBios.bat
@@ -204,7 +204,7 @@ copy /y nul %Build_Macros% >nul
 
 ::output platform specific build macros to DefineAtBuildMacros.dsc
 echo DEFINE ENBDT_PF_BUILD  = %ENBDT_PF_BUILD%  >> 
%Build_Macros%
-echo DEFINE SOURCE_DEBUG_ENABLE = %SrcDebug%>> 
%Build_Macros%
+
 echo DEFINE APLK_SETUP_ENABLE_BUILD = %APLK_SETUP_ENABLE_BUILD% >> 
%Build_Macros%
 
 if "%Arch%"=="IA32" (
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.IA32.dsc 
b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.IA32.dsc
index bfc45ff2f..1341e082b 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.IA32.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.IA32.dsc
@@ -201,3 +201,6 @@
   $(PLATFORM_PACKAGE_COMMON)/FpdtPei/FpdtPei.inf
 !endif
 
+!if $(SOURCE_DEBUG_ENABLE) == TRUE
+  SourceLevelDebugPkg/DebugAgentPei/DebugAgentPei.inf
+!endif
\ No newline at end of file
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc 
b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc
index 234c27708..04f616c36 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc
@@ -32,6 +32,10 @@
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   }
 
+!if $(SOURCE_DEBUG_ENABLE) == TRUE
+  SourceLevelDebugPkg/DebugAgentDxe/DebugAgentDxe.inf
+!endif
+
   UefiCpuPkg/CpuDxe/CpuDxe.inf {
 
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/Defines.dsc 
b/Platform/BroxtonPlatformPkg/PlatformDsc/Defines.dsc
index 842acf308..69641ced3 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/Defines.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/Defines.dsc
@@ -163,3 +163,8 @@
 DEFINE FSP_RAM_CODE_SIZE   = $(FSP_IBBM_SIZE)
 DEFINE CAR_REGION_SIZE = 0x10
 
+!if $(TARGET) == DEBUG
+  DEFINE SOURCE_DEBUG_ENABLE = TRUE
+!else 
+  DEFINE SOURCE_DEBUG_ENABLE = FALSE
+!endif
\ No newline at end of file
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeCore.dsc 
b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeCore.dsc
index 5ae62d3dc..d60c900e7 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeCore.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeCore.dsc
@@ -30,4 +30,10 @@
 
TimerLib|$(PLATFORM_PACKAGE_COMMON)/Library/PlatformTscTimerLib/DxeTscTimerLib.inf
  !endif
   !endif
+ 
+!if $(SOURCE_DEBUG_ENABLE) == TRUE
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+!else
+  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+!endif
 
diff --git 
a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeRuntimeDriver.dsc 
b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeRuntimeDriver.dsc
index 75c07b151..9e13b6ff2 100644
--- 
a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeRuntimeDriver.dsc
+++ 
b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeRuntimeDriver.dsc
@@ -19,3 +19,9 @@
  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
   !endif
 
+  !if $(SOURCE_DEBUG_ENABLE) == TRUE
+DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+  !else
+DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+  !endif
+
diff --git 

[edk2] [Patch V2 3/4] IntelFrameworkModulePkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined

2017-08-03 Thread Yonghong Zhu
Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Jeff Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish 
---
 .../BaseUefiTianoCustomDecompressLib.c  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
 
b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
index e0ba053..5d64f02 100644
--- 
a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
+++ 
b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
@@ -28,18 +28,18 @@ FillBuf (
   )
 {
   //
   // Left shift NumOfBits of bits in advance
   //
-  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
+  Sd->mBitBuf = (UINT32) LShiftU64 (((UINT64)Sd->mBitBuf), NumOfBits);
 
   //
   // Copy data needed in bytes into mSbuBitBuf
   //
   while (NumOfBits > Sd->mBitCount) {
-
-Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) 
(NumOfBits - Sd->mBitCount)));
+NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount);
+Sd->mBitBuf |= (UINT32) LShiftU64 (((UINT64)Sd->mSubBitBuf), NumOfBits);
 
 if (Sd->mCompSize > 0) {
   //
   // Get 1 byte into SubBitBuf
   //
-- 
2.6.1.windows.1

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


[edk2] [Patch V2 4/4] MdePkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined

2017-08-03 Thread Yonghong Zhu
Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635

Cc: Liming Gao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish 
---
 MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c 
b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
index e3b2846..e818543 100644
--- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
+++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
@@ -38,18 +38,18 @@ FillBuf (
   )
 {
   //
   // Left shift NumOfBits of bits in advance
   //
-  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
+  Sd->mBitBuf = (UINT32) LShiftU64 (((UINT64)Sd->mBitBuf), NumOfBits);
 
   //
   // Copy data needed in bytes into mSbuBitBuf
   //
   while (NumOfBits > Sd->mBitCount) {
-
-Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) 
(NumOfBits - Sd->mBitCount)));
+NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount);
+Sd->mBitBuf |= (UINT32) LShiftU64 (((UINT64)Sd->mSubBitBuf), NumOfBits);
 
 if (Sd->mCompSize > 0) {
   //
   // Get 1 byte into SubBitBuf
   //
-- 
2.6.1.windows.1

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


[edk2] [Patch V2 2/4] DuetPkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined

2017-08-03 Thread Yonghong Zhu
Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635

Cc: Ruiyu Ni 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish 
---
 DuetPkg/EfiLdr/TianoDecompress.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/DuetPkg/EfiLdr/TianoDecompress.c b/DuetPkg/EfiLdr/TianoDecompress.c
index b504e8e..695f516 100644
--- a/DuetPkg/EfiLdr/TianoDecompress.c
+++ b/DuetPkg/EfiLdr/TianoDecompress.c
@@ -91,15 +91,15 @@ Arguments:
 
 Returns: (VOID)
 
 --*/
 {
-  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
+  Sd->mBitBuf = (UINT32) LShiftU64 (((UINT64)Sd->mBitBuf), NumOfBits);
 
   while (NumOfBits > Sd->mBitCount) {
-
-Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) 
(NumOfBits - Sd->mBitCount)));
+NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount);
+Sd->mBitBuf |= (UINT32) LShiftU64 (((UINT64)Sd->mSubBitBuf), NumOfBits);
 
 if (Sd->mCompSize > 0) {
   //
   // Get 1 byte into SubBitBuf
   //
-- 
2.6.1.windows.1

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


[edk2] [Patch V2 1/4] BaseTools: Fix Xcode 9 Beta treating 32-bit left shift as undefined

2017-08-03 Thread Yonghong Zhu
Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635

Cc: Liming Gao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish 
---
 BaseTools/Source/C/Common/Decompress.c   | 4 ++--
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/Common/Decompress.c 
b/BaseTools/Source/C/Common/Decompress.c
index 4b83e88..b2049bd 100644
--- a/BaseTools/Source/C/Common/Decompress.c
+++ b/BaseTools/Source/C/Common/Decompress.c
@@ -87,15 +87,15 @@ Arguments:
 
 Returns: (VOID)
 
 --*/
 {
-  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
+  Sd->mBitBuf = (UINT32) (((UINT64)Sd->mBitBuf) << NumOfBits);
 
   while (NumOfBits > Sd->mBitCount) {
 
-Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) 
(NumOfBits - Sd->mBitCount)));
+Sd->mBitBuf |= (UINT32) (((UINT64)Sd->mSubBitBuf) << (NumOfBits = (UINT16) 
(NumOfBits - Sd->mBitCount)));
 
 if (Sd->mCompSize > 0) {
   //
   // Get 1 byte into SubBitBuf
   //
diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c 
b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index f810511..046fb36 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -2064,15 +2064,15 @@ Arguments:
 
 Returns: (VOID)
 
 --*/
 {
-  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
+  Sd->mBitBuf = (UINT32) (((UINT64)Sd->mBitBuf) << NumOfBits);
 
   while (NumOfBits > Sd->mBitCount) {
 
-Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) 
(NumOfBits - Sd->mBitCount)));
+Sd->mBitBuf |= (UINT32) (((UINT64)Sd->mSubBitBuf) << (NumOfBits = (UINT16) 
(NumOfBits - Sd->mBitCount)));
 
 if (Sd->mCompSize > 0) {
   //
   // Get 1 byte into SubBitBuf
   //
-- 
2.6.1.windows.1

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


[edk2] [Patch V2 0/4] Fix Xcode 9 Beta treating 32-bit left shift as undefined behavior

2017-08-03 Thread Yonghong Zhu
V2:
 Fix build MdeModulePkg failure by use LShiftU64() rather than << operator.

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

Yonghong Zhu (4):
  BaseTools: Fix Xcode 9 Beta treating 32-bit left shift as undefined
  DuetPkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined
  IntelFrameworkModulePkg: Fix Xcode 9 Beta treating 32-bit left shift
as undefined
  MdePkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined

 BaseTools/Source/C/Common/Decompress.c  | 4 ++--
 BaseTools/Source/C/TianoCompress/TianoCompress.c| 4 ++--
 DuetPkg/EfiLdr/TianoDecompress.c| 6 +++---
 .../BaseUefiTianoCustomDecompressLib.c  | 6 +++---
 MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c| 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)

-- 
2.6.1.windows.1

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


Re: [edk2] [Patch] NetworkPkg/HttpDxe: Support HTTP Patch method

2017-08-03 Thread Ye, Ting
Reviewed-by: Ye Ting  

-Original Message-
From: Wu, Jiaxin 
Sent: Wednesday, August 02, 2017 4:01 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: [Patch] NetworkPkg/HttpDxe: Support HTTP Patch method

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c 
index 8a9e573..e0fecac 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -274,14 +274,15 @@ EfiHttpRequest (
   }
 
   Request = HttpMsg->Data.Request;
 
   //
-  // Only support GET, HEAD, PUT and POST method in current implementation.
+  // Only support GET, HEAD, PATCH, PUT and POST method in current 
implementation.
   //
   if ((Request != NULL) && (Request->Method != HttpMethodGet) &&
-  (Request->Method != HttpMethodHead) && (Request->Method != 
HttpMethodPut) && (Request->Method != HttpMethodPost)) {
+  (Request->Method != HttpMethodHead) && (Request->Method != 
HttpMethodPut) && 
+  (Request->Method != HttpMethodPost) && (Request->Method != 
+ HttpMethodPatch)) {
 return EFI_UNSUPPORTED;
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
   ASSERT (HttpInstance != NULL);
@@ -297,18 +298,20 @@ EfiHttpRequest (
 return EFI_NOT_STARTED;
   }
 
   if (Request == NULL) {
 //
-// Request would be NULL only for PUT/POST operation (in the current 
implementation)
+// Request would be NULL only for PUT/POST/PATCH operation (in the 
+ current implementation)
 //
-if ((HttpInstance->Method != HttpMethodPut) && (HttpInstance->Method != 
HttpMethodPost)) {
+if ((HttpInstance->Method != HttpMethodPut) && 
+(HttpInstance->Method != HttpMethodPost) && 
+(HttpInstance->Method != HttpMethodPatch)) {
   return EFI_INVALID_PARAMETER;
 }
 
 //
-// For PUT/POST, we need to have the TCP already configured. Bail out if 
it is not!
+// For PUT/POST/PATCH, we need to have the TCP already configured. Bail 
out if it is not!
 //
 if (HttpInstance->State < HTTP_STATE_TCP_CONFIGED) {
   return EFI_INVALID_PARAMETER;
 }
 
@@ -615,11 +618,11 @@ EfiHttpRequest (
 
   ASSERT (RequestMsg != NULL);
 
   //
   // Every request we insert a TxToken and a response call would remove the 
TxToken.
-  // In cases of PUT/POST, after an initial request-response pair, we would do 
a
+  // In cases of PUT/POST/PATCH, after an initial request-response 
+ pair, we would do a
   // continuous request without a response call. So, in such cases, where 
Request
   // structure is NULL, we would not insert a TxToken.
   //
   if (Request != NULL) {
 Status = NetMapInsertTail (>TxTokens, Token, Wrap); @@ 
-,11 +1114,11 @@ HttpResponseWorker (
 
 Status = EFI_NOT_READY;
 ValueInItem = NULL;
 
 //
-// In cases of PUT/POST, after an initial request-response pair, we would 
do a
+// In cases of PUT/POST/PATCH, after an initial request-response 
+ pair, we would do a
 // continuous request without a response call. So, we would not do an 
insert of
 // TxToken. After we have sent the complete file, we will call a response 
to get
 // a final response from server. In such a case, we would not have any 
TxTokens.
 // Hence, check that case before doing a NetMapRemoveHead.
 //
--
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] NetworkPkg: iSCSI should allow to set 6 or 12 length of ISID keyword.

2017-08-03 Thread Fu, Siyuan
Ting, 

Thanks, I will update it when commit the patch.

Siyuan

-Original Message-
From: Ye, Ting 
Sent: Thursday, August 3, 2017 4:37 PM
To: Fu, Siyuan ; edk2-devel@lists.01.org
Cc: Wu, Jiaxin 
Subject: RE: [edk2] [Patch] NetworkPkg: iSCSI should allow to set 6 or 12 
length of ISID keyword.

Hi Siyuan,

I would suggest to add more info to below error message, such as below:

Error! Only last 3 bytes are configurable, please input 6  hex numbers for last 
3 bytes only or 12 hex numbers for full SSID!

+  L"Error! Only last 3 bytes are configurable, please input 6 or 12 hex 
numbers!\n"

Others are good to me.

Reviewed-by: Ye Ting  

Thanks,
Ting

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Fu Siyuan
Sent: Thursday, August 03, 2017 2:41 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Wu, Jiaxin 
Subject: [edk2] [Patch] NetworkPkg: iSCSI should allow to set 6 or 12 length of 
ISID keyword.

The last 3 bytes of ISID should be able to changed by setting the keyword with 
a value with length 6 (only last 3 bytes) or 12 (full ISID) according to the 
keyword definition in UEFI configuration namespace website.

Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c  | 8 ++--
 NetworkPkg/IScsiDxe/IScsiConfigStrings.uni | 1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c| 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index a588403..4bc9b8f 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -205,11 +205,11 @@ IScsiParseIsIdFromString (
 
   IsIdStr = (CHAR16 *) String;
 
-  if (StrLen (IsIdStr) != 6) {
+  if (StrLen (IsIdStr) != 6 && StrLen (IsIdStr) != 12) {
 UnicodeSPrint (
   PortString,
   (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
-  L"Error! Input is incorrect, please input 6 hex numbers!\n"
+  L"Error! Only last 3 bytes are configurable, please input 6 or 12 hex 
numbers!\n"
   );
 
 CreatePopUp (
@@ -222,6 +222,10 @@ IScsiParseIsIdFromString (
 return EFI_INVALID_PARAMETER;
   }
 
+  if (StrLen (IsIdStr) == 12) {
+IsIdStr += 6;
+  }
+
   for (Index = 3; Index < 6; Index++) {
 CopyMem (TempStr, IsIdStr, sizeof (TempStr));
 TempStr[2] = L'\0';
diff --git a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni 
b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
index 7952258..10583f8 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
+++ b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
@@ -99,3 +99,4 @@
 #language x-UEFI-ns 
"iSCSIDisplayAttemptList"
 #string STR_ISCSI_ATTEMPT_ORDER #language en-US "New Attempt Order"
 #language x-UEFI-ns "iSCSIAttemptOrder"
+#string STR_ISCSI_ISID_HELP #language en-US "The iSCSI ISID. 
Default value are derived from MAC address. Only last 3 bytes are configurable."
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c 
index 2c93590..e20fe91 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -952,7 +952,7 @@ IScsiCreateKeywords (
   CONFIGURATION_VARSTORE_ID,
   (UINT16) (ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
   StringToken,
-  StringToken,
+  STRING_TOKEN (STR_ISCSI_ISID_HELP),
   0,
   0,
   ISID_CONFIGURABLE_MIN_LEN,
--
1.9.5.msysgit.1

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


Re: [edk2] [Patch] NetworkPkg: iSCSI should allow to set 6 or 12 length of ISID keyword.

2017-08-03 Thread Ye, Ting
Hi Siyuan,

I would suggest to add more info to below error message, such as below:

Error! Only last 3 bytes are configurable, please input 6  hex numbers for last 
3 bytes only or 12 hex numbers for full SSID!

+  L"Error! Only last 3 bytes are configurable, please input 6 or 12 hex 
numbers!\n"

Others are good to me.

Reviewed-by: Ye Ting  

Thanks,
Ting

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Fu Siyuan
Sent: Thursday, August 03, 2017 2:41 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Wu, Jiaxin 
Subject: [edk2] [Patch] NetworkPkg: iSCSI should allow to set 6 or 12 length of 
ISID keyword.

The last 3 bytes of ISID should be able to changed by setting the keyword with 
a value with length 6 (only last 3 bytes) or 12 (full ISID) according to the 
keyword definition in UEFI configuration namespace website.

Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c  | 8 ++--
 NetworkPkg/IScsiDxe/IScsiConfigStrings.uni | 1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c| 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index a588403..4bc9b8f 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -205,11 +205,11 @@ IScsiParseIsIdFromString (
 
   IsIdStr = (CHAR16 *) String;
 
-  if (StrLen (IsIdStr) != 6) {
+  if (StrLen (IsIdStr) != 6 && StrLen (IsIdStr) != 12) {
 UnicodeSPrint (
   PortString,
   (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
-  L"Error! Input is incorrect, please input 6 hex numbers!\n"
+  L"Error! Only last 3 bytes are configurable, please input 6 or 12 hex 
numbers!\n"
   );
 
 CreatePopUp (
@@ -222,6 +222,10 @@ IScsiParseIsIdFromString (
 return EFI_INVALID_PARAMETER;
   }
 
+  if (StrLen (IsIdStr) == 12) {
+IsIdStr += 6;
+  }
+
   for (Index = 3; Index < 6; Index++) {
 CopyMem (TempStr, IsIdStr, sizeof (TempStr));
 TempStr[2] = L'\0';
diff --git a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni 
b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
index 7952258..10583f8 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
+++ b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
@@ -99,3 +99,4 @@
 #language x-UEFI-ns 
"iSCSIDisplayAttemptList"
 #string STR_ISCSI_ATTEMPT_ORDER #language en-US "New Attempt Order"
 #language x-UEFI-ns "iSCSIAttemptOrder"
+#string STR_ISCSI_ISID_HELP #language en-US "The iSCSI ISID. 
Default value are derived from MAC address. Only last 3 bytes are configurable."
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c 
index 2c93590..e20fe91 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -952,7 +952,7 @@ IScsiCreateKeywords (
   CONFIGURATION_VARSTORE_ID,
   (UINT16) (ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
   StringToken,
-  StringToken,
+  STRING_TOKEN (STR_ISCSI_ISID_HELP),
   0,
   0,
   ISID_CONFIGURABLE_MIN_LEN,
--
1.9.5.msysgit.1

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


Re: [edk2] [Patch] NetworkPkg: Display HTTP redirection info to the screen if need.

2017-08-03 Thread Ye, Ting
Reviewed-by: Ye Ting  

-Original Message-
From: Fu, Siyuan 
Sent: Thursday, July 27, 2017 11:44 AM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Wu, Jiaxin 
Subject: [Patch] NetworkPkg: Display HTTP redirection info to the screen if 
need.

HTTP defines a set of status code for redirecting a request to a different URI 
in Section 6.4 of RFC7231 and also RFC7583. This patch updates the HTTP boot 
driver to display the redirection info to the screen so the user would have 
chance to know new URI address of the HTTP boot image.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootDxe.h |  4 
 NetworkPkg/HttpBootDxe/HttpBootImpl.c| 21 -
 NetworkPkg/HttpBootDxe/HttpBootSupport.c | 25 -  
NetworkPkg/HttpBootDxe/HttpBootSupport.h | 13 +
 4 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.h 
b/NetworkPkg/HttpBootDxe/HttpBootDxe.h
index 8d89b3e..4632ee2 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.h
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.h
@@ -179,6 +179,10 @@ struct _HTTP_BOOT_PRIVATE_DATA {
   UINT32Id;
   EFI_HTTP_BOOT_CALLBACK_PROTOCOL   *HttpBootCallback;
   EFI_HTTP_BOOT_CALLBACK_PROTOCOL   LoadFileCallback;
+
+  //
+  // Data for the default HTTP Boot callback protocol  //
   UINT64FileSize;
   UINT64ReceivedSize;
   UINT32Percentage;
diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c 
b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index 63cf396..5cfb0f4 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -1,7 +1,7 @@
 /** @file
   The implementation of EFI_LOAD_FILE_PROTOCOL for UEFI HTTP boot.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP  This program 
and the accompanying materials are licensed and made available under  the terms 
and conditions of the BSD License that accompanies this distribution.  
@@ -665,6 +665,25 @@ HttpBootCallback (
   case HttpBootHttpResponse:
 if (Data != NULL) {
   HttpMessage = (EFI_HTTP_MESSAGE *) Data;
+  
+  if (HttpMessage->Data.Response != NULL) {
+if (HttpBootIsHttpRedirectStatusCode 
(HttpMessage->Data.Response->StatusCode)) {
+  //
+  // Server indicates the resource has been redirected to a different 
URL
+  // according to the section 6.4 of RFC7231 and the RFC 7538.
+  // Display the redirect information on the screen.
+  //
+  HttpHeader = HttpFindHeader (
+ HttpMessage->HeaderCount,
+ HttpMessage->Headers,
+ HTTP_HEADER_LOCATION
+ );
+  if (HttpHeader != NULL) {
+Print (L"\n  HTTP ERROR: Resource Redirected.\n  New Location: 
%a\n", HttpHeader->FieldValue);
+  }
+}
+  }
+  
   HttpHeader = HttpFindHeader (
  HttpMessage->HeaderCount,
  HttpMessage->Headers, diff --git 
a/NetworkPkg/HttpBootDxe/HttpBootSupport.c 
b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index 5024f2e..6d4edfc 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -1034,7 +1034,8 @@ HttpIoRecvResponse (
 HttpIo->IsRxDone = FALSE;
   }
 
-  if (!EFI_ERROR (HttpIo->RspToken.Status) && HttpIo->Callback != NULL) {
+  if ((HttpIo->Callback != NULL) && 
+  (HttpIo->RspToken.Status == EFI_SUCCESS || 
+ HttpIo->RspToken.Status == EFI_HTTP_ERROR)) {
 Status = HttpIo->Callback (
HttpIoResponse,
HttpIo->RspToken.Message, @@ -1319,3 +1320,25 @@ 
HttpBootRegisterRamDisk (
   return Status;
 }
 
+/**
+  Indicate if the HTTP status code indicates a redirection.
+  
+  @param[in]  StatusCode  HTTP status code from server.
+
+  @return TRUE if it's redirection.
+
+**/
+BOOLEAN
+HttpBootIsHttpRedirectStatusCode (
+  IN   EFI_HTTP_STATUS_CODEStatusCode
+ )
+{
+  if (StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY ||
+  StatusCode == HTTP_STATUS_302_FOUND ||
+  StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT ||
+  StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT) {
+return TRUE;
+  }
+
+  return FALSE;
+}
diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.h 
b/NetworkPkg/HttpBootDxe/HttpBootSupport.h
index f2b1846..c10b2cf 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.h
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.h
@@ -445,4 +445,17 @@ HttpBootRegisterRamDisk (
   IN 

[edk2] [Patch] NetworkPkg: iSCSI should allow to set 6 or 12 length of ISID keyword.

2017-08-03 Thread Fu Siyuan
The last 3 bytes of ISID should be able to changed by setting the keyword with
a value with length 6 (only last 3 bytes) or 12 (full ISID) according to the
keyword definition in UEFI configuration namespace website.

Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c  | 8 ++--
 NetworkPkg/IScsiDxe/IScsiConfigStrings.uni | 1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c| 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index a588403..4bc9b8f 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -205,11 +205,11 @@ IScsiParseIsIdFromString (
 
   IsIdStr = (CHAR16 *) String;
 
-  if (StrLen (IsIdStr) != 6) {
+  if (StrLen (IsIdStr) != 6 && StrLen (IsIdStr) != 12) {
 UnicodeSPrint (
   PortString,
   (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
-  L"Error! Input is incorrect, please input 6 hex numbers!\n"
+  L"Error! Only last 3 bytes are configurable, please input 6 or 12 hex 
numbers!\n"
   );
 
 CreatePopUp (
@@ -222,6 +222,10 @@ IScsiParseIsIdFromString (
 return EFI_INVALID_PARAMETER;
   }
 
+  if (StrLen (IsIdStr) == 12) {
+IsIdStr += 6;
+  }
+
   for (Index = 3; Index < 6; Index++) {
 CopyMem (TempStr, IsIdStr, sizeof (TempStr));
 TempStr[2] = L'\0';
diff --git a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni 
b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
index 7952258..10583f8 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
+++ b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
@@ -99,3 +99,4 @@
 #language x-UEFI-ns 
"iSCSIDisplayAttemptList"
 #string STR_ISCSI_ATTEMPT_ORDER #language en-US "New Attempt Order"
 #language x-UEFI-ns "iSCSIAttemptOrder"
+#string STR_ISCSI_ISID_HELP #language en-US "The iSCSI ISID. 
Default value are derived from MAC address. Only last 3 bytes are configurable."
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index 2c93590..e20fe91 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -952,7 +952,7 @@ IScsiCreateKeywords (
   CONFIGURATION_VARSTORE_ID,
   (UINT16) (ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
   StringToken,
-  StringToken,
+  STRING_TOKEN (STR_ISCSI_ISID_HELP),
   0,
   0,
   ISID_CONFIGURABLE_MIN_LEN,
-- 
1.9.5.msysgit.1

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


[edk2] [PATCH v2] MdeModulePkg/DisplayEngine: Fix incorrect display issue

2017-08-03 Thread Dandan Bi
V2: Refine the codes to make the logic clear.

In a form, some new menus may be dynamically inserted between highlight
menu and previous top of screen menu when some question are refreshed.
So the highlight menu and previous top of screen menu perhaps can't be
shown in one page. Existing codes miss to handle this case then will
cause incorrect display.This patch is to fix this display issue.

Cc: Eric Dong 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 .../Universal/DisplayEngineDxe/FormDisplay.c   | 60 ++
 1 file changed, 51 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c 
b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
index dc4ae4b..b6e14bf 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
@@ -1716,27 +1716,60 @@ IsTopOfScreeMenuOption (
 
   return FALSE;
 }
 
 /**
-  Find the Top of screen menu.
+  Calculate the distance between two menus and include the skip value of 
StartMenu.
 
-  If the input is NULL, base on the record highlight info in
-  gHighligthMenuInfo to find the last highlight menu.
+  @param  StartMenu The link_entry pointer to start menu.
+  @param  EndMenu   The link_entry pointer to end menu.
 
-  @param  HighLightedStatement  The input highlight statement.
+**/
+UINTN
+GetDistanceBetweenMenus(
+  IN LIST_ENTRY  *StartMenu,
+  IN LIST_ENTRY  *EndMenu
+)
+{
+  LIST_ENTRY *Link;
+  UI_MENU_OPTION *MenuOption;
+  UINTN  Distance;
 
-  @retval  The highlight menu index.
+  Distance = 0;
+
+  Link = StartMenu;
+  while (Link != EndMenu) {
+MenuOption = MENU_OPTION_FROM_LINK (Link);
+if (MenuOption->Row == 0) {
+  UpdateOptionSkipLines (MenuOption);
+}
+Distance += MenuOption->Skip;
+Link = Link->BackLink;
+  }
+  return Distance;
+}
+
+/**
+  Find the top of screen menu base on the previous record menu info.
+
+  @param  HighLightMenu  The link_entry pointer to highlight menu.
+
+  @retval  Return the the link_entry pointer top of screen menu.
 
 **/
 LIST_ENTRY *
 FindTopOfScreenMenuOption (
- VOID
- )
+  IN LIST_ENTRY   *HighLightMenu
+  )
 {
   LIST_ENTRY  *NewPos;
   UI_MENU_OPTION  *MenuOption;
+  UINTN   TopRow;
+  UINTN   BottomRow;
+
+  TopRow= gStatementDimensions.TopRow+ SCROLL_ARROW_HEIGHT;
+  BottomRow = gStatementDimensions.BottomRow - SCROLL_ARROW_HEIGHT;
 
   NewPos = gMenuOption.ForwardLink;
   MenuOption = MENU_OPTION_FROM_LINK (NewPos);
 
   while (!IsTopOfScreeMenuOption(MenuOption)) {
@@ -1754,10 +1787,19 @@ FindTopOfScreenMenuOption (
   // Last time top of screen menu has disappeared.
   //
   if (NewPos == ) {
 NewPos = NULL;
   }
+  //
+  // Check whether highlight menu and top of screen menu can be shown within 
one page,
+  // if can't, return NULL to re-calcaulate the top of scrren menu. Because 
some new menus
+  // may be dynamically inserted between highlightmenu and previous top of 
screen menu,
+  // So previous record top of screen menu is not appropriate for current 
display.
+  //
+  if (GetDistanceBetweenMenus (HighLightMenu, NewPos) + 1 > BottomRow - 
TopRow) {
+NewPos = NULL;
+  }
 
   return NewPos;
 }
 
 /**
@@ -1803,11 +1845,11 @@ FindTopMenu (
   UpdateOptionSkipLines (MenuOption);
 
   //
   // Found the last time highlight menu.
   //
-  *TopOfScreen = FindTopOfScreenMenuOption();
+  *TopOfScreen = FindTopOfScreenMenuOption(*HighlightMenu);
   if (*TopOfScreen != NULL) {
 //
 // Found the last time selectable top of screen menu.
 //
 AdjustDateAndTimePosition(TRUE, TopOfScreen);
@@ -1856,11 +1898,11 @@ FindTopMenu (
   // Update skip info for this highlight menu.
   //
   MenuOption = MENU_OPTION_FROM_LINK (*HighlightMenu);
   UpdateOptionSkipLines (MenuOption);
   
-  *TopOfScreen = FindTopOfScreenMenuOption();
+  *TopOfScreen = FindTopOfScreenMenuOption(*HighlightMenu);
   if (*TopOfScreen == NULL) {
 //
 // Not found last time top of screen menu, so base on current 
highlight menu
 // to find the new top of screen menu.
 // Make the current highlight menu at the bottom of the form to 
calculate the
-- 
1.9.5.msysgit.1

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